diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 397a4c3e..00000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,64 +0,0 @@ -name: Build - -on: [push, pull_request] - -jobs: - build-host: - env: - MACOSX_DEPLOYMENT_TARGET: 10.14 - strategy: - fail-fast: false - matrix: - include: - - name: macOS - os: macos-latest - artifact: true - autotools: true - cmake: true - - name: Ubuntu - os: ubuntu-latest - artifact: true - autotools: true - cmake: true - - name: MSVC - os: windows-latest - cmake: true - - name: "Build - ${{ matrix.name }}" - runs-on: ${{ matrix.os }} - steps: - - uses: actions/checkout@v6 - - name: Install autotools - if: ${{ matrix.autotools }} - run: | - if [ "$RUNNER_OS" == "macOS" ]; then - brew update - brew install automake autoconf - fi - - name: Autogen (autotools) - if: ${{ matrix.autotools }} - run: ./autogen.sh - - name: Build (autotools) - if: ${{ matrix.autotools }} - run: make - - name: Check (autotools) - if: ${{ matrix.autotools }} - run: make check - - name: Dist (autotools) - id: make-dist - if: ${{ matrix.autotools }} - run: make dist - - - name: Configure (CMake) - if: ${{ matrix.cmake }} - run: cmake -S . -B build - - name: Build (CMake) - if: ${{ matrix.cmake }} - run: cmake --build build - - - uses: actions/upload-artifact@v7 - if: ${{ matrix.artifact && always() && steps.make-dist.outcome == 'success' }} - with: - name: ${{ matrix.name }} - path: yasm-*.tar.gz - diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 97d43572..00000000 --- a/.gitignore +++ /dev/null @@ -1,64 +0,0 @@ -autom4te.cache -stamp-h* -libyasm-stdint.h -nasm-token.c -nasm-macros.c -yapp-token.c -gas-token.c -license.c -module.c -x86parse.c -lc3bid.c -re2c-parser.c -re2c-parser.h -cleanup -test_hd -version.mac -*_test -configure -configure.scan -configure.lineno -./config.* -aclocal.m4 -*.tar.gz -*.la -*.lo -*.o -*.a -.libs -.deps -libtool -*.bb -*.bbg -*.da -results -./Makefile -Makefile.in -.*.swp -python-setup.txt -yasm_python.c -.python-build -_yasm.pxi -yasm.pyx -build -yasm.so -x86cpu.c -x86insn_nasm.gperf -x86insn_nasm.c -x86insn_gas.gperf -x86insn_gas.c -x86insns.c -x86regtmod.c -nasm-version.c -win64-gas.c -win64-nasm.c -YASM-VERSION-FILE -YASM-VERSION.h -.sw* -./*.s -./*.asm -x64 -*.log -*.trs -.dirstamp -*.user diff --git a/ABOUT-NLS b/ABOUT-NLS index b1de1b68..ec20977e 100644 --- a/ABOUT-NLS +++ b/ABOUT-NLS @@ -18,7 +18,35 @@ explain how users should proceed for getting the programs to use the available translations. They tell how people wanting to contribute and work on translations can contact the appropriate team. -1.1 INSTALL Matters + When reporting bugs in the `intl/' directory or bugs which may be +related to internationalization, you should tell about the version of +`gettext' which is used. The information can be found in the +`intl/VERSION' file, in internationalized packages. + +1.1 Quick configuration advice +============================== + +If you want to exploit the full power of internationalization, you +should configure it using + + ./configure --with-included-gettext + +to force usage of internationalizing routines provided within this +package, despite the existence of internationalizing capabilities in the +operating system where this package is being installed. So far, only +the `gettext' implementation in the GNU C library version 2 provides as +many features (such as locale alias, message inheritance, automatic +charset conversion or plural form handling) as the implementation here. +It is also not possible to offer this additional functionality on top +of a `catgets' implementation. Future versions of GNU `gettext' will +very likely convey even more functionality. So it might be a good idea +to change to GNU `gettext' as soon as possible. + + So you need _not_ provide this option if you are using GNU libc 2 or +you have installed a recent copy of the GNU gettext package with the +included `libintl'. + +1.2 INSTALL Matters =================== Some packages are "localizable" when properly installed; the programs @@ -28,19 +56,36 @@ internationalization, predating GNU `gettext'. By default, this package will be installed to allow translation of messages. It will automatically detect whether the system already -provides the GNU `gettext' functions. Installers may use special -options at configuration time for changing the default behaviour. The -command: +provides the GNU `gettext' functions. If not, the included GNU +`gettext' library will be used. This library is wholly contained +within this package, usually in the `intl/' subdirectory, so prior +installation of the GNU `gettext' package is _not_ required. +Installers may use special options at configuration time for changing +the default behaviour. The commands: + ./configure --with-included-gettext ./configure --disable-nls -will _totally_ disable translation of messages. +will, respectively, bypass any pre-existing `gettext' to use the +internationalizing routines provided within this package, or else, +_totally_ disable translation of messages. When you already have GNU `gettext' installed on your system and run configure without an option for your new package, `configure' will -probably detect the previously built and installed `libintl' library -and will decide to use it. If not, you may have to to use the -`--with-libintl-prefix' option to tell `configure' where to look for it. +probably detect the previously built and installed `libintl.a' file and +will decide to use this. This might not be desirable. You should use +the more recent version of the GNU `gettext' library. I.e. if the file +`intl/VERSION' shows that the library which comes with this package is +more recent, you should use + + ./configure --with-included-gettext + +to prevent auto-detection. + + The configuration process will not test for the `catgets' function +and therefore it will not be used. The reason is that even an +emulation of `gettext' on top of `catgets' could not provide all the +extensions of the GNU `gettext' library. Internationalized packages usually have many `po/LL.po' files, where LL gives an ISO 639 two-letter code identifying the language. Unless @@ -51,16 +96,13 @@ may be set, prior to configuration, to limit the installed set. `LINGUAS' should then contain a space separated list of two-letter codes, stating which languages are allowed. -1.2 Using This Package +1.3 Using This Package ====================== As a user, if your language has been installed for this package, you only have to set the `LANG' environment variable to the appropriate -`LL_CC' combination. If you happen to have the `LC_ALL' or some other -`LC_xxx' environment variables set, you should unset them before -setting `LANG', otherwise the setting of `LANG' will not have the -desired effect. Here `LL' is an ISO 639 two-letter language code, and -`CC' is an ISO 3166 two-letter country code. For example, let's +`LL_CC' combination. Here `LL' is an ISO 639 two-letter language code, +and `CC' is an ISO 3166 two-letter country code. For example, let's suppose that you speak German and live in Germany. At the shell prompt, merely execute `setenv LANG de_DE' (in `csh'), `export LANG; LANG=de_DE' (in `sh') or `export LANG=de_DE' (in `bash'). @@ -103,7 +145,7 @@ to denote the language's main dialect. For example, `de' is equivalent to `de_DE' (German as spoken in Germany), and `pt' to `pt_PT' (Portuguese as spoken in Portugal) in this context. -1.3 Translating Teams +1.4 Translating Teams ===================== For the Free Translation Project to be a success, we need interested @@ -111,7 +153,8 @@ people who like their own language and write it well, and who are also able to synergize with other translators speaking the same language. Each translation team has its own mailing list. The up-to-date list of teams can be found at the Free Translation Project's homepage, -`http://translationproject.org/', in the "Teams" area. +`http://www.iro.umontreal.ca/contrib/po/HTML/', in the "National teams" +area. If you'd like to volunteer to _work_ at translating messages, you should become a member of the translating team for your own language. @@ -125,1125 +168,901 @@ message to `sv-request@li.org', having this message body: _actively_ in translations, or at solving translational difficulties, rather than merely lurking around. If your team does not exist yet and you want to start one, or if you are unsure about what to do or how to -get started, please write to `coordinator@translationproject.org' to -reach the coordinator for all translator teams. +get started, please write to `translation@iro.umontreal.ca' to reach the +coordinator for all translator teams. The English team is special. It works at improving and uniformizing the terminology in use. Proven linguistic skills are praised more than programming skills, here. -1.4 Available Packages +1.5 Available Packages ====================== Languages are not equally supported in all packages. The following -matrix shows the current state of internationalization, as of June -2010. The matrix shows, in regard of each package, for which languages +matrix shows the current state of internationalization, as of October +2006. The matrix shows, in regard of each package, for which languages PO files have been submitted to translation coordination, with a translation percentage of at least 50%. - Ready PO files af am an ar as ast az be be@latin bg bn_IN bs ca + Ready PO files af am ar az be bg bs ca cs cy da de el en en_GB eo + +----------------------------------------------------+ + GNUnet | [] | + a2ps | [] [] [] [] [] | + aegis | () | + ant-phone | () | + anubis | [] | + ap-utils | | + aspell | [] [] [] [] [] | + bash | [] [] [] | + batchelor | [] | + bfd | | + bibshelf | [] | + binutils | [] | + bison | [] [] | + bison-runtime | | + bluez-pin | [] [] [] [] [] | + cflow | [] | + clisp | [] [] | + console-tools | [] [] | + coreutils | [] [] [] | + cpio | | + cpplib | [] [] [] | + cryptonit | [] | + darkstat | [] () [] | + dialog | [] [] [] [] [] [] | + diffutils | [] [] [] [] [] [] | + doodle | [] | + e2fsprogs | [] [] | + enscript | [] [] [] [] | + error | [] [] [] [] | + fetchmail | [] [] () [] | + fileutils | [] [] | + findutils | [] [] [] | + flex | [] [] [] | + fslint | [] | + gas | | + gawk | [] [] [] | + gbiff | [] | + gcal | [] | + gcc | [] | + gettext-examples | [] [] [] [] [] | + gettext-runtime | [] [] [] [] [] | + gettext-tools | [] [] | + gimp-print | [] [] [] [] | + gip | [] | + gliv | [] | + glunarclock | [] | + gmult | [] [] | + gnubiff | () | + gnucash | () () [] | + gnucash-glossary | [] () | + gnuedu | | + gnulib | [] [] [] [] [] [] | + gnunet-gtk | | + gnutls | | + gpe-aerial | [] [] | + gpe-beam | [] [] | + gpe-calendar | | + gpe-clock | [] [] | + gpe-conf | [] [] | + gpe-contacts | | + gpe-edit | [] | + gpe-filemanager | | + gpe-go | [] | + gpe-login | [] [] | + gpe-ownerinfo | [] [] | + gpe-package | | + gpe-sketchbook | [] [] | + gpe-su | [] [] | + gpe-taskmanager | [] [] | + gpe-timesheet | [] | + gpe-today | [] [] | + gpe-todo | | + gphoto2 | [] [] [] [] | + gprof | [] [] | + gpsdrive | () () | + gramadoir | [] [] | + grep | [] [] [] [] [] [] | + gretl | | + gsasl | | + gss | | + gst-plugins | [] [] [] [] | + gst-plugins-base | [] [] [] | + gst-plugins-good | [] [] [] [] [] [] [] | + gstreamer | [] [] [] [] [] [] [] | + gtick | () | + gtkam | [] [] [] | + gtkorphan | [] [] | + gtkspell | [] [] [] [] | + gutenprint | [] | + hello | [] [] [] [] [] | + id-utils | [] [] | + impost | | + indent | [] [] [] | + iso_3166 | [] [] | + iso_3166_2 | | + iso_4217 | [] | + iso_639 | [] [] | + jpilot | [] | + jtag | | + jwhois | | + kbd | [] [] [] [] | + keytouch | | + keytouch-editor | | + keytouch-keyboa... | | + latrine | () | + ld | [] | + leafpad | [] [] [] [] [] | + libc | [] [] [] [] [] | + libexif | [] | + libextractor | [] | + libgpewidget | [] [] [] | + libgpg-error | [] | + libgphoto2 | [] [] | + libgphoto2_port | [] [] | + libgsasl | | + libiconv | [] [] | + libidn | [] [] | + lifelines | [] () | + lilypond | [] | + lingoteach | | + lynx | [] [] [] [] | + m4 | [] [] [] [] | + mailutils | [] | + make | [] [] | + man-db | [] () [] [] | + minicom | [] [] [] | + mysecretdiary | [] [] | + nano | [] [] [] | + nano_1_0 | [] () [] [] | + opcodes | [] | + parted | | + pilot-qof | [] | + psmisc | [] | + pwdutils | | + python | | + qof | | + radius | [] | + recode | [] [] [] [] [] [] | + rpm | [] [] | + screem | | + scrollkeeper | [] [] [] [] [] [] [] [] | + sed | [] [] [] | + sh-utils | [] [] | + shared-mime-info | [] [] [] [] | + sharutils | [] [] [] [] [] [] | + shishi | | + silky | | + skencil | [] () | + sketch | [] () | + solfege | | + soundtracker | [] [] | + sp | [] | + stardict | [] | + system-tools-ba... | [] [] [] [] [] [] [] [] [] | + tar | [] | + texinfo | [] [] [] | + textutils | [] [] [] | + tin | () () | + tp-robot | [] | + tuxpaint | [] [] [] [] [] | + unicode-han-tra... | | + unicode-transla... | | + util-linux | [] [] [] [] | + vorbis-tools | [] [] [] [] | + wastesedge | () | + wdiff | [] [] [] [] | + wget | [] [] | + xchat | [] [] [] [] [] [] | + xkeyboard-config | | + xpad | [] [] | + +----------------------------------------------------+ + af am ar az be bg bs ca cs cy da de el en en_GB eo + 10 0 1 2 9 22 1 42 41 2 60 95 16 1 17 16 + + es et eu fa fi fr ga gl gu he hi hr hu id is it +--------------------------------------------------+ - a2ps | [] [] | + GNUnet | | + a2ps | [] [] [] () | aegis | | - ant-phone | | - anubis | | - aspell | [] [] | - bash | | - bfd | | - bibshelf | [] | - binutils | | - bison | | - bison-runtime | [] | - bluez-pin | [] [] | - bombono-dvd | | - buzztard | | - cflow | | - clisp | | - coreutils | [] [] | - cpio | | - cppi | | - cpplib | [] | - cryptsetup | | - dfarc | | - dialog | [] [] | - dico | | - diffutils | [] | - dink | | - doodle | | - e2fsprogs | [] | - enscript | [] | - exif | | - fetchmail | [] | - findutils | [] | - flex | [] | - freedink | | - gas | | - gawk | [] [] | - gcal | [] | - gcc | | - gettext-examples | [] [] [] [] | - gettext-runtime | [] [] | - gettext-tools | [] [] | - gip | [] | - gjay | | - gliv | [] | - glunarclock | [] [] | - gnubiff | | - gnucash | [] | - gnuedu | | - gnulib | | - gnunet | | + ant-phone | [] | + anubis | [] | + ap-utils | [] [] | + aspell | [] [] [] | + bash | [] [] [] | + batchelor | [] [] | + bfd | [] | + bibshelf | [] [] [] | + binutils | [] [] [] | + bison | [] [] [] [] [] [] | + bison-runtime | [] [] [] [] [] | + bluez-pin | [] [] [] [] [] | + cflow | [] | + clisp | [] [] | + console-tools | | + coreutils | [] [] [] [] [] [] | + cpio | [] [] [] | + cpplib | [] [] | + cryptonit | [] | + darkstat | [] () [] [] [] | + dialog | [] [] [] [] [] [] [] [] | + diffutils | [] [] [] [] [] [] [] [] [] | + doodle | [] [] | + e2fsprogs | [] [] [] | + enscript | [] [] [] | + error | [] [] [] [] [] | + fetchmail | [] | + fileutils | [] [] [] [] [] [] | + findutils | [] [] [] [] | + flex | [] [] [] | + fslint | [] | + gas | [] [] | + gawk | [] [] [] [] | + gbiff | [] | + gcal | [] [] | + gcc | [] | + gettext-examples | [] [] [] [] [] [] | + gettext-runtime | [] [] [] [] [] [] | + gettext-tools | [] [] [] | + gimp-print | [] [] | + gip | [] [] [] | + gliv | () | + glunarclock | [] [] [] | + gmult | [] [] [] | + gnubiff | () () | + gnucash | () () () | + gnucash-glossary | [] [] | + gnuedu | [] | + gnulib | [] [] [] [] [] [] [] [] | gnunet-gtk | | gnutls | | - gold | | - gpe-aerial | | - gpe-beam | | - gpe-bluetooth | | + gpe-aerial | [] [] | + gpe-beam | [] [] | gpe-calendar | | - gpe-clock | [] | - gpe-conf | | - gpe-contacts | | - gpe-edit | | - gpe-filemanager | | - gpe-go | | - gpe-login | | - gpe-ownerinfo | [] | - gpe-package | | - gpe-sketchbook | | - gpe-su | [] | - gpe-taskmanager | [] | - gpe-timesheet | [] | - gpe-today | [] | - gpe-todo | | - gphoto2 | | - gprof | [] | - gpsdrive | | - gramadoir | | - grep | | - grub | [] [] | - gsasl | | - gss | | - gst-plugins-bad | [] | - gst-plugins-base | [] | - gst-plugins-good | [] | - gst-plugins-ugly | [] | - gstreamer | [] [] [] | - gtick | | - gtkam | [] | - gtkorphan | [] | - gtkspell | [] [] [] | - gutenprint | | - hello | [] | - help2man | | - hylafax | | - idutils | | - indent | [] [] | - iso_15924 | | - iso_3166 | [] [] [] [] [] [] [] | - iso_3166_2 | | - iso_4217 | | - iso_639 | [] [] [] [] | - iso_639_3 | | - jwhois | | - kbd | | - keytouch | [] | - keytouch-editor | | - keytouch-keyboa... | [] | - klavaro | [] | - latrine | | - ld | [] | - leafpad | [] [] | - libc | [] [] | - libexif | () | - libextractor | | - libgnutls | | - libgpewidget | | + gpe-clock | [] [] [] [] | + gpe-conf | [] | + gpe-contacts | [] [] | + gpe-edit | [] [] [] [] | + gpe-filemanager | [] | + gpe-go | [] [] [] | + gpe-login | [] [] [] | + gpe-ownerinfo | [] [] [] [] [] | + gpe-package | [] | + gpe-sketchbook | [] [] | + gpe-su | [] [] [] [] | + gpe-taskmanager | [] [] [] | + gpe-timesheet | [] [] [] [] | + gpe-today | [] [] [] [] | + gpe-todo | [] | + gphoto2 | [] [] [] [] [] | + gprof | [] [] [] [] | + gpsdrive | () () [] () | + gramadoir | [] [] | + grep | [] [] [] [] [] [] [] [] [] [] [] [] | + gretl | [] [] [] | + gsasl | [] [] | + gss | [] | + gst-plugins | [] [] [] | + gst-plugins-base | [] [] | + gst-plugins-good | [] [] [] | + gstreamer | [] [] [] | + gtick | [] | + gtkam | [] [] [] [] | + gtkorphan | [] [] | + gtkspell | [] [] [] [] [] [] | + gutenprint | [] | + hello | [] [] [] [] [] [] [] [] [] [] [] [] [] | + id-utils | [] [] [] [] [] | + impost | [] [] | + indent | [] [] [] [] [] [] [] [] [] [] | + iso_3166 | [] [] [] | + iso_3166_2 | [] | + iso_4217 | [] [] [] [] | + iso_639 | [] [] [] [] [] | + jpilot | [] [] | + jtag | [] | + jwhois | [] [] [] [] [] | + kbd | [] [] | + keytouch | [] | + keytouch-editor | [] | + keytouch-keyboa... | [] | + latrine | [] [] [] | + ld | [] [] | + leafpad | [] [] [] [] [] [] | + libc | [] [] [] [] [] | + libexif | [] | + libextractor | [] | + libgpewidget | [] [] [] [] [] | libgpg-error | | - libgphoto2 | | - libgphoto2_port | | - libgsasl | | - libiconv | [] | - libidn | | - lifelines | | - liferea | [] [] | - lilypond | | - linkdr | [] | - lordsawar | | - lprng | | - lynx | [] | - m4 | | - mailfromd | | - mailutils | | - make | | - man-db | | - man-db-manpages | | - minicom | | - mkisofs | | - myserver | | - nano | [] [] | - opcodes | | - parted | | - pies | | - popt | | - psmisc | | - pspp | [] | + libgphoto2 | [] [] [] | + libgphoto2_port | [] [] | + libgsasl | [] [] | + libiconv | [] [] | + libidn | [] [] | + lifelines | () | + lilypond | [] | + lingoteach | [] [] [] | + lynx | [] [] [] | + m4 | [] [] [] [] | + mailutils | [] [] | + make | [] [] [] [] [] [] [] [] | + man-db | () | + minicom | [] [] [] [] | + mysecretdiary | [] [] [] | + nano | [] [] [] [] [] [] | + nano_1_0 | [] [] [] [] [] | + opcodes | [] [] [] [] | + parted | [] [] [] [] | + pilot-qof | | + psmisc | [] [] [] | pwdutils | | - radius | [] | - recode | [] [] | - rosegarden | | - rpm | | - rush | | - sarg | | + python | | + qof | [] | + radius | [] [] | + recode | [] [] [] [] [] [] [] [] | + rpm | [] [] | screem | | - scrollkeeper | [] [] [] | - sed | [] [] | - sharutils | [] [] | + scrollkeeper | [] [] [] | + sed | [] [] [] [] [] | + sh-utils | [] [] [] [] [] [] [] | + shared-mime-info | [] [] [] [] [] [] | + sharutils | [] [] [] [] [] [] [] [] | shishi | | - skencil | | - solfege | | - solfege-manual | | - soundtracker | | - sp | | - sysstat | | - tar | [] | - texinfo | | - tin | | + silky | [] | + skencil | [] [] | + sketch | [] [] | + solfege | [] | + soundtracker | [] [] [] | + sp | [] | + stardict | [] | + system-tools-ba... | [] [] [] [] [] [] [] [] | + tar | [] [] [] [] [] [] [] | + texinfo | [] [] | + textutils | [] [] [] [] [] | + tin | [] () | + tp-robot | [] [] [] [] | + tuxpaint | [] [] | unicode-han-tra... | | - unicode-transla... | | - util-linux-ng | [] | - vice | | - vmm | | - vorbis-tools | | - wastesedge | | - wdiff | | - wget | [] [] | - wyslij-po | | - xchat | [] [] [] [] | - xdg-user-dirs | [] [] [] [] [] [] [] [] [] | - xkeyboard-config | [] [] | + unicode-transla... | [] [] | + util-linux | [] [] [] [] [] [] [] | + vorbis-tools | [] [] | + wastesedge | () | + wdiff | [] [] [] [] [] [] [] [] | + wget | [] [] [] [] [] [] [] [] | + xchat | [] [] [] [] [] [] [] [] | + xkeyboard-config | [] [] [] [] | + xpad | [] [] [] | +--------------------------------------------------+ - af am an ar as ast az be be@latin bg bn_IN bs ca - 6 0 1 2 3 19 1 10 3 28 3 1 38 + es et eu fa fi fr ga gl gu he hi hr hu id is it + 88 22 14 2 40 115 61 14 1 8 1 6 59 31 0 52 - crh cs da de el en en_GB en_ZA eo es et eu fa + ja ko ku ky lg lt lv mk mn ms mt nb ne nl nn no +-------------------------------------------------+ - a2ps | [] [] [] [] [] [] [] | - aegis | [] [] [] | - ant-phone | [] () | - anubis | [] [] | - aspell | [] [] [] [] [] | - bash | [] [] [] | - bfd | [] | - bibshelf | [] [] [] | - binutils | [] | - bison | [] [] | - bison-runtime | [] [] [] [] | - bluez-pin | [] [] [] [] [] [] | - bombono-dvd | [] | - buzztard | [] [] [] | - cflow | [] [] | - clisp | [] [] [] [] | - coreutils | [] [] [] [] | + GNUnet | | + a2ps | () [] [] () | + aegis | () | + ant-phone | [] | + anubis | [] [] [] | + ap-utils | [] | + aspell | [] [] | + bash | [] | + batchelor | [] [] | + bfd | | + bibshelf | [] | + binutils | | + bison | [] [] [] | + bison-runtime | [] [] [] | + bluez-pin | [] [] [] | + cflow | | + clisp | [] | + console-tools | | + coreutils | [] | cpio | | - cppi | | - cpplib | [] [] [] | - cryptsetup | [] | - dfarc | [] [] [] | - dialog | [] [] [] [] [] | - dico | | - diffutils | [] [] [] [] [] [] | - dink | [] [] [] | - doodle | [] | - e2fsprogs | [] [] [] | - enscript | [] [] [] | - exif | () [] [] | - fetchmail | [] [] () [] [] [] | - findutils | [] [] [] | - flex | [] [] | - freedink | [] [] [] | - gas | [] | - gawk | [] [] [] | - gcal | [] | - gcc | [] [] | - gettext-examples | [] [] [] [] | - gettext-runtime | [] [] [] [] | - gettext-tools | [] [] [] | - gip | [] [] [] [] | - gjay | [] | - gliv | [] [] [] | - glunarclock | [] [] | - gnubiff | () | - gnucash | [] () () () () | - gnuedu | [] [] | - gnulib | [] [] | - gnunet | | - gnunet-gtk | [] | - gnutls | [] [] | - gold | [] | - gpe-aerial | [] [] [] [] | - gpe-beam | [] [] [] [] | - gpe-bluetooth | [] [] | - gpe-calendar | [] | - gpe-clock | [] [] [] [] | - gpe-conf | [] [] [] | - gpe-contacts | [] [] [] | - gpe-edit | [] [] | - gpe-filemanager | [] [] [] | - gpe-go | [] [] [] [] | - gpe-login | [] [] | - gpe-ownerinfo | [] [] [] [] | - gpe-package | [] [] [] | - gpe-sketchbook | [] [] [] [] | - gpe-su | [] [] [] [] | - gpe-taskmanager | [] [] [] [] | - gpe-timesheet | [] [] [] [] | - gpe-today | [] [] [] [] | - gpe-todo | [] [] [] | - gphoto2 | [] [] () [] [] [] | - gprof | [] [] [] | - gpsdrive | [] [] [] | - gramadoir | [] [] [] | - grep | [] | - grub | [] [] | - gsasl | [] | + cpplib | [] | + cryptonit | [] | + darkstat | [] [] | + dialog | [] [] | + diffutils | [] [] [] | + doodle | | + e2fsprogs | [] | + enscript | [] | + error | [] | + fetchmail | [] [] | + fileutils | [] [] | + findutils | [] | + flex | [] [] | + fslint | [] [] | + gas | | + gawk | [] [] | + gbiff | [] | + gcal | | + gcc | | + gettext-examples | [] [] | + gettext-runtime | [] [] [] | + gettext-tools | [] [] | + gimp-print | [] [] | + gip | [] [] | + gliv | [] | + glunarclock | [] [] | + gmult | [] [] | + gnubiff | | + gnucash | () () | + gnucash-glossary | [] | + gnuedu | | + gnulib | [] [] [] [] | + gnunet-gtk | | + gnutls | | + gpe-aerial | [] | + gpe-beam | [] | + gpe-calendar | [] | + gpe-clock | [] [] [] | + gpe-conf | [] [] | + gpe-contacts | [] | + gpe-edit | [] [] [] | + gpe-filemanager | [] [] | + gpe-go | [] [] [] | + gpe-login | [] [] [] | + gpe-ownerinfo | [] [] | + gpe-package | [] [] | + gpe-sketchbook | [] [] | + gpe-su | [] [] [] | + gpe-taskmanager | [] [] [] [] | + gpe-timesheet | [] | + gpe-today | [] [] | + gpe-todo | [] | + gphoto2 | [] [] | + gprof | | + gpsdrive | () () () | + gramadoir | () | + grep | [] [] [] [] | + gretl | | + gsasl | [] | gss | | - gst-plugins-bad | [] [] [] [] [] | - gst-plugins-base | [] [] [] [] [] | - gst-plugins-good | [] [] [] [] [] [] | - gst-plugins-ugly | [] [] [] [] [] [] | - gstreamer | [] [] [] [] [] | - gtick | [] () [] | - gtkam | [] [] () [] [] | - gtkorphan | [] [] [] [] | - gtkspell | [] [] [] [] [] [] [] | - gutenprint | [] [] [] | - hello | [] [] [] [] | - help2man | [] | - hylafax | [] [] | - idutils | [] [] | - indent | [] [] [] [] [] [] [] | - iso_15924 | [] () [] [] | - iso_3166 | [] [] [] [] () [] [] [] () | - iso_3166_2 | () | - iso_4217 | [] [] [] () [] [] | - iso_639 | [] [] [] [] () [] [] | - iso_639_3 | [] | - jwhois | [] | - kbd | [] [] [] [] [] | - keytouch | [] [] | - keytouch-editor | [] [] | - keytouch-keyboa... | [] | - klavaro | [] [] [] [] | - latrine | [] () | - ld | [] [] | - leafpad | [] [] [] [] [] [] | - libc | [] [] [] [] | - libexif | [] [] () | + gst-plugins | [] | + gst-plugins-base | | + gst-plugins-good | [] | + gstreamer | [] | + gtick | | + gtkam | [] | + gtkorphan | [] | + gtkspell | [] [] | + gutenprint | | + hello | [] [] [] [] [] [] | + id-utils | [] | + impost | | + indent | [] [] | + iso_3166 | [] | + iso_3166_2 | [] | + iso_4217 | [] [] [] | + iso_639 | [] [] | + jpilot | () () () | + jtag | | + jwhois | [] | + kbd | [] | + keytouch | [] | + keytouch-editor | | + keytouch-keyboa... | | + latrine | [] | + ld | | + leafpad | [] [] | + libc | [] [] [] [] [] | + libexif | | libextractor | | - libgnutls | [] | - libgpewidget | [] [] | - libgpg-error | [] [] | - libgphoto2 | [] () | - libgphoto2_port | [] () [] | - libgsasl | | - libiconv | [] [] [] [] [] | - libidn | [] [] [] | - lifelines | [] () | - liferea | [] [] [] [] [] | - lilypond | [] [] [] | - linkdr | [] [] [] | - lordsawar | [] | - lprng | | - lynx | [] [] [] [] | - m4 | [] [] [] [] | - mailfromd | | - mailutils | [] | - make | [] [] [] | - man-db | | - man-db-manpages | | - minicom | [] [] [] [] | - mkisofs | | - myserver | | - nano | [] [] [] | - opcodes | [] [] | - parted | [] [] | - pies | | - popt | [] [] [] [] [] | - psmisc | [] [] [] | - pspp | [] | - pwdutils | [] | - radius | [] | - recode | [] [] [] [] [] [] | - rosegarden | () () () | - rpm | [] [] [] | - rush | | - sarg | | - screem | | - scrollkeeper | [] [] [] [] [] | - sed | [] [] [] [] [] [] | - sharutils | [] [] [] [] | + libgpewidget | [] | + libgpg-error | | + libgphoto2 | [] | + libgphoto2_port | [] | + libgsasl | [] | + libiconv | | + libidn | [] [] | + lifelines | [] | + lilypond | | + lingoteach | [] | + lynx | [] [] | + m4 | [] [] | + mailutils | | + make | [] [] [] | + man-db | () | + minicom | [] | + mysecretdiary | [] | + nano | [] [] [] | + nano_1_0 | [] [] [] | + opcodes | [] | + parted | [] [] | + pilot-qof | | + psmisc | [] [] [] | + pwdutils | | + python | | + qof | | + radius | | + recode | [] | + rpm | [] [] | + screem | [] | + scrollkeeper | [] [] [] [] | + sed | [] [] | + sh-utils | [] [] | + shared-mime-info | [] [] [] [] [] | + sharutils | [] [] | shishi | | - skencil | [] () [] | - solfege | [] [] [] | - solfege-manual | [] [] | - soundtracker | [] [] [] | - sp | [] | - sysstat | [] [] [] | - tar | [] [] [] [] | - texinfo | [] [] [] | - tin | [] [] | + silky | [] | + skencil | | + sketch | | + solfege | | + soundtracker | | + sp | () | + stardict | [] [] | + system-tools-ba... | [] [] [] [] | + tar | [] [] [] | + texinfo | [] [] [] | + textutils | [] [] [] | + tin | | + tp-robot | [] | + tuxpaint | [] | unicode-han-tra... | | unicode-transla... | | - util-linux-ng | [] [] [] [] | - vice | () () | - vmm | [] | - vorbis-tools | [] [] | - wastesedge | [] | - wdiff | [] [] | - wget | [] [] [] | - wyslij-po | | - xchat | [] [] [] [] [] | - xdg-user-dirs | [] [] [] [] [] [] [] [] [] | - xkeyboard-config | [] [] [] [] [] [] | + util-linux | [] [] | + vorbis-tools | [] | + wastesedge | [] | + wdiff | [] [] | + wget | [] [] | + xchat | [] [] [] [] | + xkeyboard-config | [] | + xpad | [] [] [] | +-------------------------------------------------+ - crh cs da de el en en_GB en_ZA eo es et eu fa - 5 64 105 117 18 1 8 0 28 89 18 19 0 + ja ko ku ky lg lt lv mk mn ms mt nb ne nl nn no + 52 24 2 2 1 3 0 2 3 21 0 15 1 97 5 1 - fi fr ga gl gu he hi hr hu hy id is it ja ka kn - +----------------------------------------------------+ - a2ps | [] [] [] [] | - aegis | [] [] | - ant-phone | [] [] | - anubis | [] [] [] [] | - aspell | [] [] [] [] | - bash | [] [] [] [] | - bfd | [] [] [] | - bibshelf | [] [] [] [] [] | - binutils | [] [] [] | - bison | [] [] [] [] | - bison-runtime | [] [] [] [] [] [] | - bluez-pin | [] [] [] [] [] [] [] [] | - bombono-dvd | [] | - buzztard | [] | - cflow | [] [] [] | - clisp | [] | - coreutils | [] [] [] [] [] | - cpio | [] [] [] [] | - cppi | [] [] | - cpplib | [] [] [] | - cryptsetup | [] [] [] | - dfarc | [] [] [] | - dialog | [] [] [] [] [] [] [] | - dico | | - diffutils | [] [] [] [] [] [] [] [] [] | - dink | [] | - doodle | [] [] | - e2fsprogs | [] [] | - enscript | [] [] [] [] | - exif | [] [] [] [] [] [] | - fetchmail | [] [] [] [] | - findutils | [] [] [] [] [] [] | - flex | [] [] [] | - freedink | [] [] [] | - gas | [] [] | - gawk | [] [] [] [] () [] | - gcal | [] | - gcc | [] | - gettext-examples | [] [] [] [] [] [] [] | - gettext-runtime | [] [] [] [] [] [] | - gettext-tools | [] [] [] [] | - gip | [] [] [] [] [] [] | - gjay | [] | - gliv | [] () | - glunarclock | [] [] [] [] | - gnubiff | () [] () | - gnucash | () () () () () [] | - gnuedu | [] [] | - gnulib | [] [] [] [] [] [] | - gnunet | | - gnunet-gtk | [] | - gnutls | [] [] | - gold | [] [] | - gpe-aerial | [] [] [] | - gpe-beam | [] [] [] [] | - gpe-bluetooth | [] [] [] [] | - gpe-calendar | [] [] | - gpe-clock | [] [] [] [] [] | - gpe-conf | [] [] [] [] | - gpe-contacts | [] [] [] [] | - gpe-edit | [] [] [] | - gpe-filemanager | [] [] [] [] | - gpe-go | [] [] [] [] [] | - gpe-login | [] [] [] | - gpe-ownerinfo | [] [] [] [] [] | - gpe-package | [] [] [] | - gpe-sketchbook | [] [] [] [] | - gpe-su | [] [] [] [] [] [] | - gpe-taskmanager | [] [] [] [] [] | - gpe-timesheet | [] [] [] [] [] | - gpe-today | [] [] [] [] [] [] [] | - gpe-todo | [] [] [] | - gphoto2 | [] [] [] [] [] [] | - gprof | [] [] [] [] | - gpsdrive | [] [] [] | - gramadoir | [] [] [] | - grep | [] [] | - grub | [] [] [] [] | - gsasl | [] [] [] [] [] | - gss | [] [] [] [] [] | - gst-plugins-bad | [] [] [] [] [] [] | - gst-plugins-base | [] [] [] [] [] [] | - gst-plugins-good | [] [] [] [] [] [] | - gst-plugins-ugly | [] [] [] [] [] [] | - gstreamer | [] [] [] [] [] | - gtick | [] [] [] [] [] | - gtkam | [] [] [] [] [] | - gtkorphan | [] [] [] | - gtkspell | [] [] [] [] [] [] [] [] [] | - gutenprint | [] [] [] [] | - hello | [] [] [] | - help2man | [] [] | - hylafax | [] | - idutils | [] [] [] [] [] [] | - indent | [] [] [] [] [] [] [] [] | - iso_15924 | [] () [] [] | - iso_3166 | [] () [] [] [] [] [] [] [] [] [] [] | - iso_3166_2 | () [] [] [] | - iso_4217 | [] () [] [] [] [] | - iso_639 | [] () [] [] [] [] [] [] [] | - iso_639_3 | () [] [] | - jwhois | [] [] [] [] [] | - kbd | [] [] | - keytouch | [] [] [] [] [] [] | - keytouch-editor | [] [] [] [] [] | - keytouch-keyboa... | [] [] [] [] [] | - klavaro | [] [] | - latrine | [] [] [] | - ld | [] [] [] [] | - leafpad | [] [] [] [] [] [] [] () | - libc | [] [] [] [] [] | - libexif | [] | - libextractor | | - libgnutls | [] [] | - libgpewidget | [] [] [] [] | - libgpg-error | [] [] | - libgphoto2 | [] [] [] | - libgphoto2_port | [] [] [] | - libgsasl | [] [] [] [] [] | - libiconv | [] [] [] [] [] [] | - libidn | [] [] [] [] | - lifelines | () | - liferea | [] [] [] [] | - lilypond | [] [] | - linkdr | [] [] [] [] [] | - lordsawar | | - lprng | [] | - lynx | [] [] [] [] [] | - m4 | [] [] [] [] [] [] | - mailfromd | | - mailutils | [] [] | - make | [] [] [] [] [] [] [] [] [] | - man-db | [] [] | - man-db-manpages | [] | - minicom | [] [] [] [] [] | - mkisofs | [] [] [] [] | - myserver | | - nano | [] [] [] [] [] [] | - opcodes | [] [] [] [] | - parted | [] [] [] [] | - pies | | - popt | [] [] [] [] [] [] [] [] [] | - psmisc | [] [] [] | - pspp | | - pwdutils | [] [] | - radius | [] [] | - recode | [] [] [] [] [] [] [] [] | - rosegarden | () () () () () | - rpm | [] [] | - rush | | - sarg | [] | - screem | [] [] | - scrollkeeper | [] [] [] [] | - sed | [] [] [] [] [] [] [] [] | - sharutils | [] [] [] [] [] [] [] | - shishi | [] | - skencil | [] | - solfege | [] [] [] [] | - solfege-manual | [] [] | - soundtracker | [] [] | - sp | [] () | - sysstat | [] [] [] [] [] | - tar | [] [] [] [] [] [] [] | - texinfo | [] [] [] [] | - tin | [] | - unicode-han-tra... | | - unicode-transla... | [] [] | - util-linux-ng | [] [] [] [] [] [] | - vice | () () () | - vmm | [] | - vorbis-tools | [] | - wastesedge | () () | - wdiff | [] | - wget | [] [] [] [] [] [] [] [] | - wyslij-po | [] [] [] | - xchat | [] [] [] [] [] [] [] [] [] | - xdg-user-dirs | [] [] [] [] [] [] [] [] [] [] [] [] [] | - xkeyboard-config | [] [] [] [] [] | - +----------------------------------------------------+ - fi fr ga gl gu he hi hr hu hy id is it ja ka kn - 105 121 53 20 4 8 3 5 53 2 120 5 84 67 0 4 + nso or pa pl pt pt_BR rm ro ru rw sk sl sq sr sv ta + +------------------------------------------------------+ + GNUnet | | + a2ps | () [] [] [] [] [] [] | + aegis | () () | + ant-phone | [] [] | + anubis | [] [] [] | + ap-utils | () | + aspell | [] [] | + bash | [] [] [] | + batchelor | [] [] | + bfd | | + bibshelf | [] | + binutils | [] [] | + bison | [] [] [] [] [] | + bison-runtime | [] [] [] [] | + bluez-pin | [] [] [] [] [] [] [] [] [] | + cflow | [] | + clisp | [] | + console-tools | [] | + coreutils | [] [] [] [] | + cpio | [] [] [] | + cpplib | [] | + cryptonit | [] [] | + darkstat | [] [] [] [] [] [] | + dialog | [] [] [] [] [] [] [] [] [] | + diffutils | [] [] [] [] [] [] | + doodle | [] [] | + e2fsprogs | [] [] | + enscript | [] [] [] [] [] | + error | [] [] [] [] | + fetchmail | [] [] [] | + fileutils | [] [] [] [] [] | + findutils | [] [] [] [] [] [] | + flex | [] [] [] [] [] | + fslint | [] [] [] [] | + gas | | + gawk | [] [] [] [] | + gbiff | [] | + gcal | [] | + gcc | [] | + gettext-examples | [] [] [] [] [] [] [] [] | + gettext-runtime | [] [] [] [] [] [] [] [] | + gettext-tools | [] [] [] [] [] [] [] | + gimp-print | [] [] | + gip | [] [] [] [] | + gliv | [] [] [] [] | + glunarclock | [] [] [] [] [] [] | + gmult | [] [] [] [] | + gnubiff | () | + gnucash | () [] | + gnucash-glossary | [] [] [] | + gnuedu | | + gnulib | [] [] [] [] [] | + gnunet-gtk | [] | + gnutls | [] [] | + gpe-aerial | [] [] [] [] [] [] [] | + gpe-beam | [] [] [] [] [] [] [] | + gpe-calendar | [] | + gpe-clock | [] [] [] [] [] [] [] [] | + gpe-conf | [] [] [] [] [] [] [] | + gpe-contacts | [] [] [] [] [] | + gpe-edit | [] [] [] [] [] [] [] [] | + gpe-filemanager | [] [] | + gpe-go | [] [] [] [] [] [] | + gpe-login | [] [] [] [] [] [] [] [] | + gpe-ownerinfo | [] [] [] [] [] [] [] [] | + gpe-package | [] [] | + gpe-sketchbook | [] [] [] [] [] [] [] [] | + gpe-su | [] [] [] [] [] [] [] [] | + gpe-taskmanager | [] [] [] [] [] [] [] [] | + gpe-timesheet | [] [] [] [] [] [] [] [] | + gpe-today | [] [] [] [] [] [] [] [] | + gpe-todo | [] [] [] [] | + gphoto2 | [] [] [] [] [] | + gprof | [] [] [] | + gpsdrive | [] [] [] | + gramadoir | [] [] | + grep | [] [] [] [] [] [] [] [] | + gretl | [] | + gsasl | [] [] [] | + gss | [] [] [] | + gst-plugins | [] [] [] [] | + gst-plugins-base | [] | + gst-plugins-good | [] [] [] [] | + gstreamer | [] [] [] | + gtick | [] | + gtkam | [] [] [] [] | + gtkorphan | [] | + gtkspell | [] [] [] [] [] [] [] [] | + gutenprint | [] | + hello | [] [] [] [] [] [] [] [] | + id-utils | [] [] [] [] | + impost | [] | + indent | [] [] [] [] [] [] | + iso_3166 | [] [] [] [] [] [] | + iso_3166_2 | | + iso_4217 | [] [] [] [] | + iso_639 | [] [] [] [] | + jpilot | | + jtag | [] | + jwhois | [] [] [] [] | + kbd | [] [] [] | + keytouch | [] | + keytouch-editor | [] | + keytouch-keyboa... | [] | + latrine | [] [] | + ld | [] | + leafpad | [] [] [] [] [] [] | + libc | [] [] [] [] [] | + libexif | [] | + libextractor | [] [] | + libgpewidget | [] [] [] [] [] [] [] | + libgpg-error | [] [] | + libgphoto2 | [] | + libgphoto2_port | [] [] [] | + libgsasl | [] [] [] [] | + libiconv | [] [] | + libidn | [] [] () | + lifelines | [] [] | + lilypond | | + lingoteach | [] | + lynx | [] [] [] | + m4 | [] [] [] [] [] | + mailutils | [] [] [] [] | + make | [] [] [] [] | + man-db | [] [] | + minicom | [] [] [] [] [] | + mysecretdiary | [] [] [] [] | + nano | [] [] [] | + nano_1_0 | [] [] [] [] | + opcodes | [] [] | + parted | [] | + pilot-qof | [] | + psmisc | [] [] | + pwdutils | [] [] | + python | | + qof | [] [] | + radius | [] [] | + recode | [] [] [] [] [] [] [] | + rpm | [] [] [] [] | + screem | | + scrollkeeper | [] [] [] [] [] [] [] | + sed | [] [] [] [] [] [] [] [] [] | + sh-utils | [] [] [] | + shared-mime-info | [] [] [] [] [] | + sharutils | [] [] [] [] | + shishi | [] | + silky | [] | + skencil | [] [] [] | + sketch | [] [] [] | + solfege | [] | + soundtracker | [] [] | + sp | | + stardict | [] [] [] | + system-tools-ba... | [] [] [] [] [] [] [] [] [] | + tar | [] [] [] [] [] | + texinfo | [] [] [] [] | + textutils | [] [] [] | + tin | () | + tp-robot | [] | + tuxpaint | [] [] [] [] [] | + unicode-han-tra... | | + unicode-transla... | | + util-linux | [] [] [] [] | + vorbis-tools | [] [] | + wastesedge | | + wdiff | [] [] [] [] [] [] | + wget | [] [] [] [] | + xchat | [] [] [] [] [] [] [] | + xkeyboard-config | [] [] | + xpad | [] [] [] | + +------------------------------------------------------+ + nso or pa pl pt pt_BR rm ro ru rw sk sl sq sr sv ta + 0 2 3 58 30 54 5 73 72 4 40 46 11 50 128 2 - ko ku ky lg lt lv mk ml mn mr ms mt nb nds ne - +-----------------------------------------------+ - a2ps | [] | - aegis | | - ant-phone | | - anubis | [] [] | - aspell | [] | - bash | | - bfd | | - bibshelf | [] [] | - binutils | | - bison | [] | - bison-runtime | [] [] [] [] [] | - bluez-pin | [] [] [] [] [] | - bombono-dvd | | - buzztard | | - cflow | | - clisp | | - coreutils | [] | - cpio | | - cppi | | - cpplib | | - cryptsetup | | - dfarc | [] | - dialog | [] [] [] [] [] | - dico | | - diffutils | [] [] | - dink | | - doodle | | - e2fsprogs | | - enscript | | - exif | [] | - fetchmail | | - findutils | | - flex | | - freedink | [] | - gas | | - gawk | | - gcal | | - gcc | | - gettext-examples | [] [] [] [] | - gettext-runtime | [] | - gettext-tools | [] | - gip | [] [] | - gjay | | - gliv | | - glunarclock | [] | - gnubiff | | - gnucash | () () () () | - gnuedu | | - gnulib | | - gnunet | | - gnunet-gtk | | - gnutls | [] | - gold | | - gpe-aerial | [] | - gpe-beam | [] | - gpe-bluetooth | [] [] | - gpe-calendar | [] | - gpe-clock | [] [] [] [] [] | - gpe-conf | [] [] | - gpe-contacts | [] [] | - gpe-edit | [] | - gpe-filemanager | [] [] | - gpe-go | [] [] [] | - gpe-login | [] | - gpe-ownerinfo | [] [] | - gpe-package | [] [] | - gpe-sketchbook | [] [] | - gpe-su | [] [] [] [] [] [] | - gpe-taskmanager | [] [] [] [] [] [] | - gpe-timesheet | [] [] | - gpe-today | [] [] [] [] | - gpe-todo | [] [] | - gphoto2 | | - gprof | [] | - gpsdrive | | - gramadoir | | - grep | | - grub | | - gsasl | | - gss | | - gst-plugins-bad | [] [] [] [] | - gst-plugins-base | [] [] | - gst-plugins-good | [] [] | - gst-plugins-ugly | [] [] [] [] [] | - gstreamer | | - gtick | | - gtkam | [] | - gtkorphan | [] [] | - gtkspell | [] [] [] [] [] [] [] | - gutenprint | | - hello | [] [] [] | - help2man | | - hylafax | | - idutils | | - indent | | - iso_15924 | [] [] | - iso_3166 | [] [] () [] [] [] [] [] | - iso_3166_2 | | - iso_4217 | [] [] | - iso_639 | [] [] | - iso_639_3 | [] | - jwhois | [] | - kbd | | - keytouch | [] | - keytouch-editor | [] | - keytouch-keyboa... | [] | - klavaro | [] | - latrine | [] | - ld | | - leafpad | [] [] [] | - libc | [] | - libexif | | - libextractor | | - libgnutls | [] | - libgpewidget | [] [] | - libgpg-error | | - libgphoto2 | | - libgphoto2_port | | - libgsasl | | - libiconv | | - libidn | | - lifelines | | - liferea | | - lilypond | | - linkdr | | - lordsawar | | - lprng | | - lynx | | - m4 | | - mailfromd | | - mailutils | | - make | [] | - man-db | | - man-db-manpages | | - minicom | [] | - mkisofs | | - myserver | | - nano | [] [] | - opcodes | | - parted | | - pies | | - popt | [] [] [] | - psmisc | | - pspp | | - pwdutils | | - radius | | - recode | | - rosegarden | | - rpm | | - rush | | - sarg | | - screem | | - scrollkeeper | [] [] | - sed | | - sharutils | | - shishi | | - skencil | | - solfege | [] | - solfege-manual | | - soundtracker | | - sp | | - sysstat | [] | - tar | [] | - texinfo | [] | - tin | | - unicode-han-tra... | | - unicode-transla... | | - util-linux-ng | | - vice | | - vmm | | - vorbis-tools | | - wastesedge | | - wdiff | | - wget | [] | - wyslij-po | | - xchat | [] [] [] | - xdg-user-dirs | [] [] [] [] [] [] [] [] | - xkeyboard-config | [] [] [] | - +-----------------------------------------------+ - ko ku ky lg lt lv mk ml mn mr ms mt nb nds ne - 20 5 10 1 13 48 4 2 2 4 24 10 20 3 1 - - nl nn or pa pl ps pt pt_BR ro ru rw sk sl sq sr + tg th tk tr uk ven vi wa xh zh_CN zh_HK zh_TW zu +---------------------------------------------------+ - a2ps | [] [] [] [] [] [] [] [] | - aegis | [] [] [] | - ant-phone | [] [] | - anubis | [] [] [] | - aspell | [] [] [] [] [] | - bash | [] [] | - bfd | [] | - bibshelf | [] [] | - binutils | [] [] | - bison | [] [] [] | - bison-runtime | [] [] [] [] [] [] [] | - bluez-pin | [] [] [] [] [] [] [] [] | - bombono-dvd | [] () | - buzztard | [] [] | - cflow | [] | - clisp | [] [] | - coreutils | [] [] [] [] [] [] | - cpio | [] [] [] | - cppi | [] | - cpplib | [] | - cryptsetup | [] | - dfarc | [] | - dialog | [] [] [] [] | - dico | [] | - diffutils | [] [] [] [] [] [] | - dink | () | - doodle | [] [] | - e2fsprogs | [] [] | - enscript | [] [] [] [] [] | - exif | [] [] [] () [] | - fetchmail | [] [] [] [] | - findutils | [] [] [] [] [] | - flex | [] [] [] [] [] | - freedink | [] [] | - gas | | - gawk | [] [] [] [] | - gcal | | - gcc | [] | - gettext-examples | [] [] [] [] [] [] [] [] | - gettext-runtime | [] [] [] [] [] [] [] [] [] | - gettext-tools | [] [] [] [] [] [] | - gip | [] [] [] [] [] | - gjay | | - gliv | [] [] [] [] [] [] | - glunarclock | [] [] [] [] [] | - gnubiff | [] () | - gnucash | [] () () () | - gnuedu | [] | - gnulib | [] [] [] [] | - gnunet | | - gnunet-gtk | | - gnutls | [] [] | - gold | | - gpe-aerial | [] [] [] [] [] [] [] | - gpe-beam | [] [] [] [] [] [] [] | - gpe-bluetooth | [] [] | - gpe-calendar | [] [] [] [] | - gpe-clock | [] [] [] [] [] [] [] [] | - gpe-conf | [] [] [] [] [] [] [] | - gpe-contacts | [] [] [] [] [] | - gpe-edit | [] [] [] | - gpe-filemanager | [] [] [] | - gpe-go | [] [] [] [] [] [] [] [] | - gpe-login | [] [] | - gpe-ownerinfo | [] [] [] [] [] [] [] [] | - gpe-package | [] [] | - gpe-sketchbook | [] [] [] [] [] [] [] | - gpe-su | [] [] [] [] [] [] [] [] | - gpe-taskmanager | [] [] [] [] [] [] [] [] | - gpe-timesheet | [] [] [] [] [] [] [] [] | - gpe-today | [] [] [] [] [] [] [] [] | - gpe-todo | [] [] [] [] [] | - gphoto2 | [] [] [] [] [] [] [] [] | - gprof | [] [] [] | - gpsdrive | [] [] | - gramadoir | [] [] | - grep | [] [] [] [] | - grub | [] [] [] | - gsasl | [] [] [] [] | - gss | [] [] [] | - gst-plugins-bad | [] [] [] [] [] [] | - gst-plugins-base | [] [] [] [] [] | - gst-plugins-good | [] [] [] [] [] | - gst-plugins-ugly | [] [] [] [] [] [] | - gstreamer | [] [] [] [] [] | - gtick | [] [] [] | - gtkam | [] [] [] [] [] [] | - gtkorphan | [] | - gtkspell | [] [] [] [] [] [] [] [] [] [] | - gutenprint | [] [] | - hello | [] [] [] [] | - help2man | [] [] | - hylafax | [] | - idutils | [] [] [] [] [] | - indent | [] [] [] [] [] [] [] | - iso_15924 | [] [] [] [] | - iso_3166 | [] [] [] [] [] () [] [] [] [] [] [] [] [] | - iso_3166_2 | [] [] [] | - iso_4217 | [] [] [] [] [] [] [] [] | - iso_639 | [] [] [] [] [] [] [] [] [] | - iso_639_3 | [] [] | - jwhois | [] [] [] [] | - kbd | [] [] [] | - keytouch | [] [] [] | - keytouch-editor | [] [] [] | - keytouch-keyboa... | [] [] [] | - klavaro | [] [] | - latrine | [] [] | - ld | | - leafpad | [] [] [] [] [] [] [] [] [] | - libc | [] [] [] [] | - libexif | [] [] () [] | - libextractor | | - libgnutls | [] [] | - libgpewidget | [] [] [] | - libgpg-error | [] [] | - libgphoto2 | [] [] | - libgphoto2_port | [] [] [] [] [] | - libgsasl | [] [] [] [] [] | - libiconv | [] [] [] [] [] | - libidn | [] [] | - lifelines | [] [] | - liferea | [] [] [] [] [] () () [] | - lilypond | [] | - linkdr | [] [] [] | - lordsawar | | - lprng | [] | - lynx | [] [] [] | - m4 | [] [] [] [] [] | - mailfromd | [] | - mailutils | [] | - make | [] [] [] [] | - man-db | [] [] [] | - man-db-manpages | [] [] [] | - minicom | [] [] [] [] | - mkisofs | [] [] [] | - myserver | | - nano | [] [] [] [] | - opcodes | [] [] | - parted | [] [] [] [] | - pies | [] | - popt | [] [] [] [] | - psmisc | [] [] [] | - pspp | [] [] | - pwdutils | [] | - radius | [] [] [] | - recode | [] [] [] [] [] [] [] [] | - rosegarden | () () | - rpm | [] [] [] | - rush | [] [] | - sarg | | - screem | | - scrollkeeper | [] [] [] [] [] [] [] [] | - sed | [] [] [] [] [] [] [] [] [] | - sharutils | [] [] [] [] | - shishi | [] | - skencil | [] [] | - solfege | [] [] [] [] | - solfege-manual | [] [] [] | - soundtracker | [] | - sp | | - sysstat | [] [] [] [] | - tar | [] [] [] [] | - texinfo | [] [] [] [] | - tin | [] | - unicode-han-tra... | | - unicode-transla... | | - util-linux-ng | [] [] [] [] [] | - vice | [] | - vmm | [] | - vorbis-tools | [] [] | - wastesedge | [] | - wdiff | [] [] | - wget | [] [] [] [] [] [] [] | - wyslij-po | [] [] [] | - xchat | [] [] [] [] [] [] [] [] [] | - xdg-user-dirs | [] [] [] [] [] [] [] [] [] [] [] [] [] [] | - xkeyboard-config | [] [] [] | - +---------------------------------------------------+ - nl nn or pa pl ps pt pt_BR ro ru rw sk sl sq sr - 135 10 4 7 105 1 29 62 47 91 3 54 46 9 37 - - sv sw ta te tg th tr uk vi wa zh_CN zh_HK zh_TW - +---------------------------------------------------+ - a2ps | [] [] [] [] [] | 27 - aegis | [] | 9 - ant-phone | [] [] [] [] | 9 - anubis | [] [] [] [] | 15 - aspell | [] [] [] | 20 - bash | [] [] [] | 12 - bfd | [] | 6 - bibshelf | [] [] [] | 16 - binutils | [] [] | 8 - bison | [] [] | 12 - bison-runtime | [] [] [] [] [] [] | 29 - bluez-pin | [] [] [] [] [] [] [] [] | 37 - bombono-dvd | [] | 4 - buzztard | [] | 7 - cflow | [] [] [] | 9 - clisp | | 10 - coreutils | [] [] [] [] | 22 - cpio | [] [] [] [] [] [] | 13 - cppi | [] [] | 5 - cpplib | [] [] [] [] [] [] | 14 - cryptsetup | [] [] | 7 - dfarc | [] | 9 - dialog | [] [] [] [] [] [] [] | 30 - dico | [] | 2 - diffutils | [] [] [] [] [] [] | 30 - dink | | 4 - doodle | [] [] | 7 - e2fsprogs | [] [] [] | 11 - enscript | [] [] [] [] | 17 - exif | [] [] [] | 16 - fetchmail | [] [] [] | 17 - findutils | [] [] [] [] [] | 20 - flex | [] [] [] [] | 15 - freedink | [] | 10 - gas | [] | 4 - gawk | [] [] [] [] | 18 - gcal | [] [] | 5 - gcc | [] [] [] | 7 - gettext-examples | [] [] [] [] [] [] [] | 34 - gettext-runtime | [] [] [] [] [] [] [] | 29 - gettext-tools | [] [] [] [] [] [] | 22 - gip | [] [] [] [] | 22 - gjay | [] | 3 - gliv | [] [] [] | 14 - glunarclock | [] [] [] [] [] | 19 - gnubiff | [] [] | 4 - gnucash | () [] () [] () | 10 - gnuedu | [] [] | 7 - gnulib | [] [] [] [] | 16 - gnunet | [] | 1 - gnunet-gtk | [] [] [] | 5 - gnutls | [] [] [] | 10 - gold | [] | 4 - gpe-aerial | [] [] [] | 18 - gpe-beam | [] [] [] | 19 - gpe-bluetooth | [] [] [] | 13 - gpe-calendar | [] [] [] [] | 12 - gpe-clock | [] [] [] [] [] | 28 - gpe-conf | [] [] [] [] | 20 - gpe-contacts | [] [] [] | 17 - gpe-edit | [] [] [] | 12 - gpe-filemanager | [] [] [] [] | 16 - gpe-go | [] [] [] [] [] | 25 - gpe-login | [] [] [] | 11 - gpe-ownerinfo | [] [] [] [] [] | 25 - gpe-package | [] [] [] | 13 - gpe-sketchbook | [] [] [] | 20 - gpe-su | [] [] [] [] [] | 30 - gpe-taskmanager | [] [] [] [] [] | 29 - gpe-timesheet | [] [] [] [] [] | 25 - gpe-today | [] [] [] [] [] [] | 30 - gpe-todo | [] [] [] [] | 17 - gphoto2 | [] [] [] [] [] | 24 - gprof | [] [] [] | 15 - gpsdrive | [] [] [] | 11 - gramadoir | [] [] [] | 11 - grep | [] [] [] | 10 - grub | [] [] [] | 14 - gsasl | [] [] [] [] | 14 - gss | [] [] [] | 11 - gst-plugins-bad | [] [] [] [] | 26 - gst-plugins-base | [] [] [] [] [] | 24 - gst-plugins-good | [] [] [] [] | 24 - gst-plugins-ugly | [] [] [] [] [] | 29 - gstreamer | [] [] [] [] | 22 - gtick | [] [] [] | 13 - gtkam | [] [] [] | 20 - gtkorphan | [] [] [] | 14 - gtkspell | [] [] [] [] [] [] [] [] [] | 45 - gutenprint | [] | 10 - hello | [] [] [] [] [] [] | 21 - help2man | [] [] | 7 - hylafax | [] | 5 - idutils | [] [] [] [] | 17 - indent | [] [] [] [] [] [] | 30 - iso_15924 | () [] () [] [] | 16 - iso_3166 | [] [] () [] [] () [] [] [] () | 53 - iso_3166_2 | () [] () [] | 9 - iso_4217 | [] () [] [] () [] [] | 26 - iso_639 | [] [] [] () [] () [] [] [] [] | 38 - iso_639_3 | [] () | 8 - jwhois | [] [] [] [] [] | 16 - kbd | [] [] [] [] [] | 15 - keytouch | [] [] [] | 16 - keytouch-editor | [] [] [] | 14 - keytouch-keyboa... | [] [] [] | 14 - klavaro | [] | 11 - latrine | [] [] [] | 10 - ld | [] [] [] [] | 11 - leafpad | [] [] [] [] [] [] | 33 - libc | [] [] [] [] [] | 21 - libexif | [] () | 7 - libextractor | [] | 1 - libgnutls | [] [] [] | 9 - libgpewidget | [] [] [] | 14 - libgpg-error | [] [] [] | 9 - libgphoto2 | [] [] | 8 - libgphoto2_port | [] [] [] [] | 14 - libgsasl | [] [] [] | 13 - libiconv | [] [] [] [] | 21 - libidn | () [] [] | 11 - lifelines | [] | 4 - liferea | [] [] [] | 21 - lilypond | [] | 7 - linkdr | [] [] [] [] [] | 17 - lordsawar | | 1 - lprng | [] | 3 - lynx | [] [] [] [] | 17 - m4 | [] [] [] [] | 19 - mailfromd | [] [] | 3 - mailutils | [] | 5 - make | [] [] [] [] | 21 - man-db | [] [] [] | 8 - man-db-manpages | | 4 - minicom | [] [] | 16 - mkisofs | [] [] | 9 - myserver | | 0 - nano | [] [] [] [] | 21 - opcodes | [] [] [] | 11 - parted | [] [] [] [] [] | 15 - pies | [] [] | 3 - popt | [] [] [] [] [] [] | 27 - psmisc | [] [] | 11 - pspp | | 4 - pwdutils | [] [] | 6 - radius | [] [] | 9 - recode | [] [] [] [] | 28 - rosegarden | () | 0 - rpm | [] [] [] | 11 - rush | [] [] | 4 - sarg | | 1 - screem | [] | 3 - scrollkeeper | [] [] [] [] [] | 27 - sed | [] [] [] [] [] | 30 - sharutils | [] [] [] [] [] | 22 - shishi | [] | 3 - skencil | [] [] | 7 - solfege | [] [] [] [] | 16 - solfege-manual | [] | 8 - soundtracker | [] [] [] | 9 - sp | [] | 3 - sysstat | [] [] | 15 - tar | [] [] [] [] [] [] | 23 - texinfo | [] [] [] [] [] | 17 - tin | | 4 + GNUnet | [] | 2 + a2ps | [] [] [] | 19 + aegis | | 0 + ant-phone | [] [] | 6 + anubis | [] [] [] | 11 + ap-utils | () [] | 4 + aspell | [] [] [] | 15 + bash | [] | 11 + batchelor | [] [] | 9 + bfd | | 1 + bibshelf | [] | 7 + binutils | [] [] [] | 9 + bison | [] [] [] | 19 + bison-runtime | [] [] [] | 15 + bluez-pin | [] [] [] [] [] [] | 28 + cflow | [] [] | 5 + clisp | | 6 + console-tools | [] [] | 5 + coreutils | [] [] | 16 + cpio | [] [] [] | 9 + cpplib | [] [] [] [] | 11 + cryptonit | | 5 + darkstat | [] () () | 15 + dialog | [] [] [] [] [] | 30 + diffutils | [] [] [] [] | 28 + doodle | [] | 6 + e2fsprogs | [] [] | 10 + enscript | [] [] [] | 16 + error | [] [] [] [] | 18 + fetchmail | [] [] | 12 + fileutils | [] [] [] | 18 + findutils | [] [] [] | 17 + flex | [] [] | 15 + fslint | [] | 9 + gas | [] | 3 + gawk | [] [] | 15 + gbiff | [] | 5 + gcal | [] | 5 + gcc | [] [] [] | 6 + gettext-examples | [] [] [] [] [] [] | 27 + gettext-runtime | [] [] [] [] [] [] | 28 + gettext-tools | [] [] [] [] [] | 19 + gimp-print | [] [] | 12 + gip | [] [] | 12 + gliv | [] [] | 8 + glunarclock | [] [] [] | 15 + gmult | [] [] [] [] | 15 + gnubiff | [] | 1 + gnucash | () | 2 + gnucash-glossary | [] [] | 9 + gnuedu | [] | 2 + gnulib | [] [] [] [] [] | 28 + gnunet-gtk | | 1 + gnutls | | 2 + gpe-aerial | [] [] | 14 + gpe-beam | [] [] | 14 + gpe-calendar | [] | 3 + gpe-clock | [] [] [] [] | 21 + gpe-conf | [] [] | 14 + gpe-contacts | [] [] | 10 + gpe-edit | [] [] [] [] | 20 + gpe-filemanager | [] | 6 + gpe-go | [] [] | 15 + gpe-login | [] [] [] [] [] | 21 + gpe-ownerinfo | [] [] [] [] | 21 + gpe-package | [] | 6 + gpe-sketchbook | [] [] | 16 + gpe-su | [] [] [] | 20 + gpe-taskmanager | [] [] [] | 20 + gpe-timesheet | [] [] [] [] | 18 + gpe-today | [] [] [] [] [] | 21 + gpe-todo | [] | 7 + gphoto2 | [] [] [] [] | 20 + gprof | [] [] | 11 + gpsdrive | | 4 + gramadoir | [] | 7 + grep | [] [] [] [] | 34 + gretl | | 4 + gsasl | [] [] | 8 + gss | [] | 5 + gst-plugins | [] [] [] | 15 + gst-plugins-base | [] [] [] | 9 + gst-plugins-good | [] [] [] [] [] | 20 + gstreamer | [] [] [] | 17 + gtick | [] | 3 + gtkam | [] | 13 + gtkorphan | [] | 7 + gtkspell | [] [] [] [] [] [] | 26 + gutenprint | | 3 + hello | [] [] [] [] [] | 37 + id-utils | [] [] | 14 + impost | [] | 4 + indent | [] [] [] [] | 25 + iso_3166 | [] [] [] [] | 16 + iso_3166_2 | | 2 + iso_4217 | [] [] | 14 + iso_639 | [] | 14 + jpilot | [] [] [] [] | 7 + jtag | [] | 3 + jwhois | [] [] [] | 13 + kbd | [] [] | 12 + keytouch | [] | 4 + keytouch-editor | | 2 + keytouch-keyboa... | [] | 3 + latrine | [] [] | 8 + ld | [] [] [] [] | 8 + leafpad | [] [] [] [] | 23 + libc | [] [] [] | 23 + libexif | [] | 4 + libextractor | [] | 5 + libgpewidget | [] [] [] | 19 + libgpg-error | [] | 4 + libgphoto2 | [] | 8 + libgphoto2_port | [] [] [] | 11 + libgsasl | [] | 8 + libiconv | [] | 7 + libidn | [] [] | 10 + lifelines | | 4 + lilypond | | 2 + lingoteach | [] | 6 + lynx | [] [] [] | 15 + m4 | [] [] [] | 18 + mailutils | [] | 8 + make | [] [] [] | 20 + man-db | [] | 6 + minicom | [] | 14 + mysecretdiary | [] [] | 12 + nano | [] [] | 17 + nano_1_0 | [] [] [] | 18 + opcodes | [] [] | 10 + parted | [] [] [] | 10 + pilot-qof | [] | 3 + psmisc | [] | 10 + pwdutils | [] | 3 + python | | 0 + qof | [] | 4 + radius | [] | 6 + recode | [] [] [] | 25 + rpm | [] [] [] [] | 14 + screem | [] | 2 + scrollkeeper | [] [] [] [] | 26 + sed | [] [] [] | 22 + sh-utils | [] | 15 + shared-mime-info | [] [] [] [] | 24 + sharutils | [] [] [] | 23 + shishi | | 1 + silky | [] | 4 + skencil | [] | 7 + sketch | | 6 + solfege | | 2 + soundtracker | [] [] | 9 + sp | [] | 3 + stardict | [] [] [] [] | 11 + system-tools-ba... | [] [] [] [] [] [] [] | 37 + tar | [] [] [] [] | 20 + texinfo | [] [] [] | 15 + textutils | [] [] [] | 17 + tin | | 1 + tp-robot | [] [] [] | 10 + tuxpaint | [] [] [] | 16 unicode-han-tra... | | 0 unicode-transla... | | 2 - util-linux-ng | [] [] [] [] | 20 - vice | () () | 1 - vmm | [] | 4 - vorbis-tools | [] | 6 - wastesedge | | 2 - wdiff | [] [] | 7 - wget | [] [] [] [] [] | 26 - wyslij-po | [] [] | 8 - xchat | [] [] [] [] [] [] | 36 - xdg-user-dirs | [] [] [] [] [] [] [] [] [] [] | 63 - xkeyboard-config | [] [] [] | 22 + util-linux | [] [] [] | 20 + vorbis-tools | [] [] | 11 + wastesedge | | 1 + wdiff | [] [] | 22 + wget | [] [] [] | 19 + xchat | [] [] [] [] | 29 + xkeyboard-config | [] [] [] [] | 11 + xpad | [] [] [] | 14 +---------------------------------------------------+ - 85 teams sv sw ta te tg th tr uk vi wa zh_CN zh_HK zh_TW - 178 domains 119 1 3 3 0 10 65 51 155 17 98 7 41 2618 + 77 teams tg th tk tr uk ven vi wa xh zh_CN zh_HK zh_TW zu + 170 domains 0 1 1 77 39 0 136 10 1 48 5 54 0 2028 Some counters in the preceding matrix are higher than the number of visible blocks let us expect. This is because a few extra PO files are @@ -1256,12 +1075,12 @@ distributed as such by its maintainer. There might be an observable lag between the mere existence a PO file and its wide availability in a distribution. - If June 2010 seems to be old, you may fetch a more recent copy of + If October 2006 seems to be old, you may fetch a more recent copy of this `ABOUT-NLS' file on most GNU archive sites. The most up-to-date matrix with full percentage details can be found at -`http://translationproject.org/extra/matrix.html'. +`http://www.iro.umontreal.ca/contrib/po/HTML/matrix.html'. -1.5 Using `gettext' in new packages +1.6 Using `gettext' in new packages =================================== If you are writing a freely available program and want to @@ -1277,6 +1096,6 @@ the use of `gettext' the only thing missing are the translations. The Free Translation Project is also available for packages which are not developed inside the GNU project. Therefore the information given above applies also for every other Free Software Project. Contact -`coordinator@translationproject.org' to make the `.pot' files available -to the translation teams. +`translation@iro.umontreal.ca' to make the `.pot' files available to +the translation teams. diff --git a/BSD.txt b/BSD.txt index 03476b75..ae21308f 100644 --- a/BSD.txt +++ b/BSD.txt @@ -42,33 +42,3 @@ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- -NASM is now licensed under the 2-clause BSD license, also known as the -simplified BSD license. - - Copyright 1996-2009 the NASM Authors - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following - conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND - CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, - INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index 9e1bb76b..00000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,47 +0,0 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.4...4.0) -PROJECT(yasm) -if (COMMAND cmake_policy) - cmake_policy(SET CMP0003 NEW) -endif (COMMAND cmake_policy) - -OPTION(BUILD_SHARED_LIBS "Build shared libraries" ON) - -# Where to look first for cmake modules -set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules") - -INCLUDE(YasmMacros) -INCLUDE(VersionGen) - -OPTION(ENABLE_NLS "Enable message translations" OFF) - -OPTION(YASM_BUILD_TESTS "Enable building of tests" ON) - -IF(YASM_BUILD_TESTS) - ENABLE_TESTING() -ENDIF(YASM_BUILD_TESTS) - -# Default build type to debug if not set -IF(NOT CMAKE_BUILD_TYPE) - SET(CMAKE_BUILD_TYPE Debug CACHE STRING - "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." - FORCE) -ENDIF(NOT CMAKE_BUILD_TYPE) - -VERSION_GEN(PACKAGE_VERSION "${CMAKE_BINARY_DIR}/YASM-VERSION-FILE" "1.3.0") - -set (PACKAGE_STRING "yasm ${PACKAGE_VERSION}") - -INCLUDE_DIRECTORIES(AFTER ${CMAKE_BINARY_DIR} ${yasm_SOURCE_DIR}) - -INCLUDE(ConfigureChecks.cmake) - -ADD_SUBDIRECTORY(tools) -ADD_SUBDIRECTORY(libyasm) -ADD_SUBDIRECTORY(modules) -ADD_SUBDIRECTORY(frontends) - -INSTALL(FILES - libyasm.h - ${CMAKE_BINARY_DIR}/libyasm-stdint.h - DESTINATION include - ) diff --git a/COPYING b/COPYING index 430673b7..5e9221f9 100644 --- a/COPYING +++ b/COPYING @@ -1,17 +1,15 @@ -Yasm is Copyright (c) 2001-2014 Peter Johnson and other Yasm developers. +Yasm is Copyright (c) 2001-2007 Peter Johnson and other Yasm developers. Yasm developers and/or contributors include: Peter Johnson Michael Urman - Brian Gladman (Visual Studio build files, other fixes) + Brian Gladman (VC8 build files, other fixes) Stanislav Karchebny (options parser) - Mathieu Monnier (SSE4 instruction patches, NASM preprocessor additions) + Mathieu Monnier (SSE4 instruction patches) Anonymous "NASM64" developer (NASM preprocessor fixes) Stephen Polkowski (x86 instruction patches) Henryk Richter (Mach-O object format) Ben Skeggs (patches, bug reports) - Alexei Svitkine (GAS preprocessor) - Samuel Thibault (TASM parser and frontend) ----------------------------------- Yasm licensing overview and summary @@ -40,7 +38,8 @@ bitvect) are fulfilled. ------- Modules ------- -The modules are 2-clause or 3-clause BSD licensed. +The modules are 2-clause or 3-clause BSD licensed, with the exception of: + preprocs/nasm - LGPL licensed --------- Frontends diff --git a/ChangeLog b/ChangeLog index 1f6ad37d..e69de29b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,11 +0,0 @@ -2014-08-10 gettextize - - * m4/gettext.m4: Upgrade to gettext-0.18.3. - * m4/iconv.m4: Upgrade to gettext-0.18.3. - * m4/lib-ld.m4: Upgrade to gettext-0.18.3. - * m4/lib-link.m4: Upgrade to gettext-0.18.3. - * m4/lib-prefix.m4: Upgrade to gettext-0.18.3. - * m4/nls.m4: Upgrade to gettext-0.18.3. - * m4/po.m4: Upgrade to gettext-0.18.3. - * m4/progtest.m4: Upgrade to gettext-0.18.3. - diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake deleted file mode 100644 index 1eb43acf..00000000 --- a/ConfigureChecks.cmake +++ /dev/null @@ -1,76 +0,0 @@ -INCLUDE(CheckCSourceCompiles) -INCLUDE(CheckCCompilerFlag) -INCLUDE(CheckFunctionExists) -INCLUDE(CheckIncludeFile) -INCLUDE(CheckSymbolExists) -INCLUDE(CheckTypeSize) -INCLUDE(CheckLibraryExists) - -FIND_PROGRAM(CPP_PROG NAMES cpp) - -# Platform-specific include files (POSIX, Win32) -CHECK_INCLUDE_FILE(locale.h HAVE_LOCALE_H) -CHECK_INCLUDE_FILE(libgen.h HAVE_LIBGEN_H) -CHECK_INCLUDE_FILE(unistd.h HAVE_UNISTD_H) -CHECK_INCLUDE_FILE(direct.h HAVE_DIRECT_H) -CHECK_INCLUDE_FILE(stdint.h HAVE_STDINT_H) - -CHECK_SYMBOL_EXISTS(abort "stdlib.h" HAVE_ABORT) - -CHECK_FUNCTION_EXISTS(getcwd HAVE_GETCWD) -CHECK_FUNCTION_EXISTS(_stricmp HAVE__STRICMP) -CHECK_FUNCTION_EXISTS(toascii HAVE_TOASCII) - -CHECK_LIBRARY_EXISTS(dl dlopen "" HAVE_LIBDL) - -IF (HAVE_LIBDL) - SET(LIBDL "dl") -ELSE (HAVE_LIBDL) - SET(LIBDL "") -ENDIF (HAVE_LIBDL) - -CONFIGURE_FILE(libyasm-stdint.h.cmake - ${CMAKE_CURRENT_BINARY_DIR}/libyasm-stdint.h) -CONFIGURE_FILE(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h) - -ADD_DEFINITIONS(-DHAVE_CONFIG_H) - -FIND_PACKAGE(Python3 REQUIRED COMPONENTS Interpreter) -set(PYTHON_EXECUTABLE "${Python3_EXECUTABLE}") -IF (NOT PYTHON_EXECUTABLE) - MESSAGE(FATAL_ERROR "Could not find Python executable") -ENDIF (NOT PYTHON_EXECUTABLE) - -IF (CMAKE_COMPILER_IS_GNUCXX) - CHECK_C_COMPILER_FLAG(-pipe C_ACCEPTS_PIPE) - CHECK_C_COMPILER_FLAG(-ansi C_ACCEPTS_ANSI) - CHECK_C_COMPILER_FLAG(-pedantic C_ACCEPTS_PEDANTIC) - CHECK_C_COMPILER_FLAG(-Wall C_ACCEPTS_WALL) - CHECK_C_COMPILER_FLAG(-Wno-unused-parameter C_ACCEPTS_WNOUNUSEDPARAM) - - IF (C_ACCEPTS_PIPE) - ADD_DEFINITIONS(-pipe) - ENDIF (C_ACCEPTS_PIPE) - - IF (C_ACCEPTS_ANSI) - ADD_DEFINITIONS(-ansi) - ENDIF (C_ACCEPTS_ANSI) - - IF (C_ACCEPTS_PEDANTIC) - ADD_DEFINITIONS(-pedantic) - ENDIF (C_ACCEPTS_PEDANTIC) - - IF (C_ACCEPTS_WALL) - ADD_DEFINITIONS(-Wall) - ENDIF (C_ACCEPTS_WALL) - - IF (C_ACCEPTS_WNOUNUSEDPARAM) - ADD_DEFINITIONS(-Wno-unused-parameter) - ENDIF (C_ACCEPTS_WNOUNUSEDPARAM) -ENDIF (CMAKE_COMPILER_IS_GNUCXX) - -# Disable some annoying Visual Studio warnings -IF (MSVC) - ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS) - ADD_DEFINITIONS(-D_CRT_NONSTDC_NO_WARNINGS) -ENDIF (MSVC) diff --git a/HACKING b/HACKING index 0c565b87..bc85acc5 100644 --- a/HACKING +++ b/HACKING @@ -1,3 +1,5 @@ +$Id$ + If you are contributing code to the YASM project or trying to compile YASM from a CVS checkout, please read this first. @@ -64,7 +66,7 @@ requires in a packaged distribution. Programs required: * m4 * gettext * make (GNU preferred) - * Python + * bison * gcc To rebuild the manpages from the DocBook XML files, the program "xmlto" and diff --git a/INSTALL b/INSTALL index 29a2b29e..b42a17ac 100644 --- a/INSTALL +++ b/INSTALL @@ -51,18 +51,6 @@ The simplest way to compile this package is: all sorts of other programs in order to regenerate files that came with the distribution. -Installation using vcpkg -================== -You can build and install yasm using [vcpkg](https://github.com/Microsoft/vcpkg/) dependency manager: - - `git clone https://github.com/Microsoft/vcpkg.git' - `cd vcpkg' - `./bootstrap-vcpkg.sh' # `./bootstrap-vcpkg.bat' for Windows - `./vcpkg integrate install' - `./vcpkg install yasm' - -The yasm port in vcpkg is kept up to date by Microsoft team members and community contributors. If the version is out of date, please [create an issue or pull request](https://github.com/Microsoft/vcpkg) on the vcpkg repository. - Compilers and Options ===================== diff --git a/Makefile.am b/Makefile.am index d955a229..f96bcca6 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,12 +1,12 @@ +# $Id$ + SUBDIRS = po . -ACLOCAL_AMFLAGS = -I m4 AM_YFLAGS = -d AM_CFLAGS = @MORE_CFLAGS@ bin_PROGRAMS = dist_man_MANS = -notrans_dist_man_MANS = TESTS = TESTS_ENVIRONMENT = noinst_PROGRAMS = genstring @@ -21,9 +21,6 @@ nodist_include_HEADERS = libyasm-stdint.h noinst_HEADERS = util.h BUILT_SOURCES = -MAINTAINERCLEANFILES = -DISTCLEANFILES = -SUFFIXES = # configure.lineno doesn't clean up after itself? CLEANFILES = configure.lineno @@ -31,8 +28,9 @@ EXTRA_DIST = config/config.rpath # libyasm-stdint.h doesn't clean up after itself? CONFIG_CLEAN_FILES = libyasm-stdint.h -CONFIG_CLEAN_FILES += YASM-VERSION-FILE -CONFIG_CLEAN_FILES += YASM-VERSION.h + +# automake doesn't distribute mkinstalldirs? +EXTRA_DIST += config/mkinstalldirs EXTRA_DIST += tools/Makefile.inc EXTRA_DIST += libyasm/Makefile.inc @@ -57,93 +55,60 @@ EXTRA_DIST += BSD.txt EXTRA_DIST += GNU_GPL-2.0 EXTRA_DIST += GNU_LGPL-2.0 EXTRA_DIST += splint.sh -EXTRA_DIST += YASM-VERSION-GEN.sh -EXTRA_DIST += CMakeLists.txt -EXTRA_DIST += ConfigureChecks.cmake -EXTRA_DIST += config.h.cmake -EXTRA_DIST += libyasm-stdint.h.cmake -EXTRA_DIST += cmake/CMakeLists.txt -EXTRA_DIST += cmake/modules/CMakeLists.txt -EXTRA_DIST += cmake/modules/DummyCFile.c -EXTRA_DIST += cmake/modules/VersionGen.cmake -EXTRA_DIST += cmake/modules/YasmMacros.cmake -EXTRA_DIST += frontends/CMakeLists.txt -EXTRA_DIST += frontends/tasm/CMakeLists.txt -EXTRA_DIST += frontends/vsyasm/CMakeLists.txt -EXTRA_DIST += frontends/yasm/CMakeLists.txt -EXTRA_DIST += frontends/yasm/genstring.py -EXTRA_DIST += frontends/yasm/yasm-plugin.c -EXTRA_DIST += frontends/yasm/yasm-plugin.h -EXTRA_DIST += libyasm/CMakeLists.txt -EXTRA_DIST += libyasm/cmake-module.c -EXTRA_DIST += modules/arch/CMakeLists.txt -EXTRA_DIST += modules/arch/lc3b/CMakeLists.txt -EXTRA_DIST += modules/arch/x86/CMakeLists.txt -EXTRA_DIST += modules/CMakeLists.txt -EXTRA_DIST += modules/dbgfmts/CMakeLists.txt -EXTRA_DIST += modules/dbgfmts/codeview/CMakeLists.txt -EXTRA_DIST += modules/dbgfmts/dwarf2/CMakeLists.txt -EXTRA_DIST += modules/dbgfmts/null/CMakeLists.txt -EXTRA_DIST += modules/dbgfmts/stabs/CMakeLists.txt -EXTRA_DIST += modules/listfmts/CMakeLists.txt -EXTRA_DIST += modules/listfmts/nasm/CMakeLists.txt -EXTRA_DIST += modules/objfmts/bin/CMakeLists.txt -EXTRA_DIST += modules/objfmts/CMakeLists.txt -EXTRA_DIST += modules/objfmts/coff/CMakeLists.txt -EXTRA_DIST += modules/objfmts/dbg/CMakeLists.txt -EXTRA_DIST += modules/objfmts/elf/CMakeLists.txt -EXTRA_DIST += modules/objfmts/macho/CMakeLists.txt -EXTRA_DIST += modules/objfmts/rdf/CMakeLists.txt -EXTRA_DIST += modules/objfmts/xdf/CMakeLists.txt -EXTRA_DIST += modules/parsers/CMakeLists.txt -EXTRA_DIST += modules/parsers/gas/CMakeLists.txt -EXTRA_DIST += modules/parsers/nasm/CMakeLists.txt -EXTRA_DIST += modules/preprocs/CMakeLists.txt -EXTRA_DIST += modules/preprocs/cpp/CMakeLists.txt -EXTRA_DIST += modules/preprocs/gas/CMakeLists.txt -EXTRA_DIST += modules/preprocs/nasm/CMakeLists.txt -EXTRA_DIST += modules/preprocs/raw/CMakeLists.txt -EXTRA_DIST += plugins/README -EXTRA_DIST += plugins/dbg/CMakeLists.txt -EXTRA_DIST += plugins/dbg/dbg-objfmt.c -EXTRA_DIST += plugins/dbg/init_plugin.c -EXTRA_DIST += plugins/dbg/README -EXTRA_DIST += plugins/x86/CMakeLists.txt -EXTRA_DIST += plugins/x86/init_plugin.c -EXTRA_DIST += plugins/x86/README -EXTRA_DIST += tools/CMakeLists.txt -EXTRA_DIST += tools/genmacro/CMakeLists.txt -EXTRA_DIST += tools/genperf/CMakeLists.txt -EXTRA_DIST += tools/re2c/CMakeLists.txt EXTRA_DIST += Mkfiles/Makefile.flat EXTRA_DIST += Mkfiles/Makefile.dj EXTRA_DIST += Mkfiles/dj/config.h EXTRA_DIST += Mkfiles/dj/libyasm-stdint.h +EXTRA_DIST += Mkfiles/vc/yasm.sln +EXTRA_DIST += Mkfiles/vc/yasm.vcproj +EXTRA_DIST += Mkfiles/vc/config.h +EXTRA_DIST += Mkfiles/vc/libyasm-stdint.h +EXTRA_DIST += Mkfiles/vc/genmacro/genmacro.vcproj +EXTRA_DIST += Mkfiles/vc/genmacro/run.bat +EXTRA_DIST += Mkfiles/vc/genmodule/genmodule.vcproj +EXTRA_DIST += Mkfiles/vc/genmodule/run.bat +EXTRA_DIST += Mkfiles/vc/genstring/genstring.vcproj +EXTRA_DIST += Mkfiles/vc/genstring/run.bat +EXTRA_DIST += Mkfiles/vc/genversion/genversion.vcproj +EXTRA_DIST += Mkfiles/vc/genversion/run.bat +EXTRA_DIST += Mkfiles/vc/libyasm/libyasm.vcproj +EXTRA_DIST += Mkfiles/vc/modules/modules.vcproj +EXTRA_DIST += Mkfiles/vc/re2c/re2c.vcproj +EXTRA_DIST += Mkfiles/vc/re2c/run.bat +EXTRA_DIST += Mkfiles/vc/gap/gap.vcproj +EXTRA_DIST += Mkfiles/vc/gap/run.bat +EXTRA_DIST += Mkfiles/vc8/crt_secure_no_deprecate.vsprops +EXTRA_DIST += Mkfiles/vc8/yasm.sln +EXTRA_DIST += Mkfiles/vc8/yasm.vcproj +EXTRA_DIST += Mkfiles/vc8/config.h +EXTRA_DIST += Mkfiles/vc8/libyasm-stdint.h +EXTRA_DIST += Mkfiles/vc8/readme.vc8.txt +EXTRA_DIST += Mkfiles/vc8/yasm.rules +EXTRA_DIST += Mkfiles/vc8/genmacro/genmacro.vcproj +EXTRA_DIST += Mkfiles/vc8/genmacro/run.bat +EXTRA_DIST += Mkfiles/vc8/genmodule/genmodule.vcproj +EXTRA_DIST += Mkfiles/vc8/genmodule/run.bat +EXTRA_DIST += Mkfiles/vc8/genstring/genstring.vcproj +EXTRA_DIST += Mkfiles/vc8/genstring/run.bat +EXTRA_DIST += Mkfiles/vc8/genversion/genversion.vcproj +EXTRA_DIST += Mkfiles/vc8/genversion/run.bat +EXTRA_DIST += Mkfiles/vc8/libyasm/libyasm.vcproj +EXTRA_DIST += Mkfiles/vc8/modules/modules.vcproj +EXTRA_DIST += Mkfiles/vc8/re2c/re2c.vcproj +EXTRA_DIST += Mkfiles/vc8/re2c/run.bat +EXTRA_DIST += Mkfiles/vc8/gap/gap.vcproj +EXTRA_DIST += Mkfiles/vc8/gap/run.bat # Until this gets fixed in automake -DISTCLEANFILES += libyasm/stamp-h libyasm/stamp-h[0-9]* +DISTCLEANFILES = libyasm/stamp-h libyasm/stamp-h[0-9]* -dist-hook: YASM-VERSION-FILE YASM-VERSION.h - cp YASM-VERSION-FILE $(distdir)/version - cp YASM-VERSION.h $(distdir)/Mkfiles/dj/ - -YASM-VERSION-FILE: $(top_srcdir)/YASM-VERSION-GEN.sh - $(top_srcdir)/YASM-VERSION-GEN.sh +ACLOCAL_AMFLAGS = -I m4 distclean-local: -rm -rf results -if HAVE_PYTHON - -rm -rf build -endif - -# Until gets fixed libyasm cross-build for target system -# use fixinstall-yasm-XXX make targets -all-local: python-build -install-exec-hook: python-install -uninstall-hook: python-uninstall if BUILD_MAN -MAINTAINERCLEANFILES += $(dist_man_MANS) $(notrans_dist_man_MANS) +MAINTAINERCLEANFILES = $(dist_man_MANS) endif # genstring build diff --git a/Mkfiles/Makefile.dj b/Mkfiles/Makefile.dj index 34773036..dab4a5ff 100644 --- a/Mkfiles/Makefile.dj +++ b/Mkfiles/Makefile.dj @@ -1,3 +1,5 @@ +# $Id$ +# # Ultra-flat Makefile for DJGPP (also works for Cygwin). # Does NOT depend on or use configure. # @@ -11,14 +13,16 @@ CFLAGS=-DHAVE_CONFIG_H -IMkfiles/dj -O -I. CC?=gcc BUILDCC?=$(CC) -all: yasm ytasm vsyasm +all: yasm LIBYASM_OBJS= \ + libyasm/arch.o \ libyasm/assocdat.o \ libyasm/bitvect.o \ libyasm/bc-align.o \ libyasm/bc-data.o \ libyasm/bc-incbin.o \ + libyasm/bc-insn.o \ libyasm/bc-org.o \ libyasm/bc-reserve.o \ libyasm/bytecode.o \ @@ -27,7 +31,6 @@ LIBYASM_OBJS= \ libyasm/file.o \ libyasm/floatnum.o \ libyasm/hamt.o \ - libyasm/insn.o \ libyasm/intnum.o \ libyasm/inttree.o \ libyasm/linemap.o \ @@ -48,20 +51,18 @@ MODULES_ARCH_X86_OBJS= \ modules/arch/x86/x86arch.o \ modules/arch/x86/x86bc.o \ modules/arch/x86/x86expr.o \ - modules/arch/x86/x86id.o \ - x86cpu.o \ - x86regtmod.o + modules/arch/x86/x86id.o YASM_MODULES=arch_x86 -MODULES_ARCH_LC3B_OBJS= \ - modules/arch/lc3b/lc3barch.o \ - modules/arch/lc3b/lc3bbc.o \ - lc3bid.o -YASM_MODULES+=arch_lc3b +#MODULES_ARCH_LC3B_OBJS= \ +# modules/arch/lc3b/lc3barch.o \ +# modules/arch/lc3b/lc3bbc.o \ +# lc3bid.o +#YASM_MODULES+=arch_lc3b MODULES_ARCH_OBJS= \ $(MODULES_ARCH_X86_OBJS) \ - $(MODULES_ARCH_LC3B_OBJS) +# $(MODULES_ARCH_LC3B_OBJS) MODULES_DBGFMTS_OBJS= \ modules/dbgfmts/null/null-dbgfmt.o \ @@ -95,9 +96,9 @@ MODULES_OBJFMTS_OBJS= \ modules/objfmts/rdf/rdf-objfmt.o \ modules/objfmts/xdf/xdf-objfmt.o YASM_MODULES+=objfmt_dbg -YASM_MODULES+=objfmt_bin objfmt_dosexe +YASM_MODULES+=objfmt_bin YASM_MODULES+=objfmt_coff objfmt_win32 objfmt_win64 objfmt_x64 -YASM_MODULES+=objfmt_elf objfmt_elf32 objfmt_elf64 objfmt_elfx32 +YASM_MODULES+=objfmt_elf objfmt_elf32 objfmt_elf64 YASM_MODULES+=objfmt_macho objfmt_macho32 objfmt_macho64 YASM_MODULES+=objfmt_rdf YASM_MODULES+=objfmt_xdf @@ -107,10 +108,9 @@ MODULES_PARSERS_OBJS= \ modules/parsers/nasm/nasm-parse.o \ nasm-token.o \ modules/parsers/gas/gas-parser.o \ - modules/parsers/gas/gas-parse-intel.o \ modules/parsers/gas/gas-parse.o \ gas-token.o -YASM_MODULES+=parser_nasm parser_tasm +YASM_MODULES+=parser_nasm YASM_MODULES+=parser_gas parser_gnu MODULES_PREPROCS_NASM_OBJS= \ @@ -118,26 +118,15 @@ MODULES_PREPROCS_NASM_OBJS= \ modules/preprocs/nasm/nasm-pp.o \ modules/preprocs/nasm/nasm-preproc.o \ modules/preprocs/nasm/nasmlib.o -YASM_MODULES+=preproc_nasm preproc_tasm +YASM_MODULES+=preproc_nasm MODULES_PREPROCS_RAW_OBJS = \ modules/preprocs/raw/raw-preproc.o YASM_MODULES+=preproc_raw -MODULES_PREPROCS_CPP_OBJS = \ - modules/preprocs/cpp/cpp-preproc.o -YASM_MODULES+=preproc_cpp - -MODULES_PREPROCS_GAS_OBJS = \ - modules/preprocs/gas/gas-eval.o \ - modules/preprocs/gas/gas-preproc.o -YASM_MODULES+=preproc_gas - MODULES_PREPROCS_OBJS = \ $(MODULES_PREPROCS_NASM_OBJS) \ - $(MODULES_PREPROCS_RAW_OBJS) \ - $(MODULES_PREPROCS_CPP_OBJS) \ - $(MODULES_PREPROCS_GAS_OBJS) + $(MODULES_PREPROCS_RAW_OBJS) MODULES_OBJS = \ $(MODULES_ARCH_OBJS) \ @@ -154,18 +143,6 @@ YASM_OBJS= \ $(LIBYASM_OBJS) \ $(MODULES_OBJS) -YTASM_OBJS= \ - frontends/tasm/tasm.o \ - frontends/tasm/tasm-options.o \ - $(LIBYASM_OBJS) \ - $(MODULES_OBJS) - -VSYASM_OBJS= \ - frontends/vsyasm/vsyasm.o \ - frontends/yasm/yasm-options.o \ - $(LIBYASM_OBJS) \ - $(MODULES_OBJS) - genstring: genstring.c $(BUILDCC) -o $@ $< @@ -174,25 +151,13 @@ license.c: COPYING genstring frontends/yasm/yasm.c: license.c -genmacro: tools/genmacro/genmacro.c +genmacro: modules/preprocs/nasm/genmacro.c $(BUILDCC) -o $@ $< -nasm-version.c: version.mac genmacro - ./genmacro $@ nasm_version_mac version.mac +nasm-macros.c: modules/preprocs/nasm/standard.mac version.mac genmacro + ./genmacro modules/preprocs/nasm/standard.mac version.mac -modules/preprocs/nasm/nasm-pp.c: nasm-version.c - -nasm-macros.c: modules/parsers/nasm/nasm-std.mac genmacro - ./genmacro $@ nasm_standard_mac modules/parsers/nasm/nasm-std.mac - -modules/parsers/nasm/nasm-parser.c: nasm-macros.c - -win64-nasm.c: modules/objfmts/coff/win64-nasm.mac genmacro - ./genmacro $@ win64_nasm_stdmac modules/objfmts/coff/win64-nasm.mac -win64-gas.c: modules/objfmts/coff/win64-gas.mac genmacro - ./genmacro $@ win64_gas_stdmac modules/objfmts/coff/win64-gas.mac - -modules/objfmts/coff/coff-objfmt.c: win64-nasm.c win64-gas.c +modules/preprocs/nasm/nasm-pp.c: nasm-macros.c genversion: modules/preprocs/nasm/genversion.c $(BUILDCC) -IMkfiles/dj -o $@ $< @@ -206,23 +171,10 @@ genmodule: libyasm/genmodule.c module.c: libyasm/module.in genmodule ./genmodule libyasm/module.in Mkfiles/Makefile.dj -x86insn_nasm.gperf x86insn_gas.gperf x86insns.c: modules/arch/x86/gen_x86_insn.py - # ignore error in case python is not installed - -python modules/arch/x86/gen_x86_insn.py +x86parse.c: modules/arch/x86/x86parse.gap gap + ./gap modules/arch/x86/x86parse.gap $@ -x86insn_nasm.c: x86insn_nasm.gperf genperf - ./genperf x86insn_nasm.gperf $@ - -x86insn_gas.c: x86insn_gas.gperf genperf - ./genperf x86insn_gas.gperf $@ - -x86cpu.c: modules/arch/x86/x86cpu.gperf genperf - ./genperf modules/arch/x86/x86cpu.gperf $@ - -x86regtmod.c: modules/arch/x86/x86regtmod.gperf genperf - ./genperf modules/arch/x86/x86regtmod.gperf $@ - -modules/arch/x86/x86id.c: x86insn_nasm.c x86insn_gas.c x86insns.c +modules/arch/x86/x86id.c: x86parse.c lc3bid.c: modules/arch/lc3b/lc3bid.re re2c ./re2c -s -o $@ modules/arch/lc3b/lc3bid.re @@ -247,25 +199,19 @@ RE2C_SRCS= \ re2c: $(RE2C_SRCS) $(BUILDCC) -I. -o re2c $(RE2C_SRCS) -GENPERF_SRCS= \ - tools/genperf/genperf.c \ - tools/genperf/perfect.c \ +GAP_SRCS= \ + tools/gap/gap.c \ + tools/gap/perfect.c \ libyasm/phash.c \ libyasm/xmalloc.c \ libyasm/xstrdup.c -genperf: $(GENPERF_SRCS) - $(BUILDCC) -I. -o genperf $(GENPERF_SRCS) +gap: $(GAP_SRCS) + $(BUILDCC) -I. -o gap $(GAP_SRCS) yasm: $(YASM_OBJS) $(CC) -o yasm $(YASM_OBJS) -ytasm: $(YTASM_OBJS) - $(CC) -o ytasm $(YTASM_OBJS) - -vsyasm: $(VSYASM_OBJS) - $(CC) -o vsyasm $(VSYASM_OBJS) - .c.o: $(CC) -c $(CFLAGS) -o $@ $< diff --git a/Mkfiles/Makefile.flat b/Mkfiles/Makefile.flat index e4d5b219..9160a245 100644 --- a/Mkfiles/Makefile.flat +++ b/Mkfiles/Makefile.flat @@ -1,3 +1,5 @@ +# $Id$ +# # Ultra-flat Makefile "prototype" for non-Unix platforms. # Does NOT depend on or use configure. # @@ -14,14 +16,16 @@ CFLAGS=-DHAVE_CONFIG_H -IMkfiles -I. CC?=gcc BUILDCC?=$(CC) -all: yasm ytasm vsyasm +all: yasm LIBYASM_OBJS= \ + libyasm/arch.o \ libyasm/assocdat.o \ libyasm/bitvect.o \ libyasm/bc-align.o \ libyasm/bc-data.o \ libyasm/bc-incbin.o \ + libyasm/bc-insn.o \ libyasm/bc-org.o \ libyasm/bc-reserve.o \ libyasm/bytecode.o \ @@ -30,7 +34,6 @@ LIBYASM_OBJS= \ libyasm/file.o \ libyasm/floatnum.o \ libyasm/hamt.o \ - libyasm/insn.o \ libyasm/intnum.o \ libyasm/inttree.o \ libyasm/linemap.o \ @@ -51,20 +54,18 @@ MODULES_ARCH_X86_OBJS= \ modules/arch/x86/x86arch.o \ modules/arch/x86/x86bc.o \ modules/arch/x86/x86expr.o \ - modules/arch/x86/x86id.o \ - x86cpu.o \ - x86regtmod.o + modules/arch/x86/x86id.o YASM_MODULES=arch_x86 -MODULES_ARCH_LC3B_OBJS= \ - modules/arch/lc3b/lc3barch.o \ - modules/arch/lc3b/lc3bbc.o \ - lc3bid.o -YASM_MODULES+=arch_lc3b +#MODULES_ARCH_LC3B_OBJS= \ +# modules/arch/lc3b/lc3barch.o \ +# modules/arch/lc3b/lc3bbc.o \ +# lc3bid.o +#YASM_MODULES+=arch_lc3b MODULES_ARCH_OBJS= \ $(MODULES_ARCH_X86_OBJS) \ - $(MODULES_ARCH_LC3B_OBJS) +# $(MODULES_ARCH_LC3B_OBJS) MODULES_DBGFMTS_OBJS= \ modules/dbgfmts/null/null-dbgfmt.o \ @@ -98,9 +99,9 @@ MODULES_OBJFMTS_OBJS= \ modules/objfmts/rdf/rdf-objfmt.o \ modules/objfmts/xdf/xdf-objfmt.o YASM_MODULES+=objfmt_dbg -YASM_MODULES+=objfmt_bin objfmt_dosexe +YASM_MODULES+=objfmt_bin YASM_MODULES+=objfmt_coff objfmt_win32 objfmt_win64 objfmt_x64 -YASM_MODULES+=objfmt_elf objfmt_elf32 objfmt_elf64 objfmt_elfx32 +YASM_MODULES+=objfmt_elf objfmt_elf32 objfmt_elf64 YASM_MODULES+=objfmt_macho objfmt_macho32 objfmt_macho64 YASM_MODULES+=objfmt_rdf YASM_MODULES+=objfmt_xdf @@ -110,10 +111,9 @@ MODULES_PARSERS_OBJS= \ modules/parsers/nasm/nasm-parse.o \ nasm-token.o \ modules/parsers/gas/gas-parser.o \ - modules/parsers/gas/gas-parse-intel.o \ modules/parsers/gas/gas-parse.o \ gas-token.o -YASM_MODULES+=parser_nasm parser_tasm +YASM_MODULES+=parser_nasm YASM_MODULES+=parser_gas parser_gnu MODULES_PREPROCS_NASM_OBJS= \ @@ -121,26 +121,15 @@ MODULES_PREPROCS_NASM_OBJS= \ modules/preprocs/nasm/nasm-pp.o \ modules/preprocs/nasm/nasm-preproc.o \ modules/preprocs/nasm/nasmlib.o -YASM_MODULES+=preproc_nasm preproc_tasm +YASM_MODULES+=preproc_nasm MODULES_PREPROCS_RAW_OBJS = \ modules/preprocs/raw/raw-preproc.o YASM_MODULES+=preproc_raw -MODULES_PREPROCS_CPP_OBJS = \ - modules/preprocs/cpp/cpp-preproc.o -YASM_MODULES+=preproc_cpp - -MODULES_PREPROCS_GAS_OBJS = \ - modules/preprocs/gas/gas-eval.o \ - modules/preprocs/gas/gas-preproc.o -YASM_MODULES+=preproc_gas - MODULES_PREPROCS_OBJS = \ $(MODULES_PREPROCS_NASM_OBJS) \ - $(MODULES_PREPROCS_RAW_OBJS) \ - $(MODULES_PREPROCS_CPP_OBJS) \ - $(MODULES_PREPROCS_GAS_OBJS) + $(MODULES_PREPROCS_RAW_OBJS) MODULES_OBJS = \ $(MODULES_ARCH_OBJS) \ @@ -157,18 +146,6 @@ YASM_OBJS= \ $(LIBYASM_OBJS) \ $(MODULES_OBJS) -YTASM_OBJS= \ - frontends/tasm/tasm.o \ - frontends/tasm/tasm-options.o \ - $(LIBYASM_OBJS) \ - $(MODULES_OBJS) - -VSYASM_OBJS= \ - frontends/vsyasm/vsyasm.o \ - frontends/yasm/yasm-options.o \ - $(LIBYASM_OBJS) \ - $(MODULES_OBJS) - genstring: genstring.c $(BUILDCC) -o $@ $< @@ -177,28 +154,16 @@ license.c: COPYING genstring frontends/yasm/yasm.c: license.c -genmacro: tools/genmacro/genmacro.c +genmacro: modules/preprocs/nasm/genmacro.c $(BUILDCC) -o $@ $< -nasm-version.c: version.mac genmacro - ./genmacro $@ nasm_version_mac version.mac +nasm-macros.c: modules/preprocs/nasm/standard.mac version.mac genmacro + ./genmacro modules/preprocs/nasm/standard.mac version.mac -modules/preprocs/nasm/nasm-pp.c: nasm-version.c +modules/preprocs/nasm/nasm-pp.c: nasm-macros.c -nasm-macros.c: modules/parsers/nasm/nasm-std.mac genmacro - ./genmacro $@ nasm_standard_mac modules/parsers/nasm/nasm-std.mac - -modules/parsers/nasm/nasm-parser.c: nasm-macros.c - -win64-nasm.c: modules/objfmts/coff/win64-nasm.mac genmacro - ./genmacro $@ win64_nasm_stdmac modules/objfmts/coff/win64-nasm.mac -win64-gas.c: modules/objfmts/coff/win64-gas.mac genmacro - ./genmacro $@ win64_gas_stdmac modules/objfmts/coff/win64-gas.mac - -modules/objfmts/coff/coff-objfmt.c: win64-nasm.c win64-gas.c - -genversion: modules/preprocs/nasm/genversion.c YASM-VERSION.h - $(BUILDCC) -IMkfiles -I. -o $@ $< +genversion: modules/preprocs/nasm/genversion.c + $(BUILDCC) -IMkfiles -o $@ $< version.mac: genversion ./genversion $@ @@ -209,23 +174,10 @@ genmodule: libyasm/genmodule.c module.c: libyasm/module.in genmodule ./genmodule libyasm/module.in Mkfiles/Makefile.flat -x86insn_nasm.gperf x86insn_gas.gperf x86insns.c: modules/arch/x86/gen_x86_insn.py - # ignore error in case python is not installed - -python modules/arch/x86/gen_x86_insn.py +x86parse.c: modules/arch/x86/x86parse.gap gap + ./gap modules/arch/x86/x86parse.gap $@ -x86insn_nasm.c: x86insn_nasm.gperf genperf - ./genperf x86insn_nasm.gperf $@ - -x86insn_gas.c: x86insn_gas.gperf genperf - ./genperf x86insn_gas.gperf $@ - -x86cpu.c: modules/arch/x86/x86cpu.gperf genperf - ./genperf modules/arch/x86/x86cpu.gperf $@ - -x86regtmod.c: modules/arch/x86/x86regtmod.gperf genperf - ./genperf modules/arch/x86/x86regtmod.gperf $@ - -modules/arch/x86/x86id.c: x86insn_nasm.c x86insn_gas.c x86insns.c +modules/arch/x86/x86id.c: x86parse.c lc3bid.c: modules/arch/lc3b/lc3bid.re re2c ./re2c -s -o $@ modules/arch/lc3b/lc3bid.re @@ -250,30 +202,19 @@ RE2C_SRCS= \ re2c: $(RE2C_SRCS) $(BUILDCC) -I. -o re2c $(RE2C_SRCS) -GENPERF_SRCS= \ - tools/genperf/genperf.c \ - tools/genperf/perfect.c \ +GAP_SRCS= \ + tools/gap/gap.c \ + tools/gap/perfect.c \ libyasm/phash.c \ libyasm/xmalloc.c \ libyasm/xstrdup.c -genperf: $(GENPERF_SRCS) - $(BUILDCC) -I. -o genperf $(GENPERF_SRCS) +gap: $(GAP_SRCS) + $(BUILDCC) -I. -o gap $(GAP_SRCS) yasm: $(YASM_OBJS) $(CC) -o yasm $(YASM_OBJS) -ytasm: $(YTASM_OBJS) - $(CC) -o ytasm $(YTASM_OBJS) - -vsyasm: $(VSYASM_OBJS) - $(CC) -o vsyasm $(VSYASM_OBJS) - .c.o: $(CC) -c $(CFLAGS) -o $@ $< -$(YASM_OBJS) $(YTASM_OBJS) $(VSYASM_OBJS): YASM-VERSION.h - -YASM-VERSION.h: YASM-VERSION-GEN.sh - sh YASM-VERSION-GEN.sh - diff --git a/Mkfiles/dj/config.h b/Mkfiles/dj/config.h index b33554ac..dfc7ddda 100644 --- a/Mkfiles/dj/config.h +++ b/Mkfiles/dj/config.h @@ -1,10 +1,8 @@ -#include "YASM-VERSION.h" -#define yasm__splitpath(path, tail) yasm__splitpath_win(path, tail) -#define yasm__abspath(path) yasm__abspath_win(path) -#define yasm__combpath(from, to) yasm__combpath_win(from, to) +/* $Id$ */ -/* Command name to run C preprocessor */ -#define CPP_PROG "gcc -E" +#define yasm__splitpath(path, tail) yasm__splitpath_win(path, tail) +#define yasm__abspath(path) yasm__abspath_win(path) +#define yasm__combpath(from, to) yasm__combpath_win(from, to) /* */ /* #undef ENABLE_NLS */ @@ -15,23 +13,12 @@ /* */ /* #undef HAVE_CATGETS */ -/* Define to 1 if you have the MacOS X function CFLocaleCopyCurrent in the - CoreFoundation framework. */ -/* #undef HAVE_CFLOCALECOPYCURRENT */ - -/* Define to 1 if you have the MacOS X function CFPreferencesCopyAppValue in - the CoreFoundation framework. */ -/* #undef HAVE_CFPREFERENCESCOPYAPPVALUE */ - /* Define if the GNU dcgettext() function is already present or preinstalled. */ /* #undef HAVE_DCGETTEXT */ -/* Define to 1 if you have the header file. */ -/* #undef HAVE_DIRECT_H */ - -/* Define to 1 if you have the `ftruncate' function. */ -#define HAVE_FTRUNCATE 1 +/* Define if you don't have `vprintf' but do have `_doprnt'. */ +/* #undef HAVE_DOPRNT */ /* Define to 1 if you have the `getcwd' function. */ #define HAVE_GETCWD 1 @@ -54,15 +41,21 @@ /* Define to 1 if you have the header file. */ /* #undef HAVE_LIBGEN_H */ +/* Define if you have the header file. */ +#define HAVE_LIMITS_H 1 + +/* Define if you have the `memcpy' function. */ +#define HAVE_MEMCPY 1 + +/* Define if you have the `memmove' function. */ +#define HAVE_MEMMOVE 1 + /* Define if you have the header file. */ #define HAVE_MEMORY_H 1 /* Define if you have the `mergesort function. */ /* #undef HAVE_MERGESORT */ -/* Define to 1 if you have the `popen' function. */ -#define HAVE_POPEN 1 - /* Define if you have the header file. */ #define HAVE_STDINT_H 1 @@ -90,44 +83,59 @@ /* Define if you have the `strncasecmp' function. */ #define HAVE_STRNCASECMP 1 +/* Define if you have the `strrchr' function. */ +#define HAVE_STRRCHR 1 + /* Define if you have the `strsep' function. */ #define HAVE_STRSEP 1 +/* Define if you have the header file. */ +#define HAVE_SYS_PARAM_H 1 + /* Define if you have the header file. */ #define HAVE_SYS_STAT_H 1 /* Define if you have the header file. */ #define HAVE_SYS_TYPES_H 1 +/* Define if you have that is POSIX.1 compatible. */ +#define HAVE_SYS_WAIT_H 1 + /* Define if you have the `toascii' function. */ #define HAVE_TOASCII 1 /* Define if you have the header file. */ #define HAVE_UNISTD_H 1 +/* Define if you have the vprintf function. */ +#define HAVE_VPRINTF 1 + /* Define to 1 if you have the `vsnprintf' function. */ /* #undef HAVE_VSNPRINTF */ -/* Define to 1 if you have the `_stricmp' function. */ -/* #undef HAVE__STRICMP */ - /* Name of package */ #define PACKAGE "yasm" /* Define to the address where bug reports for this package should be sent. */ #define PACKAGE_BUGREPORT "bug-yasm@tortall.net" +/* Define to build version of this package. */ +#define PACKAGE_BUILD "1880" + +/* Define to internal version of this package. */ +#define PACKAGE_INTVER "0.6.1" + /* Define to the full name of this package. */ #define PACKAGE_NAME "yasm" /* Define to the full name and version of this package. */ -/*#define PACKAGE_STRING "yasm HEAD"*/ +#define PACKAGE_STRING "yasm 0.6.1" /* Define to the one symbol short name of this package. */ #define PACKAGE_TARNAME "yasm" /* Define to the version of this package. */ -/*#define PACKAGE_VERSION "HEAD"*/ +#define PACKAGE_VERSION "0.6.1" /* Define if the C compiler supports function prototypes. */ #define PROTOTYPES 1 @@ -151,7 +159,7 @@ #define STDC_HEADERS 1 /* Version number of package */ -#define VERSION "HEAD" +#define VERSION "0.6.1" /* Define if using the dmalloc debugging malloc package */ /* #undef WITH_DMALLOC */ diff --git a/Mkfiles/nightly-build.pl b/Mkfiles/nightly-build.pl new file mode 100644 index 00000000..1ac17a29 --- /dev/null +++ b/Mkfiles/nightly-build.pl @@ -0,0 +1,48 @@ +#!/usr/bin/perl +# $Id$ +use POSIX qw(strftime); + +$|++; + +my $version = '0.0.1'; +my $todaydate = strftime "%Y%m%d", localtime; +my $snapshot_dir = "/home/yasm/public_html/snapshots/$todaydate"; +my $cvs_dir = '/usr/local/cvs2/yasm/chrooted-cvs/cvs'; +my $build_dir = '/home/yasm/build'; + +# Create snapshot directory +system('mkdir', $snapshot_dir); +# Relink "latest" symlink +system('rm', "$snapshot_dir/../latest"); +system('ln', '-s', $snapshot_dir, "$snapshot_dir/../latest"); +system('rm', "$snapshot_dir/../../latest"); +system('ln', '-s', $snapshot_dir, "$snapshot_dir/../../latest"); + +# Build CVS tree tarball +chdir("$cvs_dir/..") || die "Could not change to CVS directory"; +system('tar', '-czf', "$snapshot_dir/yasm-cvstree.tar.gz", 'cvs') == 0 + or die "CVS tree tarball build failed: $?."; + +# Build CVS checkout tarball +chdir($build_dir) || die "Could not change to build directory"; +system('chmod', '-R', 'u+w', 'yasm') == 0 + or die "Could not chmod old CVS checkout directory: $?."; +system('rm', '-Rf', 'yasm') == 0 + or die "Could not remove old CVS checkout directory: $?."; +system('mkdir', 'yasm') == 0 + or die "Could not create CVS checkout directory: $?."; +chdir('yasm') || die "Could not change to CVS checkout directory."; +system('cvs', '-q', "-d$cvs_dir", 'checkout', '.') == 0 + or die "CVS checkout failed: $?."; +chdir('..'); +system('tar', '-czf', "$snapshot_dir/yasm-cvs.tar.gz", 'yasm') == 0 + or die "CVS checkout tarball build failed: $?."; +chdir('yasm'); + +# Update and build distribution tarball +system("./autogen.sh >$snapshot_dir/autogen-log.txt 2>$snapshot_dir/autogen-errwarn.txt") == 0 + or die "autogen.sh failed: $?."; +system("gmake distcheck >$snapshot_dir/make-log.txt 2>$snapshot_dir/make-errwarn.txt") == 0 + or die "build failed: $?."; +system("cp *.tar.gz $snapshot_dir/") == 0 + or die "dist tarball copy failed."; diff --git a/Mkfiles/vs/config.h b/Mkfiles/vc/config.h similarity index 72% rename from Mkfiles/vs/config.h rename to Mkfiles/vc/config.h index b7f609fc..f1c55405 100644 --- a/Mkfiles/vs/config.h +++ b/Mkfiles/vc/config.h @@ -1,170 +1,181 @@ -#include "YASM-VERSION.h" -#define yasm__splitpath(path, tail) yasm__splitpath_win(path, tail) -#define yasm__abspath(path) yasm__abspath_win(path) -#define yasm__combpath(from, to) yasm__combpath_win(from, to) - -/* Command name to run C preprocessor */ -#define CPP_PROG "cpp" - -/* */ -/* #undef ENABLE_NLS */ - -/* Define if you have the `abort' function. */ -#define HAVE_ABORT 1 - -/* */ -/* #undef HAVE_CATGETS */ - -/* Define to 1 if you have the MacOS X function CFLocaleCopyCurrent in the - CoreFoundation framework. */ -/* #undef HAVE_CFLOCALECOPYCURRENT */ - -/* Define to 1 if you have the MacOS X function CFPreferencesCopyAppValue in - the CoreFoundation framework. */ -/* #undef HAVE_CFPREFERENCESCOPYAPPVALUE */ - -/* Define if the GNU dcgettext() function is already present or preinstalled. - */ -/* #undef HAVE_DCGETTEXT */ - -/* Define to 1 if you have the header file. */ -#define HAVE_DIRECT_H 1 - -/* Define to 1 if you have the `getcwd' function. */ -#define HAVE_GETCWD 1 - -/* */ -/* #undef HAVE_GETTEXT */ - -/* Define if you have the GNU C Library */ -/* #undef HAVE_GNU_C_LIBRARY */ - -/* Define if you have the iconv() function. */ -/* #undef HAVE_ICONV */ - -/* Define if you have the header file. */ -/* #undef HAVE_INTTYPES_H */ - -/* */ -/* #undef HAVE_LC_MESSAGES */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_LIBGEN_H */ - -/* Define if you have the header file. */ -/* #undef HAVE_MEMORY_H */ - -/* Define if you have the `mergesort' function. */ -/* #undef HAVE_MERGESORT */ - -/* Define to 1 if you have the `popen' function. */ -/* #undef HAVE_POPEN */ - -/* Define if you have the header file. */ -/* #undef HAVE_STDINT_H */ - -/* Define if you have the header file. */ -#define HAVE_STDLIB_H 1 - -/* */ -/* #undef HAVE_STPCPY */ - -/* Define if you have the `strcasecmp' function. */ -/* #undef HAVE_STRCASECMP */ - -/* Define if you have the `strcmpi' function. */ -/* #undef HAVE_STRCMPI */ - -/* Define if you have the `stricmp' function. */ -/* #undefine HAVE_STRICMP */ - -/* Define if you have the header file. */ -/* #undef HAVE_STRINGS_H */ - -/* Define if you have the header file. */ -#define HAVE_STRING_H 1 - -/* Define if you have the `strncasecmp' function. */ -/* #undef HAVE_STRNCASECMP */ - -/* Define if you have the `strsep' function. */ -/* #undef HAVE_STRSEP */ - -/* Define if you have the header file. */ -/* #undef HAVE_SYS_STAT_H */ - -/* Define if you have the header file. */ -#define HAVE_SYS_TYPES_H 1 - -/* Define if you have the `toascii' function. */ -#define HAVE_TOASCII 1 -#define toascii __toascii - -/* Define if you have the header file. */ -/* #undef HAVE_UNISTD_H */ - -/* Define to 1 if you have the `vsnprintf' function. */ -/* #undef HAVE_VSNPRINTF */ - -/* Define to 1 if you have the `_stricmp' function. */ -#define HAVE__STRICMP 1 - -/* Name of package */ -#define PACKAGE "yasm" - -/* Define to the address where bug reports for this package should be sent. */ -#define PACKAGE_BUGREPORT "bug-yasm@tortall.net" - -/* Define to the full name of this package. */ -#define PACKAGE_NAME "yasm" - -/* Define to the full name and version of this package. */ -#define PACKAGE_STRING "yasm HEAD" - -/* Define to the one symbol short name of this package. */ -#define PACKAGE_TARNAME "yasm" - -/* Define to the version of this package. */ -/*#define PACKAGE_VERSION "HEAD"*/ - -/* Define if the C compiler supports function prototypes. */ -#define PROTOTYPES 1 - -/* The size of a `char', as computed by sizeof. */ -/* #undef SIZEOF_CHAR */ - -/* The size of a `int', as computed by sizeof. */ -/* #undef SIZEOF_INT */ - -/* The size of a `long', as computed by sizeof. */ -/* #undef SIZEOF_LONG */ - -/* The size of a `short', as computed by sizeof. */ -/* #undef SIZEOF_SHORT */ - -/* The size of a `void*', as computed by sizeof. */ -/* #undef SIZEOF_VOIDP */ - -/* Define if you have the ANSI C header files. */ -#define STDC_HEADERS 1 - -/* Version number of package */ -#define VERSION "HEAD" - -/* Define if using the dmalloc debugging malloc package */ -/* #undef WITH_DMALLOC */ - -/* Define like PROTOTYPES; this can be used by system headers. */ -#define __PROTOTYPES 1 - -/* Define to empty if `const' does not conform to ANSI C. */ -/* #undef const */ - -/* Define as `__inline' if that's what the C compiler calls it, or to nothing - if it is not supported. */ -#ifndef __cplusplus -/* #undef inline */ -#endif - -/* Define to `unsigned' if doesn't define. */ -/* #undef size_t */ +/* $Id$ */ + +#define yasm__splitpath(path, tail) yasm__splitpath_win(path, tail) +#define yasm__abspath(path) yasm__abspath_win(path) +#define yasm__combpath(from, to) yasm__combpath_win(from, to) + +/* */ +/* #undef ENABLE_NLS */ + +/* Define if you have the `abort' function. */ +#define HAVE_ABORT 1 + +/* */ +/* #undef HAVE_CATGETS */ + +/* Define if the GNU dcgettext() function is already present or preinstalled. + */ +/* #undef HAVE_DCGETTEXT */ + +/* Define if you don't have `vprintf' but do have `_doprnt'. */ +/* #undef HAVE_DOPRNT */ + +/* Define to 1 if you have the `getcwd' function. */ +#define HAVE_GETCWD 1 + +/* */ +/* #undef HAVE_GETTEXT */ + +/* Define if you have the GNU C Library */ +/* #undef HAVE_GNU_C_LIBRARY */ + +/* Define if you have the iconv() function. */ +/* #undef HAVE_ICONV */ + +/* Define if you have the header file. */ +/* #undef HAVE_INTTYPES_H */ + +/* */ +/* #undef HAVE_LC_MESSAGES */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LIBGEN_H */ + +/* Define if you have the header file. */ +#define HAVE_LIMITS_H 1 + +/* Define if you have the `memcpy' function. */ +#define HAVE_MEMCPY 1 + +/* Define if you have the `memmove' function. */ +#define HAVE_MEMMOVE 1 + +/* Define if you have the header file. */ +/* #undef HAVE_MEMORY_H */ + +/* Define if you have the `mergesort function. */ +/* #undef HAVE_MERGESORT */ + +/* Define if you have the header file. */ +/* #undef HAVE_STDINT_H */ + +/* Define if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* */ +/* #undef HAVE_STPCPY */ + +/* Define if you have the `strcasecmp' function. */ +/* #undef HAVE_STRCASECMP */ + +/* Define if you have the `strcmpi' function. */ +/* #undefine HAVE_STRCMPI */ + +/* Define if you have the `stricmp' function. */ +#define HAVE__STRICMP 1 + +/* Define if you have the header file. */ +/* #undef HAVE_STRINGS_H */ + +/* Define if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define if you have the `strncasecmp' function. */ +/* #undef HAVE_STRNCASECMP */ + +/* Define if you have the `strrchr' function. */ +/* #undef HAVE_STRRCHR */ + +/* Define if you have the `strsep' function. */ +/* #undef HAVE_STRSEP */ + +/* Define if you have the header file. */ +/* #undef HAVE_SYS_PARAM_H */ + +/* Define if you have the header file. */ +/* #undef HAVE_SYS_STAT_H */ + +/* Define if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define if you have that is POSIX.1 compatible. */ +/* #undef HAVE_SYS_WAIT_H */ + +/* Define if you have the `toascii' function. */ +#define HAVE_TOASCII 1 +#define toascii __toascii + +/* Define if you have the header file. */ +/* #undef HAVE_UNISTD_H */ + +/* Define if you have the vprintf function. */ +#define HAVE_VPRINTF 1 + +/* Define to 1 if you have the `vsnprintf' function. */ +/* #undef HAVE_VSNPRINTF */ + +/* Name of package */ +#define PACKAGE "yasm" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "bug-yasm@tortall.net" + +/* Define to build version of this package. */ +#define PACKAGE_BUILD "BRANCH" + +/* Define to internal version of this package. */ +#define PACKAGE_INTVER "0.6.1" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "yasm" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "yasm 0.6.1" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "yasm" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "0.6.1" + +/* Define if the C compiler supports function prototypes. */ +#define PROTOTYPES 1 + +/* The size of a `char', as computed by sizeof. */ +/* #undef SIZEOF_CHAR */ + +/* The size of a `int', as computed by sizeof. */ +/* #undef SIZEOF_INT */ + +/* The size of a `long', as computed by sizeof. */ +/* #undef SIZEOF_LONG */ + +/* The size of a `short', as computed by sizeof. */ +/* #undef SIZEOF_SHORT */ + +/* The size of a `void*', as computed by sizeof. */ +/* #undef SIZEOF_VOIDP */ + +/* Define if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Version number of package */ +#define VERSION "0.6.1" + +/* Define if using the dmalloc debugging malloc package */ +/* #undef WITH_DMALLOC */ + +/* Define like PROTOTYPES; this can be used by system headers. */ +#define __PROTOTYPES 1 + +/* Define to empty if `const' does not conform to ANSI C. */ +/* #undef const */ + +/* Define as `__inline' if that's what the C compiler calls it, or to nothing + if it is not supported. */ +#ifndef __cplusplus +/* #undef inline */ +#endif + +/* Define to `unsigned' if doesn't define. */ +/* #undef size_t */ diff --git a/Mkfiles/vc/gap/gap.vcproj b/Mkfiles/vc/gap/gap.vcproj new file mode 100644 index 00000000..ee7c8770 --- /dev/null +++ b/Mkfiles/vc/gap/gap.vcproj @@ -0,0 +1,158 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Mkfiles/vc/gap/run.bat b/Mkfiles/vc/gap/run.bat new file mode 100644 index 00000000..d5060801 --- /dev/null +++ b/Mkfiles/vc/gap/run.bat @@ -0,0 +1,2 @@ +cd ..\..\..\ +%1 modules\arch\x86\x86parse.gap x86parse.c diff --git a/Mkfiles/vc/genmacro/genmacro.vcproj b/Mkfiles/vc/genmacro/genmacro.vcproj new file mode 100644 index 00000000..0f18b4bd --- /dev/null +++ b/Mkfiles/vc/genmacro/genmacro.vcproj @@ -0,0 +1,128 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Mkfiles/vc/genmacro/run.bat b/Mkfiles/vc/genmacro/run.bat new file mode 100644 index 00000000..f3323e72 --- /dev/null +++ b/Mkfiles/vc/genmacro/run.bat @@ -0,0 +1,2 @@ +cd ..\..\.. +%1 modules\preprocs\nasm\standard.mac version.mac diff --git a/Mkfiles/vc/genmodule/genmodule.vcproj b/Mkfiles/vc/genmodule/genmodule.vcproj new file mode 100644 index 00000000..0cd85b27 --- /dev/null +++ b/Mkfiles/vc/genmodule/genmodule.vcproj @@ -0,0 +1,127 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Mkfiles/vs/genmodule/run.bat b/Mkfiles/vc/genmodule/run.bat similarity index 94% rename from Mkfiles/vs/genmodule/run.bat rename to Mkfiles/vc/genmodule/run.bat index 00055692..e34a4169 100644 --- a/Mkfiles/vs/genmodule/run.bat +++ b/Mkfiles/vc/genmodule/run.bat @@ -1,3 +1,3 @@ -@echo off -cd ..\..\.. -%1 libyasm\module.in Makefile.am +@echo off +cd ..\..\.. +%1 libyasm\module.in Makefile.am diff --git a/Mkfiles/vc/genstring/genstring.vcproj b/Mkfiles/vc/genstring/genstring.vcproj new file mode 100644 index 00000000..cc1ba413 --- /dev/null +++ b/Mkfiles/vc/genstring/genstring.vcproj @@ -0,0 +1,128 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Mkfiles/vs/genstring/run.bat b/Mkfiles/vc/genstring/run.bat similarity index 95% rename from Mkfiles/vs/genstring/run.bat rename to Mkfiles/vc/genstring/run.bat index baedcecb..5864b1dc 100644 --- a/Mkfiles/vs/genstring/run.bat +++ b/Mkfiles/vc/genstring/run.bat @@ -1,2 +1,2 @@ -cd ..\..\.. -%1 license_msg license.c COPYING +cd ..\..\.. +%1 license_msg license.c COPYING diff --git a/Mkfiles/vc/genversion/genversion.vcproj b/Mkfiles/vc/genversion/genversion.vcproj new file mode 100644 index 00000000..62e252d3 --- /dev/null +++ b/Mkfiles/vc/genversion/genversion.vcproj @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Mkfiles/vs/genversion/run.bat b/Mkfiles/vc/genversion/run.bat similarity index 93% rename from Mkfiles/vs/genversion/run.bat rename to Mkfiles/vc/genversion/run.bat index 41b19cad..30edf8f1 100644 --- a/Mkfiles/vs/genversion/run.bat +++ b/Mkfiles/vc/genversion/run.bat @@ -1,2 +1,2 @@ -cd ..\..\.. -%1 version.mac +cd ..\..\.. +%1 version.mac diff --git a/Mkfiles/vs/libyasm-stdint.h b/Mkfiles/vc/libyasm-stdint.h similarity index 63% rename from Mkfiles/vs/libyasm-stdint.h rename to Mkfiles/vc/libyasm-stdint.h index 91d7d009..fed61b33 100644 --- a/Mkfiles/vs/libyasm-stdint.h +++ b/Mkfiles/vc/libyasm-stdint.h @@ -1,4 +1,8 @@ -#ifndef _UINTPTR_T_DEFINED -typedef unsigned long uintptr_t; -#define _UINTPTR_T_DEFINED -#endif +#ifndef _UINTPTR_T_DEFINED +#ifdef _WIN64 +#include +#else +typedef unsigned long uintptr_t; +#endif +#define _UINTPTR_T_DEFINED +#endif diff --git a/Mkfiles/vc/libyasm/libyasm.vcproj b/Mkfiles/vc/libyasm/libyasm.vcproj new file mode 100644 index 00000000..375f3397 --- /dev/null +++ b/Mkfiles/vc/libyasm/libyasm.vcproj @@ -0,0 +1,305 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Mkfiles/vc/modules/modules.vcproj b/Mkfiles/vc/modules/modules.vcproj new file mode 100644 index 00000000..fee60184 --- /dev/null +++ b/Mkfiles/vc/modules/modules.vcproj @@ -0,0 +1,311 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Mkfiles/vc/re2c/re2c.vcproj b/Mkfiles/vc/re2c/re2c.vcproj new file mode 100644 index 00000000..13579b6e --- /dev/null +++ b/Mkfiles/vc/re2c/re2c.vcproj @@ -0,0 +1,197 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Mkfiles/vs/re2c/run.bat b/Mkfiles/vc/re2c/run.bat similarity index 97% rename from Mkfiles/vs/re2c/run.bat rename to Mkfiles/vc/re2c/run.bat index 6ac571f0..cde2a7b6 100644 --- a/Mkfiles/vs/re2c/run.bat +++ b/Mkfiles/vc/re2c/run.bat @@ -1,4 +1,4 @@ -cd ..\..\..\ -%1 -s -o lc3bid.c modules\arch\lc3b\lc3bid.re -%1 -b -o nasm-token.c modules\parsers\nasm\nasm-token.re -%1 -b -o gas-token.c modules\parsers\gas\gas-token.re +cd ..\..\..\ +%1 -s -o lc3bid.c modules\arch\lc3b\lc3bid.re +%1 -b -o nasm-token.c modules\parsers\nasm\nasm-token.re +%1 -b -o gas-token.c modules\parsers\gas\gas-token.re diff --git a/Mkfiles/vc/yasm.sln b/Mkfiles/vc/yasm.sln new file mode 100644 index 00000000..8921a59d --- /dev/null +++ b/Mkfiles/vc/yasm.sln @@ -0,0 +1,94 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libyasm", "libyasm\libyasm.vcproj", "{29FE7874-1256-4AD6-B889-68E399DC9608}" + ProjectSection(ProjectDependencies) = postProject + {F0E8B707-00C5-4FF2-B8EF-7C39817132A0} = {F0E8B707-00C5-4FF2-B8EF-7C39817132A0} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "modules", "modules\modules.vcproj", "{D715A3D4-EFAA-442E-AD8B-5B4FF64E1DD6}" + ProjectSection(ProjectDependencies) = postProject + {3C58BE13-50A3-4583-984D-D8902B3D7713} = {3C58BE13-50A3-4583-984D-D8902B3D7713} + {5758BF4E-ABC4-11DA-B012-B622A1EF5492} = {5758BF4E-ABC4-11DA-B012-B622A1EF5492} + {29FE7874-1256-4AD6-B889-68E399DC9608} = {29FE7874-1256-4AD6-B889-68E399DC9608} + {225700A5-07B8-434E-AD61-555278BF6733} = {225700A5-07B8-434E-AD61-555278BF6733} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "yasm", "yasm.vcproj", "{34EB1BEB-C2D6-4A52-82B7-7ACD714A30D5}" + ProjectSection(ProjectDependencies) = postProject + {29FE7874-1256-4AD6-B889-68E399DC9608} = {29FE7874-1256-4AD6-B889-68E399DC9608} + {D715A3D4-EFAA-442E-AD8B-5B4FF64E1DD6} = {D715A3D4-EFAA-442E-AD8B-5B4FF64E1DD6} + {021CEB0A-F721-4F59-B349-9CEEAF244459} = {021CEB0A-F721-4F59-B349-9CEEAF244459} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "genmacro", "genmacro\genmacro.vcproj", "{225700A5-07B8-434E-AD61-555278BF6733}" + ProjectSection(ProjectDependencies) = postProject + {B545983B-8EE0-4A7B-A67A-E749EEAE62A2} = {B545983B-8EE0-4A7B-A67A-E749EEAE62A2} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "genversion", "genversion\genversion.vcproj", "{B545983B-8EE0-4A7B-A67A-E749EEAE62A2}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "re2c", "re2c\re2c.vcproj", "{3C58BE13-50A3-4583-984D-D8902B3D7713}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gap", "gap\gap.vcproj", "{5758BF4E-ABC4-11DA-B012-B622A1EF5492}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "genmodule", "genmodule\genmodule.vcproj", "{F0E8B707-00C5-4FF2-B8EF-7C39817132A0}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "genstring", "genstring\genstring.vcproj", "{021CEB0A-F721-4F59-B349-9CEEAF244459}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {29FE7874-1256-4AD6-B889-68E399DC9608}.Debug.ActiveCfg = Debug|Win32 + {29FE7874-1256-4AD6-B889-68E399DC9608}.Debug.Build.0 = Debug|Win32 + {29FE7874-1256-4AD6-B889-68E399DC9608}.Release.ActiveCfg = Release|Win32 + {29FE7874-1256-4AD6-B889-68E399DC9608}.Release.Build.0 = Release|Win32 + {D715A3D4-EFAA-442E-AD8B-5B4FF64E1DD6}.Debug.ActiveCfg = Debug|Win32 + {D715A3D4-EFAA-442E-AD8B-5B4FF64E1DD6}.Debug.Build.0 = Debug|Win32 + {D715A3D4-EFAA-442E-AD8B-5B4FF64E1DD6}.Release.ActiveCfg = Release|Win32 + {D715A3D4-EFAA-442E-AD8B-5B4FF64E1DD6}.Release.Build.0 = Release|Win32 + {34EB1BEB-C2D6-4A52-82B7-7ACD714A30D5}.Debug.ActiveCfg = Debug|Win32 + {34EB1BEB-C2D6-4A52-82B7-7ACD714A30D5}.Debug.Build.0 = Debug|Win32 + {34EB1BEB-C2D6-4A52-82B7-7ACD714A30D5}.Release.ActiveCfg = Release|Win32 + {34EB1BEB-C2D6-4A52-82B7-7ACD714A30D5}.Release.Build.0 = Release|Win32 + {225700A5-07B8-434E-AD61-555278BF6733}.Debug.ActiveCfg = Debug|Win32 + {225700A5-07B8-434E-AD61-555278BF6733}.Debug.Build.0 = Debug|Win32 + {225700A5-07B8-434E-AD61-555278BF6733}.Release.ActiveCfg = Release|Win32 + {225700A5-07B8-434E-AD61-555278BF6733}.Release.Build.0 = Release|Win32 + {B545983B-8EE0-4A7B-A67A-E749EEAE62A2}.Debug.ActiveCfg = Debug|Win32 + {B545983B-8EE0-4A7B-A67A-E749EEAE62A2}.Debug.Build.0 = Debug|Win32 + {B545983B-8EE0-4A7B-A67A-E749EEAE62A2}.Release.ActiveCfg = Release|Win32 + {B545983B-8EE0-4A7B-A67A-E749EEAE62A2}.Release.Build.0 = Release|Win32 + {3C58BE13-50A3-4583-984D-D8902B3D7713}.Debug.ActiveCfg = Debug|Win32 + {3C58BE13-50A3-4583-984D-D8902B3D7713}.Debug.Build.0 = Debug|Win32 + {3C58BE13-50A3-4583-984D-D8902B3D7713}.Release.ActiveCfg = Release|Win32 + {3C58BE13-50A3-4583-984D-D8902B3D7713}.Release.Build.0 = Release|Win32 + {5758BF4E-ABC4-11DA-B012-B622A1EF5492}.Debug.ActiveCfg = Debug|Win32 + {5758BF4E-ABC4-11DA-B012-B622A1EF5492}.Debug.Build.0 = Debug|Win32 + {5758BF4E-ABC4-11DA-B012-B622A1EF5492}.Release.ActiveCfg = Release|Win32 + {5758BF4E-ABC4-11DA-B012-B622A1EF5492}.Release.Build.0 = Release|Win32 + {F0E8B707-00C5-4FF2-B8EF-7C39817132A0}.Debug.ActiveCfg = Debug|Win32 + {F0E8B707-00C5-4FF2-B8EF-7C39817132A0}.Debug.Build.0 = Debug|Win32 + {F0E8B707-00C5-4FF2-B8EF-7C39817132A0}.Release.ActiveCfg = Release|Win32 + {F0E8B707-00C5-4FF2-B8EF-7C39817132A0}.Release.Build.0 = Release|Win32 + {021CEB0A-F721-4F59-B349-9CEEAF244459}.Debug.ActiveCfg = Debug|Win32 + {021CEB0A-F721-4F59-B349-9CEEAF244459}.Debug.Build.0 = Debug|Win32 + {021CEB0A-F721-4F59-B349-9CEEAF244459}.Release.ActiveCfg = Release|Win32 + {021CEB0A-F721-4F59-B349-9CEEAF244459}.Release.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Mkfiles/vc/yasm.vcproj b/Mkfiles/vc/yasm.vcproj new file mode 100644 index 00000000..70a25a9f --- /dev/null +++ b/Mkfiles/vc/yasm.vcproj @@ -0,0 +1,161 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Mkfiles/vc8/config.h b/Mkfiles/vc8/config.h new file mode 100644 index 00000000..75c731de --- /dev/null +++ b/Mkfiles/vc8/config.h @@ -0,0 +1,181 @@ +/* $Id: config.h 1137 2004-09-04 01:24:57Z peter $ */ + +#define yasm__splitpath(path, tail) yasm__splitpath_win(path, tail) +#define yasm__abspath(path) yasm__abspath_win(path) +#define yasm__combpath(from, to) yasm__combpath_win(from, to) + +/* */ +/* #undef ENABLE_NLS */ + +/* Define if you have the `abort' function. */ +#define HAVE_ABORT 1 + +/* */ +/* #undef HAVE_CATGETS */ + +/* Define if the GNU dcgettext() function is already present or preinstalled. + */ +/* #undef HAVE_DCGETTEXT */ + +/* Define if you don't have `vprintf' but do have `_doprnt'. */ +/* #undef HAVE_DOPRNT */ + +/* Define to 1 if you have the `getcwd' function. */ +#define HAVE_GETCWD 1 + +/* */ +/* #undef HAVE_GETTEXT */ + +/* Define if you have the GNU C Library */ +/* #undef HAVE_GNU_C_LIBRARY */ + +/* Define if you have the iconv() function. */ +/* #undef HAVE_ICONV */ + +/* Define if you have the header file. */ +/* #undef HAVE_INTTYPES_H */ + +/* */ +/* #undef HAVE_LC_MESSAGES */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LIBGEN_H */ + +/* Define if you have the header file. */ +#define HAVE_LIMITS_H 1 + +/* Define if you have the `memcpy' function. */ +#define HAVE_MEMCPY 1 + +/* Define if you have the `memmove' function. */ +#define HAVE_MEMMOVE 1 + +/* Define if you have the header file. */ +/* #undef HAVE_MEMORY_H */ + +/* Define if you have the `mergesort function. */ +/* #undef HAVE_MERGESORT */ + +/* Define if you have the header file. */ +/* #undef HAVE_STDINT_H */ + +/* Define if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* */ +/* #undef HAVE_STPCPY */ + +/* Define if you have the `strcasecmp' function. */ +/* #undef HAVE_STRCASECMP */ + +/* Define if you have the `strcmpi' function. */ +/* #undef HAVE_STRCMPI */ + +/* Define if you have the `stricmp' function. */ +#define HAVE__STRICMP 1 + +/* Define if you have the header file. */ +/* #undef HAVE_STRINGS_H */ + +/* Define if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define if you have the `strncasecmp' function. */ +/* #undef HAVE_STRNCASECMP */ + +/* Define if you have the `strrchr' function. */ +/* #undef HAVE_STRRCHR */ + +/* Define if you have the `strsep' function. */ +/* #undef HAVE_STRSEP */ + +/* Define if you have the header file. */ +/* #undef HAVE_SYS_PARAM_H */ + +/* Define if you have the header file. */ +/* #undef HAVE_SYS_STAT_H */ + +/* Define if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define if you have that is POSIX.1 compatible. */ +/* #undef HAVE_SYS_WAIT_H */ + +/* Define if you have the `toascii' function. */ +#define HAVE_TOASCII 1 +#define toascii __toascii + +/* Define if you have the header file. */ +/* #undef HAVE_UNISTD_H */ + +/* Define if you have the vprintf function. */ +#define HAVE_VPRINTF 1 + +/* Define to 1 if you have the `vsnprintf' function. */ +/* #undef HAVE_VSNPRINTF */ + +/* Name of package */ +#define PACKAGE "yasm" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "bug-yasm@tortall.net" + +/* Define to build version of this package. */ +#define PACKAGE_BUILD "BRANCH" + +/* Define to internal version of this package. */ +#define PACKAGE_INTVER "0.6.1" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "yasm" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "yasm 0.6.1" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "yasm" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "0.6.1" + +/* Define if the C compiler supports function prototypes. */ +#define PROTOTYPES 1 + +/* The size of a `char', as computed by sizeof. */ +/* #undef SIZEOF_CHAR */ + +/* The size of a `int', as computed by sizeof. */ +/* #undef SIZEOF_INT */ + +/* The size of a `long', as computed by sizeof. */ +/* #undef SIZEOF_LONG */ + +/* The size of a `short', as computed by sizeof. */ +/* #undef SIZEOF_SHORT */ + +/* The size of a `void*', as computed by sizeof. */ +/* #undef SIZEOF_VOIDP */ + +/* Define if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Version number of package */ +#define VERSION "0.6.1" + +/* Define if using the dmalloc debugging malloc package */ +/* #undef WITH_DMALLOC */ + +/* Define like PROTOTYPES; this can be used by system headers. */ +#define __PROTOTYPES 1 + +/* Define to empty if `const' does not conform to ANSI C. */ +/* #undef const */ + +/* Define as `__inline' if that's what the C compiler calls it, or to nothing + if it is not supported. */ +#ifndef __cplusplus +/* #undef inline */ +#endif + +/* Define to `unsigned' if doesn't define. */ +/* #undef size_t */ diff --git a/Mkfiles/vs/crt_secure_no_deprecate.vsprops b/Mkfiles/vc8/crt_secure_no_deprecate.vsprops similarity index 96% rename from Mkfiles/vs/crt_secure_no_deprecate.vsprops rename to Mkfiles/vc8/crt_secure_no_deprecate.vsprops index 56ab506f..d61ba30a 100644 --- a/Mkfiles/vs/crt_secure_no_deprecate.vsprops +++ b/Mkfiles/vc8/crt_secure_no_deprecate.vsprops @@ -1,11 +1,11 @@ - - - - + + + + diff --git a/Mkfiles/vc8/gap/gap.vcproj b/Mkfiles/vc8/gap/gap.vcproj new file mode 100644 index 00000000..9ba90035 --- /dev/null +++ b/Mkfiles/vc8/gap/gap.vcproj @@ -0,0 +1,233 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Mkfiles/vc8/gap/run.bat b/Mkfiles/vc8/gap/run.bat new file mode 100644 index 00000000..d5060801 --- /dev/null +++ b/Mkfiles/vc8/gap/run.bat @@ -0,0 +1,2 @@ +cd ..\..\..\ +%1 modules\arch\x86\x86parse.gap x86parse.c diff --git a/Mkfiles/vc8/genmacro/genmacro.vcproj b/Mkfiles/vc8/genmacro/genmacro.vcproj new file mode 100644 index 00000000..6c0b6118 --- /dev/null +++ b/Mkfiles/vc8/genmacro/genmacro.vcproj @@ -0,0 +1,201 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Mkfiles/vc8/genmacro/run.bat b/Mkfiles/vc8/genmacro/run.bat new file mode 100644 index 00000000..f3323e72 --- /dev/null +++ b/Mkfiles/vc8/genmacro/run.bat @@ -0,0 +1,2 @@ +cd ..\..\.. +%1 modules\preprocs\nasm\standard.mac version.mac diff --git a/Mkfiles/vc8/genmodule/genmodule.vcproj b/Mkfiles/vc8/genmodule/genmodule.vcproj new file mode 100644 index 00000000..b55f7125 --- /dev/null +++ b/Mkfiles/vc8/genmodule/genmodule.vcproj @@ -0,0 +1,203 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Mkfiles/vc8/genmodule/run.bat b/Mkfiles/vc8/genmodule/run.bat new file mode 100644 index 00000000..e34a4169 --- /dev/null +++ b/Mkfiles/vc8/genmodule/run.bat @@ -0,0 +1,3 @@ +@echo off +cd ..\..\.. +%1 libyasm\module.in Makefile.am diff --git a/Mkfiles/vc8/genstring/genstring.vcproj b/Mkfiles/vc8/genstring/genstring.vcproj new file mode 100644 index 00000000..9910c8b4 --- /dev/null +++ b/Mkfiles/vc8/genstring/genstring.vcproj @@ -0,0 +1,201 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Mkfiles/vc8/genstring/run.bat b/Mkfiles/vc8/genstring/run.bat new file mode 100644 index 00000000..5864b1dc --- /dev/null +++ b/Mkfiles/vc8/genstring/run.bat @@ -0,0 +1,2 @@ +cd ..\..\.. +%1 license_msg license.c COPYING diff --git a/Mkfiles/vc8/genversion/genversion.vcproj b/Mkfiles/vc8/genversion/genversion.vcproj new file mode 100644 index 00000000..c65952fa --- /dev/null +++ b/Mkfiles/vc8/genversion/genversion.vcproj @@ -0,0 +1,212 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Mkfiles/vc8/genversion/run.bat b/Mkfiles/vc8/genversion/run.bat new file mode 100644 index 00000000..30edf8f1 --- /dev/null +++ b/Mkfiles/vc8/genversion/run.bat @@ -0,0 +1,2 @@ +cd ..\..\.. +%1 version.mac diff --git a/Mkfiles/vc8/libyasm-stdint.h b/Mkfiles/vc8/libyasm-stdint.h new file mode 100644 index 00000000..fed61b33 --- /dev/null +++ b/Mkfiles/vc8/libyasm-stdint.h @@ -0,0 +1,8 @@ +#ifndef _UINTPTR_T_DEFINED +#ifdef _WIN64 +#include +#else +typedef unsigned long uintptr_t; +#endif +#define _UINTPTR_T_DEFINED +#endif diff --git a/Mkfiles/vc8/libyasm/libyasm.vcproj b/Mkfiles/vc8/libyasm/libyasm.vcproj new file mode 100644 index 00000000..287c988f --- /dev/null +++ b/Mkfiles/vc8/libyasm/libyasm.vcproj @@ -0,0 +1,571 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Mkfiles/vc8/modules/modules.vcproj b/Mkfiles/vc8/modules/modules.vcproj new file mode 100644 index 00000000..03821e78 --- /dev/null +++ b/Mkfiles/vc8/modules/modules.vcproj @@ -0,0 +1,561 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Mkfiles/vc8/re2c/re2c.vcproj b/Mkfiles/vc8/re2c/re2c.vcproj new file mode 100644 index 00000000..84de9b8b --- /dev/null +++ b/Mkfiles/vc8/re2c/re2c.vcproj @@ -0,0 +1,281 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Mkfiles/vc8/re2c/run.bat b/Mkfiles/vc8/re2c/run.bat new file mode 100644 index 00000000..cde2a7b6 --- /dev/null +++ b/Mkfiles/vc8/re2c/run.bat @@ -0,0 +1,4 @@ +cd ..\..\..\ +%1 -s -o lc3bid.c modules\arch\lc3b\lc3bid.re +%1 -b -o nasm-token.c modules\parsers\nasm\nasm-token.re +%1 -b -o gas-token.c modules\parsers\gas\gas-token.re diff --git a/Mkfiles/vc8/readme.vc8.txt b/Mkfiles/vc8/readme.vc8.txt new file mode 100644 index 00000000..03741bfa --- /dev/null +++ b/Mkfiles/vc8/readme.vc8.txt @@ -0,0 +1,98 @@ + +Building YASM with Microsoft Visual Studio 2005 +----------------------------------------------- + +This note describes how to build YASM using Microsoft Visual Studio 2005. + +1. The Compiler +--------------- + +If you want to build the 64-bit version of YASM you will need to install +the Visual Studio 2005 64-bit tools, which are not installed by default. + +2. YASM Download +---------------- + +First YASM needs to be downloaded and the files placed within a suitable +directory, which will be called here but can be named and located +as you wish. + +3. Building YASM with Microsoft VC8 +----------------------------------- + +Now locate and double click on the yasm.sln solution file in the 'Mkfiles/vc8' +subdirectory to open the build project in the Visual Studio 2005 IDE and then +select: + + win32 or x64 build + release or debug build + +as appropriate to build the YASM binaries that you need. + +4. Using YASM with Visual Sudio 2005 and VC++ version 8 +------------------------------------------------------- + +1. Firstly you need to locate the directory (or directories) where the VC++ +compiler binaries are located and put copies of the appropriate yasm.exe +binary in these directories. + +On a win32 system you will use the win32 version of YASM. On an x64 system +you can use either the 32 or the 64 bit versions. The win32 YASM binary +should be placed in the 32-bit VC++ binary directory, which is typically +located at: + + Program Files (x86)\Microsoft Visual Studio 8\VC\bin + +If needed the 64-bit YASM binary should be places in the 64-bit tools +binary directory, which is typically at: + + Program Files\Microsoft Visual Studio 8\VC\bin + +2. To use the new custom tools facility in Visual Studio 2005, you need to +place a copy of the yasm.rules file in the Visual Studio 2005 VC project +defaults directory, which is typically located at: + + Program Files (x86)\Microsoft Visual Studio 8\VC\VCProjectDefaults + +This allows you to configure YASM as an assembler within the VC++ IDE. To +use YASM in a project, right click on the project in the Solution Explorer +and select 'Custom Build Rules..'. This will give you a dialog box that +allows you to select YASM as an assembler (note that your assembler files +need to have the extension '.asm'). + +To assemble a file with YASM, select the Property Page for the file and the +select 'Yasm Assembler' in the Tool dialog entry. Then click 'Apply' and an +additional property page entry will appear and enable YASM settings to be +established. + +As alternative to placing the yasm.rules files as described above is to set +the rules file path in the Visual Studio 2005 settings dialogue. + +It is also important to note that the rules file passes the symbols 'Win32' +or 'x64' to YASM by using the Visual Studio 2005 $(PlatformName) macro in +order to obtain either a 32 or a 64 bit assembler mode. This is a recent +enhancement to YASM so you will need to be sure that your YASM files are at +revision r1331 or higher to use this facility. + +5. A Linker Issue +----------------- + +There appears to be a linker bug in the VC++ v8 linker that prevents symbols +with absolute addresses being linked in DLL builds. This means, for example, +that LEA instructions of the general form: + + lea, rax,[rax+symbol] + +cannot be used for DLL builds. The following general form has to be used +instead: + + lea rcx,[symbol wrt rip] + lea rax,[rax+rcx] + +This limitation may also cause problems with other instruction that use +absolute addresses. + +I am most grateful for the fantastic support that Peter Johnson, YASM's +creator, has given me in tracking down this issue. + + Brian Gladman, 16th January 2006 diff --git a/Mkfiles/vc8/yasm.rules b/Mkfiles/vc8/yasm.rules new file mode 100644 index 00000000..3001425e --- /dev/null +++ b/Mkfiles/vc8/yasm.rules @@ -0,0 +1,114 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Mkfiles/vs/yasm.sln b/Mkfiles/vc8/yasm.sln similarity index 67% rename from Mkfiles/vs/yasm.sln rename to Mkfiles/vc8/yasm.sln index 8d3b03a4..6717facf 100644 --- a/Mkfiles/vs/yasm.sln +++ b/Mkfiles/vc8/yasm.sln @@ -1,145 +1,128 @@ -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30320.27 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{825AC694-358C-4D8D-92DE-33A2691978CE}" - ProjectSection(SolutionItems) = preProject - crt_secure_no_deprecate.vsprops = crt_secure_no_deprecate.vsprops - readme.vs.txt = readme.vs.txt - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libyasm", "libyasm\libyasm.vcxproj", "{29FE7874-1256-4AD6-B889-68E399DC9608}" - ProjectSection(ProjectDependencies) = postProject - {B545983B-8EE0-4A7B-A67A-E749EEAE62A2} = {B545983B-8EE0-4A7B-A67A-E749EEAE62A2} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "modules", "modules\modules.vcxproj", "{D715A3D4-EFAA-442E-AD8B-5B4FF64E1DD6}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "yasm", "yasm.vcxproj", "{34EB1BEB-C2D6-4A52-82B7-7ACD714A30D5}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "genmacro", "genmacro\genmacro.vcxproj", "{225700A5-07B8-434E-AD61-555278BF6733}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "genversion", "genversion\genversion.vcxproj", "{B545983B-8EE0-4A7B-A67A-E749EEAE62A2}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "re2c", "re2c\re2c.vcxproj", "{3C58BE13-50A3-4583-984D-D8902B3D7713}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "genperf", "genperf\genperf.vcxproj", "{C45A8B59-8B59-4D5D-A8E8-FB090F8DD619}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "genmodule", "genmodule\genmodule.vcxproj", "{F0E8B707-00C5-4FF2-B8EF-7C39817132A0}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "genstring", "genstring\genstring.vcxproj", "{021CEB0A-F721-4F59-B349-9CEEAF244459}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ytasm", "ytasm.vcxproj", "{2162937B-0DBD-4450-B45F-DF578D8E7508}" - ProjectSection(ProjectDependencies) = postProject - {021CEB0A-F721-4F59-B349-9CEEAF244459} = {021CEB0A-F721-4F59-B349-9CEEAF244459} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vsyasm", "vsyasm.vcxproj", "{7FDD85BB-CC86-442B-A425-989B5B296ED5}" - ProjectSection(ProjectDependencies) = postProject - {021CEB0A-F721-4F59-B349-9CEEAF244459} = {021CEB0A-F721-4F59-B349-9CEEAF244459} - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {29FE7874-1256-4AD6-B889-68E399DC9608}.Debug|Win32.ActiveCfg = Debug|Win32 - {29FE7874-1256-4AD6-B889-68E399DC9608}.Debug|Win32.Build.0 = Debug|Win32 - {29FE7874-1256-4AD6-B889-68E399DC9608}.Debug|x64.ActiveCfg = Debug|x64 - {29FE7874-1256-4AD6-B889-68E399DC9608}.Debug|x64.Build.0 = Debug|x64 - {29FE7874-1256-4AD6-B889-68E399DC9608}.Release|Win32.ActiveCfg = Release|Win32 - {29FE7874-1256-4AD6-B889-68E399DC9608}.Release|Win32.Build.0 = Release|Win32 - {29FE7874-1256-4AD6-B889-68E399DC9608}.Release|x64.ActiveCfg = Release|x64 - {29FE7874-1256-4AD6-B889-68E399DC9608}.Release|x64.Build.0 = Release|x64 - {D715A3D4-EFAA-442E-AD8B-5B4FF64E1DD6}.Debug|Win32.ActiveCfg = Debug|Win32 - {D715A3D4-EFAA-442E-AD8B-5B4FF64E1DD6}.Debug|Win32.Build.0 = Debug|Win32 - {D715A3D4-EFAA-442E-AD8B-5B4FF64E1DD6}.Debug|x64.ActiveCfg = Debug|x64 - {D715A3D4-EFAA-442E-AD8B-5B4FF64E1DD6}.Debug|x64.Build.0 = Debug|x64 - {D715A3D4-EFAA-442E-AD8B-5B4FF64E1DD6}.Release|Win32.ActiveCfg = Release|Win32 - {D715A3D4-EFAA-442E-AD8B-5B4FF64E1DD6}.Release|Win32.Build.0 = Release|Win32 - {D715A3D4-EFAA-442E-AD8B-5B4FF64E1DD6}.Release|x64.ActiveCfg = Release|x64 - {D715A3D4-EFAA-442E-AD8B-5B4FF64E1DD6}.Release|x64.Build.0 = Release|x64 - {34EB1BEB-C2D6-4A52-82B7-7ACD714A30D5}.Debug|Win32.ActiveCfg = Debug|Win32 - {34EB1BEB-C2D6-4A52-82B7-7ACD714A30D5}.Debug|Win32.Build.0 = Debug|Win32 - {34EB1BEB-C2D6-4A52-82B7-7ACD714A30D5}.Debug|x64.ActiveCfg = Debug|x64 - {34EB1BEB-C2D6-4A52-82B7-7ACD714A30D5}.Debug|x64.Build.0 = Debug|x64 - {34EB1BEB-C2D6-4A52-82B7-7ACD714A30D5}.Release|Win32.ActiveCfg = Release|Win32 - {34EB1BEB-C2D6-4A52-82B7-7ACD714A30D5}.Release|Win32.Build.0 = Release|Win32 - {34EB1BEB-C2D6-4A52-82B7-7ACD714A30D5}.Release|x64.ActiveCfg = Release|x64 - {34EB1BEB-C2D6-4A52-82B7-7ACD714A30D5}.Release|x64.Build.0 = Release|x64 - {225700A5-07B8-434E-AD61-555278BF6733}.Debug|Win32.ActiveCfg = Debug|Win32 - {225700A5-07B8-434E-AD61-555278BF6733}.Debug|Win32.Build.0 = Debug|Win32 - {225700A5-07B8-434E-AD61-555278BF6733}.Debug|x64.ActiveCfg = Debug|Win32 - {225700A5-07B8-434E-AD61-555278BF6733}.Debug|x64.Build.0 = Debug|Win32 - {225700A5-07B8-434E-AD61-555278BF6733}.Release|Win32.ActiveCfg = Release|Win32 - {225700A5-07B8-434E-AD61-555278BF6733}.Release|Win32.Build.0 = Release|Win32 - {225700A5-07B8-434E-AD61-555278BF6733}.Release|x64.ActiveCfg = Release|x64 - {225700A5-07B8-434E-AD61-555278BF6733}.Release|x64.Build.0 = Release|x64 - {B545983B-8EE0-4A7B-A67A-E749EEAE62A2}.Debug|Win32.ActiveCfg = Debug|Win32 - {B545983B-8EE0-4A7B-A67A-E749EEAE62A2}.Debug|Win32.Build.0 = Debug|Win32 - {B545983B-8EE0-4A7B-A67A-E749EEAE62A2}.Debug|x64.ActiveCfg = Debug|Win32 - {B545983B-8EE0-4A7B-A67A-E749EEAE62A2}.Debug|x64.Build.0 = Debug|Win32 - {B545983B-8EE0-4A7B-A67A-E749EEAE62A2}.Release|Win32.ActiveCfg = Release|Win32 - {B545983B-8EE0-4A7B-A67A-E749EEAE62A2}.Release|Win32.Build.0 = Release|Win32 - {B545983B-8EE0-4A7B-A67A-E749EEAE62A2}.Release|x64.ActiveCfg = Release|x64 - {B545983B-8EE0-4A7B-A67A-E749EEAE62A2}.Release|x64.Build.0 = Release|x64 - {3C58BE13-50A3-4583-984D-D8902B3D7713}.Debug|Win32.ActiveCfg = Debug|Win32 - {3C58BE13-50A3-4583-984D-D8902B3D7713}.Debug|Win32.Build.0 = Debug|Win32 - {3C58BE13-50A3-4583-984D-D8902B3D7713}.Debug|x64.ActiveCfg = Debug|Win32 - {3C58BE13-50A3-4583-984D-D8902B3D7713}.Debug|x64.Build.0 = Debug|Win32 - {3C58BE13-50A3-4583-984D-D8902B3D7713}.Release|Win32.ActiveCfg = Release|Win32 - {3C58BE13-50A3-4583-984D-D8902B3D7713}.Release|Win32.Build.0 = Release|Win32 - {3C58BE13-50A3-4583-984D-D8902B3D7713}.Release|x64.ActiveCfg = Release|x64 - {3C58BE13-50A3-4583-984D-D8902B3D7713}.Release|x64.Build.0 = Release|x64 - {C45A8B59-8B59-4D5D-A8E8-FB090F8DD619}.Debug|Win32.ActiveCfg = Debug|Win32 - {C45A8B59-8B59-4D5D-A8E8-FB090F8DD619}.Debug|Win32.Build.0 = Debug|Win32 - {C45A8B59-8B59-4D5D-A8E8-FB090F8DD619}.Debug|x64.ActiveCfg = Debug|Win32 - {C45A8B59-8B59-4D5D-A8E8-FB090F8DD619}.Debug|x64.Build.0 = Debug|Win32 - {C45A8B59-8B59-4D5D-A8E8-FB090F8DD619}.Release|Win32.ActiveCfg = Release|Win32 - {C45A8B59-8B59-4D5D-A8E8-FB090F8DD619}.Release|Win32.Build.0 = Release|Win32 - {C45A8B59-8B59-4D5D-A8E8-FB090F8DD619}.Release|x64.ActiveCfg = Release|x64 - {C45A8B59-8B59-4D5D-A8E8-FB090F8DD619}.Release|x64.Build.0 = Release|x64 - {F0E8B707-00C5-4FF2-B8EF-7C39817132A0}.Debug|Win32.ActiveCfg = Debug|Win32 - {F0E8B707-00C5-4FF2-B8EF-7C39817132A0}.Debug|Win32.Build.0 = Debug|Win32 - {F0E8B707-00C5-4FF2-B8EF-7C39817132A0}.Debug|x64.ActiveCfg = Debug|Win32 - {F0E8B707-00C5-4FF2-B8EF-7C39817132A0}.Debug|x64.Build.0 = Debug|Win32 - {F0E8B707-00C5-4FF2-B8EF-7C39817132A0}.Release|Win32.ActiveCfg = Release|Win32 - {F0E8B707-00C5-4FF2-B8EF-7C39817132A0}.Release|Win32.Build.0 = Release|Win32 - {F0E8B707-00C5-4FF2-B8EF-7C39817132A0}.Release|x64.ActiveCfg = Release|x64 - {F0E8B707-00C5-4FF2-B8EF-7C39817132A0}.Release|x64.Build.0 = Release|x64 - {021CEB0A-F721-4F59-B349-9CEEAF244459}.Debug|Win32.ActiveCfg = Debug|Win32 - {021CEB0A-F721-4F59-B349-9CEEAF244459}.Debug|Win32.Build.0 = Debug|Win32 - {021CEB0A-F721-4F59-B349-9CEEAF244459}.Debug|x64.ActiveCfg = Debug|Win32 - {021CEB0A-F721-4F59-B349-9CEEAF244459}.Debug|x64.Build.0 = Debug|Win32 - {021CEB0A-F721-4F59-B349-9CEEAF244459}.Release|Win32.ActiveCfg = Release|Win32 - {021CEB0A-F721-4F59-B349-9CEEAF244459}.Release|Win32.Build.0 = Release|Win32 - {021CEB0A-F721-4F59-B349-9CEEAF244459}.Release|x64.ActiveCfg = Release|x64 - {021CEB0A-F721-4F59-B349-9CEEAF244459}.Release|x64.Build.0 = Release|x64 - {2162937B-0DBD-4450-B45F-DF578D8E7508}.Debug|Win32.ActiveCfg = Debug|Win32 - {2162937B-0DBD-4450-B45F-DF578D8E7508}.Debug|Win32.Build.0 = Debug|Win32 - {2162937B-0DBD-4450-B45F-DF578D8E7508}.Debug|x64.ActiveCfg = Debug|x64 - {2162937B-0DBD-4450-B45F-DF578D8E7508}.Debug|x64.Build.0 = Debug|x64 - {2162937B-0DBD-4450-B45F-DF578D8E7508}.Release|Win32.ActiveCfg = Release|Win32 - {2162937B-0DBD-4450-B45F-DF578D8E7508}.Release|Win32.Build.0 = Release|Win32 - {2162937B-0DBD-4450-B45F-DF578D8E7508}.Release|x64.ActiveCfg = Release|x64 - {2162937B-0DBD-4450-B45F-DF578D8E7508}.Release|x64.Build.0 = Release|x64 - {7FDD85BB-CC86-442B-A425-989B5B296ED5}.Debug|Win32.ActiveCfg = Debug|Win32 - {7FDD85BB-CC86-442B-A425-989B5B296ED5}.Debug|Win32.Build.0 = Debug|Win32 - {7FDD85BB-CC86-442B-A425-989B5B296ED5}.Debug|x64.ActiveCfg = Debug|x64 - {7FDD85BB-CC86-442B-A425-989B5B296ED5}.Debug|x64.Build.0 = Debug|x64 - {7FDD85BB-CC86-442B-A425-989B5B296ED5}.Release|Win32.ActiveCfg = Release|Win32 - {7FDD85BB-CC86-442B-A425-989B5B296ED5}.Release|Win32.Build.0 = Release|Win32 - {7FDD85BB-CC86-442B-A425-989B5B296ED5}.Release|x64.ActiveCfg = Release|x64 - {7FDD85BB-CC86-442B-A425-989B5B296ED5}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {BE3F09BB-91A9-474C-AAD9-4B4D43DCE89E} - EndGlobalSection -EndGlobal +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libyasm", "libyasm\libyasm.vcproj", "{29FE7874-1256-4AD6-B889-68E399DC9608}" + ProjectSection(ProjectDependencies) = postProject + {F0E8B707-00C5-4FF2-B8EF-7C39817132A0} = {F0E8B707-00C5-4FF2-B8EF-7C39817132A0} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "modules", "modules\modules.vcproj", "{D715A3D4-EFAA-442E-AD8B-5B4FF64E1DD6}" + ProjectSection(ProjectDependencies) = postProject + {3C58BE13-50A3-4583-984D-D8902B3D7713} = {3C58BE13-50A3-4583-984D-D8902B3D7713} + {5758BF4E-ABC4-11DA-B012-B622A1EF5492} = {5758BF4E-ABC4-11DA-B012-B622A1EF5492} + {29FE7874-1256-4AD6-B889-68E399DC9608} = {29FE7874-1256-4AD6-B889-68E399DC9608} + {225700A5-07B8-434E-AD61-555278BF6733} = {225700A5-07B8-434E-AD61-555278BF6733} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "yasm", "yasm.vcproj", "{34EB1BEB-C2D6-4A52-82B7-7ACD714A30D5}" + ProjectSection(ProjectDependencies) = postProject + {021CEB0A-F721-4F59-B349-9CEEAF244459} = {021CEB0A-F721-4F59-B349-9CEEAF244459} + {29FE7874-1256-4AD6-B889-68E399DC9608} = {29FE7874-1256-4AD6-B889-68E399DC9608} + {D715A3D4-EFAA-442E-AD8B-5B4FF64E1DD6} = {D715A3D4-EFAA-442E-AD8B-5B4FF64E1DD6} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "genmacro", "genmacro\genmacro.vcproj", "{225700A5-07B8-434E-AD61-555278BF6733}" + ProjectSection(ProjectDependencies) = postProject + {B545983B-8EE0-4A7B-A67A-E749EEAE62A2} = {B545983B-8EE0-4A7B-A67A-E749EEAE62A2} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "genversion", "genversion\genversion.vcproj", "{B545983B-8EE0-4A7B-A67A-E749EEAE62A2}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "re2c", "re2c\re2c.vcproj", "{3C58BE13-50A3-4583-984D-D8902B3D7713}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gap", "gap\gap.vcproj", "{5758BF4E-ABC4-11DA-B012-B622A1EF5492}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "genmodule", "genmodule\genmodule.vcproj", "{F0E8B707-00C5-4FF2-B8EF-7C39817132A0}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "genstring", "genstring\genstring.vcproj", "{021CEB0A-F721-4F59-B349-9CEEAF244459}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{825AC694-358C-4D8D-92DE-33A2691978CE}" + ProjectSection(SolutionItems) = preProject + crt_secure_no_deprecate.vsprops = crt_secure_no_deprecate.vsprops + readme.vc8.txt = readme.vc8.txt + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {29FE7874-1256-4AD6-B889-68E399DC9608}.Debug|Win32.ActiveCfg = Debug|Win32 + {29FE7874-1256-4AD6-B889-68E399DC9608}.Debug|Win32.Build.0 = Debug|Win32 + {29FE7874-1256-4AD6-B889-68E399DC9608}.Debug|x64.ActiveCfg = Debug|x64 + {29FE7874-1256-4AD6-B889-68E399DC9608}.Debug|x64.Build.0 = Debug|x64 + {29FE7874-1256-4AD6-B889-68E399DC9608}.Release|Win32.ActiveCfg = Release|Win32 + {29FE7874-1256-4AD6-B889-68E399DC9608}.Release|Win32.Build.0 = Release|Win32 + {29FE7874-1256-4AD6-B889-68E399DC9608}.Release|x64.ActiveCfg = Release|x64 + {29FE7874-1256-4AD6-B889-68E399DC9608}.Release|x64.Build.0 = Release|x64 + {D715A3D4-EFAA-442E-AD8B-5B4FF64E1DD6}.Debug|Win32.ActiveCfg = Debug|Win32 + {D715A3D4-EFAA-442E-AD8B-5B4FF64E1DD6}.Debug|Win32.Build.0 = Debug|Win32 + {D715A3D4-EFAA-442E-AD8B-5B4FF64E1DD6}.Debug|x64.ActiveCfg = Debug|x64 + {D715A3D4-EFAA-442E-AD8B-5B4FF64E1DD6}.Debug|x64.Build.0 = Debug|x64 + {D715A3D4-EFAA-442E-AD8B-5B4FF64E1DD6}.Release|Win32.ActiveCfg = Release|Win32 + {D715A3D4-EFAA-442E-AD8B-5B4FF64E1DD6}.Release|Win32.Build.0 = Release|Win32 + {D715A3D4-EFAA-442E-AD8B-5B4FF64E1DD6}.Release|x64.ActiveCfg = Release|x64 + {D715A3D4-EFAA-442E-AD8B-5B4FF64E1DD6}.Release|x64.Build.0 = Release|x64 + {34EB1BEB-C2D6-4A52-82B7-7ACD714A30D5}.Debug|Win32.ActiveCfg = Debug|Win32 + {34EB1BEB-C2D6-4A52-82B7-7ACD714A30D5}.Debug|Win32.Build.0 = Debug|Win32 + {34EB1BEB-C2D6-4A52-82B7-7ACD714A30D5}.Debug|x64.ActiveCfg = Debug|x64 + {34EB1BEB-C2D6-4A52-82B7-7ACD714A30D5}.Debug|x64.Build.0 = Debug|x64 + {34EB1BEB-C2D6-4A52-82B7-7ACD714A30D5}.Release|Win32.ActiveCfg = Release|Win32 + {34EB1BEB-C2D6-4A52-82B7-7ACD714A30D5}.Release|Win32.Build.0 = Release|Win32 + {34EB1BEB-C2D6-4A52-82B7-7ACD714A30D5}.Release|x64.ActiveCfg = Release|x64 + {34EB1BEB-C2D6-4A52-82B7-7ACD714A30D5}.Release|x64.Build.0 = Release|x64 + {225700A5-07B8-434E-AD61-555278BF6733}.Debug|Win32.ActiveCfg = Debug|Win32 + {225700A5-07B8-434E-AD61-555278BF6733}.Debug|Win32.Build.0 = Debug|Win32 + {225700A5-07B8-434E-AD61-555278BF6733}.Debug|x64.ActiveCfg = Debug|Win32 + {225700A5-07B8-434E-AD61-555278BF6733}.Debug|x64.Build.0 = Debug|Win32 + {225700A5-07B8-434E-AD61-555278BF6733}.Release|Win32.ActiveCfg = Release|Win32 + {225700A5-07B8-434E-AD61-555278BF6733}.Release|Win32.Build.0 = Release|Win32 + {225700A5-07B8-434E-AD61-555278BF6733}.Release|x64.ActiveCfg = Release|Win32 + {225700A5-07B8-434E-AD61-555278BF6733}.Release|x64.Build.0 = Release|Win32 + {B545983B-8EE0-4A7B-A67A-E749EEAE62A2}.Debug|Win32.ActiveCfg = Debug|Win32 + {B545983B-8EE0-4A7B-A67A-E749EEAE62A2}.Debug|Win32.Build.0 = Debug|Win32 + {B545983B-8EE0-4A7B-A67A-E749EEAE62A2}.Debug|x64.ActiveCfg = Debug|Win32 + {B545983B-8EE0-4A7B-A67A-E749EEAE62A2}.Debug|x64.Build.0 = Debug|Win32 + {B545983B-8EE0-4A7B-A67A-E749EEAE62A2}.Release|Win32.ActiveCfg = Release|Win32 + {B545983B-8EE0-4A7B-A67A-E749EEAE62A2}.Release|Win32.Build.0 = Release|Win32 + {B545983B-8EE0-4A7B-A67A-E749EEAE62A2}.Release|x64.ActiveCfg = Release|Win32 + {B545983B-8EE0-4A7B-A67A-E749EEAE62A2}.Release|x64.Build.0 = Release|Win32 + {3C58BE13-50A3-4583-984D-D8902B3D7713}.Debug|Win32.ActiveCfg = Debug|Win32 + {3C58BE13-50A3-4583-984D-D8902B3D7713}.Debug|Win32.Build.0 = Debug|Win32 + {3C58BE13-50A3-4583-984D-D8902B3D7713}.Debug|x64.ActiveCfg = Debug|Win32 + {3C58BE13-50A3-4583-984D-D8902B3D7713}.Debug|x64.Build.0 = Debug|Win32 + {3C58BE13-50A3-4583-984D-D8902B3D7713}.Release|Win32.ActiveCfg = Release|Win32 + {3C58BE13-50A3-4583-984D-D8902B3D7713}.Release|Win32.Build.0 = Release|Win32 + {3C58BE13-50A3-4583-984D-D8902B3D7713}.Release|x64.ActiveCfg = Release|Win32 + {3C58BE13-50A3-4583-984D-D8902B3D7713}.Release|x64.Build.0 = Release|Win32 + {5758BF4E-ABC4-11DA-B012-B622A1EF5492}.Debug|Win32.ActiveCfg = Debug|Win32 + {5758BF4E-ABC4-11DA-B012-B622A1EF5492}.Debug|Win32.Build.0 = Debug|Win32 + {5758BF4E-ABC4-11DA-B012-B622A1EF5492}.Debug|x64.ActiveCfg = Debug|Win32 + {5758BF4E-ABC4-11DA-B012-B622A1EF5492}.Debug|x64.Build.0 = Debug|Win32 + {5758BF4E-ABC4-11DA-B012-B622A1EF5492}.Release|Win32.ActiveCfg = Release|Win32 + {5758BF4E-ABC4-11DA-B012-B622A1EF5492}.Release|Win32.Build.0 = Release|Win32 + {5758BF4E-ABC4-11DA-B012-B622A1EF5492}.Release|x64.ActiveCfg = Release|Win32 + {5758BF4E-ABC4-11DA-B012-B622A1EF5492}.Release|x64.Build.0 = Release|Win32 + {F0E8B707-00C5-4FF2-B8EF-7C39817132A0}.Debug|Win32.ActiveCfg = Debug|Win32 + {F0E8B707-00C5-4FF2-B8EF-7C39817132A0}.Debug|Win32.Build.0 = Debug|Win32 + {F0E8B707-00C5-4FF2-B8EF-7C39817132A0}.Debug|x64.ActiveCfg = Debug|Win32 + {F0E8B707-00C5-4FF2-B8EF-7C39817132A0}.Debug|x64.Build.0 = Debug|Win32 + {F0E8B707-00C5-4FF2-B8EF-7C39817132A0}.Release|Win32.ActiveCfg = Release|Win32 + {F0E8B707-00C5-4FF2-B8EF-7C39817132A0}.Release|Win32.Build.0 = Release|Win32 + {F0E8B707-00C5-4FF2-B8EF-7C39817132A0}.Release|x64.ActiveCfg = Release|Win32 + {F0E8B707-00C5-4FF2-B8EF-7C39817132A0}.Release|x64.Build.0 = Release|Win32 + {021CEB0A-F721-4F59-B349-9CEEAF244459}.Debug|Win32.ActiveCfg = Debug|Win32 + {021CEB0A-F721-4F59-B349-9CEEAF244459}.Debug|Win32.Build.0 = Debug|Win32 + {021CEB0A-F721-4F59-B349-9CEEAF244459}.Debug|x64.ActiveCfg = Debug|Win32 + {021CEB0A-F721-4F59-B349-9CEEAF244459}.Debug|x64.Build.0 = Debug|Win32 + {021CEB0A-F721-4F59-B349-9CEEAF244459}.Release|Win32.ActiveCfg = Release|Win32 + {021CEB0A-F721-4F59-B349-9CEEAF244459}.Release|Win32.Build.0 = Release|Win32 + {021CEB0A-F721-4F59-B349-9CEEAF244459}.Release|x64.ActiveCfg = Release|Win32 + {021CEB0A-F721-4F59-B349-9CEEAF244459}.Release|x64.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Mkfiles/vc8/yasm.vcproj b/Mkfiles/vc8/yasm.vcproj new file mode 100644 index 00000000..ef4eab3a --- /dev/null +++ b/Mkfiles/vc8/yasm.vcproj @@ -0,0 +1,413 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Mkfiles/vs/crt_secure_no_deprecate.props b/Mkfiles/vs/crt_secure_no_deprecate.props deleted file mode 100644 index 777d6d0a..00000000 --- a/Mkfiles/vs/crt_secure_no_deprecate.props +++ /dev/null @@ -1,11 +0,0 @@ - - - - <_ProjectFileVersion>10.0.21006.1 - - - - _CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions) - - - \ No newline at end of file diff --git a/Mkfiles/vs/genmacro/genmacro.vcxproj b/Mkfiles/vs/genmacro/genmacro.vcxproj deleted file mode 100644 index 1385ac6a..00000000 --- a/Mkfiles/vs/genmacro/genmacro.vcxproj +++ /dev/null @@ -1,204 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {225700A5-07B8-434E-AD61-555278BF6733} - genmacro - Win32Proj - - - - Application - MultiByte - $(DefaultPlatformToolset) - - - Application - MultiByte - $(DefaultPlatformToolset) - - - Application - MultiByte - $(DefaultPlatformToolset) - - - Application - MultiByte - $(DefaultPlatformToolset) - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.21006.1 - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - - - $(IntDir) - Level3 - ProgramDatabase - Default - - - $(OutDir)genmacro.exe - true - $(OutDir)$(TargetName).pdb - Console - false - - - MachineX86 - - - run.bat "$(TargetPath)" - - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - EnableFastChecks - MultiThreadedDebug - - - $(IntDir) - Level3 - ProgramDatabase - Default - ..\Mkfiles\vs - - - $(OutDir)genmacro.exe - true - $(OutDir)$(TargetName).pdb - Console - false - - - - - run.bat "$(TargetPath)" - - - - - Full - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreaded - - - $(IntDir) - Level3 - Default - - - $(OutDir)genmacro.exe - $(OutDir)$(TargetName).pdb - Console - true - true - false - - - MachineX86 - - - run.bat "$(TargetPath)" - - - - - Full - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreaded - - - $(IntDir) - Level3 - Default - ..\Mkfiles\vs - - - $(OutDir)genmacro.exe - $(OutDir)$(TargetName).pdb - Console - true - true - false - - - - - run.bat "$(TargetPath)" - - - - - - - - - - - {b545983b-8ee0-4a7b-a67a-e749eeae62a2} - false - - - - - - \ No newline at end of file diff --git a/Mkfiles/vs/genmacro/genmacro.vcxproj.filters b/Mkfiles/vs/genmacro/genmacro.vcxproj.filters deleted file mode 100644 index 402cf1b4..00000000 --- a/Mkfiles/vs/genmacro/genmacro.vcxproj.filters +++ /dev/null @@ -1,17 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - - - Source Files - - - - - - \ No newline at end of file diff --git a/Mkfiles/vs/genmacro/run.bat b/Mkfiles/vs/genmacro/run.bat deleted file mode 100644 index 98c337ac..00000000 --- a/Mkfiles/vs/genmacro/run.bat +++ /dev/null @@ -1,5 +0,0 @@ -cd ..\..\.. -%1 nasm-version.c nasm_version_mac version.mac -%1 nasm-macros.c nasm_standard_mac modules\parsers\nasm\nasm-std.mac -%1 win64-nasm.c win64_nasm_stdmac modules\objfmts\coff\win64-nasm.mac -%1 win64-gas.c win64_gas_stdmac modules\objfmts\coff\win64-gas.mac diff --git a/Mkfiles/vs/genmodule/genmodule.vcxproj b/Mkfiles/vs/genmodule/genmodule.vcxproj deleted file mode 100644 index f8eb8f16..00000000 --- a/Mkfiles/vs/genmodule/genmodule.vcxproj +++ /dev/null @@ -1,207 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {F0E8B707-00C5-4FF2-B8EF-7C39817132A0} - genmodule - Win32Proj - - - - Application - MultiByte - $(DefaultPlatformToolset) - - - Application - MultiByte - $(DefaultPlatformToolset) - - - Application - MultiByte - $(DefaultPlatformToolset) - - - Application - MultiByte - $(DefaultPlatformToolset) - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.21006.1 - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - false - - - - Disabled - %(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;FILTERMODE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - - - $(IntDir) - $(IntDir) - Level3 - ProgramDatabase - Default - - - $(OutDir)genmodule.exe - true - $(OutDir)$(TargetName).pdb - Console - false - - - MachineX86 - - - run.bat "$(TargetPath)" - - - - - Disabled - ..\Mkfiles\vs;;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;FILTERMODE;%(PreprocessorDefinitions) - EnableFastChecks - MultiThreadedDebug - - - $(IntDir) - $(IntDir) - Level3 - ProgramDatabase - Default - - - $(OutDir)genmodule.exe - true - $(OutDir)$(TargetName).pdb - Console - false - - - - - run.bat "$(TargetPath)" - - - - - Full - %(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;FILTERMODE;%(PreprocessorDefinitions) - MultiThreaded - - - $(IntDir) - $(IntDir) - Level3 - Default - - - $(OutDir)genmodule.exe - $(OutDir)$(TargetName).pdb - Console - true - true - false - - - MachineX86 - - - run.bat "$(TargetPath)" - - - - - Full - ..\Mkfiles\vs;;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;FILTERMODE;%(PreprocessorDefinitions) - MultiThreaded - - - $(IntDir) - $(IntDir) - Level3 - Default - - - $(OutDir)genmodule.exe - $(OutDir)$(TargetName).pdb - Console - true - true - false - - - - - run.bat "$(TargetPath)" - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Mkfiles/vs/genmodule/genmodule.vcxproj.filters b/Mkfiles/vs/genmodule/genmodule.vcxproj.filters deleted file mode 100644 index d3255c29..00000000 --- a/Mkfiles/vs/genmodule/genmodule.vcxproj.filters +++ /dev/null @@ -1,20 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - - - Source Files - - - - - - - - - \ No newline at end of file diff --git a/Mkfiles/vs/genperf/genperf.vcxproj b/Mkfiles/vs/genperf/genperf.vcxproj deleted file mode 100644 index 913caa89..00000000 --- a/Mkfiles/vs/genperf/genperf.vcxproj +++ /dev/null @@ -1,261 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {C45A8B59-8B59-4D5D-A8E8-FB090F8DD619} - genperf - Win32Proj - - - - Application - MultiByte - $(DefaultPlatformToolset) - - - Application - MultiByte - $(DefaultPlatformToolset) - - - Application - MultiByte - $(DefaultPlatformToolset) - - - Application - MultiByte - $(DefaultPlatformToolset) - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.21006.1 - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - false - false - false - false - false - - - - - - - - Disabled - ..;../../..;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;STDC_HEADERS;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - - - $(IntDir) - Level3 - ProgramDatabase - Default - - - $(OutDir)genperf.exe - true - $(OutDir)$(TargetName).pdb - Console - false - - - MachineX86 - - - - - - - run.bat "$(TargetPath)" - - - x86insn_nasm.c;x86insn_gas.c;x86cpu.c;x86regtmod.c;%(Outputs) - - - run.bat "$(TargetPath)" - - - - - Disabled - ..;../../..;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;STDC_HEADERS;%(PreprocessorDefinitions) - EnableFastChecks - MultiThreadedDebug - - - $(IntDir) - Level3 - ProgramDatabase - Default - - - $(OutDir)genperf.exe - true - $(OutDir)$(TargetName).pdb - Console - false - - - - - - - - - run.bat "$(TargetPath)" - - - x86insn_nasm.c;x86insn_gas.c;x86cpu.c;x86regtmod.c;%(Outputs) - - - run.bat "$(TargetPath)" - - - - - Full - ..;../../..;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;STDC_HEADERS;%(PreprocessorDefinitions) - MultiThreaded - - - $(IntDir) - Level3 - Default - - - $(OutDir)genperf.exe - $(OutDir)$(TargetName).pdb - Console - true - true - false - - - MachineX86 - - - - - - - run.bat "$(TargetPath)" - - - x86insn_nasm.c;x86insn_gas.c;x86cpu.c;x86regtmod.c;%(Outputs) - - - run.bat "$(TargetPath)" - - - - - Full - ..;../../..;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;STDC_HEADERS;%(PreprocessorDefinitions) - MultiThreaded - - - $(IntDir) - Level3 - Default - - - $(OutDir)genperf.exe - $(OutDir)$(TargetName).pdb - Console - true - true - false - - - - - - - - - run.bat "$(TargetPath)" - - - x86insn_nasm.c;x86insn_gas.c;x86cpu.c;x86regtmod.c;%(Outputs) - - - run.bat "$(TargetPath)" - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Mkfiles/vs/genperf/genperf.vcxproj.filters b/Mkfiles/vs/genperf/genperf.vcxproj.filters deleted file mode 100644 index 3124b5d7..00000000 --- a/Mkfiles/vs/genperf/genperf.vcxproj.filters +++ /dev/null @@ -1,56 +0,0 @@ - - - - - {3C1E9AA8-6338-4CED-99F1-BEBA80607BD5} - h;hpp;hxx;hm;inl;inc;xsd - - - {1062695D-1C50-4068-8313-73A409885BC1} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - - \ No newline at end of file diff --git a/Mkfiles/vs/genperf/run.bat b/Mkfiles/vs/genperf/run.bat deleted file mode 100644 index 40ab8d52..00000000 --- a/Mkfiles/vs/genperf/run.bat +++ /dev/null @@ -1,40 +0,0 @@ -cd ..\..\.. -@echo off - -for /f "usebackq tokens=1*" %%f in (`reg query HKCR\Applications\python.exe\shell\open\command 2^>NUL`) do (set _my_=%%f %%g) -goto try1%errorlevel% - -:try10 -goto ok - -:try11 -for /f "usebackq tokens=1*" %%f in (`reg query HKCR\Python.File\shell\open\command 2^>NUL`) do (set _my_=%%f %%g) -goto try2%errorlevel% - -:try20: -goto ok - -:try21: -echo Building without Python ... -goto therest - -:ok -echo Building with Python ... -set _res_=%_my_:*REG_SZ=% -set _end_=%_res_:*exe"=% -call set _python_=%%_res_:%_end_%=%% -echo %_python_% -call %_python_% modules\arch\x86\gen_x86_insn.py - -:therest -@echo on -call :update %1 x86insn_nasm.gperf x86insn_nasm.c -call :update %1 x86insn_gas.gperf x86insn_gas.c -call :update %1 modules\arch\x86\x86cpu.gperf x86cpu.c -call :update %1 modules\arch\x86\x86regtmod.gperf x86regtmod.c -goto :eof - -:update -%1 %2 tf -call mkfiles\vs\out_copy_rename tf .\ %3 -del tf diff --git a/Mkfiles/vs/genstring/genstring.vcxproj b/Mkfiles/vs/genstring/genstring.vcxproj deleted file mode 100644 index 0c7d7898..00000000 --- a/Mkfiles/vs/genstring/genstring.vcxproj +++ /dev/null @@ -1,196 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {021CEB0A-F721-4F59-B349-9CEEAF244459} - genstring - Win32Proj - - - - Application - MultiByte - $(DefaultPlatformToolset) - - - Application - MultiByte - $(DefaultPlatformToolset) - - - Application - MultiByte - $(DefaultPlatformToolset) - - - Application - MultiByte - $(DefaultPlatformToolset) - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.21006.1 - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - - - $(IntDir) - Level3 - ProgramDatabase - Default - - - $(OutDir)genstring.exe - true - $(OutDir)$(TargetName).pdb - Console - false - - - MachineX86 - - - run.bat "$(TargetPath)" - - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - EnableFastChecks - MultiThreadedDebug - - - $(IntDir) - Level3 - ProgramDatabase - Default - - - $(OutDir)genstring.exe - true - $(OutDir)$(TargetName).pdb - Console - false - - - - - run.bat "$(TargetPath)" - - - - - Full - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreaded - - - $(IntDir) - Level3 - Default - - - $(OutDir)genstring.exe - $(OutDir)$(TargetName).pdb - Console - true - true - false - - - MachineX86 - - - run.bat "$(TargetPath)" - - - - - Full - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreaded - - - $(IntDir) - Level3 - Default - - - $(OutDir)genstring.exe - $(OutDir)$(TargetName).pdb - Console - true - true - false - - - - - run.bat "$(TargetPath)" - - - - - - - - - - - - \ No newline at end of file diff --git a/Mkfiles/vs/genstring/genstring.vcxproj.filters b/Mkfiles/vs/genstring/genstring.vcxproj.filters deleted file mode 100644 index 04ed411d..00000000 --- a/Mkfiles/vs/genstring/genstring.vcxproj.filters +++ /dev/null @@ -1,17 +0,0 @@ - - - - - {28EBE11C-5BE8-4935-9381-F57696749E0C} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - - - Source Files - - - - - - \ No newline at end of file diff --git a/Mkfiles/vs/genversion/genversion.vcxproj b/Mkfiles/vs/genversion/genversion.vcxproj deleted file mode 100644 index c9cbe8b2..00000000 --- a/Mkfiles/vs/genversion/genversion.vcxproj +++ /dev/null @@ -1,223 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {B545983B-8EE0-4A7B-A67A-E749EEAE62A2} - genversion - Win32Proj - - - - Application - MultiByte - $(DefaultPlatformToolset) - - - Application - MultiByte - $(DefaultPlatformToolset) - - - Application - MultiByte - $(DefaultPlatformToolset) - - - Application - MultiByte - $(DefaultPlatformToolset) - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.21006.1 - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - false - - - - Disabled - ..\..\vc10;..\..\..\;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - - - $(IntDir) - Level3 - ProgramDatabase - Default - - - $(OutDir)genversion.exe - true - $(OutDir)$(TargetName).pdb - Console - false - - - MachineX86 - - - run.bat "$(TargetPath)" - - - cd ..\..\..\ -YASM-VERSION-GEN.bat - - - - - - Disabled - ..\..\vs;..\..\..\;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - EnableFastChecks - MultiThreadedDebug - - - $(IntDir) - Level3 - ProgramDatabase - Default - - - $(OutDir)genversion.exe - true - $(OutDir)$(TargetName).pdb - Console - false - - - - - run.bat "$(TargetPath)" - - - cd ..\..\..\ -YASM-VERSION-GEN.bat - - - - - - Full - ..\..\vc10;..\..\..\;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreaded - - - $(IntDir) - Level3 - Default - - - $(OutDir)genversion.exe - $(OutDir)$(TargetName).pdb - Console - true - true - false - - - MachineX86 - - - run.bat "$(TargetPath)" - - - cd ..\..\..\ -YASM-VERSION-GEN.bat - - - - - - Full - ..\..\vs;..\..\..\;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreaded - - - $(IntDir) - Level3 - Default - - - $(OutDir)genversion.exe - $(OutDir)$(TargetName).pdb - Console - true - true - false - - - - - run.bat "$(TargetPath)" - - - cd ..\..\..\ -YASM-VERSION-GEN.bat - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Mkfiles/vs/genversion/genversion.vcxproj.filters b/Mkfiles/vs/genversion/genversion.vcxproj.filters deleted file mode 100644 index cc088b12..00000000 --- a/Mkfiles/vs/genversion/genversion.vcxproj.filters +++ /dev/null @@ -1,26 +0,0 @@ - - - - - {2acbec3a-0ed8-4b2e-826e-a84c7d35f205} - h;hpp;hxx;hm;inl - - - {E67ED277-E4F2-4D79-8C9E-962BAC164F3F} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - - - Source Files - - - - - Header Files - - - - - - \ No newline at end of file diff --git a/Mkfiles/vs/genversion/runpre.bat b/Mkfiles/vs/genversion/runpre.bat deleted file mode 100644 index fdd15708..00000000 --- a/Mkfiles/vs/genversion/runpre.bat +++ /dev/null @@ -1,2 +0,0 @@ -cd ..\..\.. -YASM-VERSION-GEN.bat diff --git a/Mkfiles/vs/libyasm/libyasm.vcxproj b/Mkfiles/vs/libyasm/libyasm.vcxproj deleted file mode 100644 index 03a53e25..00000000 --- a/Mkfiles/vs/libyasm/libyasm.vcxproj +++ /dev/null @@ -1,278 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {29FE7874-1256-4AD6-B889-68E399DC9608} - libyasm - 10.0 - - - - StaticLibrary - false - MultiByte - $(DefaultPlatformToolset) - - - StaticLibrary - false - MultiByte - $(DefaultPlatformToolset) - - - StaticLibrary - false - MultiByte - $(DefaultPlatformToolset) - - - StaticLibrary - false - MultiByte - $(DefaultPlatformToolset) - - - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.21006.1 - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - - - - Full - Default - ..;../../..;%(AdditionalIncludeDirectories) - NDEBUG;WIN32;_LIB;HAVE_CONFIG_H;%(PreprocessorDefinitions) - true - MultiThreaded - true - - - $(IntDir) - $(IntDir) - $(IntDir) - Level3 - true - Default - ProgramDatabase - - - NDEBUG;%(PreprocessorDefinitions) - 0x0409 - - - $(OutDir)libyasm.lib - true - - - - - X64 - - - Full - Default - ..;../../..;%(AdditionalIncludeDirectories) - NDEBUG;_LIB;HAVE_CONFIG_H;WIN64;%(PreprocessorDefinitions) - true - MultiThreaded - true - - - - - $(IntDir) - $(IntDir) - $(IntDir) - Level3 - true - Default - ProgramDatabase - - - NDEBUG;%(PreprocessorDefinitions) - 0x0409 - - - $(OutDir)libyasm.lib - true - - - - - Disabled - ..;../../..;%(AdditionalIncludeDirectories) - _DEBUG;WIN32;_LIB;HAVE_CONFIG_H;%(PreprocessorDefinitions) - EnableFastChecks - MultiThreadedDebug - - - $(IntDir) - $(IntDir) - $(IntDir) - Level3 - true - Default - ProgramDatabase - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - $(OutDir)libyasm.lib - true - - - - - X64 - - - Disabled - ..;../../..;%(AdditionalIncludeDirectories) - _DEBUG;_LIB;HAVE_CONFIG_H;WIN64;%(PreprocessorDefinitions) - EnableFastChecks - MultiThreadedDebug - - - - - $(IntDir) - $(IntDir) - $(IntDir) - Level3 - true - ProgramDatabase - Default - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - $(OutDir)libyasm.lib - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {f0e8b707-00c5-4ff2-b8ef-7c39817132a0} - false - - - - - - \ No newline at end of file diff --git a/Mkfiles/vs/libyasm/libyasm.vcxproj.filters b/Mkfiles/vs/libyasm/libyasm.vcxproj.filters deleted file mode 100644 index 9bdf13a4..00000000 --- a/Mkfiles/vs/libyasm/libyasm.vcxproj.filters +++ /dev/null @@ -1,200 +0,0 @@ - - - - - {4ca3b698-9d01-4e4e-ae00-5c98da045efe} - h;hpp;hxx;hm;inl - - - {68607062-982d-4251-9a1a-30f76474983d} - cpp;c;cxx;rc;def;r;odl;idl;hpj;bat - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Source Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - - \ No newline at end of file diff --git a/Mkfiles/vs/modules/modules.vcxproj b/Mkfiles/vs/modules/modules.vcxproj deleted file mode 100644 index 699eb6fd..00000000 --- a/Mkfiles/vs/modules/modules.vcxproj +++ /dev/null @@ -1,324 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {D715A3D4-EFAA-442E-AD8B-5B4FF64E1DD6} - modules - - - - StaticLibrary - false - MultiByte - $(DefaultPlatformToolset) - - - StaticLibrary - false - MultiByte - $(DefaultPlatformToolset) - - - StaticLibrary - false - MultiByte - $(DefaultPlatformToolset) - - - StaticLibrary - false - MultiByte - $(DefaultPlatformToolset) - - - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.21006.1 - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - - - - Full - Default - ..;../../..;%(AdditionalIncludeDirectories) - NDEBUG;WIN32;_LIB;HAVE_CONFIG_H;%(PreprocessorDefinitions) - true - MultiThreaded - true - - - - - $(IntDir) - $(IntDir) - $(IntDir) - Level3 - true - Default - ProgramDatabase - - - NDEBUG;%(PreprocessorDefinitions) - 0x0409 - - - $(OutDir)modules.lib - true - - - - - - - - - X64 - - - Full - Default - ..;../../..;%(AdditionalIncludeDirectories) - NDEBUG;_LIB;HAVE_CONFIG_H;WIN64;%(PreprocessorDefinitions) - true - MultiThreaded - true - - - - - $(IntDir) - $(IntDir) - $(IntDir) - Level3 - true - Default - ProgramDatabase - - - NDEBUG;%(PreprocessorDefinitions) - 0x0409 - - - $(OutDir)modules.lib - true - - - - - Disabled - ..;../../..;%(AdditionalIncludeDirectories) - _DEBUG;WIN32;_LIB;HAVE_CONFIG_H;%(PreprocessorDefinitions) - EnableFastChecks - MultiThreadedDebug - - - - - $(IntDir) - $(IntDir) - $(IntDir) - Level3 - true - ProgramDatabase - Default - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - $(OutDir)modules.lib - true - - - - - X64 - - - Disabled - ..;../../..;%(AdditionalIncludeDirectories) - _DEBUG;_LIB;HAVE_CONFIG_H;WIN64;%(PreprocessorDefinitions) - EnableFastChecks - MultiThreadedDebug - - - - - $(IntDir) - $(IntDir) - $(IntDir) - Level3 - true - ProgramDatabase - Default - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - $(OutDir)modules.lib - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {225700a5-07b8-434e-ad61-555278bf6733} - false - - - {c45a8b59-8b59-4d5d-a8e8-fb090f8dd619} - false - - - {29fe7874-1256-4ad6-b889-68e399dc9608} - false - - - {3c58be13-50a3-4583-984d-d8902b3d7713} - false - - - - - - \ No newline at end of file diff --git a/Mkfiles/vs/modules/modules.vcxproj.filters b/Mkfiles/vs/modules/modules.vcxproj.filters deleted file mode 100644 index e6ff3add..00000000 --- a/Mkfiles/vs/modules/modules.vcxproj.filters +++ /dev/null @@ -1,256 +0,0 @@ - - - - - {39c89f91-d860-4396-a49f-86b8b7a51c33} - cpp;c;cxx;rc;def;r;odl;idl;hpj;bat - - - {be0cdf28-cbed-4774-b3cc-b63e4e3fa0a9} - - - {491cc60a-889b-4f53-aae9-f4d7d6aa667a} - - - {c084015d-3c3e-4379-8746-ae5cffcec79e} - - - {3333e0b3-e95f-44f6-9000-58d4da368360} - - - {528f2955-ceba-4691-a36c-054f119e3dcc} - - - {81686d52-eb71-4d4a-a830-66c45afb808f} - - - {98fe1e43-3794-4639-bf29-14b0c569754f} - - - {6b3956d4-0bff-4e8e-af61-a7e59b476fa4} - - - {446fad62-ac17-49e9-8263-33481f04f182} - - - {33fb7fc8-61f9-428d-9c94-7a4912fbb678} - - - {48fc77ec-7d78-4c0a-bfc2-9aa76faf5d7f} - - - - - Source Files\parsers - - - Source Files\arch - - - Source Files\arch - - - Source Files\arch - - - Source Files\arch - - - Source Files\arch - - - Source Files\arch - - - Source Files\arch - - - Source Files\dbgfmts - - - Source Files\dbgfmts - - - Source Files\dbgfmts - - - Source Files\dbgfmts - - - Source Files\dbgfmts - - - Source Files\dbgfmts - - - Source Files\dbgfmts - - - Source Files\dbgfmts - - - Source Files\dbgfmts - - - Source Files\listfmts\nasm - - - Source Files\objfmts - - - Source Files\objfmts - - - Source Files\objfmts - - - Source Files\objfmts - - - Source Files\objfmts - - - Source Files\objfmts - - - Source Files\objfmts - - - Source Files\objfmts - - - Source Files\objfmts - - - Source Files\objfmts - - - Source Files\objfmts - - - Source Files\parsers - - - Source Files\parsers - - - Source Files\parsers - - - Source Files\parsers - - - Source Files\parsers - - - Source Files\preprocs\cpp - - - Source Files\preprocs\gas - - - Source Files\preprocs\gas - - - Source Files\preprocs\nasm - - - Source Files\preprocs\nasm - - - Source Files\preprocs\nasm - - - Source Files\preprocs\nasm - - - Source Files\preprocs\raw - - - Source Files\parsers - - - Source Files\arch - - - Source Files\arch - - - Source Files\objfmts - - - - - Source Files\arch - - - Source Files\arch - - - Source Files\dbgfmts - - - Source Files\dbgfmts - - - Source Files\objfmts - - - Source Files\objfmts - - - Source Files\objfmts - - - Source Files\parsers - - - Source Files\parsers - - - Source Files\preprocs\gas - - - Source Files\preprocs\nasm - - - Source Files\preprocs\nasm - - - Source Files\preprocs\nasm - - - Source Files\preprocs\nasm - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Mkfiles/vs/out_copy_rename.bat b/Mkfiles/vs/out_copy_rename.bat deleted file mode 100644 index 3179b59a..00000000 --- a/Mkfiles/vs/out_copy_rename.bat +++ /dev/null @@ -1,42 +0,0 @@ -@echo off -if not exist %1 goto nofile -if exist %2 goto copy - -echo creating directory %2 -md %2 > nul - -:copy -set str=%2 -for /f "useback tokens=*" %%a in ('%str%') do set str=%%~a -set str=%str:~-1% -if %str% == "\" goto hasbackslash - -if not exist %2\%3 goto cpy -fc %1 %2\%3 > nul && if not %errorlevel 1 goto exit -echo overwriting %2\%3 with %1 -copy %1 %2\%3 > nul -goto exit - -:cpy -echo copying %1 to %2\%3 -copy %1 %2\%3 > nul -goto exit - -:hasbackslash -if not exist %2%3 goto cpy2 -fc %1 %2%3 > nul && if not %errorlevel 1 goto exit -echo overwriting %2%3 with %1 -copy %1 %2%3 > nul -goto exit - -:cpy2 -echo copying %1 to %2%3 -copy %1 %2%3 > nul -goto exit - -:nofile -echo %1 not found - -:exit - - diff --git a/Mkfiles/vs/re2c/re2c.vcxproj b/Mkfiles/vs/re2c/re2c.vcxproj deleted file mode 100644 index d7bb0736..00000000 --- a/Mkfiles/vs/re2c/re2c.vcxproj +++ /dev/null @@ -1,221 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {3C58BE13-50A3-4583-984D-D8902B3D7713} - re2c - Win32Proj - - - - Application - MultiByte - $(DefaultPlatformToolset) - - - Application - MultiByte - $(DefaultPlatformToolset) - - - Application - MultiByte - $(DefaultPlatformToolset) - - - Application - MultiByte - $(DefaultPlatformToolset) - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.21006.1 - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - false - - - - Disabled - ..;../../..;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - - - $(IntDir) - Level3 - Default - ProgramDatabase - - - $(OutDir)re2c.exe - true - $(OutDir)$(TargetName).pdb - Console - false - - - MachineX86 - - - run.bat "$(TargetPath)" - - - - - Disabled - ..;../../..;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - EnableFastChecks - MultiThreadedDebug - - - $(IntDir) - Level3 - Default - ProgramDatabase - - - $(OutDir)re2c.exe - true - $(OutDir)$(TargetName).pdb - Console - false - - - - - run.bat "$(TargetPath)" - - - - - Full - ..;../../..;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreaded - - - $(IntDir) - Level3 - Default - - - $(OutDir)re2c.exe - $(OutDir)$(TargetName).pdb - Console - true - true - false - - - MachineX86 - - - run.bat "$(TargetPath)" - - - - - Full - ..;../../..;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreaded - - - $(IntDir) - Level3 - Default - - - $(OutDir)re2c.exe - $(OutDir)$(TargetName).pdb - Console - true - true - false - - - - - run.bat "$(TargetPath)" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Mkfiles/vs/re2c/re2c.vcxproj.filters b/Mkfiles/vs/re2c/re2c.vcxproj.filters deleted file mode 100644 index da0f935c..00000000 --- a/Mkfiles/vs/re2c/re2c.vcxproj.filters +++ /dev/null @@ -1,80 +0,0 @@ - - - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - - \ No newline at end of file diff --git a/Mkfiles/vs/readme.vs.txt b/Mkfiles/vs/readme.vs.txt deleted file mode 100644 index 21c70be9..00000000 --- a/Mkfiles/vs/readme.vs.txt +++ /dev/null @@ -1,96 +0,0 @@ -Building YASM with Microsoft Visual Studio ------------------------------------------- - -This note describes how to build YASM using Microsoft Visual -Studio 2019 and later versions. - -1. YASM Download ----------------- - -First YASM needs to be downloaded and the files placed within -a suitable directory, which will be called here but can -be named and located as you wish. - -2. Building YASM ----------------- - -Now locate and double click on the yasm.sln solution file in -the 'Mkfiles/vs' subdirectory to open the build project in -the Visual Studio IDE and then select: - - win32 or x64 build - release or debug build - -as appropriate to build the YASM binaries that you need. - -4. Using YASM with Visual Sudio -------------------------------- - -The YASM version vsyasm.exe is designed specifically for use -with the 2010 and later versions of Visual Studio. To tell -Visual Studio where to find vsyasm.exe, the environment -variable YASMPATH can be set to the absolute path of the -directory in which vsyasm.exe is located (this path should -include the final backslash). - -Alternatively you can find the directory (or directories) -where the VC++ compiler binaries are located and put copies -of the vsyasm.exe binary in these directories. - -Depending on your system you can use either the win32 or the -x64 version of vsyasm.exe, which must be named vsyasm.exe. - -To use the custom tools facility in Visual Studio you need to -place a copy of three files - yasm.props, yasm.targets and -yasm.xml - into a location where they can be found by the -Visual Studio build customisation processes. There are several -ways to do this: - - a. put these files in the MSBUILD customisation directory - - b. put them in a convenient location and set this path in the - 'Build Customisations Search Path' in the Visual Studio - 'Projects and Solutions|VC++ Project Settings' item in - the 'Tools|Options' menu; - - c. put them in a convenient location and set this path in the - 'Build Customisation dialogue (discussed later). - -To use YASM in a project, right click on the project in the Solution -Explorer and select 'Build Customisations..'. This will give you a -dialog box that allows you to select YASM as an assembler (note that -your assembler files need to have the extension '.asm'). If you have -used option c. above, you will need to let the dialogue find them -using the 'Find Existing' button below the dialogue. - -To assemble a file with YASM, select the Property Page for the file -and the select 'Yasm Assembler' in the Tool dialog entry. Then click -'Apply' and an additional property page entry will appear and enable -YASM settings to be established. - -5. A Linker Issue ------------------ - -There appears to be a linker bug in the VC++ linker that prevents -symbols with absolute addresses being linked in DLL builds. This -means, for example, that LEA instructions of the general form: - - lea, rax,[rax+symbol] - -cannot be used for DLL builds. The following general form -has to be used instead: - - lea rcx,[symbol wrt rip] - lea rax,[rax+rcx] - -This limitation may also cause problems with other instruction -that use absolute addresses. - -6. Acknowledgements -------------------- - -I am most grateful for the fantastic support that Peter Johnson, -YASM's creator, has given me in tracking down issues in using -YASM for the production of Windows x64 code. - - Brian Gladman, 16th May 2019 diff --git a/Mkfiles/vs/vsyasm.props b/Mkfiles/vs/vsyasm.props deleted file mode 100644 index 9d5c14fa..00000000 --- a/Mkfiles/vs/vsyasm.props +++ /dev/null @@ -1,27 +0,0 @@ - - - - Midl - CustomBuild - - - _SelectedFiles;$(YASMDependsOn) - - - C:\Program Files\yasm\ - - - - False - $(IntDir)%(FileName).obj - 0 - 0 - "$(YASM_PATH.TrimEnd('\'))"\vsyasm.exe -Xvc -f $(Platform) [AllOptions] [AdditionalOptions] [Inputs] - %(ObjectFile) - Assembling %(Filename)%(Extension) ==> $(IntDir)%(FileName).obj - false - - - diff --git a/Mkfiles/vs/vsyasm.targets b/Mkfiles/vs/vsyasm.targets deleted file mode 100644 index 8f38f2cb..00000000 --- a/Mkfiles/vs/vsyasm.targets +++ /dev/null @@ -1,110 +0,0 @@ - - - - - - - _YASM - - - - - - $(ComputeLinkInputsTargets); - ComputeYASMOutput; - - - $(ComputeLibInputsTargets); - ComputeYASMOutput; - - - - - $(MSBuildThisFileDirectory)$(MSBuildThisFileName).xml - - - - - - <_YASMReadTlog - Include="^%(YASM.FullPath);%(YASM.AdditionalDependencies)" - Condition="'%(YASM.ExcludedFromBuild)' != 'true' and '%(YASM.ObjectFile)' != ''"/> - <_YASMWriteTlog - Include="^%(YASM.FullPath);$([MSBuild]::NormalizePath('$(MSBuildProjectDirectory)', '%(YASM.ObjectFile)'))" - Condition="'%(YASM.ExcludedFromBuild)' != 'true' and '%(YASM.ObjectFile)' != ''"/> - - - - - - - - <_YASMReadTlog Remove="@(_YASMReadTlog)" /> - <_YASMWriteTlog Remove="@(_YASMWriteTlog)" /> - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Mkfiles/vs/vsyasm.vcxproj b/Mkfiles/vs/vsyasm.vcxproj deleted file mode 100644 index 40ab4d6e..00000000 --- a/Mkfiles/vs/vsyasm.vcxproj +++ /dev/null @@ -1,280 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {7FDD85BB-CC86-442B-A425-989B5B296ED5} - vsyasm - 10.0 - - - - Application - false - MultiByte - $(DefaultPlatformToolset) - - - Application - false - MultiByte - $(DefaultPlatformToolset) - - - Application - false - MultiByte - $(DefaultPlatformToolset) - - - Application - false - MultiByte - $(DefaultPlatformToolset) - - - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.21006.1 - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - $(Platform)\$(Configuration)/yasm.tlb - - - - - Disabled - .;../..;%(AdditionalIncludeDirectories) - _DEBUG;WIN32;_LIB;HAVE_CONFIG_H;VC;%(PreprocessorDefinitions) - EnableFastChecks - MultiThreadedDebug - - - - - $(IntDir) - $(IntDir) - $(IntDir) - Level3 - true - ProgramDatabase - Default - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - $(OutDir)vsyasm.exe - true - true - $(OutDir)$(ProjectName).pdb - Console - false - - - MachineX86 - - - - - X64 - $(Platform)\$(Configuration)/yasm.tlb - - - - - Disabled - .;../..;%(AdditionalIncludeDirectories) - _DEBUG;_LIB;HAVE_CONFIG_H;VC;WIN64;%(PreprocessorDefinitions) - EnableFastChecks - MultiThreadedDebug - - - - - $(IntDir) - $(IntDir) - $(IntDir) - Level3 - true - ProgramDatabase - Default - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - $(OutDir)vsyasm.exe - true - true - $(OutDir)$(TargetName).pdb - Console - false - - - MachineX64 - - - - - $(Platform)\$(Configuration)/yasm.tlb - - - - - Full - Default - true - .;../..;%(AdditionalIncludeDirectories) - NDEBUG;WIN32;_LIB;HAVE_CONFIG_H;VC;%(PreprocessorDefinitions) - true - MultiThreaded - true - - - - - $(IntDir) - $(IntDir) - $(IntDir) - Level3 - true - Default - ProgramDatabase - - - NDEBUG;%(PreprocessorDefinitions) - 0x0409 - - - $(OutDir)vsyasm.exe - true - true - $(OutDir)$(ProjectName).pdb - Console - false - - - MachineX86 - - - - - X64 - $(Platform)\$(Configuration)/yasm.tlb - - - - - Full - OnlyExplicitInline - .;../..;%(AdditionalIncludeDirectories) - NDEBUG;_LIB;HAVE_CONFIG_H;VC;WIN64;%(PreprocessorDefinitions) - true - MultiThreaded - true - - - - - $(IntDir) - $(IntDir) - $(IntDir) - Level3 - true - Default - ProgramDatabase - - - NDEBUG;%(PreprocessorDefinitions) - 0x0409 - - - $(OutDir)vsyasm.exe - true - $(OutDir)$(TargetName).pdb - Console - false - - - MachineX64 - true - - - - - - - - - {29fe7874-1256-4ad6-b889-68e399dc9608} - false - - - {d715a3d4-efaa-442e-ad8b-5b4ff64e1dd6} - false - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Mkfiles/vs/vsyasm.xml b/Mkfiles/vs/vsyasm.xml deleted file mode 100644 index a108f005..00000000 --- a/Mkfiles/vs/vsyasm.xml +++ /dev/null @@ -1,283 +0,0 @@ - - - - - - - - - - - - - General - - - - - - Symbols - - - - - - Files - - - - - - Command Line - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Execute Before - - - Specifies the targets for the build customization to run before. - - - - - - - - - - - - Execute After - - - Specifies the targets for the build customization to run after. - - - - - - - - - - - - - - - - - - Additional Options - - - Additional Options - - - - - - - - \ No newline at end of file diff --git a/Mkfiles/vs/yasm.vcxproj b/Mkfiles/vs/yasm.vcxproj deleted file mode 100644 index 13363e3c..00000000 --- a/Mkfiles/vs/yasm.vcxproj +++ /dev/null @@ -1,283 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {34EB1BEB-C2D6-4A52-82B7-7ACD714A30D5} - yasm - - - - Application - false - MultiByte - $(DefaultPlatformToolset) - - - Application - false - MultiByte - $(DefaultPlatformToolset) - - - Application - false - MultiByte - $(DefaultPlatformToolset) - - - Application - false - MultiByte - $(DefaultPlatformToolset) - - - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.21006.1 - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - $(Platform)\$(Configuration)/yasm.tlb - - - - - Disabled - .;../..;%(AdditionalIncludeDirectories) - _DEBUG;WIN32;_LIB;HAVE_CONFIG_H;VC;%(PreprocessorDefinitions) - EnableFastChecks - MultiThreadedDebug - - - - - $(IntDir) - $(IntDir) - $(IntDir) - Level3 - true - ProgramDatabase - Default - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - $(OutDir)yasm.exe - true - true - $(OutDir)$(ProjectName).pdb - Console - false - - - MachineX86 - - - - - X64 - $(Platform)\$(Configuration)/yasm.tlb - - - - - Disabled - .;../..;%(AdditionalIncludeDirectories) - _DEBUG;_LIB;HAVE_CONFIG_H;VC;WIN64;%(PreprocessorDefinitions) - EnableFastChecks - MultiThreadedDebug - - - - - $(IntDir) - $(IntDir) - $(IntDir) - Level3 - true - ProgramDatabase - Default - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - $(OutDir)yasm.exe - true - true - $(OutDir)$(TargetName).pdb - Console - false - - - MachineX64 - - - - - $(Platform)\$(Configuration)/yasm.tlb - - - - - Full - Default - true - .;../..;%(AdditionalIncludeDirectories) - NDEBUG;WIN32;_LIB;HAVE_CONFIG_H;VC;%(PreprocessorDefinitions) - true - MultiThreaded - true - - - - - $(IntDir) - $(IntDir) - $(IntDir) - Level3 - true - Default - ProgramDatabase - - - NDEBUG;%(PreprocessorDefinitions) - 0x0409 - - - $(OutDir)yasm.exe - true - true - $(OutDir)$(ProjectName).pdb - Console - false - - - MachineX86 - - - - - X64 - $(Platform)\$(Configuration)/yasm.tlb - - - - - Full - OnlyExplicitInline - .;../..;%(AdditionalIncludeDirectories) - NDEBUG;_LIB;HAVE_CONFIG_H;VC;WIN64;%(PreprocessorDefinitions) - true - MultiThreaded - true - - - - - $(IntDir) - $(IntDir) - $(IntDir) - Level3 - true - Default - ProgramDatabase - - - NDEBUG;%(PreprocessorDefinitions) - 0x0409 - - - $(OutDir)yasm.exe - true - $(OutDir)$(TargetName).pdb - Console - false - - - MachineX64 - true - - - - - - - - - - - - - - - - - {021ceb0a-f721-4f59-b349-9ceeaf244459} - false - - - {29fe7874-1256-4ad6-b889-68e399dc9608} - false - - - {d715a3d4-efaa-442e-ad8b-5b4ff64e1dd6} - false - - - - - - \ No newline at end of file diff --git a/Mkfiles/vs/yasm.vcxproj.filters b/Mkfiles/vs/yasm.vcxproj.filters deleted file mode 100644 index 04941c22..00000000 --- a/Mkfiles/vs/yasm.vcxproj.filters +++ /dev/null @@ -1,41 +0,0 @@ - - - - - {51f0d88e-1373-4bf8-a72e-c79706d37f8b} - h;hpp;hxx;hm;inl - - - {db67b411-6f59-462c-9c20-75024c6b3912} - cpp;c;cxx;rc;def;r;odl;idl;hpj;bat - - - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - \ No newline at end of file diff --git a/Mkfiles/vs/ytasm.vcxproj b/Mkfiles/vs/ytasm.vcxproj deleted file mode 100644 index 0e9d6bfa..00000000 --- a/Mkfiles/vs/ytasm.vcxproj +++ /dev/null @@ -1,278 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {2162937B-0DBD-4450-B45F-DF578D8E7508} - ytasm - - - - Application - false - MultiByte - $(DefaultPlatformToolset) - - - Application - false - MultiByte - $(DefaultPlatformToolset) - - - Application - false - MultiByte - $(DefaultPlatformToolset) - - - Application - false - MultiByte - $(DefaultPlatformToolset) - - - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.21006.1 - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - $(Platform)\$(Configuration)/yasm.tlb - - - - - Disabled - .;../..;%(AdditionalIncludeDirectories) - _DEBUG;WIN32;_LIB;HAVE_CONFIG_H;VC;%(PreprocessorDefinitions) - EnableFastChecks - MultiThreadedDebug - - - - - $(IntDir) - $(IntDir) - $(IntDir) - Level3 - true - ProgramDatabase - Default - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - $(OutDir)ytasm.exe - true - true - $(OutDir)$(ProjectName).pdb - Console - false - - - MachineX86 - - - - - X64 - $(Platform)\$(Configuration)/yasm.tlb - - - - - Disabled - .;../..;%(AdditionalIncludeDirectories) - _DEBUG;_LIB;HAVE_CONFIG_H;VC;WIN64;%(PreprocessorDefinitions) - EnableFastChecks - MultiThreadedDebug - - - - - $(IntDir) - $(IntDir) - $(IntDir) - Level3 - true - ProgramDatabase - Default - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - $(OutDir)ytasm.exe - true - true - $(OutDir)$(TargetName).pdb - Console - false - - - MachineX64 - - - - - $(Platform)\$(Configuration)/yasm.tlb - - - - - Full - Default - true - .;../..;%(AdditionalIncludeDirectories) - NDEBUG;WIN32;_LIB;HAVE_CONFIG_H;VC;%(PreprocessorDefinitions) - true - MultiThreaded - true - - - - - $(IntDir) - $(IntDir) - $(IntDir) - Level3 - true - Default - ProgramDatabase - - - NDEBUG;%(PreprocessorDefinitions) - 0x0409 - - - $(OutDir)ytasm.exe - true - true - $(OutDir)$(ProjectName).pdb - Console - false - - - MachineX86 - - - - - X64 - $(Platform)\$(Configuration)/yasm.tlb - - - - - Full - OnlyExplicitInline - .;../..;%(AdditionalIncludeDirectories) - NDEBUG;_LIB;HAVE_CONFIG_H;VC;WIN64;%(PreprocessorDefinitions) - true - MultiThreaded - true - - - - - $(IntDir) - $(IntDir) - $(IntDir) - Level3 - true - Default - ProgramDatabase - - - NDEBUG;%(PreprocessorDefinitions) - 0x0409 - - - $(OutDir)ytasm.exe - true - $(OutDir)$(TargetName).pdb - Console - false - - - MachineX64 - true - - - - - - - - - - - - - - - - {29fe7874-1256-4ad6-b889-68e399dc9608} - false - - - {d715a3d4-efaa-442e-ad8b-5b4ff64e1dd6} - false - - - - - - \ No newline at end of file diff --git a/README b/README index 6d529727..e69de29b 100644 --- a/README +++ b/README @@ -1,13 +0,0 @@ -The Yasm Modular Assembler Project -================================== - -Yasm is a complete rewrite of the NASM assembler under the “new” BSD License -(some portions are under other licenses, see COPYING for details). - -Yasm currently supports the x86 and AMD64 instruction sets, accepts NASM and -GAS assembler syntaxes, outputs binary, ELF32, ELF64, 32 and 64-bit Mach-O, -RDOFF2, COFF, Win32, and Win64 object formats, and generates source debugging -information in STABS, DWARF 2, and CodeView 8 formats. - -Yasm can be easily integrated into Visual Studio 2005/2008 and 2010 for -assembly of NASM or GAS syntax code into Win32 or Win64 object files. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index d205e244..00000000 --- a/SECURITY.md +++ /dev/null @@ -1,27 +0,0 @@ -Yasm Security policy -==================== - -A security bug is one that compromises the security of a system by either -making it unavailable, compromising the integrity of the data or by providing -unauthorized access to resources on the system through untrusted inputs. In -the context of yasm, it is expected that all inputs are trusted, since it is -developer code. It is the responsibility of the developer to either verify the -authenticity of the code they're building or to build untrusted code in a -sandbox to protect the system from any ill effects. This responsibility also -extends to the libyasm library. While the library aims to be robust and will -fix bugs arising from bogus inputs, it is the responsibility of the application -to ensure that either the environment under which the call is made is isolated -or that the input is sanitized. - -As such, all bugs will be deemed to have no security consequence with the -exception of bugs where yasm generates code that invoke [undefined behaviour in -a -system](https://www.cs.cmu.edu/~rdriley/487/papers/Thompson_1984_ReflectionsonTrustingTrust.pdf) -from valid, safe and trusted assembly code. - -Reporting security bugs ------------------------ - -To report security issues privately, you may reach out to one of the members of -the [Yasm Team](https://github.com/yasm/yasm/wiki/Yasmteam). Most issues -should just go into GitHub issues as regular bugs. diff --git a/YASM-VERSION-GEN.bat b/YASM-VERSION-GEN.bat deleted file mode 100644 index 92bb97e6..00000000 --- a/YASM-VERSION-GEN.bat +++ /dev/null @@ -1,38 +0,0 @@ -@echo off -if exist version goto haveversion - -set errorlevel=0 -set _my_= -for /f "usebackq tokens=1*" %%f in (`reg query HKCU\Software\TortoiseGit /v MSysGit`) do (set _my_=%%f %%g) -if %errorlevel% neq 0 goto notfound -if "%_my_%" == "" goto notfound - -rem Using the shell script version (calling Git) ... -set _gitbin_=%_my_:*REG_SZ=% -for /f "tokens=* delims= " %%a in ("%_gitbin_%") do set _gitbin_=%%a -set OLDPATH=%PATH% -set PATH=%_gitbin_%;%PATH% -"%_gitbin_%\sh" YASM-VERSION-GEN.sh "%_gitbin_%" -set PATH=%OLDPATH% -exit /b - -:notfound -rem Could not find Git ... -set _ver_= -for /f "usebackq tokens=2 delims==" %%a in (`%SystemRoot%\system32\find "DEF_VER=" ^ YASM-VERSION-FILE -echo #define PACKAGE_STRING "yasm %_ver_%" > YASM-VERSION.h -echo #define PACKAGE_VERSION "%_ver_%" >> YASM-VERSION.h - diff --git a/YASM-VERSION-GEN.sh b/YASM-VERSION-GEN.sh deleted file mode 100755 index 33469507..00000000 --- a/YASM-VERSION-GEN.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/sh - -YVF=YASM-VERSION-FILE -DEF_VER=v1.3.0 - -LF=' -' - -# First see if there is a version file (included in release tarballs), -# then try git-describe, then default. -if test -f version -then - VN=$(cat version) || VN="$DEF_VER" -elif test -d .git -o -f .git && - VN=$(git describe --match "v[0-9]*" --abbrev=4 HEAD 2>/dev/null) && - case "$VN" in - *$LF*) (exit 1) ;; - v[0-9]*) - git update-index -q --refresh - test -z "$(git diff-index --name-only HEAD --)" || - VN="$VN-dirty" ;; - esac -then - VN=$(echo "$VN" | sed -e 's/-/./g'); -else - VN="$DEF_VER" -fi - -VN=$(expr "$VN" : v*'\(.*\)') - -if test -r $YVF -then - VC=$(cat $YVF) -else - VC=unset -fi -test "$VN" = "$VC" || { - echo >&2 "$VN" - echo "$VN" >$YVF - echo "#define PACKAGE_STRING \"yasm $VN\"" > YASM-VERSION.h - echo "#define PACKAGE_VERSION \"$VN\"" >> YASM-VERSION.h -} diff --git a/autogen.sh b/autogen.sh index 12da6aa4..9f9c45b2 100755 --- a/autogen.sh +++ b/autogen.sh @@ -1,4 +1,5 @@ #!/bin/sh +# $Id$ # Run this to set up the build system: configure, makefiles, etc. # (based on the version in enlightenment's cvs) @@ -73,8 +74,7 @@ if test ! -d "config"; then mkdir config fi -rm -rf autom4te.cache -rm -f configure config.h config.status config.log stamp-h.in +rm -f stamp-h.in #echo " gettextize -f --no-changelog" #echo "N" | gettextize -f --no-changelog || exit 1 echo " aclocal $ACLOCAL_FLAGS" diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt deleted file mode 100644 index 5e4ef796..00000000 --- a/cmake/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -ADD_SUBDIRECTORY(modules) diff --git a/cmake/modules/CMakeLists.txt b/cmake/modules/CMakeLists.txt deleted file mode 100644 index e4351fc9..00000000 --- a/cmake/modules/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -FILE(GLOB cmakeFiles "${CMAKE_CURRENT_SOURCE_DIR}/*.cmake") - diff --git a/cmake/modules/DummyCFile.c b/cmake/modules/DummyCFile.c deleted file mode 100644 index f8b643af..00000000 --- a/cmake/modules/DummyCFile.c +++ /dev/null @@ -1,4 +0,0 @@ -int main() -{ - return 0; -} diff --git a/cmake/modules/VersionGen.cmake b/cmake/modules/VersionGen.cmake deleted file mode 100644 index f10ce33c..00000000 --- a/cmake/modules/VersionGen.cmake +++ /dev/null @@ -1,78 +0,0 @@ -# Redistribution and use is allowed according to the terms of the BSD license. -# -# Copyright (c) 2011 Peter Johnson - -macro (VERSION_GEN _version _version_file _default_version) - set (_vn "v${_default_version}") - - # First see if there is a version file (included in release tarballs), - # then try git-describe, then default. - if (EXISTS "${CMAKE_SOURCE_DIR}/version") - file (STRINGS "${CMAKE_SOURCE_DIR}/version" _version_strs LIMIT_COUNT 1) - list (GET _version_strs 0 _version_strs0) - if (NOT (${_version_strs0} STREQUAL "")) - set (_vn "v${_version_strs0}") - endif (NOT (${_version_strs0} STREQUAL "")) - elseif (EXISTS "${CMAKE_SOURCE_DIR}/.git") - execute_process (COMMAND git describe --match "v[0-9]*" --abbrev=4 HEAD - RESULT_VARIABLE _git_result - OUTPUT_VARIABLE _git_vn - ERROR_QUIET - OUTPUT_STRIP_TRAILING_WHITESPACE) - - if (_git_result EQUAL 0) - # Special handling until we get a more recent tag on the master - # branch - if (_git_vn MATCHES "^v0[.]1[.]0") - execute_process (COMMAND git merge-base v${_default_version} HEAD - OUTPUT_VARIABLE _merge_base - ERROR_QUIET - OUTPUT_STRIP_TRAILING_WHITESPACE) - #message (STATUS "Merge base: ${_merge_base}") - - execute_process (COMMAND git rev-list ${_merge_base}..HEAD - OUTPUT_VARIABLE _rev_list - ERROR_QUIET) - string (REGEX MATCHALL "[^\n]*\n" _rev_list_lines "${_rev_list}") - #message (STATUS "Rev list: ${_rev_list_lines}") - list (LENGTH _rev_list_lines _vn1) - - execute_process (COMMAND git rev-list --max-count=1 --abbrev-commit --abbrev=4 HEAD - OUTPUT_VARIABLE _vn2 - ERROR_QUIET - OUTPUT_STRIP_TRAILING_WHITESPACE) - - set (_git_vn "v${_default_version}-${_vn1}-g${_vn2}") - endif (_git_vn MATCHES "^v0[.]1[.]0") - - # Append -dirty if there are local changes - execute_process (COMMAND git update-index -q --refresh) - execute_process (COMMAND git diff-index --name-only HEAD -- - OUTPUT_VARIABLE _git_vn_dirty) - if (_git_vn_dirty) - set (_git_vn "${_git_vn}-dirty") - endif (_git_vn_dirty) - - # Substitute . for - in the result - string (REPLACE "-" "." _vn "${_git_vn}") - endif (_git_result EQUAL 0) - endif (EXISTS "${CMAKE_SOURCE_DIR}/version") - - # Strip leading "v" from version - #message (STATUS "_vn: ${_vn}") - string (REGEX REPLACE "^v*(.+)" "\\1" _vn "${_vn}") - - # Update version file if required - if (EXISTS ${_version_file}) - file (STRINGS ${_version_file} _version_strs LIMIT_COUNT 1) - list (GET _version_strs 0 _vc) - else (EXISTS ${_version_file}) - set (_vc "unset") - endif (EXISTS ${_version_file}) - if (NOT ("${_vn}" STREQUAL "${_vc}")) - file (WRITE ${_version_file} "${_vn}") - endif (NOT ("${_vn}" STREQUAL "${_vc}")) - - # Set output version variable - set (${_version} ${_vn}) -endmacro (VERSION_GEN) diff --git a/cmake/modules/YasmMacros.cmake b/cmake/modules/YasmMacros.cmake deleted file mode 100644 index c6e01922..00000000 --- a/cmake/modules/YasmMacros.cmake +++ /dev/null @@ -1,83 +0,0 @@ -# Portions based on kdelibs KDE4Macros.cmake: -# -# Copyright (c) 2006, 2007, Alexander Neundorf, -# Copyright (c) 2006, 2007, Laurent Montel, -# Copyright (c) 2007 Matthias Kretz -# -# Redistribution and use is allowed according to the terms of the BSD license. -# -# Changes for Yasm Copyright (c) 2007 Peter Johnson - -# add a unit test, which is executed when running make test -# it will be built with RPATH pointing to the build dir -# The targets are always created, but only built for the "all" -# target if the option YASM_BUILD_TESTS is enabled. Otherwise the rules for -# the target are created but not built by default. You can build them by -# manually building the target. -# The name of the target can be specified using TESTNAME , if it is -# not given the macro will default to the -macro (YASM_ADD_UNIT_TEST _test_NAME) - set(_srcList ${ARGN}) - set(_targetName ${_test_NAME}) - if( ${ARGV1} STREQUAL "TESTNAME" ) - set(_targetName ${ARGV2}) - LIST(REMOVE_AT _srcList 0 1) - endif( ${ARGV1} STREQUAL "TESTNAME" ) - yasm_add_test_executable( ${_test_NAME} ${_srcList} ) - add_test( ${_targetName} ${EXECUTABLE_OUTPUT_PATH}/${_test_NAME} ) -endmacro (YASM_ADD_UNIT_TEST) - -# add an test executable -# it will be built with RPATH pointing to the build dir -# The targets are always created, but only built for the "all" -# target if the option YASM_BUILD_TESTS is enabled. Otherwise the rules for -# the target are created but not built by default. You can build them by -# manually building the target. -macro (YASM_ADD_TEST_EXECUTABLE _target_NAME) - - set(_add_executable_param) - - if (NOT YASM_BUILD_TESTS) - set(_add_executable_param EXCLUDE_FROM_ALL) - endif (NOT YASM_BUILD_TESTS) - - set( EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR} ) - - set(_SRCS ${ARGN}) - add_executable(${_target_NAME} ${_add_executable_param} ${_SRCS}) - - set_target_properties(${_target_NAME} PROPERTIES - SKIP_BUILD_RPATH FALSE - BUILD_WITH_INSTALL_RPATH FALSE) - -endmacro (YASM_ADD_TEST_EXECUTABLE) - -macro (YASM_ADD_MODULE _module_NAME) - list(APPEND YASM_MODULES_SRC ${ARGN}) - list(APPEND YASM_MODULES ${_module_NAME}) -endmacro (YASM_ADD_MODULE) - -macro (YASM_GENPERF _in_NAME _out_NAME) - add_custom_command( - OUTPUT ${_out_NAME} - COMMAND yasm::genperf ${_in_NAME} ${_out_NAME} - MAIN_DEPENDENCY ${_in_NAME} - ) -endmacro (YASM_GENPERF) - -macro (YASM_RE2C _in_NAME _out_NAME) - add_custom_command( - OUTPUT ${_out_NAME} - COMMAND yasm::re2c ${ARGN} -o ${_out_NAME} ${_in_NAME} - MAIN_DEPENDENCY ${_in_NAME} - ) -endmacro (YASM_RE2C) - -macro (YASM_GENMACRO _in_NAME _out_NAME _var_NAME) - add_custom_command( - OUTPUT ${_out_NAME} - COMMAND yasm::genmacro ${_out_NAME} ${_var_NAME} ${_in_NAME} - MAIN_DEPENDENCY ${_in_NAME} - ) -endmacro (YASM_GENMACRO) - diff --git a/config.h.cmake b/config.h.cmake deleted file mode 100644 index 61e99d00..00000000 --- a/config.h.cmake +++ /dev/null @@ -1,53 +0,0 @@ -/* config.h. Generated by cmake from config.h.cmake */ - -#define CMAKE_BUILD 1 - -/* Define if shared libs are being built */ -#cmakedefine BUILD_SHARED_LIBS 1 - -/* Define if messsage translations are enabled */ -#cmakedefine ENABLE_NLS 1 - -/* Define if you have the `abort' function. */ -#cmakedefine HAVE_ABORT 1 - -/* */ -#undef HAVE_GETTEXT - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_LIBGEN_H 1 - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_UNISTD_H 1 - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_DIRECT_H 1 - -/* Define to 1 if you have the `getcwd' function. */ -#cmakedefine HAVE_GETCWD 1 - -/* Define to 1 if you have the `_stricmp' function. */ -#cmakedefine HAVE__STRICMP 1 - -/* Define to 1 if you have the `toascii' function. */ -#cmakedefine HAVE_TOASCII 1 - -/* Name of package */ -#define PACKAGE "yasm" - -/* Define to the address where bug reports for this package should be sent. */ -#define PACKAGE_BUGREPORT "bug-yasm@tortall.net" - -/* Define to the full name of this package. */ -#define PACKAGE_NAME "yasm" - -/* Define to the full name and version of this package. */ -#define PACKAGE_STRING "@PACKAGE_STRING@" - -/* Define to the version of this package. */ -#define PACKAGE_VERSION "@PACKAGE_VERSION@" - -#define VERSION PACKAGE_VERSION - -/* Command name to run C preprocessor */ -#define CPP_PROG "@CPP_PROG@" diff --git a/config/.gitignore b/config/.gitignore deleted file mode 100644 index 4ea29110..00000000 --- a/config/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -mkinstalldirs -depcomp -compile -missing -install-sh diff --git a/config/config.guess b/config/config.guess index d622a44e..0e30d56e 100644 --- a/config/config.guess +++ b/config/config.guess @@ -1,10 +1,9 @@ #! /bin/sh # Attempt to guess a canonical system name. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, -# 2011, 2012 Free Software Foundation, Inc. +# 2000, 2001, 2002, 2003 Free Software Foundation, Inc. -timestamp='2012-02-10' +timestamp='2003-07-02' # 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 @@ -17,24 +16,24 @@ timestamp='2012-02-10' # 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 . +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. - -# Originally written by Per Bothner. Please send patches (context -# diff format) to and include a ChangeLog -# entry. +# Originally written by Per Bothner . +# Please send patches to . Submit a context +# diff and a properly formatted ChangeLog entry. # # This script attempts to guess a canonical system name similar to # config.sub. If it succeeds, it prints the system name on stdout, and # exits with 0. Otherwise, it exits with 1. # -# You can get the latest version of this script from: -# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD +# The plan is that this can be called by configure scripts if you +# don't specify an explicit build system type. me=`echo "$0" | sed -e 's,.*/,,'` @@ -54,8 +53,7 @@ version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, -2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO @@ -68,11 +66,11 @@ Try \`$me --help' for more information." while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) - echo "$timestamp" ; exit ;; + echo "$timestamp" ; exit 0 ;; --version | -v ) - echo "$version" ; exit ;; + echo "$version" ; exit 0 ;; --help | --h* | -h ) - echo "$usage"; exit ;; + echo "$usage"; exit 0 ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. @@ -106,7 +104,7 @@ set_cc_for_build=' trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; : ${TMPDIR=/tmp} ; - { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || + { tmp=`(umask 077 && mktemp -d -q "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; @@ -125,7 +123,7 @@ case $CC_FOR_BUILD,$HOST_CC,$CC in ;; ,,*) CC_FOR_BUILD=$CC ;; ,*,*) CC_FOR_BUILD=$HOST_CC ;; -esac ; set_cc_for_build= ;' +esac ;' # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 1994-08-24) @@ -143,7 +141,7 @@ UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or - # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, + # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently # switched to ELF, *-*-netbsd* would select the old # object file format. This provides both forward @@ -160,7 +158,6 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; sh3eb) machine=sh-unknown ;; - sh5el) machine=sh5le-unknown ;; *) machine=${UNAME_MACHINE_ARCH}-unknown ;; esac # The Operating System including object format, if it has switched @@ -169,7 +166,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in arm*|i386|m68k|ns32k|sh3*|sparc|vax) eval $set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ - | grep -q __ELF__ + | grep __ELF__ >/dev/null then # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). # Return netbsd for either. FIX? @@ -179,7 +176,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in fi ;; *) - os=netbsd + os=netbsd ;; esac # The OS release @@ -199,32 +196,50 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. echo "${machine}-${os}${release}" - exit ;; + exit 0 ;; + amiga:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + arc:OpenBSD:*:*) + echo mipsel-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + hp300:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + mac68k:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + macppc:OpenBSD:*:*) + echo powerpc-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + mvme68k:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + mvme88k:OpenBSD:*:*) + echo m88k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + mvmeppc:OpenBSD:*:*) + echo powerpc-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + pmax:OpenBSD:*:*) + echo mipsel-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + sgi:OpenBSD:*:*) + echo mipseb-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + sun3:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + wgrisc:OpenBSD:*:*) + echo mipsel-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; *:OpenBSD:*:*) - UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` - echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} - exit ;; - *:ekkoBSD:*:*) - echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} - exit ;; - *:SolidBSD:*:*) - echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} - exit ;; - macppc:MirBSD:*:*) - echo powerpc-unknown-mirbsd${UNAME_RELEASE} - exit ;; - *:MirBSD:*:*) - echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} - exit ;; + echo ${UNAME_MACHINE}-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; alpha:OSF1:*:*) - case $UNAME_RELEASE in - *4.0) + if test $UNAME_RELEASE = "V4.0"; then UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` - ;; - *5.*) - UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` - ;; - esac + fi # According to Compaq, /usr/sbin/psrinfo has been available on # OSF/1 and Tru64 systems produced since 1995. I hope that # covers most systems running today. This code pipes the CPU @@ -262,52 +277,42 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in "EV7.9 (21364A)") UNAME_MACHINE="alphaev79" ;; esac - # A Pn.n version is a patched version. # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. - echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - # Reset EXIT trap before exiting to avoid spurious non-zero exit code. - exitcode=$? - trap '' 0 - exit $exitcode ;; + echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + exit 0 ;; + Alpha*:OpenVMS:*:*) + echo alpha-hp-vms + exit 0 ;; Alpha\ *:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # Should we change UNAME_MACHINE based on the output of uname instead # of the specific Alpha model? echo alpha-pc-interix - exit ;; + exit 0 ;; 21064:Windows_NT:50:3) echo alpha-dec-winnt3.5 - exit ;; + exit 0 ;; Amiga*:UNIX_System_V:4.0:*) echo m68k-unknown-sysv4 - exit ;; + exit 0;; *:[Aa]miga[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-amigaos - exit ;; + exit 0 ;; *:[Mm]orph[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-morphos - exit ;; + exit 0 ;; *:OS/390:*:*) echo i370-ibm-openedition - exit ;; - *:z/VM:*:*) - echo s390-ibm-zvmoe - exit ;; - *:OS400:*:*) - echo powerpc-ibm-os400 - exit ;; + exit 0 ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix${UNAME_RELEASE} - exit ;; - arm:riscos:*:*|arm:RISCOS:*:*) - echo arm-unknown-riscos - exit ;; + exit 0;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) echo hppa1.1-hitachi-hiuxmpp - exit ;; + exit 0;; Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. if test "`(/bin/universe) 2>/dev/null`" = att ; then @@ -315,51 +320,32 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in else echo pyramid-pyramid-bsd fi - exit ;; + exit 0 ;; NILE*:*:*:dcosx) echo pyramid-pyramid-svr4 - exit ;; + exit 0 ;; DRS?6000:unix:4.0:6*) echo sparc-icl-nx6 - exit ;; - DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) + exit 0 ;; + DRS?6000:UNIX_SV:4.2*:7*) case `/usr/bin/uname -p` in - sparc) echo sparc-icl-nx7; exit ;; + sparc) echo sparc-icl-nx7 && exit 0 ;; esac ;; - s390x:SunOS:*:*) - echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; sun4H:SunOS:5.*:*) echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; + exit 0 ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) - echo i386-pc-auroraux${UNAME_RELEASE} - exit ;; - i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) - eval $set_cc_for_build - SUN_ARCH="i386" - # If there is a compiler, see if it is configured for 64-bit objects. - # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. - # This test works for both compilers. - if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then - if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ - (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ - grep IS_64BIT_ARCH >/dev/null - then - SUN_ARCH="x86_64" - fi - fi - echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; + exit 0 ;; + i86pc:SunOS:5.*:*) + echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; + exit 0 ;; sun4*:SunOS:*:*) case "`/usr/bin/arch -k`" in Series*|S4*) @@ -368,10 +354,10 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in esac # Japanese Language versions have a version number like `4.1.3-JL'. echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` - exit ;; + exit 0 ;; sun3*:SunOS:*:*) echo m68k-sun-sunos${UNAME_RELEASE} - exit ;; + exit 0 ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 @@ -383,10 +369,10 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in echo sparc-sun-sunos${UNAME_RELEASE} ;; esac - exit ;; + exit 0 ;; aushp:SunOS:*:*) echo sparc-auspex-sunos${UNAME_RELEASE} - exit ;; + exit 0 ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not # "atarist" or "atariste" at least should have a processor @@ -396,41 +382,38 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit ;; + echo m68k-atari-mint${UNAME_RELEASE} + exit 0 ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} - exit ;; + exit 0 ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit ;; + echo m68k-atari-mint${UNAME_RELEASE} + exit 0 ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) - echo m68k-milan-mint${UNAME_RELEASE} - exit ;; + echo m68k-milan-mint${UNAME_RELEASE} + exit 0 ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) - echo m68k-hades-mint${UNAME_RELEASE} - exit ;; + echo m68k-hades-mint${UNAME_RELEASE} + exit 0 ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) - echo m68k-unknown-mint${UNAME_RELEASE} - exit ;; - m68k:machten:*:*) - echo m68k-apple-machten${UNAME_RELEASE} - exit ;; + echo m68k-unknown-mint${UNAME_RELEASE} + exit 0 ;; powerpc:machten:*:*) echo powerpc-apple-machten${UNAME_RELEASE} - exit ;; + exit 0 ;; RISC*:Mach:*:*) echo mips-dec-mach_bsd4.3 - exit ;; + exit 0 ;; RISC*:ULTRIX:*:*) echo mips-dec-ultrix${UNAME_RELEASE} - exit ;; + exit 0 ;; VAX*:ULTRIX*:*:*) echo vax-dec-ultrix${UNAME_RELEASE} - exit ;; + exit 0 ;; 2020:CLIX:*:* | 2430:CLIX:*:*) echo clipper-intergraph-clix${UNAME_RELEASE} - exit ;; + exit 0 ;; mips:*:*:UMIPS | mips:*:*:RISCos) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c @@ -454,36 +437,35 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in exit (-1); } EOF - $CC_FOR_BUILD -o $dummy $dummy.c && - dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && - SYSTEM_NAME=`$dummy $dummyarg` && - { echo "$SYSTEM_NAME"; exit; } + $CC_FOR_BUILD -o $dummy $dummy.c \ + && $dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \ + && exit 0 echo mips-mips-riscos${UNAME_RELEASE} - exit ;; + exit 0 ;; Motorola:PowerMAX_OS:*:*) echo powerpc-motorola-powermax - exit ;; + exit 0 ;; Motorola:*:4.3:PL8-*) echo powerpc-harris-powermax - exit ;; + exit 0 ;; Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) echo powerpc-harris-powermax - exit ;; + exit 0 ;; Night_Hawk:Power_UNIX:*:*) echo powerpc-harris-powerunix - exit ;; + exit 0 ;; m88k:CX/UX:7*:*) echo m88k-harris-cxux7 - exit ;; + exit 0 ;; m88k:*:4*:R4*) echo m88k-motorola-sysv4 - exit ;; + exit 0 ;; m88k:*:3*:R3*) echo m88k-motorola-sysv3 - exit ;; + exit 0 ;; AViiON:dgux:*:*) - # DG/UX returns AViiON for all architectures - UNAME_PROCESSOR=`/usr/bin/uname -p` + # DG/UX returns AViiON for all architectures + UNAME_PROCESSOR=`/usr/bin/uname -p` if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] then if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ @@ -496,29 +478,29 @@ EOF else echo i586-dg-dgux${UNAME_RELEASE} fi - exit ;; + exit 0 ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) echo m88k-dolphin-sysv3 - exit ;; + exit 0 ;; M88*:*:R3*:*) # Delta 88k system running SVR3 echo m88k-motorola-sysv3 - exit ;; + exit 0 ;; XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) echo m88k-tektronix-sysv3 - exit ;; + exit 0 ;; Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) echo m68k-tektronix-bsd - exit ;; + exit 0 ;; *:IRIX*:*:*) echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` - exit ;; + exit 0 ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. - echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id - exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' + echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id + exit 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX ' i*86:AIX:*:*) echo i386-ibm-aix - exit ;; + exit 0 ;; ia64:AIX:*:*) if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` @@ -526,7 +508,7 @@ EOF IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} - exit ;; + exit 0 ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then eval $set_cc_for_build @@ -541,19 +523,15 @@ EOF exit(0); } EOF - if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` - then - echo "$SYSTEM_NAME" - else - echo rs6000-ibm-aix3.2.5 - fi + $CC_FOR_BUILD -o $dummy $dummy.c && $dummy && exit 0 + echo rs6000-ibm-aix3.2.5 elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then echo rs6000-ibm-aix3.2.4 else echo rs6000-ibm-aix3.2 fi - exit ;; - *:AIX:*:[4567]) + exit 0 ;; + *:AIX:*:[45]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 @@ -566,28 +544,28 @@ EOF IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${IBM_ARCH}-ibm-aix${IBM_REV} - exit ;; + exit 0 ;; *:AIX:*:*) echo rs6000-ibm-aix - exit ;; + exit 0 ;; ibmrt:4.4BSD:*|romp-ibm:BSD:*) echo romp-ibm-bsd4.4 - exit ;; + exit 0 ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to - exit ;; # report: romp-ibm BSD 4.3 + exit 0 ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) echo rs6000-bull-bosx - exit ;; + exit 0 ;; DPX/2?00:B.O.S.:*:*) echo m68k-bull-sysv3 - exit ;; + exit 0 ;; 9000/[34]??:4.3bsd:1.*:*) echo m68k-hp-bsd - exit ;; + exit 0 ;; hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) echo m68k-hp-bsd4.4 - exit ;; + exit 0 ;; 9000/[34678]??:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` case "${UNAME_MACHINE}" in @@ -596,52 +574,52 @@ EOF 9000/[678][0-9][0-9]) if [ -x /usr/bin/getconf ]; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` - sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` - case "${sc_cpu_version}" in - 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 - 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 - 532) # CPU_PA_RISC2_0 - case "${sc_kernel_bits}" in - 32) HP_ARCH="hppa2.0n" ;; - 64) HP_ARCH="hppa2.0w" ;; + sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` + case "${sc_cpu_version}" in + 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 + 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 + 532) # CPU_PA_RISC2_0 + case "${sc_kernel_bits}" in + 32) HP_ARCH="hppa2.0n" ;; + 64) HP_ARCH="hppa2.0w" ;; '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 - esac ;; - esac + esac ;; + esac fi if [ "${HP_ARCH}" = "" ]; then eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + sed 's/^ //' << EOF >$dummy.c - #define _HPUX_SOURCE - #include - #include + #define _HPUX_SOURCE + #include + #include - int main () - { - #if defined(_SC_KERNEL_BITS) - long bits = sysconf(_SC_KERNEL_BITS); - #endif - long cpu = sysconf (_SC_CPU_VERSION); + int main () + { + #if defined(_SC_KERNEL_BITS) + long bits = sysconf(_SC_KERNEL_BITS); + #endif + long cpu = sysconf (_SC_CPU_VERSION); - switch (cpu) - { - case CPU_PA_RISC1_0: puts ("hppa1.0"); break; - case CPU_PA_RISC1_1: puts ("hppa1.1"); break; - case CPU_PA_RISC2_0: - #if defined(_SC_KERNEL_BITS) - switch (bits) - { - case 64: puts ("hppa2.0w"); break; - case 32: puts ("hppa2.0n"); break; - default: puts ("hppa2.0"); break; - } break; - #else /* !defined(_SC_KERNEL_BITS) */ - puts ("hppa2.0"); break; - #endif - default: puts ("hppa1.0"); break; - } - exit (0); - } + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1"); break; + case CPU_PA_RISC2_0: + #if defined(_SC_KERNEL_BITS) + switch (bits) + { + case 64: puts ("hppa2.0w"); break; + case 32: puts ("hppa2.0n"); break; + default: puts ("hppa2.0"); break; + } break; + #else /* !defined(_SC_KERNEL_BITS) */ + puts ("hppa2.0"); break; + #endif + default: puts ("hppa1.0"); break; + } + exit (0); + } EOF (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` test -z "$HP_ARCH" && HP_ARCH=hppa @@ -649,19 +627,9 @@ EOF esac if [ ${HP_ARCH} = "hppa2.0w" ] then - eval $set_cc_for_build - - # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating - # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler - # generating 64-bit code. GNU and HP use different nomenclature: - # - # $ CC_FOR_BUILD=cc ./config.guess - # => hppa2.0w-hp-hpux11.23 - # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess - # => hppa64-hp-hpux11.23 - - if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | - grep -q __LP64__ + # avoid double evaluation of $set_cc_for_build + test -n "$CC_FOR_BUILD" || eval $set_cc_for_build + if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E -) | grep __LP64__ >/dev/null then HP_ARCH="hppa2.0w" else @@ -669,11 +637,11 @@ EOF fi fi echo ${HP_ARCH}-hp-hpux${HPUX_REV} - exit ;; + exit 0 ;; ia64:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` echo ia64-hp-hpux${HPUX_REV} - exit ;; + exit 0 ;; 3050*:HI-UX:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c @@ -701,173 +669,197 @@ EOF exit (0); } EOF - $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && - { echo "$SYSTEM_NAME"; exit; } + $CC_FOR_BUILD -o $dummy $dummy.c && $dummy && exit 0 echo unknown-hitachi-hiuxwe2 - exit ;; + exit 0 ;; 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) echo hppa1.1-hp-bsd - exit ;; + exit 0 ;; 9000/8??:4.3bsd:*:*) echo hppa1.0-hp-bsd - exit ;; + exit 0 ;; *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) echo hppa1.0-hp-mpeix - exit ;; + exit 0 ;; hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) echo hppa1.1-hp-osf - exit ;; + exit 0 ;; hp8??:OSF1:*:*) echo hppa1.0-hp-osf - exit ;; + exit 0 ;; i*86:OSF1:*:*) if [ -x /usr/sbin/sysversion ] ; then echo ${UNAME_MACHINE}-unknown-osf1mk else echo ${UNAME_MACHINE}-unknown-osf1 fi - exit ;; + exit 0 ;; parisc*:Lites*:*:*) echo hppa1.1-hp-lites - exit ;; + exit 0 ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd - exit ;; + exit 0 ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi - exit ;; + exit 0 ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) echo c34-convex-bsd - exit ;; + exit 0 ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) echo c38-convex-bsd - exit ;; + exit 0 ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd - exit ;; + exit 0 ;; CRAY*Y-MP:*:*:*) echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; + exit 0 ;; CRAY*[A-Z]90:*:*:*) echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ -e 's/\.[^.]*$/.X/' - exit ;; + exit 0 ;; CRAY*TS:*:*:*) echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; + exit 0 ;; CRAY*T3E:*:*:*) echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; + exit 0 ;; CRAY*SV1:*:*:*) echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; + exit 0 ;; *:UNICOS/mp:*:*) - echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; + echo nv1-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit 0 ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` - echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" - exit ;; - 5000:UNIX_System_V:4.*:*) - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` - echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" - exit ;; + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` + echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit 0 ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} - exit ;; + exit 0 ;; sparc*:BSD/OS:*:*) echo sparc-unknown-bsdi${UNAME_RELEASE} - exit ;; + exit 0 ;; *:BSD/OS:*:*) echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} - exit ;; - *:FreeBSD:*:*) - UNAME_PROCESSOR=`/usr/bin/uname -p` - case ${UNAME_PROCESSOR} in - amd64) - echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; - *) - echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; - esac - exit ;; + exit 0 ;; + *:FreeBSD:*:*|*:GNU/FreeBSD:*:*) + # Determine whether the default compiler uses glibc. + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include + #if __GLIBC__ >= 2 + LIBC=gnu + #else + LIBC= + #endif +EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=` + # GNU/FreeBSD systems have a "k" prefix to indicate we are using + # FreeBSD's kernel, but not the complete OS. + case ${LIBC} in gnu) kernel_only='k' ;; esac + echo ${UNAME_MACHINE}-unknown-${kernel_only}freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`${LIBC:+-$LIBC} + exit 0 ;; i*:CYGWIN*:*) echo ${UNAME_MACHINE}-pc-cygwin - exit ;; - *:MINGW*:*) + exit 0 ;; + i*:MINGW*:*) echo ${UNAME_MACHINE}-pc-mingw32 - exit ;; - i*:MSYS*:*) - echo ${UNAME_MACHINE}-pc-msys - exit ;; - i*:windows32*:*) - # uname -m includes "-pc" on this system. - echo ${UNAME_MACHINE}-mingw32 - exit ;; + exit 0 ;; i*:PW*:*) echo ${UNAME_MACHINE}-pc-pw32 - exit ;; - *:Interix*:*) - case ${UNAME_MACHINE} in - x86) - echo i586-pc-interix${UNAME_RELEASE} - exit ;; - authenticamd | genuineintel | EM64T) - echo x86_64-unknown-interix${UNAME_RELEASE} - exit ;; - IA64) - echo ia64-unknown-interix${UNAME_RELEASE} - exit ;; - esac ;; + exit 0 ;; + x86:Interix*:[34]*) + echo i586-pc-interix${UNAME_RELEASE}|sed -e 's/\..*//' + exit 0 ;; [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) echo i${UNAME_MACHINE}-pc-mks - exit ;; - 8664:Windows_NT:*) - echo x86_64-pc-mks - exit ;; + exit 0 ;; i*:Windows_NT*:* | Pentium*:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we # UNAME_MACHINE based on the output of uname instead of i386? echo i586-pc-interix - exit ;; + exit 0 ;; i*:UWIN*:*) echo ${UNAME_MACHINE}-pc-uwin - exit ;; - amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) - echo x86_64-unknown-cygwin - exit ;; + exit 0 ;; p*:CYGWIN*:*) echo powerpcle-unknown-cygwin - exit ;; + exit 0 ;; prep*:SunOS:5.*:*) echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; + exit 0 ;; *:GNU:*:*) - # the GNU system echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` - exit ;; - *:GNU/*:*:*) - # other systems with GNU libc and userland - echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu - exit ;; + exit 0 ;; i*86:Minix:*:*) echo ${UNAME_MACHINE}-pc-minix - exit ;; - aarch64:Linux:*:*) + exit 0 ;; + arm*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; - aarch64_be:Linux:*:*) - UNAME_MACHINE=aarch64_be + exit 0 ;; + cris:Linux:*:*) + echo cris-axis-linux-gnu + exit 0 ;; + ia64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; + exit 0 ;; + m68*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit 0 ;; + mips:Linux:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #undef CPU + #undef mips + #undef mipsel + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) + CPU=mipsel + #else + #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) + CPU=mips + #else + CPU= + #endif + #endif +EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=` + test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0 + ;; + mips64:Linux:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #undef CPU + #undef mips64 + #undef mips64el + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) + CPU=mips64el + #else + #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) + CPU=mips64 + #else + CPU= + #endif + #endif +EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=` + test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0 + ;; + ppc:Linux:*:*) + echo powerpc-unknown-linux-gnu + exit 0 ;; + ppc64:Linux:*:*) + echo powerpc64-unknown-linux-gnu + exit 0 ;; alpha:Linux:*:*) case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in EV5) UNAME_MACHINE=alphaev5 ;; @@ -877,90 +869,11 @@ EOF EV6) UNAME_MACHINE=alphaev6 ;; EV67) UNAME_MACHINE=alphaev67 ;; EV68*) UNAME_MACHINE=alphaev68 ;; - esac - objdump --private-headers /bin/sh | grep -q ld.so.1 + esac + objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} - exit ;; - arm*:Linux:*:*) - eval $set_cc_for_build - if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ - | grep -q __ARM_EABI__ - then - echo ${UNAME_MACHINE}-unknown-linux-gnu - else - if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ - | grep -q __ARM_PCS_VFP - then - echo ${UNAME_MACHINE}-unknown-linux-gnueabi - else - echo ${UNAME_MACHINE}-unknown-linux-gnueabihf - fi - fi - exit ;; - avr32*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; - cris:Linux:*:*) - echo ${UNAME_MACHINE}-axis-linux-gnu - exit ;; - crisv32:Linux:*:*) - echo ${UNAME_MACHINE}-axis-linux-gnu - exit ;; - frv:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; - hexagon:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; - i*86:Linux:*:*) - LIBC=gnu - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #ifdef __dietlibc__ - LIBC=dietlibc - #endif -EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'` - echo "${UNAME_MACHINE}-pc-linux-${LIBC}" - exit ;; - ia64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; - m32r*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; - m68*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; - mips:Linux:*:* | mips64:Linux:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #undef CPU - #undef ${UNAME_MACHINE} - #undef ${UNAME_MACHINE}el - #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) - CPU=${UNAME_MACHINE}el - #else - #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) - CPU=${UNAME_MACHINE} - #else - CPU= - #endif - #endif -EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` - test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } - ;; - or32:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; - padre:Linux:*:*) - echo sparc-unknown-linux-gnu - exit ;; - parisc64:Linux:*:* | hppa64:Linux:*:*) - echo hppa64-unknown-linux-gnu - exit ;; + exit 0 ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in @@ -968,71 +881,109 @@ EOF PA8*) echo hppa2.0-unknown-linux-gnu ;; *) echo hppa-unknown-linux-gnu ;; esac - exit ;; - ppc64:Linux:*:*) - echo powerpc64-unknown-linux-gnu - exit ;; - ppc:Linux:*:*) - echo powerpc-unknown-linux-gnu - exit ;; + exit 0 ;; + parisc64:Linux:*:* | hppa64:Linux:*:*) + echo hppa64-unknown-linux-gnu + exit 0 ;; s390:Linux:*:* | s390x:Linux:*:*) echo ${UNAME_MACHINE}-ibm-linux - exit ;; + exit 0 ;; sh64*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit 0 ;; sh*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; + exit 0 ;; sparc:Linux:*:* | sparc64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; - tile*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; - vax:Linux:*:*) - echo ${UNAME_MACHINE}-dec-linux-gnu - exit ;; + exit 0 ;; x86_64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; - xtensa*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; + echo x86_64-unknown-linux-gnu + exit 0 ;; + i*86:Linux:*:*) + # The BFD linker knows what the default object file format is, so + # first see if it will tell us. cd to the root directory to prevent + # problems with other programs or directories called `ld' in the path. + # Set LC_ALL=C to ensure ld outputs messages in English. + ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \ + | sed -ne '/supported targets:/!d + s/[ ][ ]*/ /g + s/.*supported targets: *// + s/ .*// + p'` + case "$ld_supported_targets" in + elf32-i386) + TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu" + ;; + a.out-i386-linux) + echo "${UNAME_MACHINE}-pc-linux-gnuaout" + exit 0 ;; + coff-i386) + echo "${UNAME_MACHINE}-pc-linux-gnucoff" + exit 0 ;; + "") + # Either a pre-BFD a.out linker (linux-gnuoldld) or + # one that does not give us useful --help. + echo "${UNAME_MACHINE}-pc-linux-gnuoldld" + exit 0 ;; + esac + # Determine whether the default compiler is a.out or elf + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include + #ifdef __ELF__ + # ifdef __GLIBC__ + # if __GLIBC__ >= 2 + LIBC=gnu + # else + LIBC=gnulibc1 + # endif + # else + LIBC=gnulibc1 + # endif + #else + #ifdef __INTEL_COMPILER + LIBC=gnu + #else + LIBC=gnuaout + #endif + #endif +EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=` + test x"${LIBC}" != x && echo "${UNAME_MACHINE}-pc-linux-${LIBC}" && exit 0 + test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0 + ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. # earlier versions are messed up and put the nodename in both # sysname and nodename. echo i386-sequent-sysv4 - exit ;; + exit 0 ;; i*86:UNIX_SV:4.2MP:2.*) - # Unixware is an offshoot of SVR4, but it has its own version - # number series starting with 2... - # I am not positive that other SVR4 systems won't match this, + # Unixware is an offshoot of SVR4, but it has its own version + # number series starting with 2... + # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. - # Use sysv4.2uw... so that sysv4* matches it. + # Use sysv4.2uw... so that sysv4* matches it. echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} - exit ;; + exit 0 ;; i*86:OS/2:*:*) # If we were able to find `uname', then EMX Unix compatibility # is probably installed. echo ${UNAME_MACHINE}-pc-os2-emx - exit ;; + exit 0 ;; i*86:XTS-300:*:STOP) echo ${UNAME_MACHINE}-unknown-stop - exit ;; + exit 0 ;; i*86:atheos:*:*) echo ${UNAME_MACHINE}-unknown-atheos - exit ;; - i*86:syllable:*:*) - echo ${UNAME_MACHINE}-pc-syllable - exit ;; - i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) + exit 0 ;; + i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) echo i386-unknown-lynxos${UNAME_RELEASE} - exit ;; + exit 0 ;; i*86:*DOS:*:*) echo ${UNAME_MACHINE}-pc-msdosdjgpp - exit ;; + exit 0 ;; i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then @@ -1040,16 +991,15 @@ EOF else echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} fi - exit ;; - i*86:*:5:[678]*) - # UnixWare 7.x, OpenUNIX and OpenServer 6. + exit 0 ;; + i*86:*:5:[78]*) case `/bin/uname -X | grep "^Machine"` in *486*) UNAME_MACHINE=i486 ;; *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} - exit ;; + exit 0 ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' /dev/null 2>&1 ; then echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 fi - exit ;; + exit 0 ;; mini*:CTIX:SYS*5:*) # "miniframe" echo m68010-convergent-sysv - exit ;; + exit 0 ;; mc68k:UNIX:SYSTEM5:3.51m) echo m68k-convergent-sysv - exit ;; + exit 0 ;; M680?0:D-NIX:5.3:*) echo m68k-diab-dnix - exit ;; - M68*:*:R3V[5678]*:*) - test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; - 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) + exit 0 ;; + M68*:*:R3V[567]*:*) + test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;; + 3[34]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0) OS_REL='' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4.3${OS_REL}; exit; } + && echo i486-ncr-sysv4.3${OS_REL} && exit 0 /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; + && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4; exit; } ;; - NCR*:*:4.2:* | MPRAS*:*:4.2:*) - OS_REL='.3' - test -r /etc/.relid \ - && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4.3${OS_REL}; exit; } - /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } - /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && echo i486-ncr-sysv4 && exit 0 ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) echo m68k-unknown-lynxos${UNAME_RELEASE} - exit ;; + exit 0 ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 - exit ;; + exit 0 ;; TSUNAMI:LynxOS:2.*:*) echo sparc-unknown-lynxos${UNAME_RELEASE} - exit ;; + exit 0 ;; rs6000:LynxOS:2.*:*) echo rs6000-unknown-lynxos${UNAME_RELEASE} - exit ;; - PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) + exit 0 ;; + PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*) echo powerpc-unknown-lynxos${UNAME_RELEASE} - exit ;; + exit 0 ;; SM[BE]S:UNIX_SV:*:*) echo mips-dde-sysv${UNAME_RELEASE} - exit ;; + exit 0 ;; RM*:ReliantUNIX-*:*:*) echo mips-sni-sysv4 - exit ;; + exit 0 ;; RM*:SINIX-*:*:*) echo mips-sni-sysv4 - exit ;; + exit 0 ;; *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` @@ -1154,94 +1091,68 @@ EOF else echo ns32k-sni-sysv fi - exit ;; - PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort - # says - echo i586-unisys-sysv4 - exit ;; + exit 0 ;; + PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort + # says + echo i586-unisys-sysv4 + exit 0 ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes . # How about differentiating between stratus architectures? -djm echo hppa1.1-stratus-sysv4 - exit ;; + exit 0 ;; *:*:*:FTX*) # From seanf@swdc.stratus.com. echo i860-stratus-sysv4 - exit ;; - i*86:VOS:*:*) - # From Paul.Green@stratus.com. - echo ${UNAME_MACHINE}-stratus-vos - exit ;; + exit 0 ;; *:VOS:*:*) # From Paul.Green@stratus.com. echo hppa1.1-stratus-vos - exit ;; + exit 0 ;; mc68*:A/UX:*:*) echo m68k-apple-aux${UNAME_RELEASE} - exit ;; + exit 0 ;; news*:NEWS-OS:6*:*) echo mips-sony-newsos6 - exit ;; + exit 0 ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if [ -d /usr/nec ]; then - echo mips-nec-sysv${UNAME_RELEASE} + echo mips-nec-sysv${UNAME_RELEASE} else - echo mips-unknown-sysv${UNAME_RELEASE} + echo mips-unknown-sysv${UNAME_RELEASE} fi - exit ;; + exit 0 ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. echo powerpc-be-beos - exit ;; + exit 0 ;; BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. echo powerpc-apple-beos - exit ;; + exit 0 ;; BePC:BeOS:*:*) # BeOS running on Intel PC compatible. echo i586-pc-beos - exit ;; - BePC:Haiku:*:*) # Haiku running on Intel PC compatible. - echo i586-pc-haiku - exit ;; + exit 0 ;; SX-4:SUPER-UX:*:*) echo sx4-nec-superux${UNAME_RELEASE} - exit ;; + exit 0 ;; SX-5:SUPER-UX:*:*) echo sx5-nec-superux${UNAME_RELEASE} - exit ;; + exit 0 ;; SX-6:SUPER-UX:*:*) echo sx6-nec-superux${UNAME_RELEASE} - exit ;; - SX-7:SUPER-UX:*:*) - echo sx7-nec-superux${UNAME_RELEASE} - exit ;; - SX-8:SUPER-UX:*:*) - echo sx8-nec-superux${UNAME_RELEASE} - exit ;; - SX-8R:SUPER-UX:*:*) - echo sx8r-nec-superux${UNAME_RELEASE} - exit ;; + exit 0 ;; Power*:Rhapsody:*:*) echo powerpc-apple-rhapsody${UNAME_RELEASE} - exit ;; + exit 0 ;; *:Rhapsody:*:*) echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} - exit ;; + exit 0 ;; *:Darwin:*:*) - UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown - case $UNAME_PROCESSOR in - i386) - eval $set_cc_for_build - if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then - if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ - (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ - grep IS_64BIT_ARCH >/dev/null - then - UNAME_PROCESSOR="x86_64" - fi - fi ;; - unknown) UNAME_PROCESSOR=powerpc ;; + case `uname -p` in + *86) UNAME_PROCESSOR=i686 ;; + powerpc) UNAME_PROCESSOR=powerpc ;; esac echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} - exit ;; + exit 0 ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` if test "$UNAME_PROCESSOR" = "x86"; then @@ -1249,28 +1160,22 @@ EOF UNAME_MACHINE=pc fi echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} - exit ;; + exit 0 ;; *:QNX:*:4*) echo i386-pc-qnx - exit ;; - NEO-?:NONSTOP_KERNEL:*:*) - echo neo-tandem-nsk${UNAME_RELEASE} - exit ;; - NSE-?:NONSTOP_KERNEL:*:*) - echo nse-tandem-nsk${UNAME_RELEASE} - exit ;; - NSR-?:NONSTOP_KERNEL:*:*) + exit 0 ;; + NSR-[DGKLNPTVW]:NONSTOP_KERNEL:*:*) echo nsr-tandem-nsk${UNAME_RELEASE} - exit ;; + exit 0 ;; *:NonStop-UX:*:*) echo mips-compaq-nonstopux - exit ;; + exit 0 ;; BS2000:POSIX*:*:*) echo bs2000-siemens-sysv - exit ;; + exit 0 ;; DS/*:UNIX_System_V:*:*) echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} - exit ;; + exit 0 ;; *:Plan9:*:*) # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 @@ -1281,53 +1186,28 @@ EOF UNAME_MACHINE="$cputype" fi echo ${UNAME_MACHINE}-unknown-plan9 - exit ;; + exit 0 ;; *:TOPS-10:*:*) echo pdp10-unknown-tops10 - exit ;; + exit 0 ;; *:TENEX:*:*) echo pdp10-unknown-tenex - exit ;; + exit 0 ;; KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) echo pdp10-dec-tops20 - exit ;; + exit 0 ;; XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) echo pdp10-xkl-tops20 - exit ;; + exit 0 ;; *:TOPS-20:*:*) echo pdp10-unknown-tops20 - exit ;; + exit 0 ;; *:ITS:*:*) echo pdp10-unknown-its - exit ;; + exit 0 ;; SEI:*:*:SEIUX) - echo mips-sei-seiux${UNAME_RELEASE} - exit ;; - *:DragonFly:*:*) - echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` - exit ;; - *:*VMS:*:*) - UNAME_MACHINE=`(uname -p) 2>/dev/null` - case "${UNAME_MACHINE}" in - A*) echo alpha-dec-vms ; exit ;; - I*) echo ia64-dec-vms ; exit ;; - V*) echo vax-dec-vms ; exit ;; - esac ;; - *:XENIX:*:SysV) - echo i386-pc-xenix - exit ;; - i*86:skyos:*:*) - echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' - exit ;; - i*86:rdos:*:*) - echo ${UNAME_MACHINE}-pc-rdos - exit ;; - i*86:AROS:*:*) - echo ${UNAME_MACHINE}-pc-aros - exit ;; - x86_64:VMkernel:*:*) - echo ${UNAME_MACHINE}-unknown-esx - exit ;; + echo mips-sei-seiux${UNAME_RELEASE} + exit 0 ;; esac #echo '(No uname command or uname output not recognized.)' 1>&2 @@ -1350,16 +1230,16 @@ main () #include printf ("m68k-sony-newsos%s\n", #ifdef NEWSOS4 - "4" + "4" #else - "" + "" #endif - ); exit (0); + ); exit (0); #endif #endif #if defined (__arm) && defined (__acorn) && defined (__unix) - printf ("arm-acorn-riscix\n"); exit (0); + printf ("arm-acorn-riscix"); exit (0); #endif #if defined (hp300) && !defined (hpux) @@ -1448,12 +1328,11 @@ main () } EOF -$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` && - { echo "$SYSTEM_NAME"; exit; } +$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && $dummy && exit 0 # Apollos put the system type in the environment. -test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; } +test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; } # Convex versions that predate uname can use getsysinfo(1) @@ -1462,22 +1341,22 @@ then case `getsysinfo -f cpu_type` in c1*) echo c1-convex-bsd - exit ;; + exit 0 ;; c2*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi - exit ;; + exit 0 ;; c34*) echo c34-convex-bsd - exit ;; + exit 0 ;; c38*) echo c38-convex-bsd - exit ;; + exit 0 ;; c4*) echo c4-convex-bsd - exit ;; + exit 0 ;; esac fi @@ -1488,9 +1367,7 @@ This script, last modified $timestamp, has failed to recognize the operating system you are using. It is advised that you download the most up to date version of the config scripts from - http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD -and - http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD + ftp://ftp.gnu.org/pub/gnu/config/ If the version you run ($0) is already up to date, please send the following data and any information you think might be diff --git a/config/config.rpath b/config/config.rpath index c38b914d..c492a93b 100755 --- a/config/config.rpath +++ b/config/config.rpath @@ -2,7 +2,7 @@ # Output a system dependent set of variables, describing how to set the # run time search path of shared libraries in an executable. # -# Copyright 1996-2013 Free Software Foundation, Inc. +# Copyright 1996-2006 Free Software Foundation, Inc. # Taken from GNU libtool, 2001 # Originally by Gordon Matzigkeit , 1996 # @@ -25,7 +25,7 @@ # known workaround is to choose shorter directory names for the build # directory and/or the installation directory. -# All known linkers require a '.a' archive for static linking (except MSVC, +# All known linkers require a `.a' archive for static linking (except MSVC, # which needs '.lib'). libext=a shrext=.so @@ -47,7 +47,7 @@ for cc_temp in $CC""; do done cc_basename=`echo "$cc_temp" | sed -e 's%^.*/%%'` -# Code taken from libtool.m4's _LT_COMPILER_PIC. +# Code taken from libtool.m4's AC_LIBTOOL_PROG_COMPILER_PIC. wl= if test "$GCC" = yes; then @@ -57,7 +57,14 @@ else aix*) wl='-Wl,' ;; - mingw* | cygwin* | pw32* | os2* | cegcc*) + darwin*) + case $cc_basename in + xlc*) + wl='-Wl,' + ;; + esac + ;; + mingw* | pw32* | os2*) ;; hpux9* | hpux10* | hpux11*) wl='-Wl,' @@ -65,37 +72,24 @@ else irix5* | irix6* | nonstopux*) wl='-Wl,' ;; - linux* | k*bsd*-gnu | kopensolaris*-gnu) + newsos6) + ;; + linux*) case $cc_basename in - ecc*) + icc* | ecc*) wl='-Wl,' ;; - icc* | ifort*) - wl='-Wl,' - ;; - lf95*) - wl='-Wl,' - ;; - nagfor*) - wl='-Wl,-Wl,,' - ;; - pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*) + pgcc | pgf77 | pgf90) wl='-Wl,' ;; ccc*) wl='-Wl,' ;; - xl* | bgxl* | bgf* | mpixl*) - wl='-Wl,' - ;; como) wl='-lopt=' ;; *) case `$CC -V 2>&1 | sed 5q` in - *Sun\ F* | *Sun*Fortran*) - wl= - ;; *Sun\ C*) wl='-Wl,' ;; @@ -103,36 +97,22 @@ else ;; esac ;; - newsos6) - ;; - *nto* | *qnx*) - ;; osf3* | osf4* | osf5*) wl='-Wl,' ;; - rdos*) + sco3.2v5*) ;; solaris*) - case $cc_basename in - f77* | f90* | f95* | sunf77* | sunf90* | sunf95*) - wl='-Qoption ld ' - ;; - *) - wl='-Wl,' - ;; - esac + wl='-Wl,' ;; sunos4*) wl='-Qoption ld ' ;; - sysv4 | sysv4.2uw2* | sysv4.3*) + sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) wl='-Wl,' ;; sysv4*MP*) ;; - sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) - wl='-Wl,' - ;; unicos*) wl='-Wl,' ;; @@ -141,7 +121,7 @@ else esac fi -# Code taken from libtool.m4's _LT_LINKER_SHLIBS. +# Code taken from libtool.m4's AC_LIBTOOL_PROG_LD_SHLIBS. hardcode_libdir_flag_spec= hardcode_libdir_separator= @@ -149,7 +129,7 @@ hardcode_direct=no hardcode_minus_L=no case "$host_os" in - cygwin* | mingw* | pw32* | cegcc*) + cygwin* | mingw* | pw32*) # FIXME: the MSVC++ port hasn't been tested in a loooong time # When not using gcc, we currently assume that we are using # Microsoft Visual C++. @@ -175,21 +155,22 @@ if test "$with_gnu_ld" = yes; then # option of GNU ld is called -rpath, not --rpath. hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' case "$host_os" in - aix[3-9]*) + aix3* | aix4* | aix5*) # On AIX/PPC, the GNU linker is very broken if test "$host_cpu" != ia64; then ld_shlibs=no fi ;; amigaos*) - case "$host_cpu" in - powerpc) - ;; - m68k) - hardcode_libdir_flag_spec='-L$libdir' - hardcode_minus_L=yes - ;; - esac + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + # Samuel A. Falvo II reports + # that the semantics of dynamic libraries on AmigaOS, at least up + # to version 4, is to share data among multiple programs linked + # with the same dynamic library. Since this doesn't match the + # behavior of shared libraries on other platforms, we cannot use + # them. + ld_shlibs=no ;; beos*) if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then @@ -198,7 +179,7 @@ if test "$with_gnu_ld" = yes; then ld_shlibs=no fi ;; - cygwin* | mingw* | pw32* | cegcc*) + cygwin* | mingw* | pw32*) # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. hardcode_libdir_flag_spec='-L$libdir' @@ -208,13 +189,11 @@ if test "$with_gnu_ld" = yes; then ld_shlibs=no fi ;; - haiku*) - ;; - interix[3-9]*) + interix3*) hardcode_direct=no hardcode_libdir_flag_spec='${wl}-rpath,$libdir' ;; - gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu) + linux*) if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then : else @@ -272,7 +251,7 @@ else hardcode_direct=unsupported fi ;; - aix[4-9]*) + aix4* | aix5*) if test "$host_cpu" = ia64; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. @@ -282,7 +261,7 @@ else # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # need to do runtime linking. - case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*) + case $host_os in aix4.[23]|aix4.[23].*|aix5*) for ld_flag in $LDFLAGS; do if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then aix_use_runtimelinking=yes @@ -301,7 +280,7 @@ else strings "$collect2name" | grep resolve_lib_name >/dev/null then # We have reworked collect2 - : + hardcode_direct=yes else # We have old collect2 hardcode_direct=unsupported @@ -337,18 +316,14 @@ else fi ;; amigaos*) - case "$host_cpu" in - powerpc) - ;; - m68k) - hardcode_libdir_flag_spec='-L$libdir' - hardcode_minus_L=yes - ;; - esac + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + # see comment about different semantics on the GNU ld section + ld_shlibs=no ;; bsdi[45]*) ;; - cygwin* | mingw* | pw32* | cegcc*) + cygwin* | mingw* | pw32*) # When not using gcc, we currently assume that we are using # Microsoft Visual C++. # hardcode_libdir_flag_spec is actually meaningless, as there is @@ -358,15 +333,24 @@ else ;; darwin* | rhapsody*) hardcode_direct=no - if { case $cc_basename in ifort*) true;; *) test "$GCC" = yes;; esac; }; then + if test "$GCC" = yes ; then : else - ld_shlibs=no + case $cc_basename in + xlc*) + ;; + *) + ld_shlibs=no + ;; + esac fi ;; dgux*) hardcode_libdir_flag_spec='-L$libdir' ;; + freebsd1*) + ld_shlibs=no + ;; freebsd2.2*) hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes @@ -375,7 +359,7 @@ else hardcode_direct=yes hardcode_minus_L=yes ;; - freebsd* | dragonfly*) + freebsd* | kfreebsd*-gnu | dragonfly*) hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes ;; @@ -427,25 +411,19 @@ else hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator=: ;; - *nto* | *qnx*) - ;; openbsd*) - if test -f /usr/libexec/ld.so; then - hardcode_direct=yes - if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - hardcode_libdir_flag_spec='${wl}-rpath,$libdir' - else - case "$host_os" in - openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) - hardcode_libdir_flag_spec='-R$libdir' - ;; - *) - hardcode_libdir_flag_spec='${wl}-rpath,$libdir' - ;; - esac - fi + hardcode_direct=yes + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + hardcode_libdir_flag_spec='${wl}-rpath,$libdir' else - ld_shlibs=no + case "$host_os" in + openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) + hardcode_libdir_flag_spec='-R$libdir' + ;; + *) + hardcode_libdir_flag_spec='${wl}-rpath,$libdir' + ;; + esac fi ;; os2*) @@ -493,7 +471,7 @@ else ld_shlibs=yes fi ;; - sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*) + sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7*) ;; sysv5* | sco3.2v5* | sco5v6*) hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`' @@ -509,58 +487,34 @@ else fi # Check dynamic linker characteristics -# Code taken from libtool.m4's _LT_SYS_DYNAMIC_LINKER. -# Unlike libtool.m4, here we don't care about _all_ names of the library, but -# only about the one the linker finds when passed -lNAME. This is the last -# element of library_names_spec in libtool.m4, or possibly two of them if the -# linker has special search rules. -library_names_spec= # the last element of library_names_spec in libtool.m4 +# Code taken from libtool.m4's AC_LIBTOOL_SYS_DYNAMIC_LINKER. libname_spec='lib$name' case "$host_os" in aix3*) - library_names_spec='$libname.a' ;; - aix[4-9]*) - library_names_spec='$libname$shrext' + aix4* | aix5*) ;; amigaos*) - case "$host_cpu" in - powerpc*) - library_names_spec='$libname$shrext' ;; - m68k) - library_names_spec='$libname.a' ;; - esac ;; beos*) - library_names_spec='$libname$shrext' ;; bsdi[45]*) - library_names_spec='$libname$shrext' ;; - cygwin* | mingw* | pw32* | cegcc*) + cygwin* | mingw* | pw32*) shrext=.dll - library_names_spec='$libname.dll.a $libname.lib' ;; darwin* | rhapsody*) shrext=.dylib - library_names_spec='$libname$shrext' ;; dgux*) - library_names_spec='$libname$shrext' + ;; + freebsd1*) + ;; + kfreebsd*-gnu) ;; freebsd* | dragonfly*) - case "$host_os" in - freebsd[123]*) - library_names_spec='$libname$shrext$versuffix' ;; - *) - library_names_spec='$libname$shrext' ;; - esac ;; gnu*) - library_names_spec='$libname$shrext' - ;; - haiku*) - library_names_spec='$libname$shrext' ;; hpux9* | hpux10* | hpux11*) case $host_cpu in @@ -574,13 +528,10 @@ case "$host_os" in shrext=.sl ;; esac - library_names_spec='$libname$shrext' ;; - interix[3-9]*) - library_names_spec='$libname$shrext' + interix3*) ;; irix5* | irix6* | nonstopux*) - library_names_spec='$libname$shrext' case "$host_os" in irix5* | nonstopux*) libsuff= shlibsuff= @@ -597,62 +548,41 @@ case "$host_os" in ;; linux*oldld* | linux*aout* | linux*coff*) ;; - linux* | k*bsd*-gnu | kopensolaris*-gnu) - library_names_spec='$libname$shrext' + linux*) ;; knetbsd*-gnu) - library_names_spec='$libname$shrext' ;; netbsd*) - library_names_spec='$libname$shrext' ;; newsos6) - library_names_spec='$libname$shrext' ;; - *nto* | *qnx*) - library_names_spec='$libname$shrext' + nto-qnx*) ;; openbsd*) - library_names_spec='$libname$shrext$versuffix' ;; os2*) libname_spec='$name' shrext=.dll - library_names_spec='$libname.a' ;; osf3* | osf4* | osf5*) - library_names_spec='$libname$shrext' - ;; - rdos*) ;; solaris*) - library_names_spec='$libname$shrext' ;; sunos4*) - library_names_spec='$libname$shrext$versuffix' ;; sysv4 | sysv4.3*) - library_names_spec='$libname$shrext' ;; sysv4*MP*) - library_names_spec='$libname$shrext' ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) - library_names_spec='$libname$shrext' - ;; - tpf*) - library_names_spec='$libname$shrext' ;; uts4*) - library_names_spec='$libname$shrext' ;; esac sed_quote_subst='s/\(["`$\\]\)/\\\1/g' escaped_wl=`echo "X$wl" | sed -e 's/^X//' -e "$sed_quote_subst"` shlibext=`echo "$shrext" | sed -e 's,^\.,,'` -escaped_libname_spec=`echo "X$libname_spec" | sed -e 's/^X//' -e "$sed_quote_subst"` -escaped_library_names_spec=`echo "X$library_names_spec" | sed -e 's/^X//' -e "$sed_quote_subst"` escaped_hardcode_libdir_flag_spec=`echo "X$hardcode_libdir_flag_spec" | sed -e 's/^X//' -e "$sed_quote_subst"` LC_ALL=C sed -e 's/^\([a-zA-Z0-9_]*\)=/acl_cv_\1=/' <. -# +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. + # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. - # Please send patches to . Submit a context -# diff and a properly formatted GNU ChangeLog entry. +# diff and a properly formatted ChangeLog entry. # # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. # If it is invalid, we print an error message on stderr and exit with code 1. # Otherwise, we print the canonical config type on stdout and succeed. -# You can get the latest version of this script from: -# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD - # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases # that are meaningful with *any* GNU software. @@ -73,8 +70,7 @@ Report bugs and patches to ." version="\ GNU config.sub ($timestamp) -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, -2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO @@ -87,11 +83,11 @@ Try \`$me --help' for more information." while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) - echo "$timestamp" ; exit ;; + echo "$timestamp" ; exit 0 ;; --version | -v ) - echo "$version" ; exit ;; + echo "$version" ; exit 0 ;; --help | --h* | -h ) - echo "$usage"; exit ;; + echo "$usage"; exit 0 ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. @@ -103,7 +99,7 @@ while test $# -gt 0 ; do *local*) # First pass through any local machine types. echo $1 - exit ;; + exit 0;; * ) break ;; @@ -122,18 +118,10 @@ esac # Here we must recognize all the valid KERNEL-OS combinations. maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in - nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ - linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ - knetbsd*-gnu* | netbsd*-gnu* | \ - kopensolaris*-gnu* | \ - storm-chaos* | os2-emx* | rtmk-nova*) + nto-qnx* | linux-gnu* | kfreebsd*-gnu* | netbsd*-gnu* | storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; - android-linux) - os=-linux-android - basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown - ;; *) basic_machine=`echo $1 | sed 's/-[^-]*$//'` if [ $basic_machine != $1 ] @@ -156,13 +144,10 @@ case $os in -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ - -apple | -axis | -knuth | -cray | -microblaze) + -apple | -axis) os= basic_machine=$1 ;; - -bluegene*) - os=-cnk - ;; -sim | -cisco | -oki | -wec | -winbond) os= basic_machine=$1 @@ -177,17 +162,13 @@ case $os in os=-chorusos basic_machine=$1 ;; - -chorusrdb) - os=-chorusrdb + -chorusrdb) + os=-chorusrdb basic_machine=$1 - ;; + ;; -hiux*) os=-hiuxwe2 ;; - -sco6) - os=-sco5v6 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; -sco5) os=-sco3.2v5 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` @@ -204,10 +185,6 @@ case $os in # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; - -sco5v6*) - # Don't forget version if it is 3.2v4 or newer. - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; -sco*) os=-sco3.2v2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` @@ -225,12 +202,6 @@ case $os in -isc*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; - -lynx*178) - os=-lynxos178 - ;; - -lynx*5) - os=-lynxos5 - ;; -lynx*) os=-lynxos ;; @@ -255,103 +226,55 @@ case $basic_machine in # Some are omitted here because they have special meanings below. 1750a | 580 \ | a29k \ - | aarch64 | aarch64_be \ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ - | am33_2.0 \ - | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \ - | be32 | be64 \ - | bfin \ + | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \ | c4x | clipper \ | d10v | d30v | dlx | dsp16xx \ - | epiphany \ - | fido | fr30 | frv \ + | fr30 | frv \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ - | hexagon \ | i370 | i860 | i960 | ia64 \ - | ip2k | iq2000 \ - | le32 | le64 \ - | lm32 \ - | m32c | m32r | m32rle | m68000 | m68k | m88k \ - | maxq | mb | microblaze | mcore | mep | metag \ + | ip2k \ + | m32r | m68000 | m68k | m88k | mcore \ | mips | mipsbe | mipseb | mipsel | mipsle \ | mips16 \ | mips64 | mips64el \ - | mips64octeon | mips64octeonel \ - | mips64orion | mips64orionel \ - | mips64r5900 | mips64r5900el \ | mips64vr | mips64vrel \ + | mips64orion | mips64orionel \ | mips64vr4100 | mips64vr4100el \ | mips64vr4300 | mips64vr4300el \ | mips64vr5000 | mips64vr5000el \ - | mips64vr5900 | mips64vr5900el \ | mipsisa32 | mipsisa32el \ | mipsisa32r2 | mipsisa32r2el \ | mipsisa64 | mipsisa64el \ - | mipsisa64r2 | mipsisa64r2el \ | mipsisa64sb1 | mipsisa64sb1el \ | mipsisa64sr71k | mipsisa64sr71kel \ | mipstx39 | mipstx39el \ | mn10200 | mn10300 \ - | moxie \ - | mt \ | msp430 \ - | nds32 | nds32le | nds32be \ - | nios | nios2 \ | ns16k | ns32k \ - | open8 \ - | or32 \ + | openrisc | or32 \ | pdp10 | pdp11 | pj | pjl \ - | powerpc | powerpc64 | powerpc64le | powerpcle \ + | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ | pyramid \ - | rl78 | rx \ - | score \ - | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ + | sh | sh[1234] | sh[23]e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \ | sh64 | sh64le \ - | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ - | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ - | spu \ - | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ - | ubicom32 \ - | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ + | sparc | sparc64 | sparc86x | sparclet | sparclite | sparcv9 | sparcv9b \ + | strongarm \ + | tahoe | thumb | tic4x | tic80 | tron \ + | v850 | v850e \ | we32k \ - | x86 | xc16x | xstormy16 | xtensa \ - | z8k | z80) + | x86 | xscale | xstormy16 | xtensa \ + | z8k) basic_machine=$basic_machine-unknown ;; - c54x) - basic_machine=tic54x-unknown - ;; - c55x) - basic_machine=tic55x-unknown - ;; - c6x) - basic_machine=tic6x-unknown - ;; - m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | picochip) + m6811 | m68hc11 | m6812 | m68hc12) + # Motorola 68HC11/12. basic_machine=$basic_machine-unknown os=-none ;; m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) ;; - ms1) - basic_machine=mt-unknown - ;; - - strongarm | thumb | xscale) - basic_machine=arm-unknown - ;; - xgate) - basic_machine=$basic_machine-unknown - os=-none - ;; - xscaleeb) - basic_machine=armeb-unknown - ;; - - xscaleel) - basic_machine=armel-unknown - ;; # We use `pc' rather than `unknown' # because (1) that's what they normally are, and @@ -367,80 +290,58 @@ case $basic_machine in # Recognize the basic CPU types with company name. 580-* \ | a29k-* \ - | aarch64-* | aarch64_be-* \ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ - | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ + | alphapca5[67]-* | alpha64pca5[67]-* | amd64-* | arc-* \ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ - | avr-* | avr32-* \ - | be32-* | be64-* \ - | bfin-* | bs2000-* \ - | c[123]* | c30-* | [cjt]90-* | c4x-* \ - | clipper-* | craynv-* | cydra-* \ + | avr-* \ + | bs2000-* \ + | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \ + | clipper-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ | elxsi-* \ - | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ + | f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \ | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ - | hexagon-* \ | i*86-* | i860-* | i960-* | ia64-* \ - | ip2k-* | iq2000-* \ - | le32-* | le64-* \ - | lm32-* \ - | m32c-* | m32r-* | m32rle-* \ + | ip2k-* \ + | m32r-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ - | m88110-* | m88k-* | maxq-* | mcore-* | metag-* | microblaze-* \ + | m88110-* | m88k-* | mcore-* \ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ | mips16-* \ | mips64-* | mips64el-* \ - | mips64octeon-* | mips64octeonel-* \ - | mips64orion-* | mips64orionel-* \ - | mips64r5900-* | mips64r5900el-* \ | mips64vr-* | mips64vrel-* \ + | mips64orion-* | mips64orionel-* \ | mips64vr4100-* | mips64vr4100el-* \ | mips64vr4300-* | mips64vr4300el-* \ | mips64vr5000-* | mips64vr5000el-* \ - | mips64vr5900-* | mips64vr5900el-* \ | mipsisa32-* | mipsisa32el-* \ | mipsisa32r2-* | mipsisa32r2el-* \ | mipsisa64-* | mipsisa64el-* \ - | mipsisa64r2-* | mipsisa64r2el-* \ | mipsisa64sb1-* | mipsisa64sb1el-* \ | mipsisa64sr71k-* | mipsisa64sr71kel-* \ | mipstx39-* | mipstx39el-* \ - | mmix-* \ - | mt-* \ | msp430-* \ - | nds32-* | nds32le-* | nds32be-* \ - | nios-* | nios2-* \ - | none-* | np1-* | ns16k-* | ns32k-* \ - | open8-* \ + | none-* | np1-* | nv1-* | ns16k-* | ns32k-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ - | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ + | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ | pyramid-* \ - | rl78-* | romp-* | rs6000-* | rx-* \ - | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ + | romp-* | rs6000-* \ + | sh-* | sh[1234]-* | sh[23]e-* | sh[34]eb-* | shbe-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ - | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ - | sparclite-* \ - | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \ - | tahoe-* \ + | sparc-* | sparc64-* | sparc86x-* | sparclet-* | sparclite-* \ + | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \ + | tahoe-* | thumb-* \ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ - | tile*-* \ | tron-* \ - | ubicom32-* \ - | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ - | vax-* \ + | v850-* | v850e-* | vax-* \ | we32k-* \ - | x86-* | x86_64-* | xc16x-* | xps100-* \ - | xstormy16-* | xtensa*-* \ + | x86-* | x86_64-* | xps100-* | xscale-* | xstormy16-* \ + | xtensa-* \ | ymp-* \ - | z8k-* | z80-*) - ;; - # Recognize the basic CPU types without company name, with glob match. - xtensa*) - basic_machine=$basic_machine-unknown + | z8k-*) ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. @@ -458,9 +359,6 @@ case $basic_machine in basic_machine=a29k-amd os=-udi ;; - abacus) - basic_machine=abacus-unknown - ;; adobe68k) basic_machine=m68010-adobe os=-scout @@ -478,9 +376,6 @@ case $basic_machine in amd64) basic_machine=x86_64-pc ;; - amd64-*) - basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; amdahl) basic_machine=580-amdahl os=-sysv @@ -504,10 +399,6 @@ case $basic_machine in basic_machine=m68k-apollo os=-bsd ;; - aros) - basic_machine=i386-pc - os=-aros - ;; aux) basic_machine=m68k-apple os=-aux @@ -516,35 +407,10 @@ case $basic_machine in basic_machine=ns32k-sequent os=-dynix ;; - blackfin) - basic_machine=bfin-unknown - os=-linux - ;; - blackfin-*) - basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` - os=-linux - ;; - bluegene*) - basic_machine=powerpc-ibm - os=-cnk - ;; - c54x-*) - basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - c55x-*) - basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - c6x-*) - basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; c90) basic_machine=c90-cray os=-unicos ;; - cegcc) - basic_machine=arm-unknown - os=-cegcc - ;; convex-c1) basic_machine=c1-convex os=-bsd @@ -569,27 +435,12 @@ case $basic_machine in basic_machine=j90-cray os=-unicos ;; - craynv) - basic_machine=craynv-cray - os=-unicosmp - ;; - cr16 | cr16-*) - basic_machine=cr16-unknown - os=-elf - ;; crds | unos) basic_machine=m68k-crds ;; - crisv32 | crisv32-* | etraxfs*) - basic_machine=crisv32-axis - ;; cris | cris-* | etrax*) basic_machine=cris-axis ;; - crx) - basic_machine=crx-unknown - os=-elf - ;; da30 | da30-*) basic_machine=m68k-da30 ;; @@ -612,14 +463,6 @@ case $basic_machine in basic_machine=m88k-motorola os=-sysv3 ;; - dicos) - basic_machine=i686-pc - os=-dicos - ;; - djgpp) - basic_machine=i586-pc - os=-msdosdjgpp - ;; dpx20 | dpx20-*) basic_machine=rs6000-bull os=-bosx @@ -731,6 +574,7 @@ case $basic_machine in i370-ibm* | ibm*) basic_machine=i370-ibm ;; +# I'm not sure what "Sysv32" means. Should this be sysv3.2? i*86v32) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv32 @@ -769,14 +613,6 @@ case $basic_machine in basic_machine=m68k-isi os=-sysv ;; - m68knommu) - basic_machine=m68k-unknown - os=-linux - ;; - m68knommu-*) - basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` - os=-linux - ;; m88k-omron*) basic_machine=m88k-omron ;; @@ -788,17 +624,10 @@ case $basic_machine in basic_machine=ns32k-utek os=-sysv ;; - microblaze) - basic_machine=microblaze-xilinx - ;; mingw32) basic_machine=i386-pc os=-mingw32 ;; - mingw32ce) - basic_machine=arm-unknown - os=-mingw32ce - ;; miniframe) basic_machine=m68000-convergent ;; @@ -812,6 +641,10 @@ case $basic_machine in mips3*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown ;; + mmix*) + basic_machine=mmix-knuth + os=-mmixware + ;; monitor) basic_machine=m68k-rom68k os=-coff @@ -824,21 +657,10 @@ case $basic_machine in basic_machine=i386-pc os=-msdos ;; - ms1-*) - basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` - ;; - msys) - basic_machine=i386-pc - os=-msys - ;; mvs) basic_machine=i370-ibm os=-mvs ;; - nacl) - basic_machine=le32-unknown - os=-nacl - ;; ncr3000) basic_machine=i486-ncr os=-sysv4 @@ -903,11 +725,9 @@ case $basic_machine in np1) basic_machine=np1-gould ;; - neo-tandem) - basic_machine=neo-tandem - ;; - nse-tandem) - basic_machine=nse-tandem + nv1) + basic_machine=nv1-cray + os=-unicosmp ;; nsr-tandem) basic_machine=nsr-tandem @@ -916,12 +736,9 @@ case $basic_machine in basic_machine=hppa1.1-oki os=-proelf ;; - openrisc | openrisc-*) + or32 | or32-*) basic_machine=or32-unknown - ;; - os400) - basic_machine=powerpc-ibm - os=-os400 + os=-coff ;; OSE68000 | ose68000) basic_machine=m68000-ericsson @@ -939,14 +756,6 @@ case $basic_machine in basic_machine=i860-intel os=-osf ;; - parisc) - basic_machine=hppa-unknown - os=-linux - ;; - parisc-*) - basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` - os=-linux - ;; pbd) basic_machine=sparc-tti ;; @@ -956,12 +765,6 @@ case $basic_machine in pc532 | pc532-*) basic_machine=ns32k-pc532 ;; - pc98) - basic_machine=i386-pc - ;; - pc98-*) - basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; pentium | p5 | k5 | k6 | nexgen | viac3) basic_machine=i586-pc ;; @@ -991,10 +794,9 @@ case $basic_machine in ;; power) basic_machine=power-ibm ;; - ppc | ppcbe) basic_machine=powerpc-unknown + ppc) basic_machine=powerpc-unknown ;; - ppc-* | ppcbe-*) - basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` + ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppcle | powerpclittle | ppc-le | powerpc-little) basic_machine=powerpcle-unknown @@ -1019,10 +821,6 @@ case $basic_machine in basic_machine=i586-unknown os=-pw32 ;; - rdos) - basic_machine=i386-pc - os=-rdos - ;; rom68k) basic_machine=m68k-rom68k os=-coff @@ -1049,10 +847,6 @@ case $basic_machine in sb1el) basic_machine=mipsisa64sb1el-unknown ;; - sde) - basic_machine=mipsisa32-sde - os=-elf - ;; sei) basic_machine=mips-sei os=-seiux @@ -1064,9 +858,6 @@ case $basic_machine in basic_machine=sh-hitachi os=-hms ;; - sh5el) - basic_machine=sh5le-unknown - ;; sh64) basic_machine=sh64-unknown ;; @@ -1088,9 +879,6 @@ case $basic_machine in basic_machine=i860-stratus os=-sysv4 ;; - strongarm-* | thumb-*) - basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; sun2) basic_machine=m68000-sun ;; @@ -1147,9 +935,17 @@ case $basic_machine in basic_machine=t90-cray os=-unicos ;; - tile*) - basic_machine=$basic_machine-unknown - os=-linux-gnu + tic54x | c54x*) + basic_machine=tic54x-unknown + os=-coff + ;; + tic55x | c55x*) + basic_machine=tic55x-unknown + os=-coff + ;; + tic6x | c6x*) + basic_machine=tic6x-unknown + os=-coff ;; tx39) basic_machine=mipstx39-unknown @@ -1164,10 +960,6 @@ case $basic_machine in tower | tower-32) basic_machine=m68k-ncr ;; - tpf) - basic_machine=s390x-ibm - os=-tpf - ;; udi29k) basic_machine=a29k-amd os=-udi @@ -1211,16 +1003,9 @@ case $basic_machine in basic_machine=hppa1.1-winbond os=-proelf ;; - xbox) - basic_machine=i686-pc - os=-mingw32 - ;; xps | xps100) basic_machine=xps100-honeywell ;; - xscale-* | xscalee[bl]-*) - basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'` - ;; ymp) basic_machine=ymp-cray os=-unicos @@ -1229,10 +1014,6 @@ case $basic_machine in basic_machine=z8k-unknown os=-sim ;; - z80-*-coff) - basic_machine=z80-unknown - os=-sim - ;; none) basic_machine=none-none os=-none @@ -1252,9 +1033,6 @@ case $basic_machine in romp) basic_machine=romp-ibm ;; - mmix) - basic_machine=mmix-knuth - ;; rs6000) basic_machine=rs6000-ibm ;; @@ -1271,10 +1049,13 @@ case $basic_machine in we32k) basic_machine=we32k-att ;; - sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) + sh3 | sh4 | sh[34]eb | sh[1234]le | sh[23]ele) basic_machine=sh-unknown ;; - sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) + sh64) + basic_machine=sh64-unknown + ;; + sparc | sparcv9 | sparcv9b) basic_machine=sparc-sun ;; cydra) @@ -1318,12 +1099,9 @@ esac if [ x"$os" != x"" ] then case $os in - # First match some system type aliases - # that might get confused with valid system types. + # First match some system type aliases + # that might get confused with valid system types. # -solaris* is a basic system type, with this one exception. - -auroraux) - os=-auroraux - ;; -solaris1 | -solaris1.*) os=`echo $os | sed -e 's|solaris1|sunos4|'` ;; @@ -1344,31 +1122,25 @@ case $os in # Each alternative MUST END IN A *, to match a version number. # -sysv* is not here because it comes later, after sysvr4. -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ - | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ - | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ - | -sym* | -kopensolaris* \ + | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ - | -aos* | -aros* \ + | -aos* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ - | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ - | -openbsd* | -solidbsd* \ - | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ - | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ + | -hiux* | -386bsd* | -netbsd* | -openbsd* | -kfreebsd* | -freebsd* | -riscix* \ + | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ - | -chorusos* | -chorusrdb* | -cegcc* \ - | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ - | -mingw32* | -linux-gnu* | -linux-android* \ - | -linux-newlib* | -linux-uclibc* \ - | -uxpv* | -beos* | -mpeix* | -udk* \ + | -chorusos* | -chorusrdb* \ + | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ + | -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ - | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ - | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*) + | -powermax* | -dnix* | -nx6 | -nx7 | -sei*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) @@ -1386,15 +1158,12 @@ case $os in os=`echo $os | sed -e 's|nto|nto-qnx|'` ;; -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ - | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ + | -windows* | -osx | -abug | -netware* | -os9* | -beos* \ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) ;; -mac*) os=`echo $os | sed -e 's|mac|macos|'` ;; - -linux-dietlibc) - os=-linux-dietlibc - ;; -linux*) os=`echo $os | sed -e 's|linux|linux-gnu|'` ;; @@ -1407,9 +1176,6 @@ case $os in -opened*) os=-openedition ;; - -os400*) - os=-os400 - ;; -wince*) os=-wince ;; @@ -1431,9 +1197,6 @@ case $os in -atheos*) os=-atheos ;; - -syllable*) - os=-syllable - ;; -386bsd) os=-bsd ;; @@ -1456,9 +1219,6 @@ case $os in -sinix*) os=-sysv4 ;; - -tpf*) - os=-tpf - ;; -triton*) os=-sysv3 ;; @@ -1495,14 +1255,6 @@ case $os in -kaos*) os=-kaos ;; - -zvmoe) - os=-zvmoe - ;; - -dicos*) - os=-dicos - ;; - -nacl*) - ;; -none) ;; *) @@ -1525,12 +1277,6 @@ else # system, and we'll never get to this point. case $basic_machine in - score-*) - os=-elf - ;; - spu-*) - os=-elf - ;; *-acorn) os=-riscix1.2 ;; @@ -1540,21 +1286,9 @@ case $basic_machine in arm*-semi) os=-aout ;; - c4x-* | tic4x-*) - os=-coff - ;; - hexagon-*) - os=-elf - ;; - tic54x-*) - os=-coff - ;; - tic55x-*) - os=-coff - ;; - tic6x-*) - os=-coff - ;; + c4x-* | tic4x-*) + os=-coff + ;; # This must come before the *-dec entry. pdp10-*) os=-tops20 @@ -1573,13 +1307,13 @@ case $basic_machine in ;; m68000-sun) os=-sunos3 + # This also exists in the configure program, but was not the + # default. + # os=-sunos4 ;; m68*-cisco) os=-aout ;; - mep-*) - os=-elf - ;; mips*-cisco) os=-elf ;; @@ -1598,15 +1332,9 @@ case $basic_machine in *-be) os=-beos ;; - *-haiku) - os=-haiku - ;; *-ibm) os=-aix ;; - *-knuth) - os=-mmixware - ;; *-wec) os=-proelf ;; @@ -1709,7 +1437,7 @@ case $basic_machine in -sunos*) vendor=sun ;; - -cnk*|-aix*) + -aix*) vendor=ibm ;; -beos*) @@ -1739,15 +1467,9 @@ case $basic_machine in -mvs* | -opened*) vendor=ibm ;; - -os400*) - vendor=ibm - ;; -ptx*) vendor=sequent ;; - -tpf*) - vendor=ibm - ;; -vxsim* | -vxworks* | -windiss*) vendor=wrs ;; @@ -1772,7 +1494,7 @@ case $basic_machine in esac echo $basic_machine$os -exit +exit 0 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) diff --git a/config/ltmain.sh b/config/ltmain.sh new file mode 100755 index 00000000..a85567fc --- /dev/null +++ b/config/ltmain.sh @@ -0,0 +1,6919 @@ +# ltmain.sh - Provide generalized library-building support services. +# NOTE: Changing this file will not affect anything until you rerun configure. +# +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005 +# Free Software Foundation, Inc. +# Originally by Gordon Matzigkeit , 1996 +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +basename="s,^.*/,,g" + +# 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" + +# The name of this program: +progname=`echo "$progpath" | $SED $basename` +modename="$progname" + +# Global variables: +EXIT_SUCCESS=0 +EXIT_FAILURE=1 + +PROGRAM=ltmain.sh +PACKAGE=libtool +VERSION=1.5.22 +TIMESTAMP=" (1.1220.2.365 2005/12/18 22:14:06)" + +# See if we are running on zsh, and set the options which allow our +# commands through without removal of \ escapes. +if test -n "${ZSH_VERSION+set}" ; then + setopt NO_GLOB_SUBST +fi + +# Check that we have a working $echo. +if test "X$1" = X--no-reexec; then + # Discard the --no-reexec flag, and continue. + shift +elif test "X$1" = X--fallback-echo; then + # Avoid inline document here, it may be left over + : +elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then + # Yippee, $echo works! + : +else + # Restart under the correct shell, and then maybe $echo will work. + exec $SHELL "$progpath" --no-reexec ${1+"$@"} +fi + +if test "X$1" = X--fallback-echo; then + # used as fallback echo + shift + cat <&2 + $echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2 + exit $EXIT_FAILURE +fi + +# Global variables. +mode=$default_mode +nonopt= +prev= +prevopt= +run= +show="$echo" +show_help= +execute_dlfiles= +duplicate_deps=no +preserve_args= +lo2o="s/\\.lo\$/.${objext}/" +o2lo="s/\\.${objext}\$/.lo/" + +##################################### +# Shell function definitions: +# This seems to be the best place for them + +# 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 "$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" || { + $echo "cannot create temporary directory \`$my_tmpdir'" 1>&2 + exit $EXIT_FAILURE + } + fi + + $echo "X$my_tmpdir" | $Xsed +} + + +# 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. +func_win32_libid () +{ + 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 eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | \ + $EGREP -e 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then + win32_nmres=`eval $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_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 () +{ + # FreeBSD-specific: where we install compilers with non-standard names + tag_compilers_CC="*cc cc* *gcc gcc*" + tag_compilers_CXX="*c++ c++* *g++ g++*" + base_compiler=`set -- "$@"; echo $1` + + # If $tagname isn't set, then try to infer if the default "CC" tag applies + if test -z "$tagname"; then + for zp in $tag_compilers_CC; do + case $base_compiler in + $zp) tagname="CC"; break;; + esac + done + fi + + if test -n "$available_tags" && test -z "$tagname"; then + CC_quoted= + for arg in $CC; do + case $arg in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + arg="\"$arg\"" + ;; + esac + CC_quoted="$CC_quoted $arg" + done + 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 "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*) ;; + # 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. + case $arg in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + arg="\"$arg\"" + ;; + esac + CC_quoted="$CC_quoted $arg" + done + case "$@ " in + " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*) + # 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 + + # FreeBSD-specific: try compilers based on inferred tag + if test -z "$tagname"; then + eval "tag_compilers=\$tag_compilers_${z}" + if test -n "$tag_compilers"; then + for zp in $tag_compilers; do + case $base_compiler in + $zp) tagname=$z; break;; + esac + done + if test -n "$tagname"; then + break + fi + fi + fi + 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 + $echo "$modename: unable to infer tagged configuration" + $echo "$modename: specify a tag with \`--tag'" 1>&2 + exit $EXIT_FAILURE +# else +# $echo "$modename: using $tagname tagged configuration" + fi + ;; + esac + fi +} + + +# func_extract_an_archive dir oldlib +func_extract_an_archive () +{ + f_ex_an_ar_dir="$1"; shift + f_ex_an_ar_oldlib="$1" + + $show "(cd $f_ex_an_ar_dir && $AR x $f_ex_an_ar_oldlib)" + $run eval "(cd \$f_ex_an_ar_dir && $AR x \$f_ex_an_ar_oldlib)" || exit $? + if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then + : + else + $echo "$modename: ERROR: object name conflicts: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 1>&2 + exit $EXIT_FAILURE + fi +} + +# func_extract_archives gentop oldlib ... +func_extract_archives () +{ + my_gentop="$1"; shift + my_oldlibs=${1+"$@"} + my_oldobjs="" + my_xlib="" + my_xabs="" + my_xdir="" + my_status="" + + $show "${rm}r $my_gentop" + $run ${rm}r "$my_gentop" + $show "$mkdir $my_gentop" + $run $mkdir "$my_gentop" + my_status=$? + if test "$my_status" -ne 0 && test ! -d "$my_gentop"; then + exit $my_status + fi + + 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 + my_xlib=`$echo "X$my_xlib" | $Xsed -e 's%^.*/%%'` + my_xdir="$my_gentop/$my_xlib" + + $show "${rm}r $my_xdir" + $run ${rm}r "$my_xdir" + $show "$mkdir $my_xdir" + $run $mkdir "$my_xdir" + exit_status=$? + if test "$exit_status" -ne 0 && test ! -d "$my_xdir"; then + exit $exit_status + fi + case $host in + *-darwin*) + $show "Extracting $my_xabs" + # Do not bother doing anything if just a dry run + if test -z "$run"; then + darwin_orig_dir=`pwd` + cd $my_xdir || exit $? + darwin_archive=$my_xabs + darwin_curdir=`pwd` + darwin_base_archive=`$echo "X$darwin_archive" | $Xsed -e 's%^.*/%%'` + darwin_arches=`lipo -info "$darwin_archive" 2>/dev/null | $EGREP Architectures 2>/dev/null` + if test -n "$darwin_arches"; then + darwin_arches=`echo "$darwin_arches" | $SED -e 's/.*are://'` + darwin_arch= + $show "$darwin_base_archive has multiple architectures $darwin_arches" + for darwin_arch in $darwin_arches ; do + 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 have a bunch of thin objects, gotta fatten them up :) + darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print| xargs basename | sort -u | $NL2SP` + 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}r unfat-$$ + cd "$darwin_orig_dir" + else + cd "$darwin_orig_dir" + func_extract_an_archive "$my_xdir" "$my_xabs" + fi # $darwin_arches + fi # $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" +} +# End of Shell function definitions +##################################### + +# Darwin sucks +eval std_shrext=\"$shrext_cmds\" + +disable_libs=no + +# Parse our command line options once, thoroughly. +while test "$#" -gt 0 +do + arg="$1" + shift + + case $arg in + -*=*) optarg=`$echo "X$arg" | $Xsed -e 's/[-_a-zA-Z0-9]*=//'` ;; + *) optarg= ;; + esac + + # If the previous option needs an argument, assign it. + if test -n "$prev"; then + case $prev in + execute_dlfiles) + execute_dlfiles="$execute_dlfiles $arg" + ;; + tag) + tagname="$arg" + preserve_args="${preserve_args}=$arg" + + # Check whether tagname contains only valid characters + case $tagname in + *[!-_A-Za-z0-9,/]*) + $echo "$progname: invalid tag name: $tagname" 1>&2 + exit $EXIT_FAILURE + ;; + esac + + case $tagname in + CC) + # Don't test for the "default" C tag, as we know, it's there, but + # not specially marked. + ;; + *) + if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "$progpath" > /dev/null; then + taglist="$taglist $tagname" + # Evaluate the configuration. + eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$tagname'$/,/^# ### END LIBTOOL TAG CONFIG: '$tagname'$/p' < $progpath`" + else + $echo "$progname: ignoring unknown tag $tagname" 1>&2 + fi + ;; + esac + ;; + *) + eval "$prev=\$arg" + ;; + esac + + prev= + prevopt= + continue + fi + + # Have we seen a non-optional argument yet? + case $arg in + --help) + show_help=yes + ;; + + --version) + $echo "$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP" + $echo + $echo "Copyright (C) 2005 Free Software Foundation, Inc." + $echo "This is free software; see the source for copying conditions. There is NO" + $echo "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + exit $? + ;; + + --config) + ${SED} -e '1,/^# ### BEGIN LIBTOOL CONFIG/d' -e '/^# ### END LIBTOOL CONFIG/,$d' $progpath + # Now print the configurations for the tags. + for tagname in $taglist; do + ${SED} -n -e "/^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$/,/^# ### END LIBTOOL TAG CONFIG: $tagname$/p" < "$progpath" + done + exit $? + ;; + + --debug) + $echo "$progname: enabling shell trace mode" + set -x + preserve_args="$preserve_args $arg" + ;; + + --dry-run | -n) + run=: + ;; + + --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 $? + ;; + + --finish) mode="finish" ;; + + --mode) prevopt="--mode" prev=mode ;; + --mode=*) mode="$optarg" ;; + + --preserve-dup-deps) duplicate_deps="yes" ;; + + --quiet | --silent) + show=: + preserve_args="$preserve_args $arg" + ;; + + --tag) + prevopt="--tag" + prev=tag + preserve_args="$preserve_args --tag" + ;; + --tag=*) + set tag "$optarg" ${1+"$@"} + shift + prev=tag + preserve_args="$preserve_args --tag" + ;; + + -dlopen) + prevopt="-dlopen" + prev=execute_dlfiles + ;; + + -*) + $echo "$modename: unrecognized option \`$arg'" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + ;; + + *) + nonopt="$arg" + break + ;; + esac +done + +if test -n "$prevopt"; then + $echo "$modename: option \`$prevopt' requires an argument" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE +fi + +case $disable_libs in +no) + ;; +shared) + build_libtool_libs=no + build_old_libs=yes + ;; +static) + build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` + ;; +esac + +# 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= + +if test -z "$show_help"; then + + # Infer the operation mode. + if test -z "$mode"; then + $echo "*** Warning: inferring the mode of operation is deprecated." 1>&2 + $echo "*** Future versions of Libtool will require --mode=MODE be specified." 1>&2 + case $nonopt in + *cc | cc* | *++ | gcc* | *-gcc* | g++* | xlc*) + mode=link + for arg + do + case $arg in + -c) + mode=compile + break + ;; + esac + done + ;; + *db | *dbx | *strace | *truss) + mode=execute + ;; + *install*|cp|mv) + mode=install + ;; + *rm) + mode=uninstall + ;; + *) + # If we have no mode, but dlfiles were specified, then do execute mode. + test -n "$execute_dlfiles" && mode=execute + + # Just use the default operation mode. + if test -z "$mode"; then + if test -n "$nonopt"; then + $echo "$modename: warning: cannot infer operation mode from \`$nonopt'" 1>&2 + else + $echo "$modename: warning: cannot infer operation mode without MODE-ARGS" 1>&2 + fi + fi + ;; + esac + fi + + # Only execute mode is allowed to have -dlopen flags. + if test -n "$execute_dlfiles" && test "$mode" != execute; then + $echo "$modename: unrecognized option \`-dlopen'" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + fi + + # Change the help message to a mode-specific one. + generic_help="$help" + help="Try \`$modename --help --mode=$mode' for more information." + + # These modes are in order of execution frequency so that they run quickly. + case $mode in + # libtool compile mode + compile) + modename="$modename: compile" + # Get the compilation command and the source file. + base_compile= + srcfile="$nonopt" # always keep a non-empty value in "srcfile" + suppress_opt=yes + suppress_output= + arg_mode=normal + libobj= + later= + + for arg + do + case $arg_mode in + arg ) + # do not "continue". Instead, add this to base_compile + lastarg="$arg" + arg_mode=normal + ;; + + target ) + libobj="$arg" + arg_mode=normal + continue + ;; + + normal ) + # Accept any command-line options. + case $arg in + -o) + if test -n "$libobj" ; then + $echo "$modename: you cannot specify \`-o' more than once" 1>&2 + exit $EXIT_FAILURE + fi + arg_mode=target + continue + ;; + + -static | -prefer-pic | -prefer-non-pic) + later="$later $arg" + continue + ;; + + -no-suppress) + suppress_opt=no + continue + ;; + + -Xcompiler) + arg_mode=arg # the next one goes into the "base_compile" arg list + continue # The current "srcfile" will either be retained or + ;; # replaced later. I would guess that would be a bug. + + -Wc,*) + args=`$echo "X$arg" | $Xsed -e "s/^-Wc,//"` + lastarg= + save_ifs="$IFS"; IFS=',' + for arg in $args; do + IFS="$save_ifs" + + # Double-quote args containing other shell metacharacters. + # Many Bourne shells cannot handle close brackets correctly + # in scan sets, so we specify it separately. + case $arg in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + arg="\"$arg\"" + ;; + esac + lastarg="$lastarg $arg" + done + IFS="$save_ifs" + lastarg=`$echo "X$lastarg" | $Xsed -e "s/^ //"` + + # Add the arguments to base_compile. + base_compile="$base_compile $lastarg" + continue + ;; + + * ) + # Accept the current argument as the source file. + # The previous "srcfile" becomes the current argument. + # + lastarg="$srcfile" + srcfile="$arg" + ;; + esac # case $arg + ;; + esac # case $arg_mode + + # Aesthetically quote the previous argument. + lastarg=`$echo "X$lastarg" | $Xsed -e "$sed_quote_subst"` + + case $lastarg in + # Double-quote args containing other shell metacharacters. + # Many Bourne shells cannot handle close brackets correctly + # in scan sets, and some SunOS ksh mistreat backslash-escaping + # in scan sets (worked around with variable expansion), + # and furthermore cannot handle '|' '&' '(' ')' in scan sets + # at all, so we specify them separately. + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + lastarg="\"$lastarg\"" + ;; + esac + + base_compile="$base_compile $lastarg" + done # for arg + + case $arg_mode in + arg) + $echo "$modename: you must specify an argument for -Xcompile" + exit $EXIT_FAILURE + ;; + target) + $echo "$modename: you must specify a target with \`-o'" 1>&2 + exit $EXIT_FAILURE + ;; + *) + # Get the name of the library object. + [ -z "$libobj" ] && libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'` + ;; + esac + + # Recognize several different file suffixes. + # If the user specifies -o file.o, it is replaced with file.lo + xform='[cCFSifmso]' + case $libobj in + *.ada) xform=ada ;; + *.adb) xform=adb ;; + *.ads) xform=ads ;; + *.asm) xform=asm ;; + *.c++) xform=c++ ;; + *.cc) xform=cc ;; + *.ii) xform=ii ;; + *.class) xform=class ;; + *.cpp) xform=cpp ;; + *.cxx) xform=cxx ;; + *.f90) xform=f90 ;; + *.for) xform=for ;; + *.java) xform=java ;; + esac + + libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"` + + case $libobj in + *.lo) obj=`$echo "X$libobj" | $Xsed -e "$lo2o"` ;; + *) + $echo "$modename: cannot determine name of library object from \`$libobj'" 1>&2 + exit $EXIT_FAILURE + ;; + esac + + func_infer_tag $base_compile + + for arg in $later; do + case $arg in + -static) + build_old_libs=yes + continue + ;; + + -prefer-pic) + pic_mode=yes + continue + ;; + + -prefer-non-pic) + pic_mode=no + continue + ;; + esac + done + + qlibobj=`$echo "X$libobj" | $Xsed -e "$sed_quote_subst"` + case $qlibobj in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + qlibobj="\"$qlibobj\"" ;; + esac + test "X$libobj" != "X$qlibobj" \ + && $echo "X$libobj" | grep '[]~#^*{};<>?"'"'"' &()|`$[]' \ + && $echo "$modename: libobj name \`$libobj' may not contain shell special characters." + objname=`$echo "X$obj" | $Xsed -e 's%^.*/%%'` + xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'` + if test "X$xdir" = "X$obj"; then + xdir= + else + xdir=$xdir/ + fi + lobj=${xdir}$objdir/$objname + + if test -z "$base_compile"; then + $echo "$modename: you must specify a compilation command" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + fi + + # 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 + + $run $rm $removelist + trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15 + + # On Cygwin there's no "real" PIC flag so we must build both object types + case $host_os in + cygwin* | mingw* | pw32* | os2*) + 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 "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext} + lockfile="$output_obj.lock" + removelist="$removelist $output_obj $lockfile" + trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15 + 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 $run ln "$progpath" "$lockfile" 2>/dev/null; do + $show "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." + + $run $rm $removelist + exit $EXIT_FAILURE + fi + $echo "$srcfile" > "$lockfile" + fi + + if test -n "$fix_srcfile_path"; then + eval srcfile=\"$fix_srcfile_path\" + fi + qsrcfile=`$echo "X$srcfile" | $Xsed -e "$sed_quote_subst"` + case $qsrcfile in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + qsrcfile="\"$qsrcfile\"" ;; + esac + + $run $rm "$libobj" "${libobj}T" + + # Create a libtool object file (analogous to a ".la" file), + # but don't create it if we're doing a dry run. + test -z "$run" && cat > ${libobj}T </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." + + $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 + $show "$mv $output_obj $lobj" + if $run $mv $output_obj $lobj; then : + else + error=$? + $run $rm $removelist + exit $error + fi + fi + + # Append the name of the PIC object to the libtool object file. + test -z "$run" && cat >> ${libobj}T <> ${libobj}T </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." + + $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 + $show "$mv $output_obj $obj" + if $run $mv $output_obj $obj; then : + else + error=$? + $run $rm $removelist + exit $error + fi + fi + + # Append the name of the non-PIC object the libtool object file. + # Only append if the libtool object file exists. + test -z "$run" && cat >> ${libobj}T <> ${libobj}T <&2 + fi + if test -n "$link_static_flag"; then + dlopen_self=$dlopen_self_static + fi + prefer_static_libs=yes + else + if test -z "$pic_flag" && test -n "$link_static_flag"; then + dlopen_self=$dlopen_self_static + fi + prefer_static_libs=built + fi + 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 + case $arg in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + qarg=\"`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`\" ### testsuite: skip nested quoting test + ;; + *) qarg=$arg ;; + esac + libtool_args="$libtool_args $qarg" + + # If the previous option needs an argument, assign it. + if test -n "$prev"; then + case $prev in + output) + compile_command="$compile_command @OUTPUT@" + finalize_command="$finalize_command @OUTPUT@" + ;; + esac + + case $prev in + dlfiles|dlprefiles) + if test "$preload" = no; then + # Add the symbol object into the linking commands. + compile_command="$compile_command @SYMFILE@" + finalize_command="$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" + if test ! -f "$arg"; then + $echo "$modename: symbol file \`$arg' does not exist" + exit $EXIT_FAILURE + fi + prev= + continue + ;; + expsyms_regex) + export_symbols_regex="$arg" + prev= + continue + ;; + inst_prefix) + inst_prefix_dir="$arg" + prev= + continue + ;; + precious_regex) + precious_files_regex="$arg" + prev= + continue + ;; + release) + release="-$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 (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then + pic_object= + non_pic_object= + + # Read the .lo file + # If there is no directory component, then add one. + case $arg in + */* | *\\*) . $arg ;; + *) . ./$arg ;; + esac + + if test -z "$pic_object" || \ + test -z "$non_pic_object" || + test "$pic_object" = none && \ + test "$non_pic_object" = none; then + $echo "$modename: cannot find name of object for \`$arg'" 1>&2 + exit $EXIT_FAILURE + fi + + # Extract subdirectory from the argument. + xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'` + if test "X$xdir" = "X$arg"; then + xdir= + else + xdir="$xdir/" + fi + + 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. + libobjs="$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 + non_pic_objects="$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" + non_pic_objects="$non_pic_objects $non_pic_object" + fi + else + # Only an error if not doing a dry-run. + if test -z "$run"; then + $echo "$modename: \`$arg' is not a valid libtool object" 1>&2 + exit $EXIT_FAILURE + else + # Dry-run case. + + # Extract subdirectory from the argument. + xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'` + if test "X$xdir" = "X$arg"; then + xdir= + else + xdir="$xdir/" + fi + + pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"` + non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"` + libobjs="$libobjs $pic_object" + non_pic_objects="$non_pic_objects $non_pic_object" + fi + fi + done + else + $echo "$modename: link input file \`$save_arg' does not exist" + exit $EXIT_FAILURE + fi + arg=$save_arg + prev= + continue + ;; + rpath | xrpath) + # We need an absolute path. + case $arg in + [\\/]* | [A-Za-z]:[\\/]*) ;; + *) + $echo "$modename: only absolute run-paths are allowed" 1>&2 + exit $EXIT_FAILURE + ;; + 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 + ;; + xcompiler) + compiler_flags="$compiler_flags $qarg" + prev= + compile_command="$compile_command $qarg" + finalize_command="$finalize_command $qarg" + continue + ;; + xlinker) + linker_flags="$linker_flags $qarg" + compiler_flags="$compiler_flags $wl$qarg" + prev= + compile_command="$compile_command $wl$qarg" + finalize_command="$finalize_command $wl$qarg" + continue + ;; + xcclinker) + linker_flags="$linker_flags $qarg" + compiler_flags="$compiler_flags $qarg" + prev= + compile_command="$compile_command $qarg" + finalize_command="$finalize_command $qarg" + continue + ;; + shrext) + shrext_cmds="$arg" + prev= + continue + ;; + darwin_framework|darwin_framework_skip) + test "$prev" = "darwin_framework" && compiler_flags="$compiler_flags $arg" + compile_command="$compile_command $arg" + finalize_command="$finalize_command $arg" + prev= + 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 + compile_command="$compile_command $link_static_flag" + finalize_command="$finalize_command $link_static_flag" + fi + continue + ;; + + -allow-undefined) + # FIXME: remove this flag sometime in the future. + $echo "$modename: \`-allow-undefined' is deprecated because it is the default" 1>&2 + continue + ;; + + -avoid-version) + avoid_version=yes + 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 + $echo "$modename: more than one -exported-symbols argument is not allowed" + exit $EXIT_FAILURE + fi + if test "X$arg" = "X-export-symbols"; then + prev=expsyms + else + prev=expsyms_regex + fi + continue + ;; + + -framework|-arch|-isysroot) + case " $CC " in + *" ${arg} ${1} "* | *" ${arg} ${1} "*) + prev=darwin_framework_skip ;; + *) compiler_flags="$compiler_flags $arg" + prev=darwin_framework ;; + esac + compile_command="$compile_command $arg" + finalize_command="$finalize_command $arg" + 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*) + compile_command="$compile_command $arg" + finalize_command="$finalize_command $arg" + ;; + esac + continue + ;; + + -L*) + dir=`$echo "X$arg" | $Xsed -e 's/^-L//'` + # We need an absolute path. + case $dir in + [\\/]* | [A-Za-z]:[\\/]*) ;; + *) + absdir=`cd "$dir" && pwd` + if test -z "$absdir"; then + $echo "$modename: cannot determine absolute directory name of \`$dir'" 1>&2 + absdir="$dir" + notinst_path="$notinst_path $dir" + fi + 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*) + testbindir=`$echo "X$dir" | $Xsed -e 's*/lib$*/bin*'` + case :$dllsearchpath: in + *":$dir:"*) ;; + *) dllsearchpath="$dllsearchpath:$dir";; + esac + case :$dllsearchpath: in + *":$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*) + # 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 -framework System" + 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 + ;; + 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 + ;; + + # Tru64 UNIX uses -model [arg] to determine the layout of C++ + # classes, name mangling, and exception handling. + -model) + compile_command="$compile_command $arg" + compiler_flags="$compiler_flags $arg" + finalize_command="$finalize_command $arg" + prev=xcompiler + continue + ;; + + -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe) + compiler_flags="$compiler_flags $arg" + compile_command="$compile_command $arg" + finalize_command="$finalize_command $arg" + deplibs="$deplibs $arg" + continue + ;; + + -module) + module=yes + continue + ;; + + # -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* pass through architecture-specific compiler args for GCC + # -m*, -t[45]*, -txscale* pass through architecture-specific + # compiler args for GCC + # -pg pass through profiling flag for GCC + # @file GCC response files + -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*|-pg| \ + -t[45]*|-txscale*|@*) + + # Unknown arguments in both finalize_command and compile_command need + # to be aesthetically quoted because they are evaled later. + arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` + case $arg in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + arg="\"$arg\"" + ;; + esac + compile_command="$compile_command $arg" + finalize_command="$finalize_command $arg" + compiler_flags="$compiler_flags $arg" + continue + ;; + + -shrext) + prev=shrext + continue + ;; + + -no-fast-install) + fast_install=no + continue + ;; + + -no-install) + case $host in + *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*) + # The PATH hackery in wrapper scripts is required on Windows + # in order for the loader to find any dlls it needs. + $echo "$modename: warning: \`-no-install' is ignored for $host" 1>&2 + $echo "$modename: warning: assuming \`-no-fast-install' instead" 1>&2 + 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*) + dir=`$echo "X$arg" | $Xsed -e 's/^-R//'` + # We need an absolute path. + case $dir in + [\\/]* | [A-Za-z]:[\\/]*) ;; + *) + $echo "$modename: only absolute run-paths are allowed" 1>&2 + exit $EXIT_FAILURE + ;; + esac + case "$xrpath " in + *" $dir "*) ;; + *) xrpath="$xrpath $dir" ;; + esac + continue + ;; + + -static) + # 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 + ;; + + -Wc,*) + args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wc,//'` + arg= + save_ifs="$IFS"; IFS=',' + for flag in $args; do + IFS="$save_ifs" + case $flag in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + flag="\"$flag\"" + ;; + esac + arg="$arg $wl$flag" + compiler_flags="$compiler_flags $flag" + done + IFS="$save_ifs" + arg=`$echo "X$arg" | $Xsed -e "s/^ //"` + ;; + + -Wl,*) + args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wl,//'` + arg= + save_ifs="$IFS"; IFS=',' + for flag in $args; do + IFS="$save_ifs" + case $flag in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + flag="\"$flag\"" + ;; + esac + arg="$arg $wl$flag" + compiler_flags="$compiler_flags $wl$flag" + linker_flags="$linker_flags $flag" + done + IFS="$save_ifs" + arg=`$echo "X$arg" | $Xsed -e "s/^ //"` + ;; + + -Xcompiler) + prev=xcompiler + continue + ;; + + -Xlinker) + prev=xlinker + continue + ;; + + -XCClinker) + prev=xcclinker + continue + ;; + + # Some other compiler flag. + -* | +*) + # Unknown arguments in both finalize_command and compile_command need + # to be aesthetically quoted because they are evaled later. + arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` + case $arg in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + arg="\"$arg\"" + ;; + esac + ;; + + *.$objext) + # A standard object. + objs="$objs $arg" + ;; + + *.lo) + # A libtool-controlled object. + + # Check to see that this really is a libtool object. + if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then + pic_object= + non_pic_object= + + # Read the .lo file + # If there is no directory component, then add one. + case $arg in + */* | *\\*) . $arg ;; + *) . ./$arg ;; + esac + + if test -z "$pic_object" || \ + test -z "$non_pic_object" || + test "$pic_object" = none && \ + test "$non_pic_object" = none; then + $echo "$modename: cannot find name of object for \`$arg'" 1>&2 + exit $EXIT_FAILURE + fi + + # Extract subdirectory from the argument. + xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'` + if test "X$xdir" = "X$arg"; then + xdir= + else + xdir="$xdir/" + fi + + 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. + libobjs="$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 + non_pic_objects="$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" + non_pic_objects="$non_pic_objects $non_pic_object" + fi + else + # Only an error if not doing a dry-run. + if test -z "$run"; then + $echo "$modename: \`$arg' is not a valid libtool object" 1>&2 + exit $EXIT_FAILURE + else + # Dry-run case. + + # Extract subdirectory from the argument. + xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'` + if test "X$xdir" = "X$arg"; then + xdir= + else + xdir="$xdir/" + fi + + pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"` + non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"` + libobjs="$libobjs $pic_object" + non_pic_objects="$non_pic_objects $non_pic_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. + arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` + case $arg in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + arg="\"$arg\"" + ;; + esac + ;; + esac # arg + + # Now actually substitute the argument into the commands. + if test -n "$arg"; then + compile_command="$compile_command $arg" + finalize_command="$finalize_command $arg" + fi + done # argument parsing loop + + if test -n "$prev"; then + $echo "$modename: the \`$prevarg' option requires an argument" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + fi + + if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then + eval arg=\"$export_dynamic_flag_spec\" + compile_command="$compile_command $arg" + finalize_command="$finalize_command $arg" + fi + + oldlibs= + # calculate the name of the file, without its directory + outputname=`$echo "X$output" | $Xsed -e 's%^.*/%%'` + libobjs_save="$libobjs" + + if test -n "$shlibpath_var"; then + # get the directories listed in $shlibpath_var + eval shlib_search_path=\`\$echo \"X\${$shlibpath_var}\" \| \$Xsed -e \'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\" + + output_objdir=`$echo "X$output" | $Xsed -e 's%/[^/]*$%%'` + if test "X$output_objdir" = "X$output"; then + output_objdir="$objdir" + else + output_objdir="$output_objdir/$objdir" + fi + # Create the object directory. + if test ! -d "$output_objdir"; then + $show "$mkdir $output_objdir" + $run $mkdir $output_objdir + exit_status=$? + if test "$exit_status" -ne 0 && test ! -d "$output_objdir"; then + exit $exit_status + fi + fi + + # Determine the type of output + case $output in + "") + $echo "$modename: you must specify an output file" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + ;; + *.$libext) linkmode=oldlib ;; + *.lo | *.$objext) linkmode=obj ;; + *.la) linkmode=lib ;; + *) linkmode=prog ;; # Anything else should be a program. + esac + + case $host in + *cygwin* | *mingw* | *pw32*) + # don't eliminate duplications in $postdeps and $predeps + duplicate_compiler_generated_deps=yes + ;; + *) + duplicate_compiler_generated_deps=$duplicate_deps + ;; + 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 test "X$duplicate_deps" = "Xyes" ; 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 test "X$duplicate_compiler_generated_deps" = "Xyes" ; 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 + case $linkmode in + lib) + passes="conv link" + for file in $dlfiles $dlprefiles; do + case $file in + *.la) ;; + *) + $echo "$modename: libraries can \`-dlopen' only libtool libraries: $file" 1>&2 + exit $EXIT_FAILURE + ;; + 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 + 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 "$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) + if test "$linkmode,$pass" = "prog,link"; then + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + else + compiler_flags="$compiler_flags $deplib" + fi + + case $linkmode in + lib) + deplibs="$deplib $deplibs" + test "$pass" = conv && continue + newdependency_libs="$deplib $newdependency_libs" + ;; + 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 + ;; + *) + ;; + esac # linkmode + + continue + ;; + -l*) + if test "$linkmode" != lib && test "$linkmode" != prog; then + $echo "$modename: warning: \`-l' is ignored for archives/objects" 1>&2 + continue + fi + name=`$echo "X$deplib" | $Xsed -e 's/^-l//'` + for searchdir in $newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path; 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 (${SED} -e '2q' $lib | + grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then + library_names= + old_library= + case $lib in + */* | *\\*) . $lib ;; + *) . ./$lib ;; + esac + 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 + ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'` + test "X$ladir" = "X$lib" && ladir="." + 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 + -L*) + case $linkmode in + lib) + deplibs="$deplib $deplibs" + test "$pass" = conv && continue + newdependency_libs="$deplib $newdependency_libs" + newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'` + ;; + 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 + newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'` + ;; + *) + $echo "$modename: warning: \`-L' is ignored for archives/objects" 1>&2 + ;; + esac # linkmode + continue + ;; # -L + -R*) + if test "$pass" = link; then + dir=`$echo "X$deplib" | $Xsed -e 's/^-R//'` + # 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) + valid_a_lib=no + case $deplibs_check_method in + match_pattern*) + set dummy $deplibs_check_method + match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"` + 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 used here." + else + $echo + $echo "*** Warning: Linking the shared library $output against the" + $echo "*** static library $deplib is not portable!" + deplibs="$deplib $deplibs" + fi + 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 + $echo "$modename: cannot find the library \`$lib' or unhandled argument \`$deplib'" 1>&2 + exit $EXIT_FAILURE + fi + + # Check to see that this really is a libtool archive. + if (${SED} -e '2q' $lib | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : + else + $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 + exit $EXIT_FAILURE + fi + + ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'` + test "X$ladir" = "X$lib" && ladir="." + + dlname= + dlopen= + dlpreopen= + libdir= + library_names= + old_library= + # 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 + case $lib in + */* | *\\*) . $lib ;; + *) . ./$lib ;; + esac + + 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 + $echo "$modename: cannot find name of link library for \`$lib'" 1>&2 + exit $EXIT_FAILURE + 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" + tmp_libs= + for deplib in $dependency_libs; do + deplibs="$deplib $deplibs" + if test "X$duplicate_deps" = "Xyes" ; then + case "$tmp_libs " in + *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; + esac + fi + tmp_libs="$tmp_libs $deplib" + done + elif test "$linkmode" != prog && test "$linkmode" != lib; then + $echo "$modename: \`$lib' is not a convenience library" 1>&2 + exit $EXIT_FAILURE + fi + 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 + $echo "$modename: cannot find name of link library for \`$lib'" 1>&2 + exit $EXIT_FAILURE + fi + + # This library was specified with -dlopen. + if test "$pass" = dlopen; then + if test -z "$libdir"; then + $echo "$modename: cannot -dlopen a convenience library: \`$lib'" 1>&2 + exit $EXIT_FAILURE + 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 + $echo "$modename: warning: cannot determine absolute directory name of \`$ladir'" 1>&2 + $echo "$modename: passing it literally to the linker, although it might fail" 1>&2 + abs_ladir="$ladir" + fi + ;; + esac + laname=`$echo "X$lib" | $Xsed -e 's%^.*/%%'` + + # 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 + $echo "$modename: warning: library \`$lib' was moved." 1>&2 + 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 + name=`$echo "X$laname" | $Xsed -e 's/\.la$//' -e 's/^lib//'` + + # This library was specified with -dlpreopen. + if test "$pass" = dlpreopen; then + if test -z "$libdir"; then + $echo "$modename: cannot -dlpreopen a convenience library: \`$lib'" 1>&2 + exit $EXIT_FAILURE + 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" + # 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*) newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`;; ### testsuite: skip nested quoting test + 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 test "X$duplicate_deps" = "Xyes" ; 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 -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 + *" $dir "*) ;; + *" $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 + if test "$installed" = no; then + notinst_deplibs="$notinst_deplibs $lib" + need_relink=yes + fi + # This is a shared library + + # Warn about portability, can't link against -module's on + # some systems (darwin) + if 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 + realname="$2" + shift; shift + libname=`eval \\$echo \"$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*) + major=`expr $current - $age` + versuffix="-$major" + ;; + esac + eval soname=\"$soname_spec\" + else + soname="$realname" + fi + + # Make a new name for the extract_expsyms_cmds to use + soroot="$soname" + soname=`$echo $soroot | ${SED} -e 's/^.*\///'` + newlib="libimp-`$echo $soname | ${SED} 's/^lib//;s/\.dll$//'`.a" + + # If the library has no export list, then create one now + if test -f "$output_objdir/$soname-def"; then : + else + $show "extracting exported symbol list from \`$soname'" + save_ifs="$IFS"; IFS='~' + cmds=$extract_expsyms_cmds + for cmd in $cmds; do + IFS="$save_ifs" + eval cmd=\"$cmd\" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + fi + + # Create $newlib + if test -f "$output_objdir/$newlib"; then :; else + $show "generating import library for \`$soname'" + save_ifs="$IFS"; IFS='~' + cmds=$old_archive_from_expsyms_cmds + for cmd in $cmds; do + IFS="$save_ifs" + eval cmd=\"$cmd\" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + 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 module then we can not link against + # it, someone is ignoring the new warnings I added + if /usr/bin/file -L $add 2> /dev/null | + $EGREP ": [^:]* bundle" >/dev/null ; 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 + 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; then + add="$dir/$linklib" + elif test "$hardcode_minus_L" = yes; then + add_dir="-L$dir" + # 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 + $echo "$modename: configuration error: unsupported hardcode properties" + exit $EXIT_FAILURE + 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; 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*) temp_xrpath=`$echo "X$libdir" | $Xsed -e 's/^-R//'` + 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 test "X$duplicate_deps" = "Xyes" ; 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 + case $deplib in + -L*) path="$deplib" ;; + *.la) + dir=`$echo "X$deplib" | $Xsed -e 's%/[^/]*$%%'` + test "X$dir" = "X$deplib" && dir="." + # We need an absolute path. + case $dir in + [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;; + *) + absdir=`cd "$dir" && pwd` + if test -z "$absdir"; then + $echo "$modename: warning: cannot determine absolute directory name of \`$dir'" 1>&2 + absdir="$dir" + fi + ;; + esac + if grep "^installed=no" $deplib > /dev/null; then + path="$absdir/$objdir" + else + eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` + if test -z "$libdir"; then + $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2 + exit $EXIT_FAILURE + fi + if test "$absdir" != "$libdir"; then + $echo "$modename: warning: \`$deplib' seems to be moved" 1>&2 + fi + path="$absdir" + fi + depdepl= + case $host in + *-*-darwin*) + # we do not want to link against static libs, + # but need to link against shared + eval 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 "$path/$depdepl" ; then + depdepl="$path/$depdepl" + fi + # do not add paths which are already there + case " $newlib_search_path " in + *" $path "*) ;; + *) newlib_search_path="$newlib_search_path $path";; + esac + fi + path="" + ;; + *) + path="-L$path" + ;; + esac + ;; + -l*) + case $host in + *-*-darwin*) + # Again, we only want to link against shared libraries + eval tmp_libs=`$echo "X$deplib" | $Xsed -e "s,^\-l,,"` + for tmp in $newlib_search_path ; do + if test -f "$tmp/lib$tmp_libs.dylib" ; then + eval depdepl="$tmp/lib$tmp_libs.dylib" + break + fi + done + path="" + ;; + *) continue ;; + esac + ;; + *) continue ;; + esac + case " $deplibs " in + *" $path "*) ;; + *) deplibs="$path $deplibs" ;; + esac + case " $deplibs " in + *" $depdepl "*) ;; + *) deplibs="$depdepl $deplibs" ;; + esac + done + fi # link_all_deplibs != no + fi # linkmode = lib + done # for deplib in $libs + 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" + dlprefiles="$newdlprefiles" + fi + + case $linkmode in + oldlib) + if test -n "$deplibs"; then + $echo "$modename: warning: \`-l' and \`-L' are ignored for archives" 1>&2 + fi + + if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then + $echo "$modename: warning: \`-dlopen' is ignored for archives" 1>&2 + fi + + if test -n "$rpath"; then + $echo "$modename: warning: \`-rpath' is ignored for archives" 1>&2 + fi + + if test -n "$xrpath"; then + $echo "$modename: warning: \`-R' is ignored for archives" 1>&2 + fi + + if test -n "$vinfo"; then + $echo "$modename: warning: \`-version-info/-version-number' is ignored for archives" 1>&2 + fi + + if test -n "$release"; then + $echo "$modename: warning: \`-release' is ignored for archives" 1>&2 + fi + + if test -n "$export_symbols" || test -n "$export_symbols_regex"; then + $echo "$modename: warning: \`-export-symbols' is ignored for archives" 1>&2 + fi + + # 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*) + name=`$echo "X$outputname" | $Xsed -e 's/\.la$//' -e 's/^lib//'` + eval shared_ext=\"$shrext_cmds\" + eval libname=\"$libname_spec\" + ;; + *) + if test "$module" = no; then + $echo "$modename: libtool library \`$output' must begin with \`lib'" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + fi + if test "$need_lib_prefix" != no; then + # Add the "lib" prefix for modules if required + name=`$echo "X$outputname" | $Xsed -e 's/\.la$//'` + eval shared_ext=\"$shrext_cmds\" + eval libname=\"$libname_spec\" + else + libname=`$echo "X$outputname" | $Xsed -e 's/\.la$//'` + fi + ;; + esac + + if test -n "$objs"; then + if test "$deplibs_check_method" != pass_all; then + $echo "$modename: cannot build libtool library \`$output' from non-libtool objects on this host:$objs" 2>&1 + exit $EXIT_FAILURE + else + $echo + $echo "*** Warning: Linking the shared library $output against the non-libtool" + $echo "*** objects $objs is not portable!" + libobjs="$libobjs $objs" + fi + fi + + if test "$dlself" != no; then + $echo "$modename: warning: \`-dlopen self' is ignored for libtool libraries" 1>&2 + fi + + set dummy $rpath + if test "$#" -gt 2; then + $echo "$modename: warning: ignoring multiple \`-rpath's for a libtool library" 1>&2 + fi + install_libdir="$2" + + 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 + + if test -n "$vinfo"; then + $echo "$modename: warning: \`-version-info/-version-number' is ignored for convenience libraries" 1>&2 + fi + + if test -n "$release"; then + $echo "$modename: warning: \`-release' is ignored for convenience libraries" 1>&2 + fi + else + + # Parse the version information argument. + save_ifs="$IFS"; IFS=':' + set dummy $vinfo 0 0 0 + IFS="$save_ifs" + + if test -n "$8"; then + $echo "$modename: too many parameters to \`-version-info'" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + fi + + # 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="$2" + number_minor="$3" + number_revision="$4" + # + # 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) + current=`expr $number_major + $number_minor` + age="$number_minor" + revision="$number_revision" + ;; + freebsd-aout|freebsd-elf|sunos) + current="$number_major" + revision="$number_minor" + age="0" + ;; + irix|nonstopux) + current=`expr $number_major + $number_minor - 1` + age="$number_minor" + revision="$number_minor" + ;; + esac + ;; + no) + current="$2" + revision="$3" + age="$4" + ;; + 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]) ;; + *) + $echo "$modename: CURRENT \`$current' must be a nonnegative integer" 1>&2 + $echo "$modename: \`$vinfo' is not valid version information" 1>&2 + exit $EXIT_FAILURE + ;; + 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]) ;; + *) + $echo "$modename: REVISION \`$revision' must be a nonnegative integer" 1>&2 + $echo "$modename: \`$vinfo' is not valid version information" 1>&2 + exit $EXIT_FAILURE + ;; + 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]) ;; + *) + $echo "$modename: AGE \`$age' must be a nonnegative integer" 1>&2 + $echo "$modename: \`$vinfo' is not valid version information" 1>&2 + exit $EXIT_FAILURE + ;; + esac + + if test "$age" -gt "$current"; then + $echo "$modename: AGE \`$age' is greater than the current interface number \`$current'" 1>&2 + $echo "$modename: \`$vinfo' is not valid version information" 1>&2 + exit $EXIT_FAILURE + 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 + major=.`expr $current - $age` + versuffix="$major.$age.$revision" + # Darwin ld doesn't like 0 for these options... + minor_current=`expr $current + 1` + verstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision" + ;; + + freebsd-aout) + major=".$current" + versuffix=".$current.$revision"; + ;; + + freebsd-elf) + major=".$current" + versuffix=".$current"; + ;; + + irix | nonstopux) + major=`expr $current - $age + 1` + + 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 + iface=`expr $revision - $loop` + loop=`expr $loop - 1` + verstring="$verstring_prefix$major.$iface:$verstring" + done + + # Before this point, $major must not contain `.'. + major=.$major + versuffix="$major.$revision" + ;; + + linux) + major=.`expr $current - $age` + versuffix="$major.$age.$revision" + ;; + + osf) + major=.`expr $current - $age` + 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 + iface=`expr $current - $loop` + loop=`expr $loop - 1` + verstring="$verstring:${iface}.0" + done + + # Make executables depend on our current version. + verstring="$verstring:${current}.0" + ;; + + sunos) + major=".$current" + versuffix=".$current.$revision" + ;; + + windows) + # Use '-' rather than '.', since we only want one + # extension on DOS 8.3 filesystems. + major=`expr $current - $age` + versuffix="-$major" + ;; + + *) + $echo "$modename: unknown library version type \`$version_type'" 1>&2 + $echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2 + exit $EXIT_FAILURE + ;; + 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 + $echo "$modename: warning: undefined symbols not allowed in $host shared libraries" 1>&2 + build_libtool_libs=no + build_old_libs=yes + fi + else + # Don't allow undefined symbols. + allow_undefined_flag="$no_undefined_flag" + fi + fi + + 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) + ;; + $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 + if test -n "$removelist"; then + $show "${rm}r $removelist" + $run ${rm}r $removelist + fi + 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 "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP` + fi + + # Eliminate all temporary directories. + for path in $notinst_path; do + lib_search_path=`$echo "$lib_search_path " | ${SED} -e "s% $path % %g"` + deplibs=`$echo "$deplibs " | ${SED} -e "s% -L$path % %g"` + dependency_libs=`$echo "$dependency_libs " | ${SED} -e "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*) + # these systems don't actually have a c library (as such)! + ;; + *-*-rhapsody* | *-*-darwin1.[012]) + # Rhapsody C library is in the System framework + deplibs="$deplibs -framework System" + ;; + *-*-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. + $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 "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";; + esac + done + if eval $file_magic_cmd \"\$potlib\" 2>/dev/null \ + | ${SED} 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 + else + # Add a -L argument. + newdeplibs="$newdeplibs $a_deplib" + fi + done # Gone through all deplibs. + ;; + match_pattern*) + set dummy $deplibs_check_method + match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"` + for a_deplib in $deplibs; do + name=`expr $a_deplib : '-l\(.*\)'` + # If $name is empty we are operating on a -L argument. + if test -n "$name" && test "$name" != "0"; then + 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 + libname=`eval \\$echo \"$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 + else + # Add a -L argument. + newdeplibs="$newdeplibs $a_deplib" + fi + done # Gone through all deplibs. + ;; + none | unknown | *) + newdeplibs="" + tmp_deplibs=`$echo "X $deplibs" | $Xsed -e 's/ -lc$//' \ + -e '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 "X $tmp_deplibs" | ${SED} -e "1s,^X,," -e "s,$i,,"` + done + fi + if $echo "X $tmp_deplibs" | $Xsed -e 's/[ ]//g' \ + | grep . >/dev/null; then + $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 + fi + ;; + 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 is the System framework + newdeplibs=`$echo "X $newdeplibs" | $Xsed -e 's/ -lc / -framework System /'` + ;; + 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 + + + # 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 + realname="$2" + shift; 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 "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` + + # Prepare the list of exported symbols + if test -z "$export_symbols"; then + if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then + $show "generating symbol list for \`$libname.la'" + export_symbols="$output_objdir/$libname.exp" + $run $rm $export_symbols + cmds=$export_symbols_cmds + save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + eval cmd=\"$cmd\" + if len=`expr "X$cmd" : ".*"` && + test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then + $show "$cmd" + $run eval "$cmd" || exit $? + skipped_export=false + else + # The command line is too long to execute in one step. + $show "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"; then + $show "$EGREP -e \"$export_symbols_regex\" \"$export_symbols\" > \"${export_symbols}T\"" + $run eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' + $show "$mv \"${export_symbols}T\" \"$export_symbols\"" + $run eval '$mv "${export_symbols}T" "$export_symbols"' + fi + fi + fi + + if test -n "$export_symbols" && test -n "$include_expsyms"; then + $run eval '$echo "X$include_expsyms" | $SP2NL >> "$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"; then + save_libobjs=$libobjs + eval libobjs=\"\$libobjs $whole_archive_flag_spec\" + else + gentop="$output_objdir/${outputname}x" + generated="$generated $gentop" + + func_extract_archives $gentop $convenience + libobjs="$libobjs $func_extract_archives_result" + 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 + $run eval '(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:" && + len=`expr "X$test_cmds" : ".*" 2>/dev/null` && + test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then + : + else + # The command line is too long to link in one step, link piecewise. + $echo "creating reloadable object files..." + + # 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 + output_la=`$echo "X$output" | $Xsed -e "$basename"` + + # Clear the reloadable object creation command queue and + # initialize k to one. + test_cmds= + concat_cmds= + objlist= + delfiles= + last_robj= + k=1 + output=$output_objdir/$output_la-${k}.$objext + # Loop over the list of objects to be linked. + for obj in $save_libobjs + do + eval test_cmds=\"$reload_cmds $objlist $last_robj\" + if test "X$objlist" = X || + { len=`expr "X$test_cmds" : ".*" 2>/dev/null` && + test "$len" -le "$max_cmd_len"; }; then + objlist="$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. + eval concat_cmds=\"$reload_cmds $objlist $last_robj\" + else + # All subsequent reloadable object files will link in + # the last one created. + eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj\" + fi + last_robj=$output_objdir/$output_la-${k}.$objext + k=`expr $k + 1` + output=$output_objdir/$output_la-${k}.$objext + objlist=$obj + len=1 + 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~ + eval concat_cmds=\"\${concat_cmds}$reload_cmds $objlist $last_robj\" + + if ${skipped_export-false}; then + $show "generating symbol list for \`$libname.la'" + export_symbols="$output_objdir/$libname.exp" + $run $rm $export_symbols + libobjs=$output + # Append the command to create the export file. + eval concat_cmds=\"\$concat_cmds~$export_symbols_cmds\" + fi + + # Set up a command to remove the reloadable object files + # after they are used. + i=0 + while test "$i" -lt "$k" + do + i=`expr $i + 1` + delfiles="$delfiles $output_objdir/$output_la-${i}.$objext" + done + + $echo "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" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + + 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\" + 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 + + # Append the command to remove the reloadable object files + # to the just-reset $cmds. + eval cmds=\"\$cmds~\$rm $delfiles\" + fi + save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + eval cmd=\"$cmd\" + $show "$cmd" + $run eval "$cmd" || { + lt_exit=$? + + # Restore the uninstalled library and exit + if test "$mode" = relink; then + $run eval '(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 + $run eval '(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 + $show "${rm}r $gentop" + $run ${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 + $show "(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)" + $run 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 "$deplibs"; then + $echo "$modename: warning: \`-l' and \`-L' are ignored for objects" 1>&2 + fi + + if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then + $echo "$modename: warning: \`-dlopen' is ignored for objects" 1>&2 + fi + + if test -n "$rpath"; then + $echo "$modename: warning: \`-rpath' is ignored for objects" 1>&2 + fi + + if test -n "$xrpath"; then + $echo "$modename: warning: \`-R' is ignored for objects" 1>&2 + fi + + if test -n "$vinfo"; then + $echo "$modename: warning: \`-version-info' is ignored for objects" 1>&2 + fi + + if test -n "$release"; then + $echo "$modename: warning: \`-release' is ignored for objects" 1>&2 + fi + + case $output in + *.lo) + if test -n "$objs$old_deplibs"; then + $echo "$modename: cannot build library object \`$output' from non-libtool objects" 1>&2 + exit $EXIT_FAILURE + fi + libobj="$output" + obj=`$echo "X$output" | $Xsed -e "$lo2o"` + ;; + *) + libobj= + obj="$output" + ;; + esac + + # Delete the old objects. + $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 + wl= + + if test -n "$convenience"; then + if test -n "$whole_archive_flag_spec"; then + eval reload_conv_objs=\"\$reload_objs $whole_archive_flag_spec\" + 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 "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}$'/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test + + output="$obj" + cmds=$reload_cmds + save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + eval cmd=\"$cmd\" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + + # Exit if we aren't doing a library object file. + if test -z "$libobj"; then + if test -n "$gentop"; then + $show "${rm}r $gentop" + $run ${rm}r $gentop + fi + + exit $EXIT_SUCCESS + fi + + if test "$build_libtool_libs" != yes; then + if test -n "$gentop"; then + $show "${rm}r $gentop" + $run ${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" + # $run eval "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" + cmds=$reload_cmds + save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + eval cmd=\"$cmd\" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + fi + + if test -n "$gentop"; then + $show "${rm}r $gentop" + $run ${rm}r $gentop + fi + + exit $EXIT_SUCCESS + ;; + + prog) + case $host in + *cygwin*) output=`$echo $output | ${SED} -e 's,.exe$,,;s,$,.exe,'` ;; + esac + if test -n "$vinfo"; then + $echo "$modename: warning: \`-version-info' is ignored for programs" 1>&2 + fi + + if test -n "$release"; then + $echo "$modename: warning: \`-release' is ignored for programs" 1>&2 + fi + + if test "$preload" = yes; then + if test "$dlopen_support" = unknown && test "$dlopen_self" = unknown && + test "$dlopen_self_static" = unknown; then + $echo "$modename: warning: \`AC_LIBTOOL_DLOPEN' not used. Assuming no dlopen support." + fi + fi + + case $host in + *-*-rhapsody* | *-*-darwin1.[012]) + # On Rhapsody replace the C library is the System framework + compile_deplibs=`$echo "X $compile_deplibs" | $Xsed -e 's/ -lc / -framework System /'` + finalize_deplibs=`$echo "X $finalize_deplibs" | $Xsed -e 's/ -lc / -framework System /'` + ;; + esac + + case $host in + *darwin*) + # Don't allow lazy linking, it breaks C++ global constructors + if test "$tagname" = CXX ; then + compile_command="$compile_command ${wl}-bind_at_load" + finalize_command="$finalize_command ${wl}-bind_at_load" + fi + ;; + 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*) + testbindir=`$echo "X$libdir" | $Xsed -e 's*/lib$*/bin*'` + case :$dllsearchpath: in + *":$libdir:"*) ;; + *) dllsearchpath="$dllsearchpath:$libdir";; + esac + case :$dllsearchpath: in + *":$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 "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` + finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` + fi + + dlsyms= + if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then + if test -n "$NM" && test -n "$global_symbol_pipe"; then + dlsyms="${outputname}S.c" + else + $echo "$modename: not configured to extract global symbols from dlpreopened files" 1>&2 + fi + fi + + if test -n "$dlsyms"; then + case $dlsyms in + "") ;; + *.c) + # Discover the nlist of each of the dlfiles. + nlist="$output_objdir/${outputname}.nm" + + $show "$rm $nlist ${nlist}S ${nlist}T" + $run $rm "$nlist" "${nlist}S" "${nlist}T" + + # Parse the name list into a source file. + $show "creating $output_objdir/$dlsyms" + + test -z "$run" && $echo > "$output_objdir/$dlsyms" "\ +/* $dlsyms - symbol resolution table for \`$outputname' dlsym emulation. */ +/* Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP */ + +#ifdef __cplusplus +extern \"C\" { +#endif + +/* Prevent the only kind of declaration conflicts we can make. */ +#define lt_preloaded_symbols some_other_symbol + +/* External symbol declarations for the compiler. */\ +" + + if test "$dlself" = yes; then + $show "generating symbol list for \`$output'" + + test -z "$run" && $echo ': @PROGRAM@ ' > "$nlist" + + # Add our own program objects to the symbol list. + progfiles=`$echo "X$objs$old_deplibs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` + for arg in $progfiles; do + $show "extracting global C symbols from \`$arg'" + $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'" + done + + if test -n "$exclude_expsyms"; then + $run eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' + $run eval '$mv "$nlist"T "$nlist"' + fi + + if test -n "$export_symbols_regex"; then + $run eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' + $run eval '$mv "$nlist"T "$nlist"' + fi + + # Prepare the list of exported symbols + if test -z "$export_symbols"; then + export_symbols="$output_objdir/$outputname.exp" + $run $rm $export_symbols + $run eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' + case $host in + *cygwin* | *mingw* ) + $run eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' + $run eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' + ;; + esac + else + $run eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' + $run eval 'grep -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' + $run eval 'mv "$nlist"T "$nlist"' + case $host in + *cygwin* | *mingw* ) + $run eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' + $run eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' + ;; + esac + fi + fi + + for arg in $dlprefiles; do + $show "extracting global C symbols from \`$arg'" + name=`$echo "$arg" | ${SED} -e 's%^.*/%%'` + $run eval '$echo ": $name " >> "$nlist"' + $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'" + done + + if test -z "$run"; then + # 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/$dlsyms"' + else + $echo '/* NONE */' >> "$output_objdir/$dlsyms" + fi + + $echo >> "$output_objdir/$dlsyms" "\ + +#undef lt_preloaded_symbols + +#if defined (__STDC__) && __STDC__ +# define lt_ptr void * +#else +# define lt_ptr char * +# define const +#endif + +/* The mapping between symbol names and symbols. */ +" + + case $host in + *cygwin* | *mingw* ) + $echo >> "$output_objdir/$dlsyms" "\ +/* DATA imports from DLLs on WIN32 can't be const, because + runtime relocations are performed -- see ld's documentation + on pseudo-relocs */ +struct { +" + ;; + * ) + $echo >> "$output_objdir/$dlsyms" "\ +const struct { +" + ;; + esac + + + $echo >> "$output_objdir/$dlsyms" "\ + const char *name; + lt_ptr address; +} +lt_preloaded_symbols[] = +{\ +" + + eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$dlsyms" + + $echo >> "$output_objdir/$dlsyms" "\ + {0, (lt_ptr) 0} +}; + +/* This works around a problem in FreeBSD linker */ +#ifdef FREEBSD_WORKAROUND +static const void *lt_preloaded_setup() { + return lt_preloaded_symbols; +} +#endif + +#ifdef __cplusplus +} +#endif\ +" + fi + + pic_flag_for_symtable= + 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*) + case "$compile_command " in + *" -static "*) ;; + *) pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND";; + esac;; + *-*-hpux*) + case "$compile_command " in + *" -static "*) ;; + *) pic_flag_for_symtable=" $pic_flag";; + esac + esac + + # Now compile the dynamic symbol file. + $show "(cd $output_objdir && $LTCC $LTCFLAGS -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")" + $run eval '(cd $output_objdir && $LTCC $LTCFLAGS -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $? + + # Clean up the generated files. + $show "$rm $output_objdir/$dlsyms $nlist ${nlist}S ${nlist}T" + $run $rm "$output_objdir/$dlsyms" "$nlist" "${nlist}S" "${nlist}T" + + # Transform the symbol file into the correct name. + case $host in + *cygwin* | *mingw* ) + if test -f "$output_objdir/${outputname}.def" ; then + compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%"` + finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%"` + else + compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"` + finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"` + fi + ;; + * ) + compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"` + finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"` + ;; + esac + ;; + *-*-freebsd*) + # FreeBSD doesn't need this... + ;; + *) + $echo "$modename: unknown suffix for \`$dlsyms'" 1>&2 + exit $EXIT_FAILURE + ;; + 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 "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"` + finalize_command=`$echo "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"` + fi + + if test "$need_relink" = no || test "$build_libtool_libs" != yes; then + # Replace the output file specification. + compile_command=`$echo "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'` + link_command="$compile_command$compile_rpath" + + # We have no uninstalled library dependencies, so finalize right now. + $show "$link_command" + $run eval "$link_command" + exit_status=$? + + # Delete the generated files. + if test -n "$dlsyms"; then + $show "$rm $output_objdir/${outputname}S.${objext}" + $run $rm "$output_objdir/${outputname}S.${objext}" + fi + + exit $exit_status + fi + + if test -n "$shlibpath_var"; then + # We should set the shlibpath_var + rpath= + for dir in $temp_rpath; do + case $dir in + [\\/]* | [A-Za-z]:[\\/]*) + # Absolute path. + rpath="$rpath$dir:" + ;; + *) + # Relative path: add a thisdir entry. + rpath="$rpath\$thisdir/$dir:" + ;; + esac + done + temp_rpath="$rpath" + 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 "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'` + # Delete the old output file. + $run $rm $output + # Link the executable and exit + $show "$link_command" + $run 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" + + $echo "$modename: warning: this platform does not like uninstalled shared libraries" 1>&2 + $echo "$modename: \`$output' will be relinked during installation" 1>&2 + else + if test "$fast_install" != no; then + link_command="$finalize_var$compile_command$finalize_rpath" + if test "$fast_install" = yes; then + relink_command=`$echo "X$compile_var$compile_command$compile_rpath" | $Xsed -e '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 "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` + + # Delete the old output files. + $run $rm $output $output_objdir/$outputname $output_objdir/lt-$outputname + + $show "$link_command" + $run eval "$link_command" || exit $? + + # Now create the wrapper script. + $show "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}\" || 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 + var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"` + relink_command="$var=\"$var_value\"; export $var; $relink_command" + fi + done + relink_command="(cd `pwd`; $relink_command)" + relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"` + fi + + # Quote $echo for shipping. + if test "X$echo" = "X$SHELL $progpath --fallback-echo"; then + case $progpath in + [\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $progpath --fallback-echo";; + *) qecho="$SHELL `pwd`/$progpath --fallback-echo";; + esac + qecho=`$echo "X$qecho" | $Xsed -e "$sed_quote_subst"` + else + qecho=`$echo "X$echo" | $Xsed -e "$sed_quote_subst"` + fi + + # Only actually do things if our run command is non-null. + if test -z "$run"; then + # win32 will think the script is a binary if it has + # a .exe suffix, so we strip it off here. + case $output in + *.exe) output=`$echo $output|${SED} 's,.exe$,,'` ;; + esac + # test for cygwin because mv fails w/o .exe extensions + case $host in + *cygwin*) + exeext=.exe + outputname=`$echo $outputname|${SED} 's,.exe$,,'` ;; + *) exeext= ;; + esac + case $host in + *cygwin* | *mingw* ) + output_name=`basename $output` + output_path=`dirname $output` + 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 + + cat > $cwrappersource <> $cwrappersource<<"EOF" +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if defined(PATH_MAX) +# define LT_PATHMAX PATH_MAX +#elif defined(MAXPATHLEN) +# define LT_PATHMAX MAXPATHLEN +#else +# define LT_PATHMAX 1024 +#endif + +#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 +# 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 */ + +#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) +#define XFREE(stale) do { \ + if (stale) { free ((void *) stale); stale = 0; } \ +} while (0) + +/* -DDEBUG is fairly common in CFLAGS. */ +#undef DEBUG +#if defined DEBUGWRAPPER +# define DEBUG(format, ...) fprintf(stderr, format, __VA_ARGS__) +#else +# define DEBUG(format, ...) +#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); +int check_executable(const char *path); +char * strendzap(char *str, const char *pat); +void lt_fatal (const char *message, ...); + +int +main (int argc, char *argv[]) +{ + char **newargz; + int i; + + program_name = (char *) xstrdup (base_name (argv[0])); + DEBUG("(main) argv[0] : %s\n",argv[0]); + DEBUG("(main) program_name : %s\n",program_name); + newargz = XMALLOC(char *, argc+2); +EOF + + cat >> $cwrappersource <> $cwrappersource <<"EOF" + newargz[1] = find_executable(argv[0]); + if (newargz[1] == NULL) + lt_fatal("Couldn't find %s", argv[0]); + DEBUG("(main) found exe at : %s\n",newargz[1]); + /* we know the script has the same name, without the .exe */ + /* so make sure newargz[1] doesn't end in .exe */ + strendzap(newargz[1],".exe"); + for (i = 1; i < argc; i++) + newargz[i+1] = xstrdup(argv[i]); + newargz[argc+1] = NULL; + + for (i=0; i> $cwrappersource <> $cwrappersource <> $cwrappersource <<"EOF" + return 127; +} + +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; + + DEBUG("(check_executable) : %s\n", path ? (*path ? path : "EMPTY!") : "NULL!"); + if ((!path) || (!*path)) + return 0; + + if ((stat (path, &st) >= 0) && + ( + /* MinGW & native WIN32 do not support S_IXOTH or S_IXGRP */ +#if defined (S_IXOTH) + ((st.st_mode & S_IXOTH) == S_IXOTH) || +#endif +#if defined (S_IXGRP) + ((st.st_mode & S_IXGRP) == S_IXGRP) || +#endif + ((st.st_mode & S_IXUSR) == S_IXUSR)) + ) + return 1; + else + return 0; +} + +/* Searches for the full path of the wrapper. Returns + newly allocated full path name if found, NULL otherwise */ +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; + + DEBUG("(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 * +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); +} +EOF + # we should really use a build-platform specific compiler + # here, but OTOH, the wrappers (shell script and this C one) + # are only useful if you want to execute the "real" binary. + # Since the "real" binary is built for $host, then this + # wrapper might as well be built for $host, too. + $run $LTCC $LTCFLAGS -s -o $cwrapper $cwrappersource + ;; + esac + $rm $output + trap "$rm $output; exit $EXIT_FAILURE" 1 2 15 + + $echo > $output "\ +#! $SHELL + +# $output - temporary wrapper script for $objdir/$outputname +# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP +# +# 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. +Xsed='${SED} -e 1s/^X//' +sed_quote_subst='$sed_quote_subst' + +# 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 variable: + 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 + echo=\"$qecho\" + file=\"\$0\" + # Make sure echo works. + if test \"X\$1\" = X--no-reexec; then + # Discard the --no-reexec flag, and continue. + shift + elif test \"X\`(\$echo '\t') 2>/dev/null\`\" = 'X\t'; then + # Yippee, \$echo works! + : + else + # Restart under the correct shell, and then maybe \$echo will work. + exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"} + fi + fi\ +" + $echo >> $output "\ + + # Find the directory that this script lives in. + thisdir=\`\$echo \"X\$file\" | \$Xsed -e '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 \"X\$file\" | \$Xsed -e '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 \"X\$file\" | \$Xsed -e 's%^.*/%%'\` + file=\`ls -ld \"\$thisdir/\$file\" | ${SED} -n 's/.*-> //p'\` + done + + # Try to get the absolute directory name. + absdir=\`cd \"\$thisdir\" && pwd\` + test -n \"\$absdir\" && thisdir=\"\$absdir\" +" + + if test "$fast_install" = yes; then + $echo >> $output "\ + 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 >> $output "\ + + # 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 $EXIT_FAILURE + fi + fi + + $mv \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || + { $rm \"\$progdir/\$program\"; + $mv \"\$progdir/\$file\" \"\$progdir/\$program\"; } + $rm \"\$progdir/\$file\" + fi" + else + $echo >> $output "\ + program='$outputname' + progdir=\"\$thisdir/$objdir\" +" + fi + + $echo >> $output "\ + + 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 >> $output "\ + # 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 \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\` + + export $shlibpath_var +" + fi + + # fixup the dll searchpath if we need to. + if test -n "$dllsearchpath"; then + $echo >> $output "\ + # Add the dll search path components to the executable PATH + PATH=$dllsearchpath:\$PATH +" + fi + + $echo >> $output "\ + 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*) + $echo >> $output "\ + exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} +" + ;; + + *) + $echo >> $output "\ + exec \"\$progdir/\$program\" \${1+\"\$@\"} +" + ;; + esac + $echo >> $output "\ + \$echo \"\$0: cannot exec \$program \${1+\"\$@\"}\" + exit $EXIT_FAILURE + 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 $EXIT_FAILURE + fi +fi\ +" + chmod +x $output + fi + 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" + 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" + 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 + # 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 + $echo "X$obj" | $Xsed -e 's%^.*/%%' + done | sort | sort -uc >/dev/null 2>&1); then + : + else + $echo "copying selected object files to avoid basename conflicts..." + + if test -z "$gentop"; then + gentop="$output_objdir/${outputname}x" + generated="$generated $gentop" + + $show "${rm}r $gentop" + $run ${rm}r "$gentop" + $show "$mkdir $gentop" + $run $mkdir "$gentop" + exit_status=$? + if test "$exit_status" -ne 0 && test ! -d "$gentop"; then + exit $exit_status + fi + fi + + save_oldobjs=$oldobjs + oldobjs= + counter=1 + for obj in $save_oldobjs + do + objbase=`$echo "X$obj" | $Xsed -e 's%^.*/%%'` + case " $oldobjs " in + " ") oldobjs=$obj ;; + *[\ /]"$objbase "*) + while :; do + # Make sure we don't pick an alternate name that also + # overlaps. + newobj=lt$counter-$objbase + counter=`expr $counter + 1` + case " $oldobjs " in + *[\ /]"$newobj "*) ;; + *) if test ! -f "$gentop/$newobj"; then break; fi ;; + esac + done + $show "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" + $run ln "$obj" "$gentop/$newobj" || + $run cp "$obj" "$gentop/$newobj" + oldobjs="$oldobjs $gentop/$newobj" + ;; + *) oldobjs="$oldobjs $obj" ;; + esac + done + fi + + eval cmds=\"$old_archive_cmds\" + + if len=`expr "X$cmds" : ".*"` && + test "$len" -le "$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 + $echo "using piecewise archive linking..." + save_RANLIB=$RANLIB + RANLIB=: + objlist= + concat_cmds= + save_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 + for obj in $save_oldobjs + do + oldobjs="$objlist $obj" + objlist="$objlist $obj" + eval test_cmds=\"$old_archive_cmds\" + if len=`expr "X$test_cmds" : ".*" 2>/dev/null` && + test "$len" -le "$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= + 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 + save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + eval cmd=\"$cmd\" + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + done + + if test -n "$generated"; then + $show "${rm}r$generated" + $run ${rm}r$generated + fi + + # Now create the libtool archive. + case $output in + *.la) + old_library= + test "$build_old_libs" = yes && old_library="$libname.$libext" + $show "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}\" || 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 + var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"` + relink_command="$var=\"$var_value\"; 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 "X$relink_command" | $Xsed -e "$sed_quote_subst"` + if test "$hardcode_automatic" = yes ; then + relink_command= + fi + + + # Only create the output if not a dry run. + if test -z "$run"; then + 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) + name=`$echo "X$deplib" | $Xsed -e 's%^.*/%%'` + eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` + if test -z "$libdir"; then + $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2 + exit $EXIT_FAILURE + fi + newdependency_libs="$newdependency_libs $libdir/$name" + ;; + *) newdependency_libs="$newdependency_libs $deplib" ;; + esac + done + dependency_libs="$newdependency_libs" + newdlfiles= + for lib in $dlfiles; do + name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'` + eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` + if test -z "$libdir"; then + $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 + exit $EXIT_FAILURE + fi + newdlfiles="$newdlfiles $libdir/$name" + done + dlfiles="$newdlfiles" + newdlprefiles= + for lib in $dlprefiles; do + name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'` + eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` + if test -z "$libdir"; then + $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 + exit $EXIT_FAILURE + fi + newdlprefiles="$newdlprefiles $libdir/$name" + 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 + tdlname=$dlname + case $host,$output,$installed,$module,$dlname in + *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;; + esac + $echo > $output "\ +# $outputname - a libtool library file +# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP +# +# 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' + +# Libraries that this one depends upon. +dependency_libs='$dependency_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 + fi + + # Do a symbolic link so that the libtool archive can be found in + # LD_LIBRARY_PATH before the program is installed. + $show "(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)" + $run eval '(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)' || exit $? + ;; + esac + exit $EXIT_SUCCESS + ;; + + # libtool install mode + install) + modename="$modename: install" + + # 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. + $echo "X$nonopt" | grep shtool > /dev/null; then + # Aesthetically quote it. + arg=`$echo "X$nonopt" | $Xsed -e "$sed_quote_subst"` + case $arg in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + arg="\"$arg\"" + ;; + esac + install_prog="$arg " + arg="$1" + shift + else + install_prog= + arg=$nonopt + fi + + # The real first argument should be the name of the installation program. + # Aesthetically quote it. + arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` + case $arg in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + arg="\"$arg\"" + ;; + esac + install_prog="$install_prog$arg" + + # We need to accept at least all the BSD install flags. + dest= + files= + opts= + prev= + install_type= + isdir=no + stripme= + for arg + do + if test -n "$dest"; then + files="$files $dest" + dest=$arg + continue + fi + + case $arg in + -d) isdir=yes ;; + -f) + case " $install_prog " in + *[\\\ /]cp\ *) ;; + *) prev=$arg ;; + esac + ;; + -g | -m | -o) prev=$arg ;; + -s) + stripme=" -s" + continue + ;; + -*) + ;; + *) + # If the previous option needed an argument, then skip it. + if test -n "$prev"; then + prev= + else + dest=$arg + continue + fi + ;; + esac + + # Aesthetically quote the argument. + arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` + case $arg in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + arg="\"$arg\"" + ;; + esac + install_prog="$install_prog $arg" + done + + if test -z "$install_prog"; then + $echo "$modename: you must specify an install program" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + fi + + if test -n "$prev"; then + $echo "$modename: the \`$prev' option requires an argument" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + fi + + if test -z "$files"; then + if test -z "$dest"; then + $echo "$modename: no file or destination specified" 1>&2 + else + $echo "$modename: you must specify a destination" 1>&2 + fi + $echo "$help" 1>&2 + exit $EXIT_FAILURE + fi + + # Strip any trailing slash from the destination. + dest=`$echo "X$dest" | $Xsed -e 's%/$%%'` + + # Check to see that the destination is a directory. + test -d "$dest" && isdir=yes + if test "$isdir" = yes; then + destdir="$dest" + destname= + else + destdir=`$echo "X$dest" | $Xsed -e 's%/[^/]*$%%'` + test "X$destdir" = "X$dest" && destdir=. + destname=`$echo "X$dest" | $Xsed -e 's%^.*/%%'` + + # Not a directory, so check to see that there is only one file specified. + set dummy $files + if test "$#" -gt 2; then + $echo "$modename: \`$dest' is not a directory" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + fi + fi + case $destdir in + [\\/]* | [A-Za-z]:[\\/]*) ;; + *) + for file in $files; do + case $file in + *.lo) ;; + *) + $echo "$modename: \`$destdir' must be an absolute directory name" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + ;; + 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. + if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : + else + $echo "$modename: \`$file' is not a valid libtool archive" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + fi + + library_names= + old_library= + relink_command= + # If there is no directory component, then add one. + case $file in + */* | *\\*) . $file ;; + *) . ./$file ;; + esac + + # 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 + + dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`/ + test "X$dir" = "X$file/" && dir= + 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 "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. + if test "$inst_prefix_dir" = "$destdir"; then + $echo "$modename: error: cannot install \`$file' to a directory not ending in $libdir" 1>&2 + exit $EXIT_FAILURE + fi + + 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 + + $echo "$modename: warning: relinking \`$file'" 1>&2 + $show "$relink_command" + if $run eval "$relink_command"; then : + else + $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2 + exit $EXIT_FAILURE + fi + fi + + # See the names of the shared library. + set dummy $library_names + if test -n "$2"; then + realname="$2" + shift + shift + + srcname="$realname" + test -n "$relink_command" && srcname="$realname"T + + # Install the shared library and build the symlinks. + $show "$install_prog $dir/$srcname $destdir/$realname" + $run eval "$install_prog $dir/$srcname $destdir/$realname" || exit $? + if test -n "$stripme" && test -n "$striplib"; then + $show "$striplib $destdir/$realname" + $run 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 + if test "$linkname" != "$realname"; then + $show "(cd $destdir && { $LN_S -f $realname $linkname || { $rm $linkname && $LN_S $realname $linkname; }; })" + $run eval "(cd $destdir && { $LN_S -f $realname $linkname || { $rm $linkname && $LN_S $realname $linkname; }; })" + fi + done + fi + + # Do each command in the postinstall commands. + lib="$destdir/$realname" + cmds=$postinstall_cmds + save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + eval cmd=\"$cmd\" + $show "$cmd" + $run eval "$cmd" || { + lt_exit=$? + + # Restore the uninstalled library and exit + if test "$mode" = relink; then + $run eval '(cd $output_objdir && $rm ${realname}T && $mv ${realname}U $realname)' + fi + + exit $lt_exit + } + done + IFS="$save_ifs" + fi + + # Install the pseudo-library for information purposes. + name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + instname="$dir/$name"i + $show "$install_prog $instname $destdir/$name" + $run 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 + destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + destfile="$destdir/$destfile" + fi + + # Deduce the name of the destination old-style object file. + case $destfile in + *.lo) + staticdest=`$echo "X$destfile" | $Xsed -e "$lo2o"` + ;; + *.$objext) + staticdest="$destfile" + destfile= + ;; + *) + $echo "$modename: cannot copy a libtool object to \`$destfile'" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + ;; + esac + + # Install the libtool object if requested. + if test -n "$destfile"; then + $show "$install_prog $file $destfile" + $run eval "$install_prog $file $destfile" || exit $? + fi + + # Install the old object if enabled. + if test "$build_old_libs" = yes; then + # Deduce the name of the old-style object file. + staticobj=`$echo "X$file" | $Xsed -e "$lo2o"` + + $show "$install_prog $staticobj $staticdest" + $run 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 + destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + 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 + file=`$echo $file|${SED} 's,.exe$,,'` + stripped_ext=".exe" + fi + ;; + esac + + # Do a test to see if this is really a libtool program. + case $host in + *cygwin*|*mingw*) + wrapper=`$echo $file | ${SED} -e 's,.exe$,,'` + ;; + *) + wrapper=$file + ;; + esac + if (${SED} -e '4q' $wrapper | grep "^# Generated by .*$PACKAGE")>/dev/null 2>&1; then + notinst_deplibs= + relink_command= + + # Note that it is not necessary on cygwin/mingw to append a dot to + # foo even if both foo 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. + # + # If there is no directory component, then add one. + case $wrapper in + */* | *\\*) . ${wrapper} ;; + *) . ./${wrapper} ;; + esac + + # Check the variables that should have been set. + if test -z "$notinst_deplibs"; then + $echo "$modename: invalid libtool wrapper script \`$wrapper'" 1>&2 + exit $EXIT_FAILURE + fi + + finalize=yes + for lib in $notinst_deplibs; do + # Check to see that each library is installed. + libdir= + if test -f "$lib"; then + # If there is no directory component, then add one. + case $lib in + */* | *\\*) . $lib ;; + *) . ./$lib ;; + esac + fi + libfile="$libdir/"`$echo "X$lib" | $Xsed -e 's%^.*/%%g'` ### testsuite: skip nested quoting test + if test -n "$libdir" && test ! -f "$libfile"; then + $echo "$modename: warning: \`$lib' has not been installed in \`$libdir'" 1>&2 + finalize=no + fi + done + + relink_command= + # Note that it is not necessary on cygwin/mingw to append a dot to + # foo even if both foo 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. + # + # If there is no directory component, then add one. + case $wrapper in + */* | *\\*) . ${wrapper} ;; + *) . ./${wrapper} ;; + esac + + outputname= + if test "$fast_install" = no && test -n "$relink_command"; then + if test "$finalize" = yes && test -z "$run"; then + tmpdir=`func_mktempdir` + file=`$echo "X$file$stripped_ext" | $Xsed -e 's%^.*/%%'` + outputname="$tmpdir/$file" + # Replace the output file specification. + relink_command=`$echo "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'` + + $show "$relink_command" + if $run eval "$relink_command"; then : + else + $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2 + ${rm}r "$tmpdir" + continue + fi + file="$outputname" + else + $echo "$modename: warning: cannot relink \`$file'" 1>&2 + fi + else + # Install the binary that we compiled earlier. + file=`$echo "X$file$stripped_ext" | $Xsed -e "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) + destfile=`$echo $destfile | ${SED} -e 's,.exe$,,'` + ;; + esac + ;; + esac + $show "$install_prog$stripme $file $destfile" + $run eval "$install_prog\$stripme \$file \$destfile" || exit $? + test -n "$outputname" && ${rm}r "$tmpdir" + ;; + esac + done + + for file in $staticlibs; do + name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + + # Set up the ranlib parameters. + oldlib="$destdir/$name" + + $show "$install_prog $file $oldlib" + $run eval "$install_prog \$file \$oldlib" || exit $? + + if test -n "$stripme" && test -n "$old_striplib"; then + $show "$old_striplib $oldlib" + $run eval "$old_striplib $oldlib" || exit $? + fi + + # Do each command in the postinstall commands. + cmds=$old_postinstall_cmds + save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + eval cmd=\"$cmd\" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + done + + if test -n "$future_libdirs"; then + $echo "$modename: warning: remember to run \`$progname --finish$future_libdirs'" 1>&2 + fi + + if test -n "$current_libdirs"; then + # Maybe just do a dry run. + test -n "$run" && current_libdirs=" -n$current_libdirs" + exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs' + else + exit $EXIT_SUCCESS + fi + ;; + + # libtool finish mode + finish) + modename="$modename: finish" + 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. + cmds=$finish_cmds + save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + eval cmd=\"$cmd\" + $show "$cmd" + $run eval "$cmd" || admincmds="$admincmds + $cmd" + done + IFS="$save_ifs" + fi + if test -n "$finish_eval"; then + # Do the single finish_eval. + eval cmds=\"$finish_eval\" + $run eval "$cmds" || admincmds="$admincmds + $cmds" + fi + done + fi + + # Exit here if they wanted silent mode. + test "$show" = : && exit $EXIT_SUCCESS + + $echo "X----------------------------------------------------------------------" | $Xsed + $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" + $echo "more information, such as the ld(1) and ld.so(8) manual pages." + $echo "X----------------------------------------------------------------------" | $Xsed + exit $EXIT_SUCCESS + ;; + + # libtool execute mode + execute) + modename="$modename: execute" + + # The first argument is the command name. + cmd="$nonopt" + if test -z "$cmd"; then + $echo "$modename: you must specify a COMMAND" 1>&2 + $echo "$help" + exit $EXIT_FAILURE + fi + + # Handle -dlopen flags immediately. + for file in $execute_dlfiles; do + if test ! -f "$file"; then + $echo "$modename: \`$file' is not a file" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + fi + + dir= + case $file in + *.la) + # Check to see that this really is a libtool archive. + if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : + else + $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + fi + + # Read the libtool library. + dlname= + library_names= + + # If there is no directory component, then add one. + case $file in + */* | *\\*) . $file ;; + *) . ./$file ;; + esac + + # Skip this library if it cannot be dlopened. + if test -z "$dlname"; then + # Warn if it was a shared library. + test -n "$library_names" && $echo "$modename: warning: \`$file' was not linked with \`-export-dynamic'" + continue + fi + + dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` + test "X$dir" = "X$file" && dir=. + + if test -f "$dir/$objdir/$dlname"; then + dir="$dir/$objdir" + else + $echo "$modename: cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 1>&2 + exit $EXIT_FAILURE + fi + ;; + + *.lo) + # Just add the directory containing the .lo file. + dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` + test "X$dir" = "X$file" && dir=. + ;; + + *) + $echo "$modename: warning \`-dlopen' is ignored for non-libtool libraries and objects" 1>&2 + 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 + -*) ;; + *) + # Do a test to see if this is really a libtool program. + if (${SED} -e '4q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then + # If there is no directory component, then add one. + case $file in + */* | *\\*) . $file ;; + *) . ./$file ;; + esac + + # Transform arg to wrapped name. + file="$progdir/$program" + fi + ;; + esac + # Quote arguments (to preserve shell metacharacters). + file=`$echo "X$file" | $Xsed -e "$sed_quote_subst"` + args="$args \"$file\"" + done + + if test -z "$run"; then + if test -n "$shlibpath_var"; then + # Export the shlibpath_var. + eval "export $shlibpath_var" + fi + + # Restore saved environment variables + if test "${save_LC_ALL+set}" = set; then + LC_ALL="$save_LC_ALL"; export LC_ALL + fi + if test "${save_LANG+set}" = set; then + LANG="$save_LANG"; export LANG + fi + + # 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 + ;; + + # libtool clean and uninstall mode + clean | uninstall) + modename="$modename: $mode" + 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 + + if test -z "$rm"; then + $echo "$modename: you must specify an RM program" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + fi + + rmdirs= + + origobjdir="$objdir" + for file in $files; do + dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` + if test "X$dir" = "X$file"; then + dir=. + objdir="$origobjdir" + else + objdir="$dir/$origobjdir" + fi + name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + 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 (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then + . $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. + cmds=$postuninstall_cmds + save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + eval cmd=\"$cmd\" + $show "$cmd" + $run eval "$cmd" + if test "$?" -ne 0 && test "$rmforce" != yes; then + exit_status=1 + fi + done + IFS="$save_ifs" + fi + + if test -n "$old_library"; then + # Do each command in the old_postuninstall commands. + cmds=$old_postuninstall_cmds + save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + eval cmd=\"$cmd\" + $show "$cmd" + $run eval "$cmd" + if test "$?" -ne 0 && test "$rmforce" != yes; then + exit_status=1 + fi + done + IFS="$save_ifs" + fi + # FIXME: should reinstall the best remaining shared library. + ;; + esac + fi + ;; + + *.lo) + # Possibly a libtool object, so verify it. + if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then + + # Read the .lo file + . $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) + file=`$echo $file|${SED} 's,.exe$,,'` + noexename=`$echo $name|${SED} 's,.exe$,,'` + # $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 (${SED} -e '4q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then + relink_command= + . $dir/$noexename + + # 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 + $show "$rm $rmfiles" + $run $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 + $show "rmdir $dir" + $run rmdir $dir >/dev/null 2>&1 + fi + done + + exit $exit_status + ;; + + "") + $echo "$modename: you must specify a MODE" 1>&2 + $echo "$generic_help" 1>&2 + exit $EXIT_FAILURE + ;; + esac + + if test -z "$exec_cmd"; then + $echo "$modename: invalid operation mode \`$mode'" 1>&2 + $echo "$generic_help" 1>&2 + exit $EXIT_FAILURE + fi +fi # test -z "$show_help" + +if test -n "$exec_cmd"; then + eval exec $exec_cmd + exit $EXIT_FAILURE +fi + +# We need to display help for each of the modes. +case $mode in +"") $echo \ +"Usage: $modename [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 + --finish same as \`--mode=finish' + --help display this help message and exit + --mode=MODE use operation mode MODE [default=inferred from MODE-ARGS] + --quiet same as \`--silent' + --silent don't print informational messages + --tag=TAG use configuration variables from tag TAG + --version print version information + +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. Try \`$modename --help --mode=MODE' for +a more detailed description of MODE. + +Report bugs to ." + exit $EXIT_SUCCESS + ;; + +clean) + $echo \ +"Usage: $modename [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: $modename [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 + -prefer-pic try to building PIC objects only + -prefer-non-pic try to building non-PIC objects only + -static always build a \`.o' file suitable for static linking + +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: $modename [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: $modename [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: $modename [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 rest of the components are interpreted as arguments to that command (only +BSD-compatible install options are recognized)." + ;; + +link) + $echo \ +"Usage: $modename [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 + -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 + -static do not do any dynamic linking of libtool libraries + -version-info CURRENT[:REVISION[:AGE]] + specify library version info [each variable defaults to 0] + +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: $modename [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." + ;; + +*) + $echo "$modename: invalid operation mode \`$mode'" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + ;; +esac + +$echo +$echo "Try \`$modename --help' for more information about other modes." + +exit $? + +# 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 +disable_libs=shared +# ### END LIBTOOL TAG CONFIG: disable-shared + +# ### BEGIN LIBTOOL TAG CONFIG: disable-static +disable_libs=static +# ### END LIBTOOL TAG CONFIG: disable-static + +# Local Variables: +# mode:shell-script +# sh-indentation:2 +# End: diff --git a/config/mkinstalldirs b/config/mkinstalldirs deleted file mode 100755 index ef7e16fd..00000000 --- a/config/mkinstalldirs +++ /dev/null @@ -1,161 +0,0 @@ -#! /bin/sh -# mkinstalldirs --- make directory hierarchy - -scriptversion=2006-05-11.19 - -# Original author: Noah Friedman -# Created: 1993-05-16 -# Public domain. -# -# This file is maintained in Automake, please report -# bugs to or send patches to -# . - -nl=' -' -IFS=" "" $nl" -errstatus=0 -dirmode= - -usage="\ -Usage: mkinstalldirs [-h] [--help] [--version] [-m MODE] DIR ... - -Create each directory DIR (with mode MODE, if specified), including all -leading file name components. - -Report bugs to ." - -# process command line arguments -while test $# -gt 0 ; do - case $1 in - -h | --help | --h*) # -h for help - echo "$usage" - exit $? - ;; - -m) # -m PERM arg - shift - test $# -eq 0 && { echo "$usage" 1>&2; exit 1; } - dirmode=$1 - shift - ;; - --version) - echo "$0 $scriptversion" - exit $? - ;; - --) # stop option processing - shift - break - ;; - -*) # unknown option - echo "$usage" 1>&2 - exit 1 - ;; - *) # first non-opt arg - break - ;; - esac -done - -for file -do - if test -d "$file"; then - shift - else - break - fi -done - -case $# in - 0) exit 0 ;; -esac - -# Solaris 8's mkdir -p isn't thread-safe. If you mkdir -p a/b and -# mkdir -p a/c at the same time, both will detect that a is missing, -# one will create a, then the other will try to create a and die with -# a "File exists" error. This is a problem when calling mkinstalldirs -# from a parallel make. We use --version in the probe to restrict -# ourselves to GNU mkdir, which is thread-safe. -case $dirmode in - '') - if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then - echo "mkdir -p -- $*" - exec mkdir -p -- "$@" - else - # On NextStep and OpenStep, the `mkdir' command does not - # recognize any option. It will interpret all options as - # directories to create, and then abort because `.' already - # exists. - test -d ./-p && rmdir ./-p - test -d ./--version && rmdir ./--version - fi - ;; - *) - if mkdir -m "$dirmode" -p --version . >/dev/null 2>&1 && - test ! -d ./--version; then - echo "mkdir -m $dirmode -p -- $*" - exec mkdir -m "$dirmode" -p -- "$@" - else - # Clean up after NextStep and OpenStep mkdir. - for d in ./-m ./-p ./--version "./$dirmode"; - do - test -d $d && rmdir $d - done - fi - ;; -esac - -for file -do - case $file in - /*) pathcomp=/ ;; - *) pathcomp= ;; - esac - oIFS=$IFS - IFS=/ - set fnord $file - shift - IFS=$oIFS - - for d - do - test "x$d" = x && continue - - pathcomp=$pathcomp$d - case $pathcomp in - -*) pathcomp=./$pathcomp ;; - esac - - if test ! -d "$pathcomp"; then - echo "mkdir $pathcomp" - - mkdir "$pathcomp" || lasterr=$? - - if test ! -d "$pathcomp"; then - errstatus=$lasterr - else - if test ! -z "$dirmode"; then - echo "chmod $dirmode $pathcomp" - lasterr= - chmod "$dirmode" "$pathcomp" || lasterr=$? - - if test ! -z "$lasterr"; then - errstatus=$lasterr - fi - fi - fi - fi - - pathcomp=$pathcomp/ - done -done - -exit $errstatus - -# Local Variables: -# mode: shell-script -# sh-indentation: 2 -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "scriptversion=" -# time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-end: "$" -# End: diff --git a/configure.ac b/configure.ac index 2823ecd7..a6616c8f 100644 --- a/configure.ac +++ b/configure.ac @@ -1,19 +1,22 @@ # Process this file with autoconf to produce a configure script. +# $Id$ # # autoconf setup # AC_PREREQ(2.53) -AC_INIT([yasm], - m4_esyscmd([./YASM-VERSION-GEN.sh && tr -d '\n' @@ -166,7 +157,7 @@ if test "$USE_MAINTAINER_MODE" = "yes"; then MORE_CFLAGS="$MORE_CFLAGS -Wcast-align" MORE_CFLAGS="$MORE_CFLAGS -Wcast-qual" MORE_CFLAGS="$MORE_CFLAGS -Wchar-subscripts" -# MORE_CFLAGS="$MORE_CFLAGS -Wconversion" + MORE_CFLAGS="$MORE_CFLAGS -Wconversion" # MORE_CFLAGS="$MORE_CFLAGS -Wdeclaration-after-statement" # MORE_CFLAGS="$MORE_CFLAGS -Wendif-labels" MORE_CFLAGS="$MORE_CFLAGS -Winline" @@ -225,81 +216,28 @@ if test "$USE_MAINTAINER_MODE" = "yes"; then fi AC_SUBST(MORE_CFLAGS) +# +# Cross-building +# +if test "$cross_compiling" = "yes"; then + AC_MSG_CHECKING([cc for build]) + CC_FOR_BUILD="${CC_FOR_BUILD-PATH=/usr/bin:$PATH cc}" + AC_MSG_RESULT($CC_FOR_BUILD) + CCLD_FOR_BUILD="$CC_FOR_BUILD" +else + CC_FOR_BUILD="${CC_FOR_BUILD-$CC}" + CCLD_FOR_BUILD="${CCLD_FOR_BUILD-$CC}" +fi + AC_ARG_VAR(CC_FOR_BUILD,[build system C compiler]) AC_ARG_VAR(CCLD_FOR_BUILD,[build system C linker frontend]) -if test "${build}" != "${host}" ; then - CC_FOR_BUILD=${CC_FOR_BUILD-cc} - CCLD_FOR_BUILD=${CCLD_FOR_BUILD-cc} -else - CC_FOR_BUILD="\$(CC)" - CCLD_FOR_BUILD="\$(CC)" -fi AC_SUBST(CC_FOR_BUILD) AC_SUBST(CCLD_FOR_BUILD) -AC_ARG_VAR(CPP_FOR_HOST,[host system C preprocessor]) -if test "$build" != "$target" || test "$build" != "$host"; then - CPP_PROG="${CPP_FOR_HOST-cc -E}" -else - CPP_PROG="${CPP}" -fi -AC_DEFINE_UNQUOTED([CPP_PROG], "${CPP_PROG}", [Command name to run C preprocessor]) - -# Detect if we have Python -if test x$enable_python = xno; then - have_python=no -else - AC_MSG_NOTICE([Checking for Python]) - have_python=no - AM_PATH_PYTHON(2.4,[],[AC_MSG_WARN([Python not found])]) - - if test -z "$PYTHON" || test "$PYTHON" = : ; then - have_python=no - else - have_python=yes - fi - - if test x$have_python = xno ; then - if test x$enable_python = xyes ; then - AC_MSG_ERROR([Python explicitly requested, but a suitable Python version was not found]) - else - AC_MSG_WARN([Could not find a suitable version of Python]) - fi - fi -fi - -# Detect if we can build Python bindings -# (needs Python, Python headers, and Cython) -if test x$enable_python_bindings = xno; then - have_python_bindings=no -else - AC_MSG_NOTICE([Checking to see if we can build Python bindings]) - have_python_bindings=no - if test x$have_python = xyes; then - AC_MSG_CHECKING([for Cython >= 0.11.3]) - CYTHON_CHECK_VERSION(0.11.3, [AC_MSG_RESULT(yes) - have_cython=yes], - [AC_MSG_RESULT(no) - have_cython=no]) - - AM_CHECK_PYTHON_HEADERS(have_python_headers=yes,have_python_headers=no) - - if test x$have_cython = xyes -a x$have_python_headers = xyes ; then - have_python_bindings=yes - fi - fi - - if test x$have_python_bindings = xno ; then - if test x$enable_python_bindings = xyes ; then - AC_MSG_ERROR([Building Python bindings explicitly requested, but can't build Python bindings because either Cython, Python headers or a suitable Python version was not found]) - else - AC_MSG_WARN([Couldn't find either Cython, the Python headers or a suitable version of Python, not building Python bindings]) - fi - fi -fi - -AM_CONDITIONAL(HAVE_PYTHON, test x$have_python = xyes) -AM_CONDITIONAL(HAVE_PYTHON_BINDINGS, test x$have_python_bindings = xyes) +# libtool erroneously calls CC_FOR_BUILD HOST_CC; +# --host is the platform that the package is compiled for. +HOST_CC="$CC_FOR_BUILD" +AC_SUBST(HOST_CC) AC_CONFIG_FILES([Makefile po/Makefile.in diff --git a/frontends/CMakeLists.txt b/frontends/CMakeLists.txt deleted file mode 100644 index 9858b616..00000000 --- a/frontends/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -ADD_SUBDIRECTORY(yasm) -ADD_SUBDIRECTORY(tasm) -ADD_SUBDIRECTORY(vsyasm) diff --git a/frontends/Makefile.inc b/frontends/Makefile.inc index 295639e8..832a2f0b 100644 --- a/frontends/Makefile.inc +++ b/frontends/Makefile.inc @@ -1,7 +1,5 @@ +# $Id$ + EXTRA_DIST += frontends/yasm/Makefile.inc -EXTRA_DIST += frontends/tasm/Makefile.inc -EXTRA_DIST += frontends/vsyasm/Makefile.inc include frontends/yasm/Makefile.inc -include frontends/tasm/Makefile.inc -include frontends/vsyasm/Makefile.inc diff --git a/frontends/tasm/CMakeLists.txt b/frontends/tasm/CMakeLists.txt deleted file mode 100644 index 627f9f2f..00000000 --- a/frontends/tasm/CMakeLists.txt +++ /dev/null @@ -1,39 +0,0 @@ -INCLUDE_DIRECTORIES( - ${CMAKE_CURRENT_BINARY_DIR} - ${yasm_SOURCE_DIR}/frontends/yasm - ) - -ADD_CUSTOM_COMMAND( - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/license.c - COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/frontends/yasm/genstring.py - license_msg - ${CMAKE_CURRENT_BINARY_DIR}/license.c - ${CMAKE_SOURCE_DIR}/COPYING - MAIN_DEPENDENCY ${CMAKE_SOURCE_DIR}/COPYING - DEPENDS ${CMAKE_SOURCE_DIR}/frontends/yasm/genstring.py - ) - -SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}) - -IF(BUILD_SHARED_LIBS) - ADD_EXECUTABLE(ytasm - tasm.c - tasm-options.c - ${yasm_SOURCE_DIR}/frontends/yasm/yasm-plugin.c - ) - TARGET_LINK_LIBRARIES(ytasm libyasm ${LIBDL}) -ELSE(BUILD_SHARED_LIBS) - ADD_EXECUTABLE(ytasm - tasm.c - tasm-options.c - ) - TARGET_LINK_LIBRARIES(ytasm yasmstd libyasm) - ADD_DEPENDENCIES(ytasm yasmstd) - SET_PROPERTY(TARGET ytasm APPEND PROPERTY BUILD_RPATH "$") -ENDIF(BUILD_SHARED_LIBS) - -SET_SOURCE_FILES_PROPERTIES(tasm.c PROPERTIES - OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/license.c - ) - -INSTALL(TARGETS ytasm RUNTIME DESTINATION bin) diff --git a/frontends/tasm/Makefile.inc b/frontends/tasm/Makefile.inc deleted file mode 100644 index 9826e1b9..00000000 --- a/frontends/tasm/Makefile.inc +++ /dev/null @@ -1,7 +0,0 @@ -bin_PROGRAMS += ytasm - -ytasm_SOURCES = frontends/tasm/tasm.c -ytasm_SOURCES += frontends/tasm/tasm-options.c -ytasm_SOURCES += frontends/tasm/tasm-options.h - -ytasm_LDADD = libyasm.a $(INTLLIBS) diff --git a/frontends/tasm/tasm-options.c b/frontends/tasm/tasm-options.c deleted file mode 100644 index 941b16ef..00000000 --- a/frontends/tasm/tasm-options.c +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Generic Options Support Header File - * - * Copyright (c) 2001 Stanislav Karchebny - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the names of other contributors - * may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND OTHER CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR OTHER CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -#include -#include - -#include "tasm-options.h" - - -#ifdef __DEBUG__ -#define DEBUG(x) fprintf ## x ; -#else -#define DEBUG(x) -#endif - - -/* Options Parser */ -int -parse_cmdline(int argc, char **argv, opt_option *options, size_t nopts, - void (*print_error) (const char *fmt, ...)) -{ - int errors = 0, warnings = 0; - size_t i; - int got_it; - - DEBUG((stderr, "parse_cmdline: entered\n")); - - fail: - while (--argc) { - argv++; - - if (argv[0][0] == '/' && argv[0][1]) { /* opt */ - got_it = 0; - for (i = 0; i < nopts; i++) { - char *cmd = &argv[0][1]; - size_t len = strlen(options[i].opt); - if (yasm__strncasecmp(cmd, options[i].opt, len) == 0) { - char *param; - - param = &argv[0][1+len]; - if (options[i].takes_param) { - if (param[0] != '\0') { - /* do nothing */ - } else if (argc > 1) { - param = argv[1]; - argc--; - argv++; - } else { - print_error( - _("option `-%s' needs an argument!"), - options[i].opt); - errors++; - goto fail; - } - } else - param = NULL; - - if (!options[i].handler(cmd, param, options[i].extra)) - got_it = 1; - break; - } - } - if (!got_it) { - print_error(_("warning: unrecognized option `%s'"), - argv[0]); - warnings++; - } - } else { /* not an option, then it should be a file or something */ - - if (not_an_option_handler(argv[0])) - errors++; - } - } - - (void) warnings; - - DEBUG((stderr, "parse_cmdline: finished\n")); - return errors; -} - -void -help_msg(const char *msg, const char *tail, opt_option *options, size_t nopts) -{ - char optbuf[100]; - size_t i; - - printf("%s", gettext(msg)); - - for (i = 0; i < nopts; i++) { - optbuf[0] = 0; - - if (options[i].takes_param) { - if (options[i].opt) - sprintf(optbuf, "/%s <%s>", options[i].opt, - options[i].param_desc ? options[i]. - param_desc : _("param")); - } else { - if (options[i].opt) - sprintf(optbuf, "/%s", options[i].opt); - } - - printf(" %-22s %s\n", optbuf, gettext(options[i].description)); - } - - printf("%s", gettext(tail)); -} diff --git a/frontends/tasm/tasm-options.h b/frontends/tasm/tasm-options.h deleted file mode 100644 index 082409fc..00000000 --- a/frontends/tasm/tasm-options.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Generic Options Support Header File - * - * Copyright (c) 2001 Stanislav Karchebny - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND OTHER CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR OTHER CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -#ifndef TASM_OPTIONS_H -#define TASM_OPTIONS_H - -/* an option structure - * operate on either -sopt, --lopt, -sopt or --lopt= - */ -typedef struct opt_option_s -{ - /* option */ - const char *opt; - - /* !=0 if option requires parameter, 0 if not */ - int takes_param; - - int (*handler) (char *cmd, /*@null@*/ char *param, int extra); - int extra; /* extra value for handler */ - - /* description to use in help_msg() */ - /*@observer@*/ const char *description; - - /* optional description for the param taken (NULL if not present) */ - /* (short - will be printed after option sopt/lopt) */ - /*@observer@*/ /*@null@*/ const char *param_desc; -} opt_option; - -/* handle everything that is not an option */ -int not_an_option_handler(char *param); - -/* parse command line calling handlers when appropriate - * argc, argv - pass directly from main(argc,argv) - * options - array of options - * nopts - options count - */ -int parse_cmdline(int argc, char **argv, opt_option *options, size_t nopts, - void (*print_error) (const char *fmt, ...)); - -/* display help message msg followed by list of options in options and followed - * by tail - */ -void help_msg(const char *msg, const char *tail, opt_option *options, - size_t nopts); - -#endif diff --git a/frontends/tasm/tasm.c b/frontends/tasm/tasm.c deleted file mode 100644 index 9558594e..00000000 --- a/frontends/tasm/tasm.c +++ /dev/null @@ -1,1011 +0,0 @@ -/* - * Program entry point, command line parsing - * - * Copyright (C) 2001-2008 Peter Johnson - * Copyright (C) 2007-2008 Samuel Thibault - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND OTHER CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR OTHER CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -#include - -#include -#include -#include -#include - -#ifdef HAVE_LIBGEN_H -#include -#endif - -#include "tasm-options.h" - -#if defined(CMAKE_BUILD) && defined(BUILD_SHARED_LIBS) -#include "yasm-plugin.h" -#endif - -#include "license.c" - -#define DEFAULT_OBJFMT_MODULE "bin" - -#if defined(CMAKE_BUILD) && !defined(BUILD_SHARED_LIBS) -void yasm_init_plugin(void); -#endif - -/*@null@*/ /*@only@*/ static char *obj_filename = NULL, *in_filename = NULL; -/*@null@*/ /*@only@*/ static char *list_filename = NULL, *xref_filename = NULL; -/*@null@*/ /*@only@*/ static char *machine_name = NULL; -static int special_options = 0; -static int segment_ordering = 0; -static int cross_reference = 0; -static int floating_point = 0; -static int listing = 0; -static int expanded_listing = 0; -static int case_sensitivity = 0; -static int valid_length = -1; -/*@null@*/ /*@dependent@*/ static yasm_arch *cur_arch = NULL; -/*@null@*/ /*@dependent@*/ static const yasm_arch_module * - cur_arch_module = NULL; -/*@null@*/ /*@dependent@*/ static const yasm_parser_module * - cur_parser_module = NULL; -/*@null@*/ /*@dependent@*/ static yasm_preproc *cur_preproc = NULL; -/*@null@*/ /*@dependent@*/ static const yasm_preproc_module * - cur_preproc_module = NULL; -/*@null@*/ static char *objfmt_keyword = NULL; -/*@null@*/ /*@dependent@*/ static const yasm_objfmt_module * - cur_objfmt_module = NULL; -/*@null@*/ /*@dependent@*/ static const yasm_dbgfmt_module * - cur_dbgfmt_module = NULL; -/*@null@*/ /*@dependent@*/ static yasm_listfmt *cur_listfmt = NULL; -/*@null@*/ /*@dependent@*/ static const yasm_listfmt_module * - cur_listfmt_module = NULL; -static int warning_error = 0; /* warnings being treated as errors */ -static FILE *errfile; -/*@null@*/ /*@only@*/ static char *error_filename = NULL; - -/*@null@*/ /*@dependent@*/ static FILE *open_file(const char *filename, - const char *mode); -static void check_errors(/*@only@*/ yasm_errwarns *errwarns, - /*@only@*/ yasm_object *object, - /*@only@*/ yasm_linemap *linemap); -static void cleanup(/*@null@*/ /*@only@*/ yasm_object *object); - -/* Forward declarations: cmd line parser handlers */ -static int opt_special_handler(char *cmd, /*@null@*/ char *param, int extra); -static int opt_segment_ordering_handler(char *cmd, /*@null@*/ char *param, int extra); -static int opt_cross_reference_handler(char *cmd, /*@null@*/ char *param, int extra); -static int opt_floating_point_handler(char *cmd, /*@null@*/ char *param, int extra); -static int opt_ignore(char *cmd, /*@null@*/ char *param, int extra); -static int opt_listing_handler(char *cmd, /*@null@*/ char *param, int extra); -static int opt_case_handler(char *cmd, /*@null@*/ char *param, int extra); -static int opt_valid_length_handler(char *cmd, /*@null@*/ char *param, int extra); - -static int opt_warning_handler(char *cmd, /*@null@*/ char *param, int extra); -static int opt_preproc_option(char *cmd, /*@null@*/ char *param, int extra); -static int opt_exe_handler(char *cmd, /*@null@*/ char *param, int extra); - -static /*@only@*/ char *replace_extension(const char *orig, /*@null@*/ - const char *ext, const char *def); -static void print_error(const char *fmt, ...); - -static /*@exits@*/ void handle_yasm_int_error(const char *file, - unsigned int line, - const char *message); -static /*@exits@*/ void handle_yasm_fatal(const char *message, va_list va); -static const char *handle_yasm_gettext(const char *msgid); -static void print_yasm_error(const char *filename, unsigned long line, - const char *msg, /*@null@*/ const char *xref_fn, - unsigned long xref_line, - /*@null@*/ const char *xref_msg); -static void print_yasm_warning(const char *filename, unsigned long line, - const char *msg); - -static void apply_preproc_builtins(void); -static void apply_preproc_standard_macros(const yasm_stdmac *stdmacs); -static void apply_preproc_saved_options(void); -static void print_list_keyword_desc(const char *name, const char *keyword); - -/* values for special_options */ -#define SPECIAL_SHOW_HELP 0x01 -#define SPECIAL_SHOW_VERSION 0x02 -#define SPECIAL_SHOW_LICENSE 0x04 - -#define SEGMENT_ORDERING_ALPHABETIC 0x01 -#define SEGMENT_ORDERING_SOURCE 0x02 - -#define FP_EMULATED 0x01 -#define FP_REAL 0x02 - -#define CASE_ALL 0x01 -#define CASE_GLOBALS 0x02 -#define CASE_NONE 0x04 - -#define DEBUG_FULL 0x01 -#define DEBUG_LINES 0x02 -#define DEBUG_NONE 0x04 - -/* command line options */ -static opt_option options[] = -{ - { "version", 0, opt_special_handler, SPECIAL_SHOW_VERSION, - N_("show version text"), NULL }, - { "license", 0, opt_special_handler, SPECIAL_SHOW_LICENSE, - N_("show license text"), NULL }, - { "a", 0, opt_segment_ordering_handler, SEGMENT_ORDERING_ALPHABETIC, - N_("Alphabetic segment ordering"), NULL }, - { "s", 0, opt_segment_ordering_handler, SEGMENT_ORDERING_SOURCE, - N_("Source segment ordering"), NULL }, - - { "c", 0, opt_cross_reference_handler, 0, - N_("Generate cross-reference in listing"), NULL }, - - { "d", 1, opt_preproc_option, 2, - N_("pre-define a macro, optionally to value"), N_("macro[=value]") }, - - { "e", 0, opt_floating_point_handler, FP_EMULATED, - N_("Emulated floating-point instructions (not supported)"), NULL }, - { "r", 0, opt_floating_point_handler, FP_REAL, - N_("Real floating-point instructions"), NULL }, - - { "h", 0, opt_special_handler, SPECIAL_SHOW_HELP, - N_("show help text"), NULL }, - { "?", 0, opt_special_handler, SPECIAL_SHOW_HELP, - N_("show help text"), NULL }, - - { "i", 1, opt_preproc_option, 0, - N_("add include path"), N_("path") }, - - { "j", 1, opt_ignore, 0, - N_("Jam in an assemble directive CMD (eg. /jIDEAL) (not supported)"), NULL }, - - { "k", 1, opt_ignore, 0, - N_("Hash table capacity (ignored)"), N_("# symbols") }, - - { "l", 0, opt_listing_handler, 0, - N_("Generate listing"), N_("l=normal listing, la=expanded listing") }, - - { "ml", 0, opt_case_handler, CASE_ALL, - N_("Case sensitivity on all symbols"), NULL }, - { "mx", 0, opt_case_handler, CASE_GLOBALS, - N_("Case sensitivity on global symbols"), NULL }, - { "mu", 0, opt_case_handler, CASE_NONE, - N_("No case sensitivity on symbols"), NULL }, - { "mv", 0, opt_valid_length_handler, 0, - N_("Set maximum valid length for symbols"), N_("length") }, - - { "m", 1, opt_ignore, 0, - N_("Allow multiple passes to resolve forward reference (ignored)"), N_("number of passes") }, - - { "n", 0, opt_ignore, 0, - N_("Suppress symbol tables in listing"), NULL }, - - { "o", 0, opt_ignore, 0, - N_("Object code"), N_("os: standard, o: standard w/overlays, op: Phar Lap, oi: IBM") }, - - { "p", 0, opt_ignore, 0, - N_("Check for code segment overrides in protected mode"), NULL }, - { "q", 0, opt_ignore, 0, - N_("Suppress OBJ records not needed for linking (ignored)"), NULL }, - { "t", 0, opt_ignore, 0, - N_("Suppress messages if successful assembly"), NULL }, - { "u", 0, opt_ignore, 0, - N_("Set version emulation"), N_("Version") }, - { "w", 1, opt_warning_handler, 0, - N_("Set warning level"), N_("w0=none, w1=w2=warnings on, w-xxx/w+xxx=disable/enable warning xxx") }, - { "x", 0, opt_ignore, 0, - N_("Include false conditionals in listing"), NULL }, - { "zi", 0, opt_ignore, DEBUG_FULL, - N_("Full debug info"), NULL }, - { "zd", 0, opt_ignore, DEBUG_LINES, - N_("Line numbers debug info"), NULL }, - { "zn", 0, opt_ignore, DEBUG_NONE, - N_("No debug info"), NULL }, - { "z", 0, opt_ignore, 0, - N_("Display source line with error message (ignored)"), NULL }, - - { "b", 0, opt_exe_handler, 0, - N_("Build a (very) basic .exe file"), NULL }, -}; - -/* version message */ -/*@observer@*/ static const char *version_msg[] = { - PACKAGE_STRING, - "Copyright (c) 2001-2010 Peter Johnson and other Yasm developers.", - "Run yasm --license for licensing overview and summary." -}; - -/* help messages */ -/*@observer@*/ static const char *help_head = N_( - "usage: tasm [option]* source [,object] [,listing] [,xref] \n" - "Options:\n"); -/*@observer@*/ static const char *help_tail = N_( - "\n" - "source is asm source to be assembled.\n" - "\n" - "Sample invocation:\n" - " tasm /zi source.asm\n" - "\n" - "Report bugs to bug-yasm@tortall.net\n"); - -/* parsed command line storage until appropriate modules have been loaded */ -typedef STAILQ_HEAD(constcharparam_head, constcharparam) constcharparam_head; - -typedef struct constcharparam { - STAILQ_ENTRY(constcharparam) link; - const char *param; - int id; -} constcharparam; - -static constcharparam_head preproc_options; - -static int -do_assemble(void) -{ - yasm_object *object; - const char *base_filename; - /*@null@*/ FILE *obj = NULL; - yasm_arch_create_error arch_error; - yasm_linemap *linemap; - yasm_errwarns *errwarns = yasm_errwarns_create(); - int i, matched; - - /* Initialize line map */ - linemap = yasm_linemap_create(); - yasm_linemap_set(linemap, in_filename, 0, 1, 1); - - /* determine the object filename if not specified */ - if (!obj_filename) { - if (in_filename == NULL) - /* Default to yasm.out if no obj filename specified */ - obj_filename = yasm__xstrdup("yasm.out"); - else { - /* replace (or add) extension to base filename */ - yasm__splitpath(in_filename, &base_filename); - if (base_filename[0] == '\0') - obj_filename = yasm__xstrdup("yasm.out"); - else - obj_filename = replace_extension(base_filename, - "obj", - "yasm.out"); - } - } - - cur_arch = yasm_arch_create(cur_arch_module, machine_name, - cur_parser_module->keyword, &arch_error); - if (!cur_arch) { - switch (arch_error) { - case YASM_ARCH_CREATE_BAD_MACHINE: - print_error(_("%s: `%s' is not a valid %s for %s `%s'"), - _("FATAL"), machine_name, _("machine"), - _("architecture"), cur_arch_module->keyword); - break; - case YASM_ARCH_CREATE_BAD_PARSER: - print_error(_("%s: `%s' is not a valid %s for %s `%s'"), - _("FATAL"), cur_parser_module->keyword, - _("parser"), _("architecture"), - cur_arch_module->keyword); - break; - default: - print_error(_("%s: unknown architecture error"), _("FATAL")); - } - - return EXIT_FAILURE; - } - - /* Create object */ - object = yasm_object_create(in_filename, obj_filename, cur_arch, - cur_objfmt_module, cur_dbgfmt_module); - if (!object) { - yasm_error_class eclass; - unsigned long xrefline; - /*@only@*/ /*@null@*/ char *estr, *xrefstr; - - yasm_error_fetch(&eclass, &estr, &xrefline, &xrefstr); - print_error("%s: %s", _("FATAL"), estr); - yasm_xfree(estr); - yasm_xfree(xrefstr); - - cleanup(object); - return EXIT_FAILURE; - } - - /* Get a fresh copy of objfmt_module as it may have changed. */ - cur_objfmt_module = ((yasm_objfmt_base *)object->objfmt)->module; - - /* Check to see if the requested preprocessor is in the allowed list - * for the active parser. - */ - matched = 0; - for (i=0; cur_parser_module->preproc_keywords[i]; i++) - if (yasm__strcasecmp(cur_parser_module->preproc_keywords[i], - cur_preproc_module->keyword) == 0) - matched = 1; - if (!matched) { - print_error(_("%s: `%s' is not a valid %s for %s `%s'"), _("FATAL"), - cur_preproc_module->keyword, _("preprocessor"), - _("parser"), cur_parser_module->keyword); - cleanup(object); - return EXIT_FAILURE; - } - - cur_preproc = yasm_preproc_create(cur_preproc_module, in_filename, - object->symtab, linemap, errwarns); - - apply_preproc_builtins(); - apply_preproc_standard_macros(cur_parser_module->stdmacs); - apply_preproc_standard_macros(cur_objfmt_module->stdmacs); - apply_preproc_saved_options(); - - /* Get initial x86 BITS setting from object format */ - if (yasm__strcasecmp(cur_arch_module->keyword, "x86") == 0) { - yasm_arch_set_var(cur_arch, "mode_bits", - cur_objfmt_module->default_x86_mode_bits); - } - - /* Parse! */ - cur_parser_module->do_parse(object, cur_preproc, list_filename != NULL, - linemap, errwarns); - - check_errors(errwarns, object, linemap); - - /* Finalize parse */ - yasm_object_finalize(object, errwarns); - check_errors(errwarns, object, linemap); - - /* Optimize */ - yasm_object_optimize(object, errwarns); - check_errors(errwarns, object, linemap); - - /* generate any debugging information */ - yasm_dbgfmt_generate(object, linemap, errwarns); - check_errors(errwarns, object, linemap); - - /* open the object file for output (if not already opened by dbg objfmt) */ - if (!obj && yasm__strcasecmp(cur_objfmt_module->keyword, "dbg") != 0) { - obj = open_file(obj_filename, "wb"); - if (!obj) { - cleanup(object); - return EXIT_FAILURE; - } - } - - /* Write the object file */ - yasm_objfmt_output(object, obj?obj:stderr, - yasm__strcasecmp(cur_dbgfmt_module->keyword, "null"), - errwarns); - - /* Close object file */ - if (obj) - fclose(obj); - - /* If we had an error at this point, we also need to delete the output - * object file (to make sure it's not left newer than the source). - */ - if (yasm_errwarns_num_errors(errwarns, warning_error) > 0) - remove(obj_filename); - check_errors(errwarns, object, linemap); - - /* Open and write the list file */ - if (list_filename) { - FILE *list = open_file(list_filename, "wt"); - if (!list) { - cleanup(object); - return EXIT_FAILURE; - } - /* Initialize the list format */ - cur_listfmt = yasm_listfmt_create(cur_listfmt_module, in_filename, - obj_filename); - yasm_listfmt_output(cur_listfmt, list, linemap, cur_arch); - fclose(list); - } - - yasm_errwarns_output_all(errwarns, linemap, warning_error, - print_yasm_error, print_yasm_warning); - - yasm_linemap_destroy(linemap); - yasm_errwarns_destroy(errwarns); - cleanup(object); - return EXIT_SUCCESS; -} - -/* main function */ -/*@-globstate -unrecog@*/ -int -main(int argc, char *argv[]) -{ - size_t i; - - errfile = stderr; - -#if defined(HAVE_SETLOCALE) && defined(HAVE_LC_MESSAGES) - setlocale(LC_MESSAGES, ""); -#endif -#if defined(LOCALEDIR) - bindtextdomain(PACKAGE, LOCALEDIR); -#endif - textdomain(PACKAGE); - - /* Initialize errwarn handling */ - yasm_internal_error_ = handle_yasm_int_error; - yasm_fatal = handle_yasm_fatal; - yasm_gettext_hook = handle_yasm_gettext; - yasm_errwarn_initialize(); - - /* Initialize BitVector (needed for intnum/floatnum). */ - if (BitVector_Boot() != ErrCode_Ok) { - print_error(_("%s: could not initialize BitVector"), _("FATAL")); - return EXIT_FAILURE; - } - - /* Initialize intnum and floatnum */ - yasm_intnum_initialize(); - yasm_floatnum_initialize(); - -#ifdef CMAKE_BUILD - /* Load standard modules */ -#ifdef BUILD_SHARED_LIBS - if (!load_plugin("yasmstd")) { - print_error(_("%s: could not load standard modules"), _("FATAL")); - return EXIT_FAILURE; - } -#else - yasm_init_plugin(); -#endif -#endif - - /* Initialize parameter storage */ - STAILQ_INIT(&preproc_options); - - if (parse_cmdline(argc, argv, options, NELEMS(options), print_error)) - return EXIT_FAILURE; - - switch (special_options) { - case SPECIAL_SHOW_HELP: - /* Does gettext calls internally */ - help_msg(help_head, help_tail, options, NELEMS(options)); - return EXIT_SUCCESS; - case SPECIAL_SHOW_VERSION: - for (i=0; idefault_machine_keyword); - - /* Check for arch help */ - if (machine_name && strcmp(machine_name, "help") == 0) { - const yasm_arch_machine *m = cur_arch_module->machines; - printf(_("Available %s for %s `%s':\n"), _("machines"), - _("architecture"), cur_arch_module->keyword); - while (m->keyword && m->name) { - print_list_keyword_desc(m->name, m->keyword); - m++; - } - return EXIT_SUCCESS; - } - - cur_parser_module = yasm_load_parser("tasm"); - if (!cur_parser_module) { - print_error(_("%s: could not load %s"), _("FATAL"), - _("parser")); - cleanup(NULL); - return EXIT_FAILURE; - } - - /* If not already specified, default to the parser's default preproc. */ - if (!cur_preproc_module) { - cur_preproc_module = - yasm_load_preproc(cur_parser_module->default_preproc_keyword); - if (!cur_preproc_module) { - print_error(_("%s: could not load default %s"), _("FATAL"), - _("preprocessor")); - cleanup(NULL); - return EXIT_FAILURE; - } - } - - /* Determine input filename and open input file. */ - if (!in_filename) { - print_error(_("No input files specified")); - return EXIT_FAILURE; - } - - /* If list file enabled, make sure we have a list format loaded. */ - if (list_filename) { - /* use nasm as the list format. */ - cur_listfmt_module = yasm_load_listfmt("nasm"); - } - - /* If not already specified, default to null as the debug format. */ - if (!cur_dbgfmt_module) { - cur_dbgfmt_module = yasm_load_dbgfmt("null"); - if (!cur_dbgfmt_module) { - print_error(_("%s: could not load default %s"), _("FATAL"), - _("debug format")); - return EXIT_FAILURE; - } - } - - return do_assemble(); -} -/*@=globstate =unrecog@*/ - -/* Open the object file. Returns 0 on failure. */ -static FILE * -open_file(const char *filename, const char *mode) -{ - FILE *f; - - f = fopen(filename, mode); - if (!f) - print_error(_("could not open file `%s'"), filename); - return f; -} - -static void -check_errors(yasm_errwarns *errwarns, yasm_object *object, - yasm_linemap *linemap) -{ - if (yasm_errwarns_num_errors(errwarns, warning_error) > 0) { - yasm_errwarns_output_all(errwarns, linemap, warning_error, - print_yasm_error, print_yasm_warning); - yasm_linemap_destroy(linemap); - yasm_errwarns_destroy(errwarns); - cleanup(object); - exit(EXIT_FAILURE); - } -} - -/* Define DO_FREE to 1 to enable deallocation of all data structures. - * Useful for detecting memory leaks, but slows down execution unnecessarily - * (as the OS will free everything we miss here). - */ -#define DO_FREE 1 - -/* Cleans up all allocated structures. */ -static void -cleanup(yasm_object *object) -{ - if (DO_FREE) { - if (cur_listfmt) - yasm_listfmt_destroy(cur_listfmt); - if (cur_preproc) - yasm_preproc_destroy(cur_preproc); - if (object) - yasm_object_destroy(object); - - yasm_floatnum_cleanup(); - yasm_intnum_cleanup(); - - yasm_errwarn_cleanup(); - - BitVector_Shutdown(); - } - - if (DO_FREE) { - if (in_filename) - yasm_xfree(in_filename); - if (obj_filename) - yasm_xfree(obj_filename); - if (list_filename) - yasm_xfree(list_filename); - if (xref_filename) - yasm_xfree(xref_filename); - if (machine_name) - yasm_xfree(machine_name); - if (objfmt_keyword) - yasm_xfree(objfmt_keyword); - } - - if (errfile != stderr && errfile != stdout) - fclose(errfile); -#if defined(CMAKE_BUILD) && defined(BUILD_SHARED_LIBS) - unload_plugins(); -#endif -} - -/* - * Command line options handlers - */ -static char ** const filenames[] = { - &in_filename, &obj_filename, &list_filename, &xref_filename, NULL -}, ** const * cur_filename = &filenames[0]; - -static int filename_handler(char *param) { - if (!*cur_filename) { - print_error(_("error: too many files on command line.")); - return 1; - } - - if (*param) - **cur_filename = yasm__xstrdup(param); - - return 0; -} -int -not_an_option_handler(char *param) { - char *c, *d = param; - - while ((c = strchr(d, ','))) { - *c = '\0'; - if (filename_handler(d)) - return 1; - d = c + 1; - cur_filename++; - } - filename_handler(d); - return 0; -} - -static int -opt_special_handler(/*@unused@*/ char *cmd, /*@unused@*/ char *param, int extra) -{ - if (special_options == 0) - special_options = extra; - return 0; -} - -static int -opt_segment_ordering_handler(/*@unused@*/ char *cmd, /*@unused@*/ char *param, int extra) -{ - segment_ordering = extra; - return 0; -} - -static int -opt_cross_reference_handler(/*@unused@*/ char *cmd, /*@unused@*/ char *param, int extra) -{ - cross_reference = 1; - return 0; -} - -static int -opt_floating_point_handler(/*@unused@*/ char *cmd, /*@unused@*/ char *param, int extra) -{ - floating_point = extra; - return 0; -} - -static int -opt_ignore(/*@unused@*/ char *cmd, /*@unused@*/ char *param, int extra) -{ - return 0; -} - -static int -opt_listing_handler(/*@unused@*/ char *cmd, /*@unused@*/ char *param, int extra) -{ - if (param && param[0]) { - if (param[0] != 'a') - return 1; - expanded_listing = 1; - } - listing = 1; - return 0; -} - -static int -opt_case_handler(/*@unused@*/ char *cmd, /*@unused@*/ char *param, int extra) -{ - case_sensitivity = extra; - return 0; -} - -static int -opt_valid_length_handler(/*@unused@*/ char *cmd, /*@unused@*/ char *param, int extra) -{ - valid_length = atoi(param); - return 0; -} - -static int -opt_warning_handler(char *cmd, /*@unused@*/ char *param, int extra) -{ - /* is it disabling the warning instead of enabling? */ - void (*action)(yasm_warn_class wclass) = NULL; - - if (cmd[0] == '0') { - /* /w0, disable warnings */ - yasm_warn_disable_all(); - return 0; - } - - if (cmd[0] == '1' || cmd[0] == '2') { - /* /w[12], enable warnings */ - yasm_warn_enable(YASM_WARN_UNREC_CHAR); - yasm_warn_enable(YASM_WARN_ORPHAN_LABEL); - yasm_warn_enable(YASM_WARN_UNINIT_CONTENTS); - return 0; - } - - /* detect no- prefix to disable the warning */ - if (cmd[0] == '-') { - action = yasm_warn_disable; - } else if (cmd[0] == '+') { - action = yasm_warn_enable; - } else return 1; - - /* skip past '+/-' */ - cmd++; - - if (cmd[0] == '\0') - /* just /w- or /w+, so definitely not valid */ - return 1; - else if (strcmp(cmd, "error") == 0) - warning_error = (action == yasm_warn_enable); - else if (strcmp(cmd, "unrecognized-char") == 0) - action(YASM_WARN_UNREC_CHAR); - else if (strcmp(cmd, "orphan-labels") == 0) - action(YASM_WARN_ORPHAN_LABEL); - else if (strcmp(cmd, "uninit-contents") == 0) - action(YASM_WARN_UNINIT_CONTENTS); - else if (strcmp(cmd, "size-override") == 0) - action(YASM_WARN_SIZE_OVERRIDE); - else if (strcmp(cmd, "segreg-in-64bit") == 0) - action(YASM_WARN_SEGREG_IN_64BIT); - else - return 1; - - return 0; -} - -static int -opt_preproc_option(/*@unused@*/ char *cmd, char *param, int extra) -{ - constcharparam *cp; - cp = yasm_xmalloc(sizeof(constcharparam)); - cp->param = param; - cp->id = extra; - STAILQ_INSERT_TAIL(&preproc_options, cp, link); - return 0; -} - -static int -opt_exe_handler(char *cmd, /*@unused@*/ char *param, int extra) -{ - objfmt_keyword = yasm__xstrdup("dosexe"); - return 0; -} - -static void -apply_preproc_builtins(void) -{ - char *predef; - - if (!objfmt_keyword) - objfmt_keyword = yasm__xstrdup(DEFAULT_OBJFMT_MODULE); - - /* Define standard YASM assembly-time macro constants */ - predef = yasm_xmalloc(strlen("__YASM_OBJFMT__=") - + strlen(objfmt_keyword) + 1); - strcpy(predef, "__YASM_OBJFMT__="); - strcat(predef, objfmt_keyword); - yasm_preproc_define_builtin(cur_preproc, predef); - yasm_xfree(predef); -} - -static void -apply_preproc_standard_macros(const yasm_stdmac *stdmacs) -{ - int i, matched; - - if (!stdmacs) - return; - - matched = -1; - for (i=0; stdmacs[i].parser; i++) - if (yasm__strcasecmp(stdmacs[i].parser, - cur_parser_module->keyword) == 0 && - yasm__strcasecmp(stdmacs[i].preproc, - cur_preproc_module->keyword) == 0) - matched = i; - if (matched >= 0 && stdmacs[matched].macros) - yasm_preproc_add_standard(cur_preproc, stdmacs[matched].macros); -} - -static void -apply_preproc_saved_options(void) -{ - constcharparam *cp, *cpnext; - - void (*funcs[3])(yasm_preproc *, const char *); - funcs[0] = cur_preproc_module->add_include_file; - funcs[1] = cur_preproc_module->predefine_macro; - funcs[2] = cur_preproc_module->undefine_macro; - - STAILQ_FOREACH(cp, &preproc_options, link) { - if (0 <= cp->id && cp->id < 3 && funcs[cp->id]) - funcs[cp->id](cur_preproc, cp->param); - } - - cp = STAILQ_FIRST(&preproc_options); - while (cp != NULL) { - cpnext = STAILQ_NEXT(cp, link); - yasm_xfree(cp); - cp = cpnext; - } - STAILQ_INIT(&preproc_options); -} - -/* Replace extension on a filename (or append one if none is present). - * If output filename would be identical to input (same extension out as in), - * returns (copy of) def. - * A NULL ext means the trailing '.' should NOT be included, whereas a "" ext - * means the trailing '.' should be included. - */ -static char * -replace_extension(const char *orig, /*@null@*/ const char *ext, - const char *def) -{ - char *out, *outext; - size_t deflen, outlen; - - /* allocate enough space for full existing name + extension */ - outlen = strlen(orig) + 2; - if (ext) - outlen += strlen(ext) + 1; - deflen = strlen(def) + 1; - if (outlen < deflen) - outlen = deflen; - out = yasm_xmalloc(outlen); - - strcpy(out, orig); - outext = strrchr(out, '.'); - if (outext) { - /* Existing extension: make sure it's not the same as the replacement - * (as we don't want to overwrite the source file). - */ - outext++; /* advance past '.' */ - if (ext && strcmp(outext, ext) == 0) { - outext = NULL; /* indicate default should be used */ - print_error( - _("file name already ends in `.%s': output will be in `%s'"), - ext, def); - } - } else { - /* No extension: make sure the output extension is not empty - * (again, we don't want to overwrite the source file). - */ - if (!ext) - print_error( - _("file name already has no extension: output will be in `%s'"), - def); - else { - outext = strrchr(out, '\0'); /* point to end of the string */ - *outext++ = '.'; /* append '.' */ - } - } - - /* replace extension or use default name */ - if (outext) { - if (!ext) { - /* Back up and replace '.' with string terminator */ - outext--; - *outext = '\0'; - } else - strcpy(outext, ext); - } else - strcpy(out, def); - - return out; -} - -void -print_list_keyword_desc(const char *name, const char *keyword) -{ - printf("%4s%-12s%s\n", "", keyword, name); -} - -static void -print_error(const char *fmt, ...) -{ - va_list va; - fprintf(errfile, "tasm: "); - va_start(va, fmt); - vfprintf(errfile, fmt, va); - va_end(va); - fputc('\n', errfile); -} - -static /*@exits@*/ void -handle_yasm_int_error(const char *file, unsigned int line, const char *message) -{ - fprintf(stderr, _("INTERNAL ERROR at %s, line %u: %s\n"), file, line, - gettext(message)); -#ifdef HAVE_ABORT - abort(); -#else - exit(EXIT_FAILURE); -#endif -} - -static /*@exits@*/ void -handle_yasm_fatal(const char *fmt, va_list va) -{ - fprintf(errfile, "**%s**: ", _("Fatal")); - vfprintf(errfile, gettext(fmt), va); - fputc('\n', errfile); - exit(EXIT_FAILURE); -} - -static const char * -handle_yasm_gettext(const char *msgid) -{ - return gettext(msgid); -} - -static void -print_yasm_error(const char *filename, unsigned long line, const char *msg, - const char *xref_fn, unsigned long xref_line, - const char *xref_msg) -{ - if (line) - fprintf(errfile, "**%s** %s(%lu) %s\n", _("Error"), filename, line, msg); - else - fprintf(errfile, "**%s** %s %s\n", _("Error"), filename, msg); - - if (/* xref_fn && */ xref_msg) { - if (xref_line) - fprintf(errfile, "**%s** %s(%lu) %s\n", _("Error"), filename, xref_line, xref_msg); - else - fprintf(errfile, "**%s** %s %s\n", _("Error"), filename, xref_msg); - } -} - -static void -print_yasm_warning(const char *filename, unsigned long line, const char *msg) -{ - if (line) - fprintf(errfile, "*%s* %s(%lu) %s\n", _("Warning"), filename, line, msg); - else - fprintf(errfile, "*%s* %s %s\n", _("Warning"), filename, msg); -} diff --git a/frontends/vsyasm/CMakeLists.txt b/frontends/vsyasm/CMakeLists.txt deleted file mode 100644 index f5c1f15c..00000000 --- a/frontends/vsyasm/CMakeLists.txt +++ /dev/null @@ -1,39 +0,0 @@ -INCLUDE_DIRECTORIES( - ${CMAKE_CURRENT_BINARY_DIR} - ${yasm_SOURCE_DIR}/frontends/yasm - ) - -ADD_CUSTOM_COMMAND( - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/license.c - COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/frontends/yasm/genstring.py - license_msg - ${CMAKE_CURRENT_BINARY_DIR}/license.c - ${CMAKE_SOURCE_DIR}/COPYING - MAIN_DEPENDENCY ${CMAKE_SOURCE_DIR}/COPYING - DEPENDS ${CMAKE_SOURCE_DIR}/frontends/yasm/genstring.py - ) - -SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}) - -IF(BUILD_SHARED_LIBS) - ADD_EXECUTABLE(vsyasm - vsyasm.c - ${yasm_SOURCE_DIR}/frontends/yasm/yasm-options.c - ${yasm_SOURCE_DIR}/frontends/yasm/yasm-plugin.c - ) - TARGET_LINK_LIBRARIES(vsyasm libyasm ${LIBDL}) - ADD_DEPENDENCIES(vsyasm yasmstd) - SET_PROPERTY(TARGET vsyasm APPEND PROPERTY BUILD_RPATH "$") -ELSE(BUILD_SHARED_LIBS) - ADD_EXECUTABLE(vsyasm - vsyasm.c - ${yasm_SOURCE_DIR}/frontends/yasm/yasm-options.c - ) - TARGET_LINK_LIBRARIES(vsyasm yasmstd libyasm) -ENDIF(BUILD_SHARED_LIBS) - -SET_SOURCE_FILES_PROPERTIES(vsyasm.c PROPERTIES - OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/license.c - ) - -INSTALL(TARGETS vsyasm RUNTIME DESTINATION bin) diff --git a/frontends/vsyasm/Makefile.inc b/frontends/vsyasm/Makefile.inc deleted file mode 100644 index df8d9cf7..00000000 --- a/frontends/vsyasm/Makefile.inc +++ /dev/null @@ -1,9 +0,0 @@ -bin_PROGRAMS += vsyasm - -vsyasm_SOURCES = frontends/vsyasm/vsyasm.c -vsyasm_SOURCES += frontends/yasm/yasm-options.c -vsyasm_SOURCES += frontends/yasm/yasm-options.h - -$(srcdir)/frontends/vsyasm/vsyasm.c: license.c - -vsyasm_LDADD = libyasm.a $(INTLLIBS) diff --git a/frontends/vsyasm/vsyasm.c b/frontends/vsyasm/vsyasm.c deleted file mode 100644 index b3a5a592..00000000 --- a/frontends/vsyasm/vsyasm.c +++ /dev/null @@ -1,1426 +0,0 @@ -/* - * Program entry point, command line parsing - * - * Copyright (C) 2001-2007 Peter Johnson - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND OTHER CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR OTHER CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -#include - -#include -#include -#include -#include - -#ifdef HAVE_LIBGEN_H -#include -#endif - -#include "frontends/yasm/yasm-options.h" - -#if defined(CMAKE_BUILD) && defined(BUILD_SHARED_LIBS) -#include "frontends/yasm/yasm-plugin.h" -#endif - -#include "license.c" - -#if defined(CMAKE_BUILD) && !defined(BUILD_SHARED_LIBS) -void yasm_init_plugin(void); -#endif - -/*@null@*/ /*@only@*/ static char *objdir_pathname = NULL; -/*@null@*/ /*@only@*/ static char *global_prefix = NULL, *global_suffix = NULL; -/*@null@*/ /*@only@*/ static char *listdir_pathname = NULL; -/*@null@*/ /*@only@*/ static char *mapdir_pathname = NULL; -/*@null@*/ /*@only@*/ static char *objext = NULL; -/*@null@*/ /*@only@*/ static char *listext = NULL, *mapext = NULL; -/*@null@*/ /*@only@*/ static char *machine_name = NULL; -static int special_options = 0; -/*@null@*/ /*@dependent@*/ static const yasm_arch_module * - cur_arch_module = NULL; -/*@null@*/ /*@dependent@*/ static const yasm_parser_module * - cur_parser_module = NULL; -/*@null@*/ /*@dependent@*/ static const yasm_preproc_module * - cur_preproc_module = NULL; -/*@null@*/ static char *objfmt_keyword = NULL; -/*@null@*/ /*@dependent@*/ static const yasm_objfmt_module * - cur_objfmt_module = NULL; -/*@null@*/ /*@dependent@*/ static const yasm_dbgfmt_module * - cur_dbgfmt_module = NULL; -/*@null@*/ /*@dependent@*/ static const yasm_listfmt_module * - cur_listfmt_module = NULL; -static unsigned int force_strict = 0; -static int warning_error = 0; /* warnings being treated as errors */ -static FILE *errfile; -/*@null@*/ /*@only@*/ static char *error_filename = NULL; -static enum { - EWSTYLE_GNU = 0, - EWSTYLE_VC -} ewmsg_style = EWSTYLE_GNU; - -/*@null@*/ /*@dependent@*/ static FILE *open_file(const char *filename, - const char *mode); -static int check_errors(/*@only@*/ yasm_errwarns *errwarns, - /*@only@*/ yasm_object *object, - /*@only@*/ yasm_linemap *linemap, - /*@only@*/ yasm_preproc *preproc, - /*@only@*/ yasm_arch *arch); -static void cleanup(void); -static void free_input_filenames(void); - -/* Forward declarations: cmd line parser handlers */ -static int opt_special_handler(char *cmd, /*@null@*/ char *param, int extra); -static int opt_arch_handler(char *cmd, /*@null@*/ char *param, int extra); -static int opt_parser_handler(char *cmd, /*@null@*/ char *param, int extra); -static int opt_preproc_handler(char *cmd, /*@null@*/ char *param, int extra); -static int opt_objfmt_handler(char *cmd, /*@null@*/ char *param, int extra); -static int opt_dbgfmt_handler(char *cmd, /*@null@*/ char *param, int extra); -static int opt_listfmt_handler(char *cmd, /*@null@*/ char *param, int extra); -static int opt_listdir_handler(char *cmd, /*@null@*/ char *param, int extra); -static int opt_objdir_handler(char *cmd, /*@null@*/ char *param, int extra); -static int opt_mapdir_handler(char *cmd, /*@null@*/ char *param, int extra); -static int opt_listext_handler(char *cmd, /*@null@*/ char *param, int extra); -static int opt_objext_handler(char *cmd, /*@null@*/ char *param, int extra); -static int opt_mapext_handler(char *cmd, /*@null@*/ char *param, int extra); -static int opt_machine_handler(char *cmd, /*@null@*/ char *param, int extra); -static int opt_strict_handler(char *cmd, /*@null@*/ char *param, int extra); -static int opt_warning_handler(char *cmd, /*@null@*/ char *param, int extra); -static int opt_error_file(char *cmd, /*@null@*/ char *param, int extra); -static int opt_error_stdout(char *cmd, /*@null@*/ char *param, int extra); -static int opt_include_option(char *cmd, /*@null@*/ char *param, int extra); -static int opt_preproc_option(char *cmd, /*@null@*/ char *param, int extra); -static int opt_ewmsg_handler(char *cmd, /*@null@*/ char *param, int extra); -static int opt_prefix_handler(char *cmd, /*@null@*/ char *param, int extra); -static int opt_suffix_handler(char *cmd, /*@null@*/ char *param, int extra); -#if defined(CMAKE_BUILD) && defined(BUILD_SHARED_LIBS) -static int opt_plugin_handler(char *cmd, /*@null@*/ char *param, int extra); -#endif - -static /*@only@*/ char *replace_extension(const char *orig, /*@null@*/ - const char *ext); -static void print_error(const char *fmt, ...); - -static /*@exits@*/ void handle_yasm_int_error(const char *file, - unsigned int line, - const char *message); -static /*@exits@*/ void handle_yasm_fatal(const char *message, va_list va); -static const char *handle_yasm_gettext(const char *msgid); -static void print_yasm_error(const char *filename, unsigned long line, - const char *msg, /*@null@*/ const char *xref_fn, - unsigned long xref_line, - /*@null@*/ const char *xref_msg); -static void print_yasm_warning(const char *filename, unsigned long line, - const char *msg); - -static void apply_preproc_builtins(yasm_preproc *preproc); -static void apply_preproc_standard_macros(yasm_preproc *preproc, - const yasm_stdmac *stdmacs); -static void apply_preproc_saved_options(yasm_preproc *preproc); -static void free_preproc_saved_options(void); -static void print_list_keyword_desc(const char *name, const char *keyword); - -/* values for special_options */ -#define SPECIAL_SHOW_HELP 0x01 -#define SPECIAL_SHOW_VERSION 0x02 -#define SPECIAL_SHOW_LICENSE 0x04 -#define SPECIAL_LISTED 0x08 - -/* command line options */ -static opt_option options[] = -{ - { 0, "version", 0, opt_special_handler, SPECIAL_SHOW_VERSION, - N_("show version text"), NULL }, - { 0, "license", 0, opt_special_handler, SPECIAL_SHOW_LICENSE, - N_("show license text"), NULL }, - { 'h', "help", 0, opt_special_handler, SPECIAL_SHOW_HELP, - N_("show help text"), NULL }, - { 'a', "arch", 1, opt_arch_handler, 0, - N_("select architecture (list with -a help)"), N_("arch") }, - { 'p', "parser", 1, opt_parser_handler, 0, - N_("select parser (list with -p help)"), N_("parser") }, - { 'r', "preproc", 1, opt_preproc_handler, 0, - N_("select preprocessor (list with -r help)"), N_("preproc") }, - { 'f', "oformat", 1, opt_objfmt_handler, 0, - N_("select object format (list with -f help)"), N_("format") }, - { 'g', "dformat", 1, opt_dbgfmt_handler, 0, - N_("select debugging format (list with -g help)"), N_("debug") }, - { 'L', "lformat", 1, opt_listfmt_handler, 0, - N_("select list format (list with -L help)"), N_("list") }, - { 'l', "list", 1, opt_listdir_handler, 0, - N_("name of list-file output directory"), N_("pathname") }, - { 'o', "objdir", 1, opt_objdir_handler, 0, - N_("name of object-file output directory"), N_("pathname") }, - { 0, "mapdir", 1, opt_mapdir_handler, 0, - N_("name of map-file output directory"), N_("pathname") }, - { 0, "listext", 1, opt_listext_handler, 0, - N_("list-file extension (default `lst')"), N_("ext") }, - { 0, "objext", 1, opt_objext_handler, 0, - N_("object-file extension (default is by object format)"), N_("ext") }, - { 0, "mapext", 1, opt_mapext_handler, 0, - N_("map-file extension (default `map')"), N_("ext") }, - { 'm', "machine", 1, opt_machine_handler, 0, - N_("select machine (list with -m help)"), N_("machine") }, - { 0, "force-strict", 0, opt_strict_handler, 0, - N_("treat all sized operands as if `strict' was used"), NULL }, - { 'w', NULL, 0, opt_warning_handler, 1, - N_("inhibits warning messages"), NULL }, - { 'W', NULL, 0, opt_warning_handler, 0, - N_("enables/disables warning"), NULL }, - { 'Z', NULL, 1, opt_error_file, 0, - N_("redirect error messages to file"), N_("file") }, - { 's', NULL, 0, opt_error_stdout, 0, - N_("redirect error messages to stdout"), NULL }, - { 'i', NULL, 1, opt_include_option, 0, - N_("add include path"), N_("path") }, - { 'I', NULL, 1, opt_include_option, 0, - N_("add include path"), N_("path") }, - { 'P', NULL, 1, opt_preproc_option, 0, - N_("pre-include file"), N_("filename") }, - { 'd', NULL, 1, opt_preproc_option, 1, - N_("pre-define a macro, optionally to value"), N_("macro[=value]") }, - { 'D', NULL, 1, opt_preproc_option, 1, - N_("pre-define a macro, optionally to value"), N_("macro[=value]") }, - { 'u', NULL, 1, opt_preproc_option, 2, - N_("undefine a macro"), N_("macro") }, - { 'U', NULL, 1, opt_preproc_option, 2, - N_("undefine a macro"), N_("macro") }, - { 'X', NULL, 1, opt_ewmsg_handler, 0, - N_("select error/warning message style (`gnu' or `vc')"), N_("style") }, - { 0, "prefix", 1, opt_prefix_handler, 0, - N_("prepend argument to name of all external symbols"), N_("prefix") }, - { 0, "suffix", 1, opt_suffix_handler, 0, - N_("append argument to name of all external symbols"), N_("suffix") }, - { 0, "postfix", 1, opt_suffix_handler, 0, - N_("append argument to name of all external symbols"), N_("suffix") }, -#if defined(CMAKE_BUILD) && defined(BUILD_SHARED_LIBS) - { 'N', "plugin", 1, opt_plugin_handler, 0, - N_("load plugin module"), N_("plugin") }, -#endif -}; - -/* version message */ -/*@observer@*/ static const char *version_msg[] = { - PACKAGE_STRING, - "Copyright (c) 2001-2010 Peter Johnson and other Yasm developers.", - "Run yasm --license for licensing overview and summary." -}; - -/* help messages */ -/*@observer@*/ static const char *help_head = N_( - "usage: vsyasm [option]* file...\n" - "Options:\n"); -/*@observer@*/ static const char *help_tail = N_( - "\n" - "Files are asm sources to be assembled.\n" - "\n" - "Sample invocation:\n" - " vsyasm -f win64 -o objdir source1.asm source2.asm\n" - "\n" - "All options apply to all files.\n" - "\n" - "Report bugs to bug-yasm@tortall.net\n"); - -/* parsed command line storage until appropriate modules have been loaded */ -typedef STAILQ_HEAD(constcharparam_head, constcharparam) constcharparam_head; - -typedef struct constcharparam { - STAILQ_ENTRY(constcharparam) link; - const char *param; - int id; -} constcharparam; - -static constcharparam_head preproc_options; -static constcharparam_head input_files; -static int num_input_files = 0; - -static int -do_assemble(const char *in_filename) -{ - yasm_object *object; - const char *base_filename; - char *fn = NULL; - char *obj_filename, *list_filename = NULL, *map_filename = NULL; - /*@null@*/ FILE *obj = NULL; - yasm_arch_create_error arch_error; - yasm_linemap *linemap; - yasm_arch *arch = NULL; - yasm_preproc *preproc = NULL; - yasm_errwarns *errwarns = yasm_errwarns_create(); - int i, matched; - - /* Initialize line map */ - linemap = yasm_linemap_create(); - yasm_linemap_set(linemap, in_filename, 0, 1, 1); - - /* determine the output filenames */ - /* replace (or add) extension to base filename */ - yasm__splitpath(in_filename, &base_filename); - if (base_filename[0] != '\0') - fn = replace_extension(base_filename, objext); - if (!fn) - { - print_error(_("could not determine output filename for `%s'"), - in_filename); - return EXIT_FAILURE; - } - obj_filename = yasm__combpath(objdir_pathname, fn); - yasm_xfree(fn); - - if (listdir_pathname) { - fn = replace_extension(base_filename, listext); - if (!fn) - { - print_error(_("could not determine list filename for `%s'"), - in_filename); - return EXIT_FAILURE; - } - list_filename = yasm__combpath(listdir_pathname, fn); - yasm_xfree(fn); - } - - if (mapdir_pathname) { - fn = replace_extension(base_filename, mapext); - if (!fn) - { - print_error(_("could not determine map filename for `%s'"), - in_filename); - return EXIT_FAILURE; - } - map_filename = yasm__combpath(mapdir_pathname, fn); - yasm_xfree(fn); - } - - /* Set up architecture using machine and parser. */ - if (!machine_name) { - /* If we're using x86 and the default objfmt bits is 64, default the - * machine to amd64. When we get more arches with multiple machines, - * we should do this in a more modular fashion. - */ - if (yasm__strcasecmp(cur_arch_module->keyword, "x86") == 0 && - cur_objfmt_module->default_x86_mode_bits == 64) - machine_name = yasm__xstrdup("amd64"); - else - machine_name = - yasm__xstrdup(cur_arch_module->default_machine_keyword); - } - - arch = yasm_arch_create(cur_arch_module, machine_name, - cur_parser_module->keyword, &arch_error); - if (!arch) { - switch (arch_error) { - case YASM_ARCH_CREATE_BAD_MACHINE: - print_error(_("%s: `%s' is not a valid %s for %s `%s'"), - _("FATAL"), machine_name, _("machine"), - _("architecture"), cur_arch_module->keyword); - break; - case YASM_ARCH_CREATE_BAD_PARSER: - print_error(_("%s: `%s' is not a valid %s for %s `%s'"), - _("FATAL"), cur_parser_module->keyword, - _("parser"), _("architecture"), - cur_arch_module->keyword); - break; - default: - print_error(_("%s: unknown architecture error"), _("FATAL")); - } - - return EXIT_FAILURE; - } - - /* Create object */ - object = yasm_object_create(in_filename, obj_filename, arch, - cur_objfmt_module, cur_dbgfmt_module); - if (!object) { - yasm_error_class eclass; - unsigned long xrefline; - /*@only@*/ /*@null@*/ char *estr, *xrefstr; - - yasm_error_fetch(&eclass, &estr, &xrefline, &xrefstr); - print_error("%s: %s", _("FATAL"), estr); - yasm_xfree(estr); - yasm_xfree(xrefstr); - return EXIT_FAILURE; - } - - /* Get a fresh copy of objfmt_module as it may have changed. */ - cur_objfmt_module = ((yasm_objfmt_base *)object->objfmt)->module; - - /* Check to see if the requested preprocessor is in the allowed list - * for the active parser. - */ - matched = 0; - for (i=0; cur_parser_module->preproc_keywords[i]; i++) - if (yasm__strcasecmp(cur_parser_module->preproc_keywords[i], - cur_preproc_module->keyword) == 0) - matched = 1; - if (!matched) { - print_error(_("%s: `%s' is not a valid %s for %s `%s'"), _("FATAL"), - cur_preproc_module->keyword, _("preprocessor"), - _("parser"), cur_parser_module->keyword); - yasm_object_destroy(object); - return EXIT_FAILURE; - } - - if (global_prefix) - yasm_object_set_global_prefix(object, global_prefix); - if (global_suffix) - yasm_object_set_global_suffix(object, global_suffix); - - preproc = yasm_preproc_create(cur_preproc_module, in_filename, - object->symtab, linemap, errwarns); - - apply_preproc_builtins(preproc); - apply_preproc_standard_macros(preproc, cur_parser_module->stdmacs); - apply_preproc_standard_macros(preproc, cur_objfmt_module->stdmacs); - apply_preproc_saved_options(preproc); - - /* Get initial x86 BITS setting from object format */ - if (yasm__strcasecmp(cur_arch_module->keyword, "x86") == 0) { - yasm_arch_set_var(arch, "mode_bits", - cur_objfmt_module->default_x86_mode_bits); - } - - yasm_arch_set_var(arch, "force_strict", force_strict); - - /* Try to enable the map file via a map NASM directive. This is - * somewhat of a hack. - */ - if (map_filename) { - const yasm_directive *dir = &cur_objfmt_module->directives[0]; - matched = 0; - for (; dir && dir->name; dir++) { - if (yasm__strcasecmp(dir->name, "map") == 0 && - yasm__strcasecmp(dir->parser, "nasm") == 0) { - yasm_valparamhead vps; - yasm_valparam *vp; - matched = 1; - yasm_vps_initialize(&vps); - vp = yasm_vp_create_string(NULL, yasm__xstrdup(map_filename)); - yasm_vps_append(&vps, vp); - dir->handler(object, &vps, NULL, 0); - yasm_vps_delete(&vps); - } - } - if (!matched) { - print_error( - _("warning: object format `%s' does not support map files"), - cur_objfmt_module->keyword); - } - } - - /* Parse! */ - cur_parser_module->do_parse(object, preproc, list_filename != NULL, - linemap, errwarns); - - if (check_errors(errwarns, object, linemap, preproc, arch) == EXIT_FAILURE) - return EXIT_FAILURE; - - /* Finalize parse */ - yasm_object_finalize(object, errwarns); - if (check_errors(errwarns, object, linemap, preproc, arch) == EXIT_FAILURE) - return EXIT_FAILURE; - - /* Optimize */ - yasm_object_optimize(object, errwarns); - if (check_errors(errwarns, object, linemap, preproc, arch) == EXIT_FAILURE) - return EXIT_FAILURE; - - /* generate any debugging information */ - yasm_dbgfmt_generate(object, linemap, errwarns); - if (check_errors(errwarns, object, linemap, preproc, arch) == EXIT_FAILURE) - return EXIT_FAILURE; - - /* open the object file for output (if not already opened by dbg objfmt) */ - if (!obj && yasm__strcasecmp(cur_objfmt_module->keyword, "dbg") != 0) { - obj = open_file(obj_filename, "wb"); - if (!obj) { - yasm_preproc_destroy(preproc); - yasm_object_destroy(object); - yasm_linemap_destroy(linemap); - yasm_errwarns_destroy(errwarns); - return EXIT_FAILURE; - } - } - - /* Write the object file */ - yasm_objfmt_output(object, obj?obj:stderr, - yasm__strcasecmp(cur_dbgfmt_module->keyword, "null"), - errwarns); - - /* Close object file */ - if (obj) - fclose(obj); - - /* If we had an error at this point, we also need to delete the output - * object file (to make sure it's not left newer than the source). - */ - if (yasm_errwarns_num_errors(errwarns, warning_error) > 0) - remove(obj_filename); - if (check_errors(errwarns, object, linemap, preproc, arch) == EXIT_FAILURE) - return EXIT_FAILURE; - - /* Open and write the list file */ - if (list_filename) { - yasm_listfmt *cur_listfmt; - FILE *list = open_file(list_filename, "wt"); - if (!list) { - yasm_preproc_destroy(preproc); - yasm_object_destroy(object); - yasm_linemap_destroy(linemap); - yasm_errwarns_destroy(errwarns); - return EXIT_FAILURE; - } - /* Initialize the list format */ - cur_listfmt = yasm_listfmt_create(cur_listfmt_module, in_filename, - obj_filename); - yasm_listfmt_output(cur_listfmt, list, linemap, arch); - yasm_listfmt_destroy(cur_listfmt); - fclose(list); - } - - yasm_errwarns_output_all(errwarns, linemap, warning_error, - print_yasm_error, print_yasm_warning); - - yasm_preproc_destroy(preproc); - yasm_object_destroy(object); - yasm_linemap_destroy(linemap); - yasm_errwarns_destroy(errwarns); - - yasm_xfree(obj_filename); - yasm_xfree(map_filename); - yasm_xfree(list_filename); - return EXIT_SUCCESS; -} - -/* main function */ -/*@-globstate -unrecog@*/ -int -main(int argc, char *argv[]) -{ - size_t i; - constcharparam *infile; - - errfile = stderr; - -#if defined(HAVE_SETLOCALE) && defined(HAVE_LC_MESSAGES) - setlocale(LC_MESSAGES, ""); -#endif -#if defined(LOCALEDIR) - bindtextdomain(PACKAGE, LOCALEDIR); -#endif - textdomain(PACKAGE); - - /* Initialize errwarn handling */ - yasm_internal_error_ = handle_yasm_int_error; - yasm_fatal = handle_yasm_fatal; - yasm_gettext_hook = handle_yasm_gettext; - yasm_errwarn_initialize(); - - /* Initialize BitVector (needed for intnum/floatnum). */ - if (BitVector_Boot() != ErrCode_Ok) { - print_error(_("%s: could not initialize BitVector"), _("FATAL")); - return EXIT_FAILURE; - } - - /* Initialize intnum and floatnum */ - yasm_intnum_initialize(); - yasm_floatnum_initialize(); - -#ifdef CMAKE_BUILD - /* Load standard modules */ -#ifdef BUILD_SHARED_LIBS - if (!load_plugin("yasmstd")) { - print_error(_("%s: could not load standard modules"), _("FATAL")); - return EXIT_FAILURE; - } -#else - yasm_init_plugin(); -#endif -#endif - - /* Initialize parameter storage */ - STAILQ_INIT(&preproc_options); - STAILQ_INIT(&input_files); - - if (parse_cmdline(argc, argv, options, NELEMS(options), print_error)) - return EXIT_FAILURE; - - switch (special_options) { - case SPECIAL_SHOW_HELP: - /* Does gettext calls internally */ - help_msg(help_head, help_tail, options, NELEMS(options)); - return EXIT_SUCCESS; - case SPECIAL_SHOW_VERSION: - for (i=0; imachines; - printf(_("Available %s for %s `%s':\n"), _("machines"), - _("architecture"), cur_arch_module->keyword); - while (m->keyword && m->name) { - print_list_keyword_desc(m->name, m->keyword); - m++; - } - return EXIT_SUCCESS; - } - - /* Default to NASM as the parser */ - if (!cur_parser_module) { - cur_parser_module = yasm_load_parser("nasm"); - if (!cur_parser_module) { - print_error(_("%s: could not load default %s"), _("FATAL"), - _("parser")); - cleanup(); - return EXIT_FAILURE; - } - } - - /* If not already specified, default to the parser's default preproc. */ - if (!cur_preproc_module) { - cur_preproc_module = - yasm_load_preproc(cur_parser_module->default_preproc_keyword); - if (!cur_preproc_module) { - print_error(_("%s: could not load default %s"), _("FATAL"), - _("preprocessor")); - cleanup(); - return EXIT_FAILURE; - } - } - - /* Determine input filenames. */ - if (STAILQ_EMPTY(&input_files)) { - print_error(_("No input files specified")); - return EXIT_FAILURE; - } - - /* If list file enabled, make sure we have a list format loaded. */ - if (listdir_pathname) { - /* If not already specified, default to nasm as the list format. */ - if (!cur_listfmt_module) { - cur_listfmt_module = yasm_load_listfmt("nasm"); - if (!cur_listfmt_module) { - print_error(_("%s: could not load default %s"), _("FATAL"), - _("list format")); - return EXIT_FAILURE; - } - } - } - - /* If not already specified, default to null as the debug format. */ - if (!cur_dbgfmt_module) { - cur_dbgfmt_module = yasm_load_dbgfmt("null"); - if (!cur_dbgfmt_module) { - print_error(_("%s: could not load default %s"), _("FATAL"), - _("debug format")); - return EXIT_FAILURE; - } - } - - /* If not already specified, output to the current directory. */ - if (!objdir_pathname) - objdir_pathname = yasm__xstrdup("./"); - else if ((i = yasm__createpath(objdir_pathname)) > 0 && - num_input_files > 1) { - objdir_pathname[i] = '/'; - objdir_pathname[i+1] = '\0'; - } - - /* Create other output directories if necessary */ - if (listdir_pathname && (i = yasm__createpath(listdir_pathname)) > 0 && - num_input_files > 1) { - listdir_pathname[i] = '/'; - listdir_pathname[i+1] = '\0'; - } - if (mapdir_pathname && (i = yasm__createpath(mapdir_pathname)) > 0 && - num_input_files > 1) { - mapdir_pathname[i] = '/'; - mapdir_pathname[i+1] = '\0'; - } - - /* If not already specified, set file extensions */ - if (!objext && cur_objfmt_module->extension) - objext = yasm__xstrdup(cur_objfmt_module->extension); - if (!listext) - listext = yasm__xstrdup("lst"); - if (!mapext) - mapext = yasm__xstrdup("map"); - - /* Assemble each input file. Terminate on first error. */ - STAILQ_FOREACH(infile, &input_files, link) - { - if (do_assemble(infile->param) == EXIT_FAILURE) { - cleanup(); - return EXIT_FAILURE; - } - } - cleanup(); - return EXIT_SUCCESS; -} -/*@=globstate =unrecog@*/ - -/* Open the object file. Returns 0 on failure. */ -static FILE * -open_file(const char *filename, const char *mode) -{ - FILE *f; - - f = fopen(filename, mode); - if (!f) - print_error(_("could not open file `%s'"), filename); - return f; -} - -static int -check_errors(yasm_errwarns *errwarns, yasm_object *object, - yasm_linemap *linemap, yasm_preproc *preproc, yasm_arch *arch) -{ - if (yasm_errwarns_num_errors(errwarns, warning_error) > 0) { - yasm_errwarns_output_all(errwarns, linemap, warning_error, - print_yasm_error, print_yasm_warning); - yasm_preproc_destroy(preproc); - yasm_object_destroy(object); - yasm_linemap_destroy(linemap); - yasm_errwarns_destroy(errwarns); - return EXIT_FAILURE; - } - return EXIT_SUCCESS; -} - -/* Define DO_FREE to 1 to enable deallocation of all data structures. - * Useful for detecting memory leaks, but slows down execution unnecessarily - * (as the OS will free everything we miss here). - */ -#define DO_FREE 1 - -/* Cleans up all allocated structures. */ -static void -cleanup(void) -{ - if (DO_FREE) { - yasm_floatnum_cleanup(); - yasm_intnum_cleanup(); - - yasm_errwarn_cleanup(); - - BitVector_Shutdown(); - } - - if (DO_FREE) { - free_input_filenames(); - if (objdir_pathname) - yasm_xfree(objdir_pathname); - if (listdir_pathname) - yasm_xfree(listdir_pathname); - if (mapdir_pathname) - yasm_xfree(mapdir_pathname); - if (objext) - yasm_xfree(objext); - if (listext) - yasm_xfree(listext); - if (mapext) - yasm_xfree(mapext); - if (machine_name) - yasm_xfree(machine_name); - if (objfmt_keyword) - yasm_xfree(objfmt_keyword); - free_preproc_saved_options(); - } - - if (errfile != stderr && errfile != stdout) - fclose(errfile); -#if defined(CMAKE_BUILD) && defined(BUILD_SHARED_LIBS) - unload_plugins(); -#endif -} - -static void -free_input_filenames(void) -{ - constcharparam *cp, *cpnext; - cp = STAILQ_FIRST(&input_files); - while (cp != NULL) { - cpnext = STAILQ_NEXT(cp, link); - yasm_xfree(cp); - cp = cpnext; - } - STAILQ_INIT(&input_files); -} - -/* - * Command line options handlers - */ -int -not_an_option_handler(char *param) -{ - constcharparam *cp; - cp = yasm_xmalloc(sizeof(constcharparam)); - cp->param = param; - cp->id = 0; - STAILQ_INSERT_TAIL(&input_files, cp, link); - ++num_input_files; - return 0; -} - -int -other_option_handler(char *option) -{ - /* Accept, but ignore, -O and -Onnn, for compatibility with NASM. */ - if (option[0] == '-' && option[1] == 'O') { - int n = 2; - for (;;) { - if (option[n] == '\0') - return 0; - if (!isdigit(option[n])) - return 1; - n++; - } - } - return 1; -} - -static int -opt_special_handler(/*@unused@*/ char *cmd, /*@unused@*/ char *param, int extra) -{ - if (special_options == 0) - special_options = extra; - return 0; -} - -static int -opt_arch_handler(/*@unused@*/ char *cmd, char *param, /*@unused@*/ int extra) -{ - assert(param != NULL); - cur_arch_module = yasm_load_arch(param); - if (!cur_arch_module) { - if (!strcmp("help", param)) { - printf(_("Available yasm %s:\n"), _("architectures")); - yasm_list_arch(print_list_keyword_desc); - special_options = SPECIAL_LISTED; - return 0; - } - print_error(_("%s: unrecognized %s `%s'"), _("FATAL"), - _("architecture"), param); - exit(EXIT_FAILURE); - } - return 0; -} - -static int -opt_parser_handler(/*@unused@*/ char *cmd, char *param, /*@unused@*/ int extra) -{ - assert(param != NULL); - cur_parser_module = yasm_load_parser(param); - if (!cur_parser_module) { - if (!strcmp("help", param)) { - printf(_("Available yasm %s:\n"), _("parsers")); - yasm_list_parser(print_list_keyword_desc); - special_options = SPECIAL_LISTED; - return 0; - } - print_error(_("%s: unrecognized %s `%s'"), _("FATAL"), _("parser"), - param); - exit(EXIT_FAILURE); - } - return 0; -} - -static int -opt_preproc_handler(/*@unused@*/ char *cmd, char *param, /*@unused@*/ int extra) -{ - assert(param != NULL); - cur_preproc_module = yasm_load_preproc(param); - if (!cur_preproc_module) { - if (!strcmp("help", param)) { - printf(_("Available yasm %s:\n"), _("preprocessors")); - yasm_list_preproc(print_list_keyword_desc); - special_options = SPECIAL_LISTED; - return 0; - } - print_error(_("%s: unrecognized %s `%s'"), _("FATAL"), - _("preprocessor"), param); - exit(EXIT_FAILURE); - } - return 0; -} - -static int -opt_objfmt_handler(/*@unused@*/ char *cmd, char *param, /*@unused@*/ int extra) -{ - size_t i; - assert(param != NULL); - cur_objfmt_module = yasm_load_objfmt(param); - if (!cur_objfmt_module) { - if (!strcmp("help", param)) { - printf(_("Available yasm %s:\n"), _("object formats")); - yasm_list_objfmt(print_list_keyword_desc); - special_options = SPECIAL_LISTED; - return 0; - } - print_error(_("%s: unrecognized %s `%s'"), _("FATAL"), - _("object format"), param); - exit(EXIT_FAILURE); - } - if (objfmt_keyword) - yasm_xfree(objfmt_keyword); - objfmt_keyword = yasm__xstrdup(param); - for (i=0; iparam = param; - cp->id = extra; - STAILQ_INSERT_TAIL(&preproc_options, cp, link); - return 0; -} - -static int -opt_ewmsg_handler(/*@unused@*/ char *cmd, char *param, /*@unused@*/ int extra) -{ - if (yasm__strcasecmp(param, "gnu") == 0 || - yasm__strcasecmp(param, "gcc") == 0) { - ewmsg_style = EWSTYLE_GNU; - } else if (yasm__strcasecmp(param, "vc") == 0) { - ewmsg_style = EWSTYLE_VC; - } else - print_error(_("warning: unrecognized message style `%s'"), param); - - return 0; -} - -static int -opt_prefix_handler(/*@unused@*/ char *cmd, char *param, /*@unused@*/ int extra) -{ - if (global_prefix) - yasm_xfree(global_prefix); - - assert(param != NULL); - global_prefix = yasm__xstrdup(param); - - return 0; -} - -static int -opt_suffix_handler(/*@unused@*/ char *cmd, char *param, /*@unused@*/ int extra) -{ - if (global_suffix) - yasm_xfree(global_suffix); - - assert(param != NULL); - global_suffix = yasm__xstrdup(param); - - return 0; -} - -#if defined(CMAKE_BUILD) && defined(BUILD_SHARED_LIBS) -static int -opt_plugin_handler(/*@unused@*/ char *cmd, char *param, - /*@unused@*/ int extra) -{ - if (!load_plugin(param)) - print_error(_("warning: could not load plugin `%s'"), param); - return 0; -} -#endif - -static void -apply_preproc_builtins(yasm_preproc *preproc) -{ - char *predef; - - /* Define standard YASM assembly-time macro constants */ - predef = yasm_xmalloc(strlen("__YASM_OBJFMT__=") - + strlen(objfmt_keyword) + 1); - strcpy(predef, "__YASM_OBJFMT__="); - strcat(predef, objfmt_keyword); - yasm_preproc_define_builtin(preproc, predef); - yasm_xfree(predef); -} - -static void -apply_preproc_standard_macros(yasm_preproc *preproc, const yasm_stdmac *stdmacs) -{ - int i, matched; - - if (!stdmacs) - return; - - matched = -1; - for (i=0; stdmacs[i].parser; i++) - if (yasm__strcasecmp(stdmacs[i].parser, - cur_parser_module->keyword) == 0 && - yasm__strcasecmp(stdmacs[i].preproc, - cur_preproc_module->keyword) == 0) - matched = i; - if (matched >= 0 && stdmacs[matched].macros) - yasm_preproc_add_standard(preproc, stdmacs[matched].macros); -} - -static void -apply_preproc_saved_options(yasm_preproc *preproc) -{ - constcharparam *cp; - - void (*funcs[3])(yasm_preproc *, const char *); - funcs[0] = cur_preproc_module->add_include_file; - funcs[1] = cur_preproc_module->predefine_macro; - funcs[2] = cur_preproc_module->undefine_macro; - - STAILQ_FOREACH(cp, &preproc_options, link) { - if (0 <= cp->id && cp->id < 3 && funcs[cp->id]) - funcs[cp->id](preproc, cp->param); - } -} - -static void -free_preproc_saved_options(void) -{ - constcharparam *cp, *cpnext; - cp = STAILQ_FIRST(&preproc_options); - while (cp != NULL) { - cpnext = STAILQ_NEXT(cp, link); - yasm_xfree(cp); - cp = cpnext; - } - STAILQ_INIT(&preproc_options); -} - -/* Replace extension on a filename (or append one if none is present). - * If output filename would be identical to input (same extension out as in), - * returns NULL. - * A NULL ext means the trailing '.' should NOT be included, whereas a "" ext - * means the trailing '.' should be included. - */ -static char * -replace_extension(const char *orig, /*@null@*/ const char *ext) -{ - char *out, *outext; - size_t outlen; - - /* allocate enough space for full existing name + extension */ - outlen = strlen(orig) + 2; - if (ext) - outlen += strlen(ext) + 1; - out = yasm_xmalloc(outlen); - - strcpy(out, orig); - outext = strrchr(out, '.'); - if (outext) { - /* Existing extension: make sure it's not the same as the replacement - * (as we don't want to overwrite the source file). - */ - outext++; /* advance past '.' */ - if (ext && strcmp(outext, ext) == 0) { - outext = NULL; /* indicate default should be used */ - print_error(_("file name already ends in `.%s'"), ext); - } - } else { - /* No extension: make sure the output extension is not empty - * (again, we don't want to overwrite the source file). - */ - if (!ext) { - outext = NULL; - print_error(_("file name already has no extension")); - } else { - outext = strrchr(out, '\0'); /* point to end of the string */ - *outext++ = '.'; /* append '.' */ - } - } - - /* replace extension or use default name */ - if (outext) { - if (!ext) { - /* Back up and replace '.' with string terminator */ - outext--; - *outext = '\0'; - } else - strcpy(outext, ext); - } else - return NULL; - - return out; -} - -void -print_list_keyword_desc(const char *name, const char *keyword) -{ - printf("%4s%-12s%s\n", "", keyword, name); -} - -static void -print_error(const char *fmt, ...) -{ - va_list va; - fprintf(errfile, "vsyasm: "); - va_start(va, fmt); - vfprintf(errfile, fmt, va); - va_end(va); - fputc('\n', errfile); -} - -static /*@exits@*/ void -handle_yasm_int_error(const char *file, unsigned int line, const char *message) -{ - fprintf(stderr, _("INTERNAL ERROR at %s, line %u: %s\n"), file, line, - gettext(message)); -#ifdef HAVE_ABORT - abort(); -#else - exit(EXIT_FAILURE); -#endif -} - -static /*@exits@*/ void -handle_yasm_fatal(const char *fmt, va_list va) -{ - fprintf(errfile, "vsyasm: %s: ", _("FATAL")); - vfprintf(errfile, gettext(fmt), va); - fputc('\n', errfile); - exit(EXIT_FAILURE); -} - -static const char * -handle_yasm_gettext(const char *msgid) -{ - return gettext(msgid); -} - -static const char *fmt[2] = { - "%s:%lu: %s%s\n", /* GNU */ - "%s(%lu) : %s%s\n" /* VC */ -}; - -static const char *fmt_noline[2] = { - "%s: %s%s\n", /* GNU */ - "%s : %s%s\n" /* VC */ -}; - -static void -print_yasm_error(const char *filename, unsigned long line, const char *msg, - const char *xref_fn, unsigned long xref_line, - const char *xref_msg) -{ - if (line) - fprintf(errfile, fmt[ewmsg_style], filename, line, _("error: "), msg); - else - fprintf(errfile, fmt_noline[ewmsg_style], filename, _("error: "), msg); - - if (xref_fn && xref_msg) { - if (xref_line) - fprintf(errfile, fmt[ewmsg_style], xref_fn, xref_line, _("error: "), - xref_msg); - else - fprintf(errfile, fmt_noline[ewmsg_style], xref_fn, _("error: "), - xref_msg); - } -} - -static void -print_yasm_warning(const char *filename, unsigned long line, const char *msg) -{ - if (line) - fprintf(errfile, fmt[ewmsg_style], filename, line, _("warning: "), - msg); - else - fprintf(errfile, fmt_noline[ewmsg_style], filename, _("warning: "), - msg); -} diff --git a/frontends/yasm/CMakeLists.txt b/frontends/yasm/CMakeLists.txt deleted file mode 100644 index 6da0cd49..00000000 --- a/frontends/yasm/CMakeLists.txt +++ /dev/null @@ -1,36 +0,0 @@ -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) - -ADD_CUSTOM_COMMAND( - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/license.c - COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/genstring.py - license_msg - ${CMAKE_CURRENT_BINARY_DIR}/license.c - ${CMAKE_SOURCE_DIR}/COPYING - MAIN_DEPENDENCY ${CMAKE_SOURCE_DIR}/COPYING - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/genstring.py - ) - -SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}) - -IF(BUILD_SHARED_LIBS) - ADD_EXECUTABLE(yasm - yasm.c - yasm-options.c - yasm-plugin.c - ) - TARGET_LINK_LIBRARIES(yasm libyasm ${LIBDL}) - ADD_DEPENDENCIES(yasm yasmstd) - SET_PROPERTY(TARGET yasm APPEND PROPERTY BUILD_RPATH "$") -ELSE(BUILD_SHARED_LIBS) - ADD_EXECUTABLE(yasm - yasm.c - yasm-options.c - ) - TARGET_LINK_LIBRARIES(yasm yasmstd libyasm) -ENDIF(BUILD_SHARED_LIBS) - -SET_SOURCE_FILES_PROPERTIES(yasm.c PROPERTIES - OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/license.c - ) - -INSTALL(TARGETS yasm RUNTIME DESTINATION bin) diff --git a/frontends/yasm/Makefile.inc b/frontends/yasm/Makefile.inc index ff73f952..1e0a8362 100644 --- a/frontends/yasm/Makefile.inc +++ b/frontends/yasm/Makefile.inc @@ -1,3 +1,5 @@ +# $Id$ + bin_PROGRAMS += yasm dist_man_MANS += yasm.1 diff --git a/frontends/yasm/genstring.py b/frontends/yasm/genstring.py deleted file mode 100755 index 5e8bf8a1..00000000 --- a/frontends/yasm/genstring.py +++ /dev/null @@ -1,45 +0,0 @@ -#!/usr/bin/env python -# Generate array-of-const-string from text file. -# -# Copyright (C) 2006-2007 Peter Johnson -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND OTHER CONTRIBUTORS ``AS IS'' -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR OTHER CONTRIBUTORS BE -# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -import sys - -def lprint(s, f = sys.stdout, e = '\n') : - f.write(s + e) - -def file_to_string(fout, str_name, fin_name): - from os.path import basename - lprint("/* This file auto-generated from %s by genstring.py - don't edit it */\n" % basename(fin_name), f=fout) - lprint("static const char* %s[] = {" % str_name, f=fout) - lprint("\n".join(' "%s",' % - l.strip().replace('\\', '\\\\').replace('"', '\\"') - for l in open(fin_name)), - f=fout) - lprint("};", f=fout) - -if __name__ == "__main__": - if len(sys.argv) != 4: - lprint("Usage: genstring.py ", f=sys.stderr) - sys.exit(2) - file_to_string(open(sys.argv[2], "w"), sys.argv[1], sys.argv[3]) diff --git a/frontends/yasm/yasm-options.c b/frontends/yasm/yasm-options.c index e493207b..fed8d694 100644 --- a/frontends/yasm/yasm-options.c +++ b/frontends/yasm/yasm-options.c @@ -28,7 +28,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -#include +/*@unused@*/ RCSID("$Id$"); #include "yasm-options.h" @@ -43,7 +43,7 @@ /* Options Parser */ int parse_cmdline(int argc, char **argv, opt_option *options, size_t nopts, - void (*print_error) (const char *fmt, ...)) + void (*print_error) (const char *fmt, ...)) { int errors = 0, warnings = 0; size_t i; @@ -53,138 +53,101 @@ parse_cmdline(int argc, char **argv, opt_option *options, size_t nopts, fail: while (--argc) { - argv++; + argv++; - if (argv[0][0] == '-') { /* opt */ - got_it = 0; - if (argv[0][1] == '-') { /* lopt */ - if (argv[0][2] == '\0') { /* --, end of options */ - /* Handle rest of args as non-options */ - while (--argc) { - argv++; - if (not_an_option_handler(argv[0])) - errors++; - } - return errors; - } + if (argv[0][0] == '-') { /* opt */ + got_it = 0; + if (argv[0][1] == '-') { /* lopt */ + if (argv[0][2] == '\0') { /* --, end of options */ + /* Handle rest of args as non-options */ + while (--argc) { + argv++; + if (not_an_option_handler(argv[0])) + errors++; + } + return errors; + } - for (i = 0; i < nopts; i++) { - size_t optlen; - if (options[i].lopt && - strncmp(&argv[0][2], options[i].lopt, - (optlen = strlen(options[i].lopt))) == 0) { - char *param; - char c = argv[0][2 + optlen]; + for (i = 0; i < nopts; i++) { + if (options[i].lopt && + strncmp(&argv[0][2], options[i].lopt, + strlen(options[i].lopt)) == 0) { + char *param; - if (c != '\0' && c != '=' && !isspace(c)) - continue; + if (options[i].takes_param) { + param = strchr(&argv[0][2], '='); + if (!param) { + print_error( + _("option `--%s' needs an argument!"), + options[i].lopt); + errors++; + goto fail; + } else { + *param = '\0'; + param++; + } + } else + param = NULL; - if (options[i].takes_param) { - param = strchr(&argv[0][2], '='); - if (!param) { - print_error( - _("option `--%s' needs an argument!"), - options[i].lopt); - errors++; - goto fail; - } else { - *param = '\0'; - param++; - } - } else - param = NULL; + if (!options[i]. + handler(&argv[0][2], param, options[i].extra)) + got_it = 1; + break; + } + } + if (!got_it && !other_option_handler(argv[0])) + got_it = 1; + if (!got_it) { + print_error(_("warning: unrecognized option `%s'"), + argv[0]); + warnings++; + } + } else if (argv[0][1] == '\0') { /* just -, is non-option */ + if (not_an_option_handler(argv[0])) + errors++; + } else { /* sopt */ + for (i = 0; i < nopts; i++) { + if (argv[0][1] == options[i].sopt) { + char *cmd = &argv[0][1]; + char *param; - if (!options[i]. - handler(&argv[0][2], param, options[i].extra)) - got_it = 1; - break; - } - } - if (!got_it && !other_option_handler(argv[0])) - got_it = 1; - if (!got_it) { - print_error(_("warning: unrecognized option `%s'"), - argv[0]); - warnings++; - } - } else if (argv[0][1] == '\0') { /* just -, is non-option */ - if (not_an_option_handler(argv[0])) - errors++; - } else { /* sopt */ - for (i = 0; i < nopts; i++) { - size_t optlen; - if (argv[0][1] == options[i].sopt) { - char *cmd = &argv[0][1]; - char *param; + if (options[i].takes_param) { + param = argv[1]; + if (argv[0][2] != '\0') + param = &argv[0][2]; + else if (param == NULL || *param == '-') { + print_error( + _("option `-%c' needs an argument!"), + options[i].sopt); + errors++; + goto fail; + } else { + argc--; + argv++; + } + } else + param = NULL; - if (options[i].takes_param) { - param = argv[1]; - if (argv[0][2] != '\0') - param = &argv[0][2]; - else if (param == NULL || *param == '-') { - print_error( - _("option `-%c' needs an argument!"), - options[i].sopt); - errors++; - goto fail; - } else { - argc--; - argv++; - } - } else - param = NULL; + if (!options[i].handler(cmd, param, options[i].extra)) + got_it = 1; + break; + } + } + if (!got_it && !other_option_handler(argv[0])) + got_it = 1; + if (!got_it) { + print_error(_("warning: unrecognized option `%s'"), + argv[0]); + warnings++; + } + } + } else { /* not an option, then it should be a file or something */ - if (!options[i].handler(cmd, param, options[i].extra)) - got_it = 1; - break; - } - /* also allow longopt with single dash */ - if (options[i].lopt && - strncmp(&argv[0][1], options[i].lopt, - (optlen = strlen(options[i].lopt))) == 0) { - char *param; - char c = argv[0][1 + optlen]; - - if (c != '\0' && c != '=' && !isspace(c)) - continue; - - if (options[i].takes_param) { - param = strchr(&argv[0][1], '='); - if (!param) { - print_error( - _("option `-%s' needs an argument!"), - options[i].lopt); - errors++; - goto fail; - } else { - *param = '\0'; - param++; - } - } else - param = NULL; - - if (!options[i]. - handler(&argv[0][1], param, options[i].extra)) - got_it = 1; - break; - } - } - if (!got_it && !other_option_handler(argv[0])) - got_it = 1; - if (!got_it) { - print_error(_("warning: unrecognized option `%s'"), - argv[0]); - warnings++; - } - } - } else { /* not an option, then it should be a file or something */ - - if (not_an_option_handler(argv[0])) - errors++; - } + if (not_an_option_handler(argv[0])) + errors++; + } } - (void) warnings; DEBUG((stderr, "parse_cmdline: finished\n")); return errors; } @@ -198,50 +161,50 @@ help_msg(const char *msg, const char *tail, opt_option *options, size_t nopts) printf("%s", gettext(msg)); for (i = 0; i < nopts; i++) { - size_t shortopt_len = 0; - size_t longopt_len = 0; + size_t shortopt_len = 0; + size_t longopt_len = 0; - optbuf[0] = 0; - optopt[0] = 0; + optbuf[0] = 0; + optopt[0] = 0; - if (options[i].takes_param) { - if (options[i].sopt) { - sprintf(optbuf, "-%c <%s>", options[i].sopt, - options[i].param_desc ? options[i]. - param_desc : _("param")); - shortopt_len = strlen(optbuf); - } - if (options[i].sopt && options[i].lopt) - strcat(optbuf, ", "); - if (options[i].lopt) { - sprintf(optopt, "--%s=<%s>", options[i].lopt, - options[i].param_desc ? options[i]. - param_desc : _("param")); - strcat(optbuf, optopt); - longopt_len = strlen(optbuf); - } - } else { - if (options[i].sopt) { - sprintf(optbuf, "-%c", options[i].sopt); - shortopt_len = strlen(optbuf); - } - if (options[i].sopt && options[i].lopt) - strcat(optbuf, ", "); - if (options[i].lopt) { - sprintf(optopt, "--%s", options[i].lopt); - strcat(optbuf, optopt); - longopt_len = strlen(optbuf); - } - } + if (options[i].takes_param) { + if (options[i].sopt) { + sprintf(optbuf, "-%c <%s>", options[i].sopt, + options[i].param_desc ? options[i]. + param_desc : _("param")); + shortopt_len = strlen(optbuf); + } + if (options[i].sopt && options[i].lopt) + strcat(optbuf, ", "); + if (options[i].lopt) { + sprintf(optopt, "--%s=<%s>", options[i].lopt, + options[i].param_desc ? options[i]. + param_desc : _("param")); + strcat(optbuf, optopt); + longopt_len = strlen(optbuf); + } + } else { + if (options[i].sopt) { + sprintf(optbuf, "-%c", options[i].sopt); + shortopt_len = strlen(optbuf); + } + if (options[i].sopt && options[i].lopt) + strcat(optbuf, ", "); + if (options[i].lopt) { + sprintf(optopt, "--%s", options[i].lopt); + strcat(optbuf, optopt); + longopt_len = strlen(optbuf); + } + } - /* split [-s ], [--long ] if it destroys columns */ - if (shortopt_len && longopt_len && longopt_len > 22) { - optbuf[shortopt_len] = '\0'; - printf(" %-22s %s\n", optopt, gettext(options[i].description)); - printf(" %s\n", optbuf); - } - else - printf(" %-22s %s\n", optbuf, gettext(options[i].description)); + /* split [-s ], [--long ] if it destroys columns */ + if (shortopt_len && longopt_len && longopt_len > 22) { + optbuf[shortopt_len] = '\0'; + printf(" %-22s %s\n", optopt, gettext(options[i].description)); + printf(" %s\n", optbuf); + } + else + printf(" %-22s %s\n", optbuf, gettext(options[i].description)); } printf("%s", gettext(tail)); diff --git a/frontends/yasm/yasm-options.h b/frontends/yasm/yasm-options.h index 63c4fbea..04cf0434 100644 --- a/frontends/yasm/yasm-options.h +++ b/frontends/yasm/yasm-options.h @@ -1,4 +1,4 @@ -/* +/* $Id$ * Generic Options Support Header File * * Copyright (c) 2001 Stanislav Karchebny @@ -42,7 +42,7 @@ typedef struct opt_option_s int takes_param; int (*handler) (char *cmd, /*@null@*/ char *param, int extra); - int extra; /* extra value for handler */ + int extra; /* extra value for handler */ /* description to use in help_msg() */ /*@observer@*/ const char *description; @@ -64,12 +64,12 @@ int other_option_handler(char *option); * nopts - options count */ int parse_cmdline(int argc, char **argv, opt_option *options, size_t nopts, - void (*print_error) (const char *fmt, ...)); + void (*print_error) (const char *fmt, ...)); /* display help message msg followed by list of options in options and followed * by tail */ void help_msg(const char *msg, const char *tail, opt_option *options, - size_t nopts); + size_t nopts); #endif diff --git a/frontends/yasm/yasm-plugin.c b/frontends/yasm/yasm-plugin.c deleted file mode 100644 index 573ab45b..00000000 --- a/frontends/yasm/yasm-plugin.c +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Semi-portable (Windows and Unix) plugin loading - * - * Copyright (C) 2008 Peter Johnson - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND OTHER CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR OTHER CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -#include - -#include - -#include "libyasm-stdint.h" -#include "yasm-plugin.h" - -#if defined(_WIN32) -#include -#elif defined(__GNUC__) -#include -#endif - -static void **loaded_plugins = NULL; -static int num_loaded_plugins = 0; - -static void * -load_dll(const char *name) -{ -#if defined(_WIN32) - return LoadLibrary(name); -#elif defined(__GNUC__) - return dlopen(name, RTLD_NOW); -#else - return NULL; -#endif -} - -int -load_plugin(const char *name) -{ - char *path; - void *lib = NULL; - void (*init_plugin) (void) = NULL; - - /* Load library */ - - path = yasm_xmalloc(strlen(name)+10); -#if defined(_WIN32) - strcpy(path, name); - strcat(path, ".dll"); - lib = load_dll(path); -#elif defined(__GNUC__) - strcpy(path, "lib"); - strcat(path, name); - strcat(path, ".so"); - lib = load_dll(path); - if (!lib) { - strcpy(path, name); - strcat(path, ".so"); - lib = load_dll(path); - } -#endif - yasm_xfree(path); - if (!lib) - lib = load_dll(name); - - if (!lib) - return 0; /* Didn't load successfully */ - - /* Add to array of loaded plugins */ - loaded_plugins = - yasm_xrealloc(loaded_plugins, (num_loaded_plugins+1)*sizeof(void *)); - loaded_plugins[num_loaded_plugins] = lib; - num_loaded_plugins++; - - /* Get yasm_init_plugin() function and run it */ - -#if defined(_WIN32) - init_plugin = - (void (*)(void))GetProcAddress((HINSTANCE)lib, "yasm_init_plugin"); -#elif defined(__GNUC__) - init_plugin = (void (*)(void))(uintptr_t)dlsym(lib, "yasm_init_plugin"); -#endif - - if (!init_plugin) - return 0; /* Didn't load successfully */ - - init_plugin(); - return 1; -} - -void -unload_plugins(void) -{ - int i; - - if (!loaded_plugins) - return; - - for (i = 0; i < num_loaded_plugins; i++) { -#if defined(_WIN32) - FreeLibrary((HINSTANCE)loaded_plugins[i]); -#elif defined(__GNUC__) - dlclose(loaded_plugins[i]); -#endif - } - yasm_xfree(loaded_plugins); - num_loaded_plugins = 0; -} diff --git a/frontends/yasm/yasm-plugin.h b/frontends/yasm/yasm-plugin.h deleted file mode 100644 index efb1bf51..00000000 --- a/frontends/yasm/yasm-plugin.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Semi-portable (Windows and Unix) plugin loading - * - * Copyright (C) 2008 Peter Johnson - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND OTHER CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR OTHER CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -#ifndef YASM_PLUGIN_H -#define YASM_PLUGIN_H - -/* Load a plugin. Returns 0 on failure. */ -int load_plugin(const char *name); -void unload_plugins(void); - -#endif diff --git a/frontends/yasm/yasm.c b/frontends/yasm/yasm.c index 2aab8350..268ddec0 100644 --- a/frontends/yasm/yasm.c +++ b/frontends/yasm/yasm.c @@ -25,6 +25,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include +/*@unused@*/ RCSID("$Id$"); #include #include @@ -37,18 +38,13 @@ #include "yasm-options.h" -#if defined(CMAKE_BUILD) && defined(BUILD_SHARED_LIBS) -#include "yasm-plugin.h" -#endif - #include "license.c" /* Preprocess-only buffer size */ #define PREPROC_BUF_SIZE 16384 /*@null@*/ /*@only@*/ static char *obj_filename = NULL, *in_filename = NULL; -/*@null@*/ /*@only@*/ static char *global_prefix = NULL, *global_suffix = NULL; -/*@null@*/ /*@only@*/ static char *list_filename = NULL, *map_filename = NULL; +/*@null@*/ /*@only@*/ static char *list_filename = NULL; /*@null@*/ /*@only@*/ static char *machine_name = NULL; static int special_options = 0; /*@null@*/ /*@dependent@*/ static yasm_arch *cur_arch = NULL; @@ -70,11 +66,7 @@ static int special_options = 0; static int preproc_only = 0; static unsigned int force_strict = 0; static int generate_make_dependencies = 0; -static int makedep_with_empty_recipts = 0; -static int makedep_dos2unix_slash = 0; -/*@null@*/ /*@only@*/ static const char *makedep_out_filename = NULL; -/*@null@*/ /*@only@*/ static const char *makedep_target = NULL; -static int warning_error = 0; /* warnings being treated as errors */ +static int warning_error = 0; /* warnings being treated as errors */ static FILE *errfile; /*@null@*/ /*@only@*/ static char *error_filename = NULL; static enum { @@ -83,10 +75,10 @@ static enum { } ewmsg_style = EWSTYLE_GNU; /*@null@*/ /*@dependent@*/ static FILE *open_file(const char *filename, - const char *mode); + const char *mode); static void check_errors(/*@only@*/ yasm_errwarns *errwarns, - /*@only@*/ yasm_object *object, - /*@only@*/ yasm_linemap *linemap); + /*@only@*/ yasm_object *object, + /*@only@*/ yasm_linemap *linemap); static void cleanup(/*@null@*/ /*@only@*/ yasm_object *object); /* Forward declarations: cmd line parser handlers */ @@ -99,7 +91,6 @@ static int opt_dbgfmt_handler(char *cmd, /*@null@*/ char *param, int extra); static int opt_listfmt_handler(char *cmd, /*@null@*/ char *param, int extra); static int opt_listfile_handler(char *cmd, /*@null@*/ char *param, int extra); static int opt_objfile_handler(char *cmd, /*@null@*/ char *param, int extra); -static int opt_mapfile_handler(char *cmd, /*@null@*/ char *param, int extra); static int opt_machine_handler(char *cmd, /*@null@*/ char *param, int extra); static int opt_strict_handler(char *cmd, /*@null@*/ char *param, int extra); static int opt_warning_handler(char *cmd, /*@null@*/ char *param, int extra); @@ -109,46 +100,28 @@ static int preproc_only_handler(char *cmd, /*@null@*/ char *param, int extra); static int opt_include_option(char *cmd, /*@null@*/ char *param, int extra); static int opt_preproc_option(char *cmd, /*@null@*/ char *param, int extra); static int opt_ewmsg_handler(char *cmd, /*@null@*/ char *param, int extra); -static int opt_makedep_and_assemble_handler(char *cmd, /*@null@*/ char *param, int extra); -static int opt_makedep_empty_handler(char *cmd, /*@null@*/ char *param, int extra); -static int opt_makedep_target_handler(char *cmd, /*@null@*/ char *param, int extra); static int opt_makedep_handler(char *cmd, /*@null@*/ char *param, int extra); -static int opt_makedep_dos2unix_slash_handler(char *cmd, /*@null@*/ char *param, int extra); -static int opt_prefix_handler(char *cmd, /*@null@*/ char *param, int extra); -static int opt_suffix_handler(char *cmd, /*@null@*/ char *param, int extra); -#if defined(CMAKE_BUILD) && defined(BUILD_SHARED_LIBS) -static int opt_plugin_handler(char *cmd, /*@null@*/ char *param, int extra); -#endif - -#if defined(CMAKE_BUILD) && !defined(BUILD_SHARED_LIBS) -void yasm_init_plugin(void); -#endif static /*@only@*/ char *replace_extension(const char *orig, /*@null@*/ - const char *ext, const char *def); + const char *ext, const char *def); static void print_error(const char *fmt, ...); static /*@exits@*/ void handle_yasm_int_error(const char *file, - unsigned int line, - const char *message); + unsigned int line, + const char *message); static /*@exits@*/ void handle_yasm_fatal(const char *message, va_list va); static const char *handle_yasm_gettext(const char *msgid); static void print_yasm_error(const char *filename, unsigned long line, - const char *msg, /*@null@*/ const char *xref_fn, - unsigned long xref_line, - /*@null@*/ const char *xref_msg); + const char *msg, /*@null@*/ const char *xref_fn, + unsigned long xref_line, + /*@null@*/ const char *xref_msg); static void print_yasm_warning(const char *filename, unsigned long line, - const char *msg); + const char *msg); static void apply_preproc_builtins(void); -static void apply_preproc_standard_macros(const yasm_stdmac *stdmacs); static void apply_preproc_saved_options(void); static void print_list_keyword_desc(const char *name, const char *keyword); -#ifndef MAX -# define MAX(a, b) ( ((a) > (b)) ? (a) : (b) ) -#endif - /* values for special_options */ #define SPECIAL_SHOW_HELP 0x01 #define SPECIAL_SHOW_VERSION 0x02 @@ -180,8 +153,6 @@ static opt_option options[] = N_("name of list-file output"), N_("listfile") }, { 'o', "objfile", 1, opt_objfile_handler, 0, N_("name of object-file output"), N_("filename") }, - { 0, "mapfile", 1, opt_mapfile_handler, 0, - N_("name of map-file output"), N_("filename") }, { 'm', "machine", 1, opt_machine_handler, 0, N_("select machine (list with -m help)"), N_("machine") }, { 0, "force-strict", 0, opt_strict_handler, 0, @@ -190,58 +161,33 @@ static opt_option options[] = N_("inhibits warning messages"), NULL }, { 'W', NULL, 0, opt_warning_handler, 0, N_("enables/disables warning"), NULL }, - { 0, "MD", 1, opt_makedep_and_assemble_handler, 0, - N_("generate Makefile dependencies and assemble normally"), - N_("file")}, - { 0, "MP", 0, opt_makedep_empty_handler, 0, - N_("generate empty Makefile recipts for the include files"), NULL }, - { 0, "MT", 1, opt_makedep_target_handler, 0, - N_("the Makefile target to associate the dependencies with"), - N_("target")}, - { 'M', NULL, 0, opt_makedep_handler, 0, /* -M must come after -MD and -MP'! */ + { 'M', NULL, 0, opt_makedep_handler, 0, N_("generate Makefile dependencies on stdout"), NULL }, - { 0, "makedep-dos2unix-slash", 0, opt_makedep_dos2unix_slash_handler, 0, - N_("convert DOS to UNIX slashes in Makefile dependencies file"), NULL }, - { 'Z', NULL, 1, opt_error_file, 0, + { 'E', NULL, 1, opt_error_file, 0, N_("redirect error messages to file"), N_("file") }, { 's', NULL, 0, opt_error_stdout, 0, N_("redirect error messages to stdout"), NULL }, { 'e', "preproc-only", 0, preproc_only_handler, 0, N_("preprocess only (writes output to stdout by default)"), NULL }, - { 'E', NULL, 0, preproc_only_handler, 0, - N_("preprocess only (writes output to stdout by default)"), NULL }, { 'i', NULL, 1, opt_include_option, 0, N_("add include path"), N_("path") }, { 'I', NULL, 1, opt_include_option, 0, N_("add include path"), N_("path") }, { 'P', NULL, 1, opt_preproc_option, 0, N_("pre-include file"), N_("filename") }, - { 'd', NULL, 1, opt_preproc_option, 1, - N_("pre-define a macro, optionally to value"), N_("macro[=value]") }, { 'D', NULL, 1, opt_preproc_option, 1, N_("pre-define a macro, optionally to value"), N_("macro[=value]") }, - { 'u', NULL, 1, opt_preproc_option, 2, - N_("undefine a macro"), N_("macro") }, { 'U', NULL, 1, opt_preproc_option, 2, N_("undefine a macro"), N_("macro") }, { 'X', NULL, 1, opt_ewmsg_handler, 0, N_("select error/warning message style (`gnu' or `vc')"), N_("style") }, - { 0, "prefix", 1, opt_prefix_handler, 0, - N_("prepend argument to name of all external symbols"), N_("prefix") }, - { 0, "suffix", 1, opt_suffix_handler, 0, - N_("append argument to name of all external symbols"), N_("suffix") }, - { 0, "postfix", 1, opt_suffix_handler, 0, - N_("append argument to name of all external symbols"), N_("suffix") }, -#if defined(CMAKE_BUILD) && defined(BUILD_SHARED_LIBS) - { 'N', "plugin", 1, opt_plugin_handler, 0, - N_("load plugin module"), N_("plugin") }, -#endif }; /* version message */ /*@observer@*/ static const char *version_msg[] = { - PACKAGE_STRING, - "Copyright (c) 2001-2014 Peter Johnson and other Yasm developers.", + PACKAGE_NAME " " PACKAGE_INTVER "." PACKAGE_BUILD, + "Compiled on " __DATE__ ".", + "Copyright (c) 2001-2007 Peter Johnson and other Yasm developers.", "Run yasm --license for licensing overview and summary." }; @@ -269,202 +215,101 @@ typedef struct constcharparam { static constcharparam_head preproc_options; -static char * -dos2unix_slash(char *path) -{ - char *slash = strchr(path, '\\'); - while (slash) { - *slash++ = '/'; - slash = strchr(slash, '\\'); - } - return path; -} - static int -do_generate_make_dependencies(void) -{ - size_t empty_recipts_alloc = 0; - size_t empty_recipts_len = 0; - char *empty_recipts = NULL; - char *preproc_buf; - size_t linelen; - size_t got; - FILE *depout = stdout; - const char *target; - - /* Open the -MD . */ - if ( makedep_out_filename != NULL - && strcmp(makedep_out_filename, "-") != 0) { - depout = open_file(makedep_out_filename, "wt"); - if (!depout) - return EXIT_FAILURE; - } - - /* -MT (and later -MQ?) can be used to specify the target name. - If not given, fall back on the object file. */ - target = makedep_target ? makedep_target : obj_filename; - - /* Make sure preproc_buf is large enough for either of the main - file names to avoid checking later (very ulikely that it isn't). */ - linelen = strlen(target); - got = strlen(in_filename); - preproc_buf = yasm_xmalloc(MAX(PREPROC_BUF_SIZE, MAX(got, linelen) + 1)); - - /* The target (the object file) to add the dependencies to. */ - if (!makedep_dos2unix_slash || makedep_target == NULL) - fputs(target, depout); - else - fputs(dos2unix_slash(memcpy(preproc_buf, target, linelen + 1)), - depout); - - /* The source file (no empty rule for it, thus the code duplication). */ - linelen += 2 + got; - if (linelen <= 72) - fputs(": ", depout); - else { - fputs(": \\\n ", depout); - linelen = 1 + got; - } - if (!makedep_dos2unix_slash) - fwrite(in_filename, got, 1, depout); - else - fwrite(dos2unix_slash(memcpy(preproc_buf, in_filename, got + 1)), - got, 1, depout); - - /* Now the include files. */ - while ((got = yasm_preproc_get_included_file(cur_preproc, preproc_buf, - PREPROC_BUF_SIZE)) != 0) { - linelen += 1 + got; - if (linelen <= 72) - fputc(' ', depout); - else { - fputs(" \\\n ", depout); - linelen = 1 + got; - } - if (makedep_dos2unix_slash) - dos2unix_slash(preproc_buf); - fwrite(preproc_buf, got, 1, depout); - - if (makedep_with_empty_recipts) { - /* We only get one shot at each include file, so we generate the - dummy recipts in a buffer while we're writing the dependencies - for the object file. (The empty recipts makes make shut up - about deleted includes.) */ - static const char empty_tail[] = ":\n\n"; - size_t cur_len = empty_recipts_len; - - empty_recipts_len = cur_len + got + sizeof(empty_tail) - 1; - if (empty_recipts_len >= empty_recipts_alloc) { - if (empty_recipts_alloc == 0) - empty_recipts_alloc = 4096; - while (empty_recipts_len >= empty_recipts_alloc) - empty_recipts_alloc *= 2; - empty_recipts = yasm_xrealloc(empty_recipts, - empty_recipts_alloc); - } - - memcpy(&empty_recipts[cur_len], preproc_buf, got); - cur_len += got; - memcpy(&empty_recipts[cur_len], empty_tail, sizeof(empty_tail)); - } - } - - fputc('\n', depout); - yasm_xfree(preproc_buf); - - if (empty_recipts) { - fputc('\n', depout); - fwrite(empty_recipts, empty_recipts_len, 1, depout); - yasm_xfree(empty_recipts); - } - - if ( depout != stdout - && fclose(depout) != 0) { - print_error(_("error writing `%s'"), makedep_out_filename); - return EXIT_FAILURE; - } - - return 0; -} - -static int -do_preproc_only(void) +do_preproc_only(FILE *in) { yasm_linemap *linemap; - char *preproc_buf; + char *preproc_buf = yasm_xmalloc(PREPROC_BUF_SIZE); + size_t got; const char *base_filename; FILE *out = NULL; yasm_errwarns *errwarns = yasm_errwarns_create(); /* Initialize line map */ linemap = yasm_linemap_create(); - yasm_linemap_set(linemap, in_filename, 0, 1, 1); + yasm_linemap_set(linemap, in_filename, 1, 1); /* Default output to stdout if not specified or generating dependency makefiles */ if (!obj_filename || generate_make_dependencies) { - out = stdout; + out = stdout; /* determine the object filename if not specified, but we need a file name for the makefile rule */ if (generate_make_dependencies && !obj_filename) { - if (in_filename == NULL) + if (in == stdin) /* Default to yasm.out if no obj filename specified */ - obj_filename = yasm__xstrdup("yasm.out"); + obj_filename = yasm__xstrdup("yasm.out"); else { /* replace (or add) extension to base filename */ - yasm__splitpath(in_filename, &base_filename); - if (base_filename[0] == '\0') - obj_filename = yasm__xstrdup("yasm.out"); - else - obj_filename = replace_extension(base_filename, + yasm__splitpath(in_filename, &base_filename); + if (base_filename[0] == '\0') + obj_filename = yasm__xstrdup("yasm.out"); + else + obj_filename = replace_extension(base_filename, cur_objfmt_module->extension, "yasm.out"); - } + } } } else { - /* Open output (object) file */ - out = open_file(obj_filename, "wt"); - if (!out) - return EXIT_FAILURE; + /* Open output (object) file */ + out = open_file(obj_filename, "wt"); + if (!out) { + yasm_xfree(preproc_buf); + return EXIT_FAILURE; + } } - /* Create preprocessor */ - cur_preproc = yasm_preproc_create(cur_preproc_module, in_filename, NULL, - linemap, errwarns); - - /* Apply macros */ - apply_preproc_builtins(); - apply_preproc_standard_macros(cur_parser_module->stdmacs); - apply_preproc_standard_macros(cur_objfmt_module->stdmacs); - apply_preproc_saved_options(); - /* Pre-process until done */ + cur_preproc = yasm_preproc_create(cur_preproc_module, in, in_filename, + linemap, errwarns); + + apply_preproc_builtins(); + apply_preproc_saved_options(); + if (generate_make_dependencies) { - do_generate_make_dependencies(); + size_t totlen; + + fprintf(stdout, "%s: %s", obj_filename, in_filename); + totlen = strlen(obj_filename)+2+strlen(in_filename); + + while ((got = yasm_preproc_get_included_file(cur_preproc, preproc_buf, + PREPROC_BUF_SIZE)) != 0) { + totlen += got; + if (totlen > 72) { + fputs(" \\\n ", stdout); + totlen = 2; + } + fputc(' ', stdout); + fwrite(preproc_buf, got, 1, stdout); + } + fputc('\n', stdout); } else { - while ((preproc_buf = yasm_preproc_get_line(cur_preproc)) != NULL) { - fputs(preproc_buf, out); - fputc('\n', out); - yasm_xfree(preproc_buf); - } + while ((got = yasm_preproc_input(cur_preproc, preproc_buf, + PREPROC_BUF_SIZE)) != 0) + fwrite(preproc_buf, got, 1, out); } + if (in != stdin) + fclose(in); + if (out != stdout) - fclose(out); + fclose(out); if (yasm_errwarns_num_errors(errwarns, warning_error) > 0) { - yasm_errwarns_output_all(errwarns, linemap, warning_error, - print_yasm_error, print_yasm_warning); - if (out != stdout) - remove(obj_filename); - yasm_linemap_destroy(linemap); - yasm_errwarns_destroy(errwarns); - cleanup(NULL); - return EXIT_FAILURE; + yasm_errwarns_output_all(errwarns, linemap, warning_error, + print_yasm_error, print_yasm_warning); + if (out != stdout) + remove(obj_filename); + yasm_xfree(preproc_buf); + yasm_linemap_destroy(linemap); + yasm_errwarns_destroy(errwarns); + cleanup(NULL); + return EXIT_FAILURE; } yasm_errwarns_output_all(errwarns, linemap, warning_error, - print_yasm_error, print_yasm_warning); + print_yasm_error, print_yasm_warning); + yasm_xfree(preproc_buf); yasm_linemap_destroy(linemap); yasm_errwarns_destroy(errwarns); cleanup(NULL); @@ -472,7 +317,7 @@ do_preproc_only(void) } static int -do_assemble(void) +do_assemble(FILE *in) { yasm_object *object; const char *base_filename; @@ -481,89 +326,82 @@ do_assemble(void) yasm_linemap *linemap; yasm_errwarns *errwarns = yasm_errwarns_create(); int i, matched; - const char *machine; /* Initialize line map */ linemap = yasm_linemap_create(); - yasm_linemap_set(linemap, in_filename, 0, 1, 1); + yasm_linemap_set(linemap, in_filename, 1, 1); /* determine the object filename if not specified */ if (!obj_filename) { - if (in_filename == NULL) - /* Default to yasm.out if no obj filename specified */ - obj_filename = yasm__xstrdup("yasm.out"); - else { - /* replace (or add) extension to base filename */ - yasm__splitpath(in_filename, &base_filename); - if (base_filename[0] == '\0') - obj_filename = yasm__xstrdup("yasm.out"); - else - obj_filename = replace_extension(base_filename, - cur_objfmt_module->extension, - "yasm.out"); - } + if (in == stdin) + /* Default to yasm.out if no obj filename specified */ + obj_filename = yasm__xstrdup("yasm.out"); + else { + /* replace (or add) extension to base filename */ + yasm__splitpath(in_filename, &base_filename); + if (base_filename[0] == '\0') + obj_filename = yasm__xstrdup("yasm.out"); + else + obj_filename = replace_extension(base_filename, + cur_objfmt_module->extension, + "yasm.out"); + } } /* Set up architecture using machine and parser. */ if (!machine_name) { - /* If we're using x86 and the default objfmt bits is 64, default the - * machine to amd64. When we get more arches with multiple machines, - * we should do this in a more modular fashion. - */ - if (yasm__strcasecmp(cur_arch_module->keyword, "x86") == 0 && - cur_objfmt_module->default_x86_mode_bits == 64) - machine_name = yasm__xstrdup("amd64"); - else - machine_name = - yasm__xstrdup(cur_arch_module->default_machine_keyword); + /* If we're using x86 and the default objfmt bits is 64, default the + * machine to amd64. When we get more arches with multiple machines, + * we should do this in a more modular fashion. + */ + if (strcmp(cur_arch_module->keyword, "x86") == 0 && + cur_objfmt_module->default_x86_mode_bits == 64) + machine_name = yasm__xstrdup("amd64"); + else + machine_name = + yasm__xstrdup(cur_arch_module->default_machine_keyword); } - /* If we're using amd64 and the default objfmt is elfx32, change the - * machine to "x32". - */ - if (yasm__strcasecmp(machine_name, "amd64") == 0 && - yasm__strcasecmp(cur_objfmt_module->keyword, "elfx32") == 0) - machine = "x32"; - else - machine = machine_name; - - cur_arch = yasm_arch_create(cur_arch_module, machine, - cur_parser_module->keyword, &arch_error); + cur_arch = cur_arch_module->create(machine_name, + cur_parser_module->keyword, + &arch_error); if (!cur_arch) { - switch (arch_error) { - case YASM_ARCH_CREATE_BAD_MACHINE: - print_error(_("%s: `%s' is not a valid %s for %s `%s'"), - _("FATAL"), machine_name, _("machine"), - _("architecture"), cur_arch_module->keyword); - break; - case YASM_ARCH_CREATE_BAD_PARSER: - print_error(_("%s: `%s' is not a valid %s for %s `%s'"), - _("FATAL"), cur_parser_module->keyword, - _("parser"), _("architecture"), - cur_arch_module->keyword); - break; - default: - print_error(_("%s: unknown architecture error"), _("FATAL")); - } + switch (arch_error) { + case YASM_ARCH_CREATE_BAD_MACHINE: + print_error(_("%s: `%s' is not a valid %s for %s `%s'"), + _("FATAL"), machine_name, _("machine"), + _("architecture"), cur_arch_module->keyword); + break; + case YASM_ARCH_CREATE_BAD_PARSER: + print_error(_("%s: `%s' is not a valid %s for %s `%s'"), + _("FATAL"), cur_parser_module->keyword, + _("parser"), _("architecture"), + cur_arch_module->keyword); + break; + default: + print_error(_("%s: unknown architecture error"), _("FATAL")); + } - return EXIT_FAILURE; + return EXIT_FAILURE; } /* Create object */ object = yasm_object_create(in_filename, obj_filename, cur_arch, - cur_objfmt_module, cur_dbgfmt_module); + cur_objfmt_module, cur_dbgfmt_module); if (!object) { - yasm_error_class eclass; - unsigned long xrefline; - /*@only@*/ /*@null@*/ char *estr, *xrefstr; + yasm_error_class eclass; + unsigned long xrefline; + /*@only@*/ /*@null@*/ char *estr, *xrefstr; - yasm_error_fetch(&eclass, &estr, &xrefline, &xrefstr); - print_error("%s: %s", _("FATAL"), estr); - yasm_xfree(estr); - yasm_xfree(xrefstr); + yasm_error_fetch(&eclass, &estr, &xrefline, &xrefstr); + print_error("%s: %s", _("FATAL"), estr); + yasm_xfree(estr); + yasm_xfree(xrefstr); - cleanup(object); - return EXIT_FAILURE; + if (in != stdin) + fclose(in); + cleanup(object); + return EXIT_FAILURE; } /* Get a fresh copy of objfmt_module as it may have changed. */ @@ -574,72 +412,40 @@ do_assemble(void) */ matched = 0; for (i=0; cur_parser_module->preproc_keywords[i]; i++) - { - if (yasm__strcasecmp(cur_parser_module->preproc_keywords[i], - cur_preproc_module->keyword) == 0) { - matched = 1; - break; - } - } - + if (yasm__strcasecmp(cur_parser_module->preproc_keywords[i], + cur_preproc_module->keyword) == 0) + matched = 1; if (!matched) { - print_error(_("%s: `%s' is not a valid %s for %s `%s'"), _("FATAL"), - cur_preproc_module->keyword, _("preprocessor"), - _("parser"), cur_parser_module->keyword); - cleanup(object); - return EXIT_FAILURE; + print_error(_("%s: `%s' is not a valid %s for %s `%s'"), _("FATAL"), + cur_preproc_module->keyword, _("preprocessor"), + _("parser"), cur_parser_module->keyword); + if (in != stdin) + fclose(in); + cleanup(object); + return EXIT_FAILURE; } - if (global_prefix) - yasm_object_set_global_prefix(object, global_prefix); - if (global_suffix) - yasm_object_set_global_suffix(object, global_suffix); - - cur_preproc = yasm_preproc_create(cur_preproc_module, in_filename, - object->symtab, linemap, errwarns); + cur_preproc = cur_preproc_module->create(in, in_filename, linemap, + errwarns); apply_preproc_builtins(); - apply_preproc_standard_macros(cur_parser_module->stdmacs); - apply_preproc_standard_macros(cur_objfmt_module->stdmacs); apply_preproc_saved_options(); /* Get initial x86 BITS setting from object format */ - if (yasm__strcasecmp(cur_arch_module->keyword, "x86") == 0) { - yasm_arch_set_var(cur_arch, "mode_bits", - cur_objfmt_module->default_x86_mode_bits); + if (strcmp(cur_arch_module->keyword, "x86") == 0) { + yasm_arch_set_var(cur_arch, "mode_bits", + cur_objfmt_module->default_x86_mode_bits); } yasm_arch_set_var(cur_arch, "force_strict", force_strict); - /* Try to enable the map file via a map NASM directive. This is - * somewhat of a hack. - */ - if (map_filename) { - const yasm_directive *dir = &cur_objfmt_module->directives[0]; - matched = 0; - for (; dir && dir->name; dir++) { - if (yasm__strcasecmp(dir->name, "map") == 0 && - yasm__strcasecmp(dir->parser, "nasm") == 0) { - yasm_valparamhead vps; - yasm_valparam *vp; - matched = 1; - yasm_vps_initialize(&vps); - vp = yasm_vp_create_string(NULL, yasm__xstrdup(map_filename)); - yasm_vps_append(&vps, vp); - dir->handler(object, &vps, NULL, 0); - yasm_vps_delete(&vps); - } - } - if (!matched) { - print_error( - _("warning: object format `%s' does not support map files"), - cur_objfmt_module->keyword); - } - } - /* Parse! */ - cur_parser_module->do_parse(object, cur_preproc, list_filename != NULL, - linemap, errwarns); + cur_parser_module->do_parse(object, cur_preproc, in, list_filename != NULL, + linemap, errwarns); + + /* Close input file */ + if (in != stdin) + fclose(in); check_errors(errwarns, object, linemap); @@ -656,55 +462,49 @@ do_assemble(void) check_errors(errwarns, object, linemap); /* open the object file for output (if not already opened by dbg objfmt) */ - if (!obj && yasm__strcasecmp(cur_objfmt_module->keyword, "dbg") != 0) { - obj = open_file(obj_filename, "wb"); - if (!obj) { - cleanup(object); - return EXIT_FAILURE; - } + if (!obj && strcmp(cur_objfmt_module->keyword, "dbg") != 0) { + obj = open_file(obj_filename, "wb"); + if (!obj) { + cleanup(object); + return EXIT_FAILURE; + } } /* Write the object file */ yasm_objfmt_output(object, obj?obj:stderr, - yasm__strcasecmp(cur_dbgfmt_module->keyword, "null"), - errwarns); + strcmp(cur_dbgfmt_module->keyword, "null"), errwarns); /* Close object file */ if (obj) - fclose(obj); + fclose(obj); /* If we had an error at this point, we also need to delete the output * object file (to make sure it's not left newer than the source). */ if (yasm_errwarns_num_errors(errwarns, warning_error) > 0) - remove(obj_filename); + remove(obj_filename); check_errors(errwarns, object, linemap); /* Open and write the list file */ if (list_filename) { - FILE *list = open_file(list_filename, "wt"); - if (!list) { - cleanup(object); - return EXIT_FAILURE; - } - /* Initialize the list format */ - cur_listfmt = yasm_listfmt_create(cur_listfmt_module, in_filename, - obj_filename); - yasm_listfmt_output(cur_listfmt, list, linemap, cur_arch); - fclose(list); + FILE *list = open_file(list_filename, "wt"); + if (!list) { + cleanup(object); + return EXIT_FAILURE; + } + /* Initialize the list format */ + cur_listfmt = yasm_listfmt_create(cur_listfmt_module, in_filename, + obj_filename); + yasm_listfmt_output(cur_listfmt, list, linemap, cur_arch); + fclose(list); } - /* Generate make dependency. */ - if (generate_make_dependencies) - do_generate_make_dependencies(); - yasm_errwarns_output_all(errwarns, linemap, warning_error, - print_yasm_error, print_yasm_warning); + print_yasm_error, print_yasm_warning); yasm_linemap_destroy(linemap); yasm_errwarns_destroy(errwarns); cleanup(object); - yasm_delete_include_paths(); return EXIT_SUCCESS; } @@ -713,6 +513,7 @@ do_assemble(void) int main(int argc, char *argv[]) { + /*@null@*/ FILE *in = NULL; size_t i; errfile = stderr; @@ -731,150 +532,152 @@ main(int argc, char *argv[]) yasm_gettext_hook = handle_yasm_gettext; yasm_errwarn_initialize(); + /* Initialize parameter storage */ + STAILQ_INIT(&preproc_options); + + if (parse_cmdline(argc, argv, options, NELEMS(options), print_error)) + return EXIT_FAILURE; + + switch (special_options) { + case SPECIAL_SHOW_HELP: + /* Does gettext calls internally */ + help_msg(help_head, help_tail, options, NELEMS(options)); + return EXIT_SUCCESS; + case SPECIAL_SHOW_VERSION: + for (i=0; imachines; - printf(_("Available %s for %s `%s':\n"), _("machines"), - _("architecture"), cur_arch_module->keyword); - while (m->keyword && m->name) { - print_list_keyword_desc(m->name, m->keyword); - m++; - } - return EXIT_SUCCESS; + const yasm_arch_machine *m = cur_arch_module->machines; + printf(_("Available %s for %s `%s':\n"), _("machines"), + _("architecture"), cur_arch_module->keyword); + while (m->keyword && m->name) { + print_list_keyword_desc(m->name, m->keyword); + m++; + } + return EXIT_SUCCESS; } /* Default to NASM as the parser */ if (!cur_parser_module) { - cur_parser_module = yasm_load_parser("nasm"); - if (!cur_parser_module) { - print_error(_("%s: could not load default %s"), _("FATAL"), - _("parser")); - cleanup(NULL); - return EXIT_FAILURE; - } + cur_parser_module = yasm_load_parser("nasm"); + if (!cur_parser_module) { + print_error(_("%s: could not load default %s"), _("FATAL"), + _("parser")); + cleanup(NULL); + return EXIT_FAILURE; + } } /* If not already specified, default to the parser's default preproc. */ if (!cur_preproc_module) { - cur_preproc_module = - yasm_load_preproc(cur_parser_module->default_preproc_keyword); - if (!cur_preproc_module) { - print_error(_("%s: could not load default %s"), _("FATAL"), - _("preprocessor")); - cleanup(NULL); - return EXIT_FAILURE; - } + cur_preproc_module = + yasm_load_preproc(cur_parser_module->default_preproc_keyword); + if (!cur_preproc_module) { + print_error(_("%s: could not load default %s"), _("FATAL"), + _("preprocessor")); + cleanup(NULL); + return EXIT_FAILURE; + } } /* Determine input filename and open input file. */ if (!in_filename) { - print_error(_("No input files specified")); - return EXIT_FAILURE; + print_error(_("No input files specified")); + return EXIT_FAILURE; + } else if (strcmp(in_filename, "-") != 0) { + /* Open the input file (if not standard input) */ + in = fopen(in_filename, "rt"); + if (!in) { + print_error(_("%s: could not open file `%s'"), _("FATAL"), + in_filename); + yasm_xfree(in_filename); + if (obj_filename) + yasm_xfree(obj_filename); + return EXIT_FAILURE; + } + } else { + /* Filename was "-", read stdin */ + in = stdin; } /* handle preproc-only case here */ if (preproc_only) - return do_preproc_only(); + return do_preproc_only(in); /* If list file enabled, make sure we have a list format loaded. */ if (list_filename) { - /* If not already specified, default to nasm as the list format. */ - if (!cur_listfmt_module) { - cur_listfmt_module = yasm_load_listfmt("nasm"); - if (!cur_listfmt_module) { - print_error(_("%s: could not load default %s"), _("FATAL"), - _("list format")); - return EXIT_FAILURE; - } - } + /* If not already specified, default to nasm as the list format. */ + if (!cur_listfmt_module) { + cur_listfmt_module = yasm_load_listfmt("nasm"); + if (!cur_listfmt_module) { + print_error(_("%s: could not load default %s"), _("FATAL"), + _("list format")); + return EXIT_FAILURE; + } + } } /* If not already specified, default to null as the debug format. */ if (!cur_dbgfmt_module) { - cur_dbgfmt_module = yasm_load_dbgfmt("null"); - if (!cur_dbgfmt_module) { - print_error(_("%s: could not load default %s"), _("FATAL"), - _("debug format")); - return EXIT_FAILURE; - } + cur_dbgfmt_module = yasm_load_dbgfmt("null"); + if (!cur_dbgfmt_module) { + print_error(_("%s: could not load default %s"), _("FATAL"), + _("debug format")); + return EXIT_FAILURE; + } } - return do_assemble(); + return do_assemble(in); } /*@=globstate =unrecog@*/ @@ -886,21 +689,21 @@ open_file(const char *filename, const char *mode) f = fopen(filename, mode); if (!f) - print_error(_("could not open file `%s'"), filename); + print_error(_("could not open file `%s'"), filename); return f; } static void check_errors(yasm_errwarns *errwarns, yasm_object *object, - yasm_linemap *linemap) + yasm_linemap *linemap) { if (yasm_errwarns_num_errors(errwarns, warning_error) > 0) { - yasm_errwarns_output_all(errwarns, linemap, warning_error, - print_yasm_error, print_yasm_warning); - yasm_linemap_destroy(linemap); - yasm_errwarns_destroy(errwarns); - cleanup(object); - exit(EXIT_FAILURE); + yasm_errwarns_output_all(errwarns, linemap, warning_error, + print_yasm_error, print_yasm_warning); + yasm_linemap_destroy(linemap); + yasm_errwarns_destroy(errwarns); + cleanup(object); + exit(EXIT_FAILURE); } } @@ -908,48 +711,43 @@ check_errors(yasm_errwarns *errwarns, yasm_object *object, * Useful for detecting memory leaks, but slows down execution unnecessarily * (as the OS will free everything we miss here). */ -#define DO_FREE 1 +#define DO_FREE 1 /* Cleans up all allocated structures. */ static void cleanup(yasm_object *object) { if (DO_FREE) { - if (cur_listfmt) - yasm_listfmt_destroy(cur_listfmt); - if (cur_preproc) - yasm_preproc_destroy(cur_preproc); - if (object) - yasm_object_destroy(object); + if (cur_listfmt) + yasm_listfmt_destroy(cur_listfmt); + if (cur_preproc) + yasm_preproc_destroy(cur_preproc); + if (object) + yasm_object_destroy(object); - yasm_floatnum_cleanup(); - yasm_intnum_cleanup(); + yasm_floatnum_cleanup(); + yasm_intnum_cleanup(); - yasm_errwarn_cleanup(); + yasm_errwarn_cleanup(); - BitVector_Shutdown(); + BitVector_Shutdown(); } if (DO_FREE) { - if (in_filename) - yasm_xfree(in_filename); - if (obj_filename) - yasm_xfree(obj_filename); - if (list_filename) - yasm_xfree(list_filename); - if (map_filename) - yasm_xfree(map_filename); - if (machine_name) - yasm_xfree(machine_name); - if (objfmt_keyword) - yasm_xfree(objfmt_keyword); + if (in_filename) + yasm_xfree(in_filename); + if (obj_filename) + yasm_xfree(obj_filename); + if (list_filename) + yasm_xfree(list_filename); + if (machine_name) + yasm_xfree(machine_name); + if (objfmt_keyword) + yasm_xfree(objfmt_keyword); } if (errfile != stderr && errfile != stdout) - fclose(errfile); -#if defined(CMAKE_BUILD) && defined(BUILD_SHARED_LIBS) - unload_plugins(); -#endif + fclose(errfile); } /* @@ -959,9 +757,9 @@ int not_an_option_handler(char *param) { if (in_filename) { - print_error( - _("warning: can open only one input file, only the last file will be processed")); - yasm_xfree(in_filename); + print_error( + _("warning: can open only one input file, only the last file will be processed")); + yasm_xfree(in_filename); } in_filename = yasm__xstrdup(param); @@ -974,14 +772,14 @@ other_option_handler(char *option) { /* Accept, but ignore, -O and -Onnn, for compatibility with NASM. */ if (option[0] == '-' && option[1] == 'O') { - int n = 2; - for (;;) { - if (option[n] == '\0') - return 0; - if (!isdigit(option[n])) - return 1; - n++; - } + int n = 2; + for (;;) { + if (option[n] == '\0') + return 0; + if (!isdigit(option[n])) + return 1; + n++; + } } return 1; } @@ -990,7 +788,7 @@ static int opt_special_handler(/*@unused@*/ char *cmd, /*@unused@*/ char *param, int extra) { if (special_options == 0) - special_options = extra; + special_options = extra; return 0; } @@ -1000,15 +798,15 @@ opt_arch_handler(/*@unused@*/ char *cmd, char *param, /*@unused@*/ int extra) assert(param != NULL); cur_arch_module = yasm_load_arch(param); if (!cur_arch_module) { - if (!strcmp("help", param)) { - printf(_("Available yasm %s:\n"), _("architectures")); - yasm_list_arch(print_list_keyword_desc); - special_options = SPECIAL_LISTED; - return 0; - } - print_error(_("%s: unrecognized %s `%s'"), _("FATAL"), - _("architecture"), param); - exit(EXIT_FAILURE); + if (!strcmp("help", param)) { + printf(_("Available yasm %s:\n"), _("architectures")); + yasm_list_arch(print_list_keyword_desc); + special_options = SPECIAL_LISTED; + return 0; + } + print_error(_("%s: unrecognized %s `%s'"), _("FATAL"), + _("architecture"), param); + exit(EXIT_FAILURE); } return 0; } @@ -1019,15 +817,15 @@ opt_parser_handler(/*@unused@*/ char *cmd, char *param, /*@unused@*/ int extra) assert(param != NULL); cur_parser_module = yasm_load_parser(param); if (!cur_parser_module) { - if (!strcmp("help", param)) { - printf(_("Available yasm %s:\n"), _("parsers")); - yasm_list_parser(print_list_keyword_desc); - special_options = SPECIAL_LISTED; - return 0; - } - print_error(_("%s: unrecognized %s `%s'"), _("FATAL"), _("parser"), - param); - exit(EXIT_FAILURE); + if (!strcmp("help", param)) { + printf(_("Available yasm %s:\n"), _("parsers")); + yasm_list_parser(print_list_keyword_desc); + special_options = SPECIAL_LISTED; + return 0; + } + print_error(_("%s: unrecognized %s `%s'"), _("FATAL"), _("parser"), + param); + exit(EXIT_FAILURE); } return 0; } @@ -1038,15 +836,15 @@ opt_preproc_handler(/*@unused@*/ char *cmd, char *param, /*@unused@*/ int extra) assert(param != NULL); cur_preproc_module = yasm_load_preproc(param); if (!cur_preproc_module) { - if (!strcmp("help", param)) { - printf(_("Available yasm %s:\n"), _("preprocessors")); - yasm_list_preproc(print_list_keyword_desc); - special_options = SPECIAL_LISTED; - return 0; - } - print_error(_("%s: unrecognized %s `%s'"), _("FATAL"), - _("preprocessor"), param); - exit(EXIT_FAILURE); + if (!strcmp("help", param)) { + printf(_("Available yasm %s:\n"), _("preprocessors")); + yasm_list_preproc(print_list_keyword_desc); + special_options = SPECIAL_LISTED; + return 0; + } + print_error(_("%s: unrecognized %s `%s'"), _("FATAL"), + _("preprocessor"), param); + exit(EXIT_FAILURE); } return 0; } @@ -1058,21 +856,21 @@ opt_objfmt_handler(/*@unused@*/ char *cmd, char *param, /*@unused@*/ int extra) assert(param != NULL); cur_objfmt_module = yasm_load_objfmt(param); if (!cur_objfmt_module) { - if (!strcmp("help", param)) { - printf(_("Available yasm %s:\n"), _("object formats")); - yasm_list_objfmt(print_list_keyword_desc); - special_options = SPECIAL_LISTED; - return 0; - } - print_error(_("%s: unrecognized %s `%s'"), _("FATAL"), - _("object format"), param); - exit(EXIT_FAILURE); + if (!strcmp("help", param)) { + printf(_("Available yasm %s:\n"), _("object formats")); + yasm_list_objfmt(print_list_keyword_desc); + special_options = SPECIAL_LISTED; + return 0; + } + print_error(_("%s: unrecognized %s `%s'"), _("FATAL"), + _("object format"), param); + exit(EXIT_FAILURE); } if (objfmt_keyword) - yasm_xfree(objfmt_keyword); + yasm_xfree(objfmt_keyword); objfmt_keyword = yasm__xstrdup(param); for (i=0; i + + @@ -169,6 +171,16 @@ + + or : Print a + summary of options + + + Prints a summary of invocation options. All other options + are ignored, and no output file is generated. + + + or : @@ -277,16 +289,6 @@ - - or : Print a - summary of options - - - Prints a summary of invocation options. All other options - are ignored, and no output file is generated. - - - : Get the Yasm version diff --git a/genstring.c b/genstring.c index a66e2f56..df87d7b8 100644 --- a/genstring.c +++ b/genstring.c @@ -1,4 +1,4 @@ -/* +/* $Id$ * * Generate array-of-const-string from text file. * @@ -29,7 +29,7 @@ #include #include -#define MAXLINE 1024 +#define MAXLINE 1024 int main(int argc, char *argv[]) @@ -41,56 +41,56 @@ main(int argc, char *argv[]) size_t len; if (argc < 4) { - fprintf(stderr, "Usage: %s [ ...]\n", - argv[0]); - return EXIT_FAILURE; + fprintf(stderr, "Usage: %s [ ...]\n", + argv[0]); + return EXIT_FAILURE; } out = fopen(argv[2], "wt"); if (!out) { - fprintf(stderr, "Could not open `%s'.\n", argv[2]); - return EXIT_FAILURE; + fprintf(stderr, "Could not open `%s'.\n", argv[2]); + return EXIT_FAILURE; } str = malloc(MAXLINE); fprintf(out, "/* This file auto-generated from %s by genstring.c" - " - don't edit it */\n\n" - "static const char *%s[] = {\n", argv[3], argv[1]); + " - don't edit it */\n\n" + "static const char *%s[] = {\n", argv[3], argv[1]); for (i=3; i 0 && (strp[len-1] == ' ' || strp[len-1] == '\t' || - strp[len-1] == '\n')) { - strp[len-1] = '\0'; - len--; - } + /* strip off trailing whitespace */ + len = strlen(strp); + while (len > 0 && (strp[len-1] == ' ' || strp[len-1] == '\t' || + strp[len-1] == '\n')) { + strp[len-1] = '\0'; + len--; + } - /* output as string to output file */ - fprintf(out, " \""); - while (*strp != '\0') { - if (*strp == '\\' || *strp == '"') - fputc('\\', out); - fputc(*strp, out); - strp++; - } - fprintf(out, "\",\n"); - } + /* output as string to output file */ + fprintf(out, " \""); + while (*strp != '\0') { + if (*strp == '\\' || *strp == '"') + fputc('\\', out); + fputc(*strp, out); + strp++; + } + fprintf(out, "\",\n"); + } - fclose(in); + fclose(in); } fprintf(out, "};\n"); diff --git a/libyasm-stdint.h.cmake b/libyasm-stdint.h.cmake deleted file mode 100644 index 049037d5..00000000 --- a/libyasm-stdint.h.cmake +++ /dev/null @@ -1,46 +0,0 @@ -#ifndef YASM_STDINT_H -#define YASM_STDINT_H - -#cmakedefine HAVE_STDINT_H - -#ifdef HAVE_STDINT_H -#include -#elif defined(_MSC_VER) - -#ifndef _UINTPTR_T_DEFINED -#ifdef _WIN64 -#include -#else -typedef unsigned long uintptr_t; -#endif -#define _UINTPTR_T_DEFINED -#endif - -#else -typedef unsigned long uintptr_t; -#endif - -#ifndef BUILD_SHARED_LIBS -#cmakedefine BUILD_SHARED_LIBS -#define BUILD_SHARED_LIBS_UNDEF -#endif - -#ifndef YASM_LIB_DECL -# if defined(BUILD_SHARED_LIBS) && defined(_WIN32) -# ifdef YASM_LIB_SOURCE -# define YASM_LIB_DECL __declspec(dllexport) -# else -# define YASM_LIB_DECL __declspec(dllimport) -# endif -# else -# define YASM_LIB_DECL -# endif -#endif - -#undef HAVE_STDINT_H -#ifdef BUILD_SHARED_LIBS_UNDEF -#undef BUILD_SHARED_LIBS -#undef BUILD_SHARED_LIBS_UNDEF -#endif - -#endif diff --git a/libyasm.h b/libyasm.h index f52c133b..ec92aa53 100644 --- a/libyasm.h +++ b/libyasm.h @@ -2,6 +2,10 @@ * \file libyasm.h * \brief YASM library primary header file. * + * \rcs + * $Id$ + * \endrcs + * * \license * Copyright (C) 2003-2007 Peter Johnson * @@ -26,6 +30,16 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * \endlicense + * + * Define YASM_LIB_INTERNAL to include many internal function and variable + * definitions that violate the yasm_* namespace. This includes + * compat-queue.h, bitvect.h, and hamt.h. + * + * Additional parts may be included via: + * - YASM_BC_INTERNAL: reveal bytecode internal structures via bc-int.h + * inclusion + * - YASM_EXPR_INTERNAL: reveal expr internal structures via expr-int.h + * inclusion */ #ifndef YASM_LIB_H #define YASM_LIB_H @@ -41,7 +55,9 @@ typedef unsigned long uintptr_t; #include #endif -#include +#ifdef YASM_LIB_INTERNAL +# include +#endif #include #include @@ -57,7 +73,6 @@ typedef unsigned long uintptr_t; #include #include -#include #include #include @@ -69,7 +84,16 @@ typedef unsigned long uintptr_t; #include #include +#ifdef YASM_LIB_INTERNAL +#ifdef YASM_BC_INTERNAL +#include +#endif +#ifdef YASM_EXPR_INTERNAL +#include +#endif #include +#include #include +#endif #endif diff --git a/libyasm/CMakeLists.txt b/libyasm/CMakeLists.txt deleted file mode 100644 index 0299ac56..00000000 --- a/libyasm/CMakeLists.txt +++ /dev/null @@ -1,83 +0,0 @@ -SET(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}) - -ADD_LIBRARY(libyasm - assocdat.c - bitvect.c - bc-align.c - bc-data.c - bc-incbin.c - bc-org.c - bc-reserve.c - bytecode.c - cmake-module.c - errwarn.c - expr.c - file.c - floatnum.c - hamt.c - insn.c - intnum.c - inttree.c - linemap.c - md5.c - mergesort.c - phash.c - section.c - strcasecmp.c - strsep.c - symrec.c - valparam.c - value.c - xmalloc.c - xstrdup.c - ) -IF(BUILD_SHARED_LIBS) - SET_TARGET_PROPERTIES(libyasm PROPERTIES - OUTPUT_NAME "yasm" - COMPILE_FLAGS -DYASM_LIB_SOURCE - ) - if(WIN32) - SET_PROPERTY(TARGET libyasm PROPERTY PREFIX "") - endif() -ELSE(BUILD_SHARED_LIBS) - SET_TARGET_PROPERTIES(libyasm PROPERTIES - COMPILE_FLAGS -DYASM_LIB_SOURCE - ) -ENDIF(BUILD_SHARED_LIBS) - -INSTALL(TARGETS libyasm - RUNTIME DESTINATION bin - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib - ) - -INSTALL(FILES - arch.h - assocdat.h - bitvect.h - bytecode.h - compat-queue.h - coretype.h - dbgfmt.h - errwarn.h - expr.h - file.h - floatnum.h - hamt.h - insn.h - intnum.h - inttree.h - linemap.h - listfmt.h - md5.h - module.h - objfmt.h - parser.h - phash.h - preproc.h - section.h - symrec.h - valparam.h - value.h - DESTINATION include/libyasm - ) diff --git a/libyasm/Makefile.inc b/libyasm/Makefile.inc index 042dd390..2fc87633 100644 --- a/libyasm/Makefile.inc +++ b/libyasm/Makefile.inc @@ -1,8 +1,12 @@ +# $Id$ + +libyasm_a_SOURCES += libyasm/arch.c libyasm_a_SOURCES += libyasm/assocdat.c libyasm_a_SOURCES += libyasm/bitvect.c libyasm_a_SOURCES += libyasm/bc-align.c libyasm_a_SOURCES += libyasm/bc-data.c libyasm_a_SOURCES += libyasm/bc-incbin.c +libyasm_a_SOURCES += libyasm/bc-insn.c libyasm_a_SOURCES += libyasm/bc-org.c libyasm_a_SOURCES += libyasm/bc-reserve.c libyasm_a_SOURCES += libyasm/bytecode.c @@ -11,7 +15,6 @@ libyasm_a_SOURCES += libyasm/expr.c libyasm_a_SOURCES += libyasm/file.c libyasm_a_SOURCES += libyasm/floatnum.c libyasm_a_SOURCES += libyasm/hamt.c -libyasm_a_SOURCES += libyasm/insn.c libyasm_a_SOURCES += libyasm/intnum.c libyasm_a_SOURCES += libyasm/inttree.c libyasm_a_SOURCES += libyasm/linemap.c @@ -26,11 +29,12 @@ libyasm_a_SOURCES += libyasm/valparam.c libyasm_a_SOURCES += libyasm/value.c libyasm_a_SOURCES += libyasm/xmalloc.c libyasm_a_SOURCES += libyasm/xstrdup.c -nodist_libyasm_a_SOURCES += module.c +libyasm_a_SOURCES += module.c module.c: $(top_srcdir)/libyasm/module.in genmodule$(EXEEXT) Makefile $(top_builddir)/genmodule$(EXEEXT) $(top_srcdir)/libyasm/module.in Makefile +BUILT_SOURCES += module.c CLEANFILES += module.c noinst_PROGRAMS += genmodule @@ -49,6 +53,7 @@ modincludedir = $(includedir)/libyasm modinclude_HEADERS = libyasm/arch.h modinclude_HEADERS += libyasm/assocdat.h +modinclude_HEADERS += libyasm/bc-int.h modinclude_HEADERS += libyasm/bitvect.h modinclude_HEADERS += libyasm/bytecode.h modinclude_HEADERS += libyasm/compat-queue.h @@ -56,10 +61,10 @@ modinclude_HEADERS += libyasm/coretype.h modinclude_HEADERS += libyasm/dbgfmt.h modinclude_HEADERS += libyasm/errwarn.h modinclude_HEADERS += libyasm/expr.h +modinclude_HEADERS += libyasm/expr-int.h modinclude_HEADERS += libyasm/file.h modinclude_HEADERS += libyasm/floatnum.h modinclude_HEADERS += libyasm/hamt.h -modinclude_HEADERS += libyasm/insn.h modinclude_HEADERS += libyasm/intnum.h modinclude_HEADERS += libyasm/inttree.h modinclude_HEADERS += libyasm/linemap.h diff --git a/libyasm/arch.c b/libyasm/arch.c new file mode 100644 index 00000000..c0527f41 --- /dev/null +++ b/libyasm/arch.c @@ -0,0 +1,217 @@ +/* + * Architecture interface + * + * Copyright (C) 2001-2007 Peter Johnson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND OTHER CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR OTHER CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +#define YASM_LIB_INTERNAL +#define YASM_ARCH_INTERNAL +#include "util.h" +/*@unused@*/ RCSID("$Id$"); + +#include "libyasm-stdint.h" +#include "coretype.h" + +#include "expr.h" + +#include "bytecode.h" + +#include "arch.h" + + +yasm_insn_operand * +yasm_operand_create_reg(uintptr_t reg) +{ + yasm_insn_operand *retval = yasm_xmalloc(sizeof(yasm_insn_operand)); + + retval->type = YASM_INSN__OPERAND_REG; + retval->data.reg = reg; + retval->targetmod = 0; + retval->size = 0; + retval->deref = 0; + retval->strict = 0; + + return retval; +} + +yasm_insn_operand * +yasm_operand_create_segreg(uintptr_t segreg) +{ + yasm_insn_operand *retval = yasm_xmalloc(sizeof(yasm_insn_operand)); + + retval->type = YASM_INSN__OPERAND_SEGREG; + retval->data.reg = segreg; + retval->targetmod = 0; + retval->size = 0; + retval->deref = 0; + retval->strict = 0; + + return retval; +} + +yasm_insn_operand * +yasm_operand_create_mem(/*@only@*/ yasm_effaddr *ea) +{ + yasm_insn_operand *retval = yasm_xmalloc(sizeof(yasm_insn_operand)); + + retval->type = YASM_INSN__OPERAND_MEMORY; + retval->data.ea = ea; + retval->targetmod = 0; + retval->size = 0; + retval->deref = 0; + retval->strict = 0; + + return retval; +} + +yasm_insn_operand * +yasm_operand_create_imm(/*@only@*/ yasm_expr *val) +{ + yasm_insn_operand *retval; + const uintptr_t *reg; + + reg = yasm_expr_get_reg(&val, 0); + if (reg) { + retval = yasm_operand_create_reg(*reg); + yasm_expr_destroy(val); + } else { + retval = yasm_xmalloc(sizeof(yasm_insn_operand)); + retval->type = YASM_INSN__OPERAND_IMM; + retval->data.val = val; + retval->targetmod = 0; + retval->size = 0; + retval->deref = 0; + retval->strict = 0; + } + + return retval; +} + +void +yasm_operand_print(const yasm_insn_operand *op, FILE *f, int indent_level, + yasm_arch *arch) +{ + switch (op->type) { + case YASM_INSN__OPERAND_REG: + fprintf(f, "%*sReg=", indent_level, ""); + yasm_arch_reg_print(arch, op->data.reg, f); + fprintf(f, "\n"); + break; + case YASM_INSN__OPERAND_SEGREG: + fprintf(f, "%*sSegReg=", indent_level, ""); + yasm_arch_segreg_print(arch, op->data.reg, f); + fprintf(f, "\n"); + break; + case YASM_INSN__OPERAND_MEMORY: + fprintf(f, "%*sMemory=\n", indent_level, ""); + yasm_ea_print(op->data.ea, f, indent_level); + break; + case YASM_INSN__OPERAND_IMM: + fprintf(f, "%*sImm=", indent_level, ""); + yasm_expr_print(op->data.val, f); + fprintf(f, "\n"); + break; + } + fprintf(f, "%*sTargetMod=%lx\n", indent_level+1, "", + (unsigned long)op->targetmod); + fprintf(f, "%*sSize=%u\n", indent_level+1, "", op->size); + fprintf(f, "%*sDeref=%d, Strict=%d\n", indent_level+1, "", (int)op->deref, + (int)op->strict); +} + +void +yasm_ops_delete(yasm_insn_operands *headp, int content) +{ + yasm_insn_operand *cur, *next; + + cur = STAILQ_FIRST(headp); + while (cur) { + next = STAILQ_NEXT(cur, link); + if (content) + switch (cur->type) { + case YASM_INSN__OPERAND_MEMORY: + yasm_ea_destroy(cur->data.ea); + break; + case YASM_INSN__OPERAND_IMM: + yasm_expr_destroy(cur->data.val); + break; + default: + break; + } + yasm_xfree(cur); + cur = next; + } + STAILQ_INIT(headp); +} + +/*@null@*/ yasm_insn_operand * +yasm_ops_append(yasm_insn_operands *headp, + /*@returned@*/ /*@null@*/ yasm_insn_operand *op) +{ + if (op) { + STAILQ_INSERT_TAIL(headp, op, link); + return op; + } + return (yasm_insn_operand *)NULL; +} + +void +yasm_ops_print(const yasm_insn_operands *headp, FILE *f, int indent_level, + yasm_arch *arch) +{ + yasm_insn_operand *cur; + + STAILQ_FOREACH (cur, headp, link) + yasm_operand_print(cur, f, indent_level, arch); +} + +yasm_insn_operands * +yasm_ops_create(void) +{ + yasm_insn_operands *headp = yasm_xmalloc(sizeof(yasm_insn_operands)); + yasm_ops_initialize(headp); + return headp; +} + +void +yasm_ops_destroy(yasm_insn_operands *headp, int content) +{ + yasm_ops_delete(headp, content); + yasm_xfree(headp); +} + +/* Non-macro yasm_ops_first() for non-YASM_LIB_INTERNAL users. */ +#undef yasm_ops_first +yasm_insn_operand * +yasm_ops_first(yasm_insn_operands *headp) +{ + return STAILQ_FIRST(headp); +} + +/* Non-macro yasm_operand_next() for non-YASM_LIB_INTERNAL users. */ +#undef yasm_operand_next +yasm_insn_operand * +yasm_operand_next(yasm_insn_operand *cur) +{ + return STAILQ_NEXT(cur, link); +} diff --git a/libyasm/arch.h b/libyasm/arch.h index 3da9f9fc..9c4557cb 100644 --- a/libyasm/arch.h +++ b/libyasm/arch.h @@ -2,6 +2,10 @@ * \file libyasm/arch.h * \brief YASM architecture interface. * + * \rcs + * $Id$ + * \endrcs + * * \license * Copyright (C) 2002-2007 Peter Johnson * @@ -32,29 +36,35 @@ /** Errors that may be returned by yasm_arch_module::create(). */ typedef enum yasm_arch_create_error { - YASM_ARCH_CREATE_OK = 0, /**< No error. */ - YASM_ARCH_CREATE_BAD_MACHINE, /**< Unrecognized machine name. */ - YASM_ARCH_CREATE_BAD_PARSER /**< Unrecognized parser name. */ + YASM_ARCH_CREATE_OK = 0, /**< No error. */ + YASM_ARCH_CREATE_BAD_MACHINE, /**< Unrecognized machine name. */ + YASM_ARCH_CREATE_BAD_PARSER /**< Unrecognized parser name. */ } yasm_arch_create_error; /** Return values for yasm_arch_module::parse_check_insnprefix(). */ typedef enum yasm_arch_insnprefix { - YASM_ARCH_NOTINSNPREFIX = 0, /**< Unrecognized */ - YASM_ARCH_INSN, /**< An instruction */ - YASM_ARCH_PREFIX /**< An instruction prefix */ + YASM_ARCH_NOTINSNPREFIX = 0, /**< Unrecognized */ + YASM_ARCH_INSN, /**< An instruction */ + YASM_ARCH_PREFIX /**< An instruction prefix */ } yasm_arch_insnprefix; /** Types of registers / target modifiers that may be returned by * yasm_arch_module::parse_check_regtmod(). */ typedef enum yasm_arch_regtmod { - YASM_ARCH_NOTREGTMOD = 0, /**< Unrecognized */ - YASM_ARCH_REG, /**< A "normal" register */ - YASM_ARCH_REGGROUP, /**< A group of indexable registers */ - YASM_ARCH_SEGREG, /**< A segment register */ - YASM_ARCH_TARGETMOD /**< A target modifier (for jumps) */ + YASM_ARCH_NOTREGTMOD = 0, /**< Unrecognized */ + YASM_ARCH_REG, /**< A "normal" register */ + YASM_ARCH_REGGROUP, /**< A group of indexable registers */ + YASM_ARCH_SEGREG, /**< A segment register */ + YASM_ARCH_TARGETMOD /**< A target modifier (for jumps) */ } yasm_arch_regtmod; +/** An instruction operand (opaque type). */ +typedef struct yasm_insn_operand yasm_insn_operand; +#ifdef YASM_LIB_INTERNAL +/*@reldef@*/ STAILQ_HEAD(yasm_insn_operands, yasm_insn_operand); +#endif + #ifndef YASM_DOXYGEN /** Base #yasm_arch structure. Must be present as the first element in any * #yasm_arch implementation. @@ -81,9 +91,9 @@ typedef struct yasm_arch_machine { /** YASM architecture module interface. * \note All "data" in parser-related functions (yasm_arch_parse_*) needs to - * start the parse initialized to 0 to make it okay for a parser-related - * function to use/check previously stored data to see if it's been - * called before on the same piece of data. + * start the parse initialized to 0 to make it okay for a parser-related + * function to use/check previously stored data to see if it's been + * called before on the same piece of data. */ typedef struct yasm_arch_module { /** One-line description of the architecture. @@ -104,7 +114,7 @@ typedef struct yasm_arch_module { * Call yasm_arch_create() instead of calling this function. */ /*@only@*/ yasm_arch * (*create) (const char *machine, const char *parser, - /*@out@*/ yasm_arch_create_error *error); + yasm_arch_create_error *error); /** Module-level implementation of yasm_arch_destroy(). * Call yasm_arch_destroy() instead of calling this function. @@ -130,35 +140,44 @@ typedef struct yasm_arch_module { * Call yasm_arch_parse_check_insnprefix() instead of calling this function. */ yasm_arch_insnprefix (*parse_check_insnprefix) - (yasm_arch *arch, const char *id, size_t id_len, unsigned long line, - /*@out@*/ /*@only@*/ yasm_bytecode **bc, /*@out@*/ uintptr_t *prefix); + (yasm_arch *arch, /*@out@*/ uintptr_t data[4], const char *id, + size_t id_len); /** Module-level implementation of yasm_arch_parse_check_regtmod(). * Call yasm_arch_parse_check_regtmod() instead of calling this function. */ yasm_arch_regtmod (*parse_check_regtmod) - (yasm_arch *arch, const char *id, size_t id_len, - /*@out@*/ uintptr_t *data); + (yasm_arch *arch, /*@out@*/ uintptr_t *data, const char *id, + size_t id_len); /** Module-level implementation of yasm_arch_get_fill(). * Call yasm_arch_get_fill() instead of calling this function. */ const unsigned char ** (*get_fill) (const yasm_arch *arch); + /** Module-level implementation of yasm_arch_finalize_insn(). + * Call yasm_arch_finalize_insn() instead of calling this function. + */ + void (*finalize_insn) + (yasm_arch *arch, yasm_bytecode *bc, yasm_bytecode *prev_bc, + const uintptr_t data[4], int num_operands, + /*@null@*/ yasm_insn_operands *operands, int num_prefixes, + uintptr_t **prefixes, int num_segregs, const uintptr_t *segregs); + /** Module-level implementation of yasm_arch_floatnum_tobytes(). * Call yasm_arch_floatnum_tobytes() instead of calling this function. */ int (*floatnum_tobytes) (yasm_arch *arch, const yasm_floatnum *flt, - unsigned char *buf, size_t destsize, - size_t valsize, size_t shift, int warn); + unsigned char *buf, size_t destsize, + size_t valsize, size_t shift, int warn); /** Module-level implementation of yasm_arch_intnum_tobytes(). * Call yasm_arch_intnum_tobytes() instead of calling this function. */ int (*intnum_tobytes) (yasm_arch *arch, const yasm_intnum *intn, - unsigned char *buf, size_t destsize, size_t valsize, - int shift, const yasm_bytecode *bc, - int warn); + unsigned char *buf, size_t destsize, size_t valsize, + int shift, const yasm_bytecode *bc, + int warn); /** Module-level implementation of yasm_arch_get_reg_size(). * Call yasm_arch_get_reg_size() instead of calling this function. @@ -169,7 +188,7 @@ typedef struct yasm_arch_module { * Call yasm_arch_reggroup_get_reg() instead of calling this function. */ uintptr_t (*reggroup_get_reg) (yasm_arch *arch, uintptr_t reggroup, - unsigned long regindex); + unsigned long regindex); /** Module-level implementation of yasm_arch_reg_print(). * Call yasm_arch_reg_print() instead of calling this function. @@ -186,22 +205,6 @@ typedef struct yasm_arch_module { */ yasm_effaddr * (*ea_create) (yasm_arch *arch, /*@keep@*/ yasm_expr *e); - /** Module-level implementation of yasm_arch_ea_destroy(). - * Call yasm_arch_ea_destroy() instead of calling this function. - */ - void (*ea_destroy) (/*@only@*/ yasm_effaddr *ea); - - /** Module-level implementation of yasm_arch_ea_print(). - * Call yasm_arch_ea_print() instead of calling this function. - */ - void (*ea_print) (const yasm_effaddr *ea, FILE *f, int indent_level); - - /** Module-level implementation of yasm_arch_create_empty_insn(). - * Call yasm_arch_create_empty_insn() instead of calling this function. - */ - /*@only@*/ yasm_bytecode * (*create_empty_insn) (yasm_arch *arch, - unsigned long line); - /** NULL-terminated list of machines for this architecture. * Call yasm_arch_get_machine() to get the active machine of a particular * #yasm_arch. @@ -227,64 +230,114 @@ typedef struct yasm_arch_module { unsigned int min_insn_len; } yasm_arch_module; +#ifdef YASM_LIB_INTERNAL +/** An instruction operand. \internal */ +struct yasm_insn_operand { + /** Link for building linked list of operands. \internal */ + /*@reldef@*/ STAILQ_ENTRY(yasm_insn_operand) link; + + /** Operand type. */ + enum yasm_insn_operand_type { + YASM_INSN__OPERAND_REG = 1, /**< A register. */ + YASM_INSN__OPERAND_SEGREG, /**< A segment register. */ + YASM_INSN__OPERAND_MEMORY, /**< An effective address + * (memory reference). */ + YASM_INSN__OPERAND_IMM /**< An immediate or jump target. */ + } type; + + /** Operand data. */ + union { + uintptr_t reg; /**< Arch data for reg/segreg. */ + yasm_effaddr *ea; /**< Effective address for memory references. */ + yasm_expr *val; /**< Value of immediate or jump target. */ + } data; + + uintptr_t targetmod; /**< Arch target modifier, 0 if none. */ + + /** Specified size of the operand, in bits. 0 if not user-specified. */ + unsigned int size:8; + + /** Nonzero if dereference. Used for "*foo" in GAS. + * The reason for this is that by default in GAS, an unprefixed value + * is a memory address, except for jumps/calls, in which case it needs a + * "*" prefix to become a memory address (otherwise it's an immediate). + * This isn't knowable in the parser stage, so the parser sets this flag + * to indicate the "*" prefix has been used, and the arch needs to adjust + * the operand type appropriately depending on the instruction type. + */ + unsigned int deref:1; + + /** Nonzero if strict. Used for "strict foo" in NASM. + * This is used to inhibit optimization on otherwise "sized" values. + * For example, the user may just want to be explicit with the size on + * "push dword 4", but not actually want to force the immediate size to + * 4 bytes (rather wanting the optimizer to optimize it down to 1 byte as + * though "dword" was not specified). To indicate the immediate should + * actually be forced to 4 bytes, the user needs to write + * "push strict dword 4", which sets this flag. + */ + unsigned int strict:1; +}; +#endif + /** Get the one-line description of an architecture. - * \param arch architecture + * \param arch architecture * \return One-line description of architecture. */ const char *yasm_arch_name(const yasm_arch *arch); /** Get the keyword used to select an architecture. - * \param arch architecture + * \param arch architecture * \return Architecture keyword. */ const char *yasm_arch_keyword(const yasm_arch *arch); /** Get the word size of an architecture. - * \param arch architecture + * \param arch architecture * \return Word size (in bits). */ unsigned int yasm_arch_wordsize(const yasm_arch *arch); /** Get the minimum instruction length of an architecture. - * \param arch architecture + * \param arch architecture * \return Minimum instruction length (in bytes). */ unsigned int yasm_arch_min_insn_len(const yasm_arch *arch); /** Create architecture. - * \param module architecture module - * \param machine keyword of machine in use (must be one listed in - * #yasm_arch_module.machines) - * \param parser keyword of parser in use - * \param error error return value + * \param module architecture module + * \param machine keyword of machine in use (must be one listed in + * #yasm_arch_module.machines) + * \param parser keyword of parser in use + * \param error error return value * \return NULL on error (error returned in error parameter), otherwise new - * architecture. + * architecture. */ /*@only@*/ yasm_arch *yasm_arch_create(const yasm_arch_module *module, - const char *machine, const char *parser, - /*@out@*/ yasm_arch_create_error *error); + const char *machine, const char *parser, + /*@out@*/ yasm_arch_create_error *error); /** Clean up, free any architecture-allocated memory. - * \param arch architecture + * \param arch architecture */ void yasm_arch_destroy(/*@only@*/ yasm_arch *arch); /** Get architecture's active machine name. - * \param arch architecture + * \param arch architecture * \return Active machine name. */ const char *yasm_arch_get_machine(const yasm_arch *arch); /** Get architecture's active address size, in bits. - * \param arch architecture + * \param arch architecture * \return Active address size (in bits). */ unsigned int yasm_arch_get_address_size(const yasm_arch *arch); /** Set any arch-specific variables. For example, "mode_bits" in x86. - * \param arch architecture - * \param var variable name - * \param val value to set + * \param arch architecture + * \param var variable name + * \param val value to set * \return Zero on success, non-zero on failure (variable does not exist). */ int yasm_arch_set_var(yasm_arch *arch, const char *var, unsigned long val); @@ -294,144 +347,140 @@ int yasm_arch_set_var(yasm_arch *arch, const char *var, unsigned long val); * should return #YASM_ARCH_NOTINSNPREFIX so they can be treated as normal * symbols. Any additional data beyond just the type (almost always necessary) * should be returned into the space provided by the data parameter. - * \param arch architecture - * \param id identifier as in the input file - * \param id_len length of id string - * \param line virtual line - * \param bc for instructions, yasm_insn-based bytecode is returned - * (and NULL otherwise) - * \param prefix for prefixes, yasm_arch-specific value is returned - * (and 0 otherwise) + * \param arch architecture + * \param data extra identification information (yasm_arch-specific) + * [output] + * \param id identifier as in the input file + * \param id_len length of id string * \return Identifier type (#YASM_ARCH_NOTINSNPREFIX if unrecognized) */ yasm_arch_insnprefix yasm_arch_parse_check_insnprefix - (yasm_arch *arch, const char *id, size_t id_len, unsigned long line, - /*@out@*/ /*@only@*/ yasm_bytecode **bc, /*@out@*/ uintptr_t *prefix); + (yasm_arch *arch, /*@out@*/ uintptr_t data[4], const char *id, + size_t id_len); /** Check an generic identifier to see if it matches architecture specific * names for registers or target modifiers. Unrecognized identifiers should * return #YASM_ARCH_NOTREGTMOD. Any additional data beyond just the type * (almost always necessary) should be returned into the space provided by the * data parameter. - * \param arch architecture - * \param id identifier as in the input file - * \param id_len length of id string - * \param data extra identification information (yasm_arch-specific) - * [output] + * \param arch architecture + * \param data extra identification information (yasm_arch-specific) + * [output] + * \param id identifier as in the input file + * \param id_len length of id string * \return Identifier type (#YASM_ARCH_NOTREGTMOD if unrecognized) */ yasm_arch_regtmod yasm_arch_parse_check_regtmod - (yasm_arch *arch, const char *id, size_t id_len, - /*@out@*/ uintptr_t *data); + (yasm_arch *arch, /*@out@*/ uintptr_t *data, const char *id, + size_t id_len); /** Get NOP fill patterns for 1-15 bytes of fill. - * \param arch architecture + * \param arch architecture * \return 16-entry array of arrays; [0] is unused, [1] - [15] point to arrays * of 1-15 bytes (respectively) in length. */ const unsigned char **yasm_arch_get_fill(const yasm_arch *arch); +/** Finalize an instruction from a semi-generic insn description. Note an + * existing bytecode is required. + * \param arch architecture + * \param bc bytecode to finalize + * \param prev_bc previous bytecode in section + * \param data instruction data (from parse_check_id()); all + * zero indicates an empty instruction + * \param num_operands number of operands + * \param operands list of operands (in parse order) + * \param num_prefixes number of prefixes + * \param prefixes array of 4-element prefix data + * \param num_segregs number of segment register prefixes + * \param segregs array of segment register data + * \return If no match is found (the instruction is invalid), no action is + * performed and an error is recorded. + */ +void yasm_arch_finalize_insn + (yasm_arch *arch, yasm_bytecode *bc, yasm_bytecode *prev_bc, + const uintptr_t data[4], int num_operands, + /*@null@*/ yasm_insn_operands *operands, int num_prefixes, + const uintptr_t **prefixes, int num_segregs, const uintptr_t *segregs); + /** Output #yasm_floatnum to buffer. Puts the value into the least * significant bits of the destination, or may be shifted into more * significant bits by the shift parameter. The destination bits are * cleared before being set. * Architecture-specific because of endianness. - * \param arch architecture - * \param flt floating point value - * \param buf buffer to write into - * \param destsize destination size (in bytes) - * \param valsize size (in bits) - * \param shift left shift (in bits) - * \param warn enables standard overflow/underflow warnings + * \param arch architecture + * \param flt floating point value + * \param buf buffer to write into + * \param destsize destination size (in bytes) + * \param valsize size (in bits) + * \param shift left shift (in bits) + * \param warn enables standard overflow/underflow warnings * \return Nonzero on error. */ int yasm_arch_floatnum_tobytes(yasm_arch *arch, const yasm_floatnum *flt, - unsigned char *buf, size_t destsize, - size_t valsize, size_t shift, int warn); + unsigned char *buf, size_t destsize, + size_t valsize, size_t shift, int warn); /** Output #yasm_intnum to buffer. Puts the value into the least * significant bits of the destination, or may be shifted into more * significant bits by the shift parameter. The destination bits are * cleared before being set. - * \param arch architecture - * \param intn integer value - * \param buf buffer to write into - * \param destsize destination size (in bytes) - * \param valsize size (in bits) - * \param shift left shift (in bits); may be negative to specify right - * shift (standard warnings include truncation to boundary) - * \param bc bytecode being output ("parent" of value) - * \param warn enables standard warnings (value doesn't fit into - * valsize bits) + * \param arch architecture + * \param intn integer value + * \param buf buffer to write into + * \param destsize destination size (in bytes) + * \param valsize size (in bits) + * \param shift left shift (in bits); may be negative to specify right + * shift (standard warnings include truncation to boundary) + * \param bc bytecode being output ("parent" of value) + * \param warn enables standard warnings (value doesn't fit into + * valsize bits) * \return Nonzero on error. */ int yasm_arch_intnum_tobytes(yasm_arch *arch, const yasm_intnum *intn, - unsigned char *buf, size_t destsize, - size_t valsize, int shift, - const yasm_bytecode *bc, int warn); + unsigned char *buf, size_t destsize, + size_t valsize, int shift, + const yasm_bytecode *bc, int warn); /** Get the equivalent size of a register in bits. - * \param arch architecture - * \param reg register + * \param arch architecture + * \param reg register * \return 0 if there is no suitable equivalent size, otherwise the size. */ unsigned int yasm_arch_get_reg_size(yasm_arch *arch, uintptr_t reg); /** Get a specific register of a register group, based on the register * group and the index within the group. - * \param arch architecture - * \param reggroup register group - * \param regindex register index + * \param arch architecture + * \param reggroup register group + * \param regindex register index * \return 0 if regindex is not valid for that register group, otherwise the * specific register value. */ uintptr_t yasm_arch_reggroup_get_reg(yasm_arch *arch, uintptr_t reggroup, - unsigned long regindex); + unsigned long regindex); /** Print a register. For debugging purposes. - * \param arch architecture - * \param reg register - * \param f file + * \param arch architecture + * \param reg register + * \param f file */ void yasm_arch_reg_print(yasm_arch *arch, uintptr_t reg, FILE *f); /** Print a segment register. For debugging purposes. - * \param arch architecture - * \param segreg segment register - * \param f file + * \param arch architecture + * \param segreg segment register + * \param f file */ void yasm_arch_segreg_print(yasm_arch *arch, uintptr_t segreg, FILE *f); /** Create an effective address from an expression. - * \param arch architecture - * \param e expression (kept, do not delete) + * \param arch architecture + * \param e expression (kept, do not delete) * \return Newly allocated effective address. */ yasm_effaddr *yasm_arch_ea_create(yasm_arch *arch, /*@keep@*/ yasm_expr *e); -/** Delete (free allocated memory for) an effective address. - * \param arch architecture - * \param ea effective address (only pointer to it). - */ -void yasm_arch_ea_destroy(yasm_arch *arch, /*@only@*/ yasm_effaddr *ea); - -/** Print an effective address. For debugging purposes. - * \param arch architecture - * \param ea effective address - * \param f file - * \param indent_level indentation level - */ -void yasm_arch_ea_print(const yasm_arch *arch, const yasm_effaddr *ea, - FILE *f, int indent_level); - -/** Create a bytecode that represents a single empty (0 length) instruction. - * This is used for handling solitary prefixes. - * \param arch architecture - * \param line virtual line (from yasm_linemap) - * \return Newly allocated bytecode. - */ -/*@only@*/ yasm_bytecode *yasm_arch_create_empty_insn(yasm_arch *arch, - unsigned long line); #ifndef YASM_DOXYGEN @@ -457,22 +506,28 @@ void yasm_arch_ea_print(const yasm_arch *arch, const yasm_effaddr *ea, ((yasm_arch_base *)arch)->module->get_address_size(arch) #define yasm_arch_set_var(arch, var, val) \ ((yasm_arch_base *)arch)->module->set_var(arch, var, val) -#define yasm_arch_parse_check_insnprefix(arch, id, id_len, line, bc, prefix) \ - ((yasm_arch_base *)arch)->module->parse_check_insnprefix \ - (arch, id, id_len, line, bc, prefix) -#define yasm_arch_parse_check_regtmod(arch, id, id_len, data) \ - ((yasm_arch_base *)arch)->module->parse_check_regtmod \ - (arch, id, id_len, data) +#define yasm_arch_parse_check_insnprefix(arch, data, id, id_len) \ + ((yasm_arch_base *)arch)->module->parse_check_insnprefix(arch, data, id, \ + id_len) +#define yasm_arch_parse_check_regtmod(arch, data, id, id_len) \ + ((yasm_arch_base *)arch)->module->parse_check_regtmod(arch, data, id, \ + id_len) #define yasm_arch_get_fill(arch) \ ((yasm_arch_base *)arch)->module->get_fill(arch) +#define yasm_arch_finalize_insn(arch, bc, prev_bc, data, num_operands, \ + operands, num_prefixes, prefixes, \ + num_segregs, segregs) \ + ((yasm_arch_base *)arch)->module->finalize_insn \ + (arch, bc, prev_bc, data, num_operands, operands, num_prefixes, \ + prefixes, num_segregs, segregs) #define yasm_arch_floatnum_tobytes(arch, flt, buf, destsize, valsize, shift, \ - warn) \ + warn) \ ((yasm_arch_base *)arch)->module->floatnum_tobytes \ - (arch, flt, buf, destsize, valsize, shift, warn) + (arch, flt, buf, destsize, valsize, shift, warn) #define yasm_arch_intnum_tobytes(arch, intn, buf, destsize, valsize, shift, \ - bc, warn) \ + bc, warn) \ ((yasm_arch_base *)arch)->module->intnum_tobytes \ - (arch, intn, buf, destsize, valsize, shift, bc, warn) + (arch, intn, buf, destsize, valsize, shift, bc, warn) #define yasm_arch_get_reg_size(arch, reg) \ ((yasm_arch_base *)arch)->module->get_reg_size(arch, reg) #define yasm_arch_reggroup_get_reg(arch, regg, regi) \ @@ -483,13 +538,100 @@ void yasm_arch_ea_print(const yasm_arch *arch, const yasm_effaddr *ea, ((yasm_arch_base *)arch)->module->segreg_print(arch, segreg, f) #define yasm_arch_ea_create(arch, e) \ ((yasm_arch_base *)arch)->module->ea_create(arch, e) -#define yasm_arch_ea_destroy(arch, ea) \ - ((yasm_arch_base *)arch)->module->ea_destroy(ea) -#define yasm_arch_ea_print(arch, ea, f, i) \ - ((yasm_arch_base *)arch)->module->ea_print(ea, f, i) -#define yasm_arch_create_empty_insn(arch, line) \ - ((yasm_arch_base *)arch)->module->create_empty_insn(arch, line) #endif +/** Create an instruction operand from a register. + * \param reg register + * \return Newly allocated operand. + */ +yasm_insn_operand *yasm_operand_create_reg(uintptr_t reg); + +/** Create an instruction operand from a segment register. + * \param segreg segment register + * \return Newly allocated operand. + */ +yasm_insn_operand *yasm_operand_create_segreg(uintptr_t segreg); + +/** Create an instruction operand from an effective address. + * \param ea effective address + * \return Newly allocated operand. + */ +yasm_insn_operand *yasm_operand_create_mem(/*@only@*/ yasm_effaddr *ea); + +/** Create an instruction operand from an immediate expression. + * Looks for cases of a single register and creates a register variant of + * #yasm_insn_operand. + * \param val immediate expression + * \return Newly allocated operand. + */ +yasm_insn_operand *yasm_operand_create_imm(/*@only@*/ yasm_expr *val); + +/** Print an instruction operand. For debugging purposes. + * \param arch architecture + * \param f file + * \param indent_level indentation level + * \param op instruction operand + */ +void yasm_operand_print(const yasm_insn_operand *op, FILE *f, int indent_level, + yasm_arch *arch); + +/** Create a new list of instruction operands. + * \return Newly allocated list. + */ +yasm_insn_operands *yasm_ops_create(void); + +/** Destroy a list of instruction operands (created with yasm_ops_create()). + * \param headp list of instruction operands + * \param content if nonzero, deletes content of each operand + */ +void yasm_ops_destroy(yasm_insn_operands *headp, int content); + +/** Get the first operand in a list of instruction operands. + * \param headp list of instruction operands + * \return First operand in list (NULL if list is empty). + */ +yasm_insn_operand *yasm_ops_first(yasm_insn_operands *headp); + +/** Get the next operand in a list of instruction operands. + * \param cur previous operand + * \return Next operand in list (NULL if cur was the last operand). + */ +yasm_insn_operand *yasm_operand_next(yasm_insn_operand *cur); + +#ifdef YASM_LIB_INTERNAL +#define yasm_ops_initialize(headp) STAILQ_INIT(headp) +#define yasm_ops_first(headp) STAILQ_FIRST(headp) +#define yasm_operand_next(cur) STAILQ_NEXT(cur, link) + +/** Delete (free allocated memory for) a list of instruction operands (created + * with yasm_ops_initialize()). + * \param headp list of instruction operands + * \param content if nonzero, deletes content of each operand + */ +void yasm_ops_delete(yasm_insn_operands *headp, int content); +#endif + +/** Add data value to the end of a list of instruction operands. + * \note Does not make a copy of the operand; so don't pass this function + * static or local variables, and discard the op pointer after calling + * this function. + * \param headp list of instruction operands + * \param op operand (may be NULL) + * \return If operand was actually appended (it wasn't NULL), the operand; + * otherwise NULL. + */ +/*@null@*/ yasm_insn_operand *yasm_ops_append + (yasm_insn_operands *headp, + /*@returned@*/ /*@null@*/ yasm_insn_operand *op); + +/** Print a list of instruction operands. For debugging purposes. + * \param arch architecture + * \param f file + * \param indent_level indentation level + * \param headp list of instruction operands + */ +void yasm_ops_print(const yasm_insn_operands *headp, FILE *f, int indent_level, + yasm_arch *arch); + #endif diff --git a/libyasm/assocdat.c b/libyasm/assocdat.c index 56009368..4e58269f 100644 --- a/libyasm/assocdat.c +++ b/libyasm/assocdat.c @@ -24,7 +24,9 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ +#define YASM_LIB_INTERNAL #include "util.h" +/*@unused@*/ RCSID("$Id$"); #include "coretype.h" #include "assocdat.h" @@ -50,30 +52,30 @@ yasm__assoc_data_create(void) assoc_data->size = 0; assoc_data->alloc = 2; assoc_data->vector = yasm_xmalloc(assoc_data->alloc * - sizeof(assoc_data_item)); + sizeof(assoc_data_item)); return assoc_data; } void * yasm__assoc_data_get(yasm__assoc_data *assoc_data, - const yasm_assoc_data_callback *callback) + const yasm_assoc_data_callback *callback) { size_t i; if (!assoc_data) - return NULL; + return NULL; for (i=0; isize; i++) { - if (assoc_data->vector[i].callback == callback) - return assoc_data->vector[i].data; + if (assoc_data->vector[i].callback == callback) + return assoc_data->vector[i].data; } return NULL; } yasm__assoc_data * yasm__assoc_data_add(yasm__assoc_data *assoc_data_arg, - const yasm_assoc_data_callback *callback, void *data) + const yasm_assoc_data_callback *callback, void *data) { yasm__assoc_data *assoc_data; assoc_data_item *item = NULL; @@ -81,35 +83,33 @@ yasm__assoc_data_add(yasm__assoc_data *assoc_data_arg, /* Create a new assoc_data if necessary */ if (assoc_data_arg) - assoc_data = assoc_data_arg; + assoc_data = assoc_data_arg; else - assoc_data = yasm__assoc_data_create(); + assoc_data = yasm__assoc_data_create(); /* See if there's already assocated data for this callback */ for (i=0; isize; i++) { - if (assoc_data->vector[i].callback == callback) { - item = &assoc_data->vector[i]; - break; - } + if (assoc_data->vector[i].callback == callback) + item = &assoc_data->vector[i]; } /* No? Then append a new one */ if (!item) { - assoc_data->size++; - if (assoc_data->size > assoc_data->alloc) { - assoc_data->alloc *= 2; - assoc_data->vector = - yasm_xrealloc(assoc_data->vector, - assoc_data->alloc * sizeof(assoc_data_item)); - } - item = &assoc_data->vector[assoc_data->size-1]; - item->callback = callback; - item->data = NULL; + assoc_data->size++; + if (assoc_data->size > assoc_data->alloc) { + assoc_data->alloc *= 2; + assoc_data->vector = + yasm_xrealloc(assoc_data->vector, + assoc_data->alloc * sizeof(assoc_data_item)); + } + item = &assoc_data->vector[assoc_data->size-1]; + item->callback = callback; + item->data = NULL; } /* Delete existing data (if any) */ if (item->data && item->data != data) - item->callback->destroy(item->data); + item->callback->destroy(item->data); item->data = data; @@ -122,17 +122,17 @@ yasm__assoc_data_destroy(yasm__assoc_data *assoc_data) size_t i; if (!assoc_data) - return; + return; for (i=0; isize; i++) - assoc_data->vector[i].callback->destroy(assoc_data->vector[i].data); + assoc_data->vector[i].callback->destroy(assoc_data->vector[i].data); yasm_xfree(assoc_data->vector); yasm_xfree(assoc_data); } void yasm__assoc_data_print(const yasm__assoc_data *assoc_data, FILE *f, - int indent_level) + int indent_level) { /*TODO*/ } diff --git a/libyasm/assocdat.h b/libyasm/assocdat.h index cf423867..49f6b4e6 100644 --- a/libyasm/assocdat.h +++ b/libyasm/assocdat.h @@ -2,6 +2,10 @@ * \file assocdat.h * \brief YASM associated data storage (libyasm internal use) * + * \rcs + * $Id$ + * \endrcs + * * \license * Copyright (C) 2003-2007 Peter Johnson * @@ -30,47 +34,38 @@ #ifndef YASM_ASSOCDAT_H #define YASM_ASSOCDAT_H -#ifndef YASM_LIB_DECL -#define YASM_LIB_DECL -#endif - /** Associated data container. */ typedef struct yasm__assoc_data yasm__assoc_data; /** Create an associated data container. */ -YASM_LIB_DECL /*@only@*/ yasm__assoc_data *yasm__assoc_data_create(void); /** Get associated data for a data callback. - * \param assoc_data container of associated data - * \param callback callback used when adding data + * \param assoc_data container of associated data + * \param callback callback used when adding data * \return Associated data (NULL if none). */ -YASM_LIB_DECL /*@dependent@*/ /*@null@*/ void *yasm__assoc_data_get (/*@null@*/ yasm__assoc_data *assoc_data, const yasm_assoc_data_callback *callback); /** Add associated data to a associated data container. * \attention Deletes any existing associated data for that data callback. - * \param assoc_data container of associated data - * \param callback callback - * \param data data to associate + * \param assoc_data container of associated data + * \param callback callback + * \param data data to associate */ -YASM_LIB_DECL /*@only@*/ yasm__assoc_data *yasm__assoc_data_add (/*@null@*/ /*@only@*/ yasm__assoc_data *assoc_data, const yasm_assoc_data_callback *callback, /*@only@*/ /*@null@*/ void *data); /** Destroy all associated data in a container. */ -YASM_LIB_DECL void yasm__assoc_data_destroy (/*@null@*/ /*@only@*/ yasm__assoc_data *assoc_data); /** Print all associated data in a container. */ -YASM_LIB_DECL void yasm__assoc_data_print(const yasm__assoc_data *assoc_data, FILE *f, - int indent_level); + int indent_level); #endif diff --git a/libyasm/bc-align.c b/libyasm/bc-align.c index 2a47882e..3c077aaa 100644 --- a/libyasm/bc-align.c +++ b/libyasm/bc-align.c @@ -24,7 +24,9 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ +#define YASM_LIB_INTERNAL #include "util.h" +/*@unused@*/ RCSID("$Id$"); #include "libyasm-stdint.h" #include "coretype.h" @@ -35,9 +37,11 @@ #include "bytecode.h" +#include "bc-int.h" + typedef struct bytecode_align { - /*@only@*/ yasm_expr *boundary; /* alignment boundary */ + /*@only@*/ yasm_expr *boundary; /* alignment boundary */ /* What to fill intervening locations with, NULL if using code_fill */ /*@only@*/ /*@null@*/ yasm_expr *fill; @@ -53,20 +57,18 @@ static void bc_align_destroy(void *contents); static void bc_align_print(const void *contents, FILE *f, int indent_level); static void bc_align_finalize(yasm_bytecode *bc, yasm_bytecode *prev_bc); static int bc_align_calc_len(yasm_bytecode *bc, yasm_bc_add_span_func add_span, - void *add_span_data); + void *add_span_data); static int bc_align_expand(yasm_bytecode *bc, int span, long old_val, - long new_val, /*@out@*/ long *neg_thres, - /*@out@*/ long *pos_thres); -static int bc_align_tobytes(yasm_bytecode *bc, unsigned char **bufp, - unsigned char *bufstart, void *d, - yasm_output_value_func output_value, - /*@null@*/ yasm_output_reloc_func output_reloc); + long new_val, /*@out@*/ long *neg_thres, + /*@out@*/ long *pos_thres); +static int bc_align_tobytes(yasm_bytecode *bc, unsigned char **bufp, void *d, + yasm_output_value_func output_value, + /*@null@*/ yasm_output_reloc_func output_reloc); static const yasm_bytecode_callback bc_align_callback = { bc_align_destroy, bc_align_print, bc_align_finalize, - NULL, bc_align_calc_len, bc_align_expand, bc_align_tobytes, @@ -79,11 +81,11 @@ bc_align_destroy(void *contents) { bytecode_align *align = (bytecode_align *)contents; if (align->boundary) - yasm_expr_destroy(align->boundary); + yasm_expr_destroy(align->boundary); if (align->fill) - yasm_expr_destroy(align->fill); + yasm_expr_destroy(align->fill); if (align->maxskip) - yasm_expr_destroy(align->maxskip); + yasm_expr_destroy(align->maxskip); yasm_xfree(contents); } @@ -106,133 +108,132 @@ bc_align_finalize(yasm_bytecode *bc, yasm_bytecode *prev_bc) { bytecode_align *align = (bytecode_align *)bc->contents; if (!yasm_expr_get_intnum(&align->boundary, 0)) - yasm_error_set(YASM_ERROR_NOT_CONSTANT, - N_("align boundary must be a constant")); + yasm_error_set(YASM_ERROR_NOT_CONSTANT, + N_("align boundary must be a constant")); if (align->fill && !yasm_expr_get_intnum(&align->fill, 0)) - yasm_error_set(YASM_ERROR_NOT_CONSTANT, - N_("align fill must be a constant")); + yasm_error_set(YASM_ERROR_NOT_CONSTANT, + N_("align fill must be a constant")); if (align->maxskip && !yasm_expr_get_intnum(&align->maxskip, 0)) - yasm_error_set(YASM_ERROR_NOT_CONSTANT, - N_("align maximum skip must be a constant")); + yasm_error_set(YASM_ERROR_NOT_CONSTANT, + N_("align maximum skip must be a constant")); } static int bc_align_calc_len(yasm_bytecode *bc, yasm_bc_add_span_func add_span, - void *add_span_data) + void *add_span_data) { long neg_thres = 0; long pos_thres = 0; if (bc_align_expand(bc, 0, 0, (long)bc->offset, &neg_thres, - &pos_thres) < 0) - return -1; + &pos_thres) < 0) + return -1; return 0; } static int bc_align_expand(yasm_bytecode *bc, int span, long old_val, long new_val, - /*@out@*/ long *neg_thres, /*@out@*/ long *pos_thres) + /*@out@*/ long *neg_thres, /*@out@*/ long *pos_thres) { bytecode_align *align = (bytecode_align *)bc->contents; unsigned long end; unsigned long boundary = - yasm_intnum_get_uint(yasm_expr_get_intnum(&align->boundary, 0)); + yasm_intnum_get_uint(yasm_expr_get_intnum(&align->boundary, 0)); if (boundary == 0) { - bc->len = 0; - *pos_thres = new_val; - return 0; + bc->len = 0; + *pos_thres = new_val; + return 0; } end = (unsigned long)new_val; if ((unsigned long)new_val & (boundary-1)) - end = ((unsigned long)new_val & ~(boundary-1)) + boundary; + end = ((unsigned long)new_val & ~(boundary-1)) + boundary; *pos_thres = (long)end; bc->len = end - (unsigned long)new_val; if (align->maxskip) { - unsigned long maxskip = - yasm_intnum_get_uint(yasm_expr_get_intnum(&align->maxskip, 0)); - if (bc->len > maxskip) { - *pos_thres = (long)end-maxskip-1; - bc->len = 0; - } + unsigned long maxskip = + yasm_intnum_get_uint(yasm_expr_get_intnum(&align->maxskip, 0)); + if (bc->len > maxskip) { + *pos_thres = (long)end-maxskip-1; + bc->len = 0; + } } return 1; } static int -bc_align_tobytes(yasm_bytecode *bc, unsigned char **bufp, - unsigned char *bufstart, void *d, - yasm_output_value_func output_value, - /*@unused@*/ yasm_output_reloc_func output_reloc) +bc_align_tobytes(yasm_bytecode *bc, unsigned char **bufp, void *d, + yasm_output_value_func output_value, + /*@unused@*/ yasm_output_reloc_func output_reloc) { bytecode_align *align = (bytecode_align *)bc->contents; unsigned long len; unsigned long boundary = - yasm_intnum_get_uint(yasm_expr_get_intnum(&align->boundary, 0)); + yasm_intnum_get_uint(yasm_expr_get_intnum(&align->boundary, 0)); if (boundary == 0) - return 0; + return 0; else { - unsigned long end = bc->offset; - if (bc->offset & (boundary-1)) - end = (bc->offset & ~(boundary-1)) + boundary; - len = end - bc->offset; - if (len == 0) - return 0; - if (align->maxskip) { - unsigned long maxskip = - yasm_intnum_get_uint(yasm_expr_get_intnum(&align->maxskip, 0)); - if (len > maxskip) - return 0; - } + unsigned long end = bc->offset; + if (bc->offset & (boundary-1)) + end = (bc->offset & ~(boundary-1)) + boundary; + len = end - bc->offset; + if (len == 0) + return 0; + if (align->maxskip) { + unsigned long maxskip = + yasm_intnum_get_uint(yasm_expr_get_intnum(&align->maxskip, 0)); + if (len > maxskip) + return 0; + } } if (align->fill) { - unsigned long v; - v = yasm_intnum_get_uint(yasm_expr_get_intnum(&align->fill, 0)); - memset(*bufp, (int)v, len); - *bufp += len; + unsigned long v; + v = yasm_intnum_get_uint(yasm_expr_get_intnum(&align->fill, 0)); + memset(*bufp, (int)v, len); + *bufp += len; } else if (align->code_fill) { - unsigned long maxlen = 15; - while (!align->code_fill[maxlen] && maxlen>0) - maxlen--; - if (maxlen == 0) { - yasm_error_set(YASM_ERROR_GENERAL, - N_("could not find any code alignment size")); - return 1; - } + unsigned long maxlen = 15; + while (!align->code_fill[maxlen] && maxlen>0) + maxlen--; + if (maxlen == 0) { + yasm_error_set(YASM_ERROR_GENERAL, + N_("could not find any code alignment size")); + return 1; + } - /* Fill with maximum code fill as much as possible */ - while (len > maxlen) { - memcpy(*bufp, align->code_fill[maxlen], maxlen); - *bufp += maxlen; - len -= maxlen; - } + /* Fill with maximum code fill as much as possible */ + while (len > maxlen) { + memcpy(*bufp, align->code_fill[maxlen], maxlen); + *bufp += maxlen; + len -= maxlen; + } - if (!align->code_fill[len]) { - yasm_error_set(YASM_ERROR_VALUE, - N_("invalid alignment size %d"), len); - return 1; - } - /* Handle rest of code fill */ - memcpy(*bufp, align->code_fill[len], len); - *bufp += len; + if (!align->code_fill[len]) { + yasm_error_set(YASM_ERROR_VALUE, + N_("invalid alignment size %d"), len); + return 1; + } + /* Handle rest of code fill */ + memcpy(*bufp, align->code_fill[len], len); + *bufp += len; } else { - /* Just fill with 0 */ - memset(*bufp, 0, len); - *bufp += len; + /* Just fill with 0 */ + memset(*bufp, 0, len); + *bufp += len; } return 0; } yasm_bytecode * yasm_bc_create_align(yasm_expr *boundary, yasm_expr *fill, - yasm_expr *maxskip, const unsigned char **code_fill, - unsigned long line) + yasm_expr *maxskip, const unsigned char **code_fill, + unsigned long line) { bytecode_align *align = yasm_xmalloc(sizeof(bytecode_align)); diff --git a/libyasm/bc-data.c b/libyasm/bc-data.c index ebbdd6f9..f1a71720 100644 --- a/libyasm/bc-data.c +++ b/libyasm/bc-data.c @@ -24,7 +24,9 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ +#define YASM_LIB_INTERNAL #include "util.h" +/*@unused@*/ RCSID("$Id$"); #include "libyasm-stdint.h" #include "coretype.h" @@ -37,48 +39,41 @@ #include "bytecode.h" #include "arch.h" +#include "bc-int.h" + struct yasm_dataval { /*@reldef@*/ STAILQ_ENTRY(yasm_dataval) link; - enum { DV_EMPTY, DV_VALUE, DV_RAW, DV_ULEB128, DV_SLEB128, DV_RESERVE } - type; + enum { DV_EMPTY, DV_VALUE, DV_RAW, DV_ULEB128, DV_SLEB128 } type; union { - yasm_value val; - struct { - /*@only@*/ unsigned char *contents; - unsigned long len; - } raw; + yasm_value val; + struct { + /*@only@*/ unsigned char *contents; + unsigned long len; + } raw; } data; - - /* number of times data is repeated, NULL=1. */ - /*@only@*/ /*@null@*/ yasm_expr *multiple; }; typedef struct bytecode_data { /* converted data (linked list) */ yasm_datavalhead datahead; - - int item_size; } bytecode_data; static void bc_data_destroy(void *contents); static void bc_data_print(const void *contents, FILE *f, int indent_level); static void bc_data_finalize(yasm_bytecode *bc, yasm_bytecode *prev_bc); -static int bc_data_item_size(yasm_bytecode *bc); static int bc_data_calc_len(yasm_bytecode *bc, yasm_bc_add_span_func add_span, - void *add_span_data); -static int bc_data_tobytes(yasm_bytecode *bc, unsigned char **bufp, - unsigned char *bufstart, void *d, - yasm_output_value_func output_value, - /*@null@*/ yasm_output_reloc_func output_reloc); + void *add_span_data); +static int bc_data_tobytes(yasm_bytecode *bc, unsigned char **bufp, void *d, + yasm_output_value_func output_value, + /*@null@*/ yasm_output_reloc_func output_reloc); static const yasm_bytecode_callback bc_data_callback = { bc_data_destroy, bc_data_print, bc_data_finalize, - bc_data_item_size, bc_data_calc_len, yasm_bc_expand_common, bc_data_tobytes, @@ -112,148 +107,103 @@ bc_data_finalize(yasm_bytecode *bc, yasm_bytecode *prev_bc) /* Convert values from simple expr to value. */ STAILQ_FOREACH(dv, &bc_data->datahead, link) { - switch (dv->type) { - case DV_VALUE: - if (yasm_value_finalize(&dv->data.val, prev_bc)) { - yasm_error_set(YASM_ERROR_TOO_COMPLEX, - N_("data expression too complex")); - return; - } - break; - case DV_ULEB128: - case DV_SLEB128: - intn = yasm_expr_get_intnum(&dv->data.val.abs, 0); - if (!intn) { - yasm_error_set(YASM_ERROR_NOT_CONSTANT, - N_("LEB128 requires constant values")); - return; - } - /* Warn for negative values in unsigned environment. - * This could be an error instead: the likelihood this is - * desired is very low! - */ - if (yasm_intnum_sign(intn) == -1 && dv->type == DV_ULEB128) - yasm_warn_set(YASM_WARN_GENERAL, - N_("negative value in unsigned LEB128")); - break; - default: - break; - } - if (dv->multiple) { - yasm_value val; - if (yasm_value_finalize_expr(&val, dv->multiple, prev_bc, 0)) - yasm_error_set(YASM_ERROR_TOO_COMPLEX, - N_("multiple expression too complex")); - else if (val.rel) - yasm_error_set(YASM_ERROR_NOT_ABSOLUTE, - N_("multiple expression not absolute")); - dv->multiple = val.abs; - } + switch (dv->type) { + case DV_VALUE: + if (yasm_value_finalize(&dv->data.val, prev_bc)) { + yasm_error_set(YASM_ERROR_TOO_COMPLEX, + N_("data expression too complex")); + return; + } + break; + case DV_ULEB128: + case DV_SLEB128: + intn = yasm_expr_get_intnum(&dv->data.val.abs, 0); + if (!intn) { + yasm_error_set(YASM_ERROR_NOT_CONSTANT, + N_("LEB128 requires constant values")); + return; + } + /* Warn for negative values in unsigned environment. + * This could be an error instead: the likelihood this is + * desired is very low! + */ + if (yasm_intnum_sign(intn) == -1 && dv->type == DV_ULEB128) + yasm_warn_set(YASM_WARN_GENERAL, + N_("negative value in unsigned LEB128")); + break; + default: + break; + } } } -static int -bc_data_item_size(yasm_bytecode *bc) -{ - bytecode_data *bc_data = (bytecode_data *)bc->contents; - return bc_data->item_size; -} - static int bc_data_calc_len(yasm_bytecode *bc, yasm_bc_add_span_func add_span, - void *add_span_data) + void *add_span_data) { bytecode_data *bc_data = (bytecode_data *)bc->contents; yasm_dataval *dv; yasm_intnum *intn; - unsigned long len = 0; - unsigned long multiple; /* Count up element sizes, rounding up string length. */ STAILQ_FOREACH(dv, &bc_data->datahead, link) { - switch (dv->type) { - case DV_EMPTY: - len = 0; - break; - case DV_VALUE: - len = dv->data.val.size/8; - break; - case DV_RAW: - len = dv->data.raw.len; - break; - case DV_ULEB128: - case DV_SLEB128: - intn = yasm_expr_get_intnum(&dv->data.val.abs, 0); - if (!intn) - yasm_internal_error(N_("non-constant in data_tobytes")); - len = yasm_intnum_size_leb128(intn, dv->type == DV_SLEB128); - break; - case DV_RESERVE: - len = dv->data.val.size/8; - break; - } - - if (!yasm_dv_get_multiple(dv, &multiple)) - len *= multiple; - - bc->len += len; + switch (dv->type) { + case DV_EMPTY: + break; + case DV_VALUE: + bc->len += dv->data.val.size/8; + break; + case DV_RAW: + bc->len += dv->data.raw.len; + break; + case DV_ULEB128: + case DV_SLEB128: + intn = yasm_expr_get_intnum(&dv->data.val.abs, 0); + if (!intn) + yasm_internal_error(N_("non-constant in data_tobytes")); + bc->len += + yasm_intnum_size_leb128(intn, dv->type == DV_SLEB128); + break; + } } return 0; } static int -bc_data_tobytes(yasm_bytecode *bc, unsigned char **bufp, - unsigned char *bufstart, void *d, - yasm_output_value_func output_value, - /*@unused@*/ yasm_output_reloc_func output_reloc) +bc_data_tobytes(yasm_bytecode *bc, unsigned char **bufp, void *d, + yasm_output_value_func output_value, + /*@unused@*/ yasm_output_reloc_func output_reloc) { bytecode_data *bc_data = (bytecode_data *)bc->contents; yasm_dataval *dv; + unsigned char *bufp_orig = *bufp; yasm_intnum *intn; unsigned int val_len; - unsigned long multiple, i; STAILQ_FOREACH(dv, &bc_data->datahead, link) { - if (yasm_dv_get_multiple(dv, &multiple) || multiple == 0) - continue; - switch (dv->type) { - case DV_EMPTY: - break; - case DV_VALUE: - val_len = dv->data.val.size/8; - for (i=0; idata.val, *bufp, val_len, - (unsigned long)(*bufp-bufstart), bc, 1, - d)) - return 1; - *bufp += val_len; - } - break; - case DV_RAW: - for (i=0; idata.raw.contents, dv->data.raw.len); - *bufp += dv->data.raw.len; - } - break; - case DV_ULEB128: - case DV_SLEB128: - intn = yasm_expr_get_intnum(&dv->data.val.abs, 234); - if (!intn) - yasm_internal_error(N_("non-constant in data_tobytes")); - for (i=0; itype == DV_SLEB128); - } - case DV_RESERVE: - val_len = dv->data.val.size/8; - for (i=0; itype) { + case DV_EMPTY: + break; + case DV_VALUE: + val_len = dv->data.val.size/8; + if (output_value(&dv->data.val, *bufp, val_len, + (unsigned long)(*bufp-bufp_orig), bc, 1, d)) + return 1; + *bufp += val_len; + break; + case DV_RAW: + memcpy(*bufp, dv->data.raw.contents, dv->data.raw.len); + *bufp += dv->data.raw.len; + break; + case DV_ULEB128: + case DV_SLEB128: + intn = yasm_expr_get_intnum(&dv->data.val.abs, 234); + if (!intn) + yasm_internal_error(N_("non-constant in data_tobytes")); + *bufp += + yasm_intnum_get_leb128(intn, *bufp, dv->type == DV_SLEB128); + } } return 0; @@ -261,7 +211,7 @@ bc_data_tobytes(yasm_bytecode *bc, unsigned char **bufp, yasm_bytecode * yasm_bc_create_data(yasm_datavalhead *datahead, unsigned int size, - int append_zero, yasm_arch *arch, unsigned long line) + int append_zero, yasm_arch *arch, unsigned long line) { bytecode_data *data = yasm_xmalloc(sizeof(bytecode_data)); yasm_bytecode *bc = yasm_bc_create_common(&bc_data_callback, data, line); @@ -271,72 +221,52 @@ yasm_bc_create_data(yasm_datavalhead *datahead, unsigned int size, yasm_dvs_initialize(&data->datahead); - data->item_size = size; /* Prescan input data for length, etc. Careful: this needs to be * precisely paired with the second loop. */ STAILQ_FOREACH(dv, datahead, link) { - if (dv->multiple && dv->type != DV_EMPTY && len > 0) { - /* Flush previous data */ - dvo = yasm_dv_create_raw(yasm_xmalloc(len), len); - STAILQ_INSERT_TAIL(&data->datahead, dvo, link); - len = 0; - } - switch (dv->type) { - case DV_EMPTY: - break; - case DV_VALUE: - case DV_ULEB128: - case DV_SLEB128: - intn = yasm_expr_get_intnum(&dv->data.val.abs, 0); - if (intn && dv->type == DV_VALUE && (arch || size == 1)) - len += size; - else if (intn && dv->type == DV_ULEB128) - len += yasm_intnum_size_leb128(intn, 0); - else if (intn && dv->type == DV_SLEB128) - len += yasm_intnum_size_leb128(intn, 1); - else { - if (len > 0) { - /* Create bytecode for all previous len */ - dvo = yasm_dv_create_raw(yasm_xmalloc(len), len); - STAILQ_INSERT_TAIL(&data->datahead, dvo, link); - len = 0; - } + switch (dv->type) { + case DV_EMPTY: + break; + case DV_VALUE: + case DV_ULEB128: + case DV_SLEB128: + intn = yasm_expr_get_intnum(&dv->data.val.abs, 0); + if (intn && dv->type == DV_VALUE && (arch || size == 1)) + len += size; + else if (intn && dv->type == DV_ULEB128) + len += yasm_intnum_size_leb128(intn, 0); + else if (intn && dv->type == DV_SLEB128) + len += yasm_intnum_size_leb128(intn, 1); + else { + if (len > 0) { + /* Create bytecode for all previous len */ + dvo = yasm_dv_create_raw(yasm_xmalloc(len), len); + STAILQ_INSERT_TAIL(&data->datahead, dvo, link); + len = 0; + } - /* Create bytecode for this value */ - dvo = yasm_xmalloc(sizeof(yasm_dataval)); - STAILQ_INSERT_TAIL(&data->datahead, dvo, link); - dvo->multiple = dv->multiple; - } - break; - case DV_RAW: - rlen = dv->data.raw.len; - /* find count, rounding up to nearest multiple of size */ - rlen = (rlen + size - 1) / size; - len += rlen*size; - break; - case DV_RESERVE: - len += size; - break; - } - - if (dv->multiple && dv->type != DV_EMPTY && len > 0) { - /* Flush this data */ - dvo = yasm_dv_create_raw(yasm_xmalloc(len), len); - STAILQ_INSERT_TAIL(&data->datahead, dvo, link); - dvo->multiple = dv->multiple; - len = 0; - } - - if (append_zero) - len++; + /* Create bytecode for this value */ + dvo = yasm_xmalloc(sizeof(yasm_dataval)); + STAILQ_INSERT_TAIL(&data->datahead, dvo, link); + } + break; + case DV_RAW: + rlen = dv->data.raw.len; + /* find count, rounding up to nearest multiple of size */ + rlen = (rlen + size - 1) / size; + len += rlen*size; + break; + } + if (append_zero) + len++; } /* Create final dataval for any trailing length */ if (len > 0) { - dvo = yasm_dv_create_raw(yasm_xmalloc(len), len); - STAILQ_INSERT_TAIL(&data->datahead, dvo, link); + dvo = yasm_dv_create_raw(yasm_xmalloc(len), len); + STAILQ_INSERT_TAIL(&data->datahead, dvo, link); } /* Second iteration: copy data and delete input datavals. */ @@ -344,78 +274,64 @@ yasm_bc_create_data(yasm_datavalhead *datahead, unsigned int size, dvo = STAILQ_FIRST(&data->datahead); len = 0; while (dv && dvo) { - if (dv->multiple && dv->type != DV_EMPTY && len > 0) { - dvo = STAILQ_NEXT(dvo, link); - len = 0; - } - switch (dv->type) { - case DV_EMPTY: - break; - case DV_VALUE: - case DV_ULEB128: - case DV_SLEB128: - intn = yasm_expr_get_intnum(&dv->data.val.abs, 0); - if (intn && dv->type == DV_VALUE && (arch || size == 1)) { - if (size == 1) - yasm_intnum_get_sized(intn, - &dvo->data.raw.contents[len], - 1, 8, 0, 0, 1); - else - yasm_arch_intnum_tobytes(arch, intn, - &dvo->data.raw.contents[len], - size, size*8, 0, bc, 1); - yasm_value_delete(&dv->data.val); - len += size; - } else if (intn && dv->type == DV_ULEB128) { - len += yasm_intnum_get_leb128(intn, - &dvo->data.raw.contents[len], - 0); - yasm_value_delete(&dv->data.val); - } else if (intn && dv->type == DV_SLEB128) { - len += yasm_intnum_get_leb128(intn, - &dvo->data.raw.contents[len], - 1); - yasm_value_delete(&dv->data.val); - } else { - if (len > 0) - dvo = STAILQ_NEXT(dvo, link); - dvo->type = dv->type; - dvo->data.val = dv->data.val; /* structure copy */ - dvo->data.val.size = size*8; /* remember size */ - dvo = STAILQ_NEXT(dvo, link); - len = 0; - } - break; - case DV_RAW: - rlen = dv->data.raw.len; - memcpy(&dvo->data.raw.contents[len], dv->data.raw.contents, - rlen); - yasm_xfree(dv->data.raw.contents); - len += rlen; - /* pad with 0's to nearest multiple of size */ - rlen %= size; - if (rlen > 0) { - rlen = size-rlen; - for (i=0; idata.raw.contents[len++] = 0; - } - break; - case DV_RESERVE: - memset(&dvo->data.raw.contents[len], 0, size); - len += size; - break; - } - - if (dv->multiple && dv->type != DV_EMPTY && len > 0) { - dvo = STAILQ_NEXT(dvo, link); - len = 0; - } - - if (append_zero) - dvo->data.raw.contents[len++] = 0; - dv2 = STAILQ_NEXT(dv, link); - yasm_xfree(dv); - dv = dv2; + switch (dv->type) { + case DV_EMPTY: + break; + case DV_VALUE: + case DV_ULEB128: + case DV_SLEB128: + intn = yasm_expr_get_intnum(&dv->data.val.abs, 0); + if (intn && dv->type == DV_VALUE && (arch || size == 1)) { + if (size == 1) + yasm_intnum_get_sized(intn, + &dvo->data.raw.contents[len], + 1, 8, 0, 0, 1); + else + yasm_arch_intnum_tobytes(arch, intn, + &dvo->data.raw.contents[len], + size, size*8, 0, bc, 1); + yasm_value_delete(&dv->data.val); + len += size; + } else if (intn && dv->type == DV_ULEB128) { + len += yasm_intnum_get_leb128(intn, + &dvo->data.raw.contents[len], + 0); + yasm_value_delete(&dv->data.val); + } else if (intn && dv->type == DV_SLEB128) { + len += yasm_intnum_get_leb128(intn, + &dvo->data.raw.contents[len], + 1); + yasm_value_delete(&dv->data.val); + } else { + if (len > 0) + dvo = STAILQ_NEXT(dvo, link); + dvo->type = dv->type; + dvo->data.val = dv->data.val; /* structure copy */ + dvo->data.val.size = size*8; /* remember size */ + dvo = STAILQ_NEXT(dvo, link); + len = 0; + } + break; + case DV_RAW: + rlen = dv->data.raw.len; + memcpy(&dvo->data.raw.contents[len], dv->data.raw.contents, + rlen); + yasm_xfree(dv->data.raw.contents); + len += rlen; + /* pad with 0's to nearest multiple of size */ + rlen %= size; + if (rlen > 0) { + rlen = size-rlen; + for (i=0; idata.raw.contents[len++] = 0; + } + break; + } + if (append_zero) + dvo->data.raw.contents[len++] = 0; + dv2 = STAILQ_NEXT(dv, link); + yasm_xfree(dv); + dv = dv2; } return bc; @@ -428,17 +344,17 @@ yasm_bc_create_leb128(yasm_datavalhead *datahead, int sign, unsigned long line) /* Convert all values into LEB type, error on strings/raws */ STAILQ_FOREACH(dv, datahead, link) { - switch (dv->type) { - case DV_VALUE: - dv->type = sign ? DV_SLEB128 : DV_ULEB128; - break; - case DV_RAW: - yasm_error_set(YASM_ERROR_VALUE, - N_("LEB128 does not allow string constants")); - break; - default: - break; - } + switch (dv->type) { + case DV_VALUE: + dv->type = sign ? DV_SLEB128 : DV_ULEB128; + break; + case DV_RAW: + yasm_error_set(YASM_ERROR_VALUE, + N_("LEB128 does not allow string constants")); + break; + default: + break; + } } return yasm_bc_create_data(datahead, 0, 0, 0, line); @@ -451,7 +367,6 @@ yasm_dv_create_expr(yasm_expr *e) retval->type = DV_VALUE; yasm_value_initialize(&retval->data.val, e, 0); - retval->multiple = NULL; return retval; } @@ -464,62 +379,10 @@ yasm_dv_create_raw(unsigned char *contents, unsigned long len) retval->type = DV_RAW; retval->data.raw.contents = contents; retval->data.raw.len = len; - retval->multiple = NULL; return retval; } -yasm_dataval * -yasm_dv_create_reserve(void) -{ - yasm_dataval *retval = yasm_xmalloc(sizeof(yasm_dataval)); - - retval->type = DV_RESERVE; - retval->multiple = NULL; - - return retval; -} - -yasm_value * -yasm_dv_get_value(yasm_dataval *dv) -{ - if (dv->type != DV_VALUE) - return NULL; - return &dv->data.val; -} - -void -yasm_dv_set_multiple(yasm_dataval *dv, yasm_expr *e) -{ - if (dv->multiple) - dv->multiple = yasm_expr_create_tree( dv->multiple, YASM_EXPR_MUL, e, - e->line); - else - dv->multiple = e; -} - -int -yasm_dv_get_multiple(yasm_dataval *dv, unsigned long *multiple) -{ - /*@dependent@*/ /*@null@*/ const yasm_intnum *num; - - *multiple = 1; - if (dv->multiple) { - num = yasm_expr_get_intnum(&dv->multiple, 0); - if (!num) { - yasm_error_set(YASM_ERROR_VALUE, - N_("could not determine multiple")); - return 1; - } - if (yasm_intnum_sign(num) < 0) { - yasm_error_set(YASM_ERROR_VALUE, N_("multiple is negative")); - return 1; - } - *multiple = yasm_intnum_get_uint(num); - } - return 0; -} - void yasm_dvs_delete(yasm_datavalhead *headp) { @@ -527,21 +390,19 @@ yasm_dvs_delete(yasm_datavalhead *headp) cur = STAILQ_FIRST(headp); while (cur) { - next = STAILQ_NEXT(cur, link); - switch (cur->type) { - case DV_VALUE: - yasm_value_delete(&cur->data.val); - break; - case DV_RAW: - yasm_xfree(cur->data.raw.contents); - break; - default: - break; - } - if (cur->multiple) - yasm_expr_destroy(cur->multiple); - yasm_xfree(cur); - cur = next; + next = STAILQ_NEXT(cur, link); + switch (cur->type) { + case DV_VALUE: + yasm_value_delete(&cur->data.val); + break; + case DV_RAW: + yasm_xfree(cur->data.raw.contents); + break; + default: + break; + } + yasm_xfree(cur); + cur = next; } STAILQ_INIT(headp); } @@ -550,8 +411,8 @@ yasm_dataval * yasm_dvs_append(yasm_datavalhead *headp, yasm_dataval *dv) { if (dv) { - STAILQ_INSERT_TAIL(headp, dv, link); - return dv; + STAILQ_INSERT_TAIL(headp, dv, link); + return dv; } return (yasm_dataval *)NULL; } @@ -563,38 +424,38 @@ yasm_dvs_print(const yasm_datavalhead *head, FILE *f, int indent_level) unsigned long i; STAILQ_FOREACH(cur, head, link) { - fprintf(f, "%*sMultiple=", indent_level, ""); - if (!cur->multiple) - fprintf(f, "nil (1)"); - else - yasm_expr_print(cur->multiple, f); - switch (cur->type) { - case DV_EMPTY: - fprintf(f, "%*sEmpty\n", indent_level, ""); - break; - case DV_VALUE: - fprintf(f, "%*sValue:\n", indent_level, ""); - yasm_value_print(&cur->data.val, f, indent_level+1); - break; - case DV_RAW: - fprintf(f, "%*sLength=%lu\n", indent_level, "", - cur->data.raw.len); - fprintf(f, "%*sBytes=[", indent_level, ""); - for (i=0; idata.raw.len; i++) - fprintf(f, "0x%02x, ", cur->data.raw.contents[i]); - fprintf(f, "]\n"); - break; - case DV_ULEB128: - fprintf(f, "%*sULEB128 value:\n", indent_level, ""); - yasm_value_print(&cur->data.val, f, indent_level+1); - break; - case DV_SLEB128: - fprintf(f, "%*sSLEB128 value:\n", indent_level, ""); - yasm_value_print(&cur->data.val, f, indent_level+1); - break; - case DV_RESERVE: - fprintf(f, "%*sReserved\n", indent_level, ""); - break; - } + switch (cur->type) { + case DV_EMPTY: + fprintf(f, "%*sEmpty\n", indent_level, ""); + break; + case DV_VALUE: + fprintf(f, "%*sValue:\n", indent_level, ""); + yasm_value_print(&cur->data.val, f, indent_level+1); + break; + case DV_RAW: + fprintf(f, "%*sLength=%lu\n", indent_level, "", + cur->data.raw.len); + fprintf(f, "%*sBytes=[", indent_level, ""); + for (i=0; idata.raw.len; i++) + fprintf(f, "0x%02x, ", cur->data.raw.contents[i]); + fprintf(f, "]\n"); + break; + case DV_ULEB128: + fprintf(f, "%*sULEB128 value:\n", indent_level, ""); + yasm_value_print(&cur->data.val, f, indent_level+1); + break; + case DV_SLEB128: + fprintf(f, "%*sSLEB128 value:\n", indent_level, ""); + yasm_value_print(&cur->data.val, f, indent_level+1); + break; + } } } + +/* Non-macro yasm_dvs_initialize() for non-YASM_LIB_INTERNAL users. */ +#undef yasm_dvs_initialize +void +yasm_dvs_initialize(yasm_datavalhead *headp) +{ + STAILQ_INIT(headp); +} diff --git a/libyasm/bc-incbin.c b/libyasm/bc-incbin.c index a8fec7d6..0f8c776d 100644 --- a/libyasm/bc-incbin.c +++ b/libyasm/bc-incbin.c @@ -24,7 +24,9 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ +#define YASM_LIB_INTERNAL #include "util.h" +/*@unused@*/ RCSID("$Id$"); #include "libyasm-stdint.h" #include "coretype.h" @@ -40,10 +42,12 @@ #include "file.h" +#include "bc-int.h" + typedef struct bytecode_incbin { - /*@only@*/ char *filename; /* file to include data from */ - const char *from; /* filename of what contained incbin */ + /*@only@*/ char *filename; /* file to include data from */ + const char *from; /* filename of what contained incbin */ /* starting offset to read from (NULL=0) */ /*@only@*/ /*@null@*/ yasm_expr *start; @@ -56,17 +60,15 @@ static void bc_incbin_destroy(void *contents); static void bc_incbin_print(const void *contents, FILE *f, int indent_level); static void bc_incbin_finalize(yasm_bytecode *bc, yasm_bytecode *prev_bc); static int bc_incbin_calc_len(yasm_bytecode *bc, yasm_bc_add_span_func add_span, - void *add_span_data); -static int bc_incbin_tobytes(yasm_bytecode *bc, unsigned char **bufp, - unsigned char *bufstart, void *d, - yasm_output_value_func output_value, - /*@null@*/ yasm_output_reloc_func output_reloc); + void *add_span_data); +static int bc_incbin_tobytes(yasm_bytecode *bc, unsigned char **bufp, void *d, + yasm_output_value_func output_value, + /*@null@*/ yasm_output_reloc_func output_reloc); static const yasm_bytecode_callback bc_incbin_callback = { bc_incbin_destroy, bc_incbin_print, bc_incbin_finalize, - NULL, bc_incbin_calc_len, yasm_bc_expand_common, bc_incbin_tobytes, @@ -90,17 +92,17 @@ bc_incbin_print(const void *contents, FILE *f, int indent_level) const bytecode_incbin *incbin = (const bytecode_incbin *)contents; fprintf(f, "%*s_IncBin_\n", indent_level, ""); fprintf(f, "%*sFilename=`%s'\n", indent_level, "", - incbin->filename); + incbin->filename); fprintf(f, "%*sStart=", indent_level, ""); if (!incbin->start) - fprintf(f, "nil (0)"); + fprintf(f, "nil (0)"); else - yasm_expr_print(incbin->start, f); + yasm_expr_print(incbin->start, f); fprintf(f, "%*sMax Len=", indent_level, ""); if (!incbin->maxlen) - fprintf(f, "nil (unlimited)"); + fprintf(f, "nil (unlimited)"); else - yasm_expr_print(incbin->maxlen, f); + yasm_expr_print(incbin->maxlen, f); fprintf(f, "\n"); } @@ -111,25 +113,25 @@ bc_incbin_finalize(yasm_bytecode *bc, yasm_bytecode *prev_bc) yasm_value val; if (yasm_value_finalize_expr(&val, incbin->start, prev_bc, 0)) - yasm_error_set(YASM_ERROR_TOO_COMPLEX, - N_("start expression too complex")); + yasm_error_set(YASM_ERROR_TOO_COMPLEX, + N_("start expression too complex")); else if (val.rel) - yasm_error_set(YASM_ERROR_NOT_ABSOLUTE, - N_("start expression not absolute")); + yasm_error_set(YASM_ERROR_NOT_ABSOLUTE, + N_("start expression not absolute")); incbin->start = val.abs; if (yasm_value_finalize_expr(&val, incbin->maxlen, prev_bc, 0)) - yasm_error_set(YASM_ERROR_TOO_COMPLEX, - N_("maximum length expression too complex")); + yasm_error_set(YASM_ERROR_TOO_COMPLEX, + N_("maximum length expression too complex")); else if (val.rel) - yasm_error_set(YASM_ERROR_NOT_ABSOLUTE, - N_("maximum length expression not absolute")); + yasm_error_set(YASM_ERROR_NOT_ABSOLUTE, + N_("maximum length expression not absolute")); incbin->maxlen = val.abs; } static int bc_incbin_calc_len(yasm_bytecode *bc, yasm_bc_add_span_func add_span, - void *add_span_data) + void *add_span_data) { bytecode_incbin *incbin = (bytecode_incbin *)bc->contents; FILE *f; @@ -138,67 +140,66 @@ bc_incbin_calc_len(yasm_bytecode *bc, yasm_bc_add_span_func add_span, /* Try to convert start to integer value */ if (incbin->start) { - num = yasm_expr_get_intnum(&incbin->start, 0); - if (num) - start = yasm_intnum_get_uint(num); - if (!num) { - /* FIXME */ - yasm_error_set(YASM_ERROR_NOT_IMPLEMENTED, - N_("incbin does not yet understand non-constant")); - return -1; - } + num = yasm_expr_get_intnum(&incbin->start, 0); + if (num) + start = yasm_intnum_get_uint(num); + if (!num) { + /* FIXME */ + yasm_error_set(YASM_ERROR_NOT_IMPLEMENTED, + N_("incbin does not yet understand non-constant")); + return -1; + } } /* Try to convert maxlen to integer value */ if (incbin->maxlen) { - num = yasm_expr_get_intnum(&incbin->maxlen, 0); - if (num) - maxlen = yasm_intnum_get_uint(num); - if (!num) { - /* FIXME */ - yasm_error_set(YASM_ERROR_NOT_IMPLEMENTED, - N_("incbin does not yet understand non-constant")); - return -1; - } + num = yasm_expr_get_intnum(&incbin->maxlen, 0); + if (num) + maxlen = yasm_intnum_get_uint(num); + if (!num) { + /* FIXME */ + yasm_error_set(YASM_ERROR_NOT_IMPLEMENTED, + N_("incbin does not yet understand non-constant")); + return -1; + } } /* Open file and determine its length */ f = yasm_fopen_include(incbin->filename, incbin->from, "rb", NULL); if (!f) { - yasm_error_set(YASM_ERROR_IO, - N_("`incbin': unable to open file `%s'"), - incbin->filename); - return -1; + yasm_error_set(YASM_ERROR_IO, + N_("`incbin': unable to open file `%s'"), + incbin->filename); + return -1; } if (fseek(f, 0L, SEEK_END) < 0) { - yasm_error_set(YASM_ERROR_IO, - N_("`incbin': unable to seek on file `%s'"), - incbin->filename); - return -1; + yasm_error_set(YASM_ERROR_IO, + N_("`incbin': unable to seek on file `%s'"), + incbin->filename); + return -1; } flen = (unsigned long)ftell(f); fclose(f); /* Compute length of incbin from start, maxlen, and len */ if (start > flen) { - yasm_warn_set(YASM_WARN_GENERAL, - N_("`incbin': start past end of file `%s'"), - incbin->filename); - start = flen; + yasm_warn_set(YASM_WARN_GENERAL, + N_("`incbin': start past end of file `%s'"), + incbin->filename); + start = flen; } flen -= start; if (incbin->maxlen) - if (maxlen < flen) - flen = maxlen; + if (maxlen < flen) + flen = maxlen; bc->len += flen; return 0; } static int -bc_incbin_tobytes(yasm_bytecode *bc, unsigned char **bufp, - unsigned char *bufstart, void *d, - yasm_output_value_func output_value, - /*@unused@*/ yasm_output_reloc_func output_reloc) +bc_incbin_tobytes(yasm_bytecode *bc, unsigned char **bufp, void *d, + yasm_output_value_func output_value, + /*@unused@*/ yasm_output_reloc_func output_reloc) { bytecode_incbin *incbin = (bytecode_incbin *)bc->contents; FILE *f; @@ -207,37 +208,37 @@ bc_incbin_tobytes(yasm_bytecode *bc, unsigned char **bufp, /* Convert start to integer value */ if (incbin->start) { - num = yasm_expr_get_intnum(&incbin->start, 0); - if (!num) - yasm_internal_error( - N_("could not determine start in bc_tobytes_incbin")); - start = yasm_intnum_get_uint(num); + num = yasm_expr_get_intnum(&incbin->start, 0); + if (!num) + yasm_internal_error( + N_("could not determine start in bc_tobytes_incbin")); + start = yasm_intnum_get_uint(num); } /* Open file */ f = yasm_fopen_include(incbin->filename, incbin->from, "rb", NULL); if (!f) { - yasm_error_set(YASM_ERROR_IO, N_("`incbin': unable to open file `%s'"), - incbin->filename); - return 1; + yasm_error_set(YASM_ERROR_IO, N_("`incbin': unable to open file `%s'"), + incbin->filename); + return 1; } /* Seek to start of data */ if (fseek(f, (long)start, SEEK_SET) < 0) { - yasm_error_set(YASM_ERROR_IO, - N_("`incbin': unable to seek on file `%s'"), - incbin->filename); - fclose(f); - return 1; + yasm_error_set(YASM_ERROR_IO, + N_("`incbin': unable to seek on file `%s'"), + incbin->filename); + fclose(f); + return 1; } /* Read len bytes */ if (fread(*bufp, 1, (size_t)bc->len, f) < (size_t)bc->len) { - yasm_error_set(YASM_ERROR_IO, - N_("`incbin': unable to read %lu bytes from file `%s'"), - bc->len, incbin->filename); - fclose(f); - return 1; + yasm_error_set(YASM_ERROR_IO, + N_("`incbin': unable to read %lu bytes from file `%s'"), + bc->len, incbin->filename); + fclose(f); + return 1; } *bufp += bc->len; @@ -247,7 +248,7 @@ bc_incbin_tobytes(yasm_bytecode *bc, unsigned char **bufp, yasm_bytecode * yasm_bc_create_incbin(char *filename, yasm_expr *start, yasm_expr *maxlen, - yasm_linemap *linemap, unsigned long line) + yasm_linemap *linemap, unsigned long line) { bytecode_incbin *incbin = yasm_xmalloc(sizeof(bytecode_incbin)); unsigned long xline; diff --git a/libyasm/bc-insn.c b/libyasm/bc-insn.c new file mode 100644 index 00000000..f163a74e --- /dev/null +++ b/libyasm/bc-insn.c @@ -0,0 +1,334 @@ +/* + * Insn bytecode + * + * Copyright (C) 2005-2007 Peter Johnson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND OTHER CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR OTHER CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +#define YASM_LIB_INTERNAL +#include "util.h" +/*@unused@*/ RCSID("$Id$"); + +#include "libyasm-stdint.h" +#include "coretype.h" + +#include "errwarn.h" +#include "expr.h" +#include "value.h" + +#include "bytecode.h" +#include "arch.h" + +#include "bc-int.h" + + +typedef struct bytecode_insn { + /*@dependent@*/ yasm_arch *arch; + uintptr_t insn_data[4]; + + int num_operands; + /*@null@*/ yasm_insn_operands operands; + + /* array of 4-element prefix_data arrays */ + int num_prefixes; + /*@null@*/ uintptr_t **prefixes; + + /* array of segment prefixes */ + int num_segregs; + /*@null@*/ uintptr_t *segregs; +} bytecode_insn; + +static void bc_insn_destroy(void *contents); +static void bc_insn_print(const void *contents, FILE *f, int indent_level); +static void bc_insn_finalize(yasm_bytecode *bc, yasm_bytecode *prev_bc); +static int bc_insn_calc_len(yasm_bytecode *bc, yasm_bc_add_span_func add_span, + void *add_span_data); +static int bc_insn_tobytes(yasm_bytecode *bc, unsigned char **bufp, void *d, + yasm_output_value_func output_value, + /*@null@*/ yasm_output_reloc_func output_reloc); + +static const yasm_bytecode_callback bc_insn_callback = { + bc_insn_destroy, + bc_insn_print, + bc_insn_finalize, + bc_insn_calc_len, + yasm_bc_expand_common, + bc_insn_tobytes, + 0 +}; + + +const yasm_expr * +yasm_ea_get_disp(const yasm_effaddr *ea) +{ + return ea->disp.abs; +} + +void +yasm_ea_set_len(yasm_effaddr *ptr, unsigned int len) +{ + if (!ptr) + return; + + /* Currently don't warn if length truncated, as this is called only from + * an explicit override, where we expect the user knows what they're doing. + */ + + ptr->disp.size = (unsigned char)len; +} + +void +yasm_ea_set_nosplit(yasm_effaddr *ptr, unsigned int nosplit) +{ + if (!ptr) + return; + + ptr->nosplit = (unsigned char)nosplit; +} + +void +yasm_ea_set_strong(yasm_effaddr *ptr, unsigned int strong) +{ + if (!ptr) + return; + + ptr->strong = (unsigned char)strong; +} + +void +yasm_ea_set_segreg(yasm_effaddr *ea, uintptr_t segreg) +{ + if (!ea) + return; + + if (segreg != 0 && ea->segreg != 0) + yasm_warn_set(YASM_WARN_GENERAL, + N_("multiple segment overrides, using leftmost")); + + ea->segreg = segreg; +} + +/*@-nullstate@*/ +void +yasm_ea_destroy(yasm_effaddr *ea) +{ + ea->callback->destroy(ea); + yasm_value_delete(&ea->disp); + yasm_xfree(ea); +} +/*@=nullstate@*/ + +/*@-nullstate@*/ +void +yasm_ea_print(const yasm_effaddr *ea, FILE *f, int indent_level) +{ + fprintf(f, "%*sDisp:\n", indent_level, ""); + yasm_value_print(&ea->disp, f, indent_level+1); + fprintf(f, "%*sNoSplit=%u\n", indent_level, "", (unsigned int)ea->nosplit); + ea->callback->print(ea, f, indent_level); +} +/*@=nullstate@*/ + +static void +bc_insn_destroy(void *contents) +{ + bytecode_insn *insn = (bytecode_insn *)contents; + if (insn->num_operands > 0) + yasm_ops_delete(&insn->operands, 0); + if (insn->num_prefixes > 0) { + int i; + for (i=0; inum_prefixes; i++) + yasm_xfree(insn->prefixes[i]); + yasm_xfree(insn->prefixes); + } + if (insn->num_segregs > 0) + yasm_xfree(insn->segregs); + yasm_xfree(contents); +} + +static void +bc_insn_print(const void *contents, FILE *f, int indent_level) +{ +} + +static void +bc_insn_finalize(yasm_bytecode *bc, yasm_bytecode *prev_bc) +{ + bytecode_insn *insn = (bytecode_insn *)bc->contents; + int i; + yasm_insn_operand *op; + yasm_error_class eclass; + char *str, *xrefstr; + unsigned long xrefline; + + /* Simplify the operands' expressions first. */ + for (i = 0, op = yasm_ops_first(&insn->operands); + op && inum_operands; op = yasm_operand_next(op), i++) { + /* Check operand type */ + switch (op->type) { + case YASM_INSN__OPERAND_MEMORY: + /* Don't get over-ambitious here; some archs' memory expr + * parser are sensitive to the presence of *1, etc, so don't + * simplify reg*1 identities. + */ + if (op->data.ea) + op->data.ea->disp.abs = + yasm_expr__level_tree(op->data.ea->disp.abs, 1, 1, 0, + 0, NULL, NULL); + if (yasm_error_occurred()) { + /* Add a pointer to where it was used to the error */ + yasm_error_fetch(&eclass, &str, &xrefline, &xrefstr); + if (xrefstr) { + yasm_error_set_xref(xrefline, "%s", xrefstr); + yasm_xfree(xrefstr); + } + if (str) { + yasm_error_set(eclass, "%s in memory expression", str); + yasm_xfree(str); + } + return; + } + break; + case YASM_INSN__OPERAND_IMM: + op->data.val = + yasm_expr__level_tree(op->data.val, 1, 1, 1, 0, NULL, + NULL); + if (yasm_error_occurred()) { + /* Add a pointer to where it was used to the error */ + yasm_error_fetch(&eclass, &str, &xrefline, &xrefstr); + if (xrefstr) { + yasm_error_set_xref(xrefline, "%s", xrefstr); + yasm_xfree(xrefstr); + } + if (str) { + yasm_error_set(eclass, "%s in immediate expression", + str); + yasm_xfree(str); + } + return; + } + break; + default: + break; + } + } + + yasm_arch_finalize_insn(insn->arch, bc, prev_bc, insn->insn_data, + insn->num_operands, &insn->operands, + insn->num_prefixes, insn->prefixes, + insn->num_segregs, insn->segregs); +} + +static int +bc_insn_calc_len(yasm_bytecode *bc, yasm_bc_add_span_func add_span, + void *add_span_data) +{ + yasm_internal_error(N_("bc_insn_calc_len() is not implemented")); + /*@notreached@*/ + return 0; +} + +static int +bc_insn_tobytes(yasm_bytecode *bc, unsigned char **bufp, void *d, + yasm_output_value_func output_value, + /*@unused@*/ yasm_output_reloc_func output_reloc) +{ + yasm_internal_error(N_("bc_insn_tobytes() is not implemented")); + /*@notreached@*/ + return 1; +} + +yasm_bytecode * +yasm_bc_create_insn(yasm_arch *arch, const uintptr_t insn_data[4], + int num_operands, /*@null@*/ yasm_insn_operands *operands, + unsigned long line) +{ + bytecode_insn *insn = yasm_xmalloc(sizeof(bytecode_insn)); + + insn->arch = arch; + insn->insn_data[0] = insn_data[0]; + insn->insn_data[1] = insn_data[1]; + insn->insn_data[2] = insn_data[2]; + insn->insn_data[3] = insn_data[3]; + insn->num_operands = num_operands; + if (operands) + insn->operands = *operands; /* structure copy */ + else + yasm_ops_initialize(&insn->operands); + insn->num_prefixes = 0; + insn->prefixes = NULL; + insn->num_segregs = 0; + insn->segregs = NULL; + + return yasm_bc_create_common(&bc_insn_callback, insn, line); +} + +yasm_bytecode * +yasm_bc_create_empty_insn(yasm_arch *arch, unsigned long line) +{ + bytecode_insn *insn = yasm_xmalloc(sizeof(bytecode_insn)); + + insn->arch = arch; + insn->insn_data[0] = 0; + insn->insn_data[1] = 0; + insn->insn_data[2] = 0; + insn->insn_data[3] = 0; + insn->num_operands = 0; + yasm_ops_initialize(&insn->operands); + insn->num_prefixes = 0; + insn->prefixes = NULL; + insn->num_segregs = 0; + insn->segregs = NULL; + + return yasm_bc_create_common(&bc_insn_callback, insn, line); +} + +void +yasm_bc_insn_add_prefix(yasm_bytecode *bc, const uintptr_t prefix_data[4]) +{ + bytecode_insn *insn = (bytecode_insn *)bc->contents; + + assert(bc->callback == bc_insn_callback); + + insn->prefixes = + yasm_xrealloc(insn->prefixes, + (insn->num_prefixes+1)*sizeof(uintptr_t *)); + insn->prefixes[insn->num_prefixes] = yasm_xmalloc(4*sizeof(uintptr_t)); + insn->prefixes[insn->num_prefixes][0] = prefix_data[0]; + insn->prefixes[insn->num_prefixes][1] = prefix_data[1]; + insn->prefixes[insn->num_prefixes][2] = prefix_data[2]; + insn->prefixes[insn->num_prefixes][3] = prefix_data[3]; + insn->num_prefixes++; +} + +void +yasm_bc_insn_add_seg_prefix(yasm_bytecode *bc, uintptr_t segreg) +{ + bytecode_insn *insn = (bytecode_insn *)bc->contents; + + assert(bc->callback == bc_insn_callback); + + insn->segregs = + yasm_xrealloc(insn->segregs, (insn->num_segregs+1)*sizeof(uintptr_t)); + insn->segregs[insn->num_segregs] = segreg; + insn->num_segregs++; +} diff --git a/libyasm/bc-int.h b/libyasm/bc-int.h new file mode 100644 index 00000000..e162b227 --- /dev/null +++ b/libyasm/bc-int.h @@ -0,0 +1,113 @@ +/* $Id$ + * Bytecode internal structures header file + * + * Copyright (C) 2001-2007 Peter Johnson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND OTHER CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR OTHER CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef YASM_BC_INT_H +#define YASM_BC_INT_H + +typedef struct yasm_bytecode_callback { + void (*destroy) (/*@only@*/ void *contents); + void (*print) (const void *contents, FILE *f, int indent_level); + void (*finalize) (yasm_bytecode *bc, yasm_bytecode *prev_bc); + int (*calc_len) (yasm_bytecode *bc, yasm_bc_add_span_func add_span, + void *add_span_data); + int (*expand) (yasm_bytecode *bc, int span, long old_val, long new_val, + /*@out@*/ long *neg_thres, /*@out@*/ long *pos_thres); + int (*tobytes) (yasm_bytecode *bc, unsigned char **bufp, void *d, + yasm_output_value_func output_value, + /*@null@*/ yasm_output_reloc_func output_reloc); + enum yasm_bytecode_special_type { + YASM_BC_SPECIAL_NONE = 0, + YASM_BC_SPECIAL_RESERVE,/* Reserves space instead of outputting data */ + YASM_BC_SPECIAL_OFFSET /* Adjusts offset instead of calculating len */ + } special; +} yasm_bytecode_callback; + +struct yasm_bytecode { + /*@reldef@*/ STAILQ_ENTRY(yasm_bytecode) link; + + /*@null@*/ const yasm_bytecode_callback *callback; + + /* Pointer to section containing bytecode; NULL if not part of a section. */ + /*@dependent@*/ /*@null@*/ yasm_section *section; + + /* number of times bytecode is repeated, NULL=1. */ + /*@only@*/ /*@null@*/ yasm_expr *multiple; + + unsigned long len; /* total length of entire bytecode + (not including multiple copies) */ + long mult_int; /* number of copies: integer version */ + + /* where it came from */ + unsigned long line; + + /* other assembler state info */ + unsigned long offset; /* ~0UL if unknown */ + unsigned long bc_index; + + /* NULL-terminated array of labels that point to this bytecode (as the + * bytecode previous to the label). NULL if no labels point here. */ + /*@null@*/ yasm_symrec **symrecs; + + /* bytecode-type-specific data (type identified by callback) */ + void *contents; +}; + +/** Create a bytecode of any specified type. + * \param callback bytecode callback functions, if NULL, creates empty + * bytecode (may not be resolved or output) + * \param contents type-specific data + * \param line virtual line (from yasm_linemap) + * \return Newly allocated bytecode of the specified type. + */ +/*@only@*/ yasm_bytecode *yasm_bc_create_common + (/*@null@*/ const yasm_bytecode_callback *callback, + /*@only@*/ /*@null@*/ void *contents, unsigned long line); + +/** Transform a bytecode of any type into a different type. + * \param bc bytecode to transform + * \param callback new bytecode callback function + * \param contents new type-specific data + */ +void yasm_bc_transform(yasm_bytecode *bc, + const yasm_bytecode_callback *callback, + void *contents); + +/** Common bytecode callback finalize function, for where no finalization + * is ever required for this type of bytecode. + */ +void yasm_bc_finalize_common(yasm_bytecode *bc, yasm_bytecode *prev_bc); + +/** Common bytecode callback expand function, for where the bytecode is + * always short (calc_len never calls add_span). Causes an internal + * error if called. + */ +int yasm_bc_expand_common + (yasm_bytecode *bc, int span, long old_val, long new_val, + /*@out@*/ long *neg_thres, /*@out@*/ long *pos_thres); + +#define yasm_bc__next(x) STAILQ_NEXT(x, link) + +#endif diff --git a/libyasm/bc-org.c b/libyasm/bc-org.c index 7ef96c84..70056e50 100644 --- a/libyasm/bc-org.c +++ b/libyasm/bc-org.c @@ -24,7 +24,9 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ +#define YASM_LIB_INTERNAL #include "util.h" +/*@unused@*/ RCSID("$Id$"); #include "libyasm-stdint.h" #include "coretype.h" @@ -37,30 +39,29 @@ #include "bytecode.h" +#include "bc-int.h" + typedef struct bytecode_org { - unsigned long start; /* target starting offset within section */ - unsigned long fill; /* fill value */ + unsigned long start; /* target starting offset within section */ } bytecode_org; static void bc_org_destroy(void *contents); static void bc_org_print(const void *contents, FILE *f, int indent_level); static void bc_org_finalize(yasm_bytecode *bc, yasm_bytecode *prev_bc); static int bc_org_calc_len(yasm_bytecode *bc, yasm_bc_add_span_func add_span, - void *add_span_data); + void *add_span_data); static int bc_org_expand(yasm_bytecode *bc, int span, long old_val, - long new_val, /*@out@*/ long *neg_thres, - /*@out@*/ long *pos_thres); -static int bc_org_tobytes(yasm_bytecode *bc, unsigned char **bufp, - unsigned char *bufstart, void *d, - yasm_output_value_func output_value, - /*@null@*/ yasm_output_reloc_func output_reloc); + long new_val, /*@out@*/ long *neg_thres, + /*@out@*/ long *pos_thres); +static int bc_org_tobytes(yasm_bytecode *bc, unsigned char **bufp, void *d, + yasm_output_value_func output_value, + /*@null@*/ yasm_output_reloc_func output_reloc); static const yasm_bytecode_callback bc_org_callback = { bc_org_destroy, bc_org_print, bc_org_finalize, - NULL, bc_org_calc_len, bc_org_expand, bc_org_tobytes, @@ -89,29 +90,29 @@ bc_org_finalize(yasm_bytecode *bc, yasm_bytecode *prev_bc) static int bc_org_calc_len(yasm_bytecode *bc, yasm_bc_add_span_func add_span, - void *add_span_data) + void *add_span_data) { bytecode_org *org = (bytecode_org *)bc->contents; long neg_thres = 0; long pos_thres = org->start; if (bc_org_expand(bc, 0, 0, (long)bc->offset, &neg_thres, &pos_thres) < 0) - return -1; + return -1; return 0; } static int bc_org_expand(yasm_bytecode *bc, int span, long old_val, long new_val, - /*@out@*/ long *neg_thres, /*@out@*/ long *pos_thres) + /*@out@*/ long *neg_thres, /*@out@*/ long *pos_thres) { bytecode_org *org = (bytecode_org *)bc->contents; /* Check for overrun */ if ((unsigned long)new_val > org->start) { - yasm_error_set(YASM_ERROR_GENERAL, - N_("ORG overlap with already existing data")); - return -1; + yasm_error_set(YASM_ERROR_GENERAL, + N_("ORG overlap with already existing data")); + return -1; } /* Generate space to start offset */ @@ -120,33 +121,31 @@ bc_org_expand(yasm_bytecode *bc, int span, long old_val, long new_val, } static int -bc_org_tobytes(yasm_bytecode *bc, unsigned char **bufp, - unsigned char *bufstart, void *d, - yasm_output_value_func output_value, - /*@unused@*/ yasm_output_reloc_func output_reloc) +bc_org_tobytes(yasm_bytecode *bc, unsigned char **bufp, void *d, + yasm_output_value_func output_value, + /*@unused@*/ yasm_output_reloc_func output_reloc) { bytecode_org *org = (bytecode_org *)bc->contents; unsigned long len, i; /* Sanity check for overrun */ if (bc->offset > org->start) { - yasm_error_set(YASM_ERROR_GENERAL, - N_("ORG overlap with already existing data")); - return 1; + yasm_error_set(YASM_ERROR_GENERAL, + N_("ORG overlap with already existing data")); + return 1; } len = org->start - bc->offset; for (i=0; ifill); /* XXX: handle more than 8 bit? */ + YASM_WRITE_8(*bufp, 0); return 0; } yasm_bytecode * -yasm_bc_create_org(unsigned long start, unsigned long fill, unsigned long line) +yasm_bc_create_org(unsigned long start, unsigned long line) { bytecode_org *org = yasm_xmalloc(sizeof(bytecode_org)); org->start = start; - org->fill = fill; return yasm_bc_create_common(&bc_org_callback, org, line); } diff --git a/libyasm/bc-reserve.c b/libyasm/bc-reserve.c index 197175b4..5b680365 100644 --- a/libyasm/bc-reserve.c +++ b/libyasm/bc-reserve.c @@ -24,7 +24,9 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ +#define YASM_LIB_INTERNAL #include "util.h" +/*@unused@*/ RCSID("$Id$"); #include "libyasm-stdint.h" #include "coretype.h" @@ -36,6 +38,9 @@ #include "bytecode.h" +#include "bc-int.h" +#include "expr-int.h" + typedef struct bytecode_reserve { /*@only@*/ /*@null@*/ yasm_expr *numitems; /* number of items to reserve */ @@ -45,20 +50,17 @@ typedef struct bytecode_reserve { static void bc_reserve_destroy(void *contents); static void bc_reserve_print(const void *contents, FILE *f, int indent_level); static void bc_reserve_finalize(yasm_bytecode *bc, yasm_bytecode *prev_bc); -static int bc_reserve_elem_size(yasm_bytecode *bc); static int bc_reserve_calc_len(yasm_bytecode *bc, - yasm_bc_add_span_func add_span, - void *add_span_data); -static int bc_reserve_tobytes(yasm_bytecode *bc, unsigned char **bufp, - unsigned char *bufstart, void *d, - yasm_output_value_func output_value, - /*@null@*/ yasm_output_reloc_func output_reloc); + yasm_bc_add_span_func add_span, + void *add_span_data); +static int bc_reserve_tobytes(yasm_bytecode *bc, unsigned char **bufp, void *d, + yasm_output_value_func output_value, + /*@null@*/ yasm_output_reloc_func output_reloc); static const yasm_bytecode_callback bc_reserve_callback = { bc_reserve_destroy, bc_reserve_print, bc_reserve_finalize, - bc_reserve_elem_size, bc_reserve_calc_len, yasm_bc_expand_common, bc_reserve_tobytes, @@ -90,23 +92,16 @@ bc_reserve_finalize(yasm_bytecode *bc, yasm_bytecode *prev_bc) bytecode_reserve *reserve = (bytecode_reserve *)bc->contents; /* multiply reserve expression into multiple */ if (!bc->multiple) - bc->multiple = reserve->numitems; + bc->multiple = reserve->numitems; else - bc->multiple = yasm_expr_create_tree(bc->multiple, YASM_EXPR_MUL, - reserve->numitems, bc->line); + bc->multiple = yasm_expr_create_tree(bc->multiple, YASM_EXPR_MUL, + reserve->numitems, bc->line); reserve->numitems = NULL; } -static int -bc_reserve_elem_size(yasm_bytecode *bc) -{ - bytecode_reserve *reserve = (bytecode_reserve *)bc->contents; - return reserve->itemsize; -} - static int bc_reserve_calc_len(yasm_bytecode *bc, yasm_bc_add_span_func add_span, - void *add_span_data) + void *add_span_data) { bytecode_reserve *reserve = (bytecode_reserve *)bc->contents; bc->len += reserve->itemsize; @@ -114,10 +109,9 @@ bc_reserve_calc_len(yasm_bytecode *bc, yasm_bc_add_span_func add_span, } static int -bc_reserve_tobytes(yasm_bytecode *bc, unsigned char **bufp, - unsigned char *bufstart, void *d, - yasm_output_value_func output_value, - /*@unused@*/ yasm_output_reloc_func output_reloc) +bc_reserve_tobytes(yasm_bytecode *bc, unsigned char **bufp, void *d, + yasm_output_value_func output_value, + /*@unused@*/ yasm_output_reloc_func output_reloc) { yasm_internal_error(N_("bc_reserve_tobytes called")); /*@notreached@*/ @@ -126,7 +120,7 @@ bc_reserve_tobytes(yasm_bytecode *bc, unsigned char **bufp, yasm_bytecode * yasm_bc_create_reserve(yasm_expr *numitems, unsigned int itemsize, - unsigned long line) + unsigned long line) { bytecode_reserve *reserve = yasm_xmalloc(sizeof(bytecode_reserve)); diff --git a/libyasm/bitvect.c b/libyasm/bitvect.c index b6570ea3..c39f9b65 100644 --- a/libyasm/bitvect.c +++ b/libyasm/bitvect.c @@ -1,4 +1,6 @@ +#define YASM_LIB_INTERNAL #include "util.h" +RCSID("$Id$"); #include "coretype.h" @@ -8,8 +10,10 @@ /* MODULE IMPORTS: */ /*****************************************************************************/ #include /* MODULE TYPE: (sys) */ +#ifdef STDC_HEADERS #include /* MODULE TYPE: (sys) */ #include /* MODULE TYPE: (sys) */ +#endif /*****************************************************************************/ /* MODULE INTERFACE: */ /*****************************************************************************/ @@ -457,7 +461,7 @@ void BitVector_Destroy_List(listptr list, N_int count) /* free list */ { BitVector_Destroy(*slot++); } - yasm_xfree((voidptr) list); + free((voidptr) list); } } @@ -496,7 +500,7 @@ listptr BitVector_Create_List(N_int bits, boolean clear, N_int count) if (count > 0) { - list = (listptr) yasm_xmalloc(sizeof(wordptr) * count); + list = (listptr) malloc(sizeof(wordptr) * count); if (list != NULL) { slot = list; @@ -1510,9 +1514,7 @@ ErrCode BitVector_from_Hex(wordptr addr, charptr string) digit = (int) *(--string); length--; /* separate because toupper() is likely a macro! */ digit = toupper(digit); - if (digit == '_') - count -= 4; - else if ((ok = (isxdigit(digit) != 0))) + if ((ok = (isxdigit(digit) != 0))) { if (digit >= (int) 'A') digit -= (int) 'A' - 10; else digit -= (int) '0'; @@ -1549,9 +1551,7 @@ ErrCode BitVector_from_Oct(wordptr addr, charptr string) for ( count = count_fill; (ok and (length > 0) and (count < BITS)); count += 3 ) { digit = (int) *(--string); length--; - if (digit == '_') - count -= 3; - else if ((ok = (isdigit(digit) && digit != '8' && digit != '9')) != 0) + if ((ok = (isdigit(digit) && digit != '8' && digit != '9')) != 0) { digit -= (int) '0'; value |= (((N_word) digit) << count); @@ -1631,9 +1631,6 @@ ErrCode BitVector_from_Bin(wordptr addr, charptr string) case (int) '1': value |= BITMASKTAB[count]; break; - case (int) '_': - count--; - break; default: ok = FALSE; break; @@ -1783,11 +1780,11 @@ BitVector_from_Dec_static_data *BitVector_from_Dec_static_Boot(N_word bits) data->rank = BitVector_Create(bits,FALSE); data->temp = BitVector_Create(bits,FALSE); } else { - data->term = NULL; - data->base = NULL; - data->prod = NULL; - data->rank = NULL; - data->temp = NULL; + data->term = NULL; + data->base = NULL; + data->prod = NULL; + data->rank = NULL; + data->temp = NULL; } return data; } @@ -1805,7 +1802,7 @@ void BitVector_from_Dec_static_Shutdown(BitVector_from_Dec_static_data *data) } ErrCode BitVector_from_Dec_static(BitVector_from_Dec_static_data *data, - wordptr addr, charptr string) + wordptr addr, charptr string) { ErrCode error = ErrCode_Ok; N_word bits = bits_(addr); @@ -1827,11 +1824,11 @@ ErrCode BitVector_from_Dec_static(BitVector_from_Dec_static_data *data, if (bits > 0) { - term = data->term; - base = data->base; - prod = data->prod; - rank = data->rank; - temp = data->temp; + term = data->term; + base = data->base; + prod = data->prod; + rank = data->rank; + temp = data->temp; length = strlen((char *) string); if (length == 0) return(ErrCode_Pars); @@ -1843,10 +1840,10 @@ ErrCode BitVector_from_Dec_static(BitVector_from_Dec_static_data *data, if (--length == 0) return(ErrCode_Pars); } string += length; - if (init) - { - BitVector_Empty(prod); - BitVector_Empty(rank); + if (init) + { + BitVector_Empty(prod); + BitVector_Empty(rank); } BitVector_Empty(addr); *base = EXP10; @@ -3876,9 +3873,9 @@ void Matrix_Transpose(wordptr X, N_int rowsX, N_int colsX, /* ARTISTIC LICENSE: */ /*****************************************************************************/ /* - The "Artistic License" + The "Artistic License" - Preamble + Preamble The intent of this document is to state the conditions under which a Package may be copied, such that the Copyright Holder maintains some @@ -3889,30 +3886,30 @@ reasonable modifications. Definitions: - "Package" refers to the collection of files distributed by the - Copyright Holder, and derivatives of that collection of files - created through textual modification. + "Package" refers to the collection of files distributed by the + Copyright Holder, and derivatives of that collection of files + created through textual modification. - "Standard Version" refers to such a Package if it has not been - modified, or has been modified in accordance with the wishes - of the Copyright Holder as specified below. + "Standard Version" refers to such a Package if it has not been + modified, or has been modified in accordance with the wishes + of the Copyright Holder as specified below. - "Copyright Holder" is whoever is named in the copyright or - copyrights for the package. + "Copyright Holder" is whoever is named in the copyright or + copyrights for the package. - "You" is you, if you're thinking about copying or distributing - this Package. + "You" is you, if you're thinking about copying or distributing + this Package. - "Reasonable copying fee" is whatever you can justify on the - basis of media cost, duplication charges, time of people involved, - and so on. (You will not be required to justify it to the - Copyright Holder, but only to the computing community at large - as a market that must bear the fee.) + "Reasonable copying fee" is whatever you can justify on the + basis of media cost, duplication charges, time of people involved, + and so on. (You will not be required to justify it to the + Copyright Holder, but only to the computing community at large + as a market that must bear the fee.) - "Freely Available" means that no fee is charged for the item - itself, though there may be fees involved in handling the item. - It also means that recipients of the item may redistribute it - under the same conditions they received it. + "Freely Available" means that no fee is charged for the item + itself, though there may be fees involved in handling the item. + It also means that recipients of the item may redistribute it + under the same conditions they received it. 1. You may make and give away verbatim copies of the source form of the Standard Version of this Package without restriction, provided that you @@ -4002,7 +3999,7 @@ products derived from this software without specific prior written permission. IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. - The End + The End */ /*****************************************************************************/ /* GNU GENERAL PUBLIC LICENSE: */ diff --git a/libyasm/bitvect.h b/libyasm/bitvect.h index a13470ad..4bdcf3ba 100644 --- a/libyasm/bitvect.h +++ b/libyasm/bitvect.h @@ -1,3 +1,5 @@ +/* $Id$ */ + #ifndef YASM_BITVECT_H #define YASM_BITVECT_H /*****************************************************************************/ @@ -13,9 +15,6 @@ /* and your own application(s) which might - directly or indirectly - */ /* include this definitions file. */ /*****************************************************************************/ -#ifndef YASM_LIB_DECL -#define YASM_LIB_DECL -#endif typedef unsigned char N_char; typedef unsigned char N_byte; @@ -83,11 +82,7 @@ typedef Z_longword *Z_longwordptr; #ifdef MACOS_TRADITIONAL #define boolean Boolean #else - #if __STDC_VERSION__ < 202311L - typedef enum boolean { false = FALSE, true = TRUE } boolean; - #else - typedef bool boolean; - #endif + typedef enum boolean { false = FALSE, true = TRUE } boolean; #endif #endif @@ -122,318 +117,213 @@ typedef wordptr *listptr; /* ===> MISCELLANEOUS BASIC FUNCTIONS: <=== */ -YASM_LIB_DECL const char * BitVector_Error (ErrCode error); /* return string for err code */ -YASM_LIB_DECL ErrCode BitVector_Boot (void); /* 0 = ok, 1..7 = error */ -YASM_LIB_DECL void BitVector_Shutdown (void); /* undo Boot */ -YASM_LIB_DECL N_word BitVector_Size (N_int bits); /* bit vector size (# of words) */ -YASM_LIB_DECL N_word BitVector_Mask (N_int bits); /* bit vector mask (unused bits) */ /* ===> CLASS METHODS: <=== */ -YASM_LIB_DECL const char * BitVector_Version (void); /* returns version string */ -YASM_LIB_DECL N_int BitVector_Word_Bits (void); /* return # of bits in machine word */ -YASM_LIB_DECL N_int BitVector_Long_Bits (void); /* return # of bits in unsigned long */ /* ===> CONSTRUCTOR METHODS: <=== */ -YASM_LIB_DECL /*@only@*/ wordptr BitVector_Create (N_int bits, boolean clear); /* malloc */ -YASM_LIB_DECL listptr BitVector_Create_List(N_int bits, boolean clear, N_int count); -YASM_LIB_DECL wordptr BitVector_Resize (wordptr oldaddr, N_int bits); /* realloc */ -YASM_LIB_DECL wordptr BitVector_Shadow (wordptr addr); /* make new same size but empty */ -YASM_LIB_DECL wordptr BitVector_Clone (wordptr addr); /* make exact duplicate */ -YASM_LIB_DECL wordptr BitVector_Concat (wordptr X, wordptr Y); /* return concatenation */ /* ===> DESTRUCTOR METHODS: <=== */ -YASM_LIB_DECL void BitVector_Dispose (/*@only@*/ /*@out@*/ charptr string); /* string */ -YASM_LIB_DECL void BitVector_Destroy (/*@only@*/ wordptr addr); /* bitvec */ -YASM_LIB_DECL void BitVector_Destroy_List (listptr list, N_int count); /* list */ /* ===> OBJECT METHODS: <=== */ /* ===> bit vector copy function: */ -YASM_LIB_DECL void BitVector_Copy (wordptr X, wordptr Y); /* X = Y */ /* ===> bit vector initialization: */ -YASM_LIB_DECL void BitVector_Empty (wordptr addr); /* X = {} */ -YASM_LIB_DECL void BitVector_Fill (wordptr addr); /* X = ~{} */ -YASM_LIB_DECL void BitVector_Flip (wordptr addr); /* X = ~X */ -YASM_LIB_DECL void BitVector_Primes (wordptr addr); /* ===> miscellaneous functions: */ -YASM_LIB_DECL void BitVector_Reverse (wordptr X, wordptr Y); /* ===> bit vector interval operations and functions: */ -YASM_LIB_DECL void BitVector_Interval_Empty (/*@out@*/ wordptr addr, N_int lower, N_int upper); -YASM_LIB_DECL void BitVector_Interval_Fill (/*@out@*/ wordptr addr, N_int lower, N_int upper); -YASM_LIB_DECL void BitVector_Interval_Flip (/*@out@*/ wordptr addr, N_int lower, N_int upper); -YASM_LIB_DECL void BitVector_Interval_Reverse (/*@out@*/ wordptr addr, N_int lower, N_int upper); -YASM_LIB_DECL boolean BitVector_interval_scan_inc (wordptr addr, N_int start, N_intptr min, N_intptr max); -YASM_LIB_DECL boolean BitVector_interval_scan_dec (wordptr addr, N_int start, N_intptr min, N_intptr max); -YASM_LIB_DECL void BitVector_Interval_Copy (/*@out@*/ wordptr X, wordptr Y, N_int Xoffset, N_int Yoffset, N_int length); -YASM_LIB_DECL wordptr BitVector_Interval_Substitute(/*@out@*/ wordptr X, wordptr Y, N_int Xoffset, N_int Xlength, N_int Yoffset, N_int Ylength); /* ===> bit vector test functions: */ -YASM_LIB_DECL boolean BitVector_is_empty (wordptr addr); /* X == {} ? */ -YASM_LIB_DECL boolean BitVector_is_full (wordptr addr); /* X == ~{} ? */ -YASM_LIB_DECL boolean BitVector_equal (wordptr X, wordptr Y); /* X == Y ? */ -YASM_LIB_DECL Z_int BitVector_Lexicompare(wordptr X, wordptr Y); /* X <,=,> Y ? */ -YASM_LIB_DECL Z_int BitVector_Compare (wordptr X, wordptr Y); /* X <,=,> Y ? */ /* ===> bit vector string conversion functions: */ -YASM_LIB_DECL /*@only@*/ charptr BitVector_to_Hex (wordptr addr); -YASM_LIB_DECL ErrCode BitVector_from_Hex (/*@out@*/wordptr addr, charptr string); -YASM_LIB_DECL ErrCode BitVector_from_Oct(/*@out@*/ wordptr addr, charptr string); -YASM_LIB_DECL /*@only@*/ charptr BitVector_to_Bin (wordptr addr); -YASM_LIB_DECL ErrCode BitVector_from_Bin (/*@out@*/ wordptr addr, charptr string); -YASM_LIB_DECL /*@only@*/ charptr BitVector_to_Dec (wordptr addr); -YASM_LIB_DECL ErrCode BitVector_from_Dec (/*@out@*/ wordptr addr, charptr string); typedef struct BitVector_from_Dec_static_data BitVector_from_Dec_static_data; -YASM_LIB_DECL BitVector_from_Dec_static_data *BitVector_from_Dec_static_Boot(N_word bits); -YASM_LIB_DECL void BitVector_from_Dec_static_Shutdown(/*@null@*/ BitVector_from_Dec_static_data *data); -YASM_LIB_DECL ErrCode BitVector_from_Dec_static(BitVector_from_Dec_static_data *data, - /*@out@*/ wordptr addr, charptr string); + /*@out@*/ wordptr addr, charptr string); -YASM_LIB_DECL /*@only@*/ charptr BitVector_to_Enum (wordptr addr); -YASM_LIB_DECL ErrCode BitVector_from_Enum (/*@out@*/ wordptr addr, charptr string); /* ===> bit vector bit operations, functions & tests: */ -YASM_LIB_DECL void BitVector_Bit_Off (/*@out@*/ wordptr addr, N_int indx); /* X = X \ {x} */ -YASM_LIB_DECL void BitVector_Bit_On (/*@out@*/ wordptr addr, N_int indx); /* X = X + {x} */ -YASM_LIB_DECL boolean BitVector_bit_flip (/*@out@*/ wordptr addr, N_int indx); /* (X+{x})\(X*{x}) */ -YASM_LIB_DECL boolean BitVector_bit_test (wordptr addr, N_int indx); /* {x} in X ? */ -YASM_LIB_DECL void BitVector_Bit_Copy (/*@out@*/ wordptr addr, N_int indx, boolean bit); /* ===> bit vector bit shift & rotate functions: */ -YASM_LIB_DECL void BitVector_LSB (/*@out@*/ wordptr addr, boolean bit); -YASM_LIB_DECL void BitVector_MSB (/*@out@*/ wordptr addr, boolean bit); -YASM_LIB_DECL boolean BitVector_lsb_ (wordptr addr); -YASM_LIB_DECL boolean BitVector_msb_ (wordptr addr); -YASM_LIB_DECL boolean /*@alt void@*/ BitVector_rotate_left (wordptr addr); -YASM_LIB_DECL boolean /*@alt void@*/ BitVector_rotate_right (wordptr addr); -YASM_LIB_DECL boolean /*@alt void@*/ BitVector_shift_left (wordptr addr, boolean carry_in); -YASM_LIB_DECL boolean /*@alt void@*/ BitVector_shift_right (wordptr addr, boolean carry_in); -YASM_LIB_DECL void BitVector_Move_Left (wordptr addr, N_int bits); -YASM_LIB_DECL void BitVector_Move_Right (wordptr addr, N_int bits); /* ===> bit vector insert/delete bits: */ -YASM_LIB_DECL void BitVector_Insert (wordptr addr, N_int offset, N_int count, boolean clear); -YASM_LIB_DECL void BitVector_Delete (wordptr addr, N_int offset, N_int count, boolean clear); /* ===> bit vector arithmetic: */ -YASM_LIB_DECL boolean /*@alt void@*/ BitVector_increment (wordptr addr); /* X++ */ -YASM_LIB_DECL boolean /*@alt void@*/ BitVector_decrement (wordptr addr); /* X-- */ -YASM_LIB_DECL boolean /*@alt void@*/ BitVector_compute (wordptr X, wordptr Y, wordptr Z, boolean minus, boolean *carry); -YASM_LIB_DECL boolean /*@alt void@*/ BitVector_add (wordptr X, wordptr Y, wordptr Z, boolean *carry); -YASM_LIB_DECL boolean /*@alt void@*/ BitVector_sub (wordptr X, wordptr Y, wordptr Z, boolean *carry); -YASM_LIB_DECL boolean /*@alt void@*/ BitVector_inc (wordptr X, wordptr Y); -YASM_LIB_DECL boolean /*@alt void@*/ BitVector_dec (wordptr X, wordptr Y); -YASM_LIB_DECL void BitVector_Negate (wordptr X, wordptr Y); -YASM_LIB_DECL void BitVector_Absolute (wordptr X, wordptr Y); -YASM_LIB_DECL Z_int BitVector_Sign (wordptr addr); -YASM_LIB_DECL ErrCode BitVector_Mul_Pos (wordptr X, wordptr Y, wordptr Z, boolean strict); -YASM_LIB_DECL ErrCode BitVector_Multiply (wordptr X, wordptr Y, wordptr Z); -YASM_LIB_DECL ErrCode BitVector_Div_Pos (wordptr Q, wordptr X, wordptr Y, wordptr R); -YASM_LIB_DECL ErrCode BitVector_Divide (wordptr Q, wordptr X, wordptr Y, wordptr R); -YASM_LIB_DECL ErrCode BitVector_GCD (wordptr X, wordptr Y, wordptr Z); -YASM_LIB_DECL ErrCode BitVector_GCD2 (wordptr U, wordptr V, wordptr W, /* O */ wordptr X, wordptr Y); /* I */ -YASM_LIB_DECL ErrCode BitVector_Power (wordptr X, wordptr Y, wordptr Z); /* ===> direct memory access functions: */ -YASM_LIB_DECL void BitVector_Block_Store(wordptr addr, charptr buffer, N_int length); -YASM_LIB_DECL charptr BitVector_Block_Read (wordptr addr, /*@out@*/ N_intptr length); /* ===> word array functions: */ -YASM_LIB_DECL void BitVector_Word_Store (wordptr addr, N_int offset, N_int value); -YASM_LIB_DECL N_int BitVector_Word_Read (wordptr addr, N_int offset); -YASM_LIB_DECL void BitVector_Word_Insert(wordptr addr, N_int offset, N_int count, boolean clear); -YASM_LIB_DECL void BitVector_Word_Delete(wordptr addr, N_int offset, N_int count, boolean clear); /* ===> arbitrary size chunk functions: */ -YASM_LIB_DECL void BitVector_Chunk_Store(wordptr addr, N_int chunksize, N_int offset, N_long value); -YASM_LIB_DECL N_long BitVector_Chunk_Read (wordptr addr, N_int chunksize, N_int offset); /* ===> set operations: */ -YASM_LIB_DECL void Set_Union (wordptr X, wordptr Y, wordptr Z); /* X = Y + Z */ -YASM_LIB_DECL void Set_Intersection (wordptr X, wordptr Y, wordptr Z); /* X = Y * Z */ -YASM_LIB_DECL void Set_Difference (wordptr X, wordptr Y, wordptr Z); /* X = Y \ Z */ -YASM_LIB_DECL void Set_ExclusiveOr (wordptr X, wordptr Y, wordptr Z); /*(Y+Z)\(Y*Z)*/ -YASM_LIB_DECL void Set_Complement (wordptr X, wordptr Y); /* X = ~Y */ /* ===> set functions: */ -YASM_LIB_DECL boolean Set_subset (wordptr X, wordptr Y); /* X in Y ? */ -YASM_LIB_DECL N_int Set_Norm (wordptr addr); /* = | X | */ -YASM_LIB_DECL N_int Set_Norm2 (wordptr addr); /* = | X | */ -YASM_LIB_DECL N_int Set_Norm3 (wordptr addr); /* = | X | */ -YASM_LIB_DECL Z_long Set_Min (wordptr addr); /* = min(X) */ -YASM_LIB_DECL Z_long Set_Max (wordptr addr); /* = max(X) */ /* ===> matrix-of-booleans operations: */ -YASM_LIB_DECL void Matrix_Multiplication(wordptr X, N_int rowsX, N_int colsX, wordptr Y, N_int rowsY, N_int colsY, wordptr Z, N_int rowsZ, N_int colsZ); -YASM_LIB_DECL void Matrix_Product (wordptr X, N_int rowsX, N_int colsX, wordptr Y, N_int rowsY, N_int colsY, wordptr Z, N_int rowsZ, N_int colsZ); -YASM_LIB_DECL void Matrix_Closure (wordptr addr, N_int rows, N_int cols); -YASM_LIB_DECL void Matrix_Transpose (wordptr X, N_int rowsX, N_int colsX, wordptr Y, N_int rowsY, N_int colsY); @@ -499,9 +389,9 @@ void Matrix_Transpose (wordptr X, N_int rowsX, N_int colsX, /* ARTISTIC LICENSE: */ /*****************************************************************************/ /* - The "Artistic License" + The "Artistic License" - Preamble + Preamble The intent of this document is to state the conditions under which a Package may be copied, such that the Copyright Holder maintains some @@ -512,30 +402,30 @@ reasonable modifications. Definitions: - "Package" refers to the collection of files distributed by the - Copyright Holder, and derivatives of that collection of files - created through textual modification. + "Package" refers to the collection of files distributed by the + Copyright Holder, and derivatives of that collection of files + created through textual modification. - "Standard Version" refers to such a Package if it has not been - modified, or has been modified in accordance with the wishes - of the Copyright Holder as specified below. + "Standard Version" refers to such a Package if it has not been + modified, or has been modified in accordance with the wishes + of the Copyright Holder as specified below. - "Copyright Holder" is whoever is named in the copyright or - copyrights for the package. + "Copyright Holder" is whoever is named in the copyright or + copyrights for the package. - "You" is you, if you're thinking about copying or distributing - this Package. + "You" is you, if you're thinking about copying or distributing + this Package. - "Reasonable copying fee" is whatever you can justify on the - basis of media cost, duplication charges, time of people involved, - and so on. (You will not be required to justify it to the - Copyright Holder, but only to the computing community at large - as a market that must bear the fee.) + "Reasonable copying fee" is whatever you can justify on the + basis of media cost, duplication charges, time of people involved, + and so on. (You will not be required to justify it to the + Copyright Holder, but only to the computing community at large + as a market that must bear the fee.) - "Freely Available" means that no fee is charged for the item - itself, though there may be fees involved in handling the item. - It also means that recipients of the item may redistribute it - under the same conditions they received it. + "Freely Available" means that no fee is charged for the item + itself, though there may be fees involved in handling the item. + It also means that recipients of the item may redistribute it + under the same conditions they received it. 1. You may make and give away verbatim copies of the source form of the Standard Version of this Package without restriction, provided that you @@ -625,7 +515,7 @@ products derived from this software without specific prior written permission. IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. - The End + The End */ /*****************************************************************************/ /* GNU GENERAL PUBLIC LICENSE: */ diff --git a/libyasm/bytecode.c b/libyasm/bytecode.c index f864bae0..6881e6c6 100644 --- a/libyasm/bytecode.c +++ b/libyasm/bytecode.c @@ -24,7 +24,9 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ +#define YASM_LIB_INTERNAL #include "util.h" +/*@unused@*/ RCSID("$Id$"); #include "libyasm-stdint.h" #include "coretype.h" @@ -37,15 +39,18 @@ #include "bytecode.h" +#include "bc-int.h" +#include "expr-int.h" + void yasm_bc_set_multiple(yasm_bytecode *bc, yasm_expr *e) { if (bc->multiple) - bc->multiple = yasm_expr_create_tree(bc->multiple, YASM_EXPR_MUL, e, - e->line); + bc->multiple = yasm_expr_create_tree(bc->multiple, YASM_EXPR_MUL, e, + e->line); else - bc->multiple = e; + bc->multiple = e; } void @@ -53,48 +58,28 @@ yasm_bc_finalize_common(yasm_bytecode *bc, yasm_bytecode *prev_bc) { } -int -yasm_bc_calc_len_common(yasm_bytecode *bc, yasm_bc_add_span_func add_span, - void *add_span_data) -{ - yasm_internal_error(N_("bytecode length cannot be calculated")); - /*@unreached@*/ - return 0; -} - int yasm_bc_expand_common(yasm_bytecode *bc, int span, long old_val, long new_val, - /*@out@*/ long *neg_thres, /*@out@*/ long *pos_thres) + /*@out@*/ long *neg_thres, /*@out@*/ long *pos_thres) { yasm_internal_error(N_("bytecode does not have any dependent spans")); /*@unreached@*/ return 0; } -int -yasm_bc_tobytes_common(yasm_bytecode *bc, unsigned char **buf, - unsigned char *bufstart, void *d, - yasm_output_value_func output_value, - /*@null@*/ yasm_output_reloc_func output_reloc) -{ - yasm_internal_error(N_("bytecode cannot be converted to bytes")); - /*@unreached@*/ - return 0; -} - void yasm_bc_transform(yasm_bytecode *bc, const yasm_bytecode_callback *callback, - void *contents) + void *contents) { if (bc->callback) - bc->callback->destroy(bc->contents); + bc->callback->destroy(bc->contents); bc->callback = callback; bc->contents = contents; } yasm_bytecode * yasm_bc_create_common(const yasm_bytecode_callback *callback, void *contents, - unsigned long line) + unsigned long line) { yasm_bytecode *bc = yasm_xmalloc(sizeof(yasm_bytecode)); @@ -104,7 +89,7 @@ yasm_bc_create_common(const yasm_bytecode_callback *callback, void *contents, bc->len = 0; bc->mult_int = 1; bc->line = line; - bc->offset = ~0UL; /* obviously incorrect / uninitialized value */ + bc->offset = ~0UL; /* obviously incorrect / uninitialized value */ bc->symrecs = NULL; bc->contents = contents; @@ -121,20 +106,20 @@ void yasm_bc__add_symrec(yasm_bytecode *bc, yasm_symrec *sym) { if (!bc->symrecs) { - bc->symrecs = yasm_xmalloc(2*sizeof(yasm_symrec *)); - bc->symrecs[0] = sym; - bc->symrecs[1] = NULL; + bc->symrecs = yasm_xmalloc(2*sizeof(yasm_symrec *)); + bc->symrecs[0] = sym; + bc->symrecs[1] = NULL; } else { - /* Very inefficient implementation for large numbers of symbols. But - * that would be very unusual, so use the simple algorithm instead. - */ - size_t count = 1; - while (bc->symrecs[count]) - count++; - bc->symrecs = yasm_xrealloc(bc->symrecs, - (count+2)*sizeof(yasm_symrec *)); - bc->symrecs[count] = sym; - bc->symrecs[count+1] = NULL; + /* Very inefficient implementation for large numbers of symbols. But + * that would be very unusual, so use the simple algorithm instead. + */ + size_t count = 1; + while (bc->symrecs[count]) + count++; + bc->symrecs = yasm_xrealloc(bc->symrecs, + (count+2)*sizeof(yasm_symrec *)); + bc->symrecs[count] = sym; + bc->symrecs[count+1] = NULL; } } @@ -142,13 +127,13 @@ void yasm_bc_destroy(yasm_bytecode *bc) { if (!bc) - return; + return; if (bc->callback) - bc->callback->destroy(bc->contents); + bc->callback->destroy(bc->contents); yasm_expr_destroy(bc->multiple); if (bc->symrecs) - yasm_xfree(bc->symrecs); + yasm_xfree(bc->symrecs); yasm_xfree(bc); } @@ -156,14 +141,14 @@ void yasm_bc_print(const yasm_bytecode *bc, FILE *f, int indent_level) { if (!bc->callback) - fprintf(f, "%*s_Empty_\n", indent_level, ""); + fprintf(f, "%*s_Empty_\n", indent_level, ""); else - bc->callback->print(bc->contents, f, indent_level); + bc->callback->print(bc->contents, f, indent_level); fprintf(f, "%*sMultiple=", indent_level, ""); if (!bc->multiple) - fprintf(f, "nil (1)"); + fprintf(f, "nil (1)"); else - yasm_expr_print(bc->multiple, f); + yasm_expr_print(bc->multiple, f); fprintf(f, "\n%*sLength=%lu\n", indent_level, "", bc->len); fprintf(f, "%*sLine Index=%lu\n", indent_level, "", bc->line); fprintf(f, "%*sOffset=%lx\n", indent_level, "", bc->offset); @@ -173,26 +158,26 @@ void yasm_bc_finalize(yasm_bytecode *bc, yasm_bytecode *prev_bc) { if (bc->callback) - bc->callback->finalize(bc, prev_bc); + bc->callback->finalize(bc, prev_bc); if (bc->multiple) { - yasm_value val; + yasm_value val; - if (yasm_value_finalize_expr(&val, bc->multiple, prev_bc, 0)) - yasm_error_set(YASM_ERROR_TOO_COMPLEX, - N_("multiple expression too complex")); - else if (val.rel) - yasm_error_set(YASM_ERROR_NOT_ABSOLUTE, - N_("multiple expression not absolute")); - /* Finalize creates NULL output if value=0, but bc->multiple is NULL - * if value=1 (this difference is to make the common case small). - * However, this means we need to set bc->multiple explicitly to 0 - * here if val.abs is NULL. - */ - if (val.abs) - bc->multiple = val.abs; - else - bc->multiple = yasm_expr_create_ident( - yasm_expr_int(yasm_intnum_create_uint(0)), bc->line); + if (yasm_value_finalize_expr(&val, bc->multiple, prev_bc, 0)) + yasm_error_set(YASM_ERROR_TOO_COMPLEX, + N_("multiple expression too complex")); + else if (val.rel) + yasm_error_set(YASM_ERROR_NOT_ABSOLUTE, + N_("multiple expression not absolute")); + /* Finalize creates NULL output if value=0, but bc->multiple is NULL + * if value=1 (this difference is to make the common case small). + * However, this means we need to set bc->multiple explicitly to 0 + * here if val.abs is NULL. + */ + if (val.abs) + bc->multiple = val.abs; + else + bc->multiple = yasm_expr_create_ident( + yasm_expr_int(yasm_intnum_create_uint(0)), bc->line); } } @@ -203,14 +188,14 @@ yasm_calc_bc_dist(yasm_bytecode *precbc1, yasm_bytecode *precbc2) yasm_intnum *intn; if (precbc1->section != precbc2->section) - return NULL; + return NULL; dist1 = yasm_bc_next_offset(precbc1); dist2 = yasm_bc_next_offset(precbc2); if (dist2 < dist1) { - intn = yasm_intnum_create_uint(dist1 - dist2); - yasm_intnum_calc(intn, YASM_EXPR_NEG, NULL); - return intn; + intn = yasm_intnum_create_uint(dist1 - dist2); + yasm_intnum_calc(intn, YASM_EXPR_NEG, NULL); + return intn; } dist2 -= dist1; return yasm_intnum_create_uint(dist2); @@ -222,128 +207,112 @@ yasm_bc_next_offset(yasm_bytecode *precbc) return precbc->offset + precbc->len*precbc->mult_int; } -int -yasm_bc_elem_size(yasm_bytecode *bc) -{ - if (!bc->callback) { - yasm_internal_error(N_("got empty bytecode in yasm_bc_elem_size")); - return 0; - } else if (!bc->callback->elem_size) - return 0; - else - return bc->callback->elem_size(bc); -} - int yasm_bc_calc_len(yasm_bytecode *bc, yasm_bc_add_span_func add_span, - void *add_span_data) + void *add_span_data) { int retval = 0; bc->len = 0; if (!bc->callback) - yasm_internal_error(N_("got empty bytecode in yasm_bc_calc_len")); + yasm_internal_error(N_("got empty bytecode in yasm_bc_calc_len")); else - retval = bc->callback->calc_len(bc, add_span, add_span_data); + retval = bc->callback->calc_len(bc, add_span, add_span_data); /* Check for multiples */ bc->mult_int = 1; if (bc->multiple) { - /*@dependent@*/ /*@null@*/ const yasm_intnum *num; + /*@dependent@*/ /*@null@*/ const yasm_intnum *num; - num = yasm_expr_get_intnum(&bc->multiple, 0); - if (num) { - if (yasm_intnum_sign(num) < 0) { - yasm_error_set(YASM_ERROR_VALUE, N_("multiple is negative")); - retval = -1; - } else - bc->mult_int = yasm_intnum_get_int(num); - } else { - if (yasm_expr__contains(bc->multiple, YASM_EXPR_FLOAT)) { - yasm_error_set(YASM_ERROR_VALUE, - N_("expression must not contain floating point value")); - retval = -1; - } else { - yasm_value value; - yasm_value_initialize(&value, bc->multiple, 0); - add_span(add_span_data, bc, 0, &value, 0, 0); - bc->mult_int = 0; /* assume 0 to start */ - } - } + num = yasm_expr_get_intnum(&bc->multiple, 0); + if (num) { + if (yasm_intnum_sign(num) < 0) { + yasm_error_set(YASM_ERROR_VALUE, N_("multiple is negative")); + retval = -1; + } else + bc->mult_int = yasm_intnum_get_int(num); + } else { + if (yasm_expr__contains(bc->multiple, YASM_EXPR_FLOAT)) { + yasm_error_set(YASM_ERROR_VALUE, + N_("expression must not contain floating point value")); + retval = -1; + } else { + yasm_value value; + yasm_value_initialize(&value, bc->multiple, 0); + add_span(add_span_data, bc, 0, &value, 0, 0); + bc->mult_int = 0; /* assume 0 to start */ + } + } } /* If we got an error somewhere along the line, clear out any calc len */ if (retval < 0) - bc->len = 0; + bc->len = 0; return retval; } int yasm_bc_expand(yasm_bytecode *bc, int span, long old_val, long new_val, - /*@out@*/ long *neg_thres, /*@out@*/ long *pos_thres) + /*@out@*/ long *neg_thres, /*@out@*/ long *pos_thres) { if (span == 0) { - bc->mult_int = new_val; - return 1; + bc->mult_int = new_val; + return 1; } if (!bc->callback) { - yasm_internal_error(N_("got empty bytecode in yasm_bc_expand")); - /*@unreached@*/ - return -1; + yasm_internal_error(N_("got empty bytecode in yasm_bc_expand")); + /*@unreached@*/ + return -1; } else - return bc->callback->expand(bc, span, old_val, new_val, neg_thres, - pos_thres); + return bc->callback->expand(bc, span, old_val, new_val, neg_thres, + pos_thres); } /*@null@*/ /*@only@*/ unsigned char * yasm_bc_tobytes(yasm_bytecode *bc, unsigned char *buf, unsigned long *bufsize, - /*@out@*/ int *gap, void *d, - yasm_output_value_func output_value, - /*@null@*/ yasm_output_reloc_func output_reloc) + /*@out@*/ int *gap, void *d, + yasm_output_value_func output_value, + /*@null@*/ yasm_output_reloc_func output_reloc) /*@sets *buf@*/ { /*@only@*/ /*@null@*/ unsigned char *mybuf = NULL; - unsigned char *bufstart; unsigned char *origbuf, *destbuf; long i; int error = 0; - long mult; - if (yasm_bc_get_multiple(bc, &mult, 1) || mult == 0) { - *bufsize = 0; - return NULL; + if (yasm_bc_get_multiple(bc, &bc->mult_int, 1) || bc->mult_int == 0) { + *bufsize = 0; + return NULL; } - bc->mult_int = mult; /* special case for reserve bytecodes */ if (bc->callback->special == YASM_BC_SPECIAL_RESERVE) { - *bufsize = bc->len*bc->mult_int; - *gap = 1; - return NULL; /* we didn't allocate a buffer */ + *bufsize = bc->len*bc->mult_int; + *gap = 1; + return NULL; /* we didn't allocate a buffer */ } *gap = 0; if (*bufsize < bc->len*bc->mult_int) { - mybuf = yasm_xmalloc(bc->len*bc->mult_int); - destbuf = mybuf; + mybuf = yasm_xmalloc(bc->len*bc->mult_int); + destbuf = mybuf; } else - destbuf = buf; - bufstart = destbuf; + destbuf = buf; *bufsize = bc->len*bc->mult_int; if (!bc->callback) - yasm_internal_error(N_("got empty bytecode in bc_tobytes")); + yasm_internal_error(N_("got empty bytecode in bc_tobytes")); else for (i=0; imult_int; i++) { - origbuf = destbuf; - error = bc->callback->tobytes(bc, &destbuf, bufstart, d, output_value, - output_reloc); + origbuf = destbuf; + error = bc->callback->tobytes(bc, &destbuf, d, output_value, + output_reloc); - if (!error && ((unsigned long)(destbuf - origbuf) != bc->len)) - yasm_internal_error( - N_("written length does not match optimized length")); + if (!error && ((unsigned long)(destbuf - origbuf) != bc->len)) + yasm_internal_error( + N_("written length does not match optimized length")); } return mybuf; @@ -356,17 +325,17 @@ yasm_bc_get_multiple(yasm_bytecode *bc, long *multiple, int calc_bc_dist) *multiple = 1; if (bc->multiple) { - num = yasm_expr_get_intnum(&bc->multiple, calc_bc_dist); - if (!num) { - yasm_error_set(YASM_ERROR_VALUE, - N_("could not determine multiple")); - return 1; - } - if (yasm_intnum_sign(num) < 0) { - yasm_error_set(YASM_ERROR_VALUE, N_("multiple is negative")); - return 1; - } - *multiple = yasm_intnum_get_int(num); + num = yasm_expr_get_intnum(&bc->multiple, calc_bc_dist); + if (!num) { + yasm_error_set(YASM_ERROR_VALUE, + N_("could not determine multiple")); + return 1; + } + if (yasm_intnum_sign(num) < 0) { + yasm_error_set(YASM_ERROR_VALUE, N_("multiple is negative")); + return 1; + } + *multiple = yasm_intnum_get_int(num); } return 0; } @@ -376,11 +345,3 @@ yasm_bc_get_multiple_expr(const yasm_bytecode *bc) { return bc->multiple; } - -yasm_insn * -yasm_bc_get_insn(yasm_bytecode *bc) -{ - if (bc->callback->special != YASM_BC_SPECIAL_INSN) - return NULL; - return (yasm_insn *)bc->contents; -} diff --git a/libyasm/bytecode.h b/libyasm/bytecode.h index 47cd2624..2861becf 100644 --- a/libyasm/bytecode.h +++ b/libyasm/bytecode.h @@ -2,6 +2,10 @@ * \file libyasm/bytecode.h * \brief YASM bytecode interface. * + * \rcs + * $Id$ + * \endrcs + * * \license * Copyright (C) 2001-2007 Peter Johnson * @@ -30,303 +34,144 @@ #ifndef YASM_BYTECODE_H #define YASM_BYTECODE_H -#ifndef YASM_LIB_DECL -#define YASM_LIB_DECL -#endif +/** An effective address. */ +typedef struct yasm_effaddr yasm_effaddr; + +/** Callbacks for effective address implementations. */ +typedef struct yasm_effaddr_callback { + /** Destroy the effective address (freeing it). + * \param ea effective address + */ + void (*destroy) (/*@only@*/ yasm_effaddr *ea); + + /** Print the effective address. + * \param ea effective address + * \param f file to output to + * \param indent_level indentation level + */ + void (*print) (const yasm_effaddr *ea, FILE *f, int indent_level); +} yasm_effaddr_callback; + +/** An effective address. */ +struct yasm_effaddr { + const yasm_effaddr_callback *callback; /**< callback functions */ + + yasm_value disp; /**< address displacement */ + + uintptr_t segreg; /**< segment register override (0 if none) */ + + unsigned char need_nonzero_len; /**< 1 if length of disp must be >0. */ + unsigned char need_disp; /**< 1 if a displacement should be present + * in the output. + */ + unsigned char nosplit; /**< 1 if reg*2 should not be split into + * reg+reg. (0 if not) + */ + unsigned char strong; /**< 1 if effective address is *definitely* + * an effective address, e.g. in GAS if + * expr(,1) form is used vs. just expr. + */ +}; /** A data value (opaque type). */ typedef struct yasm_dataval yasm_dataval; -/** A list of data values. */ +/** A list of data values (opaque type). */ typedef struct yasm_datavalhead yasm_datavalhead; -/** Linked list of data values. */ +#ifdef YASM_LIB_INTERNAL /*@reldef@*/ STAILQ_HEAD(yasm_datavalhead, yasm_dataval); +#endif -/** Add a dependent span for a bytecode. - * \param add_span_data add_span_data passed into bc_calc_len() - * \param bc bytecode containing span - * \param id non-zero identifier for span; may be any non-zero value - * if <0, expand is called for any change; - * if >0, expand is only called when exceeds threshold - * \param value dependent value for bytecode expansion - * \param neg_thres negative threshold for long/short decision - * \param pos_thres positive threshold for long/short decision +/** Get the displacement portion of an effective address. + * \param ea effective address + * \return Expression representing the displacement (read-only). */ -typedef void (*yasm_bc_add_span_func) - (void *add_span_data, yasm_bytecode *bc, int id, const yasm_value *value, - long neg_thres, long pos_thres); +/*@observer@*/ const yasm_expr *yasm_ea_get_disp(const yasm_effaddr *ea); -/** Bytecode callback structure. Any implementation of a specific bytecode - * must implement these functions and this callback structure. The bytecode - * implementation-specific data is stored in #yasm_bytecode.contents. +/** Set the length of the displacement portion of an effective address. + * The length is specified in bits. + * \param ea effective address + * \param len length in bits */ -typedef struct yasm_bytecode_callback { - /** Destroys the implementation-specific data. - * Called from yasm_bc_destroy(). - * \param contents #yasm_bytecode.contents - */ - void (*destroy) (/*@only@*/ void *contents); +void yasm_ea_set_len(yasm_effaddr *ea, unsigned int len); - /** Prints the implementation-specific data (for debugging purposes). - * Called from yasm_bc_print(). - * \param contents #yasm_bytecode.contents - * \param f file - * \param indent_level indentation level - */ - void (*print) (const void *contents, FILE *f, int indent_level); - - /** Finalizes the bytecode after parsing. Called from yasm_bc_finalize(). - * A generic fill-in for this is yasm_bc_finalize_common(). - * \param bc bytecode - * \param prev_bc bytecode directly preceding bc - */ - void (*finalize) (yasm_bytecode *bc, yasm_bytecode *prev_bc); - - /** Return elements size of a data bytecode. - * This function should return the size of each elements of a data - * bytecode, for proper dereference of symbols attached to it. - * \param bc bytecode - * \return 0 if element size is unknown. - */ - int (*elem_size) (yasm_bytecode *bc); - - /** Calculates the minimum size of a bytecode. - * Called from yasm_bc_calc_len(). - * A generic fill-in for this is yasm_bc_calc_len_common(), but as this - * function internal errors when called, be very careful when using it! - * This function should simply add to bc->len and not set it directly - * (it's initialized by yasm_bc_calc_len() prior to passing control to - * this function). - * - * \param bc bytecode - * \param add_span function to call to add a span - * \param add_span_data extra data to be passed to add_span function - * \return 0 if no error occurred, nonzero if there was an error - * recognized (and output) during execution. - * \note May store to bytecode updated expressions. - */ - int (*calc_len) (yasm_bytecode *bc, yasm_bc_add_span_func add_span, - void *add_span_data); - - /** Recalculates the bytecode's length based on an expanded span length. - * Called from yasm_bc_expand(). - * A generic fill-in for this is yasm_bc_expand_common(), but as this - * function internal errors when called, if used, ensure that calc_len() - * never adds a span. - * This function should simply add to bc->len to increase the length by - * a delta amount. - * \param bc bytecode - * \param span span ID (as given to add_span in calc_len) - * \param old_val previous span value - * \param new_val new span value - * \param neg_thres negative threshold for long/short decision - * (returned) - * \param pos_thres positive threshold for long/short decision - * (returned) - * \return 0 if bc no longer dependent on this span's length, negative if - * there was an error recognized (and output) during execution, - * and positive if bc size may increase for this span further - * based on the new negative and positive thresholds returned. - * \note May store to bytecode updated expressions. - */ - int (*expand) (yasm_bytecode *bc, int span, long old_val, long new_val, - /*@out@*/ long *neg_thres, /*@out@*/ long *pos_thres); - - /** Convert a bytecode into its byte representation. - * Called from yasm_bc_tobytes(). - * A generic fill-in for this is yasm_bc_tobytes_common(), but as this - * function internal errors when called, be very careful when using it! - * \param bc bytecode - * \param bufp byte representation destination buffer; - * should be incremented as it's written to, - * so that on return its delta from the - * passed-in buf matches the bytecode length - * (it's okay not to do this if an error - * indication is returned) - * \param bufstart For calculating the correct offset parameter for - * the \a output_value calls: *bufp - bufstart. - * \param d data to pass to each call to - * output_value/output_reloc - * \param output_value function to call to convert values into their byte - * representation - * \param output_reloc function to call to output relocation entries - * for a single sym - * \return Nonzero on error, 0 on success. - * \note May result in non-reversible changes to the bytecode, but it's - * preferable if calling this function twice would result in the - * same output. - */ - int (*tobytes) (yasm_bytecode *bc, unsigned char **bufp, - unsigned char *bufstart, void *d, - yasm_output_value_func output_value, - /*@null@*/ yasm_output_reloc_func output_reloc); - - /** Special bytecode classifications. Most bytecode types should use - * #YASM_BC_SPECIAL_NONE. Others cause special handling to kick in - * in various parts of yasm. - */ - enum yasm_bytecode_special_type { - YASM_BC_SPECIAL_NONE = 0, - - /** Bytecode reserves space instead of outputting data. */ - YASM_BC_SPECIAL_RESERVE, - - /** Adjusts offset instead of calculating len. */ - YASM_BC_SPECIAL_OFFSET, - - /** Instruction bytecode. */ - YASM_BC_SPECIAL_INSN - } special; -} yasm_bytecode_callback; - -/** A bytecode. */ -struct yasm_bytecode { - /** Bytecodes are stored as a singly linked list, with tail insertion. - * \see section.h (#yasm_section). - */ - /*@reldef@*/ STAILQ_ENTRY(yasm_bytecode) link; - - /** The bytecode callback structure for this bytecode. May be NULL - * during partial initialization. - */ - /*@null@*/ const yasm_bytecode_callback *callback; - - /** Pointer to section containing bytecode; NULL if not part of a - * section. - */ - /*@dependent@*/ /*@null@*/ yasm_section *section; - - /** Number of times bytecode is repeated. - * NULL=1 (to save space in the common case). - */ - /*@only@*/ /*@null@*/ yasm_expr *multiple; - - /** Total length of entire bytecode (not including multiple copies). */ - unsigned long len; - - /** Number of copies, integer version. */ - long mult_int; - - /** Line number where bytecode was defined. */ - unsigned long line; - - /** Offset of bytecode from beginning of its section. - * 0-based, ~0UL (e.g. all 1 bits) if unknown. - */ - unsigned long offset; - - /** Unique integer index of bytecode. Used during optimization. */ - unsigned long bc_index; - - /** NULL-terminated array of labels that point to this bytecode (as the - * bytecode previous to the label). NULL if no labels point here. - */ - /*@null@*/ yasm_symrec **symrecs; - - /** Implementation-specific data (type identified by callback). */ - void *contents; -}; - -/** Create a bytecode of any specified type. - * \param callback bytecode callback functions, if NULL, creates empty - * bytecode (may not be resolved or output) - * \param contents type-specific data - * \param line virtual line (from yasm_linemap) - * \return Newly allocated bytecode of the specified type. +/** Set/clear nosplit flag of an effective address. + * The nosplit flag indicates (for architectures that support complex effective + * addresses such as x86) if various types of complex effective addresses can + * be split into different forms in order to minimize instruction length. + * \param ea effective address + * \param nosplit nosplit flag setting (0=splits allowed, nonzero=splits + * not allowed) */ -YASM_LIB_DECL -/*@only@*/ yasm_bytecode *yasm_bc_create_common - (/*@null@*/ const yasm_bytecode_callback *callback, - /*@only@*/ /*@null@*/ void *contents, unsigned long line); +void yasm_ea_set_nosplit(yasm_effaddr *ea, unsigned int nosplit); -/** Transform a bytecode of any type into a different type. - * \param bc bytecode to transform - * \param callback new bytecode callback function - * \param contents new type-specific data +/** Set/clear strong flag of an effective address. + * The strong flag indicates if an effective address is *definitely* an + * effective address. This is used in e.g. the GAS parser to differentiate + * between "expr" (which might or might not be an effective address) and + * "expr(,1)" (which is definitely an effective address). + * \param ea effective address + * \param strong strong flag setting (0=not strong, nonzero=strong) */ -YASM_LIB_DECL -void yasm_bc_transform(yasm_bytecode *bc, - const yasm_bytecode_callback *callback, - void *contents); +void yasm_ea_set_strong(yasm_effaddr *ea, unsigned int strong); -/** Common bytecode callback finalize function, for where no finalization - * is ever required for this type of bytecode. +/** Set segment override for an effective address. + * Some architectures (such as x86) support segment overrides on effective + * addresses. A override of an override will result in a warning. + * \param ea effective address + * \param segreg segment register (0 if none) */ -YASM_LIB_DECL -void yasm_bc_finalize_common(yasm_bytecode *bc, yasm_bytecode *prev_bc); +void yasm_ea_set_segreg(yasm_effaddr *ea, uintptr_t segreg); -/** Common bytecode callback calc_len function, for where the bytecode has - * no calculatable length. Causes an internal error if called. +/** Delete (free allocated memory for) an effective address. + * \param ea effective address (only pointer to it). */ -YASM_LIB_DECL -int yasm_bc_calc_len_common(yasm_bytecode *bc, yasm_bc_add_span_func add_span, - void *add_span_data); +void yasm_ea_destroy(/*@only@*/ yasm_effaddr *ea); -/** Common bytecode callback expand function, for where the bytecode is - * always short (calc_len never calls add_span). Causes an internal - * error if called. +/** Print an effective address. For debugging purposes. + * \param f file + * \param indent_level indentation level + * \param ea effective address */ -YASM_LIB_DECL -int yasm_bc_expand_common - (yasm_bytecode *bc, int span, long old_val, long new_val, - /*@out@*/ long *neg_thres, /*@out@*/ long *pos_thres); - -/** Common bytecode callback tobytes function, for where the bytecode - * cannot be converted to bytes. Causes an internal error if called. - */ -YASM_LIB_DECL -int yasm_bc_tobytes_common - (yasm_bytecode *bc, unsigned char **bufp, unsigned char *bufstart, void *d, - yasm_output_value_func output_value, - /*@null@*/ yasm_output_reloc_func output_reloc); - -/** Get the next bytecode in a linked list of bytecodes. - * \param bc bytecode - * \return Next bytecode. - */ -#define yasm_bc__next(bc) STAILQ_NEXT(bc, link) +void yasm_ea_print(const yasm_effaddr *ea, FILE *f, int indent_level); /** Set multiple field of a bytecode. * A bytecode can be repeated a number of times when output. This function * sets that multiple. - * \param bc bytecode - * \param e multiple (kept, do not free) + * \param bc bytecode + * \param e multiple (kept, do not free) */ -YASM_LIB_DECL void yasm_bc_set_multiple(yasm_bytecode *bc, /*@keep@*/ yasm_expr *e); /** Create a bytecode containing data value(s). - * \param datahead list of data values (kept, do not free) - * \param size storage size (in bytes) for each data value - * \param append_zero append a single zero byte after each data value - * (if non-zero) - * \param arch architecture (optional); if provided, data items - * are directly simplified to bytes if possible - * \param line virtual line (from yasm_linemap) + * \param datahead list of data values (kept, do not free) + * \param size storage size (in bytes) for each data value + * \param append_zero append a single zero byte after each data value + * (if non-zero) + * \param arch architecture (optional); if provided, data items + * are directly simplified to bytes if possible + * \param line virtual line (from yasm_linemap) * \return Newly allocated bytecode. */ -YASM_LIB_DECL /*@only@*/ yasm_bytecode *yasm_bc_create_data (yasm_datavalhead *datahead, unsigned int size, int append_zero, /*@null@*/ yasm_arch *arch, unsigned long line); /** Create a bytecode containing LEB128-encoded data value(s). - * \param datahead list of data values (kept, do not free) - * \param sign signedness (1=signed, 0=unsigned) of each data value - * \param line virtual line (from yasm_linemap) + * \param datahead list of data values (kept, do not free) + * \param sign signedness (1=signed, 0=unsigned) of each data value + * \param line virtual line (from yasm_linemap) * \return Newly allocated bytecode. */ -YASM_LIB_DECL /*@only@*/ yasm_bytecode *yasm_bc_create_leb128 (yasm_datavalhead *datahead, int sign, unsigned long line); /** Create a bytecode reserving space. - * \param numitems number of reserve "items" (kept, do not free) - * \param itemsize reserved size (in bytes) for each item - * \param line virtual line (from yasm_linemap) + * \param numitems number of reserve "items" (kept, do not free) + * \param itemsize reserved size (in bytes) for each item + * \param line virtual line (from yasm_linemap) * \return Newly allocated bytecode. */ -YASM_LIB_DECL /*@only@*/ yasm_bytecode *yasm_bc_create_reserve (/*@only@*/ yasm_expr *numitems, unsigned int itemsize, unsigned long line); @@ -338,39 +183,36 @@ YASM_LIB_DECL * \return NULL if bc is not a reserve bytecode, otherwise an expression * for the number of items to reserve. */ -YASM_LIB_DECL /*@null@*/ const yasm_expr *yasm_bc_reserve_numitems (yasm_bytecode *bc, /*@out@*/ unsigned int *itemsize); /** Create a bytecode that includes a binary file verbatim. - * \param filename path to binary file (kept, do not free) - * \param start starting location in file (in bytes) to read data from - * (kept, do not free); may be NULL to indicate 0 - * \param maxlen maximum number of bytes to read from the file (kept, do - * do not free); may be NULL to indicate no maximum - * \param linemap line mapping repository - * \param line virtual line (from yasm_linemap) for the bytecode + * \param filename path to binary file (kept, do not free) + * \param start starting location in file (in bytes) to read data from + * (kept, do not free); may be NULL to indicate 0 + * \param maxlen maximum number of bytes to read from the file (kept, do + * do not free); may be NULL to indicate no maximum + * \param linemap line mapping repository + * \param line virtual line (from yasm_linemap) for the bytecode * \return Newly allocated bytecode. */ -YASM_LIB_DECL /*@only@*/ yasm_bytecode *yasm_bc_create_incbin (/*@only@*/ char *filename, /*@only@*/ /*@null@*/ yasm_expr *start, /*@only@*/ /*@null@*/ yasm_expr *maxlen, yasm_linemap *linemap, unsigned long line); /** Create a bytecode that aligns the following bytecode to a boundary. - * \param boundary byte alignment (must be a power of two) - * \param fill fill data (if NULL, code_fill or 0 is used) - * \param maxskip maximum number of bytes to skip - * \param code_fill code fill data (if NULL, 0 is used) - * \param line virtual line (from yasm_linemap) + * \param boundary byte alignment (must be a power of two) + * \param fill fill data (if NULL, code_fill or 0 is used) + * \param maxskip maximum number of bytes to skip + * \param code_fill code fill data (if NULL, 0 is used) + * \param line virtual line (from yasm_linemap) * \return Newly allocated bytecode. * \note The precedence on generated fill is as follows: * - from fill parameter (if not NULL) * - from code_fill parameter (if not NULL) * - 0 */ -YASM_LIB_DECL /*@only@*/ yasm_bytecode *yasm_bc_create_align (/*@keep@*/ yasm_expr *boundary, /*@keep@*/ /*@null@*/ yasm_expr *fill, /*@keep@*/ /*@null@*/ yasm_expr *maxskip, @@ -378,137 +220,168 @@ YASM_LIB_DECL /** Create a bytecode that puts the following bytecode at a fixed section * offset. - * \param start section offset of following bytecode - * \param fill fill value - * \param line virtual line (from yasm_linemap) + * \param start section offset of following bytecode + * \param line virtual line (from yasm_linemap) * \return Newly allocated bytecode. */ -YASM_LIB_DECL /*@only@*/ yasm_bytecode *yasm_bc_create_org - (unsigned long start, unsigned long fill, unsigned long line); + (unsigned long start, unsigned long line); + +/** Create a bytecode that represents a single instruction. + * \param arch instruction's architecture + * \param insn_data data that identifies the type of instruction + * \param num_operands number of operands + * \param operands instruction operands (may be NULL if no operands) + * \param line virtual line (from yasm_linemap) + * \return Newly allocated bytecode. + * \note Keeps the list of operands; do not call yasm_ops_delete() after + * giving operands to this function. + */ +/*@only@*/ yasm_bytecode *yasm_bc_create_insn + (yasm_arch *arch, const uintptr_t insn_data[4], int num_operands, + /*@null@*/ yasm_insn_operands *operands, unsigned long line); + +/** Create a bytecode that represents a single empty (0 length) instruction. + * This is used for handling solitary prefixes. + * \param arch instruction's architecture + * \param line virtual line (from yasm_linemap) + * \return Newly allocated bytecode. + */ +/*@only@*/ yasm_bytecode *yasm_bc_create_empty_insn(yasm_arch *arch, + unsigned long line); + +/** Associate a prefix with an instruction bytecode. + * \param bc instruction bytecode + * \param prefix_data data the identifies the prefix + */ +void yasm_bc_insn_add_prefix(yasm_bytecode *bc, + const uintptr_t prefix_data[4]); + +/** Associate a segment prefix with an instruction bytecode. + * \param bc instruction bytecode + * \param segreg data the identifies the segment register + */ +void yasm_bc_insn_add_seg_prefix(yasm_bytecode *bc, uintptr_t segreg); /** Get the section that contains a particular bytecode. - * \param bc bytecode + * \param bc bytecode * \return Section containing bc (can be NULL if bytecode is not part of a - * section). + * section). */ -YASM_LIB_DECL /*@dependent@*/ /*@null@*/ yasm_section *yasm_bc_get_section (yasm_bytecode *bc); +#ifdef YASM_LIB_INTERNAL /** Add to the list of symrecs that reference a bytecode. For symrec use * only. - * \param bc bytecode - * \param sym symbol + * \param bc bytecode + * \param sym symbol */ -YASM_LIB_DECL void yasm_bc__add_symrec(yasm_bytecode *bc, /*@dependent@*/ yasm_symrec *sym); - +#endif + /** Delete (free allocated memory for) a bytecode. - * \param bc bytecode (only pointer to it); may be NULL + * \param bc bytecode (only pointer to it); may be NULL */ -YASM_LIB_DECL void yasm_bc_destroy(/*@only@*/ /*@null@*/ yasm_bytecode *bc); /** Print a bytecode. For debugging purposes. - * \param f file - * \param indent_level indentation level - * \param bc bytecode + * \param f file + * \param indent_level indentation level + * \param bc bytecode */ -YASM_LIB_DECL void yasm_bc_print(const yasm_bytecode *bc, FILE *f, int indent_level); /** Finalize a bytecode after parsing. - * \param bc bytecode - * \param prev_bc bytecode directly preceding bc in a list of bytecodes + * \param bc bytecode + * \param prev_bc bytecode directly preceding bc in a list of bytecodes */ -YASM_LIB_DECL void yasm_bc_finalize(yasm_bytecode *bc, yasm_bytecode *prev_bc); /** Determine the distance between the starting offsets of two bytecodes. - * \param precbc1 preceding bytecode to the first bytecode - * \param precbc2 preceding bytecode to the second bytecode + * \param precbc1 preceding bytecode to the first bytecode + * \param precbc2 preceding bytecode to the second bytecode * \return Distance in bytes between the two bytecodes (bc2-bc1), or NULL if - * the distance was indeterminate. + * the distance was indeterminate. * \warning Only valid /after/ optimization. */ -YASM_LIB_DECL /*@null@*/ /*@only@*/ yasm_intnum *yasm_calc_bc_dist (yasm_bytecode *precbc1, yasm_bytecode *precbc2); /** Get the offset of the next bytecode (the next bytecode doesn't have to * actually exist). - * \param precbc preceding bytecode + * \param precbc preceding bytecode * \return Offset of the next bytecode in bytes. * \warning Only valid /after/ optimization. */ -YASM_LIB_DECL unsigned long yasm_bc_next_offset(yasm_bytecode *precbc); -/** Return elemens size of a data bytecode. - * Returns the size of each elements of a data bytecode, for proper dereference - * of symbols attached to it. - * \param bc bytecode - * \return 0 if element size is unknown +/** Add a dependent span for a bytecode. + * \param add_span_data add_span_data passed into bc_calc_len() + * \param bc bytecode containing span + * \param id non-zero identifier for span; may be any non-zero value + * if <0, expand is called for any change; + * if >0, expand is only called when exceeds threshold + * \param value dependent value for bytecode expansion + * \param neg_thres negative threshold for long/short decision + * \param pos_thres positive threshold for long/short decision */ -YASM_LIB_DECL -int yasm_bc_elem_size(yasm_bytecode *bc); +typedef void (*yasm_bc_add_span_func) + (void *add_span_data, yasm_bytecode *bc, int id, const yasm_value *value, + long neg_thres, long pos_thres); /** Resolve EQUs in a bytecode and calculate its minimum size. * Generates dependent bytecode spans for cases where, if the length spanned * increases, it could cause the bytecode size to increase. * Any bytecode multiple is NOT included in the length or spans generation; * this must be handled at a higher level. - * \param bc bytecode - * \param add_span function to call to add a span - * \param add_span_data extra data to be passed to add_span function + * \param bc bytecode + * \param add_span function to call to add a span + * \param add_span_data extra data to be passed to add_span function * \return 0 if no error occurred, nonzero if there was an error recognized * (and output) during execution. * \note May store to bytecode updated expressions and the short length. */ -YASM_LIB_DECL int yasm_bc_calc_len(yasm_bytecode *bc, yasm_bc_add_span_func add_span, - void *add_span_data); + void *add_span_data); /** Recalculate a bytecode's length based on an expanded span length. - * \param bc bytecode - * \param span span ID (as given to yasm_bc_add_span_func in + * \param bc bytecode + * \param span span ID (as given to yasm_bc_add_span_func in * yasm_bc_calc_len) - * \param old_val previous span value - * \param new_val new span value - * \param neg_thres negative threshold for long/short decision (returned) - * \param pos_thres positive threshold for long/short decision (returned) + * \param old_val previous span value + * \param new_val new span value + * \param neg_thres negative threshold for long/short decision (returned) + * \param pos_thres postivie threshold for long/short decision (returned) * \return 0 if bc no longer dependent on this span's length, negative if * there was an error recognized (and output) during execution, and * positive if bc size may increase for this span further based on the * new negative and positive thresholds returned. * \note May store to bytecode updated expressions and the updated length. */ -YASM_LIB_DECL int yasm_bc_expand(yasm_bytecode *bc, int span, long old_val, long new_val, - /*@out@*/ long *neg_thres, /*@out@*/ long *pos_thres); + /*@out@*/ long *neg_thres, /*@out@*/ long *pos_thres); /** Convert a bytecode into its byte representation. - * \param bc bytecode - * \param buf byte representation destination buffer - * \param bufsize size of buf (in bytes) prior to call; size of the - * generated data after call - * \param gap if nonzero, indicates the data does not really need to - * exist in the object file; if nonzero, contents of buf - * are undefined [output] - * \param d data to pass to each call to output_value/output_reloc - * \param output_value function to call to convert values into their byte - * representation - * \param output_reloc function to call to output relocation entries - * for a single sym + * \param bc bytecode + * \param buf byte representation destination buffer + * \param bufsize size of buf (in bytes) prior to call; size of the + * generated data after call + * \param gap if nonzero, indicates the data does not really need to + * exist in the object file; if nonzero, contents of buf + * are undefined [output] + * \param d data to pass to each call to output_value/output_reloc + * \param output_value function to call to convert values into their byte + * representation + * \param output_reloc function to call to output relocation entries + * for a single sym * \return Newly allocated buffer that should be used instead of buf for - * reading the byte representation, or NULL if buf was big enough to - * hold the entire byte representation. + * reading the byte representation, or NULL if buf was big enough to + * hold the entire byte representation. * \note Calling twice on the same bytecode may \em not produce the same * results on the second call, as calling this function may result in * non-reversible changes to the bytecode. */ -YASM_LIB_DECL /*@null@*/ /*@only@*/ unsigned char *yasm_bc_tobytes (yasm_bytecode *bc, unsigned char *buf, unsigned long *bufsize, /*@out@*/ int *gap, void *d, yasm_output_value_func output_value, @@ -516,123 +389,77 @@ YASM_LIB_DECL /*@sets *buf@*/; /** Get the bytecode multiple value as an integer. - * \param bc bytecode - * \param multiple multiple value (output) - * \param calc_bc_dist nonzero if distances between bytecodes should be - * calculated, 0 if error should be returned in this case + * \param bc bytecode + * \param multiple multiple value (output) + * \param calc_bc_dist nonzero if distances between bytecodes should be + * calculated, 0 if error should be returned in this case * \return 1 on error (set with yasm_error_set), 0 on success. */ -YASM_LIB_DECL int yasm_bc_get_multiple(yasm_bytecode *bc, /*@out@*/ long *multiple, - int calc_bc_dist); + int calc_bc_dist); /** Get the bytecode multiple value as an expression. * \param bc bytecode * \return Bytecode multiple, NULL if =1. */ -YASM_LIB_DECL const yasm_expr *yasm_bc_get_multiple_expr(const yasm_bytecode *bc); -/** Get a #yasm_insn structure from an instruction bytecode (if possible). - * \param bc bytecode - * \return Instruction details if bytecode is an instruction bytecode, - * otherwise NULL. - */ -YASM_LIB_DECL -/*@dependent@*/ /*@null@*/ yasm_insn *yasm_bc_get_insn(yasm_bytecode *bc); - /** Create a new data value from an expression. - * \param expn expression + * \param expn expression * \return Newly allocated data value. */ -YASM_LIB_DECL yasm_dataval *yasm_dv_create_expr(/*@keep@*/ yasm_expr *expn); /** Create a new data value from a string. - * \param contents string (may contain NULs) - * \param len length of string + * \param contents string (may contain NULs) + * \param len length of string * \return Newly allocated data value. */ -YASM_LIB_DECL yasm_dataval *yasm_dv_create_string(/*@keep@*/ char *contents, size_t len); /** Create a new data value from raw bytes data. - * \param contents raw data (may contain NULs) - * \param len length + * \param contents raw data (may contain NULs) + * \param len length * \return Newly allocated data value. */ -YASM_LIB_DECL yasm_dataval *yasm_dv_create_raw(/*@keep@*/ unsigned char *contents, - unsigned long len); - -/** Create a new uninitialized data value. - * \return Newly allocated data value. - */ -YASM_LIB_DECL -yasm_dataval *yasm_dv_create_reserve(void); + unsigned long len); #ifndef YASM_DOXYGEN #define yasm_dv_create_string(s, l) yasm_dv_create_raw((unsigned char *)(s), \ - (unsigned long)(l)) + (unsigned long)(l)) #endif -/** Get the underlying value of a data value. - * \param dv data value - * \return Value, or null if non-value (e.g. string or raw). - */ -YASM_LIB_DECL -yasm_value *yasm_dv_get_value(yasm_dataval *dv); - -/** Set multiple field of a data value. - * A data value can be repeated a number of times when output. This function - * sets that multiple. - * \param dv data value - * \param e multiple (kept, do not free) - */ -YASM_LIB_DECL -void yasm_dv_set_multiple(yasm_dataval *dv, /*@keep@*/ yasm_expr *e); - -/** Get the data value multiple value as an unsigned long integer. - * \param dv data value - * \param multiple multiple value (output) - * \return 1 on error (set with yasm_error_set), 0 on success. - */ -YASM_LIB_DECL -int yasm_dv_get_multiple(yasm_dataval *dv, /*@out@*/ unsigned long *multiple); - /** Initialize a list of data values. - * \param headp list of data values + * \param headp list of data values */ void yasm_dvs_initialize(yasm_datavalhead *headp); -#ifndef YASM_DOXYGEN -#define yasm_dvs_initialize(headp) STAILQ_INIT(headp) +#ifdef YASM_LIB_INTERNAL +#define yasm_dvs_initialize(headp) STAILQ_INIT(headp) #endif /** Delete (free allocated memory for) a list of data values. - * \param headp list of data values + * \param headp list of data values */ -YASM_LIB_DECL void yasm_dvs_delete(yasm_datavalhead *headp); /** Add data value to the end of a list of data values. * \note Does not make a copy of the data value; so don't pass this function - * static or local variables, and discard the dv pointer after calling - * this function. - * \param headp data value list - * \param dv data value (may be NULL) + * static or local variables, and discard the dv pointer after calling + * this function. + * \param headp data value list + * \param dv data value (may be NULL) * \return If data value was actually appended (it wasn't NULL), the data - * value; otherwise NULL. + * value; otherwise NULL. */ -YASM_LIB_DECL /*@null@*/ yasm_dataval *yasm_dvs_append (yasm_datavalhead *headp, /*@returned@*/ /*@null@*/ yasm_dataval *dv); /** Print a data value list. For debugging purposes. - * \param f file - * \param indent_level indentation level - * \param headp data value list + * \param f file + * \param indent_level indentation level + * \param headp data value list */ -YASM_LIB_DECL void yasm_dvs_print(const yasm_datavalhead *headp, FILE *f, int indent_level); #endif diff --git a/libyasm/cmake-module.c b/libyasm/cmake-module.c deleted file mode 100644 index 0133f902..00000000 --- a/libyasm/cmake-module.c +++ /dev/null @@ -1,126 +0,0 @@ -/* - * YASM module loader - * - * Copyright (C) 2004-2007 Peter Johnson - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND OTHER CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR OTHER CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -#include - -#include - - -typedef struct loaded_module { - const char *keyword; /* module keyword */ - void *data; /* associated data */ -} loaded_module; - -static HAMT *loaded_modules[] = {NULL, NULL, NULL, NULL, NULL, NULL}; - -static void -load_module_destroy(/*@only@*/ void *data) -{ - /* do nothing */ -} - -void * -yasm_load_module(yasm_module_type type, const char *keyword) -{ - if (!loaded_modules[type]) - return NULL; - return HAMT_search(loaded_modules[type], keyword); -} - -void -yasm_register_module(yasm_module_type type, const char *keyword, void *data) -{ - int replace = 1; - - assert(type < sizeof(loaded_modules)); - - if (!loaded_modules[type]) - loaded_modules[type] = HAMT_create(1, yasm_internal_error_); - - HAMT_insert(loaded_modules[type], keyword, data, &replace, - load_module_destroy); -} - -typedef struct { - yasm_module_type type; - void (*printfunc) (const char *name, const char *keyword); -} list_one_data; - -static int -yasm_list_one_module(void *node, void *d) -{ - list_one_data *data = (list_one_data *)d; - yasm_arch_module *arch; - yasm_dbgfmt_module *dbgfmt; - yasm_objfmt_module *objfmt; - yasm_listfmt_module *listfmt; - yasm_parser_module *parser; - yasm_preproc_module *preproc; - - switch (data->type) { - case YASM_MODULE_ARCH: - arch = node; - data->printfunc(arch->name, arch->keyword); - break; - case YASM_MODULE_DBGFMT: - dbgfmt = node; - data->printfunc(dbgfmt->name, dbgfmt->keyword); - break; - case YASM_MODULE_OBJFMT: - objfmt = node; - data->printfunc(objfmt->name, objfmt->keyword); - break; - case YASM_MODULE_LISTFMT: - listfmt = node; - data->printfunc(listfmt->name, listfmt->keyword); - break; - case YASM_MODULE_PARSER: - parser = node; - data->printfunc(parser->name, parser->keyword); - break; - case YASM_MODULE_PREPROC: - preproc = node; - data->printfunc(preproc->name, preproc->keyword); - break; - } - return 0; -} - -void -yasm_list_modules(yasm_module_type type, - void (*printfunc) (const char *name, const char *keyword)) -{ - list_one_data data; - - /* Go through available list, and try to load each one */ - if (!loaded_modules[type]) - return; - - data.type = type; - data.printfunc = printfunc; - - HAMT_traverse(loaded_modules[type], &data, yasm_list_one_module); -} diff --git a/libyasm/compat-queue.h b/libyasm/compat-queue.h index da9eff46..5d73bd04 100644 --- a/libyasm/compat-queue.h +++ b/libyasm/compat-queue.h @@ -1,8 +1,8 @@ -/* +/* $Id$ * implementation for systems that don't have it. * * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. + * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -28,12 +28,12 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#)queue.h 8.5 (Berkeley) 8/20/94 + * @(#)queue.h 8.5 (Berkeley) 8/20/94 * $FreeBSD: src/sys/sys/queue.h,v 1.32.2.4 2001/03/31 03:33:39 hsu Exp $ */ #ifndef SYS_QUEUE_H -#define SYS_QUEUE_H +#define SYS_QUEUE_H /* * This file defines four types of data structures: singly-linked lists, @@ -77,380 +77,380 @@ * For details on the use of these macros, see the queue(3) manual page. * * - * SLIST LIST STAILQ TAILQ - * _HEAD + + + + - * _HEAD_INITIALIZER + + + + - * _ENTRY + + + + - * _INIT + + + + - * _EMPTY + + + + - * _FIRST + + + + - * _NEXT + + + + - * _PREV - - - + - * _LAST - - + + - * _FOREACH + + + + - * _FOREACH_SAFE + + + + - * _FOREACH_REVERSE - - - + - * _FOREACH_REVERSE_SAFE - - - + - * _INSERT_HEAD + + + + - * _INSERT_BEFORE - + - + - * _INSERT_AFTER + + + + - * _INSERT_TAIL - - + + - * _CONCAT - - + + - * _REMOVE_HEAD + - + - - * _REMOVE + + + + + * SLIST LIST STAILQ TAILQ + * _HEAD + + + + + * _HEAD_INITIALIZER + + + + + * _ENTRY + + + + + * _INIT + + + + + * _EMPTY + + + + + * _FIRST + + + + + * _NEXT + + + + + * _PREV - - - + + * _LAST - - + + + * _FOREACH + + + + + * _FOREACH_SAFE + + + + + * _FOREACH_REVERSE - - - + + * _FOREACH_REVERSE_SAFE - - - + + * _INSERT_HEAD + + + + + * _INSERT_BEFORE - + - + + * _INSERT_AFTER + + + + + * _INSERT_TAIL - - + + + * _CONCAT - - + + + * _REMOVE_HEAD + - + - + * _REMOVE + + + + * */ /* * Singly-linked List declarations. */ -#define SLIST_HEAD(name, type) \ -struct name { \ - struct type *slh_first; /* first element */ \ +#define SLIST_HEAD(name, type) \ +struct name { \ + struct type *slh_first; /* first element */ \ } -#define SLIST_HEAD_INITIALIZER(head) \ - { NULL } +#define SLIST_HEAD_INITIALIZER(head) \ + { NULL } -#define SLIST_ENTRY(type) \ -struct { \ - struct type *sle_next; /* next element */ \ +#define SLIST_ENTRY(type) \ +struct { \ + struct type *sle_next; /* next element */ \ } /* * Singly-linked List functions. */ -#define SLIST_EMPTY(head) ((head)->slh_first == NULL) +#define SLIST_EMPTY(head) ((head)->slh_first == NULL) -#define SLIST_FIRST(head) ((head)->slh_first) +#define SLIST_FIRST(head) ((head)->slh_first) -#define SLIST_FOREACH(var, head, field) \ - for ((var) = SLIST_FIRST((head)); \ - (var); \ - (var) = SLIST_NEXT((var), field)) +#define SLIST_FOREACH(var, head, field) \ + for ((var) = SLIST_FIRST((head)); \ + (var); \ + (var) = SLIST_NEXT((var), field)) -#define SLIST_FOREACH_SAFE(var, head, field, tvar) \ - for ((var) = SLIST_FIRST((head)); \ - (var) && ((tvar) = SLIST_NEXT((var), field), 1); \ - (var) = (tvar)) +#define SLIST_FOREACH_SAFE(var, head, field, tvar) \ + for ((var) = SLIST_FIRST((head)); \ + (var) && ((tvar) = SLIST_NEXT((var), field), 1); \ + (var) = (tvar)) -#define SLIST_FOREACH_PREVPTR(var, varp, head, field) \ - for ((varp) = &SLIST_FIRST((head)); \ - ((var) = *(varp)) != NULL; \ - (varp) = &SLIST_NEXT((var), field)) +#define SLIST_FOREACH_PREVPTR(var, varp, head, field) \ + for ((varp) = &SLIST_FIRST((head)); \ + ((var) = *(varp)) != NULL; \ + (varp) = &SLIST_NEXT((var), field)) -#define SLIST_INIT(head) do { \ - SLIST_FIRST((head)) = NULL; \ +#define SLIST_INIT(head) do { \ + SLIST_FIRST((head)) = NULL; \ } while (0) -#define SLIST_INSERT_AFTER(slistelm, elm, field) do { \ - SLIST_NEXT((elm), field) = SLIST_NEXT((slistelm), field); \ - SLIST_NEXT((slistelm), field) = (elm); \ +#define SLIST_INSERT_AFTER(slistelm, elm, field) do { \ + SLIST_NEXT((elm), field) = SLIST_NEXT((slistelm), field); \ + SLIST_NEXT((slistelm), field) = (elm); \ } while (0) -#define SLIST_INSERT_HEAD(head, elm, field) do { \ - SLIST_NEXT((elm), field) = SLIST_FIRST((head)); \ - SLIST_FIRST((head)) = (elm); \ +#define SLIST_INSERT_HEAD(head, elm, field) do { \ + SLIST_NEXT((elm), field) = SLIST_FIRST((head)); \ + SLIST_FIRST((head)) = (elm); \ } while (0) -#define SLIST_NEXT(elm, field) ((elm)->field.sle_next) +#define SLIST_NEXT(elm, field) ((elm)->field.sle_next) -#define SLIST_REMOVE(head, elm, type, field) do { \ - if (SLIST_FIRST((head)) == (elm)) { \ - SLIST_REMOVE_HEAD((head), field); \ - } \ - else { \ - struct type *curelm = SLIST_FIRST((head)); \ - while (SLIST_NEXT(curelm, field) != (elm)) \ - curelm = SLIST_NEXT(curelm, field); \ - SLIST_NEXT(curelm, field) = \ - SLIST_NEXT(SLIST_NEXT(curelm, field), field); \ - } \ +#define SLIST_REMOVE(head, elm, type, field) do { \ + if (SLIST_FIRST((head)) == (elm)) { \ + SLIST_REMOVE_HEAD((head), field); \ + } \ + else { \ + struct type *curelm = SLIST_FIRST((head)); \ + while (SLIST_NEXT(curelm, field) != (elm)) \ + curelm = SLIST_NEXT(curelm, field); \ + SLIST_NEXT(curelm, field) = \ + SLIST_NEXT(SLIST_NEXT(curelm, field), field); \ + } \ } while (0) -#define SLIST_REMOVE_HEAD(head, field) do { \ - SLIST_FIRST((head)) = SLIST_NEXT(SLIST_FIRST((head)), field); \ +#define SLIST_REMOVE_HEAD(head, field) do { \ + SLIST_FIRST((head)) = SLIST_NEXT(SLIST_FIRST((head)), field); \ } while (0) /* * Singly-linked Tail queue declarations. */ -#define STAILQ_HEAD(name, type) \ -struct name { \ - struct type *stqh_first;/* first element */ \ - struct type **stqh_last;/* addr of last next element */ \ +#define STAILQ_HEAD(name, type) \ +struct name { \ + struct type *stqh_first;/* first element */ \ + struct type **stqh_last;/* addr of last next element */ \ } -#define STAILQ_HEAD_INITIALIZER(head) \ - { NULL, &(head).stqh_first } +#define STAILQ_HEAD_INITIALIZER(head) \ + { NULL, &(head).stqh_first } -#define STAILQ_ENTRY(type) \ -struct { \ - struct type *stqe_next; /* next element */ \ +#define STAILQ_ENTRY(type) \ +struct { \ + struct type *stqe_next; /* next element */ \ } /* * Singly-linked Tail queue functions. */ -#define STAILQ_CONCAT(head1, head2) do { \ - if (!STAILQ_EMPTY((head2))) { \ - *(head1)->stqh_last = (head2)->stqh_first; \ - (head1)->stqh_last = (head2)->stqh_last; \ - STAILQ_INIT((head2)); \ - } \ +#define STAILQ_CONCAT(head1, head2) do { \ + if (!STAILQ_EMPTY((head2))) { \ + *(head1)->stqh_last = (head2)->stqh_first; \ + (head1)->stqh_last = (head2)->stqh_last; \ + STAILQ_INIT((head2)); \ + } \ } while (0) -#define STAILQ_EMPTY(head) ((head)->stqh_first == NULL) +#define STAILQ_EMPTY(head) ((head)->stqh_first == NULL) -#define STAILQ_FIRST(head) ((head)->stqh_first) +#define STAILQ_FIRST(head) ((head)->stqh_first) -#define STAILQ_FOREACH(var, head, field) \ - for((var) = STAILQ_FIRST((head)); \ - (var); \ - (var) = STAILQ_NEXT((var), field)) +#define STAILQ_FOREACH(var, head, field) \ + for((var) = STAILQ_FIRST((head)); \ + (var); \ + (var) = STAILQ_NEXT((var), field)) -#define STAILQ_FOREACH_SAFE(var, head, field, tvar) \ - for ((var) = STAILQ_FIRST((head)); \ - (var) && ((tvar) = STAILQ_NEXT((var), field), 1); \ - (var) = (tvar)) +#define STAILQ_FOREACH_SAFE(var, head, field, tvar) \ + for ((var) = STAILQ_FIRST((head)); \ + (var) && ((tvar) = STAILQ_NEXT((var), field), 1); \ + (var) = (tvar)) -#define STAILQ_INIT(head) do { \ - STAILQ_FIRST((head)) = NULL; \ - (head)->stqh_last = &STAILQ_FIRST((head)); \ +#define STAILQ_INIT(head) do { \ + STAILQ_FIRST((head)) = NULL; \ + (head)->stqh_last = &STAILQ_FIRST((head)); \ } while (0) -#define STAILQ_INSERT_AFTER(head, tqelm, elm, field) do { \ - if ((STAILQ_NEXT((elm), field) = STAILQ_NEXT((tqelm), field)) == NULL)\ - (head)->stqh_last = &STAILQ_NEXT((elm), field); \ - STAILQ_NEXT((tqelm), field) = (elm); \ +#define STAILQ_INSERT_AFTER(head, tqelm, elm, field) do { \ + if ((STAILQ_NEXT((elm), field) = STAILQ_NEXT((tqelm), field)) == NULL)\ + (head)->stqh_last = &STAILQ_NEXT((elm), field); \ + STAILQ_NEXT((tqelm), field) = (elm); \ } while (0) -#define STAILQ_INSERT_HEAD(head, elm, field) do { \ - if ((STAILQ_NEXT((elm), field) = STAILQ_FIRST((head))) == NULL) \ - (head)->stqh_last = &STAILQ_NEXT((elm), field); \ - STAILQ_FIRST((head)) = (elm); \ +#define STAILQ_INSERT_HEAD(head, elm, field) do { \ + if ((STAILQ_NEXT((elm), field) = STAILQ_FIRST((head))) == NULL) \ + (head)->stqh_last = &STAILQ_NEXT((elm), field); \ + STAILQ_FIRST((head)) = (elm); \ } while (0) -#define STAILQ_INSERT_TAIL(head, elm, field) do { \ - STAILQ_NEXT((elm), field) = NULL; \ - *(head)->stqh_last = (elm); \ - (head)->stqh_last = &STAILQ_NEXT((elm), field); \ +#define STAILQ_INSERT_TAIL(head, elm, field) do { \ + STAILQ_NEXT((elm), field) = NULL; \ + *(head)->stqh_last = (elm); \ + (head)->stqh_last = &STAILQ_NEXT((elm), field); \ } while (0) -#define STAILQ_LAST(head, type, field) \ - (STAILQ_EMPTY((head)) ? \ - NULL : \ - ((struct type *) \ - ((char *)((head)->stqh_last) - offsetof(struct type, field)))) +#define STAILQ_LAST(head, type, field) \ + (STAILQ_EMPTY((head)) ? \ + NULL : \ + ((struct type *) \ + ((char *)((head)->stqh_last) - offsetof(struct type, field)))) -#define STAILQ_NEXT(elm, field) ((elm)->field.stqe_next) +#define STAILQ_NEXT(elm, field) ((elm)->field.stqe_next) -#define STAILQ_REMOVE(head, elm, type, field) do { \ - if (STAILQ_FIRST((head)) == (elm)) { \ - STAILQ_REMOVE_HEAD((head), field); \ - } \ - else { \ - struct type *curelm = STAILQ_FIRST((head)); \ - while (STAILQ_NEXT(curelm, field) != (elm)) \ - curelm = STAILQ_NEXT(curelm, field); \ - if ((STAILQ_NEXT(curelm, field) = \ - STAILQ_NEXT(STAILQ_NEXT(curelm, field), field)) == NULL)\ - (head)->stqh_last = &STAILQ_NEXT((curelm), field);\ - } \ +#define STAILQ_REMOVE(head, elm, type, field) do { \ + if (STAILQ_FIRST((head)) == (elm)) { \ + STAILQ_REMOVE_HEAD((head), field); \ + } \ + else { \ + struct type *curelm = STAILQ_FIRST((head)); \ + while (STAILQ_NEXT(curelm, field) != (elm)) \ + curelm = STAILQ_NEXT(curelm, field); \ + if ((STAILQ_NEXT(curelm, field) = \ + STAILQ_NEXT(STAILQ_NEXT(curelm, field), field)) == NULL)\ + (head)->stqh_last = &STAILQ_NEXT((curelm), field);\ + } \ } while (0) -#define STAILQ_REMOVE_HEAD(head, field) do { \ - if ((STAILQ_FIRST((head)) = \ - STAILQ_NEXT(STAILQ_FIRST((head)), field)) == NULL) \ - (head)->stqh_last = &STAILQ_FIRST((head)); \ +#define STAILQ_REMOVE_HEAD(head, field) do { \ + if ((STAILQ_FIRST((head)) = \ + STAILQ_NEXT(STAILQ_FIRST((head)), field)) == NULL) \ + (head)->stqh_last = &STAILQ_FIRST((head)); \ } while (0) -#define STAILQ_REMOVE_HEAD_UNTIL(head, elm, field) do { \ - if ((STAILQ_FIRST((head)) = STAILQ_NEXT((elm), field)) == NULL) \ - (head)->stqh_last = &STAILQ_FIRST((head)); \ +#define STAILQ_REMOVE_HEAD_UNTIL(head, elm, field) do { \ + if ((STAILQ_FIRST((head)) = STAILQ_NEXT((elm), field)) == NULL) \ + (head)->stqh_last = &STAILQ_FIRST((head)); \ } while (0) /* * List declarations. */ -#define LIST_HEAD(name, type) \ -struct name { \ - struct type *lh_first; /* first element */ \ +#define LIST_HEAD(name, type) \ +struct name { \ + struct type *lh_first; /* first element */ \ } -#define LIST_HEAD_INITIALIZER(head) \ - { NULL } +#define LIST_HEAD_INITIALIZER(head) \ + { NULL } -#define LIST_ENTRY(type) \ -struct { \ - struct type *le_next; /* next element */ \ - struct type **le_prev; /* address of previous next element */ \ +#define LIST_ENTRY(type) \ +struct { \ + struct type *le_next; /* next element */ \ + struct type **le_prev; /* address of previous next element */ \ } /* * List functions. */ -#define LIST_EMPTY(head) ((head)->lh_first == NULL) +#define LIST_EMPTY(head) ((head)->lh_first == NULL) -#define LIST_FIRST(head) ((head)->lh_first) +#define LIST_FIRST(head) ((head)->lh_first) -#define LIST_FOREACH(var, head, field) \ - for ((var) = LIST_FIRST((head)); \ - (var); \ - (var) = LIST_NEXT((var), field)) +#define LIST_FOREACH(var, head, field) \ + for ((var) = LIST_FIRST((head)); \ + (var); \ + (var) = LIST_NEXT((var), field)) -#define LIST_FOREACH_SAFE(var, head, field, tvar) \ - for ((var) = LIST_FIRST((head)); \ - (var) && ((tvar) = LIST_NEXT((var), field), 1); \ - (var) = (tvar)) +#define LIST_FOREACH_SAFE(var, head, field, tvar) \ + for ((var) = LIST_FIRST((head)); \ + (var) && ((tvar) = LIST_NEXT((var), field), 1); \ + (var) = (tvar)) -#define LIST_INIT(head) do { \ - LIST_FIRST((head)) = NULL; \ +#define LIST_INIT(head) do { \ + LIST_FIRST((head)) = NULL; \ } while (0) -#define LIST_INSERT_AFTER(listelm, elm, field) do { \ - if ((LIST_NEXT((elm), field) = LIST_NEXT((listelm), field)) != NULL)\ - LIST_NEXT((listelm), field)->field.le_prev = \ - &LIST_NEXT((elm), field); \ - LIST_NEXT((listelm), field) = (elm); \ - (elm)->field.le_prev = &LIST_NEXT((listelm), field); \ +#define LIST_INSERT_AFTER(listelm, elm, field) do { \ + if ((LIST_NEXT((elm), field) = LIST_NEXT((listelm), field)) != NULL)\ + LIST_NEXT((listelm), field)->field.le_prev = \ + &LIST_NEXT((elm), field); \ + LIST_NEXT((listelm), field) = (elm); \ + (elm)->field.le_prev = &LIST_NEXT((listelm), field); \ } while (0) -#define LIST_INSERT_BEFORE(listelm, elm, field) do { \ - (elm)->field.le_prev = (listelm)->field.le_prev; \ - LIST_NEXT((elm), field) = (listelm); \ - *(listelm)->field.le_prev = (elm); \ - (listelm)->field.le_prev = &LIST_NEXT((elm), field); \ +#define LIST_INSERT_BEFORE(listelm, elm, field) do { \ + (elm)->field.le_prev = (listelm)->field.le_prev; \ + LIST_NEXT((elm), field) = (listelm); \ + *(listelm)->field.le_prev = (elm); \ + (listelm)->field.le_prev = &LIST_NEXT((elm), field); \ } while (0) -#define LIST_INSERT_HEAD(head, elm, field) do { \ - if ((LIST_NEXT((elm), field) = LIST_FIRST((head))) != NULL) \ - LIST_FIRST((head))->field.le_prev = &LIST_NEXT((elm), field);\ - LIST_FIRST((head)) = (elm); \ - (elm)->field.le_prev = &LIST_FIRST((head)); \ +#define LIST_INSERT_HEAD(head, elm, field) do { \ + if ((LIST_NEXT((elm), field) = LIST_FIRST((head))) != NULL) \ + LIST_FIRST((head))->field.le_prev = &LIST_NEXT((elm), field);\ + LIST_FIRST((head)) = (elm); \ + (elm)->field.le_prev = &LIST_FIRST((head)); \ } while (0) -#define LIST_NEXT(elm, field) ((elm)->field.le_next) +#define LIST_NEXT(elm, field) ((elm)->field.le_next) -#define LIST_REMOVE(elm, field) do { \ - if (LIST_NEXT((elm), field) != NULL) \ - LIST_NEXT((elm), field)->field.le_prev = \ - (elm)->field.le_prev; \ - *(elm)->field.le_prev = LIST_NEXT((elm), field); \ +#define LIST_REMOVE(elm, field) do { \ + if (LIST_NEXT((elm), field) != NULL) \ + LIST_NEXT((elm), field)->field.le_prev = \ + (elm)->field.le_prev; \ + *(elm)->field.le_prev = LIST_NEXT((elm), field); \ } while (0) /* * Tail queue declarations. */ -#define TAILQ_HEAD(name, type) \ -struct name { \ - struct type *tqh_first; /* first element */ \ - struct type **tqh_last; /* addr of last next element */ \ +#define TAILQ_HEAD(name, type) \ +struct name { \ + struct type *tqh_first; /* first element */ \ + struct type **tqh_last; /* addr of last next element */ \ } -#define TAILQ_HEAD_INITIALIZER(head) \ - { NULL, &(head).tqh_first } +#define TAILQ_HEAD_INITIALIZER(head) \ + { NULL, &(head).tqh_first } -#define TAILQ_ENTRY(type) \ -struct { \ - struct type *tqe_next; /* next element */ \ - struct type **tqe_prev; /* address of previous next element */ \ +#define TAILQ_ENTRY(type) \ +struct { \ + struct type *tqe_next; /* next element */ \ + struct type **tqe_prev; /* address of previous next element */ \ } /* * Tail queue functions. */ -#define TAILQ_CONCAT(head1, head2, field) do { \ - if (!TAILQ_EMPTY(head2)) { \ - *(head1)->tqh_last = (head2)->tqh_first; \ - (head2)->tqh_first->field.tqe_prev = (head1)->tqh_last; \ - (head1)->tqh_last = (head2)->tqh_last; \ - TAILQ_INIT((head2)); \ - } \ +#define TAILQ_CONCAT(head1, head2, field) do { \ + if (!TAILQ_EMPTY(head2)) { \ + *(head1)->tqh_last = (head2)->tqh_first; \ + (head2)->tqh_first->field.tqe_prev = (head1)->tqh_last; \ + (head1)->tqh_last = (head2)->tqh_last; \ + TAILQ_INIT((head2)); \ + } \ } while (0) -#define TAILQ_EMPTY(head) ((head)->tqh_first == NULL) +#define TAILQ_EMPTY(head) ((head)->tqh_first == NULL) -#define TAILQ_FIRST(head) ((head)->tqh_first) +#define TAILQ_FIRST(head) ((head)->tqh_first) -#define TAILQ_FOREACH(var, head, field) \ - for ((var) = TAILQ_FIRST((head)); \ - (var); \ - (var) = TAILQ_NEXT((var), field)) +#define TAILQ_FOREACH(var, head, field) \ + for ((var) = TAILQ_FIRST((head)); \ + (var); \ + (var) = TAILQ_NEXT((var), field)) -#define TAILQ_FOREACH_SAFE(var, head, field, tvar) \ - for ((var) = TAILQ_FIRST((head)); \ - (var) && ((tvar) = TAILQ_NEXT((var), field), 1); \ - (var) = (tvar)) +#define TAILQ_FOREACH_SAFE(var, head, field, tvar) \ + for ((var) = TAILQ_FIRST((head)); \ + (var) && ((tvar) = TAILQ_NEXT((var), field), 1); \ + (var) = (tvar)) -#define TAILQ_FOREACH_REVERSE(var, head, headname, field) \ - for ((var) = TAILQ_LAST((head), headname); \ - (var); \ - (var) = TAILQ_PREV((var), headname, field)) +#define TAILQ_FOREACH_REVERSE(var, head, headname, field) \ + for ((var) = TAILQ_LAST((head), headname); \ + (var); \ + (var) = TAILQ_PREV((var), headname, field)) -#define TAILQ_FOREACH_REVERSE_SAFE(var, head, headname, field, tvar) \ - for ((var) = TAILQ_LAST((head), headname); \ - (var) && ((tvar) = TAILQ_PREV((var), headname, field), 1); \ - (var) = (tvar)) +#define TAILQ_FOREACH_REVERSE_SAFE(var, head, headname, field, tvar) \ + for ((var) = TAILQ_LAST((head), headname); \ + (var) && ((tvar) = TAILQ_PREV((var), headname, field), 1); \ + (var) = (tvar)) -#define TAILQ_INIT(head) do { \ - TAILQ_FIRST((head)) = NULL; \ - (head)->tqh_last = &TAILQ_FIRST((head)); \ +#define TAILQ_INIT(head) do { \ + TAILQ_FIRST((head)) = NULL; \ + (head)->tqh_last = &TAILQ_FIRST((head)); \ } while (0) -#define TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \ - if ((TAILQ_NEXT((elm), field) = TAILQ_NEXT((listelm), field)) != NULL)\ - TAILQ_NEXT((elm), field)->field.tqe_prev = \ - &TAILQ_NEXT((elm), field); \ - else { \ - (head)->tqh_last = &TAILQ_NEXT((elm), field); \ - } \ - TAILQ_NEXT((listelm), field) = (elm); \ - (elm)->field.tqe_prev = &TAILQ_NEXT((listelm), field); \ +#define TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \ + if ((TAILQ_NEXT((elm), field) = TAILQ_NEXT((listelm), field)) != NULL)\ + TAILQ_NEXT((elm), field)->field.tqe_prev = \ + &TAILQ_NEXT((elm), field); \ + else { \ + (head)->tqh_last = &TAILQ_NEXT((elm), field); \ + } \ + TAILQ_NEXT((listelm), field) = (elm); \ + (elm)->field.tqe_prev = &TAILQ_NEXT((listelm), field); \ } while (0) -#define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \ - (elm)->field.tqe_prev = (listelm)->field.tqe_prev; \ - TAILQ_NEXT((elm), field) = (listelm); \ - *(listelm)->field.tqe_prev = (elm); \ - (listelm)->field.tqe_prev = &TAILQ_NEXT((elm), field); \ +#define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \ + (elm)->field.tqe_prev = (listelm)->field.tqe_prev; \ + TAILQ_NEXT((elm), field) = (listelm); \ + *(listelm)->field.tqe_prev = (elm); \ + (listelm)->field.tqe_prev = &TAILQ_NEXT((elm), field); \ } while (0) -#define TAILQ_INSERT_HEAD(head, elm, field) do { \ - if ((TAILQ_NEXT((elm), field) = TAILQ_FIRST((head))) != NULL) \ - TAILQ_FIRST((head))->field.tqe_prev = \ - &TAILQ_NEXT((elm), field); \ - else \ - (head)->tqh_last = &TAILQ_NEXT((elm), field); \ - TAILQ_FIRST((head)) = (elm); \ - (elm)->field.tqe_prev = &TAILQ_FIRST((head)); \ +#define TAILQ_INSERT_HEAD(head, elm, field) do { \ + if ((TAILQ_NEXT((elm), field) = TAILQ_FIRST((head))) != NULL) \ + TAILQ_FIRST((head))->field.tqe_prev = \ + &TAILQ_NEXT((elm), field); \ + else \ + (head)->tqh_last = &TAILQ_NEXT((elm), field); \ + TAILQ_FIRST((head)) = (elm); \ + (elm)->field.tqe_prev = &TAILQ_FIRST((head)); \ } while (0) -#define TAILQ_INSERT_TAIL(head, elm, field) do { \ - TAILQ_NEXT((elm), field) = NULL; \ - (elm)->field.tqe_prev = (head)->tqh_last; \ - *(head)->tqh_last = (elm); \ - (head)->tqh_last = &TAILQ_NEXT((elm), field); \ +#define TAILQ_INSERT_TAIL(head, elm, field) do { \ + TAILQ_NEXT((elm), field) = NULL; \ + (elm)->field.tqe_prev = (head)->tqh_last; \ + *(head)->tqh_last = (elm); \ + (head)->tqh_last = &TAILQ_NEXT((elm), field); \ } while (0) -#define TAILQ_LAST(head, headname) \ - (*(((struct headname *)((head)->tqh_last))->tqh_last)) +#define TAILQ_LAST(head, headname) \ + (*(((struct headname *)((head)->tqh_last))->tqh_last)) -#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next) +#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next) -#define TAILQ_PREV(elm, headname, field) \ - (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last)) +#define TAILQ_PREV(elm, headname, field) \ + (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last)) -#define TAILQ_REMOVE(head, elm, field) do { \ - if ((TAILQ_NEXT((elm), field)) != NULL) \ - TAILQ_NEXT((elm), field)->field.tqe_prev = \ - (elm)->field.tqe_prev; \ - else { \ - (head)->tqh_last = (elm)->field.tqe_prev; \ - } \ - *(elm)->field.tqe_prev = TAILQ_NEXT((elm), field); \ +#define TAILQ_REMOVE(head, elm, field) do { \ + if ((TAILQ_NEXT((elm), field)) != NULL) \ + TAILQ_NEXT((elm), field)->field.tqe_prev = \ + (elm)->field.tqe_prev; \ + else { \ + (head)->tqh_last = (elm)->field.tqe_prev; \ + } \ + *(elm)->field.tqe_prev = TAILQ_NEXT((elm), field); \ } while (0) #endif /* !SYS_QUEUE_H */ diff --git a/libyasm/coretype.h b/libyasm/coretype.h index 624e3c44..d0007a67 100644 --- a/libyasm/coretype.h +++ b/libyasm/coretype.h @@ -2,6 +2,10 @@ * \file libyasm/coretype.h * \brief YASM core types and utility functions. * + * \rcs + * $Id$ + * \endrcs + * * \license * Copyright (C) 2001-2007 Peter Johnson * @@ -30,10 +34,6 @@ #ifndef YASM_CORETYPE_H #define YASM_CORETYPE_H -#ifndef YASM_LIB_DECL -#define YASM_LIB_DECL -#endif - /** Architecture instance (mostly opaque type). \see arch.h for details. */ typedef struct yasm_arch yasm_arch; /** Preprocessor interface. \see preproc.h for details. */ @@ -52,34 +52,19 @@ typedef struct yasm_objfmt_module yasm_objfmt_module; /** Debug format module interface. \see dbgfmt.h for details. */ typedef struct yasm_dbgfmt_module yasm_dbgfmt_module; -/** Standard macro structure for modules that allows association of a set of - * standard macros with a parser/preprocessor combination. - * A NULL-terminated array of these structures is used in a number of module - * interfaces. - */ -typedef struct yasm_stdmac { - const char *parser; /**< Parser keyword */ - const char *preproc; /**< Preprocessor keyword */ - - /** NULL-terminated array of standard macros. May be NULL if no standard - * macros should be added for this preprocessor. - */ - const char **macros; -} yasm_stdmac; - /** YASM associated data callback structure. Many data structures can have * arbitrary data associated with them. */ typedef struct yasm_assoc_data_callback { /** Free memory allocated for associated data. - * \param data associated data + * \param data associated data */ void (*destroy) (/*@only@*/ void *data); /** Print a description of allocated data. For debugging purposes. - * \param data associated data - * \param f output file - * \param indent_level indentation level + * \param data associated data + * \param f output file + * \param indent_level indentation level */ void (*print) (void *data, FILE *f, int indent_level); } yasm_assoc_data_callback; @@ -89,7 +74,10 @@ typedef struct yasm_assoc_data_callback { */ typedef struct yasm_errwarns yasm_errwarns; -/** Bytecode. \see bytecode.h for details and related functions. */ +/** Bytecode (opaque type). + * \see bytecode.h for related functions. + * Define YASM_BC_INTERNAL to get visible internals. + */ typedef struct yasm_bytecode yasm_bytecode; /** Object. \see section.h for details and related functions. */ @@ -104,7 +92,10 @@ typedef struct yasm_symtab yasm_symtab; /** Symbol record (opaque type). \see symrec.h for related functions. */ typedef struct yasm_symrec yasm_symrec; -/** Expression. \see expr.h for details and related functions. */ +/** Expression (opaque type). + * \see expr.h for related functions. + * Define YASM_EXPR_INTERNAL to get visible internals. + */ typedef struct yasm_expr yasm_expr; /** Integer value (opaque type). \see intnum.h for related functions. */ typedef struct yasm_intnum yasm_intnum; @@ -171,9 +162,6 @@ typedef struct yasm_value { */ unsigned int section_rel : 1; - /** Indicates overflow warnings have been disabled for this value. */ - unsigned int no_warn : 1; - /** Sign of the value. Nonzero if the final value should be treated as * signed, 0 if it should be treated as signed. */ @@ -184,7 +172,7 @@ typedef struct yasm_value { } yasm_value; /** Maximum value of #yasm_value.rshift */ -#define YASM_VALUE_RSHIFT_MAX 127 +#define YASM_VALUE_RSHIFT_MAX 127 /** Line number mapping repository (opaque type). \see linemap.h for related * functions. @@ -204,52 +192,48 @@ typedef struct yasm_valparamhead yasm_valparamhead; */ typedef struct yasm_directive yasm_directive; -/** An effective address. - * \see insn.h for related functions. +/** A list of instruction operands (opaque type). + * The list goes from left-to-right as parsed. + * \see arch.h for related functions. */ -typedef struct yasm_effaddr yasm_effaddr; - -/** An instruction. - * \see insn.h for related functions. - */ -typedef struct yasm_insn yasm_insn; +typedef struct yasm_insn_operands yasm_insn_operands; /** Expression operators usable in #yasm_expr expressions. */ typedef enum yasm_expr_op { - YASM_EXPR_IDENT, /**< No operation, just a value. */ - YASM_EXPR_ADD, /**< Arithmetic addition (+). */ - YASM_EXPR_SUB, /**< Arithmetic subtraction (-). */ - YASM_EXPR_MUL, /**< Arithmetic multiplication (*). */ - YASM_EXPR_DIV, /**< Arithmetic unsigned division. */ - YASM_EXPR_SIGNDIV, /**< Arithmetic signed division. */ - YASM_EXPR_MOD, /**< Arithmetic unsigned modulus. */ - YASM_EXPR_SIGNMOD, /**< Arithmetic signed modulus. */ - YASM_EXPR_NEG, /**< Arithmetic negation (-). */ - YASM_EXPR_NOT, /**< Bitwise negation. */ - YASM_EXPR_OR, /**< Bitwise OR. */ - YASM_EXPR_AND, /**< Bitwise AND. */ - YASM_EXPR_XOR, /**< Bitwise XOR. */ - YASM_EXPR_XNOR, /**< Bitwise XNOR. */ - YASM_EXPR_NOR, /**< Bitwise NOR. */ - YASM_EXPR_SHL, /**< Shift left (logical). */ - YASM_EXPR_SHR, /**< Shift right (logical). */ - YASM_EXPR_LOR, /**< Logical OR. */ - YASM_EXPR_LAND, /**< Logical AND. */ - YASM_EXPR_LNOT, /**< Logical negation. */ - YASM_EXPR_LXOR, /**< Logical XOR. */ - YASM_EXPR_LXNOR, /**< Logical XNOR. */ - YASM_EXPR_LNOR, /**< Logical NOR. */ - YASM_EXPR_LT, /**< Less than comparison. */ - YASM_EXPR_GT, /**< Greater than comparison. */ - YASM_EXPR_EQ, /**< Equality comparison. */ - YASM_EXPR_LE, /**< Less than or equal to comparison. */ - YASM_EXPR_GE, /**< Greater than or equal to comparison. */ - YASM_EXPR_NE, /**< Not equal comparison. */ - YASM_EXPR_NONNUM, /**< Start of non-numeric operations (not an op). */ - YASM_EXPR_SEG, /**< SEG operator (gets segment portion of address). */ - YASM_EXPR_WRT, /**< WRT operator (gets offset of address relative to - * some other segment). */ - YASM_EXPR_SEGOFF /**< The ':' in segment:offset. */ + YASM_EXPR_IDENT, /**< No operation, just a value. */ + YASM_EXPR_ADD, /**< Arithmetic addition (+). */ + YASM_EXPR_SUB, /**< Arithmetic subtraction (-). */ + YASM_EXPR_MUL, /**< Arithmetic multiplication (*). */ + YASM_EXPR_DIV, /**< Arithmetic unsigned division. */ + YASM_EXPR_SIGNDIV, /**< Arithmetic signed division. */ + YASM_EXPR_MOD, /**< Arithmetic unsigned modulus. */ + YASM_EXPR_SIGNMOD, /**< Arithmetic signed modulus. */ + YASM_EXPR_NEG, /**< Arithmetic negation (-). */ + YASM_EXPR_NOT, /**< Bitwise negation. */ + YASM_EXPR_OR, /**< Bitwise OR. */ + YASM_EXPR_AND, /**< Bitwise AND. */ + YASM_EXPR_XOR, /**< Bitwise XOR. */ + YASM_EXPR_XNOR, /**< Bitwise XNOR. */ + YASM_EXPR_NOR, /**< Bitwise NOR. */ + YASM_EXPR_SHL, /**< Shift left (logical). */ + YASM_EXPR_SHR, /**< Shift right (logical). */ + YASM_EXPR_LOR, /**< Logical OR. */ + YASM_EXPR_LAND, /**< Logical AND. */ + YASM_EXPR_LNOT, /**< Logical negation. */ + YASM_EXPR_LXOR, /**< Logical XOR. */ + YASM_EXPR_LXNOR, /**< Logical XNOR. */ + YASM_EXPR_LNOR, /**< Logical NOR. */ + YASM_EXPR_LT, /**< Less than comparison. */ + YASM_EXPR_GT, /**< Greater than comparison. */ + YASM_EXPR_EQ, /**< Equality comparison. */ + YASM_EXPR_LE, /**< Less than or equal to comparison. */ + YASM_EXPR_GE, /**< Greater than or equal to comparison. */ + YASM_EXPR_NE, /**< Not equal comparison. */ + YASM_EXPR_NONNUM, /**< Start of non-numeric operations (not an op). */ + YASM_EXPR_SEG, /**< SEG operator (gets segment portion of address). */ + YASM_EXPR_WRT, /**< WRT operator (gets offset of address relative to + * some other segment). */ + YASM_EXPR_SEGOFF /**< The ':' in segment:offset. */ } yasm_expr_op; /** Convert yasm_value to its byte representation. Usually implemented by @@ -257,17 +241,19 @@ typedef enum yasm_expr_op { * Must put the value into the least significant bits of the destination, * unless shifted into more significant bits by the shift parameter. The * destination bits must be cleared before being set. - * \param value value - * \param buf buffer for byte representation - * \param destsize destination size (in bytes) - * \param offset offset (in bytes) of the expr contents from the start - * of the bytecode (needed for relative) - * \param bc current bytecode (usually passed into higher-level - * calling function) - * \param warn enables standard warnings: zero for none; - * nonzero for overflow/underflow floating point warnings - * \param d objfmt-specific data (passed into higher-level calling - * function) + * \param value value + * \param buf buffer for byte representation + * \param destsize destination size (in bytes) + * \param offset offset (in bytes) of the expr contents from the start + * of the bytecode (needed for relative) + * \param bc current bytecode (usually passed into higher-level + * calling function) + * \param warn enables standard warnings: zero for none; + * nonzero for overflow/underflow floating point warnings; + * negative for signed integer warnings, + * positive for unsigned integer warnings + * \param d objfmt-specific data (passed into higher-level calling + * function) * \return Nonzero if an error occurred, 0 otherwise. */ typedef int (*yasm_output_value_func) @@ -277,18 +263,18 @@ typedef int (*yasm_output_value_func) /** Convert a symbol reference to its byte representation. Usually implemented * by object formats and debug formats to keep track of relocations generated * by themselves. - * \param sym symbol - * \param bc current bytecode (usually passed into higher-level - * calling function) - * \param buf buffer for byte representation - * \param destsize destination size (in bytes) - * \param valsize size (in bits) - * \param warn enables standard warnings: zero for none; - * nonzero for overflow/underflow floating point warnings; - * negative for signed integer warnings, - * positive for unsigned integer warnings - * \param d objfmt-specific data (passed into higher-level calling - * function) + * \param sym symbol + * \param bc current bytecode (usually passed into higher-level + * calling function) + * \param buf buffer for byte representation + * \param destsize destination size (in bytes) + * \param valsize size (in bits) + * \param warn enables standard warnings: zero for none; + * nonzero for overflow/underflow floating point warnings; + * negative for signed integer warnings, + * positive for unsigned integer warnings + * \param d objfmt-specific data (passed into higher-level calling + * function) * \return Nonzero if an error occurred, 0 otherwise. */ typedef int (*yasm_output_reloc_func) @@ -297,49 +283,44 @@ typedef int (*yasm_output_reloc_func) /** Sort an array using merge sort algorithm. * \internal - * \param base base of array - * \param nmemb number of elements in array - * \param size size of each array element + * \param base base of array + * \param nmemb number of elements in array + * \param size size of each array element * \param compar element comparison function */ -YASM_LIB_DECL int yasm__mergesort(void *base, size_t nmemb, size_t size, - int (*compar)(const void *, const void *)); + int (*compar)(const void *, const void *)); /** Separate string by delimiters. * \internal * \param stringp string - * \param delim set of 1 or more delimiters + * \param delim set of 1 or more delimiters * \return First/next substring. */ -YASM_LIB_DECL /*@null@*/ char *yasm__strsep(char **stringp, const char *delim); /** Compare two strings, ignoring case differences. * \internal - * \param s1 string 1 - * \param s2 string 2 + * \param s1 string 1 + * \param s2 string 2 * \return 0 if strings are equal, -1 if s1s2. */ -YASM_LIB_DECL int yasm__strcasecmp(const char *s1, const char *s2); /** Compare portion of two strings, ignoring case differences. * \internal - * \param s1 string 1 - * \param s2 string 2 - * \param n maximum number of characters to compare + * \param s1 string 1 + * \param s2 string 2 + * \param n maximum number of characters to compare * \return 0 if strings are equal, -1 if s1s2. */ -YASM_LIB_DECL int yasm__strncasecmp(const char *s1, const char *s2, size_t n); /** strdup() implementation using yasm_xmalloc(). * \internal - * \param str string + * \param str string * \return Newly allocated duplicate string. */ -YASM_LIB_DECL /*@only@*/ char *yasm__xstrdup(const char *str); /** strndup() implementation using yasm_xmalloc(). @@ -348,26 +329,23 @@ YASM_LIB_DECL * \param max maximum number of characters to copy * \return Newly allocated duplicate string. */ -YASM_LIB_DECL /*@only@*/ char *yasm__xstrndup(const char *str, size_t max); /** Error-checking memory allocation. A default implementation is provided * that calls yasm_fatal() on allocation errors. * A replacement should \em never return NULL. - * \param size number of bytes to allocate + * \param size number of bytes to allocate * \return Allocated memory block. */ -YASM_LIB_DECL extern /*@only@*/ /*@out@*/ void * (*yasm_xmalloc) (size_t size); /** Error-checking memory allocation (with clear-to-0). A default * implementation is provided that calls yasm_fatal() on allocation errors. * A replacement should \em never return NULL. - * \param size number of elements to allocate + * \param size number of elements to allocate * \param elsize size (in bytes) of each element * \return Allocated and cleared memory block. */ -YASM_LIB_DECL extern /*@only@*/ void * (*yasm_xcalloc) (size_t nelem, size_t elsize); /** Error-checking memory reallocation. A default implementation is provided @@ -377,16 +355,14 @@ extern /*@only@*/ void * (*yasm_xcalloc) (size_t nelem, size_t elsize); * \param elsize new size, in bytes * \return Re-allocated memory block. */ -YASM_LIB_DECL extern /*@only@*/ void * (*yasm_xrealloc) (/*@only@*/ /*@out@*/ /*@returned@*/ /*@null@*/ void *oldmem, size_t size) /*@modifies oldmem@*/; /** Error-checking memory deallocation. A default implementation is provided * that calls yasm_fatal() on allocation errors. - * \param p memory block to free + * \param p memory block to free */ -YASM_LIB_DECL extern void (*yasm_xfree) (/*@only@*/ /*@out@*/ /*@null@*/ void *p) /*@modifies p@*/; diff --git a/libyasm/dbgfmt.h b/libyasm/dbgfmt.h index 8e038bbf..41d4eac8 100644 --- a/libyasm/dbgfmt.h +++ b/libyasm/dbgfmt.h @@ -2,6 +2,10 @@ * \file libyasm/dbgfmt.h * \brief YASM debug format interface. * + * \rcs + * $Id$ + * \endrcs + * * \license * Copyright (C) 2002-2007 Peter Johnson * @@ -54,7 +58,7 @@ struct yasm_dbgfmt_module { /** Create debug format. * Module-level implementation of yasm_dbgfmt_create(). * The filenames are provided solely for informational purposes. - * \param object object + * \param object object * \return NULL if object format does not provide needed support. */ /*@null@*/ /*@only@*/ yasm_dbgfmt * (*create) (yasm_object *object); @@ -68,7 +72,7 @@ struct yasm_dbgfmt_module { * Call yasm_dbgfmt_generate() instead of calling this function. */ void (*generate) (yasm_object *object, yasm_linemap *linemap, - yasm_errwarns *errwarns); + yasm_errwarns *errwarns); }; /** Get the keyword used to select a debug format. @@ -80,26 +84,26 @@ const char *yasm_dbgfmt_keyword(const yasm_dbgfmt *dbgfmt); /** Initialize debug output for use. Must call before any other debug * format functions. The filenames are provided solely for informational * purposes. - * \param module debug format module - * \param object object to generate debugging information for + * \param module debug format module + * \param object object to generate debugging information for * \return NULL if object format does not provide needed support. */ /*@null@*/ /*@only@*/ yasm_dbgfmt *yasm_dbgfmt_create (const yasm_dbgfmt_module *module, yasm_object *object); /** Cleans up any allocated debug format memory. - * \param dbgfmt debug format + * \param dbgfmt debug format */ void yasm_dbgfmt_destroy(/*@only@*/ yasm_dbgfmt *dbgfmt); /** Generate debugging information bytecodes. - * \param object object - * \param linemap virtual/physical line mapping - * \param errwarns error/warning set + * \param object object + * \param linemap virtual/physical line mapping + * \param errwarns error/warning set * \note Errors and warnings are stored into errwarns. */ void yasm_dbgfmt_generate(yasm_object *object, yasm_linemap *linemap, - yasm_errwarns *errwarns); + yasm_errwarns *errwarns); #ifndef YASM_DOXYGEN @@ -115,7 +119,7 @@ void yasm_dbgfmt_generate(yasm_object *object, yasm_linemap *linemap, ((yasm_dbgfmt_base *)dbgfmt)->module->destroy(dbgfmt) #define yasm_dbgfmt_generate(object, linemap, ews) \ ((yasm_dbgfmt_base *)((object)->dbgfmt))->module->generate \ - (object, linemap, ews) + (object, linemap, ews) #endif diff --git a/libyasm/errwarn.c b/libyasm/errwarn.c index 983e0819..04d8420f 100644 --- a/libyasm/errwarn.c +++ b/libyasm/errwarn.c @@ -24,10 +24,15 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ +#define YASM_LIB_INTERNAL #include "util.h" +/*@unused@*/ RCSID("$Id$"); #include -#include + +#ifdef STDC_HEADERS +# include +#endif #include "coretype.h" @@ -35,11 +40,7 @@ #include "errwarn.h" -#define MSG_MAXSIZE 1024 - -#if !defined(HAVE_TOASCII) || defined(lint) -# define toascii(c) ((c) & 0x7F) -#endif +#define MSG_MAXSIZE 1024 /* Default handlers for replacable functions */ static /*@exits@*/ void def_internal_error_ @@ -68,7 +69,7 @@ typedef struct warn { yasm_warn_class wclass; /*@owned@*/ /*@null@*/ char *wstr; } warn; -static STAILQ_HEAD(warn_head, warn) yasm_warns; +static STAILQ_HEAD(, warn) yasm_warns; /* Enabled warnings. See errwarn.h for a list. */ static unsigned long warn_class_enabled; @@ -85,7 +86,7 @@ typedef struct errwarn_data { } errwarn_data; struct yasm_errwarns { - /*@reldef@*/ SLIST_HEAD(errwarn_head, errwarn_data) errwarns; + /*@reldef@*/ SLIST_HEAD(, errwarn_data) errwarns; /* Total error count */ unsigned int ecount; @@ -111,11 +112,10 @@ void yasm_errwarn_initialize(void) { /* Default enabled warnings. See errwarn.h for a list. */ - warn_class_enabled = - (1UL<previous_we; first = SLIST_FIRST(&errwarns->errwarns); if (!ins_we || !first) - action = INS_HEAD; + action = INS_HEAD; while (action == INS_NONE) { - next = SLIST_NEXT(ins_we, link); - if (line < ins_we->line) { - if (ins_we == first) - action = INS_HEAD; - else - ins_we = first; - } else if (!next) - action = INS_AFTER; - else if (line >= ins_we->line && line < next->line) - action = INS_AFTER; - else - ins_we = next; + next = SLIST_NEXT(ins_we, link); + if (line < ins_we->line) { + if (ins_we == first) + action = INS_HEAD; + else + ins_we = first; + } else if (!next) + action = INS_AFTER; + else if (line >= ins_we->line && line < next->line) + action = INS_AFTER; + else + ins_we = next; } if (replace_parser_error && ins_we && ins_we->type == WE_PARSERERROR) { - /* overwrite last error */ - we = ins_we; + /* overwrite last error */ + we = ins_we; } else { - /* add a new error */ - we = yasm_xmalloc(sizeof(errwarn_data)); + /* add a new error */ + we = yasm_xmalloc(sizeof(errwarn_data)); - we->type = WE_UNKNOWN; - we->line = line; - we->xrefline = 0; - we->msg = NULL; - we->xrefmsg = NULL; + we->type = WE_UNKNOWN; + we->line = line; + we->xrefline = 0; + we->msg = NULL; + we->xrefmsg = NULL; - if (action == INS_HEAD) - SLIST_INSERT_HEAD(&errwarns->errwarns, we, link); - else if (action == INS_AFTER) { - assert(ins_we != NULL); - SLIST_INSERT_AFTER(ins_we, we, link); - } else - yasm_internal_error(N_("Unexpected errwarn insert action")); + if (action == INS_HEAD) + SLIST_INSERT_HEAD(&errwarns->errwarns, we, link); + else if (action == INS_AFTER) { + assert(ins_we != NULL); + SLIST_INSERT_AFTER(ins_we, we, link); + } else + yasm_internal_error(N_("Unexpected errwarn insert action")); } /* Remember previous err/warn */ @@ -248,9 +248,9 @@ void yasm_error_clear(void) { if (yasm_estr) - yasm_xfree(yasm_estr); + yasm_xfree(yasm_estr); if (yasm_exrefstr) - yasm_xfree(yasm_exrefstr); + yasm_xfree(yasm_exrefstr); yasm_eclass = YASM_ERROR_NONE; yasm_estr = NULL; yasm_exrefline = 0; @@ -261,9 +261,9 @@ int yasm_error_matches(yasm_error_class eclass) { if (yasm_eclass == YASM_ERROR_NONE) - return eclass == YASM_ERROR_NONE; + return eclass == YASM_ERROR_NONE; if (yasm_eclass == YASM_ERROR_GENERAL) - return eclass == YASM_ERROR_GENERAL; + return eclass == YASM_ERROR_GENERAL; return (yasm_eclass & eclass) == eclass; } @@ -271,7 +271,7 @@ void yasm_error_set_va(yasm_error_class eclass, const char *format, va_list va) { if (yasm_eclass != YASM_ERROR_NONE) - return; + return; yasm_eclass = eclass; yasm_estr = yasm_xmalloc(MSG_MAXSIZE+1); @@ -295,7 +295,7 @@ void yasm_error_set_xref_va(unsigned long xrefline, const char *format, va_list va) { if (yasm_eclass != YASM_ERROR_NONE) - return; + return; yasm_exrefline = xrefline; @@ -318,7 +318,7 @@ yasm_error_set_xref(unsigned long xrefline, const char *format, ...) void yasm_error_fetch(yasm_error_class *eclass, char **str, unsigned long *xrefline, - char **xrefstr) + char **xrefstr) { *eclass = yasm_eclass; *str = yasm_estr; @@ -334,13 +334,13 @@ void yasm_warn_clear(void) { /* Delete all error/warnings */ while (!STAILQ_EMPTY(&yasm_warns)) { - warn *w = STAILQ_FIRST(&yasm_warns); + warn *w = STAILQ_FIRST(&yasm_warns); - if (w->wstr) - yasm_xfree(w->wstr); + if (w->wstr) + yasm_xfree(w->wstr); - STAILQ_REMOVE_HEAD(&yasm_warns, link); - yasm_xfree(w); + STAILQ_REMOVE_HEAD(&yasm_warns, link); + yasm_xfree(w); } } @@ -348,7 +348,7 @@ yasm_warn_class yasm_warn_occurred(void) { if (STAILQ_EMPTY(&yasm_warns)) - return YASM_WARN_NONE; + return YASM_WARN_NONE; return STAILQ_FIRST(&yasm_warns)->wclass; } @@ -358,7 +358,7 @@ yasm_warn_set_va(yasm_warn_class wclass, const char *format, va_list va) warn *w; if (!(warn_class_enabled & (1UL<wclass = wclass; @@ -386,9 +386,9 @@ yasm_warn_fetch(yasm_warn_class *wclass, char **str) warn *w = STAILQ_FIRST(&yasm_warns); if (!w) { - *wclass = YASM_WARN_NONE; - *str = NULL; - return; + *wclass = YASM_WARN_NONE; + *str = NULL; + return; } *wclass = w->wclass; @@ -434,14 +434,14 @@ yasm_errwarns_destroy(yasm_errwarns *errwarns) /* Delete all error/warnings */ while (!SLIST_EMPTY(&errwarns->errwarns)) { - we = SLIST_FIRST(&errwarns->errwarns); - if (we->msg) - yasm_xfree(we->msg); - if (we->xrefmsg) - yasm_xfree(we->xrefmsg); + we = SLIST_FIRST(&errwarns->errwarns); + if (we->msg) + yasm_xfree(we->msg); + if (we->xrefmsg) + yasm_xfree(we->xrefmsg); - SLIST_REMOVE_HEAD(&errwarns->errwarns, link); - yasm_xfree(we); + SLIST_REMOVE_HEAD(&errwarns->errwarns, link); + yasm_xfree(we); } yasm_xfree(errwarns); @@ -451,25 +451,25 @@ void yasm_errwarn_propagate(yasm_errwarns *errwarns, unsigned long line) { if (yasm_eclass != YASM_ERROR_NONE) { - errwarn_data *we = errwarn_data_new(errwarns, line, 1); - yasm_error_class eclass; + errwarn_data *we = errwarn_data_new(errwarns, line, 1); + yasm_error_class eclass; - yasm_error_fetch(&eclass, &we->msg, &we->xrefline, &we->xrefmsg); - if (eclass != YASM_ERROR_GENERAL - && (eclass & YASM_ERROR_PARSE) == YASM_ERROR_PARSE) - we->type = WE_PARSERERROR; - else - we->type = WE_ERROR; - errwarns->ecount++; + yasm_error_fetch(&eclass, &we->msg, &we->xrefline, &we->xrefmsg); + if (eclass != YASM_ERROR_GENERAL + && (eclass & YASM_ERROR_PARSE) == YASM_ERROR_PARSE) + we->type = WE_PARSERERROR; + else + we->type = WE_ERROR; + errwarns->ecount++; } while (!STAILQ_EMPTY(&yasm_warns)) { - errwarn_data *we = errwarn_data_new(errwarns, line, 0); - yasm_warn_class wclass; + errwarn_data *we = errwarn_data_new(errwarns, line, 0); + yasm_warn_class wclass; - yasm_warn_fetch(&wclass, &we->msg); - we->type = WE_WARNING; - errwarns->wcount++; + yasm_warn_fetch(&wclass, &we->msg); + we->type = WE_WARNING; + errwarns->wcount++; } } @@ -477,46 +477,44 @@ unsigned int yasm_errwarns_num_errors(yasm_errwarns *errwarns, int warning_as_error) { if (warning_as_error) - return errwarns->ecount+errwarns->wcount; + return errwarns->ecount+errwarns->wcount; else - return errwarns->ecount; + return errwarns->ecount; } void yasm_errwarns_output_all(yasm_errwarns *errwarns, yasm_linemap *lm, - int warning_as_error, - yasm_print_error_func print_error, - yasm_print_warning_func print_warning) + int warning_as_error, + yasm_print_error_func print_error, + yasm_print_warning_func print_warning) { errwarn_data *we; const char *filename, *xref_filename; unsigned long line, xref_line; + /* If we're treating warnings as errors, tell the user about it. */ + if (warning_as_error && warning_as_error != 2) { + print_error("", 0, + yasm_gettext_hook(N_("warnings being treated as errors")), + NULL, 0, NULL); + warning_as_error = 2; + } + /* Output error/warnings. */ SLIST_FOREACH(we, &errwarns->errwarns, link) { - /* Output error/warning */ - yasm_linemap_lookup(lm, we->line, &filename, &line); - if (we->xrefline) - yasm_linemap_lookup(lm, we->xrefline, &xref_filename, &xref_line); - else { - xref_filename = NULL; - xref_line = 0; - } - if (we->type == WE_ERROR || we->type == WE_PARSERERROR) - print_error(filename, line, we->msg, xref_filename, xref_line, - we->xrefmsg); - else - { - print_warning(filename, line, we->msg); - - /* If we're treating warnings as errors, tell the user about it. */ - if (warning_as_error && warning_as_error != 2) { - const char *msg = - yasm_gettext_hook(N_("warnings being treated as errors")); - print_error(filename, line, msg, NULL, 0, NULL); - warning_as_error = 2; - } - } + /* Output error/warning */ + yasm_linemap_lookup(lm, we->line, &filename, &line); + if (we->xrefline) + yasm_linemap_lookup(lm, we->xrefline, &xref_filename, &xref_line); + else { + xref_filename = NULL; + xref_line = 0; + } + if (we->type == WE_ERROR || we->type == WE_PARSERERROR) + print_error(filename, line, we->msg, xref_filename, xref_line, + we->xrefmsg); + else + print_warning(filename, line, we->msg); } } diff --git a/libyasm/errwarn.h b/libyasm/errwarn.h index 25f68226..c83626ea 100644 --- a/libyasm/errwarn.h +++ b/libyasm/errwarn.h @@ -2,6 +2,10 @@ * \file libyasm/errwarn.h * \brief YASM error and warning reporting interface. * + * \rcs + * $Id$ + * \endrcs + * * \license * Copyright (C) 2001-2007 Peter Johnson * @@ -30,52 +34,44 @@ #ifndef YASM_ERRWARN_H #define YASM_ERRWARN_H -#ifndef YASM_LIB_DECL -#define YASM_LIB_DECL -#endif - /** Warning classes (that may be enabled/disabled). */ typedef enum yasm_warn_class { - YASM_WARN_NONE = 0, /**< No warning */ - YASM_WARN_GENERAL, /**< Non-specific warnings */ + YASM_WARN_NONE = 0, /**< No warning */ + YASM_WARN_GENERAL, /**< Non-specific warnings */ YASM_WARN_UNREC_CHAR, /**< Unrecognized characters (while tokenizing) */ - YASM_WARN_PREPROC, /**< Preprocessor warnings */ + YASM_WARN_PREPROC, /**< Preprocessor warnings */ YASM_WARN_ORPHAN_LABEL, /**< Label alone on a line without a colon */ YASM_WARN_UNINIT_CONTENTS, /**< Uninitialized space in code/data section */ - YASM_WARN_SIZE_OVERRIDE,/**< Double size override */ - YASM_WARN_IMPLICIT_SIZE_OVERRIDE, /**< Implicit size override */ - YASM_WARN_SEGREG_IN_64BIT /**< Segment register ignored in 64-bit mode */ + YASM_WARN_SIZE_OVERRIDE /**< Double size override */ } yasm_warn_class; /** Error classes. Bitmask-based to support limited subclassing. */ typedef enum yasm_error_class { - YASM_ERROR_NONE = 0x0000, /**< No error */ - YASM_ERROR_GENERAL = 0xFFFF, /**< Non-specific */ - YASM_ERROR_ARITHMETIC = 0x0001, /**< Arithmetic error (general) */ - YASM_ERROR_OVERFLOW = 0x8001, /**< Arithmetic overflow */ - YASM_ERROR_FLOATING_POINT = 0x4001, /**< Floating point error */ - YASM_ERROR_ZERO_DIVISION = 0x2001, /**< Divide-by-zero */ - YASM_ERROR_ASSERTION = 0x0002, /**< Assertion error */ - YASM_ERROR_VALUE = 0x0004, /**< Value inappropriate - * (e.g. not in range) */ - YASM_ERROR_NOT_ABSOLUTE = 0x8004, /**< Absolute expression required */ - YASM_ERROR_TOO_COMPLEX = 0x4004, /**< Expression too complex */ - YASM_ERROR_NOT_CONSTANT = 0x2004, /**< Constant expression required */ - YASM_ERROR_IO = 0x0008, /**< I/O error */ - YASM_ERROR_NOT_IMPLEMENTED = 0x0010, /**< Not implemented error */ - YASM_ERROR_TYPE = 0x0020, /**< Type error */ - YASM_ERROR_SYNTAX = 0x0040, /**< Syntax error */ - YASM_ERROR_PARSE = 0x8040 /**< Parser error */ + YASM_ERROR_NONE = 0x0000, /**< No error */ + YASM_ERROR_GENERAL = 0xFFFF, /**< Non-specific */ + YASM_ERROR_ARITHMETIC = 0x0001, /**< Arithmetic error (general) */ + YASM_ERROR_OVERFLOW = 0x8001, /**< Arithmetic overflow */ + YASM_ERROR_FLOATING_POINT = 0x4001, /**< Floating point error */ + YASM_ERROR_ZERO_DIVISION = 0x2001, /**< Divide-by-zero */ + YASM_ERROR_ASSERTION = 0x0002, /**< Assertion error */ + YASM_ERROR_VALUE = 0x0004, /**< Value inappropriate + * (e.g. not in range) */ + YASM_ERROR_NOT_ABSOLUTE = 0x8004, /**< Absolute expression required */ + YASM_ERROR_TOO_COMPLEX = 0x4004, /**< Expression too complex */ + YASM_ERROR_NOT_CONSTANT = 0x2004, /**< Constant expression required */ + YASM_ERROR_IO = 0x0008, /**< I/O error */ + YASM_ERROR_NOT_IMPLEMENTED = 0x0010, /**< Not implemented error */ + YASM_ERROR_TYPE = 0x0020, /**< Type error */ + YASM_ERROR_SYNTAX = 0x0040, /**< Syntax error */ + YASM_ERROR_PARSE = 0x8040 /**< Parser error */ } yasm_error_class; /** Initialize any internal data structures. */ -YASM_LIB_DECL void yasm_errwarn_initialize(void); /** Clean up any memory allocated by yasm_errwarn_initialize() or other * functions. */ -YASM_LIB_DECL void yasm_errwarn_cleanup(void); /** Reporting point of internal errors. These are usually due to sanity @@ -86,7 +82,6 @@ void yasm_errwarn_cleanup(void); * \param line source line (ala __LINE__) * \param message internal error message */ -YASM_LIB_DECL extern /*@exits@*/ void (*yasm_internal_error_) (const char *file, unsigned int line, const char *message); @@ -101,24 +96,21 @@ extern /*@exits@*/ void (*yasm_internal_error_) * \warning This function must NOT return to calling code; exit or longjmp * instead. * \param message fatal error message - * \param va va_list argument list for message + * \param va va_list argument list for message */ -YASM_LIB_DECL extern /*@exits@*/ void (*yasm_fatal) (const char *message, va_list va); /** Reporting point of fatal errors, with variable arguments (internal only). * \warning This function calls #yasm_fatal, and thus does not return to the * calling code. * \param message fatal error message - * \param ... argument list for message + * \param ... argument list for message */ -YASM_LIB_DECL /*@exits@*/ void yasm__fatal(const char *message, ...); /** Unconditionally clear the error indicator, freeing any associated data. * Has no effect if the error indicator is not set. */ -YASM_LIB_DECL void yasm_error_clear(void); /** Get the error indicator. YASM_ERROR_NONE is returned if no error has @@ -135,31 +127,27 @@ yasm_error_class yasm_error_occurred(void); * \return Nonzero if error indicator is set and a subclass of eclass, 0 * otherwise. */ -YASM_LIB_DECL int yasm_error_matches(yasm_error_class eclass); #ifndef YASM_DOXYGEN -YASM_LIB_DECL extern yasm_error_class yasm_eclass; -#define yasm_error_occurred() yasm_eclass +#define yasm_error_occurred() yasm_eclass #endif /** Set the error indicator (va_list version). Has no effect if the error * indicator is already set. * \param eclass error class * \param format printf format string - * \param va argument list for format + * \param va argument list for format */ -YASM_LIB_DECL void yasm_error_set_va(yasm_error_class eclass, const char *format, va_list va); /** Set the error indicator. Has no effect if the error indicator is already * set. * \param eclass error class * \param format printf format string - * \param ... argument list for format + * \param ... argument list for format */ -YASM_LIB_DECL void yasm_error_set(yasm_error_class eclass, const char *format, ...) /*@printflike@*/; @@ -168,20 +156,18 @@ void yasm_error_set(yasm_error_class eclass, const char *format, ...) * function must be called prior to its corresponding yasm_error_set() call. * \param xrefline virtual line to cross-reference to (should not be 0) * \param format printf format string - * \param va argument list for format + * \param va argument list for format */ -YASM_LIB_DECL void yasm_error_set_xref_va(unsigned long xrefline, const char *format, - va_list va); + va_list va); /** Set a cross-reference for a new error. Has no effect if the error * indicator is already set (e.g. with yasm_error_set()). This function * must be called prior to its corresponding yasm_error_set() call. * \param xrefline virtual line to cross-reference to (should not be 0) * \param format printf format string - * \param ... argument list for format + * \param ... argument list for format */ -YASM_LIB_DECL void yasm_error_set_xref(unsigned long xrefline, const char *format, ...) /*@printflike@*/; @@ -193,20 +179,18 @@ void yasm_error_set_xref(unsigned long xrefline, const char *format, ...) * all output values are set to 0 (including eclass, which is set to * YASM_ERROR_NONE). * \param eclass error class (output) - * \param str error message + * \param str error message * \param xrefline virtual line used for cross-referencing (0 if no xref) * \param xrefstr cross-reference error message (NULL if no xref) */ -YASM_LIB_DECL void yasm_error_fetch(/*@out@*/ yasm_error_class *eclass, - /*@out@*/ /*@only@*/ /*@null@*/ char **str, - /*@out@*/ unsigned long *xrefline, - /*@out@*/ /*@only@*/ /*@null@*/ char **xrefstr); + /*@out@*/ /*@only@*/ /*@null@*/ char **str, + /*@out@*/ unsigned long *xrefline, + /*@out@*/ /*@only@*/ /*@null@*/ char **xrefstr); /** Unconditionally clear all warning indicators, freeing any associated data. * Has no effect if no warning indicators have been set. */ -YASM_LIB_DECL void yasm_warn_clear(void); /** Get the first warning indicator. YASM_WARN_NONE is returned if no warning @@ -214,23 +198,20 @@ void yasm_warn_clear(void); * be treated as a boolean value. * \return First warning indicator. */ -YASM_LIB_DECL yasm_warn_class yasm_warn_occurred(void); /** Add a warning indicator (va_list version). * \param wclass warning class * \param format printf format string - * \param va argument list for format + * \param va argument list for format */ -YASM_LIB_DECL void yasm_warn_set_va(yasm_warn_class wclass, const char *format, va_list va); /** Add a warning indicator. * \param wclass warning class * \param format printf format string - * \param ... argument list for format + * \param ... argument list for format */ -YASM_LIB_DECL void yasm_warn_set(yasm_warn_class wclass, const char *format, ...) /*@printflike@*/; @@ -242,38 +223,32 @@ void yasm_warn_set(yasm_warn_class wclass, const char *format, ...) * all output values are set to 0 (including wclass, which is set to * YASM_WARN_NONE). * \param wclass warning class (output) - * \param str warning message + * \param str warning message */ -YASM_LIB_DECL void yasm_warn_fetch(/*@out@*/ yasm_warn_class *wclass, - /*@out@*/ /*@only@*/ char **str); + /*@out@*/ /*@only@*/ char **str); /** Enable a class of warnings. * \param wclass warning class */ -YASM_LIB_DECL void yasm_warn_enable(yasm_warn_class wclass); /** Disable a class of warnings. * \param wclass warning class */ -YASM_LIB_DECL void yasm_warn_disable(yasm_warn_class wclass); /** Disable all classes of warnings. */ -YASM_LIB_DECL void yasm_warn_disable_all(void); /** Create an error/warning set for collection of multiple error/warnings. * \return Newly allocated set. */ -YASM_LIB_DECL /*@only@*/ yasm_errwarns *yasm_errwarns_create(void); /** Destroy an error/warning set. * \param errwarns error/warning set */ -YASM_LIB_DECL void yasm_errwarns_destroy(/*@only@*/ yasm_errwarns *errwarns); /** Propagate error indicator and warning indicator(s) to an error/warning set. @@ -286,25 +261,23 @@ void yasm_errwarns_destroy(/*@only@*/ yasm_errwarns *errwarns); * \param errwarns error/warning set * \param line virtual line */ -YASM_LIB_DECL void yasm_errwarn_propagate(yasm_errwarns *errwarns, unsigned long line); /** Get total number of errors logged. - * \param errwarns error/warning set + * \param errwarns error/warning set * \param warning_as_error if nonzero, warnings are treated as errors. * \return Number of errors. */ -YASM_LIB_DECL unsigned int yasm_errwarns_num_errors(yasm_errwarns *errwarns, - int warning_as_error); + int warning_as_error); /** Print out an error. - * \param fn filename of source file - * \param line line number - * \param msg error message - * \param xref_fn cross-referenced source filename - * \param xref_line cross-referenced line number - * \param xref_msg cross-referenced error message + * \param fn filename of source file + * \param line line number + * \param msg error message + * \param xref_fn cross-referenced source filename + * \param xref_line cross-referenced line number + * \param xref_msg cross-referenced error message */ typedef void (*yasm_print_error_func) (const char *fn, unsigned long line, const char *msg, @@ -312,38 +285,35 @@ typedef void (*yasm_print_error_func) /*@null@*/ const char *xref_msg); /** Print out a warning. - * \param fn filename of source file - * \param line line number - * \param msg warning message + * \param fn filename of source file + * \param line line number + * \param msg warning message */ typedef void (*yasm_print_warning_func) (const char *fn, unsigned long line, const char *msg); /** Outputs error/warning set in sorted order (sorted by virtual line number). - * \param errwarns error/warning set - * \param lm line map (to convert virtual lines into filename/line pairs) + * \param errwarns error/warning set + * \param lm line map (to convert virtual lines into filename/line pairs) * \param warning_as_error if nonzero, treat warnings as errors. - * \param print_error function called to print out errors - * \param print_warning function called to print out warnings + * \param print_error function called to print out errors + * \param print_warning function called to print out warnings */ -YASM_LIB_DECL void yasm_errwarns_output_all (yasm_errwarns *errwarns, yasm_linemap *lm, int warning_as_error, yasm_print_error_func print_error, yasm_print_warning_func print_warning); /** Convert a possibly unprintable character into a printable string. * \internal - * \param ch possibly unprintable character + * \param ch possibly unprintable character * \return Printable string representation (static buffer). */ -YASM_LIB_DECL char *yasm__conv_unprint(int ch); /** Hook for library users to map to gettext() if GNU gettext is being used. - * \param msgid message catalog identifier + * \param msgid message catalog identifier * \return Translated message. */ -YASM_LIB_DECL extern const char * (*yasm_gettext_hook) (const char *msgid); #endif diff --git a/libyasm/expr-int.h b/libyasm/expr-int.h new file mode 100644 index 00000000..4a3abd9b --- /dev/null +++ b/libyasm/expr-int.h @@ -0,0 +1,118 @@ +/* $Id$ + * Expressions internal structures header file + * + * Copyright (C) 2001-2007 Peter Johnson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND OTHER CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR OTHER CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef YASM_EXPR_INT_H +#define YASM_EXPR_INT_H + +/* Types listed in canonical sorting order. See expr_order_terms(). + * Note precbc must be used carefully (in a-b pairs), as only symrecs can + * become the relative term in a #yasm_value. + */ +typedef enum yasm_expr__type { + YASM_EXPR_NONE = 0, + YASM_EXPR_REG = 1<<0, + YASM_EXPR_INT = 1<<1, + YASM_EXPR_SUBST = 1<<2, + YASM_EXPR_FLOAT = 1<<3, + YASM_EXPR_SYM = 1<<4, + YASM_EXPR_PRECBC = 1<<5, /* direct bytecode ref (rather than via symrec) */ + YASM_EXPR_EXPR = 1<<6 +} yasm_expr__type; + +struct yasm_expr__item { + yasm_expr__type type; + union { + yasm_bytecode *precbc; + yasm_symrec *sym; + yasm_expr *expn; + yasm_intnum *intn; + yasm_floatnum *flt; + uintptr_t reg; + unsigned int subst; + } data; +}; + +/* Some operations may allow more than two operand terms: + * ADD, MUL, OR, AND, XOR + */ +struct yasm_expr { + yasm_expr_op op; + unsigned long line; + int numterms; + yasm_expr__item terms[2]; /* structure may be extended to include more */ +}; + +/* Traverse over expression tree in order, calling func for each leaf + * (non-operation). The data pointer d is passed to each func call. + * + * Stops early (and returns 1) if func returns 1. Otherwise returns 0. + */ +int yasm_expr__traverse_leaves_in_const + (const yasm_expr *e, /*@null@*/ void *d, + int (*func) (/*@null@*/ const yasm_expr__item *ei, /*@null@*/ void *d)); +int yasm_expr__traverse_leaves_in + (yasm_expr *e, /*@null@*/ void *d, + int (*func) (/*@null@*/ yasm_expr__item *ei, /*@null@*/ void *d)); + +/* Reorder terms of e into canonical order. Only reorders if reordering + * doesn't change meaning of expression. (eg, doesn't reorder SUB). + * Canonical order: REG, INT, FLOAT, SYM, EXPR. + * Multiple terms of a single type are kept in the same order as in + * the original expression. + * NOTE: Only performs reordering on *one* level (no recursion). + */ +void yasm_expr__order_terms(yasm_expr *e); + +/* Copy entire expression EXCEPT for index "except" at *top level only*. */ +yasm_expr *yasm_expr__copy_except(const yasm_expr *e, int except); + +int yasm_expr__contains(const yasm_expr *e, yasm_expr__type t); + +/** Transform symrec-symrec terms in expression into YASM_EXPR_SUBST items. + * Calls the callback function for each symrec-symrec term. + * \param ep expression (pointer to) + * \param cbd callback data passed to callback function + * \param callback callback function: given subst index for bytecode + * pair, bytecode pair (bc2-bc1), and cbd (callback data) + * \return Number of transformations made. + */ +int yasm_expr__bc_dist_subst(yasm_expr **ep, void *cbd, + void (*callback) (unsigned int subst, + yasm_bytecode *precbc, + yasm_bytecode *precbc2, + void *cbd)); + +/** Substitute items into expr YASM_EXPR_SUBST items (by index). Items are + * copied, so caller is responsible for freeing array of items. + * \param e expression + * \param num_items number of items in items array + * \param items items array + * \return 1 on error (index out of range). + */ +int yasm_expr__subst(yasm_expr *e, unsigned int num_items, + const yasm_expr__item *items); + +#endif diff --git a/libyasm/expr.c b/libyasm/expr.c index 09ae1121..42ab312f 100644 --- a/libyasm/expr.c +++ b/libyasm/expr.c @@ -24,7 +24,9 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ +#define YASM_LIB_INTERNAL #include "util.h" +/*@unused@*/ RCSID("$Id$"); #include "libyasm-stdint.h" #include "coretype.h" @@ -41,14 +43,13 @@ #include "arch.h" +#include "expr-int.h" + -static /*@only@*/ yasm_expr *expr_level_op - (/*@returned@*/ /*@only@*/ yasm_expr *e, int fold_const, - int simplify_ident, int simplify_reg_mul); static int expr_traverse_nodes_post(/*@null@*/ yasm_expr *e, - /*@null@*/ void *d, - int (*func) (/*@null@*/ yasm_expr *e, - /*@null@*/ void *d)); + /*@null@*/ void *d, + int (*func) (/*@null@*/ yasm_expr *e, + /*@null@*/ void *d)); static void expr_delete_term(yasm_expr__item *term, int recurse); /* Bitmap of used items. We should really never need more than 2 at a time, @@ -62,7 +63,7 @@ static yasm_expr__item itempool[31]; /*@-compmempass@*/ yasm_expr * yasm_expr_create(yasm_expr_op op, yasm_expr__item *left, - yasm_expr__item *right, unsigned long line) + yasm_expr__item *right, unsigned long line) { yasm_expr *ptr, *sube; unsigned long z; @@ -73,52 +74,52 @@ yasm_expr_create(yasm_expr_op op, yasm_expr__item *left, ptr->terms[0].type = YASM_EXPR_NONE; ptr->terms[1].type = YASM_EXPR_NONE; if (left) { - ptr->terms[0] = *left; /* structure copy */ - z = (unsigned long)(left-itempool); - if (z>=31) - yasm_internal_error(N_("could not find expritem in pool")); - itempool_used &= ~(1<numterms++; + ptr->terms[0] = *left; /* structure copy */ + z = (unsigned long)(left-itempool); + if (z>=31) + yasm_internal_error(N_("could not find expritem in pool")); + itempool_used &= ~(1<numterms++; - /* Search downward until we find something *other* than an - * IDENT, then bring it up to the current level. - */ - while (ptr->terms[0].type == YASM_EXPR_EXPR && - ptr->terms[0].data.expn->op == YASM_EXPR_IDENT) { - sube = ptr->terms[0].data.expn; - ptr->terms[0] = sube->terms[0]; /* structure copy */ - /*@-usereleased@*/ - yasm_xfree(sube); - /*@=usereleased@*/ - } + /* Search downward until we find something *other* than an + * IDENT, then bring it up to the current level. + */ + while (ptr->terms[0].type == YASM_EXPR_EXPR && + ptr->terms[0].data.expn->op == YASM_EXPR_IDENT) { + sube = ptr->terms[0].data.expn; + ptr->terms[0] = sube->terms[0]; /* structure copy */ + /*@-usereleased@*/ + yasm_xfree(sube); + /*@=usereleased@*/ + } } else { - yasm_internal_error(N_("Right side of expression must exist")); + yasm_internal_error(N_("Right side of expression must exist")); } if (right) { - ptr->terms[1] = *right; /* structure copy */ - z = (unsigned long)(right-itempool); - if (z>=31) - yasm_internal_error(N_("could not find expritem in pool")); - itempool_used &= ~(1<numterms++; + ptr->terms[1] = *right; /* structure copy */ + z = (unsigned long)(right-itempool); + if (z>=31) + yasm_internal_error(N_("could not find expritem in pool")); + itempool_used &= ~(1<numterms++; - /* Search downward until we find something *other* than an - * IDENT, then bring it up to the current level. - */ - while (ptr->terms[1].type == YASM_EXPR_EXPR && - ptr->terms[1].data.expn->op == YASM_EXPR_IDENT) { - sube = ptr->terms[1].data.expn; - ptr->terms[1] = sube->terms[0]; /* structure copy */ - /*@-usereleased@*/ - yasm_xfree(sube); - /*@=usereleased@*/ - } + /* Search downward until we find something *other* than an + * IDENT, then bring it up to the current level. + */ + while (ptr->terms[1].type == YASM_EXPR_EXPR && + ptr->terms[1].data.expn->op == YASM_EXPR_IDENT) { + sube = ptr->terms[1].data.expn; + ptr->terms[1] = sube->terms[0]; /* structure copy */ + /*@-usereleased@*/ + yasm_xfree(sube); + /*@=usereleased@*/ + } } ptr->line = line; - return expr_level_op(ptr, 1, 1, 0); + return ptr; } /*@=compmempass@*/ @@ -130,11 +131,11 @@ expr_get_item(void) unsigned long v = itempool_used & 0x7fffffff; while (v & 1) { - v >>= 1; - z++; + v >>= 1; + z++; } if (z>=31) - yasm_internal_error(N_("too many expritems")); + yasm_internal_error(N_("too many expritems")); itempool_used |= 1<op != YASM_EXPR_ADD) - return e; + return e; for (i=0; inumterms; i++) { - int j; - yasm_expr *sube; - yasm_intnum *intn; - yasm_symrec *sym = NULL; - /*@dependent@*/ yasm_section *sect2; - /*@dependent@*/ /*@null@*/ yasm_bytecode *precbc2; + int j; + yasm_expr *sube; + yasm_intnum *intn; + yasm_symrec *sym = NULL; + /*@dependent@*/ yasm_section *sect2; + /*@dependent@*/ /*@null@*/ yasm_bytecode *precbc2; - /* First look for an (-1*symrec) term */ - if (e->terms[i].type != YASM_EXPR_EXPR) - continue; - sube = e->terms[i].data.expn; - if (sube->op != YASM_EXPR_MUL || sube->numterms != 2) - continue; + /* First look for an (-1*symrec) term */ + if (e->terms[i].type != YASM_EXPR_EXPR) + continue; + sube = e->terms[i].data.expn; + if (sube->op != YASM_EXPR_MUL || sube->numterms != 2) + continue; - if (sube->terms[0].type == YASM_EXPR_INT && - (sube->terms[1].type == YASM_EXPR_SYM || - sube->terms[1].type == YASM_EXPR_PRECBC)) { - intn = sube->terms[0].data.intn; - if (sube->terms[1].type == YASM_EXPR_PRECBC) - precbc = sube->terms[1].data.precbc; - else - sym = sube->terms[1].data.sym; - } else if ((sube->terms[0].type == YASM_EXPR_SYM || - sube->terms[0].type == YASM_EXPR_PRECBC) && - sube->terms[1].type == YASM_EXPR_INT) { - if (sube->terms[0].type == YASM_EXPR_PRECBC) - precbc = sube->terms[0].data.precbc; - else - sym = sube->terms[0].data.sym; - intn = sube->terms[1].data.intn; - } else - continue; + if (sube->terms[0].type == YASM_EXPR_INT && + (sube->terms[1].type == YASM_EXPR_SYM || + sube->terms[1].type == YASM_EXPR_PRECBC)) { + intn = sube->terms[0].data.intn; + if (sube->terms[1].type == YASM_EXPR_PRECBC) + precbc = sube->terms[1].data.precbc; + else + sym = sube->terms[1].data.sym; + } else if ((sube->terms[0].type == YASM_EXPR_SYM || + sube->terms[0].type == YASM_EXPR_PRECBC) && + sube->terms[1].type == YASM_EXPR_INT) { + if (sube->terms[0].type == YASM_EXPR_PRECBC) + precbc = sube->terms[0].data.precbc; + else + sym = sube->terms[0].data.sym; + intn = sube->terms[1].data.intn; + } else + continue; - if (!yasm_intnum_is_neg1(intn)) - continue; + if (!yasm_intnum_is_neg1(intn)) + continue; - if (sym && !yasm_symrec_get_label(sym, &precbc)) - continue; - sect2 = yasm_bc_get_section(precbc); + if (sym && !yasm_symrec_get_label(sym, &precbc)) + continue; + sect2 = yasm_bc_get_section(precbc); - /* Now look for a symrec term in the same segment */ - for (j=0; jnumterms; j++) { - if (((e->terms[j].type == YASM_EXPR_SYM && - yasm_symrec_get_label(e->terms[j].data.sym, &precbc2)) || - (e->terms[j].type == YASM_EXPR_PRECBC && - (precbc2 = e->terms[j].data.precbc))) && - (sect = yasm_bc_get_section(precbc2)) && - sect == sect2 && - callback(&e->terms[j], precbc, precbc2, cbd)) { - /* Delete the matching (-1*symrec) term */ - yasm_expr_destroy(sube); - e->terms[i].type = YASM_EXPR_NONE; - break; /* stop looking for matching symrec term */ - } - } + /* Now look for a symrec term in the same segment */ + for (j=0; jnumterms; j++) { + if (((e->terms[j].type == YASM_EXPR_SYM && + yasm_symrec_get_label(e->terms[j].data.sym, &precbc2)) || + (e->terms[j].type == YASM_EXPR_PRECBC && + (precbc2 = e->terms[j].data.precbc))) && + (sect = yasm_bc_get_section(precbc2)) && + sect == sect2 && + callback(&e->terms[j], precbc, precbc2, cbd)) { + /* Delete the matching (-1*symrec) term */ + yasm_expr_destroy(sube); + e->terms[i].type = YASM_EXPR_NONE; + break; /* stop looking for matching symrec term */ + } + } } /* Clean up any deleted (EXPR_NONE) terms */ numterms = 0; for (i=0; inumterms; i++) { - if (e->terms[i].type != YASM_EXPR_NONE) - e->terms[numterms++] = e->terms[i]; /* structure copy */ + if (e->terms[i].type != YASM_EXPR_NONE) + e->terms[numterms++] = e->terms[i]; /* structure copy */ } if (e->numterms != numterms) { - e->numterms = numterms; - e = yasm_xrealloc(e, sizeof(yasm_expr)+((numterms<2) ? 0 : - sizeof(yasm_expr__item)*(numterms-2))); - if (numterms == 1) - e->op = YASM_EXPR_IDENT; + e->numterms = numterms; + e = yasm_xrealloc(e, sizeof(yasm_expr)+((numterms<2) ? 0 : + sizeof(yasm_expr__item)*(numterms-2))); + if (numterms == 1) + e->op = YASM_EXPR_IDENT; } return e; @@ -294,11 +295,11 @@ expr_xform_bc_dist_base(/*@returned@*/ /*@only@*/ yasm_expr *e, static int expr_xform_bc_dist_cb(yasm_expr__item *ei, yasm_bytecode *precbc, - yasm_bytecode *precbc2, /*@null@*/ void *d) + yasm_bytecode *precbc2, /*@null@*/ void *d) { yasm_intnum *dist = yasm_calc_bc_dist(precbc, precbc2); if (!dist) - return 0; + return 0; /* Change the term to an integer */ ei->type = YASM_EXPR_INT; ei->data.intn = dist; @@ -316,14 +317,14 @@ expr_xform_bc_dist(/*@returned@*/ /*@only@*/ yasm_expr *e) typedef struct bc_dist_subst_cbd { void (*callback) (unsigned int subst, yasm_bytecode *precbc, - yasm_bytecode *precbc2, void *cbd); + yasm_bytecode *precbc2, void *cbd); void *cbd; unsigned int subst; } bc_dist_subst_cbd; static int expr_bc_dist_subst_cb(yasm_expr__item *ei, yasm_bytecode *precbc, - yasm_bytecode *precbc2, /*@null@*/ void *d) + yasm_bytecode *precbc2, /*@null@*/ void *d) { bc_dist_subst_cbd *my_cbd = d; assert(my_cbd != NULL); @@ -344,17 +345,17 @@ expr_xform_bc_dist_subst(yasm_expr *e, void *d) int yasm_expr__bc_dist_subst(yasm_expr **ep, void *cbd, - void (*callback) (unsigned int subst, - yasm_bytecode *precbc, - yasm_bytecode *precbc2, - void *cbd)) + void (*callback) (unsigned int subst, + yasm_bytecode *precbc, + yasm_bytecode *precbc2, + void *cbd)) { - bc_dist_subst_cbd my_cbd; /* callback info for low-level callback */ + bc_dist_subst_cbd my_cbd; /* callback info for low-level callback */ my_cbd.callback = callback; my_cbd.cbd = cbd; my_cbd.subst = 0; *ep = yasm_expr__level_tree(*ep, 1, 1, 1, 0, &expr_xform_bc_dist_subst, - &my_cbd); + &my_cbd); return my_cbd.subst; } @@ -370,7 +371,7 @@ expr_xform_neg_item(yasm_expr *e, yasm_expr__item *ei) sube->numterms = 2; sube->terms[0].type = YASM_EXPR_INT; sube->terms[0].data.intn = yasm_intnum_create_int(-1); - sube->terms[1] = *ei; /* structure copy */ + sube->terms[1] = *ei; /* structure copy */ /* Replace original ExprItem with subexp */ ei->type = YASM_EXPR_EXPR; @@ -390,60 +391,58 @@ expr_xform_neg_helper(/*@returned@*/ /*@only@*/ yasm_expr *e) int i; switch (e->op) { - case YASM_EXPR_ADD: - /* distribute (recursively if expr) over terms */ - for (i=0; inumterms; i++) { - if (e->terms[i].type == YASM_EXPR_EXPR) - e->terms[i].data.expn = - expr_xform_neg_helper(e->terms[i].data.expn); - else - expr_xform_neg_item(e, &e->terms[i]); - } - break; - case YASM_EXPR_SUB: - /* change op to ADD, and recursively negate left side (if expr) */ - e->op = YASM_EXPR_ADD; - if (e->terms[0].type == YASM_EXPR_EXPR) - e->terms[0].data.expn = - expr_xform_neg_helper(e->terms[0].data.expn); - else - expr_xform_neg_item(e, &e->terms[0]); - break; - case YASM_EXPR_NEG: - /* Negating a negated value? Make it an IDENT. */ - e->op = YASM_EXPR_IDENT; - break; - case YASM_EXPR_IDENT: - /* Negating an ident? Change it into a MUL w/ -1 if there's no - * floatnums present below; if there ARE floatnums, recurse. - */ - if (e->terms[0].type == YASM_EXPR_FLOAT) - yasm_floatnum_calc(e->terms[0].data.flt, YASM_EXPR_NEG, NULL); - else if (e->terms[0].type == YASM_EXPR_INT) - yasm_intnum_calc(e->terms[0].data.intn, YASM_EXPR_NEG, NULL); - else if (e->terms[0].type == YASM_EXPR_EXPR && - yasm_expr__contains(e->terms[0].data.expn, YASM_EXPR_FLOAT)) - expr_xform_neg_helper(e->terms[0].data.expn); - else { - e->op = YASM_EXPR_MUL; - e->numterms = 2; - e->terms[1].type = YASM_EXPR_INT; - e->terms[1].data.intn = yasm_intnum_create_int(-1); - } - break; - default: - /* Everything else. MUL will be combined when it's leveled. - * Make a new expr (to replace e) with -1*e. - */ - ne = yasm_xmalloc(sizeof(yasm_expr)); - ne->op = YASM_EXPR_MUL; - ne->line = e->line; - ne->numterms = 2; - ne->terms[0].type = YASM_EXPR_INT; - ne->terms[0].data.intn = yasm_intnum_create_int(-1); - ne->terms[1].type = YASM_EXPR_EXPR; - ne->terms[1].data.expn = e; - return ne; + case YASM_EXPR_ADD: + /* distribute (recursively if expr) over terms */ + for (i=0; inumterms; i++) { + if (e->terms[i].type == YASM_EXPR_EXPR) + e->terms[i].data.expn = + expr_xform_neg_helper(e->terms[i].data.expn); + else + expr_xform_neg_item(e, &e->terms[i]); + } + break; + case YASM_EXPR_SUB: + /* change op to ADD, and recursively negate left side (if expr) */ + e->op = YASM_EXPR_ADD; + if (e->terms[0].type == YASM_EXPR_EXPR) + e->terms[0].data.expn = + expr_xform_neg_helper(e->terms[0].data.expn); + else + expr_xform_neg_item(e, &e->terms[0]); + break; + case YASM_EXPR_NEG: + /* Negating a negated value? Make it an IDENT. */ + e->op = YASM_EXPR_IDENT; + break; + case YASM_EXPR_IDENT: + /* Negating an ident? Change it into a MUL w/ -1 if there's no + * floatnums present below; if there ARE floatnums, recurse. + */ + if (e->terms[0].type == YASM_EXPR_FLOAT) + yasm_floatnum_calc(e->terms[0].data.flt, YASM_EXPR_NEG, NULL); + else if (e->terms[0].type == YASM_EXPR_EXPR && + yasm_expr__contains(e->terms[0].data.expn, YASM_EXPR_FLOAT)) + expr_xform_neg_helper(e->terms[0].data.expn); + else { + e->op = YASM_EXPR_MUL; + e->numterms = 2; + e->terms[1].type = YASM_EXPR_INT; + e->terms[1].data.intn = yasm_intnum_create_int(-1); + } + break; + default: + /* Everything else. MUL will be combined when it's leveled. + * Make a new expr (to replace e) with -1*e. + */ + ne = yasm_xmalloc(sizeof(yasm_expr)); + ne->op = YASM_EXPR_MUL; + ne->line = e->line; + ne->numterms = 2; + ne->terms[0].type = YASM_EXPR_INT; + ne->terms[0].data.intn = yasm_intnum_create_int(-1); + ne->terms[1].type = YASM_EXPR_EXPR; + ne->terms[1].data.expn = e; + return ne; } return e; } @@ -460,23 +459,23 @@ static /*@only@*/ yasm_expr * expr_xform_neg(/*@returned@*/ /*@only@*/ yasm_expr *e) { switch (e->op) { - case YASM_EXPR_NEG: - /* Turn -x into -1*x */ - e->op = YASM_EXPR_IDENT; - return expr_xform_neg_helper(e); - case YASM_EXPR_SUB: - /* Turn a-b into a+(-1*b) */ + case YASM_EXPR_NEG: + /* Turn -x into -1*x */ + e->op = YASM_EXPR_IDENT; + return expr_xform_neg_helper(e); + case YASM_EXPR_SUB: + /* Turn a-b into a+(-1*b) */ - /* change op to ADD, and recursively negate right side (if expr) */ - e->op = YASM_EXPR_ADD; - if (e->terms[1].type == YASM_EXPR_EXPR) - e->terms[1].data.expn = - expr_xform_neg_helper(e->terms[1].data.expn); - else - expr_xform_neg_item(e, &e->terms[1]); - break; - default: - break; + /* change op to ADD, and recursively negate right side (if expr) */ + e->op = YASM_EXPR_ADD; + if (e->terms[1].type == YASM_EXPR_EXPR) + e->terms[1].data.expn = + expr_xform_neg_helper(e->terms[1].data.expn); + else + expr_xform_neg_item(e, &e->terms[1]); + break; + default: + break; } return e; @@ -490,9 +489,9 @@ expr_is_constant(yasm_expr_op op, yasm_intnum *intn) { int iszero = yasm_intnum_is_zero(intn); return ((iszero && op == YASM_EXPR_MUL) || - (iszero && op == YASM_EXPR_AND) || - (iszero && op == YASM_EXPR_LAND) || - (yasm_intnum_is_neg1(intn) && op == YASM_EXPR_OR)); + (iszero && op == YASM_EXPR_AND) || + (iszero && op == YASM_EXPR_LAND) || + (yasm_intnum_is_neg1(intn) && op == YASM_EXPR_OR)); } /* Look for simple "left" identities like 0+x, 1*x, etc. */ @@ -501,11 +500,11 @@ expr_can_destroy_int_left(yasm_expr_op op, yasm_intnum *intn) { int iszero = yasm_intnum_is_zero(intn); return ((yasm_intnum_is_pos1(intn) && op == YASM_EXPR_MUL) || - (iszero && op == YASM_EXPR_ADD) || - (yasm_intnum_is_neg1(intn) && op == YASM_EXPR_AND) || - (!iszero && op == YASM_EXPR_LAND) || - (iszero && op == YASM_EXPR_OR) || - (iszero && op == YASM_EXPR_LOR)); + (iszero && op == YASM_EXPR_ADD) || + (yasm_intnum_is_neg1(intn) && op == YASM_EXPR_AND) || + (!iszero && op == YASM_EXPR_LAND) || + (iszero && op == YASM_EXPR_OR) || + (iszero && op == YASM_EXPR_LOR)); } /* Look for simple "right" identities like x+|-0, x*&/1 */ @@ -515,15 +514,15 @@ expr_can_destroy_int_right(yasm_expr_op op, yasm_intnum *intn) int iszero = yasm_intnum_is_zero(intn); int ispos1 = yasm_intnum_is_pos1(intn); return ((ispos1 && op == YASM_EXPR_MUL) || - (ispos1 && op == YASM_EXPR_DIV) || - (iszero && op == YASM_EXPR_ADD) || - (iszero && op == YASM_EXPR_SUB) || - (yasm_intnum_is_neg1(intn) && op == YASM_EXPR_AND) || - (!iszero && op == YASM_EXPR_LAND) || - (iszero && op == YASM_EXPR_OR) || - (iszero && op == YASM_EXPR_LOR) || - (iszero && op == YASM_EXPR_SHL) || - (iszero && op == YASM_EXPR_SHR)); + (ispos1 && op == YASM_EXPR_DIV) || + (iszero && op == YASM_EXPR_ADD) || + (iszero && op == YASM_EXPR_SUB) || + (yasm_intnum_is_neg1(intn) && op == YASM_EXPR_AND) || + (!iszero && op == YASM_EXPR_LAND) || + (iszero && op == YASM_EXPR_OR) || + (iszero && op == YASM_EXPR_LOR) || + (iszero && op == YASM_EXPR_SHL) || + (iszero && op == YASM_EXPR_SHR)); } /* Check for and simplify identities. Returns new number of expr terms. @@ -534,8 +533,8 @@ expr_can_destroy_int_right(yasm_expr_op op, yasm_intnum *intn) * NOTE: Really designed to only be used by expr_level_op(). */ static int -expr_simplify_identity(yasm_expr *e, int numterms, int *int_term, - int simplify_reg_mul) +expr_simplify_identity(yasm_expr *e, int numterms, int int_term, + int simplify_reg_mul) { int i; int save_numterms; @@ -546,58 +545,57 @@ expr_simplify_identity(yasm_expr *e, int numterms, int *int_term, save_numterms = e->numterms; e->numterms = numterms; if (simplify_reg_mul || e->op != YASM_EXPR_MUL - || !yasm_intnum_is_pos1(e->terms[*int_term].data.intn) - || !yasm_expr__contains(e, YASM_EXPR_REG)) { - /* Check for simple identities that delete the intnum. - * Don't delete if the intnum is the only thing in the expn. - */ - if ((*int_term == 0 && numterms > 1 && - expr_can_destroy_int_left(e->op, e->terms[0].data.intn)) || - (*int_term > 0 && - expr_can_destroy_int_right(e->op, - e->terms[*int_term].data.intn))) { - /* Delete the intnum */ - yasm_intnum_destroy(e->terms[*int_term].data.intn); + || !yasm_intnum_is_pos1(e->terms[int_term].data.intn) + || !yasm_expr__contains(e, YASM_EXPR_REG)) { + /* Check for simple identities that delete the intnum. + * Don't delete if the intnum is the only thing in the expn. + */ + if ((int_term == 0 && numterms > 1 && + expr_can_destroy_int_left(e->op, e->terms[0].data.intn)) || + (int_term > 0 && + expr_can_destroy_int_right(e->op, e->terms[int_term].data.intn))) { + /* Delete the intnum */ + yasm_intnum_destroy(e->terms[int_term].data.intn); - /* Slide everything to its right over by 1 */ - if (*int_term != numterms-1) /* if it wasn't last.. */ - memmove(&e->terms[*int_term], &e->terms[*int_term+1], - (numterms-1-*int_term)*sizeof(yasm_expr__item)); + /* Slide everything to its right over by 1 */ + if (int_term != numterms-1) /* if it wasn't last.. */ + memmove(&e->terms[int_term], &e->terms[int_term+1], + (numterms-1-int_term)*sizeof(yasm_expr__item)); - /* Update numterms */ - numterms--; - *int_term = -1; /* no longer an int term */ - } + /* Update numterms */ + numterms--; + int_term = -1; /* no longer an int term */ + } } e->numterms = save_numterms; /* Check for simple identites that delete everything BUT the intnum. * Don't bother if the intnum is the only thing in the expn. */ - if (numterms > 1 && *int_term != -1 && - expr_is_constant(e->op, e->terms[*int_term].data.intn)) { - /* Loop through, deleting everything but the integer term */ - for (i=0; inumterms; i++) - if (i != *int_term) - expr_delete_term(&e->terms[i], 1); + if (numterms > 1 && int_term != -1 && + expr_is_constant(e->op, e->terms[int_term].data.intn)) { + /* Loop through, deleting everything but the integer term */ + for (i=0; inumterms; i++) + if (i != int_term) + expr_delete_term(&e->terms[i], 1); - /* Move integer term to the first term (if not already there) */ - if (*int_term != 0) - e->terms[0] = e->terms[*int_term]; /* structure copy */ + /* Move integer term to the first term (if not already there) */ + if (int_term != 0) + e->terms[0] = e->terms[int_term]; /* structure copy */ - /* Set numterms to 1 */ - numterms = 1; + /* Set numterms to 1 */ + numterms = 1; } /* Compute NOT, NEG, and LNOT on single intnum. */ - if (numterms == 1 && *int_term == 0 && - (e->op == YASM_EXPR_NOT || e->op == YASM_EXPR_NEG || - e->op == YASM_EXPR_LNOT)) - yasm_intnum_calc(e->terms[0].data.intn, e->op, NULL); + if (numterms == 1 && int_term == 0 && + (e->op == YASM_EXPR_NOT || e->op == YASM_EXPR_NEG || + e->op == YASM_EXPR_LNOT)) + yasm_intnum_calc(e->terms[0].data.intn, e->op, NULL); /* Change expression to IDENT if possible. */ if (numterms == 1) - e->op = YASM_EXPR_IDENT; + e->op = YASM_EXPR_IDENT; /* Return the updated numterms */ return numterms; @@ -617,7 +615,7 @@ expr_simplify_identity(yasm_expr *e, int numterms, int *int_term, /*@-mustfree@*/ static /*@only@*/ yasm_expr * expr_level_op(/*@returned@*/ /*@only@*/ yasm_expr *e, int fold_const, - int simplify_ident, int simplify_reg_mul) + int simplify_ident, int simplify_reg_mul) { int i, j, o, fold_numterms, level_numterms, level_fold_numterms; int first_int_term = -1; @@ -626,51 +624,51 @@ expr_level_op(/*@returned@*/ /*@only@*/ yasm_expr *e, int fold_const, * Go ahead and bring up any IDENT'ed values. */ while (e->op == YASM_EXPR_IDENT && e->terms[0].type == YASM_EXPR_EXPR) { - yasm_expr *sube = e->terms[0].data.expn; - yasm_xfree(e); - e = sube; + yasm_expr *sube = e->terms[0].data.expn; + yasm_xfree(e); + e = sube; } /* If non-numeric expression, don't fold constants. */ if (e->op > YASM_EXPR_NONNUM) - fold_const = 0; + fold_const = 0; level_numterms = e->numterms; level_fold_numterms = 0; for (i=0; inumterms; i++) { - /* Search downward until we find something *other* than an - * IDENT, then bring it up to the current level. - */ - while (e->terms[i].type == YASM_EXPR_EXPR && - e->terms[i].data.expn->op == YASM_EXPR_IDENT) { - yasm_expr *sube = e->terms[i].data.expn; - e->terms[i] = sube->terms[0]; - yasm_xfree(sube); - } + /* Search downward until we find something *other* than an + * IDENT, then bring it up to the current level. + */ + while (e->terms[i].type == YASM_EXPR_EXPR && + e->terms[i].data.expn->op == YASM_EXPR_IDENT) { + yasm_expr *sube = e->terms[i].data.expn; + e->terms[i] = sube->terms[0]; + yasm_xfree(sube); + } - if (e->terms[i].type == YASM_EXPR_EXPR && - e->terms[i].data.expn->op == e->op) { - /* It's an expression w/the same operator, add in its numterms. - * But don't forget to subtract one for the expr itself! - */ - level_numterms += e->terms[i].data.expn->numterms - 1; + if (e->terms[i].type == YASM_EXPR_EXPR && + e->terms[i].data.expn->op == e->op) { + /* It's an expression w/the same operator, add in its numterms. + * But don't forget to subtract one for the expr itself! + */ + level_numterms += e->terms[i].data.expn->numterms - 1; - /* If we're folding constants, count up the number of constants - * that will be merged in. - */ - if (fold_const) - for (j=0; jterms[i].data.expn->numterms; j++) - if (e->terms[i].data.expn->terms[j].type == - YASM_EXPR_INT) - level_fold_numterms++; - } + /* If we're folding constants, count up the number of constants + * that will be merged in. + */ + if (fold_const) + for (j=0; jterms[i].data.expn->numterms; j++) + if (e->terms[i].data.expn->terms[j].type == + YASM_EXPR_INT) + level_fold_numterms++; + } - /* Find the first integer term (if one is present) if we're folding - * constants. - */ - if (fold_const && first_int_term == -1 && - e->terms[i].type == YASM_EXPR_INT) - first_int_term = i; + /* Find the first integer term (if one is present) if we're folding + * constants. + */ + if (fold_const && first_int_term == -1 && + e->terms[i].type == YASM_EXPR_INT) + first_int_term = i; } /* Look for other integer terms if there's one and combine. @@ -679,122 +677,120 @@ expr_level_op(/*@returned@*/ /*@only@*/ yasm_expr *e, int fold_const, */ fold_numterms = e->numterms; if (first_int_term != -1) { - for (i=first_int_term+1, o=first_int_term+1; inumterms; i++) { - if (e->terms[i].type == YASM_EXPR_INT) { - yasm_intnum_calc(e->terms[first_int_term].data.intn, e->op, - e->terms[i].data.intn); - fold_numterms--; - level_numterms--; - /* make sure to delete folded intnum */ - yasm_intnum_destroy(e->terms[i].data.intn); - e->terms[i].data.intn = NULL; - } else if (o != i) { - /* copy term if it changed places */ - e->terms[o++] = e->terms[i]; - } else - o++; - } + for (i=first_int_term+1, o=first_int_term+1; inumterms; i++) { + if (e->terms[i].type == YASM_EXPR_INT) { + yasm_intnum_calc(e->terms[first_int_term].data.intn, e->op, + e->terms[i].data.intn); + fold_numterms--; + level_numterms--; + /* make sure to delete folded intnum */ + yasm_intnum_destroy(e->terms[i].data.intn); + } else if (o != i) { + /* copy term if it changed places */ + e->terms[o++] = e->terms[i]; + } else + o++; + } - if (simplify_ident) { - int new_fold_numterms; - /* Simplify identities and make IDENT if possible. */ - new_fold_numterms = - expr_simplify_identity(e, fold_numterms, &first_int_term, - simplify_reg_mul); - level_numterms -= fold_numterms-new_fold_numterms; - fold_numterms = new_fold_numterms; - } - if (fold_numterms == 1) - e->op = YASM_EXPR_IDENT; + if (simplify_ident) { + int new_fold_numterms; + /* Simplify identities and make IDENT if possible. */ + new_fold_numterms = + expr_simplify_identity(e, fold_numterms, first_int_term, + simplify_reg_mul); + level_numterms -= fold_numterms-new_fold_numterms; + fold_numterms = new_fold_numterms; + } + if (fold_numterms == 1) + e->op = YASM_EXPR_IDENT; } /* Only level operators that allow more than two operand terms. * Also don't bother leveling if it's not necessary to bring up any terms. */ if ((e->op != YASM_EXPR_ADD && e->op != YASM_EXPR_MUL && - e->op != YASM_EXPR_OR && e->op != YASM_EXPR_AND && - e->op != YASM_EXPR_LOR && e->op != YASM_EXPR_LAND && - e->op != YASM_EXPR_LXOR && e->op != YASM_EXPR_XOR) || - level_numterms <= fold_numterms) { - /* Downsize e if necessary */ - if (fold_numterms < e->numterms && e->numterms > 2) - e = yasm_xrealloc(e, sizeof(yasm_expr)+((fold_numterms<2) ? 0 : - sizeof(yasm_expr__item)*(fold_numterms-2))); - /* Update numterms */ - e->numterms = fold_numterms; - return e; + e->op != YASM_EXPR_OR && e->op != YASM_EXPR_AND && + e->op != YASM_EXPR_LOR && e->op != YASM_EXPR_LAND && + e->op != YASM_EXPR_LXOR && e->op != YASM_EXPR_XOR) || + level_numterms <= fold_numterms) { + /* Downsize e if necessary */ + if (fold_numterms < e->numterms && e->numterms > 2) + e = yasm_xrealloc(e, sizeof(yasm_expr)+((fold_numterms<2) ? 0 : + sizeof(yasm_expr__item)*(fold_numterms-2))); + /* Update numterms */ + e->numterms = fold_numterms; + return e; } /* Adjust numterms for constant folding from terms being "pulled up". * Careful: if there's no integer term in e, then save space for it. */ if (fold_const) { - level_numterms -= level_fold_numterms; - if (first_int_term == -1 && level_fold_numterms != 0) - level_numterms++; + level_numterms -= level_fold_numterms; + if (first_int_term == -1 && level_fold_numterms != 0) + level_numterms++; } /* Alloc more (or conceivably less, but not usually) space for e */ e = yasm_xrealloc(e, sizeof(yasm_expr)+((level_numterms<2) ? 0 : - sizeof(yasm_expr__item)*(level_numterms-2))); + sizeof(yasm_expr__item)*(level_numterms-2))); /* Copy up ExprItem's. Iterate from right to left to keep the same * ordering as was present originally. * Combine integer terms as necessary. */ - for (i=fold_numterms-1, o=level_numterms-1; i>=0; i--) { - if (e->terms[i].type == YASM_EXPR_EXPR && - e->terms[i].data.expn->op == e->op) { - /* bring up subexpression */ - yasm_expr *sube = e->terms[i].data.expn; + for (i=e->numterms-1, o=level_numterms-1; i>=0; i--) { + if (e->terms[i].type == YASM_EXPR_EXPR && + e->terms[i].data.expn->op == e->op) { + /* bring up subexpression */ + yasm_expr *sube = e->terms[i].data.expn; - /* copy terms right to left */ - for (j=sube->numterms-1; j>=0; j--) { - if (fold_const && sube->terms[j].type == YASM_EXPR_INT) { - /* Need to fold it in.. but if there's no int term already, - * just copy into a new one. - */ - if (first_int_term == -1) { - first_int_term = o--; - e->terms[first_int_term] = sube->terms[j]; /* struc */ - } else { - yasm_intnum_calc(e->terms[first_int_term].data.intn, - e->op, sube->terms[j].data.intn); - /* make sure to delete folded intnum */ - yasm_intnum_destroy(sube->terms[j].data.intn); - } - } else { - if (o == first_int_term) - o--; - e->terms[o--] = sube->terms[j]; /* structure copy */ - } - } + /* copy terms right to left */ + for (j=sube->numterms-1; j>=0; j--) { + if (fold_const && sube->terms[j].type == YASM_EXPR_INT) { + /* Need to fold it in.. but if there's no int term already, + * just copy into a new one. + */ + if (first_int_term == -1) { + first_int_term = o--; + e->terms[first_int_term] = sube->terms[j]; /* struc */ + } else { + yasm_intnum_calc(e->terms[first_int_term].data.intn, + e->op, sube->terms[j].data.intn); + /* make sure to delete folded intnum */ + yasm_intnum_destroy(sube->terms[j].data.intn); + } + } else { + if (o == first_int_term) + o--; + e->terms[o--] = sube->terms[j]; /* structure copy */ + } + } - /* delete subexpression, but *don't delete nodes* (as we've just - * copied them!) - */ - yasm_xfree(sube); - } else if (o != i) { - /* copy operand if it changed places */ - if (o == first_int_term) - o--; - e->terms[o] = e->terms[i]; - /* If we moved the first_int_term, change first_int_num too */ - if (i == first_int_term) - first_int_term = o; - o--; - } else - o--; + /* delete subexpression, but *don't delete nodes* (as we've just + * copied them!) + */ + yasm_xfree(sube); + } else if (o != i) { + /* copy operand if it changed places */ + if (o == first_int_term) + o--; + e->terms[o] = e->terms[i]; + /* If we moved the first_int_term, change first_int_num too */ + if (i == first_int_term) + first_int_term = o; + o--; + } } /* Simplify identities, make IDENT if possible, and save to e->numterms. */ if (simplify_ident && first_int_term != -1) { - e->numterms = expr_simplify_identity(e, level_numterms, - &first_int_term, simplify_reg_mul); + e->numterms = expr_simplify_identity(e, level_numterms, + first_int_term, simplify_reg_mul); } else { - e->numterms = level_numterms; - if (level_numterms == 1) - e->op = YASM_EXPR_IDENT; + e->numterms = level_numterms; + if (level_numterms == 1) + e->op = YASM_EXPR_IDENT; } return e; @@ -815,33 +811,33 @@ expr_expand_equ(yasm_expr *e, yasm__exprhead *eh) /* traverse terms */ for (i=0; inumterms; i++) { - const yasm_expr *equ_expr; + const yasm_expr *equ_expr; - /* Expand equ's. */ - if (e->terms[i].type == YASM_EXPR_SYM && - (equ_expr = yasm_symrec_get_equ(e->terms[i].data.sym))) { - yasm__exprentry *np; + /* Expand equ's. */ + if (e->terms[i].type == YASM_EXPR_SYM && + (equ_expr = yasm_symrec_get_equ(e->terms[i].data.sym))) { + yasm__exprentry *np; - /* Check for circular reference */ - SLIST_FOREACH(np, eh, next) { - if (np->e == equ_expr) { - yasm_error_set(YASM_ERROR_TOO_COMPLEX, - N_("circular reference detected")); - return e; - } - } + /* Check for circular reference */ + SLIST_FOREACH(np, eh, next) { + if (np->e == equ_expr) { + yasm_error_set(YASM_ERROR_TOO_COMPLEX, + N_("circular reference detected")); + return e; + } + } - e->terms[i].type = YASM_EXPR_EXPR; - e->terms[i].data.expn = yasm_expr_copy(equ_expr); + e->terms[i].type = YASM_EXPR_EXPR; + e->terms[i].data.expn = yasm_expr_copy(equ_expr); - /* Remember we saw this equ and recurse */ - ee.e = equ_expr; - SLIST_INSERT_HEAD(eh, &ee, next); - e->terms[i].data.expn = expr_expand_equ(e->terms[i].data.expn, eh); - SLIST_REMOVE_HEAD(eh, next); - } else if (e->terms[i].type == YASM_EXPR_EXPR) - /* Recurse */ - e->terms[i].data.expn = expr_expand_equ(e->terms[i].data.expn, eh); + /* Remember we saw this equ and recurse */ + ee.e = equ_expr; + SLIST_INSERT_HEAD(eh, &ee, next); + e->terms[i].data.expn = expr_expand_equ(e->terms[i].data.expn, eh); + SLIST_REMOVE_HEAD(eh, next); + } else if (e->terms[i].type == YASM_EXPR_EXPR) + /* Recurse */ + e->terms[i].data.expn = expr_expand_equ(e->terms[i].data.expn, eh); } return e; @@ -849,9 +845,9 @@ expr_expand_equ(yasm_expr *e, yasm__exprhead *eh) static yasm_expr * expr_level_tree(yasm_expr *e, int fold_const, int simplify_ident, - int simplify_reg_mul, int calc_bc_dist, - yasm_expr_xform_func expr_xform_extra, - void *expr_xform_extra_data) + int simplify_reg_mul, int calc_bc_dist, + yasm_expr_xform_func expr_xform_extra, + void *expr_xform_extra_data) { int i; @@ -859,33 +855,32 @@ expr_level_tree(yasm_expr *e, int fold_const, int simplify_ident, /* traverse terms */ for (i=0; inumterms; i++) { - /* Recurse */ - if (e->terms[i].type == YASM_EXPR_EXPR) - e->terms[i].data.expn = - expr_level_tree(e->terms[i].data.expn, fold_const, - simplify_ident, simplify_reg_mul, calc_bc_dist, - expr_xform_extra, expr_xform_extra_data); + /* Recurse */ + if (e->terms[i].type == YASM_EXPR_EXPR) + e->terms[i].data.expn = + expr_level_tree(e->terms[i].data.expn, fold_const, + simplify_ident, simplify_reg_mul, calc_bc_dist, + expr_xform_extra, expr_xform_extra_data); } /* Check for SEG of SEG:OFF, if we match, simplify to just the segment */ if (e->op == YASM_EXPR_SEG && e->terms[0].type == YASM_EXPR_EXPR && - e->terms[0].data.expn->op == YASM_EXPR_SEGOFF) { - e->op = YASM_EXPR_IDENT; - e->terms[0].data.expn->op = YASM_EXPR_IDENT; - /* Destroy the second (offset) term */ - e->terms[0].data.expn->numterms = 1; - expr_delete_term(&e->terms[0].data.expn->terms[1], 1); + e->terms[0].data.expn->op == YASM_EXPR_SEGOFF) { + e->op = YASM_EXPR_IDENT; + e->terms[0].data.expn->op = YASM_EXPR_IDENT; + /* Destroy the second (offset) term */ + expr_delete_term(&e->terms[1], 1); } /* do callback */ e = expr_level_op(e, fold_const, simplify_ident, simplify_reg_mul); if (calc_bc_dist || expr_xform_extra) { - if (calc_bc_dist) - e = expr_xform_bc_dist(e); - if (expr_xform_extra) - e = expr_xform_extra(e, expr_xform_extra_data); - e = expr_level_tree(e, fold_const, simplify_ident, simplify_reg_mul, - 0, NULL, NULL); + if (calc_bc_dist) + e = expr_xform_bc_dist(e); + if (expr_xform_extra) + e = expr_xform_extra(e, expr_xform_extra_data); + e = expr_level_tree(e, fold_const, simplify_ident, simplify_reg_mul, + 0, NULL, NULL); } return e; } @@ -893,19 +888,19 @@ expr_level_tree(yasm_expr *e, int fold_const, int simplify_ident, /* Level an entire expn tree, expanding equ's as we go */ yasm_expr * yasm_expr__level_tree(yasm_expr *e, int fold_const, int simplify_ident, - int simplify_reg_mul, int calc_bc_dist, - yasm_expr_xform_func expr_xform_extra, - void *expr_xform_extra_data) + int simplify_reg_mul, int calc_bc_dist, + yasm_expr_xform_func expr_xform_extra, + void *expr_xform_extra_data) { yasm__exprhead eh; SLIST_INIT(&eh); if (!e) - return 0; + return 0; e = expr_expand_equ(e, &eh); e = expr_level_tree(e, fold_const, simplify_ident, simplify_reg_mul, - calc_bc_dist, expr_xform_extra, expr_xform_extra_data); + calc_bc_dist, expr_xform_extra, expr_xform_extra_data); return e; } @@ -932,27 +927,27 @@ yasm_expr__order_terms(yasm_expr *e) { /* don't bother reordering if only one element */ if (e->numterms == 1) - return; + return; /* only reorder some types of operations */ switch (e->op) { - case YASM_EXPR_ADD: - case YASM_EXPR_MUL: - case YASM_EXPR_OR: - case YASM_EXPR_AND: - case YASM_EXPR_XOR: - case YASM_EXPR_LOR: - case YASM_EXPR_LAND: - case YASM_EXPR_LXOR: - /* Use mergesort to sort. It's fast on already sorted values and a - * stable sort (multiple terms of same type are kept in the same - * order). - */ - yasm__mergesort(e->terms, (size_t)e->numterms, - sizeof(yasm_expr__item), expr_order_terms_compare); - break; - default: - break; + case YASM_EXPR_ADD: + case YASM_EXPR_MUL: + case YASM_EXPR_OR: + case YASM_EXPR_AND: + case YASM_EXPR_XOR: + case YASM_EXPR_LOR: + case YASM_EXPR_LAND: + case YASM_EXPR_LXOR: + /* Use mergesort to sort. It's fast on already sorted values and a + * stable sort (multiple terms of same type are kept in the same + * order). + */ + yasm__mergesort(e->terms, (size_t)e->numterms, + sizeof(yasm_expr__item), expr_order_terms_compare); + break; + default: + break; } } @@ -961,31 +956,31 @@ expr_item_copy(yasm_expr__item *dest, const yasm_expr__item *src) { dest->type = src->type; switch (src->type) { - case YASM_EXPR_SYM: - /* Symbols don't need to be copied */ - dest->data.sym = src->data.sym; - break; - case YASM_EXPR_PRECBC: - /* Nor do direct bytecode references */ - dest->data.precbc = src->data.precbc; - break; - case YASM_EXPR_EXPR: - dest->data.expn = yasm_expr__copy_except(src->data.expn, -1); - break; - case YASM_EXPR_INT: - dest->data.intn = yasm_intnum_copy(src->data.intn); - break; - case YASM_EXPR_FLOAT: - dest->data.flt = yasm_floatnum_copy(src->data.flt); - break; - case YASM_EXPR_REG: - dest->data.reg = src->data.reg; - break; - case YASM_EXPR_SUBST: - dest->data.subst = src->data.subst; - break; - default: - break; + case YASM_EXPR_SYM: + /* Symbols don't need to be copied */ + dest->data.sym = src->data.sym; + break; + case YASM_EXPR_PRECBC: + /* Nor do direct bytecode references */ + dest->data.precbc = src->data.precbc; + break; + case YASM_EXPR_EXPR: + dest->data.expn = yasm_expr__copy_except(src->data.expn, -1); + break; + case YASM_EXPR_INT: + dest->data.intn = yasm_intnum_copy(src->data.intn); + break; + case YASM_EXPR_FLOAT: + dest->data.flt = yasm_floatnum_copy(src->data.flt); + break; + case YASM_EXPR_REG: + dest->data.reg = src->data.reg; + break; + case YASM_EXPR_SUBST: + dest->data.subst = src->data.subst; + break; + default: + break; } } @@ -995,40 +990,43 @@ yasm_expr__copy_except(const yasm_expr *e, int except) { yasm_expr *n; int i; - - if (e == NULL) - return NULL; - + n = yasm_xmalloc(sizeof(yasm_expr) + - sizeof(yasm_expr__item)*(e->numterms<2?0:e->numterms-2)); + sizeof(yasm_expr__item)*(e->numterms<2?0:e->numterms-2)); n->op = e->op; n->line = e->line; n->numterms = e->numterms; for (i=0; inumterms; i++) { - if (i != except) - expr_item_copy(&n->terms[i], &e->terms[i]); + if (i != except) + expr_item_copy(&n->terms[i], &e->terms[i]); } return n; } +yasm_expr * +yasm_expr_copy(const yasm_expr *e) +{ + return yasm_expr__copy_except(e, -1); +} + static void expr_delete_term(yasm_expr__item *term, int recurse) { switch (term->type) { - case YASM_EXPR_INT: - yasm_intnum_destroy(term->data.intn); - break; - case YASM_EXPR_FLOAT: - yasm_floatnum_destroy(term->data.flt); - break; - case YASM_EXPR_EXPR: - if (recurse) - yasm_expr_destroy(term->data.expn); - break; - default: - break; + case YASM_EXPR_INT: + yasm_intnum_destroy(term->data.intn); + break; + case YASM_EXPR_FLOAT: + yasm_floatnum_destroy(term->data.flt); + break; + case YASM_EXPR_EXPR: + if (recurse) + yasm_expr_destroy(term->data.expn); + break; + default: + break; } } @@ -1037,9 +1035,9 @@ expr_destroy_each(/*@only@*/ yasm_expr *e, /*@unused@*/ void *d) { int i; for (i=0; inumterms; i++) - expr_delete_term(&e->terms[i], 0); - yasm_xfree(e); /* free ourselves */ - return 0; /* don't stop recursion */ + expr_delete_term(&e->terms[i], 0); + yasm_xfree(e); /* free ourselves */ + return 0; /* don't stop recursion */ } /*@-mustfree@*/ @@ -1079,16 +1077,16 @@ expr_subst_callback(yasm_expr__item *ei, void *d) { subst_cbd *cbd = d; if (ei->type != YASM_EXPR_SUBST) - return 0; + return 0; if (ei->data.subst >= cbd->num_items) - return 1; /* error */ + return 1; /* error */ expr_item_copy(ei, &cbd->items[ei->data.subst]); return 0; } int yasm_expr__subst(yasm_expr *e, unsigned int num_items, - const yasm_expr__item *items) + const yasm_expr__item *items) { subst_cbd cbd; cbd.num_items = num_items; @@ -1104,19 +1102,19 @@ yasm_expr__subst(yasm_expr *e, unsigned int num_items, */ static int expr_traverse_nodes_post(yasm_expr *e, void *d, - int (*func) (/*@null@*/ yasm_expr *e, - /*@null@*/ void *d)) + int (*func) (/*@null@*/ yasm_expr *e, + /*@null@*/ void *d)) { int i; if (!e) - return 0; + return 0; /* traverse terms */ for (i=0; inumterms; i++) { - if (e->terms[i].type == YASM_EXPR_EXPR && - expr_traverse_nodes_post(e->terms[i].data.expn, d, func)) - return 1; + if (e->terms[i].type == YASM_EXPR_EXPR && + expr_traverse_nodes_post(e->terms[i].data.expn, d, func)) + return 1; } /* do callback */ @@ -1135,17 +1133,17 @@ yasm_expr__traverse_leaves_in_const(const yasm_expr *e, void *d, int i; if (!e) - return 0; + return 0; for (i=0; inumterms; i++) { - if (e->terms[i].type == YASM_EXPR_EXPR) { - if (yasm_expr__traverse_leaves_in_const(e->terms[i].data.expn, d, - func)) - return 1; - } else { - if (func(&e->terms[i], d)) - return 1; - } + if (e->terms[i].type == YASM_EXPR_EXPR) { + if (yasm_expr__traverse_leaves_in_const(e->terms[i].data.expn, d, + func)) + return 1; + } else { + if (func(&e->terms[i], d)) + return 1; + } } return 0; } @@ -1162,16 +1160,16 @@ yasm_expr__traverse_leaves_in(yasm_expr *e, void *d, int i; if (!e) - return 0; + return 0; for (i=0; inumterms; i++) { - if (e->terms[i].type == YASM_EXPR_EXPR) { - if (yasm_expr__traverse_leaves_in(e->terms[i].data.expn, d, func)) - return 1; - } else { - if (func(&e->terms[i], d)) - return 1; - } + if (e->terms[i].type == YASM_EXPR_EXPR) { + if (yasm_expr__traverse_leaves_in(e->terms[i].data.expn, d, func)) + return 1; + } else { + if (func(&e->terms[i], d)) + return 1; + } } return 0; } @@ -1186,15 +1184,15 @@ yasm_expr_extract_deep_segoff(yasm_expr **ep) /* Try to extract at this level */ retval = yasm_expr_extract_segoff(ep); if (retval) - return retval; + return retval; /* Not at this level? Search any expr children. */ for (i=0; inumterms; i++) { - if (e->terms[i].type == YASM_EXPR_EXPR) { - retval = yasm_expr_extract_deep_segoff(&e->terms[i].data.expn); - if (retval) - return retval; - } + if (e->terms[i].type == YASM_EXPR_EXPR) { + retval = yasm_expr_extract_deep_segoff(&e->terms[i].data.expn); + if (retval) + return retval; + } } /* Didn't find one */ @@ -1209,23 +1207,23 @@ yasm_expr_extract_segoff(yasm_expr **ep) /* If not SEG:OFF, we can't do this transformation */ if (e->op != YASM_EXPR_SEGOFF) - return NULL; + return NULL; /* Extract the SEG portion out to its own expression */ if (e->terms[0].type == YASM_EXPR_EXPR) - retval = e->terms[0].data.expn; + retval = e->terms[0].data.expn; else { - /* Need to build IDENT expression to hold non-expression contents */ - retval = yasm_xmalloc(sizeof(yasm_expr)); - retval->op = YASM_EXPR_IDENT; - retval->numterms = 1; - retval->terms[0] = e->terms[0]; /* structure copy */ + /* Need to build IDENT expression to hold non-expression contents */ + retval = yasm_xmalloc(sizeof(yasm_expr)); + retval->op = YASM_EXPR_IDENT; + retval->numterms = 1; + retval->terms[0] = e->terms[0]; /* structure copy */ } /* Delete the SEG: portion by changing the expression into an IDENT */ e->op = YASM_EXPR_IDENT; e->numterms = 1; - e->terms[0] = e->terms[1]; /* structure copy */ + e->terms[0] = e->terms[1]; /* structure copy */ return retval; } @@ -1238,17 +1236,17 @@ yasm_expr_extract_wrt(yasm_expr **ep) /* If not WRT, we can't do this transformation */ if (e->op != YASM_EXPR_WRT) - return NULL; + return NULL; /* Extract the right side portion out to its own expression */ if (e->terms[1].type == YASM_EXPR_EXPR) - retval = e->terms[1].data.expn; + retval = e->terms[1].data.expn; else { - /* Need to build IDENT expression to hold non-expression contents */ - retval = yasm_xmalloc(sizeof(yasm_expr)); - retval->op = YASM_EXPR_IDENT; - retval->numterms = 1; - retval->terms[0] = e->terms[1]; /* structure copy */ + /* Need to build IDENT expression to hold non-expression contents */ + retval = yasm_xmalloc(sizeof(yasm_expr)); + retval->op = YASM_EXPR_IDENT; + retval->numterms = 1; + retval->terms[0] = e->terms[1]; /* structure copy */ } /* Delete the right side portion by changing the expr into an IDENT */ @@ -1264,10 +1262,10 @@ yasm_expr_get_intnum(yasm_expr **ep, int calc_bc_dist) { *ep = yasm_expr_simplify(*ep, calc_bc_dist); - if (*ep && (*ep)->op == YASM_EXPR_IDENT && (*ep)->terms[0].type == YASM_EXPR_INT) - return (*ep)->terms[0].data.intn; + if ((*ep)->op == YASM_EXPR_IDENT && (*ep)->terms[0].type == YASM_EXPR_INT) + return (*ep)->terms[0].data.intn; else - return (yasm_intnum *)NULL; + return (yasm_intnum *)NULL; } /*@=unqualifiedtrans =nullderef -nullstate -onlytrans@*/ @@ -1276,12 +1274,12 @@ const yasm_symrec * yasm_expr_get_symrec(yasm_expr **ep, int simplify) { if (simplify) - *ep = yasm_expr_simplify(*ep, 0); + *ep = yasm_expr_simplify(*ep, 0); if ((*ep)->op == YASM_EXPR_IDENT && (*ep)->terms[0].type == YASM_EXPR_SYM) - return (*ep)->terms[0].data.sym; + return (*ep)->terms[0].data.sym; else - return (yasm_symrec *)NULL; + return (yasm_symrec *)NULL; } /*@=unqualifiedtrans =nullderef -nullstate -onlytrans@*/ @@ -1290,12 +1288,12 @@ const uintptr_t * yasm_expr_get_reg(yasm_expr **ep, int simplify) { if (simplify) - *ep = yasm_expr_simplify(*ep, 0); + *ep = yasm_expr_simplify(*ep, 0); if ((*ep)->op == YASM_EXPR_IDENT && (*ep)->terms[0].type == YASM_EXPR_REG) - return &((*ep)->terms[0].data.reg); + return &((*ep)->terms[0].data.reg); else - return NULL; + return NULL; } /*@=unqualifiedtrans =nullderef -nullstate -onlytrans@*/ @@ -1306,215 +1304,145 @@ yasm_expr_print(const yasm_expr *e, FILE *f) int i; if (!e) { - fprintf(f, "(nil)"); - return; + fprintf(f, "(nil)"); + return; } switch (e->op) { - case YASM_EXPR_ADD: - strcpy(opstr, "+"); - break; - case YASM_EXPR_SUB: - strcpy(opstr, "-"); - break; - case YASM_EXPR_MUL: - strcpy(opstr, "*"); - break; - case YASM_EXPR_DIV: - strcpy(opstr, "/"); - break; - case YASM_EXPR_SIGNDIV: - strcpy(opstr, "//"); - break; - case YASM_EXPR_MOD: - strcpy(opstr, "%"); - break; - case YASM_EXPR_SIGNMOD: - strcpy(opstr, "%%"); - break; - case YASM_EXPR_NEG: - fprintf(f, "-"); - opstr[0] = 0; - break; - case YASM_EXPR_NOT: - fprintf(f, "~"); - opstr[0] = 0; - break; - case YASM_EXPR_OR: - strcpy(opstr, "|"); - break; - case YASM_EXPR_AND: - strcpy(opstr, "&"); - break; - case YASM_EXPR_XOR: - strcpy(opstr, "^"); - break; - case YASM_EXPR_XNOR: - strcpy(opstr, "XNOR"); - break; - case YASM_EXPR_NOR: - strcpy(opstr, "NOR"); - break; - case YASM_EXPR_SHL: - strcpy(opstr, "<<"); - break; - case YASM_EXPR_SHR: - strcpy(opstr, ">>"); - break; - case YASM_EXPR_LOR: - strcpy(opstr, "||"); - break; - case YASM_EXPR_LAND: - strcpy(opstr, "&&"); - break; - case YASM_EXPR_LNOT: - strcpy(opstr, "!"); - break; - case YASM_EXPR_LXOR: - strcpy(opstr, "^^"); - break; - case YASM_EXPR_LXNOR: - strcpy(opstr, "LXNOR"); - break; - case YASM_EXPR_LNOR: - strcpy(opstr, "LNOR"); - break; - case YASM_EXPR_LT: - strcpy(opstr, "<"); - break; - case YASM_EXPR_GT: - strcpy(opstr, ">"); - break; - case YASM_EXPR_LE: - strcpy(opstr, "<="); - break; - case YASM_EXPR_GE: - strcpy(opstr, ">="); - break; - case YASM_EXPR_NE: - strcpy(opstr, "!="); - break; - case YASM_EXPR_EQ: - strcpy(opstr, "=="); - break; - case YASM_EXPR_SEG: - fprintf(f, "SEG "); - opstr[0] = 0; - break; - case YASM_EXPR_WRT: - strcpy(opstr, " WRT "); - break; - case YASM_EXPR_SEGOFF: - strcpy(opstr, ":"); - break; - case YASM_EXPR_IDENT: - opstr[0] = 0; - break; - default: - strcpy(opstr, " !UNK! "); - break; + case YASM_EXPR_ADD: + strcpy(opstr, "+"); + break; + case YASM_EXPR_SUB: + strcpy(opstr, "-"); + break; + case YASM_EXPR_MUL: + strcpy(opstr, "*"); + break; + case YASM_EXPR_DIV: + strcpy(opstr, "/"); + break; + case YASM_EXPR_SIGNDIV: + strcpy(opstr, "//"); + break; + case YASM_EXPR_MOD: + strcpy(opstr, "%"); + break; + case YASM_EXPR_SIGNMOD: + strcpy(opstr, "%%"); + break; + case YASM_EXPR_NEG: + fprintf(f, "-"); + opstr[0] = 0; + break; + case YASM_EXPR_NOT: + fprintf(f, "~"); + opstr[0] = 0; + break; + case YASM_EXPR_OR: + strcpy(opstr, "|"); + break; + case YASM_EXPR_AND: + strcpy(opstr, "&"); + break; + case YASM_EXPR_XOR: + strcpy(opstr, "^"); + break; + case YASM_EXPR_XNOR: + strcpy(opstr, "XNOR"); + break; + case YASM_EXPR_NOR: + strcpy(opstr, "NOR"); + break; + case YASM_EXPR_SHL: + strcpy(opstr, "<<"); + break; + case YASM_EXPR_SHR: + strcpy(opstr, ">>"); + break; + case YASM_EXPR_LOR: + strcpy(opstr, "||"); + break; + case YASM_EXPR_LAND: + strcpy(opstr, "&&"); + break; + case YASM_EXPR_LNOT: + strcpy(opstr, "!"); + break; + case YASM_EXPR_LXOR: + strcpy(opstr, "^^"); + break; + case YASM_EXPR_LXNOR: + strcpy(opstr, "LXNOR"); + break; + case YASM_EXPR_LNOR: + strcpy(opstr, "LNOR"); + break; + case YASM_EXPR_LT: + strcpy(opstr, "<"); + break; + case YASM_EXPR_GT: + strcpy(opstr, ">"); + break; + case YASM_EXPR_LE: + strcpy(opstr, "<="); + break; + case YASM_EXPR_GE: + strcpy(opstr, ">="); + break; + case YASM_EXPR_NE: + strcpy(opstr, "!="); + break; + case YASM_EXPR_EQ: + strcpy(opstr, "=="); + break; + case YASM_EXPR_SEG: + fprintf(f, "SEG "); + opstr[0] = 0; + break; + case YASM_EXPR_WRT: + strcpy(opstr, " WRT "); + break; + case YASM_EXPR_SEGOFF: + strcpy(opstr, ":"); + break; + case YASM_EXPR_IDENT: + opstr[0] = 0; + break; + default: + strcpy(opstr, " !UNK! "); + break; } for (i=0; inumterms; i++) { - switch (e->terms[i].type) { - case YASM_EXPR_PRECBC: - fprintf(f, "{%lx}", - yasm_bc_next_offset(e->terms[i].data.precbc)); - break; - case YASM_EXPR_SYM: - fprintf(f, "%s", yasm_symrec_get_name(e->terms[i].data.sym)); - break; - case YASM_EXPR_EXPR: - fprintf(f, "("); - yasm_expr_print(e->terms[i].data.expn, f); - fprintf(f, ")"); - break; - case YASM_EXPR_INT: - yasm_intnum_print(e->terms[i].data.intn, f); - break; - case YASM_EXPR_FLOAT: - yasm_floatnum_print(e->terms[i].data.flt, f); - break; - case YASM_EXPR_REG: - /* FIXME */ - /*yasm_arch_reg_print(arch, e->terms[i].data.reg, f);*/ - break; - case YASM_EXPR_SUBST: - fprintf(f, "[%u]", e->terms[i].data.subst); - break; - case YASM_EXPR_NONE: - break; - } - if (i < e->numterms-1) - fprintf(f, "%s", opstr); + switch (e->terms[i].type) { + case YASM_EXPR_PRECBC: + fprintf(f, "{%lx}", + yasm_bc_next_offset(e->terms[i].data.precbc)); + break; + case YASM_EXPR_SYM: + fprintf(f, "%s", yasm_symrec_get_name(e->terms[i].data.sym)); + break; + case YASM_EXPR_EXPR: + fprintf(f, "("); + yasm_expr_print(e->terms[i].data.expn, f); + fprintf(f, ")"); + break; + case YASM_EXPR_INT: + yasm_intnum_print(e->terms[i].data.intn, f); + break; + case YASM_EXPR_FLOAT: + yasm_floatnum_print(e->terms[i].data.flt, f); + break; + case YASM_EXPR_REG: + /* FIXME */ + /*yasm_arch_reg_print(arch, e->terms[i].data.reg, f);*/ + break; + case YASM_EXPR_SUBST: + fprintf(f, "[%u]", e->terms[i].data.subst); + break; + case YASM_EXPR_NONE: + break; + } + if (i < e->numterms-1) + fprintf(f, "%s", opstr); } } - -unsigned int -yasm_expr_size(const yasm_expr *e) -{ - int i; - int seen = 0; - unsigned int size = 0, newsize; - - if (e->op == YASM_EXPR_IDENT) { - if (e->terms[0].type == YASM_EXPR_SYM) - return yasm_symrec_get_size(e->terms[0].data.sym); - return 0; - } - if (e->op != YASM_EXPR_ADD && e->op != YASM_EXPR_SUB) - return 0; - - for (i=0; inumterms; i++) { - newsize = 0; - switch (e->terms[i].type) { - case YASM_EXPR_EXPR: - newsize = yasm_expr_size(e->terms[i].data.expn); - break; - case YASM_EXPR_SYM: - newsize = yasm_symrec_get_size(e->terms[i].data.sym); - break; - default: - break; - } - if (newsize) { - size = newsize; - if (seen) - /* either sum of idents (?!) or substract of idents */ - return 0; - seen = 1; - } - } - /* exactly one offset */ - return size; -} - -const char * -yasm_expr_segment(const yasm_expr *e) -{ - int i; - int seen = 0; - const char *segment = NULL; - - if (e->op == YASM_EXPR_IDENT) { - if (e->terms[0].type == YASM_EXPR_SYM) - return yasm_symrec_get_segment(e->terms[0].data.sym); - return NULL; - } - if (e->op != YASM_EXPR_ADD && e->op != YASM_EXPR_SUB) - return NULL; - - for (i=0; inumterms; i++) { - if ((e->op == YASM_EXPR_ADD || !i) && - e->terms[i].type == YASM_EXPR_EXPR) { - if ((segment = yasm_expr_segment(e->terms[i].data.expn))) { - if (seen) { - /* either sum of idents (?!) or substract of idents */ - return NULL; - } - seen = 1; - } - } - } - /* exactly one offset */ - return segment; -} diff --git a/libyasm/expr.h b/libyasm/expr.h index 0de62dfe..86723db5 100644 --- a/libyasm/expr.h +++ b/libyasm/expr.h @@ -2,6 +2,10 @@ * \file libyasm/expr.h * \brief YASM expression interface. * + * \rcs + * $Id$ + * \endrcs + * * \license * Copyright (C) 2001-2007 Michael Urman, Peter Johnson * @@ -30,63 +34,16 @@ #ifndef YASM_EXPR_H #define YASM_EXPR_H -#ifndef YASM_LIB_DECL -#define YASM_LIB_DECL -#endif - -/** Type of an expression item. Types are listed in canonical sorting order. - * See expr_order_terms(). - * Note #YASM_EXPR_PRECBC must be used carefully (in a-b pairs), as only - * symrecs can become the relative term in a #yasm_value. - */ -typedef enum yasm_expr__type { - YASM_EXPR_NONE = 0, /**< Nothing */ - YASM_EXPR_REG = 1<<0, /**< Register */ - YASM_EXPR_INT = 1<<1, /**< Integer value */ - YASM_EXPR_SUBST = 1<<2, /**< Substitution placeholder */ - YASM_EXPR_FLOAT = 1<<3, /**< Floating point value */ - YASM_EXPR_SYM = 1<<4, /**< Symbol */ - YASM_EXPR_PRECBC = 1<<5,/**< Direct bytecode ref (rather than via sym) */ - YASM_EXPR_EXPR = 1<<6 /**< Subexpression */ -} yasm_expr__type; - -/** Expression item. */ -typedef struct yasm_expr__item { - yasm_expr__type type; /**< Type */ - - /** Expression item data. Correct value depends on type. */ - union { - yasm_bytecode *precbc; /**< Direct bytecode ref (YASM_EXPR_PRECBC) */ - yasm_symrec *sym; /**< Symbol (YASM_EXPR_SYM) */ - yasm_expr *expn; /**< Subexpression (YASM_EXPR_EXPR) */ - yasm_intnum *intn; /**< Integer value (YASM_EXPR_INT) */ - yasm_floatnum *flt; /**< Floating point value (YASM_EXPR_FLOAT) */ - uintptr_t reg; /**< Register (YASM_EXPR_REG) */ - unsigned int subst; /**< Subst placeholder (YASM_EXPR_SUBST) */ - } data; -} yasm_expr__item; - -/** Expression. */ -struct yasm_expr { - yasm_expr_op op; /**< Operation. */ - unsigned long line; /**< Line number where expression was defined. */ - int numterms; /**< Number of terms in the expression. */ - - /** Terms of the expression. Structure may be extended to include more - * terms, as some operations may allow more than two operand terms - * (ADD, MUL, OR, AND, XOR). - */ - yasm_expr__item terms[2]; -}; +/** Expression item (opaque type). \internal */ +typedef struct yasm_expr__item yasm_expr__item; /** Create a new expression e=a op b. - * \param op operation - * \param a expression item a - * \param b expression item b (optional depending on op) - * \param line virtual line (where expression defined) + * \param op operation + * \param a expression item a + * \param b expression item b (optional depending on op) + * \param line virtual line (where expression defined) * \return Newly allocated expression. */ -YASM_LIB_DECL /*@only@*/ yasm_expr *yasm_expr_create (yasm_expr_op op, /*@only@*/ yasm_expr__item *a, /*@only@*/ /*@null@*/ yasm_expr__item *b, unsigned long line); @@ -95,99 +52,88 @@ YASM_LIB_DECL * \param precbc preceding bytecode * \return Newly allocated expression item. */ -YASM_LIB_DECL /*@only@*/ yasm_expr__item *yasm_expr_precbc(/*@keep@*/ yasm_bytecode *precbc); /** Create a new symbol expression item. - * \param sym symbol + * \param sym symbol * \return Newly allocated expression item. */ -YASM_LIB_DECL /*@only@*/ yasm_expr__item *yasm_expr_sym(/*@keep@*/ yasm_symrec *sym); /** Create a new expression expression item. - * \param e expression + * \param e expression * \return Newly allocated expression item. */ -YASM_LIB_DECL /*@only@*/ yasm_expr__item *yasm_expr_expr(/*@keep@*/ yasm_expr *e); /** Create a new intnum expression item. - * \param intn intnum + * \param intn intnum * \return Newly allocated expression item. */ -YASM_LIB_DECL /*@only@*/ yasm_expr__item *yasm_expr_int(/*@keep@*/ yasm_intnum *intn); /** Create a new floatnum expression item. - * \param flt floatnum + * \param flt floatnum * \return Newly allocated expression item. */ -YASM_LIB_DECL /*@only@*/ yasm_expr__item *yasm_expr_float(/*@keep@*/ yasm_floatnum *flt); /** Create a new register expression item. - * \param reg register + * \param reg register * \return Newly allocated expression item. */ -YASM_LIB_DECL /*@only@*/ yasm_expr__item *yasm_expr_reg(uintptr_t reg); /** Create a new expression tree e=l op r. - * \param l expression for left side of new expression - * \param o operation - * \param r expression for right side of new expression - * \param i line index + * \param l expression for left side of new expression + * \param o operation + * \param r expression for right side of new expression + * \param i line index * \return Newly allocated expression. */ #define yasm_expr_create_tree(l,o,r,i) \ yasm_expr_create ((o), yasm_expr_expr(l), yasm_expr_expr(r), i) /** Create a new expression branch e=op r. - * \param o operation - * \param r expression for right side of new expression - * \param i line index + * \param o operation + * \param r expression for right side of new expression + * \param i line index * \return Newly allocated expression. */ #define yasm_expr_create_branch(o,r,i) \ yasm_expr_create ((o), yasm_expr_expr(r), (yasm_expr__item *)NULL, i) /** Create a new expression identity e=r. - * \param r expression for identity within new expression - * \param i line index + * \param r expression for identity within new expression + * \param i line index * \return Newly allocated expression. */ #define yasm_expr_create_ident(r,i) \ yasm_expr_create (YASM_EXPR_IDENT, (r), (yasm_expr__item *)NULL, i) /** Duplicate an expression. - * \param e expression + * \param e expression * \return Newly allocated expression identical to e. */ yasm_expr *yasm_expr_copy(const yasm_expr *e); -#ifndef YASM_DOXYGEN -#define yasm_expr_copy(e) yasm_expr__copy_except(e, -1) -#endif /** Destroy (free allocated memory for) an expression. - * \param e expression + * \param e expression */ -YASM_LIB_DECL void yasm_expr_destroy(/*@only@*/ /*@null@*/ yasm_expr *e); /** Determine if an expression is a specified operation (at the top level). - * \param e expression - * \param op operator + * \param e expression + * \param op operator * \return Nonzero if the expression was the specified operation at the top * level, zero otherwise. */ -YASM_LIB_DECL int yasm_expr_is_op(const yasm_expr *e, yasm_expr_op op); /** Extra transformation function for yasm_expr__level_tree(). - * \param e expression being simplified - * \param d data provided as expr_xform_extra_data to - * yasm_expr__level_tree() + * \param e expression being simplified + * \param d data provided as expr_xform_extra_data to + * yasm_expr__level_tree() * \return Transformed e. */ typedef /*@only@*/ yasm_expr * (*yasm_expr_xform_func) @@ -195,17 +141,16 @@ typedef /*@only@*/ yasm_expr * (*yasm_expr_xform_func) /** Level an entire expression tree. * \internal - * \param e expression - * \param fold_const enable constant folding if nonzero + * \param e expression + * \param fold_const enable constant folding if nonzero * \param simplify_ident simplify identities * \param simplify_reg_mul simplify REG*1 identities - * \param calc_bc_dist nonzero if distances between bytecodes should be - * calculated, 0 if they should be left intact + * \param calc_bc_dist nonzero if distances between bytecodes should be + * calculated, 0 if they should be left intact * \param expr_xform_extra extra transformation function - * \param expr_xform_extra_data data to pass to expr_xform_extra + * \param expr_xform_extra_data data to pass to expr_xform_extra * \return Leveled expression. */ -YASM_LIB_DECL /*@only@*/ /*@null@*/ yasm_expr *yasm_expr__level_tree (/*@returned@*/ /*@only@*/ /*@null@*/ yasm_expr *e, int fold_const, int simplify_ident, int simplify_reg_mul, int calc_bc_dist, @@ -215,8 +160,8 @@ YASM_LIB_DECL /** Simplify an expression as much as possible. Eliminates extraneous * branches and simplifies integer-only subexpressions. Simplified version * of yasm_expr__level_tree(). - * \param e expression - * \param cbd if distance between bytecodes should be calculated + * \param e expression + * \param cbd if distance between bytecodes should be calculated * \return Simplified expression. */ #define yasm_expr_simplify(e, cbd) \ @@ -224,165 +169,66 @@ YASM_LIB_DECL /** Extract the segment portion of an expression containing SEG:OFF, leaving * the offset. - * \param ep expression (pointer to) + * \param ep expression (pointer to) * \return NULL if unable to extract a segment (expr does not contain a * YASM_EXPR_SEGOFF operator), otherwise the segment expression. * The input expression is modified such that on return, it's the * offset expression. */ -YASM_LIB_DECL /*@only@*/ /*@null@*/ yasm_expr *yasm_expr_extract_deep_segoff(yasm_expr **ep); /** Extract the segment portion of a SEG:OFF expression, leaving the offset. - * \param ep expression (pointer to) + * \param ep expression (pointer to) * \return NULL if unable to extract a segment (YASM_EXPR_SEGOFF not the * top-level operator), otherwise the segment expression. The input * expression is modified such that on return, it's the offset * expression. */ -YASM_LIB_DECL /*@only@*/ /*@null@*/ yasm_expr *yasm_expr_extract_segoff(yasm_expr **ep); /** Extract the right portion (y) of a x WRT y expression, leaving the left * portion (x). - * \param ep expression (pointer to) + * \param ep expression (pointer to) * \return NULL if unable to extract (YASM_EXPR_WRT not the top-level * operator), otherwise the right side of the WRT expression. The * input expression is modified such that on return, it's the left side * of the WRT expression. */ -YASM_LIB_DECL /*@only@*/ /*@null@*/ yasm_expr *yasm_expr_extract_wrt(yasm_expr **ep); /** Get the integer value of an expression if it's just an integer. - * \param ep expression (pointer to) - * \param calc_bc_dist nonzero if distances between bytecodes should be - * calculated, 0 if NULL should be returned in this case + * \param ep expression (pointer to) + * \param calc_bc_dist nonzero if distances between bytecodes should be + * calculated, 0 if NULL should be returned in this case * \return NULL if the expression is too complex (contains anything other than * integers, ie floats, non-valued labels, registers); otherwise the * intnum value of the expression. */ -YASM_LIB_DECL /*@dependent@*/ /*@null@*/ yasm_intnum *yasm_expr_get_intnum (yasm_expr **ep, int calc_bc_dist); /** Get the symbol value of an expression if it's just a symbol. - * \param ep expression (pointer to) - * \param simplify if nonzero, simplify the expression first + * \param ep expression (pointer to) + * \param simplify if nonzero, simplify the expression first * \return NULL if the expression is too complex; otherwise the symbol value of * the expression. */ -YASM_LIB_DECL /*@dependent@*/ /*@null@*/ const yasm_symrec *yasm_expr_get_symrec (yasm_expr **ep, int simplify); /** Get the register value of an expression if it's just a register. - * \param ep expression (pointer to) - * \param simplify if nonzero, simplify the expression first + * \param ep expression (pointer to) + * \param simplify if nonzero, simplify the expression first * \return NULL if the expression is too complex; otherwise the register value * of the expression. */ -YASM_LIB_DECL /*@dependent@*/ /*@null@*/ const uintptr_t *yasm_expr_get_reg (yasm_expr **ep, int simplify); /** Print an expression. For debugging purposes. - * \param e expression - * \param f file + * \param e expression + * \param f file */ -YASM_LIB_DECL void yasm_expr_print(/*@null@*/ const yasm_expr *e, FILE *f); -/** Return the size of an expression, if the user provided it - * \param e expression - */ -YASM_LIB_DECL -unsigned int yasm_expr_size(const yasm_expr *e); - -/** Return the segment of an expression, if the user provided it - * \param e expression - */ -YASM_LIB_DECL -const char *yasm_expr_segment(const yasm_expr *e); - -/** Traverse over expression tree in order (const version). - * Calls func for each leaf (non-operation). - * \param e expression - * \param d data passed to each call to func - * \param func callback function - * \return Stops early (and returns 1) if func returns 1. - * Otherwise returns 0. - */ -YASM_LIB_DECL -int yasm_expr__traverse_leaves_in_const - (const yasm_expr *e, /*@null@*/ void *d, - int (*func) (/*@null@*/ const yasm_expr__item *ei, /*@null@*/ void *d)); - -/** Traverse over expression tree in order. - * Calls func for each leaf (non-operation). - * \param e expression - * \param d data passed to each call to func - * \param func callback function - * \return Stops early (and returns 1) if func returns 1. - * Otherwise returns 0. - */ -YASM_LIB_DECL -int yasm_expr__traverse_leaves_in - (yasm_expr *e, /*@null@*/ void *d, - int (*func) (/*@null@*/ yasm_expr__item *ei, /*@null@*/ void *d)); - -/** Reorder terms of e into canonical order. Only reorders if reordering - * doesn't change meaning of expression. (eg, doesn't reorder SUB). - * Canonical order: REG, INT, FLOAT, SYM, EXPR. - * Multiple terms of a single type are kept in the same order as in - * the original expression. - * \param e expression - * \note Only performs reordering on *one* level (no recursion). - */ -YASM_LIB_DECL -void yasm_expr__order_terms(yasm_expr *e); - -/** Copy entire expression EXCEPT for index "except" at *top level only*. - * \param e expression - * \param except term index not to copy; -1 to copy all terms - * \return Newly allocated copy of expression. - */ -YASM_LIB_DECL -yasm_expr *yasm_expr__copy_except(const yasm_expr *e, int except); - -/** Test if expression contains an item. Searches recursively into - * subexpressions. - * \param e expression - * \param t type of item to look for - * \return Nonzero if expression contains an item of type t, zero if not. - */ -YASM_LIB_DECL -int yasm_expr__contains(const yasm_expr *e, yasm_expr__type t); - -/** Transform symrec-symrec terms in expression into #YASM_EXPR_SUBST items. - * Calls the callback function for each symrec-symrec term. - * \param ep expression (pointer to) - * \param cbd callback data passed to callback function - * \param callback callback function: given subst index for bytecode - * pair, bytecode pair (bc2-bc1), and cbd (callback data) - * \return Number of transformations made. - */ -YASM_LIB_DECL -int yasm_expr__bc_dist_subst(yasm_expr **ep, void *cbd, - void (*callback) (unsigned int subst, - yasm_bytecode *precbc, - yasm_bytecode *precbc2, - void *cbd)); - -/** Substitute items into expr YASM_EXPR_SUBST items (by index). Items are - * copied, so caller is responsible for freeing array of items. - * \param e expression - * \param num_items number of items in items array - * \param items items array - * \return 1 on error (index out of range). - */ -YASM_LIB_DECL -int yasm_expr__subst(yasm_expr *e, unsigned int num_items, - const yasm_expr__item *items); - #endif diff --git a/libyasm/file.c b/libyasm/file.c index ea9f603b..9e158ea9 100644 --- a/libyasm/file.c +++ b/libyasm/file.c @@ -25,31 +25,21 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include +/*@unused@*/ RCSID("$Id$"); -/* Need either unistd.h or direct.h to prototype getcwd() and mkdir() */ +/* Need either unistd.h or direct.h (on Windows) to prototype getcwd() */ #ifdef HAVE_UNISTD_H #include -#endif - -#ifdef HAVE_DIRECT_H +#elif defined(WIN32) || defined(_WIN32) #include #endif -#ifdef _WIN32 -#include -#endif - -#ifdef HAVE_SYS_STAT_H -#include -#endif - #include -#include #include "errwarn.h" #include "file.h" -#define BSIZE 8192 /* Fill block size */ +#define BSIZE 8192 /* Fill block size */ void @@ -68,48 +58,48 @@ void yasm_scanner_delete(yasm_scanner *s) { if (s->bot) { - yasm_xfree(s->bot); - s->bot = NULL; + yasm_xfree(s->bot); + s->bot = NULL; } } int yasm_fill_helper(yasm_scanner *s, unsigned char **cursor, - size_t (*input_func) (void *d, unsigned char *buf, - size_t max), - void *input_func_data) + size_t (*input_func) (void *d, unsigned char *buf, + size_t max), + void *input_func_data) { size_t cnt; int first = 0; if (s->eof) - return 0; + return 0; cnt = s->tok - s->bot; if (cnt > 0) { - memmove(s->bot, s->tok, (size_t)(s->lim - s->tok)); - s->tok = s->bot; - s->ptr -= cnt; - *cursor -= cnt; - s->lim -= cnt; + memmove(s->bot, s->tok, (size_t)(s->lim - s->tok)); + s->tok = s->bot; + s->ptr -= cnt; + *cursor -= cnt; + s->lim -= cnt; } if (!s->bot) - first = 1; + first = 1; if ((s->top - s->lim) < BSIZE) { - unsigned char *buf = yasm_xmalloc((size_t)(s->lim - s->bot) + BSIZE); - memcpy(buf, s->tok, (size_t)(s->lim - s->tok)); - s->tok = buf; - s->ptr = &buf[s->ptr - s->bot]; - *cursor = &buf[*cursor - s->bot]; - s->lim = &buf[s->lim - s->bot]; - s->top = &s->lim[BSIZE]; - if (s->bot) - yasm_xfree(s->bot); - s->bot = buf; + unsigned char *buf = yasm_xmalloc((size_t)(s->lim - s->bot) + BSIZE); + memcpy(buf, s->tok, (size_t)(s->lim - s->tok)); + s->tok = buf; + s->ptr = &buf[s->ptr - s->bot]; + *cursor = &buf[*cursor - s->bot]; + s->lim = &buf[s->lim - s->bot]; + s->top = &s->lim[BSIZE]; + if (s->bot) + yasm_xfree(s->bot); + s->bot = buf; } if ((cnt = input_func(input_func_data, s->lim, BSIZE)) == 0) { - s->eof = &s->lim[cnt]; - *s->eof++ = '\n'; + s->eof = &s->lim[cnt]; + *s->eof++ = '\n'; } s->lim += cnt; return first; @@ -123,59 +113,59 @@ yasm_unescape_cstring(unsigned char *str, size_t *len) unsigned char t[4]; while ((size_t)(s-str)<*len) { - if (*s == '\\' && (size_t)(&s[1]-str)<*len) { - s++; - switch (*s) { - case 'b': *o = '\b'; s++; break; - case 'f': *o = '\f'; s++; break; - case 'n': *o = '\n'; s++; break; - case 'r': *o = '\r'; s++; break; - case 't': *o = '\t'; s++; break; - case 'x': - /* hex escape; grab last two digits */ - s++; - while ((size_t)(&s[2]-str)<*len && isxdigit(s[0]) - && isxdigit(s[1]) && isxdigit(s[2])) - s++; - if ((size_t)(s-str)<*len && isxdigit(*s)) { - t[0] = *s++; - t[1] = '\0'; - t[2] = '\0'; - if ((size_t)(s-str)<*len && isxdigit(*s)) - t[1] = *s++; - *o = (unsigned char)strtoul((char *)t, NULL, 16); - } else - *o = '\0'; - break; - default: - if (isdigit(*s)) { - int warn = 0; - /* octal escape */ - if (*s > '7') - warn = 1; - *o = *s++ - '0'; - if ((size_t)(s-str)<*len && isdigit(*s)) { - if (*s > '7') - warn = 1; - *o <<= 3; - *o += *s++ - '0'; - if ((size_t)(s-str)<*len && isdigit(*s)) { - if (*s > '7') - warn = 1; - *o <<= 3; - *o += *s++ - '0'; - } - } - if (warn) - yasm_warn_set(YASM_WARN_GENERAL, - N_("octal value out of range")); - } else - *o = *s++; - break; - } - o++; - } else - *o++ = *s++; + if (*s == '\\' && (size_t)(&s[1]-str)<*len) { + s++; + switch (*s) { + case 'b': *o = '\b'; s++; break; + case 'f': *o = '\f'; s++; break; + case 'n': *o = '\n'; s++; break; + case 'r': *o = '\r'; s++; break; + case 't': *o = '\t'; s++; break; + case 'x': + /* hex escape; grab last two digits */ + s++; + while ((size_t)(&s[2]-str)<*len && isxdigit(s[0]) + && isxdigit(s[1]) && isxdigit(s[2])) + s++; + if ((size_t)(s-str)<*len && isxdigit(*s)) { + t[0] = *s++; + t[1] = '\0'; + t[2] = '\0'; + if ((size_t)(s-str)<*len && isxdigit(*s)) + t[1] = *s++; + *o = (unsigned char)strtoul((char *)t, NULL, 16); + } else + *o = '\0'; + break; + default: + if (isdigit(*s)) { + int warn = 0; + /* octal escape */ + if (*s > '7') + warn = 1; + *o = *s++ - '0'; + if ((size_t)(s-str)<*len && isdigit(*s)) { + if (*s > '7') + warn = 1; + *o <<= 3; + *o += *s++ - '0'; + if ((size_t)(s-str)<*len && isdigit(*s)) { + if (*s > '7') + warn = 1; + *o <<= 3; + *o += *s++ - '0'; + } + } + if (warn) + yasm_warn_set(YASM_WARN_GENERAL, + N_("octal value out of range")); + } else + *o = *s++; + break; + } + o++; + } else + *o++ = *s++; } *len = o-str; } @@ -186,18 +176,18 @@ yasm__splitpath_unix(const char *path, /*@out@*/ const char **tail) const char *s; s = strrchr(path, '/'); if (!s) { - /* No head */ - *tail = path; - return 0; + /* No head */ + *tail = path; + return 0; } *tail = s+1; /* Strip trailing ./ on path */ while ((s-1)>=path && *(s-1) == '.' && *s == '/' - && !((s-2)>=path && *(s-2) == '.')) - s -= 2; + && !((s-2)>=path && *(s-2) == '.')) + s -= 2; /* Strip trailing slashes on path (except leading) */ while (s>path && *s == '/') - s--; + s--; /* Return length of head */ return s-path+1; } @@ -210,73 +200,74 @@ yasm__splitpath_win(const char *path, /*@out@*/ const char **tail) /* split off drive letter first, if any */ if (isalpha(path[0]) && path[1] == ':') - basepath += 2; + basepath += 2; s = basepath; while (*s != '\0') - s++; + s++; while (s >= basepath && *s != '\\' && *s != '/') - s--; + s--; if (s < basepath) { - *tail = basepath; - if (path == basepath) - return 0; /* No head */ - else - return 2; /* Drive letter is head */ + *tail = basepath; + if (path == basepath) + return 0; /* No head */ + else + return 2; /* Drive letter is head */ } *tail = s+1; /* Strip trailing .\ or ./ on path */ while ((s-1)>=basepath && *(s-1) == '.' && (*s == '/' || *s == '\\') - && !((s-2)>=basepath && *(s-2) == '.')) - s -= 2; + && !((s-2)>=basepath && *(s-2) == '.')) + s -= 2; /* Strip trailing slashes on path (except leading) */ while (s>basepath && (*s == '/' || *s == '\\')) - s--; + s--; /* Return length of head */ return s-path+1; } +/* FIXME: dumb way for now */ char * -yasm__getcwd(void) -{ - char *buf; - size_t size; - - size = 1024; - buf = yasm_xmalloc(size); - - if (getenv("YASM_TEST_SUITE")) { - strcpy(buf, "./"); - return buf; - } - - while (getcwd(buf, size-1) == NULL) { - if (errno != ERANGE) { - yasm__fatal(N_("could not determine current working directory")); - yasm_xfree(buf); - return NULL; - } - size *= 2; - buf = yasm_xrealloc(buf, size); - } - - /* append a '/' if not already present */ - size = strlen(buf); - if (buf[size-1] != '\\' && buf[size-1] != '/') { - buf[size] = '/'; - buf[size+1] = '\0'; - } - return buf; -} - -char * -yasm__abspath(const char *path) +yasm__abspath_unix(const char *path) { char *curdir, *abspath; + static const char pathsep[2] = "/"; - curdir = yasm__getcwd(); - abspath = yasm__combpath(curdir, path); - yasm_xfree(curdir); + curdir = getcwd(NULL, 0); + + abspath = yasm_xmalloc(strlen(curdir) + strlen(path) + 2); + strcpy(abspath, curdir); + strcat(abspath, pathsep); + strcat(abspath, path); + + free(curdir); + + return abspath; +} + +/* FIXME: dumb way for now */ +char * +yasm__abspath_win(const char *path) +{ + char *curdir, *abspath, *ch; + static const char pathsep[2] = "\\"; + + curdir = getcwd(NULL, 0); + + abspath = yasm_xmalloc(strlen(curdir) + strlen(path) + 2); + strcpy(abspath, curdir); + strcat(abspath, pathsep); + strcat(abspath, path); + + free(curdir); + + /* Replace all / with \ */ + ch = abspath; + while (*ch) { + if (*ch == '/') + *ch = '\\'; + ch++; + } return abspath; } @@ -289,34 +280,34 @@ yasm__combpath_unix(const char *from, const char *to) char *out; if (to[0] == '/') { - /* absolute "to" */ - out = yasm_xmalloc(strlen(to)+1); - /* Combine any double slashes when copying */ - for (j=0; *to; to++) { - if (*to == '/' && *(to+1) == '/') - continue; - out[j++] = *to; - } - out[j++] = '\0'; - return out; + /* absolute "to" */ + out = yasm_xmalloc(strlen(to)+1); + /* Combine any double slashes when copying */ + for (j=0; *to; to++) { + if (*to == '/' && *(to+1) == '/') + continue; + out[j++] = *to; + } + out[j++] = '\0'; + return out; } /* Get path component; note this strips trailing slash */ pathlen = yasm__splitpath_unix(from, &tail); - out = yasm_xmalloc(pathlen+strlen(to)+2); /* worst case maximum len */ + out = yasm_xmalloc(pathlen+strlen(to)+2); /* worst case maximum len */ /* Combine any double slashes when copying */ for (i=0, j=0; i 0 && out[pathlen-1] != '/') - out[pathlen++] = '/'; + out[pathlen++] = '/'; /* Now scan from left to right through "to", stripping off "." and ".."; * if we see "..", back up one directory in out unless last directory in @@ -327,39 +318,39 @@ yasm__combpath_unix(const char *from, const char *to) * the same as "foo"). */ for (;;) { - if (to[0] == '.' && to[1] == '/') { - to += 2; /* current directory */ - while (*to == '/') - to++; /* strip off any additional slashes */ - } else if (pathlen == 0) - break; /* no more "from" path left, we're done */ - else if (to[0] == '.' && to[1] == '.' && to[2] == '/') { - if (pathlen >= 3 && out[pathlen-1] == '/' && out[pathlen-2] == '.' - && out[pathlen-3] == '.') { - /* can't ".." against a "..", so we're done. */ - break; - } + if (to[0] == '.' && to[1] == '/') { + to += 2; /* current directory */ + while (*to == '/') + to++; /* strip off any additional slashes */ + } else if (pathlen == 0) + break; /* no more "from" path left, we're done */ + else if (to[0] == '.' && to[1] == '.' && to[2] == '/') { + if (pathlen >= 3 && out[pathlen-1] == '/' && out[pathlen-2] == '.' + && out[pathlen-3] == '.') { + /* can't ".." against a "..", so we're done. */ + break; + } - to += 3; /* throw away "../" */ - while (*to == '/') - to++; /* strip off any additional slashes */ + to += 3; /* throw away "../" */ + while (*to == '/') + to++; /* strip off any additional slashes */ - /* and back out last directory in "out" if not already at root */ - if (pathlen > 1) { - pathlen--; /* strip off trailing '/' */ - while (pathlen > 0 && out[pathlen-1] != '/') - pathlen--; - } - } else - break; + /* and back out last directory in "out" if not already at root */ + if (pathlen > 1) { + pathlen--; /* strip off trailing '/' */ + while (pathlen > 0 && out[pathlen-1] != '/') + pathlen--; + } + } else + break; } /* Copy "to" to tail of output, and we're done */ /* Combine any double slashes when copying */ for (j=pathlen; *to; to++) { - if (*to == '/' && *(to+1) == '/') - continue; - out[j++] = *to; + if (*to == '/' && *(to+1) == '/') + continue; + out[j++] = *to; } out[j++] = '\0'; @@ -374,43 +365,43 @@ yasm__combpath_win(const char *from, const char *to) char *out; if ((isalpha(to[0]) && to[1] == ':') || (to[0] == '/' || to[0] == '\\')) { - /* absolute or drive letter "to" */ - out = yasm_xmalloc(strlen(to)+1); - /* Combine any double slashes when copying */ - for (j=0; *to; to++) { - if ((*to == '/' || *to == '\\') - && (*(to+1) == '/' || *(to+1) == '\\')) - continue; - if (*to == '/') - out[j++] = '\\'; - else - out[j++] = *to; - } - out[j++] = '\0'; - return out; + /* absolute or drive letter "to" */ + out = yasm_xmalloc(strlen(to)+1); + /* Combine any double slashes when copying */ + for (j=0; *to; to++) { + if ((*to == '/' || *to == '\\') + && (*(to+1) == '/' || *(to+1) == '\\')) + continue; + if (*to == '/') + out[j++] = '\\'; + else + out[j++] = *to; + } + out[j++] = '\0'; + return out; } /* Get path component; note this strips trailing slash */ pathlen = yasm__splitpath_win(from, &tail); - out = yasm_xmalloc(pathlen+strlen(to)+2); /* worst case maximum len */ + out = yasm_xmalloc(pathlen+strlen(to)+2); /* worst case maximum len */ /* Combine any double slashes when copying */ for (i=0, j=0; i 0 && out[pathlen-1] != '\\' - && !(pathlen == 2 && isalpha(out[0]) && out[1] == ':')) - out[pathlen++] = '\\'; + && !(pathlen == 2 && isalpha(out[0]) && out[1] == ':')) + out[pathlen++] = '\\'; /* Now scan from left to right through "to", stripping off "." and ".."; * if we see "..", back up one directory in out unless last directory in @@ -421,122 +412,60 @@ yasm__combpath_win(const char *from, const char *to) * the same as "foo"). */ for (;;) { - if (to[0] == '.' && (to[1] == '/' || to[1] == '\\')) { - to += 2; /* current directory */ - while (*to == '/' || *to == '\\') - to++; /* strip off any additional slashes */ - } else if (pathlen == 0 - || (pathlen == 2 && isalpha(out[0]) && out[1] == ':')) - break; /* no more "from" path left, we're done */ - else if (to[0] == '.' && to[1] == '.' - && (to[2] == '/' || to[2] == '\\')) { - if (pathlen >= 3 && out[pathlen-1] == '\\' - && out[pathlen-2] == '.' && out[pathlen-3] == '.') { - /* can't ".." against a "..", so we're done. */ - break; - } + if (to[0] == '.' && (to[1] == '/' || to[1] == '\\')) { + to += 2; /* current directory */ + while (*to == '/' || *to == '\\') + to++; /* strip off any additional slashes */ + } else if (pathlen == 0 + || (pathlen == 2 && isalpha(out[0]) && out[1] == ':')) + break; /* no more "from" path left, we're done */ + else if (to[0] == '.' && to[1] == '.' + && (to[2] == '/' || to[2] == '\\')) { + if (pathlen >= 3 && out[pathlen-1] == '\\' + && out[pathlen-2] == '.' && out[pathlen-3] == '.') { + /* can't ".." against a "..", so we're done. */ + break; + } - to += 3; /* throw away "../" (or "..\") */ - while (*to == '/' || *to == '\\') - to++; /* strip off any additional slashes */ + to += 3; /* throw away "../" (or "..\") */ + while (*to == '/' || *to == '\\') + to++; /* strip off any additional slashes */ - /* and back out last directory in "out" if not already at root */ - if (pathlen > 1) { - pathlen--; /* strip off trailing '/' */ - while (pathlen > 0 && out[pathlen-1] != '\\') - pathlen--; - } - } else - break; + /* and back out last directory in "out" if not already at root */ + if (pathlen > 1) { + pathlen--; /* strip off trailing '/' */ + while (pathlen > 0 && out[pathlen-1] != '\\') + pathlen--; + } + } else + break; } /* Copy "to" to tail of output, and we're done */ /* Combine any double slashes when copying */ for (j=pathlen; *to; to++) { - if ((*to == '/' || *to == '\\') && (*(to+1) == '/' || *(to+1) == '\\')) - continue; - if (*to == '/') - out[j++] = '\\'; - else - out[j++] = *to; + if ((*to == '/' || *to == '\\') && (*(to+1) == '/' || *(to+1) == '\\')) + continue; + if (*to == '/') + out[j++] = '\\'; + else + out[j++] = *to; } out[j++] = '\0'; return out; } -size_t -yasm__createpath_common(const char *path, int win) -{ - const char *pp = path, *pe; - char *ts, *tp; - size_t len, lth; - - lth = len = strlen(path); - ts = tp = (char *) yasm_xmalloc(len + 1); - pe = pp + len; - while (pe > pp) { - if ((win && *pe == '\\') || *pe == '/') - break; - --pe; - --lth; - } - - while (pp <= pe) { - if (pp == pe || (win && *pp == '\\') || *pp == '/') { -#ifdef _WIN32 - struct _finddata_t fi; - intptr_t h; -#elif defined(HAVE_SYS_STAT_H) - struct stat fi; -#endif - *tp = '\0'; - -#ifdef _WIN32 - h = _findfirst(ts, &fi); - if (h != -1) { - if (fi.attrib != _A_SUBDIR) { - _findclose(h); - break; - } - } else if (errno == ENOENT) { - if (_mkdir(ts) == -1) { - _findclose(h); - lth = -1; - break; - } - } - _findclose(h); -#elif defined(HAVE_SYS_STAT_H) - if (stat(ts, &fi) != -1) { - if (!S_ISDIR(fi.st_mode)) - break; - } else if (errno == ENOENT) { - if (mkdir(ts, 0755) == -1) { - lth = 0; - break; - } - } -#else - break; -#endif - } - *tp++ = *pp++; - } - yasm_xfree(ts); - return lth; -} - typedef struct incpath { STAILQ_ENTRY(incpath) link; /*@owned@*/ char *path; } incpath; -STAILQ_HEAD(incpath_head, incpath) incpaths = STAILQ_HEAD_INITIALIZER(incpaths); +STAILQ_HEAD(, incpath) incpaths = STAILQ_HEAD_INITIALIZER(incpaths); FILE * yasm_fopen_include(const char *iname, const char *from, const char *mode, - char **oname) + char **oname) { FILE *f; char *combine; @@ -544,33 +473,33 @@ yasm_fopen_include(const char *iname, const char *from, const char *mode, /* Try directly relative to from first, then each of the include paths */ if (from) { - combine = yasm__combpath(from, iname); - f = fopen(combine, mode); - if (f) { - if (oname) - *oname = combine; - else - yasm_xfree(combine); - return f; - } - yasm_xfree(combine); + combine = yasm__combpath(from, iname); + f = fopen(combine, mode); + if (f) { + if (oname) + *oname = combine; + else + yasm_xfree(combine); + return f; + } + yasm_xfree(combine); } STAILQ_FOREACH(np, &incpaths, link) { - combine = yasm__combpath(np->path, iname); - f = fopen(combine, mode); - if (f) { - if (oname) - *oname = combine; - else - yasm_xfree(combine); - return f; - } - yasm_xfree(combine); + combine = yasm__combpath(np->path, iname); + f = fopen(combine, mode); + if (f) { + if (oname) + *oname = combine; + else + yasm_xfree(combine); + return f; + } + yasm_xfree(combine); } if (oname) - *oname = NULL; + *oname = NULL; return NULL; } @@ -581,31 +510,14 @@ yasm_delete_include_paths(void) n1 = STAILQ_FIRST(&incpaths); while (n1) { - n2 = STAILQ_NEXT(n1, link); - yasm_xfree(n1->path); - yasm_xfree(n1); - n1 = n2; + n2 = STAILQ_NEXT(n1, link); + yasm_xfree(n1->path); + yasm_xfree(n1); + n1 = n2; } STAILQ_INIT(&incpaths); } -const char * -yasm_get_include_dir(void **iter) -{ - incpath *p = (incpath *)*iter; - - if (!p) - p = STAILQ_FIRST(&incpaths); - else - p = STAILQ_NEXT(p, link); - - *iter = p; - if (p) - return p->path; - else - return NULL; -} - void yasm_add_include_path(const char *path) { @@ -616,8 +528,8 @@ yasm_add_include_path(const char *path) memcpy(np->path, path, len+1); /* Add trailing slash if it is missing */ if (path[len-1] != '\\' && path[len-1] != '/') { - np->path[len] = '/'; - np->path[len+1] = '\0'; + np->path[len] = '/'; + np->path[len+1] = '\0'; } STAILQ_INSERT_TAIL(&incpaths, np, link); @@ -627,9 +539,9 @@ size_t yasm_fwrite_16_l(unsigned short val, FILE *f) { if (fputc(val & 0xFF, f) == EOF) - return 0; + return 0; if (fputc((val >> 8) & 0xFF, f) == EOF) - return 0; + return 0; return 1; } @@ -637,13 +549,13 @@ size_t yasm_fwrite_32_l(unsigned long val, FILE *f) { if (fputc((int)(val & 0xFF), f) == EOF) - return 0; + return 0; if (fputc((int)((val >> 8) & 0xFF), f) == EOF) - return 0; + return 0; if (fputc((int)((val >> 16) & 0xFF), f) == EOF) - return 0; + return 0; if (fputc((int)((val >> 24) & 0xFF), f) == EOF) - return 0; + return 0; return 1; } @@ -651,9 +563,9 @@ size_t yasm_fwrite_16_b(unsigned short val, FILE *f) { if (fputc((val >> 8) & 0xFF, f) == EOF) - return 0; + return 0; if (fputc(val & 0xFF, f) == EOF) - return 0; + return 0; return 1; } @@ -661,12 +573,12 @@ size_t yasm_fwrite_32_b(unsigned long val, FILE *f) { if (fputc((int)((val >> 24) & 0xFF), f) == EOF) - return 0; + return 0; if (fputc((int)((val >> 16) & 0xFF), f) == EOF) - return 0; + return 0; if (fputc((int)((val >> 8) & 0xFF), f) == EOF) - return 0; + return 0; if (fputc((int)(val & 0xFF), f) == EOF) - return 0; + return 0; return 1; } diff --git a/libyasm/file.h b/libyasm/file.h index 1e9b87b0..215d0f22 100644 --- a/libyasm/file.h +++ b/libyasm/file.h @@ -2,6 +2,10 @@ * \file libyasm/file.h * \brief YASM file helpers. * + * \rcs + * $Id$ + * \endrcs + * * \license * Copyright (C) 2001-2007 Peter Johnson * @@ -30,43 +34,36 @@ #ifndef YASM_FILE_H #define YASM_FILE_H -#ifndef YASM_LIB_DECL -#define YASM_LIB_DECL -#endif - /** Re2c scanner state. */ typedef struct yasm_scanner { - unsigned char *bot; /**< Bottom of scan buffer */ - unsigned char *tok; /**< Start of token */ - unsigned char *ptr; /**< Scan marker */ - unsigned char *cur; /**< Cursor (1 past end of token) */ - unsigned char *lim; /**< Limit of good data */ - unsigned char *top; /**< Top of scan buffer */ - unsigned char *eof; /**< End of file */ + unsigned char *bot; /**< Bottom of scan buffer */ + unsigned char *tok; /**< Start of token */ + unsigned char *ptr; /**< Scan marker */ + unsigned char *cur; /**< Cursor (1 past end of token) */ + unsigned char *lim; /**< Limit of good data */ + unsigned char *top; /**< Top of scan buffer */ + unsigned char *eof; /**< End of file */ } yasm_scanner; /** Initialize scanner state. * \param scanner Re2c scanner state */ -YASM_LIB_DECL void yasm_scanner_initialize(yasm_scanner *scanner); /** Frees any memory used by scanner state; does not free state itself. * \param scanner Re2c scanner state */ -YASM_LIB_DECL void yasm_scanner_delete(yasm_scanner *scanner); /** Fill a scanner state structure with data coming from an input function. - * \param scanner Re2c scanner state - * \param cursor Re2c scan cursor - * \param input_func Input function to read data; takes buffer and maximum - * number of bytes, returns number of bytes read. + * \param scanner Re2c scanner state + * \param cursor Re2c scan cursor + * \param input_func Input function to read data; takes buffer and maximum + * number of bytes, returns number of bytes read. * \param input_func_data Data to pass as the first parameter to input_func * \return 1 if this was the first time this function was called on this - * scanner state, 0 otherwise. + * scanner state, 0 otherwise. */ -YASM_LIB_DECL int yasm_fill_helper (yasm_scanner *scanner, unsigned char **cursor, size_t (*input_func) (void *d, unsigned char *buf, size_t max), @@ -78,83 +75,94 @@ int yasm_fill_helper * - hex escapes: reads as many hex digits as possible, takes last 2 as value. * - oct escapes: takes up to 3 digits 0-9 and scales appropriately, with * warning. - * \param str C-style string (updated in place) - * \param len length of string (updated with new length) + * \param str C-style string (updated in place) + * \param len length of string (updated with new length) */ -YASM_LIB_DECL void yasm_unescape_cstring(unsigned char *str, size_t *len); /** Split a UNIX pathname into head (directory) and tail (base filename) * portions. * \internal - * \param path pathname - * \param tail (returned) base filename + * \param path pathname + * \param tail (returned) base filename * \return Length of head (directory). */ -YASM_LIB_DECL size_t yasm__splitpath_unix(const char *path, /*@out@*/ const char **tail); /** Split a Windows pathname into head (directory) and tail (base filename) * portions. * \internal - * \param path pathname - * \param tail (returned) base filename + * \param path pathname + * \param tail (returned) base filename * \return Length of head (directory). */ -YASM_LIB_DECL size_t yasm__splitpath_win(const char *path, /*@out@*/ const char **tail); /** Split a pathname into head (directory) and tail (base filename) portions. * Unless otherwise defined, defaults to yasm__splitpath_unix(). * \internal - * \param path pathname - * \param tail (returned) base filename + * \param path pathname + * \param tail (returned) base filename * \return Length of head (directory). */ #ifndef yasm__splitpath # if defined (_WIN32) || defined (WIN32) || defined (__MSDOS__) || \ - defined (__DJGPP__) || defined (__OS2__) -# define yasm__splitpath(path, tail) yasm__splitpath_win(path, tail) + defined (__DJGPP__) || defined (__OS2__) || defined (__CYGWIN__) || \ + defined (__CYGWIN32__) +# define yasm__splitpath(path, tail) yasm__splitpath_win(path, tail) # else -# define yasm__splitpath(path, tail) yasm__splitpath_unix(path, tail) +# define yasm__splitpath(path, tail) yasm__splitpath_unix(path, tail) # endif #endif -/** Get the current working directory. +/** Convert a UNIX relative or absolute pathname into an absolute pathname. * \internal - * \return Current working directory pathname (newly allocated). - */ -YASM_LIB_DECL -/*@only@*/ char *yasm__getcwd(void); - -/** Convert a relative or absolute pathname into an absolute pathname. - * \internal - * \param path pathname + * \param path pathname * \return Absolute version of path (newly allocated). */ -YASM_LIB_DECL -/*@only@*/ char *yasm__abspath(const char *path); +/*@only@*/ char *yasm__abspath_unix(const char *path); + +/** Convert a Windows relative or absolute pathname into an absolute pathname. + * \internal + * \param path pathname + * \return Absolute version of path (newly allocated). + */ +/*@only@*/ char *yasm__abspath_win(const char *path); + +/** Convert a relative or absolute pathname into an absolute pathname. + * Unless otherwise defined, defaults to yasm__abspath_unix(). + * \internal + * \param path pathname + * \return Absolute version of path (newly allocated). + */ +#ifndef yasm__abspath +# if defined (_WIN32) || defined (WIN32) || defined (__MSDOS__) || \ + defined (__DJGPP__) || defined (__OS2__) || defined (__CYGWIN__) || \ + defined (__CYGWIN32__) +# define yasm__abspath(path) yasm__abspath_win(path) +# else +# define yasm__abspath(path) yasm__abspath_unix(path) +# endif +#endif /** Build a UNIX pathname that is equivalent to accessing the "to" pathname * when you're in the directory containing "from". Result is relative if both * from and to are relative. * \internal - * \param from from pathname - * \param to to pathname + * \param from from pathname + * \param to to pathname * \return Combined path (newly allocated). */ -YASM_LIB_DECL char *yasm__combpath_unix(const char *from, const char *to); /** Build a Windows pathname that is equivalent to accessing the "to" pathname * when you're in the directory containing "from". Result is relative if both * from and to are relative. * \internal - * \param from from pathname - * \param to to pathname + * \param from from pathname + * \param to to pathname * \return Combined path (newly allocated). */ -YASM_LIB_DECL char *yasm__combpath_win(const char *from, const char *to); /** Build a pathname that is equivalent to accessing the "to" pathname @@ -162,40 +170,17 @@ char *yasm__combpath_win(const char *from, const char *to); * from and to are relative. * Unless otherwise defined, defaults to yasm__combpath_unix(). * \internal - * \param from from pathname - * \param to to pathname + * \param from from pathname + * \param to to pathname * \return Combined path (newly allocated). */ #ifndef yasm__combpath # if defined (_WIN32) || defined (WIN32) || defined (__MSDOS__) || \ - defined (__DJGPP__) || defined (__OS2__) -# define yasm__combpath(from, to) yasm__combpath_win(from, to) + defined (__DJGPP__) || defined (__OS2__) || defined (__CYGWIN__) || \ + defined (__CYGWIN32__) +# define yasm__combpath(from, to) yasm__combpath_win(from, to) # else -# define yasm__combpath(from, to) yasm__combpath_unix(from, to) -# endif -#endif - -/** Recursively create tree of directories needed for pathname. - * \internal - * \param path pathname - * \param win handle windows paths - * \return Length of directory portion of pathname. - */ -YASM_LIB_DECL -size_t yasm__createpath_common(const char *path, int win); - -/** Recursively create tree of directories needed for pathname. - * Unless otherwise defined, defaults to yasm__createpath_unix(). - * \internal - * \param path pathname - * \return Length of directory portion of pathname. - */ -#ifndef yasm__createpath -# if defined (_WIN32) || defined (WIN32) || defined (__MSDOS__) || \ - defined (__DJGPP__) || defined (__OS2__) -# define yasm__createpath(path) yasm__createpath_common(path, 1) -# else -# define yasm__createpath(path) yasm__createpath_common(path, 0) +# define yasm__combpath(from, to) yasm__combpath_unix(from, to) # endif #endif @@ -210,316 +195,304 @@ size_t yasm__createpath_common(const char *path, int win); * is saved into oname, and the fopen'ed FILE * is returned. If not found, * NULL is returned. * - * \param iname file to include - * \param from file doing the including - * \param mode fopen mode string - * \param oname full pathname of included file (may be relative). NULL - * may be passed if this is unwanted. + * \param iname file to include + * \param from file doing the including + * \param mode fopen mode string + * \param oname full pathname of included file (may be relative). NULL + * may be passed if this is unwanted. * \return fopen'ed include file, or NULL if not found. */ -YASM_LIB_DECL /*@null@*/ FILE *yasm_fopen_include (const char *iname, const char *from, const char *mode, /*@null@*/ /*@out@*/ /*@only@*/ char **oname); /** Delete any stored include paths added by yasm_add_include_path(). */ -YASM_LIB_DECL void yasm_delete_include_paths(void); -/** Iterate through include paths. -*/ -YASM_LIB_DECL -const char * yasm_get_include_dir(void **iter); - /** Add an include path for use by yasm_fopen_include(). * If path is relative, it is treated by yasm_fopen_include() as relative to * the current working directory. * - * \param path path to add + * \param path path to add */ -YASM_LIB_DECL void yasm_add_include_path(const char *path); /** Write an 8-bit value to a buffer, incrementing buffer pointer. * \note Only works properly if ptr is an (unsigned char *). - * \param ptr buffer - * \param val 8-bit value + * \param ptr buffer + * \param val 8-bit value */ -#define YASM_WRITE_8(ptr, val) \ - *((ptr)++) = (unsigned char)((val) & 0xFF) +#define YASM_WRITE_8(ptr, val) \ + *((ptr)++) = (unsigned char)((val) & 0xFF) /** Write a 16-bit value to a buffer in little endian, incrementing buffer * pointer. * \note Only works properly if ptr is an (unsigned char *). - * \param ptr buffer - * \param val 16-bit value + * \param ptr buffer + * \param val 16-bit value */ -#define YASM_WRITE_16_L(ptr, val) \ - do { \ - *((ptr)++) = (unsigned char)((val) & 0xFF); \ - *((ptr)++) = (unsigned char)(((val) >> 8) & 0xFF); \ - } while (0) +#define YASM_WRITE_16_L(ptr, val) \ + do { \ + *((ptr)++) = (unsigned char)((val) & 0xFF); \ + *((ptr)++) = (unsigned char)(((val) >> 8) & 0xFF); \ + } while (0) /** Write a 32-bit value to a buffer in little endian, incrementing buffer * pointer. * \note Only works properly if ptr is an (unsigned char *). - * \param ptr buffer - * \param val 32-bit value + * \param ptr buffer + * \param val 32-bit value */ -#define YASM_WRITE_32_L(ptr, val) \ - do { \ - *((ptr)++) = (unsigned char)((val) & 0xFF); \ - *((ptr)++) = (unsigned char)(((val) >> 8) & 0xFF); \ - *((ptr)++) = (unsigned char)(((val) >> 16) & 0xFF); \ - *((ptr)++) = (unsigned char)(((val) >> 24) & 0xFF); \ - } while (0) +#define YASM_WRITE_32_L(ptr, val) \ + do { \ + *((ptr)++) = (unsigned char)((val) & 0xFF); \ + *((ptr)++) = (unsigned char)(((val) >> 8) & 0xFF); \ + *((ptr)++) = (unsigned char)(((val) >> 16) & 0xFF); \ + *((ptr)++) = (unsigned char)(((val) >> 24) & 0xFF); \ + } while (0) /** Write a 16-bit value to a buffer in big endian, incrementing buffer * pointer. * \note Only works properly if ptr is an (unsigned char *). - * \param ptr buffer - * \param val 16-bit value + * \param ptr buffer + * \param val 16-bit value */ -#define YASM_WRITE_16_B(ptr, val) \ - do { \ - *((ptr)++) = (unsigned char)(((val) >> 8) & 0xFF); \ - *((ptr)++) = (unsigned char)((val) & 0xFF); \ - } while (0) +#define YASM_WRITE_16_B(ptr, val) \ + do { \ + *((ptr)++) = (unsigned char)(((val) >> 8) & 0xFF); \ + *((ptr)++) = (unsigned char)((val) & 0xFF); \ + } while (0) /** Write a 32-bit value to a buffer in big endian, incrementing buffer * pointer. * \note Only works properly if ptr is an (unsigned char *). - * \param ptr buffer - * \param val 32-bit value + * \param ptr buffer + * \param val 32-bit value */ -#define YASM_WRITE_32_B(ptr, val) \ - do { \ - *((ptr)++) = (unsigned char)(((val) >> 24) & 0xFF); \ - *((ptr)++) = (unsigned char)(((val) >> 16) & 0xFF); \ - *((ptr)++) = (unsigned char)(((val) >> 8) & 0xFF); \ - *((ptr)++) = (unsigned char)((val) & 0xFF); \ - } while (0) +#define YASM_WRITE_32_B(ptr, val) \ + do { \ + *((ptr)++) = (unsigned char)(((val) >> 24) & 0xFF); \ + *((ptr)++) = (unsigned char)(((val) >> 16) & 0xFF); \ + *((ptr)++) = (unsigned char)(((val) >> 8) & 0xFF); \ + *((ptr)++) = (unsigned char)((val) & 0xFF); \ + } while (0) /** Write an 8-bit value to a buffer. Does not increment buffer pointer. * \note Only works properly if ptr is an (unsigned char *). - * \param ptr buffer - * \param val 8-bit value + * \param ptr buffer + * \param val 8-bit value */ -#define YASM_SAVE_8(ptr, val) \ - *(ptr) = (unsigned char)((val) & 0xFF) +#define YASM_SAVE_8(ptr, val) \ + *(ptr) = (unsigned char)((val) & 0xFF) /** Write a 16-bit value to a buffer in little endian. Does not increment * buffer pointer. * \note Only works properly if ptr is an (unsigned char *). - * \param ptr buffer - * \param val 16-bit value + * \param ptr buffer + * \param val 16-bit value */ -#define YASM_SAVE_16_L(ptr, val) \ - do { \ - *(ptr) = (unsigned char)((val) & 0xFF); \ - *((ptr)+1) = (unsigned char)(((val) >> 8) & 0xFF); \ - } while (0) +#define YASM_SAVE_16_L(ptr, val) \ + do { \ + *(ptr) = (unsigned char)((val) & 0xFF); \ + *((ptr)+1) = (unsigned char)(((val) >> 8) & 0xFF); \ + } while (0) /** Write a 32-bit value to a buffer in little endian. Does not increment * buffer pointer. * \note Only works properly if ptr is an (unsigned char *). - * \param ptr buffer - * \param val 32-bit value + * \param ptr buffer + * \param val 32-bit value */ -#define YASM_SAVE_32_L(ptr, val) \ - do { \ - *(ptr) = (unsigned char)((val) & 0xFF); \ - *((ptr)+1) = (unsigned char)(((val) >> 8) & 0xFF); \ - *((ptr)+2) = (unsigned char)(((val) >> 16) & 0xFF); \ - *((ptr)+3) = (unsigned char)(((val) >> 24) & 0xFF); \ - } while (0) +#define YASM_SAVE_32_L(ptr, val) \ + do { \ + *(ptr) = (unsigned char)((val) & 0xFF); \ + *((ptr)+1) = (unsigned char)(((val) >> 8) & 0xFF); \ + *((ptr)+2) = (unsigned char)(((val) >> 16) & 0xFF); \ + *((ptr)+3) = (unsigned char)(((val) >> 24) & 0xFF); \ + } while (0) /** Write a 16-bit value to a buffer in big endian. Does not increment buffer * pointer. * \note Only works properly if ptr is an (unsigned char *). - * \param ptr buffer - * \param val 16-bit value + * \param ptr buffer + * \param val 16-bit value */ -#define YASM_SAVE_16_B(ptr, val) \ - do { \ - *(ptr) = (unsigned char)(((val) >> 8) & 0xFF); \ - *((ptr)+1) = (unsigned char)((val) & 0xFF); \ - } while (0) +#define YASM_SAVE_16_B(ptr, val) \ + do { \ + *(ptr) = (unsigned char)(((val) >> 8) & 0xFF); \ + *((ptr)+1) = (unsigned char)((val) & 0xFF); \ + } while (0) /** Write a 32-bit value to a buffer in big endian. Does not increment buffer * pointer. * \note Only works properly if ptr is an (unsigned char *). - * \param ptr buffer - * \param val 32-bit value + * \param ptr buffer + * \param val 32-bit value */ -#define YASM_SAVE_32_B(ptr, val) \ - do { \ - *(ptr) = (unsigned char)(((val) >> 24) & 0xFF); \ - *((ptr)+1) = (unsigned char)(((val) >> 16) & 0xFF); \ - *((ptr)+2) = (unsigned char)(((val) >> 8) & 0xFF); \ - *((ptr)+3) = (unsigned char)((val) & 0xFF); \ - } while (0) +#define YASM_SAVE_32_B(ptr, val) \ + do { \ + *(ptr) = (unsigned char)(((val) >> 24) & 0xFF); \ + *((ptr)+1) = (unsigned char)(((val) >> 16) & 0xFF); \ + *((ptr)+2) = (unsigned char)(((val) >> 8) & 0xFF); \ + *((ptr)+3) = (unsigned char)((val) & 0xFF); \ + } while (0) /** Direct-to-file version of YASM_SAVE_16_L(). * \note Using the macro multiple times with a single fwrite() call will * probably be faster than calling this function many times. - * \param val 16-bit value - * \param f file + * \param val 16-bit value + * \param f file * \return 1 if the write was successful, 0 if not (just like fwrite()). */ -YASM_LIB_DECL size_t yasm_fwrite_16_l(unsigned short val, FILE *f); /** Direct-to-file version of YASM_SAVE_32_L(). * \note Using the macro multiple times with a single fwrite() call will * probably be faster than calling this function many times. - * \param val 32-bit value - * \param f file + * \param val 32-bit value + * \param f file * \return 1 if the write was successful, 0 if not (just like fwrite()). */ -YASM_LIB_DECL size_t yasm_fwrite_32_l(unsigned long val, FILE *f); /** Direct-to-file version of YASM_SAVE_16_B(). * \note Using the macro multiple times with a single fwrite() call will * probably be faster than calling this function many times. - * \param val 16-bit value - * \param f file + * \param val 16-bit value + * \param f file * \return 1 if the write was successful, 0 if not (just like fwrite()). */ -YASM_LIB_DECL size_t yasm_fwrite_16_b(unsigned short val, FILE *f); /** Direct-to-file version of YASM_SAVE_32_B(). * \note Using the macro multiple times with a single fwrite() call will * probably be faster than calling this function many times. - * \param val 32-bit value - * \param f file + * \param val 32-bit value + * \param f file * \return 1 if the write was successful, 0 if not (just like fwrite()). */ -YASM_LIB_DECL size_t yasm_fwrite_32_b(unsigned long val, FILE *f); /** Read an 8-bit value from a buffer, incrementing buffer pointer. * \note Only works properly if ptr is an (unsigned char *). - * \param ptr buffer - * \param val 8-bit value + * \param ptr buffer + * \param val 8-bit value */ -#define YASM_READ_8(val, ptr) \ - (val) = *((ptr)++) & 0xFF +#define YASM_READ_8(val, ptr) \ + (val) = *((ptr)++) & 0xFF /** Read a 16-bit value from a buffer in little endian, incrementing buffer * pointer. * \note Only works properly if ptr is an (unsigned char *). - * \param ptr buffer - * \param val 16-bit value + * \param ptr buffer + * \param val 16-bit value */ -#define YASM_READ_16_L(val, ptr) \ - do { \ - (val) = *((ptr)++) & 0xFF; \ - (val) |= (*((ptr)++) & 0xFF) << 8; \ - } while (0) +#define YASM_READ_16_L(val, ptr) \ + do { \ + (val) = *((ptr)++) & 0xFF; \ + (val) |= (*((ptr)++) & 0xFF) << 8; \ + } while (0) /** Read a 32-bit value from a buffer in little endian, incrementing buffer * pointer. * \note Only works properly if ptr is an (unsigned char *). - * \param ptr buffer - * \param val 32-bit value + * \param ptr buffer + * \param val 32-bit value */ -#define YASM_READ_32_L(val, ptr) \ - do { \ - (val) = *((ptr)++) & 0xFF; \ - (val) |= (*((ptr)++) & 0xFF) << 8; \ - (val) |= (*((ptr)++) & 0xFF) << 16; \ - (val) |= (*((ptr)++) & 0xFF) << 24; \ - } while (0) +#define YASM_READ_32_L(val, ptr) \ + do { \ + (val) = *((ptr)++) & 0xFF; \ + (val) |= (*((ptr)++) & 0xFF) << 8; \ + (val) |= (*((ptr)++) & 0xFF) << 16; \ + (val) |= (*((ptr)++) & 0xFF) << 24; \ + } while (0) /** Read a 16-bit value from a buffer in big endian, incrementing buffer * pointer. * \note Only works properly if ptr is an (unsigned char *). - * \param ptr buffer - * \param val 16-bit value + * \param ptr buffer + * \param val 16-bit value */ -#define YASM_READ_16_B(val, ptr) \ - do { \ - (val) = (*((ptr)++) & 0xFF) << 8; \ - (val) |= *((ptr)++) & 0xFF; \ - } while (0) +#define YASM_READ_16_B(val, ptr) \ + do { \ + (val) = (*((ptr)++) & 0xFF) << 8; \ + (val) |= *((ptr)++) & 0xFF; \ + } while (0) /** Read a 32-bit value from a buffer in big endian, incrementing buffer * pointer. * \note Only works properly if ptr is an (unsigned char *). - * \param ptr buffer - * \param val 32-bit value + * \param ptr buffer + * \param val 32-bit value */ -#define YASM_READ_32_B(val, ptr) \ - do { \ - (val) = (*((ptr)++) & 0xFF) << 24; \ - (val) |= (*((ptr)++) & 0xFF) << 16; \ - (val) |= (*((ptr)++) & 0xFF) << 8; \ - (val) |= *((ptr)++) & 0xFF; \ - } while (0) +#define YASM_READ_32_B(val, ptr) \ + do { \ + (val) = (*((ptr)++) & 0xFF) << 24; \ + (val) |= (*((ptr)++) & 0xFF) << 16; \ + (val) |= (*((ptr)++) & 0xFF) << 8; \ + (val) |= *((ptr)++) & 0xFF; \ + } while (0) /** Read an 8-bit value from a buffer. Does not increment buffer pointer. * \note Only works properly if ptr is an (unsigned char *). - * \param ptr buffer - * \param val 8-bit value + * \param ptr buffer + * \param val 8-bit value */ -#define YASM_LOAD_8(val, ptr) \ - (val) = *(ptr) & 0xFF +#define YASM_LOAD_8(val, ptr) \ + (val) = *(ptr) & 0xFF /** Read a 16-bit value from a buffer in little endian. Does not increment * buffer pointer. * \note Only works properly if ptr is an (unsigned char *). - * \param ptr buffer - * \param val 16-bit value + * \param ptr buffer + * \param val 16-bit value */ -#define YASM_LOAD_16_L(val, ptr) \ - do { \ - (val) = *(ptr) & 0xFF; \ - (val) |= (*((ptr)+1) & 0xFF) << 8; \ - } while (0) +#define YASM_LOAD_16_L(val, ptr) \ + do { \ + (val) = *(ptr) & 0xFF; \ + (val) |= (*((ptr)+1) & 0xFF) << 8; \ + } while (0) /** Read a 32-bit value from a buffer in little endian. Does not increment * buffer pointer. * \note Only works properly if ptr is an (unsigned char *). - * \param ptr buffer - * \param val 32-bit value + * \param ptr buffer + * \param val 32-bit value */ -#define YASM_LOAD_32_L(val, ptr) \ - do { \ - (val) = (unsigned long)(*(ptr) & 0xFF); \ - (val) |= (unsigned long)((*((ptr)+1) & 0xFF) << 8); \ - (val) |= (unsigned long)((*((ptr)+2) & 0xFF) << 16); \ - (val) |= (unsigned long)((*((ptr)+3) & 0xFF) << 24); \ - } while (0) +#define YASM_LOAD_32_L(val, ptr) \ + do { \ + (val) = (unsigned long)(*(ptr) & 0xFF); \ + (val) |= (unsigned long)((*((ptr)+1) & 0xFF) << 8); \ + (val) |= (unsigned long)((*((ptr)+2) & 0xFF) << 16); \ + (val) |= (unsigned long)((*((ptr)+3) & 0xFF) << 24); \ + } while (0) /** Read a 16-bit value from a buffer in big endian. Does not increment buffer * pointer. * \note Only works properly if ptr is an (unsigned char *). - * \param ptr buffer - * \param val 16-bit value + * \param ptr buffer + * \param val 16-bit value */ -#define YASM_LOAD_16_B(val, ptr) \ - do { \ - (val) = (*(ptr) & 0xFF) << 8; \ - (val) |= *((ptr)+1) & 0xFF; \ - } while (0) +#define YASM_LOAD_16_B(val, ptr) \ + do { \ + (val) = (*(ptr) & 0xFF) << 8; \ + (val) |= *((ptr)+1) & 0xFF; \ + } while (0) /** Read a 32-bit value from a buffer in big endian. Does not increment buffer * pointer. * \note Only works properly if ptr is an (unsigned char *). - * \param ptr buffer - * \param val 32-bit value + * \param ptr buffer + * \param val 32-bit value */ -#define YASM_LOAD_32_B(val, ptr) \ - do { \ - (val) = (unsigned long)((*(ptr) & 0xFF) << 24); \ - (val) |= (unsigned long)((*((ptr)+1) & 0xFF) << 16); \ - (val) |= (unsigned long)((*((ptr)+2) & 0xFF) << 8); \ - (val) |= (unsigned long)(*((ptr)+3) & 0xFF); \ - } while (0) +#define YASM_LOAD_32_B(val, ptr) \ + do { \ + (val) = (unsigned long)((*(ptr) & 0xFF) << 24); \ + (val) |= (unsigned long)((*((ptr)+1) & 0xFF) << 16); \ + (val) |= (unsigned long)((*((ptr)+2) & 0xFF) << 8); \ + (val) |= (unsigned long)(*((ptr)+3) & 0xFF); \ + } while (0) #endif diff --git a/libyasm/floatnum.c b/libyasm/floatnum.c index ab67c2b2..3f50dda5 100644 --- a/libyasm/floatnum.c +++ b/libyasm/floatnum.c @@ -26,7 +26,9 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ +#define YASM_LIB_INTERNAL #include "util.h" +/*@unused@*/ RCSID("$Id$"); #include @@ -48,24 +50,24 @@ * Mantissa does NOT have an implied one bit (it's explicit). */ struct yasm_floatnum { - /*@only@*/ wordptr mantissa; /* Allocated to MANT_BITS bits */ + /*@only@*/ wordptr mantissa; /* Allocated to MANT_BITS bits */ unsigned short exponent; unsigned char sign; unsigned char flags; }; /* constants describing parameters of internal floating point format */ -#define MANT_BITS 80 -#define MANT_BYTES 10 -#define MANT_SIGDIGITS 24 -#define EXP_BIAS 0x7FFF -#define EXP_INF 0xFFFF -#define EXP_MAX 0xFFFE -#define EXP_MIN 1 -#define EXP_ZERO 0 +#define MANT_BITS 80 +#define MANT_BYTES 10 +#define MANT_SIGDIGITS 24 +#define EXP_BIAS 0x7FFF +#define EXP_INF 0xFFFF +#define EXP_MAX 0xFFFE +#define EXP_MIN 1 +#define EXP_ZERO 0 /* Flag settings for flags field */ -#define FLAG_ISZERO 1<<0 +#define FLAG_ISZERO 1<<0 /* Note this structure integrates the floatnum structure */ typedef struct POT_Entry_s { @@ -75,8 +77,8 @@ typedef struct POT_Entry_s { /* "Source" for POT_Entry. */ typedef struct POT_Entry_Source_s { - unsigned char mantissa[MANT_BYTES]; /* little endian mantissa */ - unsigned short exponent; /* Bias 32767 exponent */ + unsigned char mantissa[MANT_BYTES]; /* little endian mantissa */ + unsigned short exponent; /* Bias 32767 exponent */ } POT_Entry_Source; /* Power of ten tables used by the floating point I/O routines. @@ -171,9 +173,9 @@ yasm_floatnum_initialize(void) /* Initialize entry[0..12] */ for (i=12; i>=0; i--) { - POT_Table_Init_Entry(&POT_TableN[i], &POT_TableN_Source[i], 0-dec_exp); - POT_Table_Init_Entry(&POT_TableP[i+1], &POT_TableP_Source[i], dec_exp); - dec_exp *= 2; /* Update decimal exponent */ + POT_Table_Init_Entry(&POT_TableN[i], &POT_TableN_Source[i], 0-dec_exp); + POT_Table_Init_Entry(&POT_TableP[i+1], &POT_TableP_Source[i], dec_exp); + dec_exp *= 2; /* Update decimal exponent */ } /* Initialize entry[13] */ @@ -198,8 +200,8 @@ yasm_floatnum_cleanup(void) POT_TableP--; for (i=0; i<14; i++) { - BitVector_Destroy(POT_TableN[i].f.mantissa); - BitVector_Destroy(POT_TableP[i].f.mantissa); + BitVector_Destroy(POT_TableN[i].f.mantissa); + BitVector_Destroy(POT_TableP[i].f.mantissa); } BitVector_Destroy(POT_TableP[14].f.mantissa); @@ -214,15 +216,15 @@ floatnum_normalize(yasm_floatnum *flt) long norm_amt; if (BitVector_is_empty(flt->mantissa)) { - flt->exponent = 0; - return; + flt->exponent = 0; + return; } /* Look for the highest set bit, shift to make it the MSB, and adjust * exponent. Don't let exponent go negative. */ norm_amt = (MANT_BITS-1)-Set_Max(flt->mantissa); if (norm_amt > (long)flt->exponent) - norm_amt = (long)flt->exponent; + norm_amt = (long)flt->exponent; BitVector_Move_Left(flt->mantissa, (N_int)norm_amt); flt->exponent -= (unsigned short)norm_amt; } @@ -240,24 +242,24 @@ floatnum_mul(yasm_floatnum *acc, const yasm_floatnum *op) /* Check for multiply by 0 */ if (BitVector_is_empty(acc->mantissa) || BitVector_is_empty(op->mantissa)) { - BitVector_Empty(acc->mantissa); - acc->exponent = EXP_ZERO; - return; + BitVector_Empty(acc->mantissa); + acc->exponent = EXP_ZERO; + return; } /* Add exponents, checking for overflow/underflow. */ expon = (((int)acc->exponent)-EXP_BIAS) + (((int)op->exponent)-EXP_BIAS); expon += EXP_BIAS; if (expon > EXP_MAX) { - /* Overflow; return infinity. */ - BitVector_Empty(acc->mantissa); - acc->exponent = EXP_INF; - return; + /* Overflow; return infinity. */ + BitVector_Empty(acc->mantissa); + acc->exponent = EXP_INF; + return; } else if (expon < EXP_MIN) { - /* Underflow; return zero. */ - BitVector_Empty(acc->mantissa); - acc->exponent = EXP_ZERO; - return; + /* Underflow; return zero. */ + BitVector_Empty(acc->mantissa); + acc->exponent = EXP_ZERO; + return; } /* Add one to the final exponent, as the multiply shifts one extra time. */ @@ -287,7 +289,7 @@ floatnum_mul(yasm_floatnum *acc, const yasm_floatnum *op) */ norm_amt = (MANT_BITS*2-1)-Set_Max(product); if (norm_amt > (long)acc->exponent) - norm_amt = (long)acc->exponent; + norm_amt = (long)acc->exponent; BitVector_Move_Left(product, (N_int)norm_amt); acc->exponent -= (unsigned short)norm_amt; @@ -304,7 +306,7 @@ yasm_floatnum * yasm_floatnum_create(const char *str) { yasm_floatnum *flt; - int dec_exponent, dec_exp_add; /* decimal (powers of 10) exponent */ + int dec_exponent, dec_exp_add; /* decimal (powers of 10) exponent */ int POT_index; wordptr operand[2]; int sig_digits; @@ -327,17 +329,17 @@ yasm_floatnum_create(const char *str) /* check for + or - character and skip */ if (*str == '-') { - flt->sign = 1; - str++; + flt->sign = 1; + str++; } else if (*str == '+') { - flt->sign = 0; - str++; + flt->sign = 0; + str++; } else - flt->sign = 0; + flt->sign = 0; /* eliminate any leading zeros (which do not count as significant digits) */ while (*str == '0') - str++; + str++; /* When we reach the end of the leading zeros, first check for a decimal * point. If the number is of the form "0---0.0000" we need to get rid @@ -345,78 +347,78 @@ yasm_floatnum_create(const char *str) * digits. */ if (*str == '.') { - str++; - while (*str == '0') { - str++; - dec_exponent--; - } + str++; + while (*str == '0') { + str++; + dec_exponent--; + } } else { - /* The number is of the form "yyy.xxxx" (where y <> 0). */ - while (isdigit(*str)) { - /* See if we've processed more than the max significant digits: */ - if (sig_digits < MANT_SIGDIGITS) { - /* Multiply mantissa by 10 [x = (x<<1)+(x<<3)] */ - BitVector_shift_left(flt->mantissa, 0); - BitVector_Copy(operand[0], flt->mantissa); - BitVector_Move_Left(flt->mantissa, 2); - carry = 0; - BitVector_add(operand[1], operand[0], flt->mantissa, &carry); + /* The number is of the form "yyy.xxxx" (where y <> 0). */ + while (isdigit(*str)) { + /* See if we've processed more than the max significant digits: */ + if (sig_digits < MANT_SIGDIGITS) { + /* Multiply mantissa by 10 [x = (x<<1)+(x<<3)] */ + BitVector_shift_left(flt->mantissa, 0); + BitVector_Copy(operand[0], flt->mantissa); + BitVector_Move_Left(flt->mantissa, 2); + carry = 0; + BitVector_add(operand[1], operand[0], flt->mantissa, &carry); - /* Add in current digit */ - BitVector_Empty(operand[0]); - BitVector_Chunk_Store(operand[0], 4, 0, (N_long)(*str-'0')); - carry = 0; - BitVector_add(flt->mantissa, operand[1], operand[0], &carry); - } else { - /* Can't integrate more digits with mantissa, so instead just - * raise by a power of ten. - */ - dec_exponent++; - } - sig_digits++; - str++; - } + /* Add in current digit */ + BitVector_Empty(operand[0]); + BitVector_Chunk_Store(operand[0], 4, 0, (N_long)(*str-'0')); + carry = 0; + BitVector_add(flt->mantissa, operand[1], operand[0], &carry); + } else { + /* Can't integrate more digits with mantissa, so instead just + * raise by a power of ten. + */ + dec_exponent++; + } + sig_digits++; + str++; + } - if (*str == '.') - str++; - else - decimal_pt = 0; + if (*str == '.') + str++; + else + decimal_pt = 0; } if (decimal_pt) { - /* Process the digits to the right of the decimal point. */ - while (isdigit(*str)) { - /* See if we've processed more than 19 significant digits: */ - if (sig_digits < 19) { - /* Raise by a power of ten */ - dec_exponent--; + /* Process the digits to the right of the decimal point. */ + while (isdigit(*str)) { + /* See if we've processed more than 19 significant digits: */ + if (sig_digits < 19) { + /* Raise by a power of ten */ + dec_exponent--; - /* Multiply mantissa by 10 [x = (x<<1)+(x<<3)] */ - BitVector_shift_left(flt->mantissa, 0); - BitVector_Copy(operand[0], flt->mantissa); - BitVector_Move_Left(flt->mantissa, 2); - carry = 0; - BitVector_add(operand[1], operand[0], flt->mantissa, &carry); + /* Multiply mantissa by 10 [x = (x<<1)+(x<<3)] */ + BitVector_shift_left(flt->mantissa, 0); + BitVector_Copy(operand[0], flt->mantissa); + BitVector_Move_Left(flt->mantissa, 2); + carry = 0; + BitVector_add(operand[1], operand[0], flt->mantissa, &carry); - /* Add in current digit */ - BitVector_Empty(operand[0]); - BitVector_Chunk_Store(operand[0], 4, 0, (N_long)(*str-'0')); - carry = 0; - BitVector_add(flt->mantissa, operand[1], operand[0], &carry); - } - sig_digits++; - str++; - } + /* Add in current digit */ + BitVector_Empty(operand[0]); + BitVector_Chunk_Store(operand[0], 4, 0, (N_long)(*str-'0')); + carry = 0; + BitVector_add(flt->mantissa, operand[1], operand[0], &carry); + } + sig_digits++; + str++; + } } if (*str == 'e' || *str == 'E') { - str++; - /* We just saw the "E" character, now read in the exponent value and - * add it into dec_exponent. - */ - dec_exp_add = 0; - sscanf(str, "%d", &dec_exp_add); - dec_exponent += dec_exp_add; + str++; + /* We just saw the "E" character, now read in the exponent value and + * add it into dec_exponent. + */ + dec_exp_add = 0; + sscanf(str, "%d", &dec_exp_add); + dec_exponent += dec_exp_add; } /* Free calculation variables. */ @@ -425,12 +427,12 @@ yasm_floatnum_create(const char *str) /* Normalize the number, checking for 0 first. */ if (BitVector_is_empty(flt->mantissa)) { - /* Mantissa is 0, zero exponent too. */ - flt->exponent = 0; - /* Set zero flag so output functions don't see 0 value as underflow. */ - flt->flags |= FLAG_ISZERO; - /* Return 0 value. */ - return flt; + /* Mantissa is 0, zero exponent too. */ + flt->exponent = 0; + /* Set zero flag so output functions don't see 0 value as underflow. */ + flt->flags |= FLAG_ISZERO; + /* Return 0 value. */ + return flt; } /* Exponent if already norm. */ flt->exponent = (unsigned short)(0x7FFF+(MANT_BITS-1)); @@ -441,43 +443,43 @@ yasm_floatnum_create(const char *str) * up this operation (and make it more accurate). */ if (dec_exponent > 0) { - POT_index = 0; - /* Until we hit 1.0 or finish exponent or overflow */ - while ((POT_index < 14) && (dec_exponent != 0) && - (flt->exponent != EXP_INF)) { - /* Find the first power of ten in the table which is just less than - * the exponent. - */ - while (dec_exponent < POT_TableP[POT_index].dec_exponent) - POT_index++; + POT_index = 0; + /* Until we hit 1.0 or finish exponent or overflow */ + while ((POT_index < 14) && (dec_exponent != 0) && + (flt->exponent != EXP_INF)) { + /* Find the first power of ten in the table which is just less than + * the exponent. + */ + while (dec_exponent < POT_TableP[POT_index].dec_exponent) + POT_index++; - if (POT_index < 14) { - /* Subtract out what we're multiplying in from exponent */ - dec_exponent -= POT_TableP[POT_index].dec_exponent; + if (POT_index < 14) { + /* Subtract out what we're multiplying in from exponent */ + dec_exponent -= POT_TableP[POT_index].dec_exponent; - /* Multiply by current power of 10 */ - floatnum_mul(flt, &POT_TableP[POT_index].f); - } - } + /* Multiply by current power of 10 */ + floatnum_mul(flt, &POT_TableP[POT_index].f); + } + } } else if (dec_exponent < 0) { - POT_index = 0; - /* Until we hit 1.0 or finish exponent or underflow */ - while ((POT_index < 14) && (dec_exponent != 0) && - (flt->exponent != EXP_ZERO)) { - /* Find the first power of ten in the table which is just less than - * the exponent. - */ - while (dec_exponent > POT_TableN[POT_index].dec_exponent) - POT_index++; + POT_index = 0; + /* Until we hit 1.0 or finish exponent or underflow */ + while ((POT_index < 14) && (dec_exponent != 0) && + (flt->exponent != EXP_ZERO)) { + /* Find the first power of ten in the table which is just less than + * the exponent. + */ + while (dec_exponent > POT_TableN[POT_index].dec_exponent) + POT_index++; - if (POT_index < 14) { - /* Subtract out what we're multiplying in from exponent */ - dec_exponent -= POT_TableN[POT_index].dec_exponent; + if (POT_index < 14) { + /* Subtract out what we're multiplying in from exponent */ + dec_exponent -= POT_TableN[POT_index].dec_exponent; - /* Multiply by current power of 10 */ - floatnum_mul(flt, &POT_TableN[POT_index].f); - } - } + /* Multiply by current power of 10 */ + floatnum_mul(flt, &POT_TableN[POT_index].f); + } + } } /* Round the result. (Don't round underflow or overflow). Also don't @@ -485,7 +487,7 @@ yasm_floatnum_create(const char *str) */ if ((flt->exponent != EXP_INF) && (flt->exponent != EXP_ZERO) && !BitVector_is_full(flt->mantissa)) - BitVector_increment(flt->mantissa); + BitVector_increment(flt->mantissa); return flt; } @@ -512,12 +514,12 @@ yasm_floatnum_destroy(yasm_floatnum *flt) int yasm_floatnum_calc(yasm_floatnum *acc, yasm_expr_op op, - /*@unused@*/ yasm_floatnum *operand) + /*@unused@*/ yasm_floatnum *operand) { if (op != YASM_EXPR_NEG) { - yasm_error_set(YASM_ERROR_FLOATING_POINT, - N_("Unsupported floating-point arithmetic operation")); - return 1; + yasm_error_set(YASM_ERROR_FLOATING_POINT, + N_("Unsupported floating-point arithmetic operation")); + return 1; } acc->sign ^= 1; return 0; @@ -529,8 +531,8 @@ yasm_floatnum_get_int(const yasm_floatnum *flt, unsigned long *ret_val) unsigned char t[4]; if (yasm_floatnum_get_sized(flt, t, 4, 32, 0, 0, 0)) { - *ret_val = 0xDEADBEEFUL; /* Obviously incorrect return value */ - return 1; + *ret_val = 0xDEADBEEFUL; /* Obviously incorrect return value */ + return 1; } YASM_LOAD_32_L(*ret_val, &t[0]); @@ -550,8 +552,8 @@ yasm_floatnum_get_int(const yasm_floatnum *flt, unsigned long *ret_val) */ static int floatnum_get_common(const yasm_floatnum *flt, /*@out@*/ unsigned char *ptr, - N_int byte_size, N_int mant_bits, int implicit1, - N_int exp_bits) + N_int byte_size, N_int mant_bits, int implicit1, + N_int exp_bits) { long exponent = (long)flt->exponent; wordptr output; @@ -566,45 +568,45 @@ floatnum_get_common(const yasm_floatnum *flt, /*@out@*/ unsigned char *ptr, /* copy mantissa */ BitVector_Interval_Copy(output, flt->mantissa, 0, - (N_int)((MANT_BITS-implicit1)-mant_bits), - mant_bits); + (N_int)((MANT_BITS-implicit1)-mant_bits), + mant_bits); /* round mantissa */ if (BitVector_bit_test(flt->mantissa, (MANT_BITS-implicit1)-(mant_bits+1))) - BitVector_increment(output); + BitVector_increment(output); if (BitVector_bit_test(output, mant_bits)) { - /* overflowed, so zero mantissa (and set explicit bit if necessary) */ - BitVector_Empty(output); - BitVector_Bit_Copy(output, mant_bits-1, !implicit1); - /* and up the exponent (checking for overflow) */ - if (exponent+1 >= EXP_INF) - overflow = 1; - else - exponent++; + /* overflowed, so zero mantissa (and set explicit bit if necessary) */ + BitVector_Empty(output); + BitVector_Bit_Copy(output, mant_bits-1, !implicit1); + /* and up the exponent (checking for overflow) */ + if (exponent+1 >= EXP_INF) + overflow = 1; + else + exponent++; } /* adjust the exponent to the output bias, checking for overflow */ exponent -= EXP_BIAS-exp_bias; if (exponent >= exp_inf) - overflow = 1; + overflow = 1; else if (exponent <= 0) - underflow = 1; + underflow = 1; /* underflow and overflow both set!? */ if (underflow && overflow) - yasm_internal_error(N_("Both underflow and overflow set")); + yasm_internal_error(N_("Both underflow and overflow set")); /* check for underflow or overflow and set up appropriate output */ if (underflow) { - BitVector_Empty(output); - exponent = 0; - if (!(flt->flags & FLAG_ISZERO)) - retval = -1; + BitVector_Empty(output); + exponent = 0; + if (!(flt->flags & FLAG_ISZERO)) + retval = -1; } else if (overflow) { - BitVector_Empty(output); - exponent = exp_inf; - retval = 1; + BitVector_Empty(output); + exponent = exp_inf; + retval = 1; } /* move exponent into place */ @@ -616,8 +618,8 @@ floatnum_get_common(const yasm_floatnum *flt, /*@out@*/ unsigned char *ptr, /* get little-endian bytes */ buf = BitVector_Block_Read(output, &len); if (len < byte_size) - yasm_internal_error( - N_("Byte length of BitVector does not match bit length")); + yasm_internal_error( + N_("Byte length of BitVector does not match bit length")); /* copy to output */ memcpy(ptr, buf, byte_size*sizeof(unsigned char)); @@ -630,17 +632,7 @@ floatnum_get_common(const yasm_floatnum *flt, /*@out@*/ unsigned char *ptr, return retval; } -/* IEEE-754r "half precision" format: - * 16 bits: - * 15 9 Bit 0 - * | | | - * seee eemm mmmm mmmm - * - * e = bias 15 exponent - * s = sign bit - * m = mantissa bits, bit 10 is an implied one bit. - * - * IEEE-754 (Intel) "single precision" format: +/* IEEE-754 (Intel) "single precision" format: * 32 bits: * Bit 31 Bit 22 Bit 0 * | | | @@ -672,39 +664,36 @@ floatnum_get_common(const yasm_floatnum *flt, /*@out@*/ unsigned char *ptr, */ int yasm_floatnum_get_sized(const yasm_floatnum *flt, unsigned char *ptr, - size_t destsize, size_t valsize, size_t shift, - int bigendian, int warn) + size_t destsize, size_t valsize, size_t shift, + int bigendian, int warn) { int retval; if (destsize*8 != valsize || shift>0 || bigendian) { - /* TODO */ - yasm_internal_error(N_("unsupported floatnum functionality")); + /* TODO */ + yasm_internal_error(N_("unsupported floatnum functionality")); } switch (destsize) { - case 2: - retval = floatnum_get_common(flt, ptr, 2, 10, 1, 5); - break; - case 4: - retval = floatnum_get_common(flt, ptr, 4, 23, 1, 8); - break; - case 8: - retval = floatnum_get_common(flt, ptr, 8, 52, 1, 11); - break; - case 10: - retval = floatnum_get_common(flt, ptr, 10, 64, 0, 15); - break; - default: - yasm_internal_error(N_("Invalid float conversion size")); - /*@notreached@*/ - return 1; + case 4: + retval = floatnum_get_common(flt, ptr, 4, 23, 1, 8); + break; + case 8: + retval = floatnum_get_common(flt, ptr, 8, 52, 1, 11); + break; + case 10: + retval = floatnum_get_common(flt, ptr, 10, 64, 0, 15); + break; + default: + yasm_internal_error(N_("Invalid float conversion size")); + /*@notreached@*/ + return 1; } if (warn) { - if (retval < 0) - yasm_warn_set(YASM_WARN_GENERAL, - N_("underflow in floating point expression")); - else if (retval > 0) - yasm_warn_set(YASM_WARN_GENERAL, - N_("overflow in floating point expression")); + if (retval < 0) + yasm_warn_set(YASM_WARN_GENERAL, + N_("underflow in floating point expression")); + else if (retval > 0) + yasm_warn_set(YASM_WARN_GENERAL, + N_("overflow in floating point expression")); } return retval; } @@ -714,13 +703,12 @@ int yasm_floatnum_check_size(/*@unused@*/ const yasm_floatnum *flt, size_t size) { switch (size) { - case 16: - case 32: - case 64: - case 80: - return 1; - default: - return 0; + case 32: + case 64: + case 80: + return 1; + default: + return 0; } } @@ -734,27 +722,27 @@ yasm_floatnum_print(const yasm_floatnum *flt, FILE *f) /* Internal format */ str = BitVector_to_Hex(flt->mantissa); fprintf(f, "%c %s *2^%04x\n", flt->sign?'-':'+', (char *)str, - flt->exponent); + flt->exponent); yasm_xfree(str); /* 32-bit (single precision) format */ fprintf(f, "32-bit: %d: ", - yasm_floatnum_get_sized(flt, out, 4, 32, 0, 0, 0)); + yasm_floatnum_get_sized(flt, out, 4, 32, 0, 0, 0)); for (i=0; i<4; i++) - fprintf(f, "%02x ", out[i]); + fprintf(f, "%02x ", out[i]); fprintf(f, "\n"); /* 64-bit (double precision) format */ fprintf(f, "64-bit: %d: ", - yasm_floatnum_get_sized(flt, out, 8, 64, 0, 0, 0)); + yasm_floatnum_get_sized(flt, out, 8, 64, 0, 0, 0)); for (i=0; i<8; i++) - fprintf(f, "%02x ", out[i]); + fprintf(f, "%02x ", out[i]); fprintf(f, "\n"); /* 80-bit (extended precision) format */ fprintf(f, "80-bit: %d: ", - yasm_floatnum_get_sized(flt, out, 10, 80, 0, 0, 0)); + yasm_floatnum_get_sized(flt, out, 10, 80, 0, 0, 0)); for (i=0; i<10; i++) - fprintf(f, "%02x ", out[i]); + fprintf(f, "%02x ", out[i]); fprintf(f, "\n"); } diff --git a/libyasm/floatnum.h b/libyasm/floatnum.h index d2c70420..f855aaa6 100644 --- a/libyasm/floatnum.h +++ b/libyasm/floatnum.h @@ -2,6 +2,10 @@ * \file libyasm/floatnum.h * \brief YASM floating point (IEEE) interface. * + * \rcs + * $Id$ + * \endrcs + * * \license * Copyright (C) 2001-2007 Peter Johnson * @@ -32,61 +36,50 @@ #ifndef YASM_FLOATNUM_H #define YASM_FLOATNUM_H -#ifndef YASM_LIB_DECL -#define YASM_LIB_DECL -#endif - /** Initialize floatnum internal data structures. */ -YASM_LIB_DECL void yasm_floatnum_initialize(void); /** Clean up internal floatnum allocations. */ -YASM_LIB_DECL void yasm_floatnum_cleanup(void); /** Create a new floatnum from a decimal string. The input string must be in * standard C representation ([+-]123.456e[-+]789). - * \param str floating point decimal string + * \param str floating point decimal string * \return Newly allocated floatnum. */ -YASM_LIB_DECL /*@only@*/ yasm_floatnum *yasm_floatnum_create(const char *str); /** Duplicate a floatnum. - * \param flt floatnum + * \param flt floatnum * \return Newly allocated floatnum with the same value as flt. */ -YASM_LIB_DECL /*@only@*/ yasm_floatnum *yasm_floatnum_copy(const yasm_floatnum *flt); /** Destroy (free allocated memory for) a floatnum. - * \param flt floatnum + * \param flt floatnum */ -YASM_LIB_DECL void yasm_floatnum_destroy(/*@only@*/ yasm_floatnum *flt); /** Floating point calculation function: acc = acc op operand. * \note Not all operations in yasm_expr_op may be supported; unsupported * operations will result in an error. - * \param acc floatnum accumulator - * \param op operation + * \param acc floatnum accumulator + * \param op operation * \param operand floatnum operand * \return Nonzero on error. */ -YASM_LIB_DECL int yasm_floatnum_calc(yasm_floatnum *acc, yasm_expr_op op, - yasm_floatnum *operand); + yasm_floatnum *operand); /** Convert a floatnum to single-precision and return as 32-bit value. * The 32-bit value is a "standard" C value (eg, of unknown endian). - * \param flt floatnum + * \param flt floatnum * \param ret_val pointer to storage for 32-bit output * \return Nonzero if flt can't fit into single precision: -1 if underflow * occurred, 1 if overflow occurred. */ -YASM_LIB_DECL int yasm_floatnum_get_int(const yasm_floatnum *flt, - /*@out@*/ unsigned long *ret_val); + /*@out@*/ unsigned long *ret_val); /** Output a #yasm_floatnum to buffer in little-endian or big-endian. Puts the * value into the least significant bits of the destination, or may be shifted @@ -95,37 +88,34 @@ int yasm_floatnum_get_int(const yasm_floatnum *flt, * \note Not all sizes are valid. Currently, only 32 (single-precision), 64 * (double-precision), and 80 (extended-precision) are valid sizes. * Use yasm_floatnum_check_size() to check for supported sizes. - * \param flt floatnum - * \param ptr pointer to storage for size bytes of output + * \param flt floatnum + * \param ptr pointer to storage for size bytes of output * \param destsize destination size (in bytes) * \param valsize size (in bits) - * \param shift left shift (in bits) + * \param shift left shift (in bits) * \param bigendian endianness (nonzero=big, zero=little) - * \param warn enables standard overflow/underflow warnings + * \param warn enables standard overflow/underflow warnings * \return Nonzero if flt can't fit into the specified precision: -1 if * underflow occurred, 1 if overflow occurred. */ -YASM_LIB_DECL int yasm_floatnum_get_sized(const yasm_floatnum *flt, unsigned char *ptr, - size_t destsize, size_t valsize, size_t shift, - int bigendian, int warn); + size_t destsize, size_t valsize, size_t shift, + int bigendian, int warn); /** Basic check to see if size is valid for flt conversion (using * yasm_floatnum_get_sized()). Doesn't actually check for underflow/overflow * but rather checks for size=32,64,80 * (at present). - * \param flt floatnum - * \param size number of bits of output space + * \param flt floatnum + * \param size number of bits of output space * \return 1 if valid size, 0 if invalid size. */ -YASM_LIB_DECL int yasm_floatnum_check_size(const yasm_floatnum *flt, size_t size); /** Print various representations of a floatnum. For debugging purposes only. - * \param f file - * \param flt floatnum + * \param f file + * \param flt floatnum */ -YASM_LIB_DECL void yasm_floatnum_print(const yasm_floatnum *flt, FILE *f); #endif diff --git a/libyasm/genmodule.c b/libyasm/genmodule.c index 867d93a5..d15d2d8b 100644 --- a/libyasm/genmodule.c +++ b/libyasm/genmodule.c @@ -1,4 +1,4 @@ -/* +/* $Id$ * * Generate module.c from module.in and Makefile.am or Makefile. * @@ -32,9 +32,9 @@ #include "compat-queue.h" -#define OUTPUT "module.c" +#define OUTPUT "module.c" #define MAXNAME 128 -#define MAXLINE 1024 +#define MAXLINE 1024 #define MAXMODULES 128 #define MAXINCLUDES 256 @@ -54,14 +54,14 @@ main(int argc, char *argv[]) char *modules[MAXMODULES]; int num_modules = 0; STAILQ_HEAD(includehead, include) includes = - STAILQ_HEAD_INITIALIZER(includes); + STAILQ_HEAD_INITIALIZER(includes); include *inc; int isam = 0; int linecont = 0; if (argc != 3) { - fprintf(stderr, "Usage: %s \n", argv[0]); - return EXIT_FAILURE; + fprintf(stderr, "Usage: %s \n", argv[0]); + return EXIT_FAILURE; } str = malloc(MAXLINE); @@ -79,149 +79,149 @@ main(int argc, char *argv[]) isam = argv[2][len-2] == 'a' && argv[2][len-1] == 'm'; while (!STAILQ_EMPTY(&includes)) { - inc = STAILQ_FIRST(&includes); - STAILQ_REMOVE_HEAD(&includes, link); - in = fopen(inc->filename, "rt"); - if (!in) { - fprintf(stderr, "Could not open `%s'.\n", inc->filename); - return EXIT_FAILURE; - } - free(inc->filename); - free(inc); + inc = STAILQ_FIRST(&includes); + STAILQ_REMOVE_HEAD(&includes, link); + in = fopen(inc->filename, "rt"); + if (!in) { + fprintf(stderr, "Could not open `%s'.\n", inc->filename); + return EXIT_FAILURE; + } + free(inc->filename); + free(inc); - while (fgets(str, MAXLINE, in)) { - /* Strip off any trailing whitespace */ - len = strlen(str); - if (len > 0) { - strp = &str[len-1]; - while (len > 0 && isspace(*strp)) { - *strp-- = '\0'; - len--; - } - } + while (fgets(str, MAXLINE, in)) { + /* Strip off any trailing whitespace */ + len = strlen(str); + if (len > 0) { + strp = &str[len-1]; + while (len > 0 && isspace(*strp)) { + *strp-- = '\0'; + len--; + } + } - strp = str; + strp = str; - /* Skip whitespace */ - while (isspace(*strp)) - strp++; + /* Skip whitespace */ + while (isspace(*strp)) + strp++; - /* Skip comments */ - if (*strp == '#') - continue; + /* Skip comments */ + if (*strp == '#') + continue; - /* If line continuation, skip to continue copy */ - if (linecont) - goto keepgoing; + /* If line continuation, skip to continue copy */ + if (linecont) + goto keepgoing; - /* Check for include if original input is .am file */ - if (isam && strncmp(strp, "include", 7) == 0 && isspace(strp[7])) { - strp += 7; - while (isspace(*strp)) - strp++; - /* Build new include and add to end of list */ - inc = malloc(sizeof(include)); - inc->filename = malloc(strlen(strp)+1); - strcpy(inc->filename, strp); - STAILQ_INSERT_TAIL(&includes, inc, link); - continue; - } + /* Check for include if original input is .am file */ + if (isam && strncmp(strp, "include", 7) == 0 && isspace(strp[7])) { + strp += 7; + while (isspace(*strp)) + strp++; + /* Build new include and add to end of list */ + inc = malloc(sizeof(include)); + inc->filename = malloc(strlen(strp)+1); + strcpy(inc->filename, strp); + STAILQ_INSERT_TAIL(&includes, inc, link); + continue; + } - /* Check for YASM_MODULES = or += */ - if (strncmp(strp, "YASM_MODULES", 12) != 0) - continue; - strp += 12; - while (isspace(*strp)) - strp++; - if (strncmp(strp, "+=", 2) != 0 && *strp != '=') - continue; - if (*strp == '+') - strp++; - strp++; - while (isspace(*strp)) - strp++; + /* Check for YASM_MODULES = or += */ + if (strncmp(strp, "YASM_MODULES", 12) != 0) + continue; + strp += 12; + while (isspace(*strp)) + strp++; + if (strncmp(strp, "+=", 2) != 0 && *strp != '=') + continue; + if (*strp == '+') + strp++; + strp++; + while (isspace(*strp)) + strp++; keepgoing: - /* Check for continuation */ - if (len > 0 && str[len-1] == '\\') { - str[len-1] = '\0'; - while (isspace(*strp)) - *strp-- = '\0'; - linecont = 1; - } else - linecont = 0; + /* Check for continuation */ + if (len > 0 && str[len-1] == '\\') { + str[len-1] = '\0'; + while (isspace(*strp)) + *strp-- = '\0'; + linecont = 1; + } else + linecont = 0; - while (*strp != '\0') { - /* Copy module name */ - modules[num_modules] = malloc(MAXNAME); - len = 0; - while (*strp != '\0' && !isspace(*strp)) - modules[num_modules][len++] = *strp++; - modules[num_modules][len] = '\0'; - num_modules++; + while (*strp != '\0') { + /* Copy module name */ + modules[num_modules] = malloc(MAXNAME); + len = 0; + while (*strp != '\0' && !isspace(*strp)) + modules[num_modules][len++] = *strp++; + modules[num_modules][len] = '\0'; + num_modules++; - while (isspace(*strp)) - strp++; - } - } - fclose(in); + while (isspace(*strp)) + strp++; + } + } + fclose(in); } out = fopen(OUTPUT, "wt"); if (!out) { - fprintf(stderr, "Could not open `%s'.\n", OUTPUT); - return EXIT_FAILURE; + fprintf(stderr, "Could not open `%s'.\n", OUTPUT); + return EXIT_FAILURE; } fprintf(out, "/* This file auto-generated by genmodule.c" - " - don't edit it */\n\n"); + " - don't edit it */\n\n"); in = fopen(argv[1], "rt"); if (!in) { - fprintf(stderr, "Could not open `%s'.\n", argv[1]); - fclose(out); - remove(OUTPUT); - return EXIT_FAILURE; + fprintf(stderr, "Could not open `%s'.\n", argv[1]); + fclose(out); + remove(OUTPUT); + return EXIT_FAILURE; } len = 0; while (fgets(str, MAXLINE, in)) { - if (strncmp(str, "MODULES_", 8) == 0) { - len = 0; - strp = str+8; - while (*strp != '\0' && *strp != '_') { - len++; - strp++; - } - *strp = '\0'; + if (strncmp(str, "MODULES_", 8) == 0) { + len = 0; + strp = str+8; + while (*strp != '\0' && *strp != '_') { + len++; + strp++; + } + *strp = '\0'; - for (i=0; i @@ -38,51 +40,50 @@ #include "hamt.h" struct HAMTEntry { - STAILQ_ENTRY(HAMTEntry) next; /* next hash table entry */ - /*@dependent@*/ const char *str; /* string being hashed */ - /*@owned@*/ void *data; /* data pointer being stored */ + STAILQ_ENTRY(HAMTEntry) next; /* next hash table entry */ + /*@dependent@*/ const char *str; /* string being hashed */ + /*@owned@*/ void *data; /* data pointer being stored */ }; typedef struct HAMTNode { - unsigned long BitMapKey; /* 32 bits, bitmap or hash key */ - uintptr_t BaseValue; /* Base of HAMTNode list or value */ + unsigned long BitMapKey; /* 32 bits, bitmap or hash key */ + uintptr_t BaseValue; /* Base of HAMTNode list or value */ } HAMTNode; struct HAMT { STAILQ_HEAD(HAMTEntryHead, HAMTEntry) entries; HAMTNode *root; /*@exits@*/ void (*error_func) (const char *file, unsigned int line, - const char *message); + const char *message); unsigned long (*HashKey) (const char *key); unsigned long (*ReHashKey) (const char *key, int Level); - int (*CmpKey) (const char *s1, const char *s2); }; /* XXX make a portable version of this. This depends on the pointer being * 4 or 2-byte aligned (as it uses the LSB of the pointer variable to store * the subtrie flag! */ -#define IsSubTrie(n) ((n)->BaseValue & 1) -#define SetSubTrie(h, n, v) do { \ - if ((uintptr_t)(v) & 1) \ - h->error_func(__FILE__, __LINE__, \ - N_("Subtrie is seen as subtrie before flag is set (misaligned?)")); \ - (n)->BaseValue = (uintptr_t)(v) | 1; \ +#define IsSubTrie(n) ((n)->BaseValue & 1) +#define SetSubTrie(h, n, v) do { \ + if ((uintptr_t)(v) & 1) \ + h->error_func(__FILE__, __LINE__, \ + N_("Subtrie is seen as subtrie before flag is set (misaligned?)")); \ + (n)->BaseValue = (uintptr_t)(v) | 1; \ } while (0) -#define SetValue(h, n, v) do { \ - if ((uintptr_t)(v) & 1) \ - h->error_func(__FILE__, __LINE__, \ - N_("Value is seen as subtrie (misaligned?)")); \ - (n)->BaseValue = (uintptr_t)(v); \ +#define SetValue(h, n, v) do { \ + if ((uintptr_t)(v) & 1) \ + h->error_func(__FILE__, __LINE__, \ + N_("Value is seen as subtrie (misaligned?)")); \ + (n)->BaseValue = (uintptr_t)(v); \ } while (0) -#define GetSubTrie(n) (HAMTNode *)(((n)->BaseValue | 1) ^ 1) +#define GetSubTrie(n) (HAMTNode *)(((n)->BaseValue | 1) ^ 1) static unsigned long HashKey(const char *key) { unsigned long a=31415, b=27183, vHash; for (vHash=0; *key; key++, a*=b) - vHash = a*vHash + *key; + vHash = a*vHash + *key; return vHash; } @@ -91,7 +92,7 @@ ReHashKey(const char *key, int Level) { unsigned long a=31415, b=27183, vHash; for (vHash=0; *key; key++, a*=b) - vHash = a*vHash*(unsigned long)Level + *key; + vHash = a*vHash*(unsigned long)Level + *key; return vHash; } @@ -100,7 +101,7 @@ HashKey_nocase(const char *key) { unsigned long a=31415, b=27183, vHash; for (vHash=0; *key; key++, a*=b) - vHash = a*vHash + tolower(*key); + vHash = a*vHash + tolower(*key); return vHash; } @@ -109,7 +110,7 @@ ReHashKey_nocase(const char *key, int Level) { unsigned long a=31415, b=27183, vHash; for (vHash=0; *key; key++, a*=b) - vHash = a*vHash*(unsigned long)Level + tolower(*key); + vHash = a*vHash*(unsigned long)Level + tolower(*key); return vHash; } @@ -124,19 +125,17 @@ HAMT_create(int nocase, /*@exits@*/ void (*error_func) hamt->root = yasm_xmalloc(32*sizeof(HAMTNode)); for (i=0; i<32; i++) { - hamt->root[i].BitMapKey = 0; - hamt->root[i].BaseValue = 0; + hamt->root[i].BitMapKey = 0; + hamt->root[i].BaseValue = 0; } hamt->error_func = error_func; if (nocase) { - hamt->HashKey = HashKey_nocase; - hamt->ReHashKey = ReHashKey_nocase; - hamt->CmpKey = yasm__strcasecmp; + hamt->HashKey = HashKey_nocase; + hamt->ReHashKey = ReHashKey_nocase; } else { - hamt->HashKey = HashKey; - hamt->ReHashKey = ReHashKey; - hamt->CmpKey = strcmp; + hamt->HashKey = HashKey; + hamt->ReHashKey = ReHashKey; } return hamt; @@ -146,17 +145,17 @@ static void HAMT_delete_trie(HAMTNode *node) { if (IsSubTrie(node)) { - unsigned long i, Size; + unsigned long i, Size; - /* Count total number of bits in bitmap to determine size */ - BitCount(Size, node->BitMapKey); - Size &= 0x1F; - if (Size == 0) - Size = 32; + /* Count total number of bits in bitmap to determine size */ + BitCount(Size, node->BitMapKey); + Size &= 0x1F; + if (Size == 0) + Size = 32; - for (i=0; ientries)) { - HAMTEntry *entry; - entry = STAILQ_FIRST(&hamt->entries); - STAILQ_REMOVE_HEAD(&hamt->entries, next); - deletefunc(entry->data); - yasm_xfree(entry); + HAMTEntry *entry; + entry = STAILQ_FIRST(&hamt->entries); + STAILQ_REMOVE_HEAD(&hamt->entries, next); + deletefunc(entry->data); + yasm_xfree(entry); } /* delete trie */ for (i=0; i<32; i++) - HAMT_delete_trie(&hamt->root[i]); + HAMT_delete_trie(&hamt->root[i]); yasm_xfree(hamt->root); yasm_xfree(hamt); @@ -184,14 +183,14 @@ HAMT_destroy(HAMT *hamt, void (*deletefunc) (/*@only@*/ void *data)) int HAMT_traverse(HAMT *hamt, void *d, - int (*func) (/*@dependent@*/ /*@null@*/ void *node, - /*@null@*/ void *d)) + int (*func) (/*@dependent@*/ /*@null@*/ void *node, + /*@null@*/ void *d)) { HAMTEntry *entry; STAILQ_FOREACH(entry, &hamt->entries, next) { - int retval = func(entry->data, d); - if (retval != 0) - return retval; + int retval = func(entry->data, d); + if (retval != 0) + return retval; } return 0; } @@ -217,7 +216,7 @@ HAMTEntry_get_data(const HAMTEntry *entry) /*@-temptrans -kepttrans -mustfree@*/ void * HAMT_insert(HAMT *hamt, const char *str, void *data, int *replace, - void (*deletefunc) (/*@only@*/ void *data)) + void (*deletefunc) (/*@only@*/ void *data)) { HAMTNode *node, *newnodes; HAMTEntry *entry; @@ -230,145 +229,141 @@ HAMT_insert(HAMT *hamt, const char *str, void *data, int *replace, node = &hamt->root[keypart]; if (!node->BaseValue) { - node->BitMapKey = key; - entry = yasm_xmalloc(sizeof(HAMTEntry)); - entry->str = str; - entry->data = data; - STAILQ_INSERT_TAIL(&hamt->entries, entry, next); - SetValue(hamt, node, entry); - if (IsSubTrie(node)) - hamt->error_func(__FILE__, __LINE__, - N_("Data is seen as subtrie (misaligned?)")); - *replace = 1; - return data; + node->BitMapKey = key; + entry = yasm_xmalloc(sizeof(HAMTEntry)); + entry->str = str; + entry->data = data; + STAILQ_INSERT_TAIL(&hamt->entries, entry, next); + SetValue(hamt, node, entry); + if (IsSubTrie(node)) + hamt->error_func(__FILE__, __LINE__, + N_("Data is seen as subtrie (misaligned?)")); + *replace = 1; + return data; } for (;;) { - if (!(IsSubTrie(node))) { - if (node->BitMapKey == key - && hamt->CmpKey(((HAMTEntry *)(node->BaseValue))->str, - str) == 0) { - /*@-branchstate@*/ - if (*replace) { - deletefunc(((HAMTEntry *)(node->BaseValue))->data); - ((HAMTEntry *)(node->BaseValue))->str = str; - ((HAMTEntry *)(node->BaseValue))->data = data; - } else - deletefunc(data); - /*@=branchstate@*/ - return ((HAMTEntry *)(node->BaseValue))->data; - } else { - unsigned long key2 = node->BitMapKey; - /* build tree downward until keys differ */ - for (;;) { - unsigned long keypart2; + if (!(IsSubTrie(node))) { + if (node->BitMapKey == key + && strcmp(((HAMTEntry *)(node->BaseValue))->str, str) == 0) { + /*@-branchstate@*/ + if (*replace) { + deletefunc(((HAMTEntry *)(node->BaseValue))->data); + ((HAMTEntry *)(node->BaseValue))->str = str; + ((HAMTEntry *)(node->BaseValue))->data = data; + } else + deletefunc(data); + /*@=branchstate@*/ + return ((HAMTEntry *)(node->BaseValue))->data; + } else { + unsigned long key2 = node->BitMapKey; + /* build tree downward until keys differ */ + for (;;) { + unsigned long keypart2; - /* replace node with subtrie */ - keypartbits += 5; - if (keypartbits > 30) { - /* Exceeded 32 bits: rehash */ - key = hamt->ReHashKey(str, level); - key2 = hamt->ReHashKey( - ((HAMTEntry *)(node->BaseValue))->str, level); - keypartbits = 0; - } - keypart = (key >> keypartbits) & 0x1F; - keypart2 = (key2 >> keypartbits) & 0x1F; + /* replace node with subtrie */ + keypartbits += 5; + if (keypartbits > 30) { + /* Exceeded 32 bits: rehash */ + key = hamt->ReHashKey(str, level); + key2 = hamt->ReHashKey( + ((HAMTEntry *)(node->BaseValue))->str, level); + keypartbits = 0; + } + keypart = (key >> keypartbits) & 0x1F; + keypart2 = (key2 >> keypartbits) & 0x1F; - if (keypart == keypart2) { - /* Still equal, build one-node subtrie and continue - * downward. - */ - newnodes = yasm_xmalloc(sizeof(HAMTNode)); - newnodes[0].BitMapKey = key2; - newnodes[0].BaseValue = node->BaseValue; - node->BitMapKey = 1<BitMapKey = 1<str = str; - entry->data = data; - STAILQ_INSERT_TAIL(&hamt->entries, entry, next); + entry = yasm_xmalloc(sizeof(HAMTEntry)); + entry->str = str; + entry->data = data; + STAILQ_INSERT_TAIL(&hamt->entries, entry, next); - /* Copy nodes into subtrie based on order */ - if (keypart2 < keypart) { - newnodes[0].BitMapKey = key2; - newnodes[0].BaseValue = node->BaseValue; - newnodes[1].BitMapKey = key; - SetValue(hamt, &newnodes[1], entry); - } else { - newnodes[0].BitMapKey = key; - SetValue(hamt, &newnodes[0], entry); - newnodes[1].BitMapKey = key2; - newnodes[1].BaseValue = node->BaseValue; - } + /* Copy nodes into subtrie based on order */ + if (keypart2 < keypart) { + newnodes[0] = *node; /* structure copy */ + newnodes[1].BitMapKey = key; + SetValue(hamt, &newnodes[1], entry); + } else { + newnodes[0].BitMapKey = key; + SetValue(hamt, &newnodes[0], entry); + newnodes[1] = *node; /* structure copy */ + } - /* Set bits in bitmap corresponding to keys */ - node->BitMapKey = (1UL<BitMapKey = (1UL< 30) { - /* Exceeded 32 bits of current key: rehash */ - key = hamt->ReHashKey(str, level); - keypartbits = 0; - } - keypart = (key >> keypartbits) & 0x1F; - if (!(node->BitMapKey & (1< add node to table */ - unsigned long Size; + /* Subtrie: look up in bitmap */ + keypartbits += 5; + if (keypartbits > 30) { + /* Exceeded 32 bits of current key: rehash */ + key = hamt->ReHashKey(str, level); + keypartbits = 0; + } + keypart = (key >> keypartbits) & 0x1F; + if (!(node->BitMapKey & (1< add node to table */ + unsigned long Size; - /* set bit to 1 */ - node->BitMapKey |= 1<BitMapKey |= 1<BitMapKey); - Size &= 0x1F; - if (Size == 0) - Size = 32; - newnodes = yasm_xmalloc(Size*sizeof(HAMTNode)); + /* Count total number of bits in bitmap to determine new size */ + BitCount(Size, node->BitMapKey); + Size &= 0x1F; + if (Size == 0) + Size = 32; + newnodes = yasm_xmalloc(Size*sizeof(HAMTNode)); - /* Count bits below to find where to insert new node at */ - BitCount(Map, node->BitMapKey & ~((~0UL)<str = str; - entry->data = data; - STAILQ_INSERT_TAIL(&hamt->entries, entry, next); - SetValue(hamt, &newnodes[Map], entry); - SetSubTrie(hamt, node, newnodes); + /* Count bits below to find where to insert new node at */ + BitCount(Map, node->BitMapKey & ~((~0UL)<str = str; + entry->data = data; + STAILQ_INSERT_TAIL(&hamt->entries, entry, next); + SetValue(hamt, &newnodes[Map], entry); + SetSubTrie(hamt, node, newnodes); - *replace = 1; - return data; - } + *replace = 1; + return data; + } - /* Count bits below */ - BitCount(Map, node->BitMapKey & ~((~0UL)<BitMapKey & ~((~0UL)<root[keypart]; if (!node->BaseValue) - return NULL; + return NULL; for (;;) { - if (!(IsSubTrie(node))) { - if (node->BitMapKey == key - && hamt->CmpKey(((HAMTEntry *)(node->BaseValue))->str, - str) == 0) - return ((HAMTEntry *)(node->BaseValue))->data; - else - return NULL; - } + if (!(IsSubTrie(node))) { + if (node->BitMapKey == key) + return ((HAMTEntry *)(node->BaseValue))->data; + else + return NULL; + } - /* Subtree: look up in bitmap */ - keypartbits += 5; - if (keypartbits > 30) { - /* Exceeded 32 bits of current key: rehash */ - key = hamt->ReHashKey(str, level); - keypartbits = 0; - } - keypart = (key >> keypartbits) & 0x1F; - if (!(node->BitMapKey & (1< no match */ + /* Subtree: look up in bitmap */ + keypartbits += 5; + if (keypartbits > 30) { + /* Exceeded 32 bits of current key: rehash */ + key = hamt->ReHashKey(str, level); + keypartbits = 0; + } + keypart = (key >> keypartbits) & 0x1F; + if (!(node->BitMapKey & (1< no match */ - /* Count bits below */ - BitCount(Map, node->BitMapKey & ~((~0UL)<BitMapKey & ~((~0UL)<segreg != 0) - yasm_warn_set(YASM_WARN_GENERAL, - N_("multiple segment overrides, using leftmost")); - - ea->segreg = segreg; -} - -yasm_insn_operand * -yasm_operand_create_reg(uintptr_t reg) -{ - yasm_insn_operand *retval = yasm_xmalloc(sizeof(yasm_insn_operand)); - - retval->type = YASM_INSN__OPERAND_REG; - retval->data.reg = reg; - retval->seg = 0; - retval->targetmod = 0; - retval->size = 0; - retval->deref = 0; - retval->strict = 0; - - return retval; -} - -yasm_insn_operand * -yasm_operand_create_segreg(uintptr_t segreg) -{ - yasm_insn_operand *retval = yasm_xmalloc(sizeof(yasm_insn_operand)); - - retval->type = YASM_INSN__OPERAND_SEGREG; - retval->data.reg = segreg; - retval->seg = 0; - retval->targetmod = 0; - retval->size = 0; - retval->deref = 0; - retval->strict = 0; - - return retval; -} - -yasm_insn_operand * -yasm_operand_create_mem(/*@only@*/ yasm_effaddr *ea) -{ - yasm_insn_operand *retval = yasm_xmalloc(sizeof(yasm_insn_operand)); - - retval->type = YASM_INSN__OPERAND_MEMORY; - retval->data.ea = ea; - retval->seg = 0; - retval->targetmod = 0; - retval->size = 0; - retval->deref = 0; - retval->strict = 0; - retval->size = ea->data_len * 8; - - return retval; -} - -yasm_insn_operand * -yasm_operand_create_imm(/*@only@*/ yasm_expr *val) -{ - yasm_insn_operand *retval; - const uintptr_t *reg; - - reg = yasm_expr_get_reg(&val, 0); - if (reg) { - retval = yasm_operand_create_reg(*reg); - yasm_expr_destroy(val); - } else { - retval = yasm_xmalloc(sizeof(yasm_insn_operand)); - retval->type = YASM_INSN__OPERAND_IMM; - retval->data.val = val; - retval->seg = 0; - retval->targetmod = 0; - retval->size = 0; - retval->deref = 0; - retval->strict = 0; - } - - return retval; -} - -yasm_insn_operand * -yasm_insn_ops_append(yasm_insn *insn, yasm_insn_operand *op) -{ - if (op) { - insn->num_operands++; - STAILQ_INSERT_TAIL(&insn->operands, op, link); - return op; - } - return (yasm_insn_operand *)NULL; -} - -void -yasm_insn_add_prefix(yasm_insn *insn, uintptr_t prefix) -{ - insn->prefixes = - yasm_xrealloc(insn->prefixes, - (insn->num_prefixes+1)*sizeof(uintptr_t)); - insn->prefixes[insn->num_prefixes] = prefix; - insn->num_prefixes++; -} - -void -yasm_insn_add_seg_prefix(yasm_insn *insn, uintptr_t segreg) -{ - insn->segregs = - yasm_xrealloc(insn->segregs, (insn->num_segregs+1)*sizeof(uintptr_t)); - insn->segregs[insn->num_segregs] = segreg; - insn->num_segregs++; -} - -void -yasm_insn_initialize(yasm_insn *insn) -{ - STAILQ_INIT(&insn->operands); - - insn->prefixes = NULL; - insn->segregs = NULL; - - insn->num_operands = 0; - insn->num_prefixes = 0; - insn->num_segregs = 0; -} - -void -yasm_insn_delete(yasm_insn *insn, - void (*ea_destroy) (/*@only@*/ yasm_effaddr *)) -{ - if (insn->num_operands > 0) { - yasm_insn_operand *cur, *next; - - cur = STAILQ_FIRST(&insn->operands); - while (cur) { - next = STAILQ_NEXT(cur, link); - switch (cur->type) { - case YASM_INSN__OPERAND_MEMORY: - ea_destroy(cur->data.ea); - break; - case YASM_INSN__OPERAND_IMM: - yasm_expr_destroy(cur->data.val); - break; - default: - break; - } - yasm_xfree(cur); - cur = next; - } - } - if (insn->num_prefixes > 0) - yasm_xfree(insn->prefixes); - if (insn->num_segregs > 0) - yasm_xfree(insn->segregs); -} - -void -yasm_insn_print(const yasm_insn *insn, FILE *f, int indent_level) -{ - const yasm_insn_operand *op; - - STAILQ_FOREACH (op, &insn->operands, link) { - switch (op->type) { - case YASM_INSN__OPERAND_REG: - fprintf(f, "%*sReg=", indent_level, ""); - /*yasm_arch_reg_print(arch, op->data.reg, f);*/ - fprintf(f, "\n"); - break; - case YASM_INSN__OPERAND_SEGREG: - fprintf(f, "%*sSegReg=", indent_level, ""); - /*yasm_arch_segreg_print(arch, op->data.reg, f);*/ - fprintf(f, "\n"); - break; - case YASM_INSN__OPERAND_MEMORY: - fprintf(f, "%*sMemory=\n", indent_level, ""); - /*yasm_arch_ea_print(arch, op->data.ea, f, indent_level);*/ - break; - case YASM_INSN__OPERAND_IMM: - fprintf(f, "%*sImm=", indent_level, ""); - yasm_expr_print(op->data.val, f); - fprintf(f, "\n"); - break; - } - fprintf(f, "%*sTargetMod=%lx\n", indent_level+1, "", - (unsigned long)op->targetmod); - fprintf(f, "%*sSize=%u\n", indent_level+1, "", op->size); - fprintf(f, "%*sDeref=%d, Strict=%d\n", indent_level+1, "", - (int)op->deref, (int)op->strict); - } -} - -void -yasm_insn_finalize(yasm_insn *insn) -{ - unsigned int i; - yasm_insn_operand *op; - yasm_error_class eclass; - char *str, *xrefstr; - unsigned long xrefline; - - /* Simplify the operands' expressions first. */ - for (i = 0, op = yasm_insn_ops_first(insn); - op && inum_operands; op = yasm_insn_op_next(op), i++) { - /* Check operand type */ - switch (op->type) { - case YASM_INSN__OPERAND_MEMORY: - /* Don't get over-ambitious here; some archs' memory expr - * parser are sensitive to the presence of *1, etc, so don't - * simplify reg*1 identities. - */ - if (op->data.ea) - op->data.ea->disp.abs = - yasm_expr__level_tree(op->data.ea->disp.abs, 1, 1, 0, - 0, NULL, NULL); - if (yasm_error_occurred()) { - /* Add a pointer to where it was used to the error */ - yasm_error_fetch(&eclass, &str, &xrefline, &xrefstr); - if (xrefstr) { - yasm_error_set_xref(xrefline, "%s", xrefstr); - yasm_xfree(xrefstr); - } - if (str) { - yasm_error_set(eclass, "%s in memory expression", str); - yasm_xfree(str); - } - return; - } - break; - case YASM_INSN__OPERAND_IMM: - op->data.val = - yasm_expr__level_tree(op->data.val, 1, 1, 1, 0, NULL, - NULL); - if (yasm_error_occurred()) { - /* Add a pointer to where it was used to the error */ - yasm_error_fetch(&eclass, &str, &xrefline, &xrefstr); - if (xrefstr) { - yasm_error_set_xref(xrefline, "%s", xrefstr); - yasm_xfree(xrefstr); - } - if (str) { - yasm_error_set(eclass, "%s in immediate expression", - str); - yasm_xfree(str); - } - return; - } - break; - default: - break; - } - } -} diff --git a/libyasm/insn.h b/libyasm/insn.h deleted file mode 100644 index d2d175d0..00000000 --- a/libyasm/insn.h +++ /dev/null @@ -1,269 +0,0 @@ -/** - * \file libyasm/insn.h - * \brief YASM mnenomic instruction. - * - * \license - * Copyright (C) 2002-2007 Peter Johnson - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND OTHER CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR OTHER CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * \endlicense - */ -#ifndef YASM_INSN_H -#define YASM_INSN_H - -#ifndef YASM_LIB_DECL -#define YASM_LIB_DECL -#endif - -/** Base structure for an effective address. As with all base - * structures, must be present as the first element in any - * #yasm_arch implementation of an effective address. - */ -struct yasm_effaddr { - yasm_value disp; /**< address displacement */ - - /** Segment register override (0 if none). */ - uintptr_t segreg; - - /** 1 if length of disp must be >0. */ - unsigned int need_nonzero_len:1; - - /** 1 if a displacement should be present in the output. */ - unsigned int need_disp:1; - - /** 1 if reg*2 should not be split into reg+reg. (0 if not). - * This flag indicates (for architectures that support complex effective - * addresses such as x86) if various types of complex effective addresses - * can be split into different forms in order to minimize instruction - * length. - */ - unsigned int nosplit:1; - - /** 1 if effective address is /definitely/ an effective address. - * This is used in e.g. the GAS parser to differentiate - * between "expr" (which might or might not be an effective address) and - * "expr(,1)" (which is definitely an effective address). - */ - unsigned int strong:1; - - /** 1 if effective address is forced PC-relative. */ - unsigned int pc_rel:1; - - /** 1 if effective address is forced non-PC-relative. */ - unsigned int not_pc_rel:1; - - /** length of pointed data (in bytes), 0 if unknown. */ - unsigned int data_len; -}; - -/** An instruction operand (opaque type). */ -typedef struct yasm_insn_operand yasm_insn_operand; - -/** The type of an instruction operand. */ -typedef enum yasm_insn_operand_type { - YASM_INSN__OPERAND_REG = 1, /**< A register. */ - YASM_INSN__OPERAND_SEGREG, /**< A segment register. */ - YASM_INSN__OPERAND_MEMORY, /**< An effective address - * (memory reference). */ - YASM_INSN__OPERAND_IMM /**< An immediate or jump target. */ -} yasm_insn_operand_type; - -/** An instruction operand. */ -struct yasm_insn_operand { - /** Link for building linked list of operands. \internal */ - /*@reldef@*/ STAILQ_ENTRY(yasm_insn_operand) link; - - /** Operand data. */ - union { - uintptr_t reg; /**< Arch data for reg/segreg. */ - yasm_effaddr *ea; /**< Effective address for memory references. */ - yasm_expr *val; /**< Value of immediate or jump target. */ - } data; - - yasm_expr *seg; /**< Segment expression */ - - uintptr_t targetmod; /**< Arch target modifier, 0 if none. */ - - /** Specified size of the operand, in bits. 0 if not user-specified. */ - unsigned int size:16; - - /** Nonzero if dereference. Used for "*foo" in GAS. - * The reason for this is that by default in GAS, an unprefixed value - * is a memory address, except for jumps/calls, in which case it needs a - * "*" prefix to become a memory address (otherwise it's an immediate). - * This isn't knowable in the parser stage, so the parser sets this flag - * to indicate the "*" prefix has been used, and the arch needs to adjust - * the operand type appropriately depending on the instruction type. - */ - unsigned int deref:1; - - /** Nonzero if strict. Used for "strict foo" in NASM. - * This is used to inhibit optimization on otherwise "sized" values. - * For example, the user may just want to be explicit with the size on - * "push dword 4", but not actually want to force the immediate size to - * 4 bytes (rather wanting the optimizer to optimize it down to 1 byte as - * though "dword" was not specified). To indicate the immediate should - * actually be forced to 4 bytes, the user needs to write - * "push strict dword 4", which sets this flag. - */ - unsigned int strict:1; - - /** Operand type. */ - unsigned int type:4; -}; - -/** Base structure for "instruction" bytecodes. These are the mnenomic - * (rather than raw) representation of instructions. As with all base - * structures, must be present as the first element in any - * #yasm_arch implementation of mnenomic instruction bytecodes. - */ -struct yasm_insn { - /** Linked list of operands. */ - /*@reldef@*/ STAILQ_HEAD(yasm_insn_operands, yasm_insn_operand) operands; - - /** Array of prefixes. */ - /*@null@*/ uintptr_t *prefixes; - - /** Array of segment prefixes. */ - /*@null@*/ uintptr_t *segregs; - - unsigned int num_operands; /**< Number of operands. */ - unsigned int num_prefixes; /**< Number of prefixes. */ - unsigned int num_segregs; /**< Number of segment prefixes. */ -}; - -/** Set segment override for an effective address. - * Some architectures (such as x86) support segment overrides on effective - * addresses. A override of an override will result in a warning. - * \param ea effective address - * \param segreg segment register (0 if none) - */ -YASM_LIB_DECL -void yasm_ea_set_segreg(yasm_effaddr *ea, uintptr_t segreg); - -/** Create an instruction operand from a register. - * \param reg register - * \return Newly allocated operand. - */ -YASM_LIB_DECL -yasm_insn_operand *yasm_operand_create_reg(uintptr_t reg); - -/** Create an instruction operand from a segment register. - * \param segreg segment register - * \return Newly allocated operand. - */ -YASM_LIB_DECL -yasm_insn_operand *yasm_operand_create_segreg(uintptr_t segreg); - -/** Create an instruction operand from an effective address. - * \param ea effective address - * \return Newly allocated operand. - */ -YASM_LIB_DECL -yasm_insn_operand *yasm_operand_create_mem(/*@only@*/ yasm_effaddr *ea); - -/** Create an instruction operand from an immediate expression. - * Looks for cases of a single register and creates a register variant of - * #yasm_insn_operand. - * \param val immediate expression - * \return Newly allocated operand. - */ -YASM_LIB_DECL -yasm_insn_operand *yasm_operand_create_imm(/*@only@*/ yasm_expr *val); - -/** Get the first operand in an instruction. - * \param insn instruction - * \return First operand (NULL if no operands). - */ -yasm_insn_operand *yasm_insn_ops_first(yasm_insn *insn); -#define yasm_insn_ops_first(insn) STAILQ_FIRST(&((insn)->operands)) - -/** Get the next operand in an instruction. - * \param op previous operand - * \return Next operand (NULL if op was the last operand). - */ -yasm_insn_operand *yasm_insn_op_next(yasm_insn_operand *op); -#define yasm_insn_op_next(cur) STAILQ_NEXT(cur, link) - -/** Add operand to the end of an instruction. - * \note Does not make a copy of the operand; so don't pass this function - * static or local variables, and discard the op pointer after calling - * this function. - * \param insn instruction - * \param op operand (may be NULL) - * \return If operand was actually appended (it wasn't NULL), the operand; - * otherwise NULL. - */ -YASM_LIB_DECL -/*@null@*/ yasm_insn_operand *yasm_insn_ops_append - (yasm_insn *insn, - /*@returned@*/ /*@null@*/ yasm_insn_operand *op); - -/** Associate a prefix with an instruction. - * \param insn instruction - * \param prefix data that identifies the prefix - */ -YASM_LIB_DECL -void yasm_insn_add_prefix(yasm_insn *insn, uintptr_t prefix); - -/** Associate a segment prefix with an instruction. - * \param insn instruction - * \param segreg data that identifies the segment register - */ -YASM_LIB_DECL -void yasm_insn_add_seg_prefix(yasm_insn *insn, uintptr_t segreg); - -/** Initialize the common parts of an instruction. - * \internal For use by yasm_arch implementations only. - * \param insn instruction - */ -YASM_LIB_DECL -void yasm_insn_initialize(/*@out@*/ yasm_insn *insn); - -/** Delete the common parts of an instruction. - * \internal For use by yasm_arch implementations only. - * \param insn instruction - * \param content if nonzero, deletes content of each operand - * \param arch architecture - */ -YASM_LIB_DECL -void yasm_insn_delete(yasm_insn *insn, - void (*ea_destroy) (/*@only@*/ yasm_effaddr *)); - -/** Print a list of instruction operands. For debugging purposes. - * \internal For use by yasm_arch implementations only. - * \param insn instruction - * \param f file - * \param indent_level indentation level - * \param arch architecture - */ -YASM_LIB_DECL -void yasm_insn_print(const yasm_insn *insn, FILE *f, int indent_level); - -/** Finalize the common parts of an instruction. - * \internal For use by yasm_arch implementations only. - * \param insn instruction - */ -YASM_LIB_DECL -void yasm_insn_finalize(yasm_insn *insn); - -#endif diff --git a/libyasm/intnum.c b/libyasm/intnum.c index 794c0723..5e157e69 100644 --- a/libyasm/intnum.c +++ b/libyasm/intnum.c @@ -24,7 +24,9 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ +#define YASM_LIB_INTERNAL #include "util.h" +/*@unused@*/ RCSID("$Id$"); #include #include @@ -38,14 +40,14 @@ /* "Native" "word" size for intnum calculations. */ -#define BITVECT_NATIVE_SIZE 256 +#define BITVECT_NATIVE_SIZE 128 struct yasm_intnum { union val { - long l; /* integer value (for integers <32 bits) */ - wordptr bv; /* bit vector (for integers >=32 bits) */ + unsigned long ul; /* integer value (for integers <=32 bits) */ + wordptr bv; /* bit vector (for integers >32 bits) */ } val; - enum { INTNUM_L, INTNUM_BV } type; + enum { INTNUM_UL, INTNUM_BV } type; }; /* static bitvect used for conversions */ @@ -79,73 +81,31 @@ yasm_intnum_cleanup(void) BitVector_Destroy(conv_bv); } -/* Compress a bitvector into intnum storage. - * If saved as a bitvector, clones the passed bitvector. - * Can modify the passed bitvector. - */ -static void -intnum_frombv(/*@out@*/ yasm_intnum *intn, wordptr bv) -{ - if (Set_Max(bv) < 31) { - intn->type = INTNUM_L; - intn->val.l = (long)BitVector_Chunk_Read(bv, 31, 0); - } else if (BitVector_msb_(bv)) { - /* Negative, negate and see if we'll fit into a long. */ - unsigned long ul; - BitVector_Negate(bv, bv); - if (Set_Max(bv) >= 32 || - ((ul = BitVector_Chunk_Read(bv, 32, 0)) & 0x80000000)) { - /* too negative */ - BitVector_Negate(bv, bv); - intn->type = INTNUM_BV; - intn->val.bv = BitVector_Clone(bv); - } else { - intn->type = INTNUM_L; - intn->val.l = -((long)ul); - } - } else { - intn->type = INTNUM_BV; - intn->val.bv = BitVector_Clone(bv); - } -} - -/* If intnum is a BV, returns its bitvector directly. - * If not, converts into passed bv and returns that instead. - */ -static wordptr -intnum_tobv(/*@returned@*/ wordptr bv, const yasm_intnum *intn) -{ - if (intn->type == INTNUM_BV) - return intn->val.bv; - - BitVector_Empty(bv); - if (intn->val.l >= 0) - BitVector_Chunk_Store(bv, 32, 0, (unsigned long)intn->val.l); - else { - BitVector_Chunk_Store(bv, 32, 0, (unsigned long)-intn->val.l); - BitVector_Negate(bv, bv); - } - return bv; -} - yasm_intnum * yasm_intnum_create_dec(char *str) { yasm_intnum *intn = yasm_xmalloc(sizeof(yasm_intnum)); switch (BitVector_from_Dec_static(from_dec_data, conv_bv, - (unsigned char *)str)) { - case ErrCode_Pars: - yasm_error_set(YASM_ERROR_VALUE, N_("invalid decimal literal")); - break; - case ErrCode_Ovfl: - yasm_error_set(YASM_ERROR_OVERFLOW, - N_("Numeric constant too large for internal format")); - break; - default: - break; + (unsigned char *)str)) { + case ErrCode_Pars: + yasm_error_set(YASM_ERROR_VALUE, N_("invalid decimal literal")); + break; + case ErrCode_Ovfl: + yasm_error_set(YASM_ERROR_OVERFLOW, + N_("Numeric constant too large for internal format")); + break; + default: + break; } - intnum_frombv(intn, conv_bv); + if (Set_Max(conv_bv) < 32) { + intn->type = INTNUM_UL; + intn->val.ul = BitVector_Chunk_Read(conv_bv, 32, 0); + } else { + intn->type = INTNUM_BV; + intn->val.bv = BitVector_Clone(conv_bv); + } + return intn; } @@ -155,17 +115,24 @@ yasm_intnum_create_bin(char *str) yasm_intnum *intn = yasm_xmalloc(sizeof(yasm_intnum)); switch (BitVector_from_Bin(conv_bv, (unsigned char *)str)) { - case ErrCode_Pars: - yasm_error_set(YASM_ERROR_VALUE, N_("invalid binary literal")); - break; - case ErrCode_Ovfl: - yasm_error_set(YASM_ERROR_OVERFLOW, - N_("Numeric constant too large for internal format")); - break; - default: - break; + case ErrCode_Pars: + yasm_error_set(YASM_ERROR_VALUE, N_("invalid binary literal")); + break; + case ErrCode_Ovfl: + yasm_error_set(YASM_ERROR_OVERFLOW, + N_("Numeric constant too large for internal format")); + break; + default: + break; } - intnum_frombv(intn, conv_bv); + if (Set_Max(conv_bv) < 32) { + intn->type = INTNUM_UL; + intn->val.ul = BitVector_Chunk_Read(conv_bv, 32, 0); + } else { + intn->type = INTNUM_BV; + intn->val.bv = BitVector_Clone(conv_bv); + } + return intn; } @@ -175,17 +142,24 @@ yasm_intnum_create_oct(char *str) yasm_intnum *intn = yasm_xmalloc(sizeof(yasm_intnum)); switch (BitVector_from_Oct(conv_bv, (unsigned char *)str)) { - case ErrCode_Pars: - yasm_error_set(YASM_ERROR_VALUE, N_("invalid octal literal")); - break; - case ErrCode_Ovfl: - yasm_error_set(YASM_ERROR_OVERFLOW, - N_("Numeric constant too large for internal format")); - break; - default: - break; + case ErrCode_Pars: + yasm_error_set(YASM_ERROR_VALUE, N_("invalid octal literal")); + break; + case ErrCode_Ovfl: + yasm_error_set(YASM_ERROR_OVERFLOW, + N_("Numeric constant too large for internal format")); + break; + default: + break; } - intnum_frombv(intn, conv_bv); + if (Set_Max(conv_bv) < 32) { + intn->type = INTNUM_UL; + intn->val.ul = BitVector_Chunk_Read(conv_bv, 32, 0); + } else { + intn->type = INTNUM_BV; + intn->val.bv = BitVector_Clone(conv_bv); + } + return intn; } @@ -195,17 +169,24 @@ yasm_intnum_create_hex(char *str) yasm_intnum *intn = yasm_xmalloc(sizeof(yasm_intnum)); switch (BitVector_from_Hex(conv_bv, (unsigned char *)str)) { - case ErrCode_Pars: - yasm_error_set(YASM_ERROR_VALUE, N_("invalid hex literal")); - break; - case ErrCode_Ovfl: - yasm_error_set(YASM_ERROR_OVERFLOW, - N_("Numeric constant too large for internal format")); - break; - default: - break; + case ErrCode_Pars: + yasm_error_set(YASM_ERROR_VALUE, N_("invalid hex literal")); + break; + case ErrCode_Ovfl: + yasm_error_set(YASM_ERROR_OVERFLOW, + N_("Numeric constant too large for internal format")); + break; + default: + break; } - intnum_frombv(intn, conv_bv); + if (Set_Max(conv_bv) < 32) { + intn->type = INTNUM_UL; + intn->val.ul = BitVector_Chunk_Read(conv_bv, 32, 0); + } else { + intn->type = INTNUM_BV; + intn->val.bv = BitVector_Clone(conv_bv); + } + return intn; } @@ -217,87 +198,42 @@ yasm_intnum_create_charconst_nasm(const char *str) size_t len = strlen(str); if(len*8 > BITVECT_NATIVE_SIZE) - yasm_error_set(YASM_ERROR_OVERFLOW, - N_("Character constant too large for internal format")); + yasm_error_set(YASM_ERROR_OVERFLOW, + N_("Character constant too large for internal format")); - /* be conservative in choosing bitvect in case MSB is set */ - if (len > 3) { - BitVector_Empty(conv_bv); - intn->type = INTNUM_BV; + if (len > 4) { + BitVector_Empty(conv_bv); + intn->type = INTNUM_BV; } else { - intn->val.l = 0; - intn->type = INTNUM_L; + intn->val.ul = 0; + intn->type = INTNUM_UL; } switch (len) { - case 3: - intn->val.l |= ((unsigned long)str[2]) & 0xff; - intn->val.l <<= 8; - /*@fallthrough@*/ - case 2: - intn->val.l |= ((unsigned long)str[1]) & 0xff; - intn->val.l <<= 8; - /*@fallthrough@*/ - case 1: - intn->val.l |= ((unsigned long)str[0]) & 0xff; - case 0: - break; - default: - /* >=32 bit conversion */ - while (len) { - BitVector_Move_Left(conv_bv, 8); - BitVector_Chunk_Store(conv_bv, 8, 0, - ((unsigned long)str[--len]) & 0xff); - } - intn->val.bv = BitVector_Clone(conv_bv); - } - - return intn; -} - -yasm_intnum * -yasm_intnum_create_charconst_tasm(const char *str) -{ - yasm_intnum *intn = yasm_xmalloc(sizeof(yasm_intnum)); - size_t len = strlen(str); - size_t i; - - if(len*8 > BITVECT_NATIVE_SIZE) - yasm_error_set(YASM_ERROR_OVERFLOW, - N_("Character constant too large for internal format")); - - /* be conservative in choosing bitvect in case MSB is set */ - if (len > 3) { - BitVector_Empty(conv_bv); - intn->type = INTNUM_BV; - } else { - intn->val.l = 0; - intn->type = INTNUM_L; - } - - /* tasm uses big endian notation */ - i = 0; - switch (len) { - case 3: - intn->val.l |= ((unsigned long)str[i++]) & 0xff; - intn->val.l <<= 8; - /*@fallthrough@*/ - case 2: - intn->val.l |= ((unsigned long)str[i++]) & 0xff; - intn->val.l <<= 8; - /*@fallthrough@*/ - case 1: - intn->val.l |= ((unsigned long)str[i++]) & 0xff; - case 0: - break; - default: - /* >=32 bit conversion */ - while (i < len) { - BitVector_Chunk_Store(conv_bv, 8, (len-i-1)*8, - ((unsigned long)str[i]) & 0xff); - i++; - } - intn->val.bv = BitVector_Clone(conv_bv); + case 4: + intn->val.ul |= ((unsigned long)str[3]) & 0xff; + intn->val.ul <<= 8; + /*@fallthrough@*/ + case 3: + intn->val.ul |= ((unsigned long)str[2]) & 0xff; + intn->val.ul <<= 8; + /*@fallthrough@*/ + case 2: + intn->val.ul |= ((unsigned long)str[1]) & 0xff; + intn->val.ul <<= 8; + /*@fallthrough@*/ + case 1: + intn->val.ul |= ((unsigned long)str[0]) & 0xff; + case 0: + break; + default: + /* >32 bit conversion */ + while (len) { + BitVector_Move_Left(conv_bv, 8); + BitVector_Chunk_Store(conv_bv, 8, 0, + (unsigned long)str[--len]); + } + intn->val.bv = BitVector_Clone(conv_bv); } return intn; @@ -309,15 +245,8 @@ yasm_intnum_create_uint(unsigned long i) { yasm_intnum *intn = yasm_xmalloc(sizeof(yasm_intnum)); - if (i > LONG_MAX) { - /* Too big, store as bitvector */ - intn->val.bv = BitVector_Create(BITVECT_NATIVE_SIZE, TRUE); - intn->type = INTNUM_BV; - BitVector_Chunk_Store(intn->val.bv, 32, 0, i); - } else { - intn->val.l = (long)i; - intn->type = INTNUM_L; - } + intn->val.ul = i; + intn->type = INTNUM_UL; return intn; } @@ -325,17 +254,26 @@ yasm_intnum_create_uint(unsigned long i) yasm_intnum * yasm_intnum_create_int(long i) { - yasm_intnum *intn = yasm_xmalloc(sizeof(yasm_intnum)); + yasm_intnum *intn; - intn->val.l = i; - intn->type = INTNUM_L; + /* positive numbers can go through the uint() function */ + if (i >= 0) + return yasm_intnum_create_uint((unsigned long)i); + + BitVector_Empty(conv_bv); + BitVector_Chunk_Store(conv_bv, 32, 0, (unsigned long)(-i)); + BitVector_Negate(conv_bv, conv_bv); + + intn = yasm_xmalloc(sizeof(yasm_intnum)); + intn->val.bv = BitVector_Clone(conv_bv); + intn->type = INTNUM_BV; return intn; } yasm_intnum * yasm_intnum_create_leb128(const unsigned char *ptr, int sign, - unsigned long *size) + unsigned long *size) { yasm_intnum *intn = yasm_xmalloc(sizeof(yasm_intnum)); const unsigned char *ptr_orig = ptr; @@ -343,51 +281,65 @@ yasm_intnum_create_leb128(const unsigned char *ptr, int sign, BitVector_Empty(conv_bv); for (;;) { - BitVector_Chunk_Store(conv_bv, 7, i, *ptr); - i += 7; - if ((*ptr & 0x80) != 0x80) - break; - ptr++; + BitVector_Chunk_Store(conv_bv, 7, i, *ptr); + i += 7; + if ((*ptr & 0x80) != 0x80) + break; + ptr++; } *size = (unsigned long)(ptr-ptr_orig)+1; if(i > BITVECT_NATIVE_SIZE) - yasm_error_set(YASM_ERROR_OVERFLOW, - N_("Numeric constant too large for internal format")); + yasm_error_set(YASM_ERROR_OVERFLOW, + N_("Numeric constant too large for internal format")); else if (sign && (*ptr & 0x40) == 0x40) - BitVector_Interval_Fill(conv_bv, i, BITVECT_NATIVE_SIZE-1); + BitVector_Interval_Fill(conv_bv, i, BITVECT_NATIVE_SIZE-1); + + if (Set_Max(conv_bv) < 32) { + intn->type = INTNUM_UL; + intn->val.ul = BitVector_Chunk_Read(conv_bv, 32, 0); + } else { + intn->type = INTNUM_BV; + intn->val.bv = BitVector_Clone(conv_bv); + } - intnum_frombv(intn, conv_bv); return intn; } yasm_intnum * yasm_intnum_create_sized(unsigned char *ptr, int sign, size_t srcsize, - int bigendian) + int bigendian) { yasm_intnum *intn = yasm_xmalloc(sizeof(yasm_intnum)); unsigned long i = 0; if (srcsize*8 > BITVECT_NATIVE_SIZE) - yasm_error_set(YASM_ERROR_OVERFLOW, - N_("Numeric constant too large for internal format")); + yasm_error_set(YASM_ERROR_OVERFLOW, + N_("Numeric constant too large for internal format")); /* Read the buffer into a bitvect */ BitVector_Empty(conv_bv); if (bigendian) { - /* TODO */ - yasm_internal_error(N_("big endian not implemented")); + /* TODO */ + yasm_internal_error(N_("big endian not implemented")); } else { - for (i = 0; i < srcsize; i++) - BitVector_Chunk_Store(conv_bv, 8, i*8, ptr[i]); + for (i = 0; i < srcsize; i++) + BitVector_Chunk_Store(conv_bv, 8, i*8, ptr[i]); } /* Sign extend if needed */ - if (srcsize*8 < BITVECT_NATIVE_SIZE && sign && (ptr[i-1] & 0x80) == 0x80) - BitVector_Interval_Fill(conv_bv, i*8, BITVECT_NATIVE_SIZE-1); + if (srcsize*8 < BITVECT_NATIVE_SIZE && sign && (ptr[i] & 0x80) == 0x80) + BitVector_Interval_Fill(conv_bv, i*8, BITVECT_NATIVE_SIZE-1); + + if (Set_Max(conv_bv) < 32) { + intn->type = INTNUM_UL; + intn->val.ul = BitVector_Chunk_Read(conv_bv, 32, 0); + } else { + intn->type = INTNUM_BV; + intn->val.bv = BitVector_Clone(conv_bv); + } - intnum_frombv(intn, conv_bv); return intn; } @@ -397,12 +349,12 @@ yasm_intnum_copy(const yasm_intnum *intn) yasm_intnum *n = yasm_xmalloc(sizeof(yasm_intnum)); switch (intn->type) { - case INTNUM_L: - n->val.l = intn->val.l; - break; - case INTNUM_BV: - n->val.bv = BitVector_Clone(intn->val.bv); - break; + case INTNUM_UL: + n->val.ul = intn->val.ul; + break; + case INTNUM_BV: + n->val.bv = BitVector_Clone(intn->val.bv); + break; } n->type = intn->type; @@ -412,10 +364,8 @@ yasm_intnum_copy(const yasm_intnum *intn) void yasm_intnum_destroy(yasm_intnum *intn) { - if (intn == NULL) - return; if (intn->type == INTNUM_BV) - BitVector_Destroy(intn->val.bv); + BitVector_Destroy(intn->val.bv); yasm_xfree(intn); } @@ -430,314 +380,291 @@ yasm_intnum_calc(yasm_intnum *acc, yasm_expr_op op, yasm_intnum *operand) /* Always do computations with in full bit vector. * Bit vector results must be calculated through intermediate storage. */ - op1 = intnum_tobv(op1static, acc); - if (operand) - op2 = intnum_tobv(op2static, operand); + if (acc->type == INTNUM_BV) + op1 = acc->val.bv; + else { + op1 = op1static; + BitVector_Empty(op1); + BitVector_Chunk_Store(op1, 32, 0, acc->val.ul); + } + + if (operand) { + if (operand->type == INTNUM_BV) + op2 = operand->val.bv; + else { + op2 = op2static; + BitVector_Empty(op2); + BitVector_Chunk_Store(op2, 32, 0, operand->val.ul); + } + } if (!operand && op != YASM_EXPR_NEG && op != YASM_EXPR_NOT && - op != YASM_EXPR_LNOT) { - yasm_error_set(YASM_ERROR_ARITHMETIC, - N_("operation needs an operand")); - BitVector_Empty(result); - return 1; + op != YASM_EXPR_LNOT) { + yasm_error_set(YASM_ERROR_ARITHMETIC, + N_("operation needs an operand")); + BitVector_Empty(result); + return 1; } /* A operation does a bitvector computation if result is allocated. */ switch (op) { - case YASM_EXPR_ADD: - BitVector_add(result, op1, op2, &carry); - break; - case YASM_EXPR_SUB: - BitVector_sub(result, op1, op2, &carry); - break; - case YASM_EXPR_MUL: - BitVector_Multiply(result, op1, op2); - break; - case YASM_EXPR_DIV: - /* TODO: make sure op1 and op2 are unsigned */ - if (BitVector_is_empty(op2)) { - yasm_error_set(YASM_ERROR_ZERO_DIVISION, N_("divide by zero")); - BitVector_Empty(result); - return 1; - } else - BitVector_Divide(result, op1, op2, spare); - break; - case YASM_EXPR_SIGNDIV: - if (BitVector_is_empty(op2)) { - yasm_error_set(YASM_ERROR_ZERO_DIVISION, N_("divide by zero")); - BitVector_Empty(result); - return 1; - } else - BitVector_Divide(result, op1, op2, spare); - break; - case YASM_EXPR_MOD: - /* TODO: make sure op1 and op2 are unsigned */ - if (BitVector_is_empty(op2)) { - yasm_error_set(YASM_ERROR_ZERO_DIVISION, N_("divide by zero")); - BitVector_Empty(result); - return 1; - } else - BitVector_Divide(spare, op1, op2, result); - break; - case YASM_EXPR_SIGNMOD: - if (BitVector_is_empty(op2)) { - yasm_error_set(YASM_ERROR_ZERO_DIVISION, N_("divide by zero")); - BitVector_Empty(result); - return 1; - } else - BitVector_Divide(spare, op1, op2, result); - break; - case YASM_EXPR_NEG: - BitVector_Negate(result, op1); - break; - case YASM_EXPR_NOT: - Set_Complement(result, op1); - break; - case YASM_EXPR_OR: - Set_Union(result, op1, op2); - break; - case YASM_EXPR_AND: - Set_Intersection(result, op1, op2); - break; - case YASM_EXPR_XOR: - Set_ExclusiveOr(result, op1, op2); - break; - case YASM_EXPR_XNOR: - Set_ExclusiveOr(result, op1, op2); - Set_Complement(result, result); - break; - case YASM_EXPR_NOR: - Set_Union(result, op1, op2); - Set_Complement(result, result); - break; - case YASM_EXPR_SHL: - if (operand->type == INTNUM_L && operand->val.l >= 0) { - BitVector_Copy(result, op1); - BitVector_Move_Left(result, (N_int)operand->val.l); - } else /* don't even bother, just zero result */ - BitVector_Empty(result); - break; - case YASM_EXPR_SHR: - if (operand->type == INTNUM_L && operand->val.l >= 0) { - BitVector_Copy(result, op1); - carry = BitVector_msb_(op1); - count = (N_int)operand->val.l; - while (count-- > 0) - BitVector_shift_right(result, carry); - } else /* don't even bother, just zero result */ - BitVector_Empty(result); - break; - case YASM_EXPR_LOR: - BitVector_Empty(result); - BitVector_LSB(result, !BitVector_is_empty(op1) || - !BitVector_is_empty(op2)); - break; - case YASM_EXPR_LAND: - BitVector_Empty(result); - BitVector_LSB(result, !BitVector_is_empty(op1) && - !BitVector_is_empty(op2)); - break; - case YASM_EXPR_LNOT: - BitVector_Empty(result); - BitVector_LSB(result, BitVector_is_empty(op1)); - break; - case YASM_EXPR_LXOR: - BitVector_Empty(result); - BitVector_LSB(result, !BitVector_is_empty(op1) ^ - !BitVector_is_empty(op2)); - break; - case YASM_EXPR_LXNOR: - BitVector_Empty(result); - BitVector_LSB(result, !(!BitVector_is_empty(op1) ^ - !BitVector_is_empty(op2))); - break; - case YASM_EXPR_LNOR: - BitVector_Empty(result); - BitVector_LSB(result, !(!BitVector_is_empty(op1) || - !BitVector_is_empty(op2))); - break; - case YASM_EXPR_EQ: - BitVector_Empty(result); - BitVector_LSB(result, BitVector_equal(op1, op2)); - break; - case YASM_EXPR_LT: - BitVector_Empty(result); - BitVector_LSB(result, BitVector_Compare(op1, op2) < 0); - break; - case YASM_EXPR_GT: - BitVector_Empty(result); - BitVector_LSB(result, BitVector_Compare(op1, op2) > 0); - break; - case YASM_EXPR_LE: - BitVector_Empty(result); - BitVector_LSB(result, BitVector_Compare(op1, op2) <= 0); - break; - case YASM_EXPR_GE: - BitVector_Empty(result); - BitVector_LSB(result, BitVector_Compare(op1, op2) >= 0); - break; - case YASM_EXPR_NE: - BitVector_Empty(result); - BitVector_LSB(result, !BitVector_equal(op1, op2)); - break; - case YASM_EXPR_SEG: - yasm_error_set(YASM_ERROR_ARITHMETIC, N_("invalid use of '%s'"), - "SEG"); - break; - case YASM_EXPR_WRT: - yasm_error_set(YASM_ERROR_ARITHMETIC, N_("invalid use of '%s'"), - "WRT"); - break; - case YASM_EXPR_SEGOFF: - yasm_error_set(YASM_ERROR_ARITHMETIC, N_("invalid use of '%s'"), - ":"); - break; - case YASM_EXPR_IDENT: - if (result) - BitVector_Copy(result, op1); - break; - default: - yasm_error_set(YASM_ERROR_ARITHMETIC, - N_("invalid operation in intnum calculation")); - BitVector_Empty(result); - return 1; + case YASM_EXPR_ADD: + BitVector_add(result, op1, op2, &carry); + break; + case YASM_EXPR_SUB: + BitVector_sub(result, op1, op2, &carry); + break; + case YASM_EXPR_MUL: + BitVector_Multiply(result, op1, op2); + break; + case YASM_EXPR_DIV: + /* TODO: make sure op1 and op2 are unsigned */ + if (BitVector_is_empty(op2)) { + yasm_error_set(YASM_ERROR_ZERO_DIVISION, N_("divide by zero")); + BitVector_Empty(result); + return 1; + } else + BitVector_Divide(result, op1, op2, spare); + break; + case YASM_EXPR_SIGNDIV: + if (BitVector_is_empty(op2)) { + yasm_error_set(YASM_ERROR_ZERO_DIVISION, N_("divide by zero")); + BitVector_Empty(result); + return 1; + } else + BitVector_Divide(result, op1, op2, spare); + break; + case YASM_EXPR_MOD: + /* TODO: make sure op1 and op2 are unsigned */ + if (BitVector_is_empty(op2)) { + yasm_error_set(YASM_ERROR_ZERO_DIVISION, N_("divide by zero")); + BitVector_Empty(result); + return 1; + } else + BitVector_Divide(spare, op1, op2, result); + break; + case YASM_EXPR_SIGNMOD: + if (BitVector_is_empty(op2)) { + yasm_error_set(YASM_ERROR_ZERO_DIVISION, N_("divide by zero")); + BitVector_Empty(result); + return 1; + } else + BitVector_Divide(spare, op1, op2, result); + break; + case YASM_EXPR_NEG: + BitVector_Negate(result, op1); + break; + case YASM_EXPR_NOT: + Set_Complement(result, op1); + break; + case YASM_EXPR_OR: + Set_Union(result, op1, op2); + break; + case YASM_EXPR_AND: + Set_Intersection(result, op1, op2); + break; + case YASM_EXPR_XOR: + Set_ExclusiveOr(result, op1, op2); + break; + case YASM_EXPR_XNOR: + Set_ExclusiveOr(result, op1, op2); + Set_Complement(result, result); + break; + case YASM_EXPR_NOR: + Set_Union(result, op1, op2); + Set_Complement(result, result); + break; + case YASM_EXPR_SHL: + if (operand->type == INTNUM_UL) { + BitVector_Copy(result, op1); + BitVector_Move_Left(result, (N_int)operand->val.ul); + } else /* don't even bother, just zero result */ + BitVector_Empty(result); + break; + case YASM_EXPR_SHR: + if (operand->type == INTNUM_UL) { + BitVector_Copy(result, op1); + carry = BitVector_msb_(op1); + count = (N_int)operand->val.ul; + while (count-- > 0) + BitVector_shift_right(result, carry); + } else /* don't even bother, just zero result */ + BitVector_Empty(result); + break; + case YASM_EXPR_LOR: + BitVector_Empty(result); + BitVector_LSB(result, !BitVector_is_empty(op1) || + !BitVector_is_empty(op2)); + break; + case YASM_EXPR_LAND: + BitVector_Empty(result); + BitVector_LSB(result, !BitVector_is_empty(op1) && + !BitVector_is_empty(op2)); + break; + case YASM_EXPR_LNOT: + BitVector_Empty(result); + BitVector_LSB(result, BitVector_is_empty(op1)); + break; + case YASM_EXPR_LXOR: + BitVector_Empty(result); + BitVector_LSB(result, !BitVector_is_empty(op1) ^ + !BitVector_is_empty(op2)); + break; + case YASM_EXPR_LXNOR: + BitVector_Empty(result); + BitVector_LSB(result, !(!BitVector_is_empty(op1) ^ + !BitVector_is_empty(op2))); + break; + case YASM_EXPR_LNOR: + BitVector_Empty(result); + BitVector_LSB(result, !(!BitVector_is_empty(op1) || + !BitVector_is_empty(op2))); + break; + case YASM_EXPR_EQ: + BitVector_Empty(result); + BitVector_LSB(result, BitVector_equal(op1, op2)); + break; + case YASM_EXPR_LT: + BitVector_Empty(result); + BitVector_LSB(result, BitVector_Compare(op1, op2) < 0); + break; + case YASM_EXPR_GT: + BitVector_Empty(result); + BitVector_LSB(result, BitVector_Compare(op1, op2) > 0); + break; + case YASM_EXPR_LE: + BitVector_Empty(result); + BitVector_LSB(result, BitVector_Compare(op1, op2) <= 0); + break; + case YASM_EXPR_GE: + BitVector_Empty(result); + BitVector_LSB(result, BitVector_Compare(op1, op2) >= 0); + break; + case YASM_EXPR_NE: + BitVector_Empty(result); + BitVector_LSB(result, !BitVector_equal(op1, op2)); + break; + case YASM_EXPR_SEG: + yasm_error_set(YASM_ERROR_ARITHMETIC, N_("invalid use of '%s'"), + "SEG"); + break; + case YASM_EXPR_WRT: + yasm_error_set(YASM_ERROR_ARITHMETIC, N_("invalid use of '%s'"), + "WRT"); + break; + case YASM_EXPR_SEGOFF: + yasm_error_set(YASM_ERROR_ARITHMETIC, N_("invalid use of '%s'"), + ":"); + break; + case YASM_EXPR_IDENT: + if (result) + BitVector_Copy(result, op1); + break; + default: + yasm_error_set(YASM_ERROR_ARITHMETIC, + N_("invalid operation in intnum calculation")); + BitVector_Empty(result); + return 1; } /* Try to fit the result into 32 bits if possible */ - if (acc->type == INTNUM_BV) - BitVector_Destroy(acc->val.bv); - intnum_frombv(acc, result); + if (Set_Max(result) < 32) { + if (acc->type == INTNUM_BV) { + BitVector_Destroy(acc->val.bv); + acc->type = INTNUM_UL; + } + acc->val.ul = BitVector_Chunk_Read(result, 32, 0); + } else { + if (acc->type == INTNUM_BV) { + BitVector_Copy(acc->val.bv, result); + } else { + acc->type = INTNUM_BV; + acc->val.bv = BitVector_Clone(result); + } + } return 0; } /*@=nullderef =nullpass =branchstate@*/ -int -yasm_intnum_compare(const yasm_intnum *intn1, const yasm_intnum *intn2) -{ - wordptr op1, op2; - - if (intn1->type == INTNUM_L && intn2->type == INTNUM_L) { - if (intn1->val.l < intn2->val.l) - return -1; - if (intn1->val.l > intn2->val.l) - return 1; - return 0; - } - - op1 = intnum_tobv(op1static, intn1); - op2 = intnum_tobv(op2static, intn2); - return BitVector_Compare(op1, op2); -} - void yasm_intnum_zero(yasm_intnum *intn) { - yasm_intnum_set_int(intn, 0); -} - -void -yasm_intnum_set(yasm_intnum *intn, const yasm_intnum *val) -{ - if (intn->type == val->type) { - switch (val->type) { - case INTNUM_L: - intn->val.l = val->val.l; - break; - case INTNUM_BV: - BitVector_Copy(intn->val.bv, val->val.bv); - break; - } - } else { - switch (val->type) { - case INTNUM_L: - BitVector_Destroy(intn->val.bv); - intn->val.l = val->val.l; - break; - case INTNUM_BV: - intn->val.bv = BitVector_Clone(val->val.bv); - break; - } - intn->type = val->type; - } + yasm_intnum_set_uint(intn, 0); } void yasm_intnum_set_uint(yasm_intnum *intn, unsigned long val) { - if (val > LONG_MAX) { - if (intn->type != INTNUM_BV) { - intn->val.bv = BitVector_Create(BITVECT_NATIVE_SIZE, TRUE); - intn->type = INTNUM_BV; - } - BitVector_Chunk_Store(intn->val.bv, 32, 0, val); - } else { - if (intn->type == INTNUM_BV) { - BitVector_Destroy(intn->val.bv); - intn->type = INTNUM_L; - } - intn->val.l = (long)val; + if (intn->type == INTNUM_BV) { + BitVector_Destroy(intn->val.bv); + intn->type = INTNUM_UL; } + intn->val.ul = val; } void yasm_intnum_set_int(yasm_intnum *intn, long val) { + /* positive numbers can go through the uint() function */ + if (val >= 0) { + yasm_intnum_set_uint(intn, (unsigned long)val); + return; + } + + BitVector_Empty(conv_bv); + BitVector_Chunk_Store(conv_bv, 32, 0, (unsigned long)(-val)); + BitVector_Negate(conv_bv, conv_bv); + if (intn->type == INTNUM_BV) - BitVector_Destroy(intn->val.bv); - intn->type = INTNUM_L; - intn->val.l = val; + BitVector_Copy(intn->val.bv, conv_bv); + else { + intn->val.bv = BitVector_Clone(conv_bv); + intn->type = INTNUM_BV; + } } int yasm_intnum_is_zero(const yasm_intnum *intn) { - return (intn->type == INTNUM_L && intn->val.l == 0); + return (intn->type == INTNUM_UL && intn->val.ul == 0); } int yasm_intnum_is_pos1(const yasm_intnum *intn) { - return (intn->type == INTNUM_L && intn->val.l == 1); + return (intn->type == INTNUM_UL && intn->val.ul == 1); } int yasm_intnum_is_neg1(const yasm_intnum *intn) { - return (intn->type == INTNUM_L && intn->val.l == -1); + return (intn->type == INTNUM_BV && BitVector_is_full(intn->val.bv)); } int yasm_intnum_sign(const yasm_intnum *intn) { - if (intn->type == INTNUM_L) { - if (intn->val.l == 0) - return 0; - else if (intn->val.l < 0) - return -1; - else - return 1; + if (intn->type == INTNUM_UL) { + if (intn->val.ul == 0) + return 0; + else + return 1; } else - return BitVector_Sign(intn->val.bv); + return BitVector_Sign(intn->val.bv); } unsigned long yasm_intnum_get_uint(const yasm_intnum *intn) { switch (intn->type) { - case INTNUM_L: - if (intn->val.l < 0) - return 0; - return (unsigned long)intn->val.l; - case INTNUM_BV: - if (BitVector_msb_(intn->val.bv)) - return 0; - if (Set_Max(intn->val.bv) > 32) - return ULONG_MAX; - return BitVector_Chunk_Read(intn->val.bv, 32, 0); - default: - yasm_internal_error(N_("unknown intnum type")); - /*@notreached@*/ - return 0; + case INTNUM_UL: + return intn->val.ul; + case INTNUM_BV: + return BitVector_Chunk_Read(intn->val.bv, 32, 0); + default: + yasm_internal_error(N_("unknown intnum type")); + /*@notreached@*/ + return 0; } } @@ -745,38 +672,39 @@ long yasm_intnum_get_int(const yasm_intnum *intn) { switch (intn->type) { - case INTNUM_L: - return intn->val.l; - case INTNUM_BV: - if (BitVector_msb_(intn->val.bv)) { - /* it's negative: negate the bitvector to get a positive - * number, then negate the positive number. - */ - unsigned long ul; + case INTNUM_UL: + /* unsigned long values are always positive; max out if needed */ + return (intn->val.ul & 0x80000000) ? LONG_MAX : (long)intn->val.ul; + case INTNUM_BV: + if (BitVector_msb_(intn->val.bv)) { + /* it's negative: negate the bitvector to get a positive + * number, then negate the positive number. + */ + unsigned long ul; - BitVector_Negate(conv_bv, intn->val.bv); - if (Set_Max(conv_bv) >= 32) { - /* too negative */ - return LONG_MIN; - } - ul = BitVector_Chunk_Read(conv_bv, 32, 0); - /* check for too negative */ - return (ul & 0x80000000) ? LONG_MIN : -((long)ul); - } + BitVector_Negate(conv_bv, intn->val.bv); + if (Set_Max(conv_bv) >= 32) { + /* too negative */ + return LONG_MIN; + } + ul = BitVector_Chunk_Read(conv_bv, 32, 0); + /* check for too negative */ + return (ul & 0x80000000) ? LONG_MIN : -((long)ul); + } - /* it's positive, and since it's a BV, it must be >0x7FFFFFFF */ - return LONG_MAX; - default: - yasm_internal_error(N_("unknown intnum type")); - /*@notreached@*/ - return 0; + /* it's positive, and since it's a BV, it must be >0x7FFFFFFF */ + return LONG_MAX; + default: + yasm_internal_error(N_("unknown intnum type")); + /*@notreached@*/ + return 0; } } void yasm_intnum_get_sized(const yasm_intnum *intn, unsigned char *ptr, - size_t destsize, size_t valsize, int shift, - int bigendian, int warn) + size_t destsize, size_t valsize, int shift, + int bigendian, int warn) { wordptr op1 = op1static, op2; unsigned char *buf; @@ -786,42 +714,48 @@ yasm_intnum_get_sized(const yasm_intnum *intn, unsigned char *ptr, /* Currently don't support destinations larger than our native size */ if (destsize*8 > BITVECT_NATIVE_SIZE) - yasm_internal_error(N_("destination too large")); + yasm_internal_error(N_("destination too large")); /* General size warnings */ if (warn<0 && !yasm_intnum_check_size(intn, valsize, rshift, 1)) - yasm_warn_set(YASM_WARN_GENERAL, - N_("value does not fit in signed %d bit field"), - valsize); + yasm_warn_set(YASM_WARN_GENERAL, + N_("value does not fit in signed %d bit field"), + valsize); if (warn>0 && !yasm_intnum_check_size(intn, valsize, rshift, 2)) - yasm_warn_set(YASM_WARN_GENERAL, - N_("value does not fit in %d bit field"), valsize); + yasm_warn_set(YASM_WARN_GENERAL, + N_("value does not fit in %d bit field"), valsize); /* Read the original data into a bitvect */ if (bigendian) { - /* TODO */ - yasm_internal_error(N_("big endian not implemented")); + /* TODO */ + yasm_internal_error(N_("big endian not implemented")); } else - BitVector_Block_Store(op1, ptr, (N_int)destsize); + BitVector_Block_Store(op1, ptr, (N_int)destsize); /* If not already a bitvect, convert value to be written to a bitvect */ - op2 = intnum_tobv(op2static, intn); + if (intn->type == INTNUM_BV) + op2 = intn->val.bv; + else { + op2 = op2static; + BitVector_Empty(op2); + BitVector_Chunk_Store(op2, 32, 0, intn->val.ul); + } /* Check low bits if right shifting and warnings enabled */ if (warn && rshift > 0) { - BitVector_Copy(conv_bv, op2); - BitVector_Move_Left(conv_bv, (N_int)(BITVECT_NATIVE_SIZE-rshift)); - if (!BitVector_is_empty(conv_bv)) - yasm_warn_set(YASM_WARN_GENERAL, - N_("misaligned value, truncating to boundary")); + BitVector_Copy(conv_bv, op2); + BitVector_Move_Left(conv_bv, (N_int)(BITVECT_NATIVE_SIZE-rshift)); + if (!BitVector_is_empty(conv_bv)) + yasm_warn_set(YASM_WARN_GENERAL, + N_("misaligned value, truncating to boundary")); } /* Shift right if needed */ if (rshift > 0) { - carry_in = BitVector_msb_(op2); - while (rshift-- > 0) - BitVector_shift_right(op2, carry_in); - shift = 0; + carry_in = BitVector_msb_(op2); + while (rshift-- > 0) + BitVector_shift_right(op2, carry_in); + shift = 0; } /* Write the new value into the destination bitvect */ @@ -830,53 +764,56 @@ yasm_intnum_get_sized(const yasm_intnum *intn, unsigned char *ptr, /* Write out the new data */ buf = BitVector_Block_Read(op1, &len); if (bigendian) { - /* TODO */ - yasm_internal_error(N_("big endian not implemented")); + /* TODO */ + yasm_internal_error(N_("big endian not implemented")); } else - memcpy(ptr, buf, destsize); + memcpy(ptr, buf, destsize); yasm_xfree(buf); } /* Return 1 if okay size, 0 if not */ int yasm_intnum_check_size(const yasm_intnum *intn, size_t size, size_t rshift, - int rangetype) + int rangetype) { wordptr val; /* If not already a bitvect, convert value to a bitvect */ if (intn->type == INTNUM_BV) { - if (rshift > 0) { - val = conv_bv; - BitVector_Copy(val, intn->val.bv); - } else - val = intn->val.bv; - } else - val = intnum_tobv(conv_bv, intn); + if (rshift > 0) { + val = conv_bv; + BitVector_Copy(val, intn->val.bv); + } else + val = intn->val.bv; + } else { + val = conv_bv; + BitVector_Empty(val); + BitVector_Chunk_Store(val, 32, 0, intn->val.ul); + } if (size >= BITVECT_NATIVE_SIZE) - return 1; + return 1; if (rshift > 0) { - int carry_in = BitVector_msb_(val); - while (rshift-- > 0) - BitVector_shift_right(val, carry_in); + int carry_in = BitVector_msb_(val); + while (rshift-- > 0) + BitVector_shift_right(val, carry_in); } if (rangetype > 0) { - if (BitVector_msb_(val)) { - /* it's negative */ - int retval; + if (BitVector_msb_(val)) { + /* it's negative */ + int retval; - BitVector_Negate(conv_bv, val); - BitVector_dec(conv_bv, conv_bv); - retval = Set_Max(conv_bv) < (long)size-1; + BitVector_Negate(conv_bv, val); + BitVector_dec(conv_bv, conv_bv); + retval = Set_Max(conv_bv) < (long)size-1; - return retval; - } - - if (rangetype == 1) - size--; + return retval; + } + + if (rangetype == 1) + size--; } return (Set_Max(val) < (long)size); } @@ -884,30 +821,38 @@ yasm_intnum_check_size(const yasm_intnum *intn, size_t size, size_t rshift, int yasm_intnum_in_range(const yasm_intnum *intn, long low, long high) { - wordptr val = intnum_tobv(result, intn); + wordptr val = result; wordptr lval = op1static; wordptr hval = op2static; + /* If not already a bitvect, convert value to be written to a bitvect */ + if (intn->type == INTNUM_BV) + val = intn->val.bv; + else { + BitVector_Empty(val); + BitVector_Chunk_Store(val, 32, 0, intn->val.ul); + } + /* Convert high and low to bitvects */ BitVector_Empty(lval); if (low >= 0) - BitVector_Chunk_Store(lval, 32, 0, (unsigned long)low); + BitVector_Chunk_Store(lval, 32, 0, (unsigned long)low); else { - BitVector_Chunk_Store(lval, 32, 0, (unsigned long)(-low)); - BitVector_Negate(lval, lval); + BitVector_Chunk_Store(lval, 32, 0, (unsigned long)(-low)); + BitVector_Negate(lval, lval); } BitVector_Empty(hval); if (high >= 0) - BitVector_Chunk_Store(hval, 32, 0, (unsigned long)high); + BitVector_Chunk_Store(hval, 32, 0, (unsigned long)high); else { - BitVector_Chunk_Store(hval, 32, 0, (unsigned long)(-high)); - BitVector_Negate(hval, hval); + BitVector_Chunk_Store(hval, 32, 0, (unsigned long)(-high)); + BitVector_Negate(hval, hval); } /* Compare! */ return (BitVector_Compare(val, lval) >= 0 - && BitVector_Compare(val, hval) <= 0); + && BitVector_Compare(val, hval) <= 0); } static unsigned long @@ -917,27 +862,27 @@ get_leb128(wordptr val, unsigned char *ptr, int sign) unsigned char *ptr_orig = ptr; if (sign) { - /* Signed mode */ - if (BitVector_msb_(val)) { - /* Negative */ - BitVector_Negate(conv_bv, val); - size = Set_Max(conv_bv)+2; - } else { - /* Positive */ - size = Set_Max(val)+2; - } + /* Signed mode */ + if (BitVector_msb_(val)) { + /* Negative */ + BitVector_Negate(conv_bv, val); + size = Set_Max(conv_bv)+2; + } else { + /* Positive */ + size = Set_Max(val)+2; + } } else { - /* Unsigned mode */ - size = Set_Max(val)+1; + /* Unsigned mode */ + size = Set_Max(val)+1; } /* Positive/Unsigned write */ for (i=0; itype == INTNUM_L && intn->val.l == 0) { - *ptr = 0; - return 1; + if (intn->type == INTNUM_UL && intn->val.ul == 0) { + *ptr = 0; + return 1; } /* If not already a bitvect, convert value to be written to a bitvect */ - val = intnum_tobv(op1static, intn); + if (intn->type == INTNUM_BV) + val = intn->val.bv; + else { + BitVector_Empty(val); + BitVector_Chunk_Store(val, 32, 0, intn->val.ul); + } return get_leb128(val, ptr, sign); } @@ -980,15 +930,20 @@ yasm_intnum_get_leb128(const yasm_intnum *intn, unsigned char *ptr, int sign) unsigned long yasm_intnum_size_leb128(const yasm_intnum *intn, int sign) { - wordptr val; + wordptr val = op1static; /* Shortcut 0 */ - if (intn->type == INTNUM_L && intn->val.l == 0) { - return 1; + if (intn->type == INTNUM_UL && intn->val.ul == 0) { + return 1; } /* If not already a bitvect, convert value to a bitvect */ - val = intnum_tobv(op1static, intn); + if (intn->type == INTNUM_BV) + val = intn->val.bv; + else { + BitVector_Empty(val); + BitVector_Chunk_Store(val, 32, 0, intn->val.ul); + } return size_leb128(val, sign); } @@ -1000,16 +955,16 @@ yasm_get_sleb128(long v, unsigned char *ptr) /* Shortcut 0 */ if (v == 0) { - *ptr = 0; - return 1; + *ptr = 0; + return 1; } BitVector_Empty(val); if (v >= 0) - BitVector_Chunk_Store(val, 32, 0, (unsigned long)v); + BitVector_Chunk_Store(val, 32, 0, (unsigned long)v); else { - BitVector_Chunk_Store(val, 32, 0, (unsigned long)(-v)); - BitVector_Negate(val, val); + BitVector_Chunk_Store(val, 32, 0, (unsigned long)(-v)); + BitVector_Negate(val, val); } return get_leb128(val, ptr, 1); } @@ -1020,14 +975,14 @@ yasm_size_sleb128(long v) wordptr val = op1static; if (v == 0) - return 1; + return 1; BitVector_Empty(val); if (v >= 0) - BitVector_Chunk_Store(val, 32, 0, (unsigned long)v); + BitVector_Chunk_Store(val, 32, 0, (unsigned long)v); else { - BitVector_Chunk_Store(val, 32, 0, (unsigned long)(-v)); - BitVector_Negate(val, val); + BitVector_Chunk_Store(val, 32, 0, (unsigned long)(-v)); + BitVector_Negate(val, val); } return size_leb128(val, 1); } @@ -1039,8 +994,8 @@ yasm_get_uleb128(unsigned long v, unsigned char *ptr) /* Shortcut 0 */ if (v == 0) { - *ptr = 0; - return 1; + *ptr = 0; + return 1; } BitVector_Empty(val); @@ -1054,7 +1009,7 @@ yasm_size_uleb128(unsigned long v) wordptr val = op1static; if (v == 0) - return 1; + return 1; BitVector_Empty(val); BitVector_Chunk_Store(val, 32, 0, v); @@ -1067,14 +1022,14 @@ yasm_intnum_get_str(const yasm_intnum *intn) unsigned char *s; switch (intn->type) { - case INTNUM_L: - s = yasm_xmalloc(16); - sprintf((char *)s, "%ld", intn->val.l); - return (char *)s; - break; - case INTNUM_BV: - return (char *)BitVector_to_Dec(intn->val.bv); - break; + case INTNUM_UL: + s = yasm_xmalloc(16); + sprintf((char *)s, "%lu", intn->val.ul); + return (char *)s; + break; + case INTNUM_BV: + return (char *)BitVector_to_Dec(intn->val.bv); + break; } /*@notreached@*/ return NULL; @@ -1086,13 +1041,13 @@ yasm_intnum_print(const yasm_intnum *intn, FILE *f) unsigned char *s; switch (intn->type) { - case INTNUM_L: - fprintf(f, "0x%lx", intn->val.l); - break; - case INTNUM_BV: - s = BitVector_to_Hex(intn->val.bv); - fprintf(f, "0x%s", (char *)s); - yasm_xfree(s); - break; + case INTNUM_UL: + fprintf(f, "0x%lx", intn->val.ul); + break; + case INTNUM_BV: + s = BitVector_to_Hex(intn->val.bv); + fprintf(f, "0x%s", (char *)s); + yasm_xfree(s); + break; } } diff --git a/libyasm/intnum.h b/libyasm/intnum.h index bec832cf..69caf88b 100644 --- a/libyasm/intnum.h +++ b/libyasm/intnum.h @@ -2,6 +2,10 @@ * \file libyasm/intnum.h * \brief YASM integer number interface. * + * \rcs + * $Id$ + * \endrcs + * * \license * Copyright (C) 2001-2007 Peter Johnson * @@ -30,311 +34,249 @@ #ifndef YASM_INTNUM_H #define YASM_INTNUM_H -#ifndef YASM_LIB_DECL -#define YASM_LIB_DECL -#endif - /** Initialize intnum internal data structures. */ -YASM_LIB_DECL void yasm_intnum_initialize(void); /** Clean up internal intnum allocations. */ -YASM_LIB_DECL void yasm_intnum_cleanup(void); /** Create a new intnum from a decimal string. - * \param str decimal string + * \param str decimal string * \return Newly allocated intnum. */ -YASM_LIB_DECL /*@only@*/ yasm_intnum *yasm_intnum_create_dec(char *str); /** Create a new intnum from a binary string. - * \param str binary string + * \param str binary string * \return Newly allocated intnum. */ -YASM_LIB_DECL /*@only@*/ yasm_intnum *yasm_intnum_create_bin(char *str); /** Create a new intnum from an octal string. - * \param str octal string + * \param str octal string * \return Newly allocated intnum. */ -YASM_LIB_DECL /*@only@*/ yasm_intnum *yasm_intnum_create_oct(char *str); /** Create a new intnum from a hexidecimal string. - * \param str hexidecimal string + * \param str hexidecimal string * \return Newly allocated intnum. */ -YASM_LIB_DECL /*@only@*/ yasm_intnum *yasm_intnum_create_hex(char *str); /** Convert character constant to integer value, using NASM rules. NASM syntax * supports automatic conversion from strings such as 'abcd' to a 32-bit - * integer value (little endian order). This function performs those conversions. - * \param str character constant string + * integer value. This function performs those conversions. + * \param str character constant string * \return Newly allocated intnum. */ -YASM_LIB_DECL /*@only@*/ yasm_intnum *yasm_intnum_create_charconst_nasm(const char *str); -/** Convert character constant to integer value, using TASM rules. TASM syntax - * supports automatic conversion from strings such as 'abcd' to a 32-bit - * integer value (big endian order). This function performs those conversions. - * \param str character constant string - * \return Newly allocated intnum. - */ -YASM_LIB_DECL -/*@only@*/ yasm_intnum *yasm_intnum_create_charconst_tasm(const char *str); - /** Create a new intnum from an unsigned integer value. - * \param i unsigned integer value + * \param i unsigned integer value * \return Newly allocated intnum. */ -YASM_LIB_DECL /*@only@*/ yasm_intnum *yasm_intnum_create_uint(unsigned long i); /** Create a new intnum from an signed integer value. - * \param i signed integer value + * \param i signed integer value * \return Newly allocated intnum. */ -YASM_LIB_DECL /*@only@*/ yasm_intnum *yasm_intnum_create_int(long i); /** Create a new intnum from LEB128-encoded form. - * \param ptr pointer to start of LEB128 encoded form - * \param sign signed (1) or unsigned (0) LEB128 format - * \param size number of bytes read from ptr (output) + * \param ptr pointer to start of LEB128 encoded form + * \param sign signed (1) or unsigned (0) LEB128 format + * \param size number of bytes read from ptr (output) * \return Newly allocated intnum. Number of bytes read returned into * bytes_read parameter. */ -YASM_LIB_DECL /*@only@*/ yasm_intnum *yasm_intnum_create_leb128 (const unsigned char *ptr, int sign, /*@out@*/ unsigned long *size); /** Create a new intnum from a little-endian or big-endian buffer. * In little endian, the LSB is in ptr[0]. - * \param ptr pointer to start of buffer - * \param sign signed (1) or unsigned (0) source + * \param ptr pointer to start of buffer + * \param sign signed (1) or unsigned (0) source * \param srcsize source buffer size (in bytes) * \param bigendian endianness (nonzero=big, zero=little) */ -YASM_LIB_DECL /*@only@*/ yasm_intnum *yasm_intnum_create_sized (unsigned char *ptr, int sign, size_t srcsize, int bigendian); /** Duplicate an intnum. - * \param intn intnum + * \param intn intnum * \return Newly allocated intnum with the same value as intn. */ -YASM_LIB_DECL /*@only@*/ yasm_intnum *yasm_intnum_copy(const yasm_intnum *intn); /** Destroy (free allocated memory for) an intnum. - * \param intn intnum + * \param intn intnum */ -YASM_LIB_DECL void yasm_intnum_destroy(/*@only@*/ yasm_intnum *intn); /** Floating point calculation function: acc = acc op operand. * \note Not all operations in yasm_expr_op may be supported; unsupported * operations will result in an error. - * \param acc intnum accumulator - * \param op operation + * \param acc intnum accumulator + * \param op operation * \param operand intnum operand * \return Nonzero if error occurred. */ -YASM_LIB_DECL int yasm_intnum_calc(yasm_intnum *acc, yasm_expr_op op, yasm_intnum *operand); -/** Compare two intnums. - * \param intn1 first intnum - * \param intn2 second intnum - * \return -1 if intn1 < intn2, 0 if intn1 == intn2, 1 if intn1 > intn2. - */ -YASM_LIB_DECL -int yasm_intnum_compare(const yasm_intnum *intn1, const yasm_intnum *intn2); - /** Zero an intnum. - * \param intn intnum + * \param intn intnum */ -YASM_LIB_DECL void yasm_intnum_zero(yasm_intnum *intn); -/** Set an intnum to the value of another intnum. - * \param intn intnum - * \param val intnum to get value from - */ -YASM_LIB_DECL -void yasm_intnum_set(yasm_intnum *intn, const yasm_intnum *val); - /** Set an intnum to an unsigned integer. - * \param intn intnum - * \param val integer value + * \param intn intnum + * \param val integer value */ -YASM_LIB_DECL void yasm_intnum_set_uint(yasm_intnum *intn, unsigned long val); /** Set an intnum to an signed integer. - * \param intn intnum - * \param val integer value + * \param intn intnum + * \param val integer value */ -YASM_LIB_DECL void yasm_intnum_set_int(yasm_intnum *intn, long val); /** Simple value check for 0. - * \param acc intnum + * \param acc intnum * \return Nonzero if acc==0. */ -YASM_LIB_DECL int yasm_intnum_is_zero(const yasm_intnum *acc); /** Simple value check for 1. - * \param acc intnum + * \param acc intnum * \return Nonzero if acc==1. */ -YASM_LIB_DECL int yasm_intnum_is_pos1(const yasm_intnum *acc); /** Simple value check for -1. - * \param acc intnum + * \param acc intnum * \return Nonzero if acc==-1. */ -YASM_LIB_DECL int yasm_intnum_is_neg1(const yasm_intnum *acc); /** Simple sign check. - * \param acc intnum + * \param acc intnum * \return -1 if negative, 0 if zero, +1 if positive */ -YASM_LIB_DECL int yasm_intnum_sign(const yasm_intnum *acc); /** Convert an intnum to an unsigned 32-bit value. The value is in "standard" * C format (eg, of unknown endian). * \note Parameter intnum is truncated to fit into 32 bits. Use * intnum_check_size() to check for overflow. - * \param intn intnum + * \param intn intnum * \return Unsigned 32-bit value of intn. */ -YASM_LIB_DECL unsigned long yasm_intnum_get_uint(const yasm_intnum *intn); /** Convert an intnum to a signed 32-bit value. The value is in "standard" C * format (eg, of unknown endian). * \note Parameter intnum is truncated to fit into 32 bits. Use * intnum_check_size() to check for overflow. - * \param intn intnum + * \param intn intnum * \return Signed 32-bit value of intn. */ -YASM_LIB_DECL long yasm_intnum_get_int(const yasm_intnum *intn); /** Output #yasm_intnum to buffer in little-endian or big-endian. Puts the * value into the least significant bits of the destination, or may be shifted * into more significant bits by the shift parameter. The destination bits are * cleared before being set. [0] should be the first byte output to the file. - * \param intn intnum - * \param ptr pointer to storage for size bytes of output + * \param intn intnum + * \param ptr pointer to storage for size bytes of output * \param destsize destination size (in bytes) * \param valsize size (in bits) - * \param shift left shift (in bits); may be negative to specify right - * shift (standard warnings include truncation to boundary) + * \param shift left shift (in bits); may be negative to specify right + * shift (standard warnings include truncation to boundary) * \param bigendian endianness (nonzero=big, zero=little) - * \param warn enables standard warnings (value doesn't fit into valsize - * bits): <0=signed warnings, >0=unsigned warnings, 0=no warn + * \param warn enables standard warnings (value doesn't fit into valsize + * bits): <0=signed warnings, >0=unsigned warnings, 0=no warn */ -YASM_LIB_DECL void yasm_intnum_get_sized(const yasm_intnum *intn, unsigned char *ptr, - size_t destsize, size_t valsize, int shift, - int bigendian, int warn); + size_t destsize, size_t valsize, int shift, + int bigendian, int warn); /** Check to see if intnum will fit without overflow into size bits. - * \param intn intnum - * \param size number of bits of output space + * \param intn intnum + * \param size number of bits of output space * \param rshift right shift * \param rangetype signed/unsigned range selection: - * 0 => (0, unsigned max); - * 1 => (signed min, signed max); - * 2 => (signed min, unsigned max) + * 0 => (0, unsigned max); + * 1 => (signed min, signed max); + * 2 => (signed min, unsigned max) * \return Nonzero if intnum will fit. */ -YASM_LIB_DECL int yasm_intnum_check_size(const yasm_intnum *intn, size_t size, - size_t rshift, int rangetype); + size_t rshift, int rangetype); /** Check to see if intnum will fit into a particular numeric range. - * \param intn intnum - * \param low low end of range (inclusive) - * \param high high end of range (inclusive) + * \param intn intnum + * \param low low end of range (inclusive) + * \param high high end of range (inclusive) * \return Nonzero if intnum is within range. */ -YASM_LIB_DECL int yasm_intnum_in_range(const yasm_intnum *intn, long low, long high); /** Output #yasm_intnum to buffer in LEB128-encoded form. - * \param intn intnum - * \param ptr pointer to storage for output bytes - * \param sign signedness of LEB128 encoding (0=unsigned, 1=signed) + * \param intn intnum + * \param ptr pointer to storage for output bytes + * \param sign signedness of LEB128 encoding (0=unsigned, 1=signed) * \return Number of bytes generated. */ -YASM_LIB_DECL unsigned long yasm_intnum_get_leb128(const yasm_intnum *intn, - unsigned char *ptr, int sign); + unsigned char *ptr, int sign); /** Calculate number of bytes LEB128-encoded form of #yasm_intnum will take. - * \param intn intnum - * \param sign signedness of LEB128 encoding (0=unsigned, 1=signed) + * \param intn intnum + * \param sign signedness of LEB128 encoding (0=unsigned, 1=signed) * \return Number of bytes. */ -YASM_LIB_DECL unsigned long yasm_intnum_size_leb128(const yasm_intnum *intn, int sign); /** Output integer to buffer in signed LEB128-encoded form. - * \param v integer - * \param ptr pointer to storage for output bytes + * \param v integer + * \param ptr pointer to storage for output bytes * \return Number of bytes generated. */ -YASM_LIB_DECL unsigned long yasm_get_sleb128(long v, unsigned char *ptr); /** Calculate number of bytes signed LEB128-encoded form of integer will take. - * \param v integer + * \param v integer * \return Number of bytes. */ -YASM_LIB_DECL unsigned long yasm_size_sleb128(long v); /** Output integer to buffer in unsigned LEB128-encoded form. - * \param v integer - * \param ptr pointer to storage for output bytes + * \param v integer + * \param ptr pointer to storage for output bytes * \return Number of bytes generated. */ -YASM_LIB_DECL unsigned long yasm_get_uleb128(unsigned long v, unsigned char *ptr); /** Calculate number of bytes unsigned LEB128-encoded form of integer will take. - * \param v integer + * \param v integer * \return Number of bytes. */ -YASM_LIB_DECL unsigned long yasm_size_uleb128(unsigned long v); /** Get an intnum as a signed decimal string. The returned string will * contain a leading '-' if the intnum is negative. - * \param intn intnum + * \param intn intnum * \return Newly allocated string containing the decimal representation of * the intnum. */ -YASM_LIB_DECL /*@only@*/ char *yasm_intnum_get_str(const yasm_intnum *intn); /** Print an intnum. For debugging purposes. - * \param f file - * \param intn intnum + * \param f file + * \param intn intnum */ -YASM_LIB_DECL void yasm_intnum_print(const yasm_intnum *intn, FILE *f); #endif diff --git a/libyasm/inttree.c b/libyasm/inttree.c index 2ae10e9b..dbb29215 100644 --- a/libyasm/inttree.c +++ b/libyasm/inttree.c @@ -1,4 +1,6 @@ +#define YASM_LIB_INTERNAL #include "util.h" +/*@unused@*/ RCSID("$Id$"); #include #include @@ -19,8 +21,8 @@ abort();} static void Assert(int assertion, const char *error) { if (!assertion) { - fprintf(stderr, "Assertion Failed: %s\n", error); - abort(); + fprintf(stderr, "Assertion Failed: %s\n", error); + abort(); } } #endif @@ -44,7 +46,7 @@ static void DeleteFixUp(IntervalTree *, IntervalTreeNode *); #ifdef CHECK_INTERVAL_TREE_ASSUMPTIONS static void CheckMaxHighFields(const IntervalTree *, IntervalTreeNode *); static int CheckMaxHighFieldsHelper(const IntervalTree *, IntervalTreeNode *y, - const int currentHigh, int match); + const int currentHigh, int match); static void IT_CheckAssumptions(const IntervalTree *); #endif @@ -57,11 +59,11 @@ ITN_create(long low, long high, void *data) IntervalTreeNode *itn = yasm_xmalloc(sizeof(IntervalTreeNode)); itn->data = data; if (low < high) { - itn->low = low; - itn->high = high; + itn->low = low; + itn->high = high; } else { - itn->low = high; - itn->high = low; + itn->low = high; + itn->high = low; } itn->maxHigh = high; return itn; @@ -87,7 +89,7 @@ IT_create(void) /* the following are used for the Enumerate function */ it->recursionNodeStackSize = 128; it->recursionNodeStack = (it_recursion_node *) - yasm_xmalloc(it->recursionNodeStackSize*sizeof(it_recursion_node)); + yasm_xmalloc(it->recursionNodeStackSize*sizeof(it_recursion_node)); it->recursionNodeStackTop = 1; it->recursionNodeStack[0].start_node = NULL; @@ -131,7 +133,7 @@ LeftRotate(IntervalTree *it, IntervalTreeNode *x) x->right=y->left; if (y->left != it->nil) - y->left->parent=x; /* used to use sentinel here */ + y->left->parent=x; /* used to use sentinel here */ /* and do an unconditional assignment instead of testing for nil */ y->parent=x->parent; @@ -140,9 +142,9 @@ LeftRotate(IntervalTree *it, IntervalTreeNode *x) * count on the root sentinel to implicitly take care of this case */ if (x == x->parent->left) - x->parent->left=y; + x->parent->left=y; else - x->parent->right=y; + x->parent->right=y; y->left=x; x->parent=y; @@ -153,7 +155,7 @@ LeftRotate(IntervalTree *it, IntervalTreeNode *x) #elif defined(DEBUG_ASSERT) Assert(!it->nil->red,"nil not red in ITLeftRotate"); Assert((it->nil->maxHigh=LONG_MIN), - "nil->maxHigh != LONG_MIN in ITLeftRotate"); + "nil->maxHigh != LONG_MIN in ITLeftRotate"); #endif } @@ -196,7 +198,7 @@ RightRotate(IntervalTree *it, IntervalTreeNode *y) y->left=x->right; if (it->nil != x->right) - x->right->parent=y; /*used to use sentinel here */ + x->right->parent=y; /*used to use sentinel here */ /* and do an unconditional assignment instead of testing for nil */ /* Instead of checking if x->parent is the root as in the book, we @@ -204,9 +206,9 @@ RightRotate(IntervalTree *it, IntervalTreeNode *y) */ x->parent=y->parent; if (y == y->parent->left) - y->parent->left=x; + y->parent->left=x; else - y->parent->right=x; + y->parent->right=x; x->right=y; y->parent=x; @@ -217,7 +219,7 @@ RightRotate(IntervalTree *it, IntervalTreeNode *y) #elif defined(DEBUG_ASSERT) Assert(!it->nil->red,"nil not red in ITRightRotate"); Assert((it->nil->maxHigh=LONG_MIN), - "nil->maxHigh != LONG_MIN in ITRightRotate"); + "nil->maxHigh != LONG_MIN in ITRightRotate"); #endif } @@ -247,22 +249,22 @@ TreeInsertHelp(IntervalTree *it, IntervalTreeNode *z) y=it->root; x=it->root->left; while( x != it->nil) { - y=x; - if (x->low > z->low) - x=x->left; - else /* x->low <= z->low */ - x=x->right; + y=x; + if (x->low > z->low) + x=x->left; + else /* x->low <= z->low */ + x=x->right; } z->parent=y; if ((y == it->root) || (y->low > z->low)) - y->left=z; + y->left=z; else - y->right=z; + y->right=z; #if defined(DEBUG_ASSERT) Assert(!it->nil->red,"nil not red in ITTreeInsertHelp"); Assert((it->nil->maxHigh=INT_MIN), - "nil->maxHigh != INT_MIN in ITTreeInsertHelp"); + "nil->maxHigh != INT_MIN in ITTreeInsertHelp"); #endif } @@ -284,8 +286,8 @@ static void FixUpMaxHigh(IntervalTree *it, IntervalTreeNode *x) { while(x != it->root) { - x->maxHigh=ITMax(x->high,ITMax(x->left->maxHigh,x->right->maxHigh)); - x=x->parent; + x->maxHigh=ITMax(x->high,ITMax(x->left->maxHigh,x->right->maxHigh)); + x=x->parent; } #ifdef CHECK_INTERVAL_TREE_ASSUMPTIONS IT_CheckAssumptions(it); @@ -322,41 +324,41 @@ IT_insert(IntervalTree *it, long low, long high, void *data) newNode = x; x->red=1; while(x->parent->red) { /* use sentinel instead of checking for root */ - if (x->parent == x->parent->parent->left) { - y=x->parent->parent->right; - if (y->red) { - x->parent->red=0; - y->red=0; - x->parent->parent->red=1; - x=x->parent->parent; - } else { - if (x == x->parent->right) { - x=x->parent; - LeftRotate(it, x); - } - x->parent->red=0; - x->parent->parent->red=1; - RightRotate(it, x->parent->parent); - } - } else { /* case for x->parent == x->parent->parent->right */ + if (x->parent == x->parent->parent->left) { + y=x->parent->parent->right; + if (y->red) { + x->parent->red=0; + y->red=0; + x->parent->parent->red=1; + x=x->parent->parent; + } else { + if (x == x->parent->right) { + x=x->parent; + LeftRotate(it, x); + } + x->parent->red=0; + x->parent->parent->red=1; + RightRotate(it, x->parent->parent); + } + } else { /* case for x->parent == x->parent->parent->right */ /* this part is just like the section above with */ /* left and right interchanged */ - y=x->parent->parent->left; - if (y->red) { - x->parent->red=0; - y->red=0; - x->parent->parent->red=1; - x=x->parent->parent; - } else { - if (x == x->parent->left) { - x=x->parent; - RightRotate(it, x); - } - x->parent->red=0; - x->parent->parent->red=1; - LeftRotate(it, x->parent->parent); - } - } + y=x->parent->parent->left; + if (y->red) { + x->parent->red=0; + y->red=0; + x->parent->parent->red=1; + x=x->parent->parent; + } else { + if (x == x->parent->left) { + x=x->parent; + RightRotate(it, x); + } + x->parent->red=0; + x->parent->parent->red=1; + LeftRotate(it, x->parent->parent); + } + } } it->root->left->red=0; @@ -366,7 +368,7 @@ IT_insert(IntervalTree *it, long low, long high, void *data) Assert(!it->nil->red,"nil not red in ITTreeInsert"); Assert(!it->root->red,"root not red in ITTreeInsert"); Assert((it->nil->maxHigh=LONG_MIN), - "nil->maxHigh != LONG_MIN in ITTreeInsert"); + "nil->maxHigh != LONG_MIN in ITTreeInsert"); #endif return newNode; } @@ -390,18 +392,18 @@ IT_get_successor(const IntervalTree *it, IntervalTreeNode *x) IntervalTreeNode *y; if (it->nil != (y = x->right)) { /* assignment to y is intentional */ - while(y->left != it->nil) /* returns the minium of the right subtree of x */ - y=y->left; - return y; + while(y->left != it->nil) /* returns the minium of the right subtree of x */ + y=y->left; + return y; } else { - y=x->parent; - while(x == y->right) { /* sentinel used instead of checking for nil */ - x=y; - y=y->parent; - } - if (y == it->root) - return(it->nil); - return y; + y=x->parent; + while(x == y->right) { /* sentinel used instead of checking for nil */ + x=y; + y=y->parent; + } + if (y == it->root) + return(it->nil); + return y; } } @@ -424,18 +426,18 @@ IT_get_predecessor(const IntervalTree *it, IntervalTreeNode *x) IntervalTreeNode *y; if (it->nil != (y = x->left)) { /* assignment to y is intentional */ - while(y->right != it->nil) /* returns the maximum of the left subtree of x */ - y=y->right; - return y; + while(y->right != it->nil) /* returns the maximum of the left subtree of x */ + y=y->right; + return y; } else { - y=x->parent; - while(x == y->left) { - if (y == it->root) - return(it->nil); - x=y; - y=y->parent; - } - return y; + y=x->parent; + while(x == y->left) { + if (y == it->root) + return(it->nil); + x=y; + y=y->parent; + } + return y; } } @@ -456,24 +458,24 @@ IT_get_predecessor(const IntervalTree *it, IntervalTreeNode *x) static void ITN_print(const IntervalTreeNode *itn, IntervalTreeNode *nil, - IntervalTreeNode *root) + IntervalTreeNode *root) { printf(", l=%li, h=%li, mH=%li", itn->low, itn->high, itn->maxHigh); printf(" l->low="); if (itn->left == nil) - printf("NULL"); + printf("NULL"); else - printf("%li", itn->left->low); + printf("%li", itn->left->low); printf(" r->low="); if (itn->right == nil) - printf("NULL"); + printf("NULL"); else - printf("%li", itn->right->low); + printf("%li", itn->right->low); printf(" p->low="); if (itn->parent == root) - printf("NULL"); + printf("NULL"); else - printf("%li", itn->parent->low); + printf("%li", itn->parent->low); printf(" red=%i\n", itn->red); } @@ -481,9 +483,9 @@ static void TreePrintHelper(const IntervalTree *it, IntervalTreeNode *x) { if (x != it->nil) { - TreePrintHelper(it, x->left); - ITN_print(x, it->nil, it->root); - TreePrintHelper(it, x->right); + TreePrintHelper(it, x->left); + ITN_print(x, it->nil, it->root); + TreePrintHelper(it, x->right); } } @@ -491,43 +493,42 @@ void IT_destroy(IntervalTree *it) { IntervalTreeNode *x = it->root->left; - SLIST_HEAD(node_head, nodeent) - stuffToFree = SLIST_HEAD_INITIALIZER(stuffToFree); + SLIST_HEAD(, nodeent) stuffToFree = SLIST_HEAD_INITIALIZER(stuffToFree); struct nodeent { - SLIST_ENTRY(nodeent) link; - struct IntervalTreeNode *node; + SLIST_ENTRY(nodeent) link; + struct IntervalTreeNode *node; } *np; if (x != it->nil) { - if (x->left != it->nil) { - np = yasm_xmalloc(sizeof(struct nodeent)); - np->node = x->left; - SLIST_INSERT_HEAD(&stuffToFree, np, link); - } - if (x->right != it->nil) { - np = yasm_xmalloc(sizeof(struct nodeent)); - np->node = x->right; - SLIST_INSERT_HEAD(&stuffToFree, np, link); - } - yasm_xfree(x); - while (!SLIST_EMPTY(&stuffToFree)) { - np = SLIST_FIRST(&stuffToFree); - x = np->node; - SLIST_REMOVE_HEAD(&stuffToFree, link); - yasm_xfree(np); + if (x->left != it->nil) { + np = yasm_xmalloc(sizeof(struct nodeent)); + np->node = x->left; + SLIST_INSERT_HEAD(&stuffToFree, np, link); + } + if (x->right != it->nil) { + np = yasm_xmalloc(sizeof(struct nodeent)); + np->node = x->right; + SLIST_INSERT_HEAD(&stuffToFree, np, link); + } + yasm_xfree(x); + while (!SLIST_EMPTY(&stuffToFree)) { + np = SLIST_FIRST(&stuffToFree); + x = np->node; + SLIST_REMOVE_HEAD(&stuffToFree, link); + yasm_xfree(np); - if (x->left != it->nil) { - np = yasm_xmalloc(sizeof(struct nodeent)); - np->node = x->left; - SLIST_INSERT_HEAD(&stuffToFree, np, link); - } - if (x->right != it->nil) { - np = yasm_xmalloc(sizeof(struct nodeent)); - np->node = x->right; - SLIST_INSERT_HEAD(&stuffToFree, np, link); - } - yasm_xfree(x); - } + if (x->left != it->nil) { + np = yasm_xmalloc(sizeof(struct nodeent)); + np->node = x->left; + SLIST_INSERT_HEAD(&stuffToFree, np, link); + } + if (x->right != it->nil) { + np = yasm_xmalloc(sizeof(struct nodeent)); + np->node = x->right; + SLIST_INSERT_HEAD(&stuffToFree, np, link); + } + yasm_xfree(x); + } } yasm_xfree(it->nil); @@ -580,55 +581,55 @@ DeleteFixUp(IntervalTree *it, IntervalTreeNode *x) IntervalTreeNode *rootLeft = it->root->left; while ((!x->red) && (rootLeft != x)) { - if (x == x->parent->left) { - w=x->parent->right; - if (w->red) { - w->red=0; - x->parent->red=1; - LeftRotate(it, x->parent); - w=x->parent->right; - } - if ( (!w->right->red) && (!w->left->red) ) { - w->red=1; - x=x->parent; - } else { - if (!w->right->red) { - w->left->red=0; - w->red=1; - RightRotate(it, w); - w=x->parent->right; - } - w->red=x->parent->red; - x->parent->red=0; - w->right->red=0; - LeftRotate(it, x->parent); - x=rootLeft; /* this is to exit while loop */ - } - } else { /* the code below is has left and right switched from above */ - w=x->parent->left; - if (w->red) { - w->red=0; - x->parent->red=1; - RightRotate(it, x->parent); - w=x->parent->left; - } - if ((!w->right->red) && (!w->left->red)) { - w->red=1; - x=x->parent; - } else { - if (!w->left->red) { - w->right->red=0; - w->red=1; - LeftRotate(it, w); - w=x->parent->left; - } - w->red=x->parent->red; - x->parent->red=0; - w->left->red=0; - RightRotate(it, x->parent); - x=rootLeft; /* this is to exit while loop */ - } - } + if (x == x->parent->left) { + w=x->parent->right; + if (w->red) { + w->red=0; + x->parent->red=1; + LeftRotate(it, x->parent); + w=x->parent->right; + } + if ( (!w->right->red) && (!w->left->red) ) { + w->red=1; + x=x->parent; + } else { + if (!w->right->red) { + w->left->red=0; + w->red=1; + RightRotate(it, w); + w=x->parent->right; + } + w->red=x->parent->red; + x->parent->red=0; + w->right->red=0; + LeftRotate(it, x->parent); + x=rootLeft; /* this is to exit while loop */ + } + } else { /* the code below is has left and right switched from above */ + w=x->parent->left; + if (w->red) { + w->red=0; + x->parent->red=1; + RightRotate(it, x->parent); + w=x->parent->left; + } + if ((!w->right->red) && (!w->left->red)) { + w->red=1; + x=x->parent; + } else { + if (!w->left->red) { + w->right->red=0; + w->red=1; + LeftRotate(it, w); + w=x->parent->left; + } + w->red=x->parent->red; + x->parent->red=0; + w->left->red=0; + RightRotate(it, x->parent); + x=rootLeft; /* this is to exit while loop */ + } + } } x->red=0; @@ -637,7 +638,7 @@ DeleteFixUp(IntervalTree *it, IntervalTreeNode *x) #elif defined(DEBUG_ASSERT) Assert(!it->nil->red,"nil not black in ITDeleteFixUp"); Assert((it->nil->maxHigh=LONG_MIN), - "nil->maxHigh != LONG_MIN in ITDeleteFixUp"); + "nil->maxHigh != LONG_MIN in ITDeleteFixUp"); #endif } @@ -664,61 +665,61 @@ IT_delete_node(IntervalTree *it, IntervalTreeNode *z, long *low, long *high) IntervalTreeNode *x, *y; void *returnValue = z->data; if (low) - *low = z->low; + *low = z->low; if (high) - *high = z->high; + *high = z->high; y= ((z->left == it->nil) || (z->right == it->nil)) ? - z : IT_get_successor(it, z); + z : IT_get_successor(it, z); x= (y->left == it->nil) ? y->right : y->left; if (it->root == (x->parent = y->parent)) - /* assignment of y->p to x->p is intentional */ - it->root->left=x; + /* assignment of y->p to x->p is intentional */ + it->root->left=x; else { - if (y == y->parent->left) - y->parent->left=x; - else - y->parent->right=x; + if (y == y->parent->left) + y->parent->left=x; + else + y->parent->right=x; } if (y != z) { /* y should not be nil in this case */ #ifdef DEBUG_ASSERT - Assert( (y!=it->nil),"y is nil in DeleteNode \n"); + Assert( (y!=it->nil),"y is nil in DeleteNode \n"); #endif - /* y is the node to splice out and x is its child */ + /* y is the node to splice out and x is its child */ - y->maxHigh = INT_MIN; - y->left=z->left; - y->right=z->right; - y->parent=z->parent; - z->left->parent=z->right->parent=y; - if (z == z->parent->left) - z->parent->left=y; - else - z->parent->right=y; - FixUpMaxHigh(it, x->parent); - if (!(y->red)) { - y->red = z->red; - DeleteFixUp(it, x); - } else - y->red = z->red; - yasm_xfree(z); + y->maxHigh = INT_MIN; + y->left=z->left; + y->right=z->right; + y->parent=z->parent; + z->left->parent=z->right->parent=y; + if (z == z->parent->left) + z->parent->left=y; + else + z->parent->right=y; + FixUpMaxHigh(it, x->parent); + if (!(y->red)) { + y->red = z->red; + DeleteFixUp(it, x); + } else + y->red = z->red; + yasm_xfree(z); #ifdef CHECK_INTERVAL_TREE_ASSUMPTIONS - IT_CheckAssumptions(it); + IT_CheckAssumptions(it); #elif defined(DEBUG_ASSERT) - Assert(!it->nil->red,"nil not black in ITDelete"); - Assert((it->nil->maxHigh=LONG_MIN),"nil->maxHigh != LONG_MIN in ITDelete"); + Assert(!it->nil->red,"nil not black in ITDelete"); + Assert((it->nil->maxHigh=LONG_MIN),"nil->maxHigh != LONG_MIN in ITDelete"); #endif } else { - FixUpMaxHigh(it, x->parent); - if (!(y->red)) - DeleteFixUp(it, x); - yasm_xfree(y); + FixUpMaxHigh(it, x->parent); + if (!(y->red)) + DeleteFixUp(it, x); + yasm_xfree(y); #ifdef CHECK_INTERVAL_TREE_ASSUMPTIONS - IT_CheckAssumptions(it); + IT_CheckAssumptions(it); #elif defined(DEBUG_ASSERT) - Assert(!it->nil->red,"nil not black in ITDelete"); - Assert((it->nil->maxHigh=LONG_MIN),"nil->maxHigh != LONG_MIN in ITDelete"); + Assert(!it->nil->red,"nil not black in ITDelete"); + Assert((it->nil->maxHigh=LONG_MIN),"nil->maxHigh != LONG_MIN in ITDelete"); #endif } return returnValue; @@ -742,9 +743,9 @@ static int Overlap(int a1, int a2, int b1, int b2) { if (a1 <= b1) - return (b1 <= a2); + return (b1 <= a2); else - return (a1 <= b2); + return (a1 <= b2); } @@ -788,7 +789,7 @@ Overlap(int a1, int a2, int b1, int b2) */ void IT_enumerate(IntervalTree *it, long low, long high, void *cbd, - void (*callback) (IntervalTreeNode *node, void *cbd)) + void (*callback) (IntervalTreeNode *node, void *cbd)) { IntervalTreeNode *x=it->root->left; int stuffToDo = (x != it->nil); @@ -797,43 +798,43 @@ IT_enumerate(IntervalTree *it, long low, long high, void *cbd, #ifdef DEBUG_ASSERT Assert((it->recursionNodeStackTop == 1), - "recursionStack not empty when entering IntervalTree::Enumerate"); + "recursionStack not empty when entering IntervalTree::Enumerate"); #endif it->currentParent = 0; while (stuffToDo) { - if (Overlap(low,high,x->low,x->high) ) { - callback(x, cbd); - it->recursionNodeStack[it->currentParent].tryRightBranch=1; - } - if(x->left->maxHigh >= low) { /* implies x != nil */ - if (it->recursionNodeStackTop == it->recursionNodeStackSize) { - it->recursionNodeStackSize *= 2; - it->recursionNodeStack = (it_recursion_node *) - yasm_xrealloc(it->recursionNodeStack, - it->recursionNodeStackSize * sizeof(it_recursion_node)); - } - it->recursionNodeStack[it->recursionNodeStackTop].start_node = x; - it->recursionNodeStack[it->recursionNodeStackTop].tryRightBranch = 0; - it->recursionNodeStack[it->recursionNodeStackTop].parentIndex = it->currentParent; - it->currentParent = it->recursionNodeStackTop++; - x = x->left; - } else { - x = x->right; - } - stuffToDo = (x != it->nil); - while (!stuffToDo && (it->recursionNodeStackTop > 1)) { - if (it->recursionNodeStack[--it->recursionNodeStackTop].tryRightBranch) { - x=it->recursionNodeStack[it->recursionNodeStackTop].start_node->right; - it->currentParent=it->recursionNodeStack[it->recursionNodeStackTop].parentIndex; - it->recursionNodeStack[it->currentParent].tryRightBranch=1; - stuffToDo = (x != it->nil); - } - } + if (Overlap(low,high,x->low,x->high) ) { + callback(x, cbd); + it->recursionNodeStack[it->currentParent].tryRightBranch=1; + } + if(x->left->maxHigh >= low) { /* implies x != nil */ + if (it->recursionNodeStackTop == it->recursionNodeStackSize) { + it->recursionNodeStackSize *= 2; + it->recursionNodeStack = (it_recursion_node *) + yasm_xrealloc(it->recursionNodeStack, + it->recursionNodeStackSize * sizeof(it_recursion_node)); + } + it->recursionNodeStack[it->recursionNodeStackTop].start_node = x; + it->recursionNodeStack[it->recursionNodeStackTop].tryRightBranch = 0; + it->recursionNodeStack[it->recursionNodeStackTop].parentIndex = it->currentParent; + it->currentParent = it->recursionNodeStackTop++; + x = x->left; + } else { + x = x->right; + } + stuffToDo = (x != it->nil); + while (!stuffToDo && (it->recursionNodeStackTop > 1)) { + if (it->recursionNodeStack[--it->recursionNodeStackTop].tryRightBranch) { + x=it->recursionNodeStack[it->recursionNodeStackTop].start_node->right; + it->currentParent=it->recursionNodeStack[it->recursionNodeStackTop].parentIndex; + it->recursionNodeStack[it->currentParent].tryRightBranch=1; + stuffToDo = (x != it->nil); + } + } } #ifdef DEBUG_ASSERT Assert((it->recursionNodeStackTop == 1), - "recursionStack not empty when exiting IntervalTree::Enumerate"); + "recursionStack not empty when exiting IntervalTree::Enumerate"); #endif } @@ -841,21 +842,21 @@ IT_enumerate(IntervalTree *it, long low, long high, void *cbd, static int CheckMaxHighFieldsHelper(const IntervalTree *it, IntervalTreeNode *y, - int currentHigh, int match) + int currentHigh, int match) { if (y != it->nil) { - match = CheckMaxHighFieldsHelper(it, y->left, currentHigh, match) ? - 1 : match; - VERIFY(y->high <= currentHigh); - if (y->high == currentHigh) - match = 1; - match = CheckMaxHighFieldsHelper(it, y->right, currentHigh, match) ? - 1 : match; + match = CheckMaxHighFieldsHelper(it, y->left, currentHigh, match) ? + 1 : match; + VERIFY(y->high <= currentHigh); + if (y->high == currentHigh) + match = 1; + match = CheckMaxHighFieldsHelper(it, y->right, currentHigh, match) ? + 1 : match; } return match; } - + /* Make sure the maxHigh fields for everything makes sense. * * If something is wrong, print a warning and exit */ @@ -863,12 +864,12 @@ static void CheckMaxHighFields(const IntervalTree *it, IntervalTreeNode *x) { if (x != it->nil) { - CheckMaxHighFields(it, x->left); - if(!(CheckMaxHighFieldsHelper(it, x, x->maxHigh, 0) > 0)) { - fprintf(stderr, "error found in CheckMaxHighFields.\n"); - abort(); - } - CheckMaxHighFields(it, x->right); + CheckMaxHighFields(it, x->left); + if(!(CheckMaxHighFieldsHelper(it, x, x->maxHigh, 0) > 0)) { + fprintf(stderr, "error found in CheckMaxHighFields.\n"); + abort(); + } + CheckMaxHighFields(it, x->right); } } diff --git a/libyasm/inttree.h b/libyasm/inttree.h index f7a76515..2b754984 100644 --- a/libyasm/inttree.h +++ b/libyasm/inttree.h @@ -1,10 +1,7 @@ +/* $Id$ */ #ifndef YASM_INTTREE_H #define YASM_INTTREE_H -#ifndef YASM_LIB_DECL -#define YASM_LIB_DECL -#endif - /* The interval_tree.h and interval_tree.cc files contain code for * interval trees implemented using red-black-trees as described in * the book _Introduction_To_Algorithms_ by Cormen, Leisserson, @@ -48,23 +45,15 @@ typedef struct IntervalTree { unsigned int recursionNodeStackTop; } IntervalTree; -YASM_LIB_DECL IntervalTree *IT_create(void); -YASM_LIB_DECL void IT_destroy(IntervalTree *); -YASM_LIB_DECL void IT_print(const IntervalTree *); -YASM_LIB_DECL void *IT_delete_node(IntervalTree *, IntervalTreeNode *, long *low, - long *high); -YASM_LIB_DECL + long *high); IntervalTreeNode *IT_insert(IntervalTree *, long low, long high, void *data); -YASM_LIB_DECL IntervalTreeNode *IT_get_predecessor(const IntervalTree *, IntervalTreeNode *); -YASM_LIB_DECL IntervalTreeNode *IT_get_successor(const IntervalTree *, IntervalTreeNode *); -YASM_LIB_DECL void IT_enumerate(IntervalTree *, long low, long high, void *cbd, - void (*callback) (IntervalTreeNode *node, void *cbd)); + void (*callback) (IntervalTreeNode *node, void *cbd)); #endif diff --git a/libyasm/linemap.c b/libyasm/linemap.c index 42201d3c..5fb14520 100644 --- a/libyasm/linemap.c +++ b/libyasm/linemap.c @@ -24,7 +24,9 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ +#define YASM_LIB_INTERNAL #include "util.h" +/*@unused@*/ RCSID("$Id$"); #include "coretype.h" #include "hamt.h" @@ -33,6 +35,13 @@ #include "linemap.h" +/* Source lines tracking */ +typedef struct { + struct line_mapping *vector; + unsigned long size; + unsigned long allocated; +} line_mapping_head; + typedef struct line_mapping { /* monotonically increasing virtual line */ unsigned long line; @@ -62,9 +71,7 @@ struct yasm_linemap { unsigned long current; /* Mappings from virtual to physical line numbers */ - struct line_mapping *map_vector; - unsigned long map_size; - unsigned long map_allocated; + /*@only@*/ /*@null@*/ line_mapping_head *map; /* Bytecode and source line information */ /*@only@*/ line_source_info *source_info; @@ -79,83 +86,63 @@ filename_delete_one(/*@only@*/ void *d) void yasm_linemap_set(yasm_linemap *linemap, const char *filename, - unsigned long virtual_line, unsigned long file_line, - unsigned long line_inc) + unsigned long file_line, unsigned long line_inc) { char *copy; - unsigned long i; int replace = 0; - line_mapping *mapping = NULL; + line_mapping *mapping; - if (virtual_line == 0) { - virtual_line = linemap->current; - } - - /* Replace all existing mappings that have line numbers >= this one. */ - for (i = linemap->map_size; i > 0; i--) { - if (linemap->map_vector[i-1].line < virtual_line) { - if (i < linemap->map_size) { - mapping = &linemap->map_vector[i]; - linemap->map_size = i + 1; - } - break; - } - } - - if (mapping == NULL) { - /* Create a new mapping in the map */ - if (linemap->map_size >= linemap->map_allocated) { - /* allocate another size bins when full for 2x space */ - linemap->map_vector = yasm_xrealloc(linemap->map_vector, - 2*linemap->map_allocated*sizeof(line_mapping)); - linemap->map_allocated *= 2; - } - mapping = &linemap->map_vector[linemap->map_size]; - linemap->map_size++; + /* Create a new mapping in the map */ + if (linemap->map->size >= linemap->map->allocated) { + /* allocate another size bins when full for 2x space */ + linemap->map->vector = + yasm_xrealloc(linemap->map->vector, 2*linemap->map->allocated + *sizeof(line_mapping)); + linemap->map->allocated *= 2; } + mapping = &linemap->map->vector[linemap->map->size]; + linemap->map->size++; /* Fill it */ if (!filename) { - if (linemap->map_size >= 2) - mapping->filename = - linemap->map_vector[linemap->map_size-2].filename; - else - filename = "unknown"; + if (linemap->map->size >= 2) + mapping->filename = + linemap->map->vector[linemap->map->size-2].filename; + else + filename = "unknown"; } if (filename) { - /* Copy the filename (via shared storage) */ - copy = yasm__xstrdup(filename); - /*@-aliasunique@*/ - mapping->filename = HAMT_insert(linemap->filenames, copy, copy, - &replace, filename_delete_one); - /*@=aliasunique@*/ + /* Copy the filename (via shared storage) */ + copy = yasm__xstrdup(filename); + /*@-aliasunique@*/ + mapping->filename = HAMT_insert(linemap->filenames, copy, copy, + &replace, filename_delete_one); + /*@=aliasunique@*/ } - mapping->line = virtual_line; + mapping->line = linemap->current; mapping->file_line = file_line; mapping->line_inc = line_inc; } unsigned long yasm_linemap_poke(yasm_linemap *linemap, const char *filename, - unsigned long file_line) + unsigned long file_line) { unsigned long line; line_mapping *mapping; linemap->current++; - yasm_linemap_set(linemap, filename, 0, file_line, 0); + yasm_linemap_set(linemap, filename, file_line, 0); - mapping = &linemap->map_vector[linemap->map_size-1]; + mapping = &linemap->map->vector[linemap->map->size-1]; line = linemap->current; linemap->current++; - yasm_linemap_set(linemap, mapping->filename, 0, - mapping->file_line + - mapping->line_inc*(linemap->current-2-mapping->line), - mapping->line_inc); + yasm_linemap_set(linemap, mapping->filename, mapping->file_line, + mapping->line_inc); return line; } @@ -171,17 +158,18 @@ yasm_linemap_create(void) linemap->current = 1; /* initialize mapping vector */ - linemap->map_vector = yasm_xmalloc(8*sizeof(line_mapping)); - linemap->map_size = 0; - linemap->map_allocated = 8; + linemap->map = yasm_xmalloc(sizeof(line_mapping_head)); + linemap->map->vector = yasm_xmalloc(8*sizeof(line_mapping)); + linemap->map->size = 0; + linemap->map->allocated = 8; /* initialize source line information array */ linemap->source_info_size = 2; linemap->source_info = yasm_xmalloc(linemap->source_info_size * - sizeof(line_source_info)); + sizeof(line_source_info)); for (i=0; isource_info_size; i++) { - linemap->source_info[i].bc = NULL; - linemap->source_info[i].source = NULL; + linemap->source_info[i].bc = NULL; + linemap->source_info[i].source = NULL; } return linemap; @@ -192,15 +180,18 @@ yasm_linemap_destroy(yasm_linemap *linemap) { size_t i; for (i=0; isource_info_size; i++) { - if (linemap->source_info[i].source) - yasm_xfree(linemap->source_info[i].source); + if (linemap->source_info[i].source) + yasm_xfree(linemap->source_info[i].source); } yasm_xfree(linemap->source_info); - yasm_xfree(linemap->map_vector); + if (linemap->map) { + yasm_xfree(linemap->map->vector); + yasm_xfree(linemap->map); + } if (linemap->filenames) - HAMT_destroy(linemap->filenames, filename_delete_one); + HAMT_destroy(linemap->filenames, filename_delete_one); yasm_xfree(linemap); } @@ -213,24 +204,24 @@ yasm_linemap_get_current(yasm_linemap *linemap) void yasm_linemap_add_source(yasm_linemap *linemap, yasm_bytecode *bc, - const char *source) + const char *source) { size_t i; while (linemap->current > linemap->source_info_size) { - /* allocate another size bins when full for 2x space */ - linemap->source_info = yasm_xrealloc(linemap->source_info, - 2*linemap->source_info_size*sizeof(line_source_info)); - for (i=linemap->source_info_size; isource_info_size*2; i++) { - linemap->source_info[i].bc = NULL; - linemap->source_info[i].source = NULL; - } - linemap->source_info_size *= 2; + /* allocate another size bins when full for 2x space */ + linemap->source_info = yasm_xrealloc(linemap->source_info, + 2*linemap->source_info_size*sizeof(line_source_info)); + for (i=linemap->source_info_size; isource_info_size*2; i++) { + linemap->source_info[i].bc = NULL; + linemap->source_info[i].source = NULL; + } + linemap->source_info_size *= 2; } /* Delete existing info for that line (if any) */ if (linemap->source_info[linemap->current-1].source) - yasm_xfree(linemap->source_info[linemap->current-1].source); + yasm_xfree(linemap->source_info[linemap->current-1].source); linemap->source_info[linemap->current-1].bc = bc; linemap->source_info[linemap->current-1].source = yasm__xstrdup(source); @@ -244,7 +235,7 @@ yasm_linemap_goto_next(yasm_linemap *linemap) void yasm_linemap_lookup(yasm_linemap *linemap, unsigned long line, - const char **filename, unsigned long *file_line) + const char **filename, unsigned long *file_line) { line_mapping *mapping; unsigned long vindex, step; @@ -252,38 +243,39 @@ yasm_linemap_lookup(yasm_linemap *linemap, unsigned long line, assert(line <= linemap->current); /* Binary search through map to find highest line_index <= index */ + assert(linemap->map != NULL); vindex = 0; /* start step as the greatest power of 2 <= size */ step = 1; - while (step*2<=linemap->map_size) - step*=2; + while (step*2<=linemap->map->size) + step*=2; while (step>0) { - if (vindex+step < linemap->map_size - && linemap->map_vector[vindex+step].line <= line) - vindex += step; - step /= 2; + if (vindex+step < linemap->map->size + && linemap->map->vector[vindex+step].line <= line) + vindex += step; + step /= 2; } - mapping = &linemap->map_vector[vindex]; + mapping = &linemap->map->vector[vindex]; *filename = mapping->filename; - *file_line = (line ? mapping->file_line + mapping->line_inc*(line-mapping->line) : 0); + *file_line = mapping->file_line + mapping->line_inc*(line-mapping->line); } int yasm_linemap_traverse_filenames(yasm_linemap *linemap, /*@null@*/ void *d, - int (*func) (const char *filename, void *d)) + int (*func) (const char *filename, void *d)) { return HAMT_traverse(linemap->filenames, d, (int (*) (void *, void *))func); } int yasm_linemap_get_source(yasm_linemap *linemap, unsigned long line, - yasm_bytecode **bcp, const char **sourcep) + yasm_bytecode **bcp, const char **sourcep) { if (line > linemap->source_info_size) { - *bcp = NULL; - *sourcep = NULL; - return 1; + *bcp = NULL; + *sourcep = NULL; + return 1; } *bcp = linemap->source_info[line-1].bc; diff --git a/libyasm/linemap.h b/libyasm/linemap.h index 1c5aa462..310da195 100644 --- a/libyasm/linemap.h +++ b/libyasm/linemap.h @@ -2,6 +2,10 @@ * \file libyasm/linemap.h * \brief YASM virtual line mapping interface. * + * \rcs + * $Id$ + * \endrcs + * * \license * Copyright (C) 2002-2007 Peter Johnson * @@ -30,110 +34,94 @@ #ifndef YASM_LINEMAP_H #define YASM_LINEMAP_H -#ifndef YASM_LIB_DECL -#define YASM_LIB_DECL -#endif - /** Create a new line mapping repository. * \return New repository. */ -YASM_LIB_DECL yasm_linemap *yasm_linemap_create(void); /** Clean up any memory allocated for a repository. - * \param linemap line mapping repository + * \param linemap line mapping repository */ -YASM_LIB_DECL void yasm_linemap_destroy(yasm_linemap *linemap); /** Get the current line position in a repository. - * \param linemap line mapping repository + * \param linemap line mapping repository * \return Current virtual line. */ -YASM_LIB_DECL unsigned long yasm_linemap_get_current(yasm_linemap *linemap); /** Get bytecode and source line information, if any, for a virtual line. - * \param linemap line mapping repository - * \param line virtual line - * \param bcp pointer to return bytecode into - * \param sourcep pointer to return source code line pointer into + * \param linemap line mapping repository + * \param line virtual line + * \param bcp pointer to return bytecode into + * \param sourcep pointer to return source code line pointer into * \return Zero if source line information available for line, nonzero if not. * \note If source line information is not available, bcp and sourcep targets * are set to NULL. */ -YASM_LIB_DECL int yasm_linemap_get_source(yasm_linemap *linemap, unsigned long line, - /*@null@*/ yasm_bytecode **bcp, - const char **sourcep); + /*@null@*/ yasm_bytecode **bcp, + const char **sourcep); /** Add bytecode and source line information to the current virtual line. * \attention Deletes any existing bytecode and source line information for * the current virtual line. - * \param linemap line mapping repository - * \param bc bytecode (if any) - * \param source source code line + * \param linemap line mapping repository + * \param bc bytecode (if any) + * \param source source code line * \note The source code line pointer is NOT kept, it is strdup'ed. */ -YASM_LIB_DECL void yasm_linemap_add_source(yasm_linemap *linemap, - /*@null@*/ yasm_bytecode *bc, - const char *source); + /*@null@*/ yasm_bytecode *bc, + const char *source); /** Go to the next line (increments the current virtual line). - * \param linemap line mapping repository + * \param linemap line mapping repository * \return The current (new) virtual line. */ -YASM_LIB_DECL unsigned long yasm_linemap_goto_next(yasm_linemap *linemap); -/** Set a new file/line physical association starting point at the specified +/** Set a new file/line physical association starting point at the current * virtual line. line_inc indicates how much the "real" line is incremented * by for each virtual line increment (0 is perfectly legal). - * \param linemap line mapping repository - * \param filename physical file name (if NULL, not changed) - * \param virtual_line virtual line number (if 0, linemap->current is used) - * \param file_line physical line number - * \param line_inc line increment + * \param linemap line mapping repository + * \param filename physical file name (if NULL, not changed) + * \param file_line physical line number + * \param line_inc line increment */ -YASM_LIB_DECL void yasm_linemap_set(yasm_linemap *linemap, /*@null@*/ const char *filename, - unsigned long virtual_line, unsigned long file_line, - unsigned long line_inc); + unsigned long file_line, unsigned long line_inc); /** Poke a single file/line association, restoring the original physical * association starting point. Caution: increments the current virtual line * twice. - * \param linemap line mapping repository - * \param filename physical file name (if NULL, not changed) - * \param file_line physical line number + * \param linemap line mapping repository + * \param filename physical file name (if NULL, not changed) + * \param file_line physical line number * \return The virtual line number of the poked association. */ -YASM_LIB_DECL unsigned long yasm_linemap_poke(yasm_linemap *linemap, - /*@null@*/ const char *filename, - unsigned long file_line); + /*@null@*/ const char *filename, + unsigned long file_line); /** Look up the associated physical file and line for a virtual line. - * \param linemap line mapping repository - * \param line virtual line - * \param filename physical file name (output) - * \param file_line physical line number (output) + * \param linemap line mapping repository + * \param line virtual line + * \param filename physical file name (output) + * \param file_line physical line number (output) */ -YASM_LIB_DECL void yasm_linemap_lookup(yasm_linemap *linemap, unsigned long line, - /*@out@*/ const char **filename, - /*@out@*/ unsigned long *file_line); + /*@out@*/ const char **filename, + /*@out@*/ unsigned long *file_line); /** Traverses all filenames used in a linemap, calling a function on each * filename. - * \param linemap line mapping repository - * \param d data pointer passed to func on each call - * \param func function + * \param linemap line mapping repository + * \param d data pointer passed to func on each call + * \param func function * \return Stops early (and returns func's return value) if func returns a - * nonzero value; otherwise 0. + * nonzero value; otherwise 0. */ -YASM_LIB_DECL int yasm_linemap_traverse_filenames (yasm_linemap *linemap, /*@null@*/ void *d, int (*func) (const char *filename, void *d)); diff --git a/libyasm/listfmt.h b/libyasm/listfmt.h index 945f28e5..f410bbc6 100644 --- a/libyasm/listfmt.h +++ b/libyasm/listfmt.h @@ -2,6 +2,10 @@ * \file libyasm/listfmt.h * \brief YASM list format interface. * + * \rcs + * $Id$ + * \endrcs + * * \license * Copyright (C) 2004-2007 Peter Johnson * @@ -56,7 +60,7 @@ typedef struct yasm_listfmt_module { * \return NULL if unable to initialize. */ /*@null@*/ /*@only@*/ yasm_listfmt * (*create) - (const char *in_filename, const char *obj_filename); + (const char *in_filename, const char *obj_filename); /** Module-level implementation of yasm_listfmt_destroy(). * Call yasm_listfmt_destroy() instead of calling this function. @@ -67,7 +71,7 @@ typedef struct yasm_listfmt_module { * Call yasm_listfmt_output() instead of calling this function. */ void (*output) (yasm_listfmt *listfmt, FILE *f, yasm_linemap *linemap, - yasm_arch *arch); + yasm_arch *arch); } yasm_listfmt_module; /** Get the keyword used to select a list format. @@ -79,7 +83,7 @@ const char *yasm_listfmt_keyword(const yasm_listfmt *listfmt); /** Initialize list format for use. Must call before any other list * format functions. The filenames are provided solely for informational * purposes. - * \param module list format module + * \param module list format module * \param in_filename primary input filename * \param obj_filename object filename * \return NULL if object format does not provide needed support. @@ -89,19 +93,19 @@ const char *yasm_listfmt_keyword(const yasm_listfmt *listfmt); const char *obj_filename); /** Cleans up any allocated list format memory. - * \param listfmt list format + * \param listfmt list format */ void yasm_listfmt_destroy(/*@only@*/ yasm_listfmt *listfmt); /** Write out list to the list file. * This function may call all read-only yasm_* functions as necessary. - * \param listfmt list format - * \param f output list file - * \param linemap line mapping repository - * \param arch architecture + * \param listfmt list format + * \param f output list file + * \param linemap line mapping repository + * \param arch architecture */ void yasm_listfmt_output(yasm_listfmt *listfmt, FILE *f, - yasm_linemap *linemap, yasm_arch *arch); + yasm_linemap *linemap, yasm_arch *arch); #ifndef YASM_DOXYGEN diff --git a/libyasm/md5.c b/libyasm/md5.c index ba1a3077..af045fbe 100644 --- a/libyasm/md5.c +++ b/libyasm/md5.c @@ -29,6 +29,7 @@ this file is only about 3k of object code. */ #include +/*@unused@*/ RCSID("$Id$"); #include "md5.h" @@ -41,17 +42,17 @@ static unsigned long getu32(const unsigned char *addr) { - return (((((unsigned long)addr[3] << 8) | addr[2]) << 8) - | addr[1]) << 8 | addr[0]; + return (((((unsigned long)addr[3] << 8) | addr[2]) << 8) + | addr[1]) << 8 | addr[0]; } static void putu32(unsigned long data, unsigned char *addr) { - addr[0] = (unsigned char)data; - addr[1] = (unsigned char)(data >> 8); - addr[2] = (unsigned char)(data >> 16); - addr[3] = (unsigned char)(data >> 24); + addr[0] = (unsigned char)data; + addr[1] = (unsigned char)(data >> 8); + addr[2] = (unsigned char)(data >> 16); + addr[3] = (unsigned char)(data >> 24); } /* @@ -61,13 +62,13 @@ putu32(unsigned long data, unsigned char *addr) void yasm_md5_init(yasm_md5_context *ctx) { - ctx->buf[0] = 0x67452301; - ctx->buf[1] = 0xefcdab89; - ctx->buf[2] = 0x98badcfe; - ctx->buf[3] = 0x10325476; + ctx->buf[0] = 0x67452301; + ctx->buf[1] = 0xefcdab89; + ctx->buf[2] = 0x98badcfe; + ctx->buf[3] = 0x10325476; - ctx->bits[0] = 0; - ctx->bits[1] = 0; + ctx->bits[0] = 0; + ctx->bits[1] = 0; } /* @@ -76,47 +77,47 @@ yasm_md5_init(yasm_md5_context *ctx) */ void yasm_md5_update(yasm_md5_context *ctx, unsigned char const *buf, - unsigned long len) + unsigned long len) { - unsigned long t; + unsigned long t; - /* Update bitcount */ + /* Update bitcount */ - t = ctx->bits[0]; - if ((ctx->bits[0] = (t + ((unsigned long)len << 3)) & 0xffffffff) < t) - ctx->bits[1]++; /* Carry from low to high */ - ctx->bits[1] += len >> 29; + t = ctx->bits[0]; + if ((ctx->bits[0] = (t + ((unsigned long)len << 3)) & 0xffffffff) < t) + ctx->bits[1]++; /* Carry from low to high */ + ctx->bits[1] += len >> 29; - t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */ + t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */ - /* Handle any leading odd-sized chunks */ + /* Handle any leading odd-sized chunks */ - if ( t ) { - unsigned char *p = ctx->in + t; + if ( t ) { + unsigned char *p = ctx->in + t; - t = 64-t; - if (len < t) { - memcpy(p, buf, len); - return; - } - memcpy(p, buf, t); - yasm_md5_transform (ctx->buf, ctx->in); - buf += t; - len -= t; - } + t = 64-t; + if (len < t) { + memcpy(p, buf, len); + return; + } + memcpy(p, buf, t); + yasm_md5_transform (ctx->buf, ctx->in); + buf += t; + len -= t; + } - /* Process data in 64-byte chunks */ + /* Process data in 64-byte chunks */ - while (len >= 64) { - memcpy(ctx->in, buf, 64); - yasm_md5_transform (ctx->buf, ctx->in); - buf += 64; - len -= 64; - } + while (len >= 64) { + memcpy(ctx->in, buf, 64); + yasm_md5_transform (ctx->buf, ctx->in); + buf += 64; + len -= 64; + } - /* Handle any remaining bytes of data. */ + /* Handle any remaining bytes of data. */ - memcpy(ctx->in, buf, len); + memcpy(ctx->in, buf, len); } /* @@ -126,43 +127,43 @@ yasm_md5_update(yasm_md5_context *ctx, unsigned char const *buf, void yasm_md5_final(unsigned char digest[16], yasm_md5_context *ctx) { - unsigned count; - unsigned char *p; + unsigned count; + unsigned char *p; - /* Compute number of bytes mod 64 */ - count = (ctx->bits[0] >> 3) & 0x3F; + /* Compute number of bytes mod 64 */ + count = (ctx->bits[0] >> 3) & 0x3F; - /* Set the first char of padding to 0x80. This is safe since there is - always at least one byte free */ - p = ctx->in + count; - *p++ = 0x80; + /* Set the first char of padding to 0x80. This is safe since there is + always at least one byte free */ + p = ctx->in + count; + *p++ = 0x80; - /* Bytes of padding needed to make 64 bytes */ - count = 64 - 1 - count; + /* Bytes of padding needed to make 64 bytes */ + count = 64 - 1 - count; - /* Pad out to 56 mod 64 */ - if (count < 8) { - /* Two lots of padding: Pad the first block to 64 bytes */ - memset(p, 0, count); - yasm_md5_transform (ctx->buf, ctx->in); + /* Pad out to 56 mod 64 */ + if (count < 8) { + /* Two lots of padding: Pad the first block to 64 bytes */ + memset(p, 0, count); + yasm_md5_transform (ctx->buf, ctx->in); - /* Now fill the next block with 56 bytes */ - memset(ctx->in, 0, 56); - } else { - /* Pad block to 56 bytes */ - memset(p, 0, count-8); - } + /* Now fill the next block with 56 bytes */ + memset(ctx->in, 0, 56); + } else { + /* Pad block to 56 bytes */ + memset(p, 0, count-8); + } - /* Append length in bits and transform */ - putu32(ctx->bits[0], ctx->in + 56); - putu32(ctx->bits[1], ctx->in + 60); + /* Append length in bits and transform */ + putu32(ctx->bits[0], ctx->in + 56); + putu32(ctx->bits[1], ctx->in + 60); - yasm_md5_transform (ctx->buf, ctx->in); - putu32(ctx->buf[0], digest); - putu32(ctx->buf[1], digest + 4); - putu32(ctx->buf[2], digest + 8); - putu32(ctx->buf[3], digest + 12); - memset(ctx, 0, sizeof(*ctx)); /* In case it's sensitive */ + yasm_md5_transform (ctx->buf, ctx->in); + putu32(ctx->buf[0], digest); + putu32(ctx->buf[1], digest + 4); + putu32(ctx->buf[2], digest + 8); + putu32(ctx->buf[3], digest + 12); + memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */ } #ifndef ASM_MD5 @@ -177,7 +178,7 @@ yasm_md5_final(unsigned char digest[16], yasm_md5_context *ctx) /* This is the central step in the MD5 algorithm. */ #define MD5STEP(f, w, x, y, z, data, s) \ - ( w += f(x, y, z) + data, w &= 0xffffffff, w = w<>(32-s), w += x ) + ( w += f(x, y, z) + data, w &= 0xffffffff, w = w<>(32-s), w += x ) /* * The core of the MD5 algorithm, this alters an existing MD5 hash to @@ -187,90 +188,90 @@ yasm_md5_final(unsigned char digest[16], yasm_md5_context *ctx) void yasm_md5_transform(unsigned long buf[4], const unsigned char inraw[64]) { - register unsigned long a, b, c, d; - unsigned long in[16]; - int i; + register unsigned long a, b, c, d; + unsigned long in[16]; + int i; - for (i = 0; i < 16; ++i) - in[i] = getu32 (inraw + 4 * i); + for (i = 0; i < 16; ++i) + in[i] = getu32 (inraw + 4 * i); - a = buf[0]; - b = buf[1]; - c = buf[2]; - d = buf[3]; + a = buf[0]; + b = buf[1]; + c = buf[2]; + d = buf[3]; - MD5STEP(F1, a, b, c, d, in[ 0]+0xd76aa478, 7); - MD5STEP(F1, d, a, b, c, in[ 1]+0xe8c7b756, 12); - MD5STEP(F1, c, d, a, b, in[ 2]+0x242070db, 17); - MD5STEP(F1, b, c, d, a, in[ 3]+0xc1bdceee, 22); - MD5STEP(F1, a, b, c, d, in[ 4]+0xf57c0faf, 7); - MD5STEP(F1, d, a, b, c, in[ 5]+0x4787c62a, 12); - MD5STEP(F1, c, d, a, b, in[ 6]+0xa8304613, 17); - MD5STEP(F1, b, c, d, a, in[ 7]+0xfd469501, 22); - MD5STEP(F1, a, b, c, d, in[ 8]+0x698098d8, 7); - MD5STEP(F1, d, a, b, c, in[ 9]+0x8b44f7af, 12); - MD5STEP(F1, c, d, a, b, in[10]+0xffff5bb1, 17); - MD5STEP(F1, b, c, d, a, in[11]+0x895cd7be, 22); - MD5STEP(F1, a, b, c, d, in[12]+0x6b901122, 7); - MD5STEP(F1, d, a, b, c, in[13]+0xfd987193, 12); - MD5STEP(F1, c, d, a, b, in[14]+0xa679438e, 17); - MD5STEP(F1, b, c, d, a, in[15]+0x49b40821, 22); + MD5STEP(F1, a, b, c, d, in[ 0]+0xd76aa478, 7); + MD5STEP(F1, d, a, b, c, in[ 1]+0xe8c7b756, 12); + MD5STEP(F1, c, d, a, b, in[ 2]+0x242070db, 17); + MD5STEP(F1, b, c, d, a, in[ 3]+0xc1bdceee, 22); + MD5STEP(F1, a, b, c, d, in[ 4]+0xf57c0faf, 7); + MD5STEP(F1, d, a, b, c, in[ 5]+0x4787c62a, 12); + MD5STEP(F1, c, d, a, b, in[ 6]+0xa8304613, 17); + MD5STEP(F1, b, c, d, a, in[ 7]+0xfd469501, 22); + MD5STEP(F1, a, b, c, d, in[ 8]+0x698098d8, 7); + MD5STEP(F1, d, a, b, c, in[ 9]+0x8b44f7af, 12); + MD5STEP(F1, c, d, a, b, in[10]+0xffff5bb1, 17); + MD5STEP(F1, b, c, d, a, in[11]+0x895cd7be, 22); + MD5STEP(F1, a, b, c, d, in[12]+0x6b901122, 7); + MD5STEP(F1, d, a, b, c, in[13]+0xfd987193, 12); + MD5STEP(F1, c, d, a, b, in[14]+0xa679438e, 17); + MD5STEP(F1, b, c, d, a, in[15]+0x49b40821, 22); - MD5STEP(F2, a, b, c, d, in[ 1]+0xf61e2562, 5); - MD5STEP(F2, d, a, b, c, in[ 6]+0xc040b340, 9); - MD5STEP(F2, c, d, a, b, in[11]+0x265e5a51, 14); - MD5STEP(F2, b, c, d, a, in[ 0]+0xe9b6c7aa, 20); - MD5STEP(F2, a, b, c, d, in[ 5]+0xd62f105d, 5); - MD5STEP(F2, d, a, b, c, in[10]+0x02441453, 9); - MD5STEP(F2, c, d, a, b, in[15]+0xd8a1e681, 14); - MD5STEP(F2, b, c, d, a, in[ 4]+0xe7d3fbc8, 20); - MD5STEP(F2, a, b, c, d, in[ 9]+0x21e1cde6, 5); - MD5STEP(F2, d, a, b, c, in[14]+0xc33707d6, 9); - MD5STEP(F2, c, d, a, b, in[ 3]+0xf4d50d87, 14); - MD5STEP(F2, b, c, d, a, in[ 8]+0x455a14ed, 20); - MD5STEP(F2, a, b, c, d, in[13]+0xa9e3e905, 5); - MD5STEP(F2, d, a, b, c, in[ 2]+0xfcefa3f8, 9); - MD5STEP(F2, c, d, a, b, in[ 7]+0x676f02d9, 14); - MD5STEP(F2, b, c, d, a, in[12]+0x8d2a4c8a, 20); + MD5STEP(F2, a, b, c, d, in[ 1]+0xf61e2562, 5); + MD5STEP(F2, d, a, b, c, in[ 6]+0xc040b340, 9); + MD5STEP(F2, c, d, a, b, in[11]+0x265e5a51, 14); + MD5STEP(F2, b, c, d, a, in[ 0]+0xe9b6c7aa, 20); + MD5STEP(F2, a, b, c, d, in[ 5]+0xd62f105d, 5); + MD5STEP(F2, d, a, b, c, in[10]+0x02441453, 9); + MD5STEP(F2, c, d, a, b, in[15]+0xd8a1e681, 14); + MD5STEP(F2, b, c, d, a, in[ 4]+0xe7d3fbc8, 20); + MD5STEP(F2, a, b, c, d, in[ 9]+0x21e1cde6, 5); + MD5STEP(F2, d, a, b, c, in[14]+0xc33707d6, 9); + MD5STEP(F2, c, d, a, b, in[ 3]+0xf4d50d87, 14); + MD5STEP(F2, b, c, d, a, in[ 8]+0x455a14ed, 20); + MD5STEP(F2, a, b, c, d, in[13]+0xa9e3e905, 5); + MD5STEP(F2, d, a, b, c, in[ 2]+0xfcefa3f8, 9); + MD5STEP(F2, c, d, a, b, in[ 7]+0x676f02d9, 14); + MD5STEP(F2, b, c, d, a, in[12]+0x8d2a4c8a, 20); - MD5STEP(F3, a, b, c, d, in[ 5]+0xfffa3942, 4); - MD5STEP(F3, d, a, b, c, in[ 8]+0x8771f681, 11); - MD5STEP(F3, c, d, a, b, in[11]+0x6d9d6122, 16); - MD5STEP(F3, b, c, d, a, in[14]+0xfde5380c, 23); - MD5STEP(F3, a, b, c, d, in[ 1]+0xa4beea44, 4); - MD5STEP(F3, d, a, b, c, in[ 4]+0x4bdecfa9, 11); - MD5STEP(F3, c, d, a, b, in[ 7]+0xf6bb4b60, 16); - MD5STEP(F3, b, c, d, a, in[10]+0xbebfbc70, 23); - MD5STEP(F3, a, b, c, d, in[13]+0x289b7ec6, 4); - MD5STEP(F3, d, a, b, c, in[ 0]+0xeaa127fa, 11); - MD5STEP(F3, c, d, a, b, in[ 3]+0xd4ef3085, 16); - MD5STEP(F3, b, c, d, a, in[ 6]+0x04881d05, 23); - MD5STEP(F3, a, b, c, d, in[ 9]+0xd9d4d039, 4); - MD5STEP(F3, d, a, b, c, in[12]+0xe6db99e5, 11); - MD5STEP(F3, c, d, a, b, in[15]+0x1fa27cf8, 16); - MD5STEP(F3, b, c, d, a, in[ 2]+0xc4ac5665, 23); + MD5STEP(F3, a, b, c, d, in[ 5]+0xfffa3942, 4); + MD5STEP(F3, d, a, b, c, in[ 8]+0x8771f681, 11); + MD5STEP(F3, c, d, a, b, in[11]+0x6d9d6122, 16); + MD5STEP(F3, b, c, d, a, in[14]+0xfde5380c, 23); + MD5STEP(F3, a, b, c, d, in[ 1]+0xa4beea44, 4); + MD5STEP(F3, d, a, b, c, in[ 4]+0x4bdecfa9, 11); + MD5STEP(F3, c, d, a, b, in[ 7]+0xf6bb4b60, 16); + MD5STEP(F3, b, c, d, a, in[10]+0xbebfbc70, 23); + MD5STEP(F3, a, b, c, d, in[13]+0x289b7ec6, 4); + MD5STEP(F3, d, a, b, c, in[ 0]+0xeaa127fa, 11); + MD5STEP(F3, c, d, a, b, in[ 3]+0xd4ef3085, 16); + MD5STEP(F3, b, c, d, a, in[ 6]+0x04881d05, 23); + MD5STEP(F3, a, b, c, d, in[ 9]+0xd9d4d039, 4); + MD5STEP(F3, d, a, b, c, in[12]+0xe6db99e5, 11); + MD5STEP(F3, c, d, a, b, in[15]+0x1fa27cf8, 16); + MD5STEP(F3, b, c, d, a, in[ 2]+0xc4ac5665, 23); - MD5STEP(F4, a, b, c, d, in[ 0]+0xf4292244, 6); - MD5STEP(F4, d, a, b, c, in[ 7]+0x432aff97, 10); - MD5STEP(F4, c, d, a, b, in[14]+0xab9423a7, 15); - MD5STEP(F4, b, c, d, a, in[ 5]+0xfc93a039, 21); - MD5STEP(F4, a, b, c, d, in[12]+0x655b59c3, 6); - MD5STEP(F4, d, a, b, c, in[ 3]+0x8f0ccc92, 10); - MD5STEP(F4, c, d, a, b, in[10]+0xffeff47d, 15); - MD5STEP(F4, b, c, d, a, in[ 1]+0x85845dd1, 21); - MD5STEP(F4, a, b, c, d, in[ 8]+0x6fa87e4f, 6); - MD5STEP(F4, d, a, b, c, in[15]+0xfe2ce6e0, 10); - MD5STEP(F4, c, d, a, b, in[ 6]+0xa3014314, 15); - MD5STEP(F4, b, c, d, a, in[13]+0x4e0811a1, 21); - MD5STEP(F4, a, b, c, d, in[ 4]+0xf7537e82, 6); - MD5STEP(F4, d, a, b, c, in[11]+0xbd3af235, 10); - MD5STEP(F4, c, d, a, b, in[ 2]+0x2ad7d2bb, 15); - MD5STEP(F4, b, c, d, a, in[ 9]+0xeb86d391, 21); + MD5STEP(F4, a, b, c, d, in[ 0]+0xf4292244, 6); + MD5STEP(F4, d, a, b, c, in[ 7]+0x432aff97, 10); + MD5STEP(F4, c, d, a, b, in[14]+0xab9423a7, 15); + MD5STEP(F4, b, c, d, a, in[ 5]+0xfc93a039, 21); + MD5STEP(F4, a, b, c, d, in[12]+0x655b59c3, 6); + MD5STEP(F4, d, a, b, c, in[ 3]+0x8f0ccc92, 10); + MD5STEP(F4, c, d, a, b, in[10]+0xffeff47d, 15); + MD5STEP(F4, b, c, d, a, in[ 1]+0x85845dd1, 21); + MD5STEP(F4, a, b, c, d, in[ 8]+0x6fa87e4f, 6); + MD5STEP(F4, d, a, b, c, in[15]+0xfe2ce6e0, 10); + MD5STEP(F4, c, d, a, b, in[ 6]+0xa3014314, 15); + MD5STEP(F4, b, c, d, a, in[13]+0x4e0811a1, 21); + MD5STEP(F4, a, b, c, d, in[ 4]+0xf7537e82, 6); + MD5STEP(F4, d, a, b, c, in[11]+0xbd3af235, 10); + MD5STEP(F4, c, d, a, b, in[ 2]+0x2ad7d2bb, 15); + MD5STEP(F4, b, c, d, a, in[ 9]+0xeb86d391, 21); - buf[0] += a; - buf[1] += b; - buf[2] += c; - buf[3] += d; + buf[0] += a; + buf[1] += b; + buf[2] += c; + buf[3] += d; } #endif @@ -282,28 +283,28 @@ yasm_md5_transform(unsigned long buf[4], const unsigned char inraw[64]) int main (int argc, char **argv) { - yasm_md5_context context; - unsigned char checksum[16]; - int i; - int j; + yasm_md5_context context; + unsigned char checksum[16]; + int i; + int j; - if (argc < 2) - { - fprintf (stderr, "usage: %s string-to-hash\n", argv[0]); - exit (1); - } - for (j = 1; j < argc; ++j) - { - printf ("MD5 (\"%s\") = ", argv[j]); - yasm_md5_init (&context); - yasm_md5_update (&context, argv[j], strlen (argv[j])); - yasm_md5_final (checksum, &context); - for (i = 0; i < 16; i++) - { - printf ("%02x", (unsigned int) checksum[i]); - } - printf ("\n"); - } - return 0; + if (argc < 2) + { + fprintf (stderr, "usage: %s string-to-hash\n", argv[0]); + exit (1); + } + for (j = 1; j < argc; ++j) + { + printf ("MD5 (\"%s\") = ", argv[j]); + yasm_md5_init (&context); + yasm_md5_update (&context, argv[j], strlen (argv[j])); + yasm_md5_final (checksum, &context); + for (i = 0; i < 16; i++) + { + printf ("%02x", (unsigned int) checksum[i]); + } + printf ("\n"); + } + return 0; } #endif /* TEST */ diff --git a/libyasm/md5.h b/libyasm/md5.h index 7872fda7..91be1c55 100644 --- a/libyasm/md5.h +++ b/libyasm/md5.h @@ -1,12 +1,12 @@ /* See md5.c for explanation and copyright information. */ +/* + * $Id$ + */ + #ifndef YASM_MD5_H #define YASM_MD5_H -#ifndef YASM_LIB_DECL -#define YASM_LIB_DECL -#endif - /* Unlike previous versions of this code, uint32 need not be exactly 32 bits, merely 32 bits or more. Choosing a data type which is 32 bits instead of 64 is not important; speed is considerably more @@ -14,19 +14,15 @@ and always using it seems to have few disadvantages. */ typedef struct yasm_md5_context { - unsigned long buf[4]; - unsigned long bits[2]; - unsigned char in[64]; + unsigned long buf[4]; + unsigned long bits[2]; + unsigned char in[64]; } yasm_md5_context; -YASM_LIB_DECL void yasm_md5_init(yasm_md5_context *context); -YASM_LIB_DECL void yasm_md5_update(yasm_md5_context *context, unsigned char const *buf, - unsigned long len); -YASM_LIB_DECL + unsigned long len); void yasm_md5_final(unsigned char digest[16], yasm_md5_context *context); -YASM_LIB_DECL void yasm_md5_transform(unsigned long buf[4], const unsigned char in[64]); #endif /* !YASM_MD5_H */ diff --git a/libyasm/mergesort.c b/libyasm/mergesort.c index 3eeaa827..87e451d0 100644 --- a/libyasm/mergesort.c +++ b/libyasm/mergesort.c @@ -2,7 +2,7 @@ * mergesort() implementation for systems that don't have it. * * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. + * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Peter McIlroy. @@ -31,10 +31,12 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ +#define YASM_LIB_INTERNAL #include "util.h" +/*@unused@*/ RCSID("$Id$"); #if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)merge.c 8.2 (Berkeley) 2/14/94"; +static char sccsid[] = "@(#)merge.c 8.2 (Berkeley) 2/14/94"; #endif /* LIBC_SCCS and not lint */ #ifdef HAVE_MERGESORT @@ -50,39 +52,41 @@ static char sccsid[] = "@(#)merge.c 8.2 (Berkeley) 2/14/94"; */ #define NATURAL -#define THRESHOLD 16 /* Best choice for natural merge cut-off. */ +#define THRESHOLD 16 /* Best choice for natural merge cut-off. */ /* #define NATURAL to get hybrid natural merge. * (The default is pairwise merging.) */ -#include -#include +#ifdef STDC_HEADERS +# include +# include +#endif static void setup(unsigned char *, unsigned char *, size_t, size_t, - int (*)(const void *, const void *)); + int (*)(const void *, const void *)); static void insertionsort(unsigned char *, size_t, size_t, - int (*)(const void *, const void *)); + int (*)(const void *, const void *)); #define ISIZE sizeof(int) #define PSIZE sizeof(unsigned char *) -#define ICOPY_LIST(src, dst, last) \ - do \ - *(int*)dst = *(int*)src, src += ISIZE, dst += ISIZE; \ - while(src < last) -#define ICOPY_ELT(src, dst, i) \ - do \ - *(int*) dst = *(int*) src, src += ISIZE, dst += ISIZE; \ - while (i -= ISIZE) +#define ICOPY_LIST(src, dst, last) \ + do \ + *(int*)dst = *(int*)src, src += ISIZE, dst += ISIZE; \ + while(src < last) +#define ICOPY_ELT(src, dst, i) \ + do \ + *(int*) dst = *(int*) src, src += ISIZE, dst += ISIZE; \ + while (i -= ISIZE) -#define CCOPY_LIST(src, dst, last) \ - do \ - *dst++ = *src++; \ - while (src < last) -#define CCOPY_ELT(src, dst, i) \ - do \ - *dst++ = *src++; \ - while (i -= 1) +#define CCOPY_LIST(src, dst, last) \ + do \ + *dst++ = *src++; \ + while (src < last) +#define CCOPY_ELT(src, dst, i) \ + do \ + *dst++ = *src++; \ + while (i -= 1) /* * Find the next possible pointer head. (Trickery for forcing an array @@ -90,176 +94,176 @@ static void insertionsort(unsigned char *, size_t, size_t, * boundaries. */ /* Assumption: PSIZE is a power of 2. */ -#define EVAL(p) (unsigned char **) \ - ((unsigned char *)0 + \ - (((unsigned char *)p + PSIZE - 1 - (unsigned char *) 0) & ~(PSIZE - 1))) -#endif /*HAVE_MERGESORT*/ +#define EVAL(p) (unsigned char **) \ + ((unsigned char *)0 + \ + (((unsigned char *)p + PSIZE - 1 - (unsigned char *) 0) & ~(PSIZE - 1))) +#endif /*HAVE_MERGESORT*/ /* * Arguments are as for qsort. */ int yasm__mergesort(void *base, size_t nmemb, size_t size, - int (*cmp)(const void *, const void *)) + int (*cmp)(const void *, const void *)) { #ifdef HAVE_MERGESORT return mergesort(base, nmemb, size, cmp); #else - size_t i; - int sense; - int big, iflag; - unsigned char *f1, *f2, *t, *b, *tp2, *q, *l1, *l2; - unsigned char *list2, *list1, *p2, *p, *last, **p1; + size_t i; + int sense; + int big, iflag; + unsigned char *f1, *f2, *t, *b, *tp2, *q, *l1, *l2; + unsigned char *list2, *list1, *p2, *p, *last, **p1; - if (size < PSIZE / 2) { /* Pointers must fit into 2 * size. */ + if (size < PSIZE / 2) { /* Pointers must fit into 2 * size. */ #ifdef EINVAL - errno = EINVAL; + errno = EINVAL; #endif - return (-1); - } + return (-1); + } - if (nmemb == 0) - return (0); + if (nmemb == 0) + return (0); - /* - * XXX - * Stupid subtraction for the Cray. - */ - iflag = 0; - if (!(size % ISIZE) && !(((char *)base - (char *)0) % ISIZE)) - iflag = 1; + /* + * XXX + * Stupid subtraction for the Cray. + */ + iflag = 0; + if (!(size % ISIZE) && !(((char *)base - (char *)0) % ISIZE)) + iflag = 1; - if ((list2 = yasm_xmalloc(nmemb * size + PSIZE)) == NULL) - return (-1); + if ((list2 = yasm_xmalloc(nmemb * size + PSIZE)) == NULL) + return (-1); - list1 = base; - setup(list1, list2, nmemb, size, cmp); - last = list2 + nmemb * size; - i = 0; - big = 0; - while (*EVAL(list2) != last) { - l2 = list1; - p1 = EVAL(list1); - for (tp2 = p2 = list2; p2 != last; p1 = EVAL(l2)) { - p2 = *EVAL(p2); - f1 = l2; - f2 = l1 = list1 + (p2 - list2); - if (p2 != last) - p2 = *EVAL(p2); - l2 = list1 + (p2 - list2); - while (f1 < l1 && f2 < l2) { - if ((*cmp)(f1, f2) <= 0) { - q = f2; - b = f1, t = l1; - sense = -1; - } else { - q = f1; - b = f2, t = l2; - sense = 0; - } - if (!big) { /* here i = 0 */ - while ((b += size) < t && cmp(q, b) >sense) - if (++i == 6) { - big = 1; - goto EXPONENTIAL; - } - } else { -EXPONENTIAL: for (i = size; ; i <<= 1) - if ((p = (b + i)) >= t) { - if ((p = t - size) > b && - (*cmp)(q, p) <= sense) - t = p; - else - b = p; - break; - } else if ((*cmp)(q, p) <= sense) { - t = p; - if (i == size) - big = 0; - goto FASTCASE; - } else - b = p; - while (t > b+size) { - i = (((t - b) / size) >> 1) * size; - if ((*cmp)(q, p = b + i) <= sense) - t = p; - else - b = p; - } - goto COPY; -FASTCASE: while (i > size) - if ((*cmp)(q, - p = b + (i >>= 1)) <= sense) - t = p; - else - b = p; -COPY: b = t; - } - i = size; - if (q == f1) { - if (iflag) { - ICOPY_LIST(f2, tp2, b); - ICOPY_ELT(f1, tp2, i); - } else { - CCOPY_LIST(f2, tp2, b); - CCOPY_ELT(f1, tp2, i); - } - } else { - if (iflag) { - ICOPY_LIST(f1, tp2, b); - ICOPY_ELT(f2, tp2, i); - } else { - CCOPY_LIST(f1, tp2, b); - CCOPY_ELT(f2, tp2, i); - } - } - } - if (f2 < l2) { - if (iflag) - ICOPY_LIST(f2, tp2, l2); - else - CCOPY_LIST(f2, tp2, l2); - } else if (f1 < l1) { - if (iflag) - ICOPY_LIST(f1, tp2, l1); - else - CCOPY_LIST(f1, tp2, l1); - } - *p1 = l2; - } - tp2 = list1; /* swap list1, list2 */ - list1 = list2; - list2 = tp2; - last = list2 + nmemb*size; - } - if (base == list2) { - memmove(list2, list1, nmemb*size); - list2 = list1; - } - yasm_xfree(list2); - return (0); -#endif /*HAVE_MERGESORT*/ + list1 = base; + setup(list1, list2, nmemb, size, cmp); + last = list2 + nmemb * size; + i = 0; + big = 0; + while (*EVAL(list2) != last) { + l2 = list1; + p1 = EVAL(list1); + for (tp2 = p2 = list2; p2 != last; p1 = EVAL(l2)) { + p2 = *EVAL(p2); + f1 = l2; + f2 = l1 = list1 + (p2 - list2); + if (p2 != last) + p2 = *EVAL(p2); + l2 = list1 + (p2 - list2); + while (f1 < l1 && f2 < l2) { + if ((*cmp)(f1, f2) <= 0) { + q = f2; + b = f1, t = l1; + sense = -1; + } else { + q = f1; + b = f2, t = l2; + sense = 0; + } + if (!big) { /* here i = 0 */ + while ((b += size) < t && cmp(q, b) >sense) + if (++i == 6) { + big = 1; + goto EXPONENTIAL; + } + } else { +EXPONENTIAL: for (i = size; ; i <<= 1) + if ((p = (b + i)) >= t) { + if ((p = t - size) > b && + (*cmp)(q, p) <= sense) + t = p; + else + b = p; + break; + } else if ((*cmp)(q, p) <= sense) { + t = p; + if (i == size) + big = 0; + goto FASTCASE; + } else + b = p; + while (t > b+size) { + i = (((t - b) / size) >> 1) * size; + if ((*cmp)(q, p = b + i) <= sense) + t = p; + else + b = p; + } + goto COPY; +FASTCASE: while (i > size) + if ((*cmp)(q, + p = b + (i >>= 1)) <= sense) + t = p; + else + b = p; +COPY: b = t; + } + i = size; + if (q == f1) { + if (iflag) { + ICOPY_LIST(f2, tp2, b); + ICOPY_ELT(f1, tp2, i); + } else { + CCOPY_LIST(f2, tp2, b); + CCOPY_ELT(f1, tp2, i); + } + } else { + if (iflag) { + ICOPY_LIST(f1, tp2, b); + ICOPY_ELT(f2, tp2, i); + } else { + CCOPY_LIST(f1, tp2, b); + CCOPY_ELT(f2, tp2, i); + } + } + } + if (f2 < l2) { + if (iflag) + ICOPY_LIST(f2, tp2, l2); + else + CCOPY_LIST(f2, tp2, l2); + } else if (f1 < l1) { + if (iflag) + ICOPY_LIST(f1, tp2, l1); + else + CCOPY_LIST(f1, tp2, l1); + } + *p1 = l2; + } + tp2 = list1; /* swap list1, list2 */ + list1 = list2; + list2 = tp2; + last = list2 + nmemb*size; + } + if (base == list2) { + memmove(list2, list1, nmemb*size); + list2 = list1; + } + yasm_xfree(list2); + return (0); +#endif /*HAVE_MERGESORT*/ } #ifndef HAVE_MERGESORT -#define swap(a, b) { \ - s = b; \ - i = size; \ - do { \ - tmp = *a; *a++ = *s; *s++ = tmp; \ - } while (--i); \ - a -= size; \ - } -#define reverse(bot, top) { \ - s = top; \ - do { \ - i = size; \ - do { \ - tmp = *bot; *bot++ = *s; *s++ = tmp; \ - } while (--i); \ - s -= size2; \ - } while(bot < s); \ +#define swap(a, b) { \ + s = b; \ + i = size; \ + do { \ + tmp = *a; *a++ = *s; *s++ = tmp; \ + } while (--i); \ + a -= size; \ + } +#define reverse(bot, top) { \ + s = top; \ + do { \ + i = size; \ + do { \ + tmp = *bot; *bot++ = *s; *s++ = tmp; \ + } while (--i); \ + s -= size2; \ + } while(bot < s); \ } /* @@ -272,70 +276,70 @@ void setup(unsigned char *list1, unsigned char *list2, size_t n, size_t size, int (*cmp)(const void *, const void *)) { - size_t i; - unsigned int tmp; - int length, sense; - size_t size2; - unsigned char *f1, *f2, *s, *l2, *last, *p2; + size_t i; + unsigned int tmp; + int length, sense; + size_t size2; + unsigned char *f1, *f2, *s, *l2, *last, *p2; - size2 = size*2; - if (n <= 5) { - insertionsort(list1, n, size, cmp); - *EVAL(list2) = (unsigned char*) list2 + n*size; - return; - } - /* - * Avoid running pointers out of bounds; limit n to evens - * for simplicity. - */ - i = 4 + (n & 1); - insertionsort(list1 + (n - i) * size, i, size, cmp); - last = list1 + size * (n - i); - *EVAL(list2 + (last - list1)) = list2 + n * size; + size2 = size*2; + if (n <= 5) { + insertionsort(list1, n, size, cmp); + *EVAL(list2) = (unsigned char*) list2 + n*size; + return; + } + /* + * Avoid running pointers out of bounds; limit n to evens + * for simplicity. + */ + i = 4 + (n & 1); + insertionsort(list1 + (n - i) * size, i, size, cmp); + last = list1 + size * (n - i); + *EVAL(list2 + (last - list1)) = list2 + n * size; #ifdef NATURAL - p2 = list2; - f1 = list1; - sense = (cmp(f1, f1 + size) > 0); - for (; f1 < last; sense = !sense) { - length = 2; - /* Find pairs with same sense. */ - for (f2 = f1 + size2; f2 < last; f2 += size2) { - if ((cmp(f2, f2+ size) > 0) != sense) - break; - length += 2; - } - if (length < THRESHOLD) { /* Pairwise merge */ - do { - p2 = *EVAL(p2) = f1 + size2 - list1 + list2; - if (sense > 0) - swap (f1, f1 + size); - } while ((f1 += size2) < f2); - } else { /* Natural merge */ - l2 = f2; - for (f2 = f1 + size2; f2 < l2; f2 += size2) { - if ((cmp(f2-size, f2) > 0) != sense) { - p2 = *EVAL(p2) = f2 - list1 + list2; - if (sense > 0) - reverse(f1, f2-size); - f1 = f2; - } - } - if (sense > 0) - reverse (f1, f2-size); - f1 = f2; - if (f2 < last || cmp(f2 - size, f2) > 0) - p2 = *EVAL(p2) = f2 - list1 + list2; - else - p2 = *EVAL(p2) = list2 + n*size; - } - } -#else /* pairwise merge only. */ - for (f1 = list1, p2 = list2; f1 < last; f1 += size2) { - p2 = *EVAL(p2) = p2 + size2; - if (cmp (f1, f1 + size) > 0) - swap(f1, f1 + size); - } + p2 = list2; + f1 = list1; + sense = (cmp(f1, f1 + size) > 0); + for (; f1 < last; sense = !sense) { + length = 2; + /* Find pairs with same sense. */ + for (f2 = f1 + size2; f2 < last; f2 += size2) { + if ((cmp(f2, f2+ size) > 0) != sense) + break; + length += 2; + } + if (length < THRESHOLD) { /* Pairwise merge */ + do { + p2 = *EVAL(p2) = f1 + size2 - list1 + list2; + if (sense > 0) + swap (f1, f1 + size); + } while ((f1 += size2) < f2); + } else { /* Natural merge */ + l2 = f2; + for (f2 = f1 + size2; f2 < l2; f2 += size2) { + if ((cmp(f2-size, f2) > 0) != sense) { + p2 = *EVAL(p2) = f2 - list1 + list2; + if (sense > 0) + reverse(f1, f2-size); + f1 = f2; + } + } + if (sense > 0) + reverse (f1, f2-size); + f1 = f2; + if (f2 < last || cmp(f2 - size, f2) > 0) + p2 = *EVAL(p2) = f2 - list1 + list2; + else + p2 = *EVAL(p2) = list2 + n*size; + } + } +#else /* pairwise merge only. */ + for (f1 = list1, p2 = list2; f1 < last; f1 += size2) { + p2 = *EVAL(p2) = p2 + size2; + if (cmp (f1, f1 + size) > 0) + swap(f1, f1 + size); + } #endif /* NATURAL */ } @@ -345,17 +349,17 @@ setup(unsigned char *list1, unsigned char *list2, size_t n, size_t size, */ static void insertionsort(unsigned char *a, size_t n, size_t size, - int (*cmp)(const void *, const void *)) + int (*cmp)(const void *, const void *)) { - unsigned char *ai, *s, *t, *u, tmp; - size_t i; + unsigned char *ai, *s, *t, *u, tmp; + size_t i; - for (ai = a+size; --n >= 1; ai += size) - for (t = ai; t > a; t -= size) { - u = t - size; - if (cmp(u, t) <= 0) - break; - swap(u, t); - } + for (ai = a+size; --n >= 1; ai += size) + for (t = ai; t > a; t -= size) { + u = t - size; + if (cmp(u, t) <= 0) + break; + swap(u, t); + } } -#endif /*HAVE_MERGESORT*/ +#endif /*HAVE_MERGESORT*/ diff --git a/libyasm/module.h b/libyasm/module.h index 220017de..11e6c527 100644 --- a/libyasm/module.h +++ b/libyasm/module.h @@ -1,4 +1,4 @@ -/* +/* $Id$ * YASM module loader header file * * Copyright (C) 2002-2007 Peter Johnson @@ -27,10 +27,6 @@ #ifndef YASM_MODULE_H #define YASM_MODULE_H -#ifndef YASM_LIB_DECL -#define YASM_LIB_DECL -#endif - typedef enum yasm_module_type { YASM_MODULE_ARCH = 0, YASM_MODULE_DBGFMT, @@ -40,43 +36,37 @@ typedef enum yasm_module_type { YASM_MODULE_PREPROC } yasm_module_type; -YASM_LIB_DECL /*@dependent@*/ /*@null@*/ void *yasm_load_module (yasm_module_type type, const char *keyword); -#define yasm_load_arch(keyword) \ +#define yasm_load_arch(keyword) \ yasm_load_module(YASM_MODULE_ARCH, keyword) -#define yasm_load_dbgfmt(keyword) \ +#define yasm_load_dbgfmt(keyword) \ yasm_load_module(YASM_MODULE_DBGFMT, keyword) -#define yasm_load_objfmt(keyword) \ +#define yasm_load_objfmt(keyword) \ yasm_load_module(YASM_MODULE_OBJFMT, keyword) -#define yasm_load_listfmt(keyword) \ +#define yasm_load_listfmt(keyword) \ yasm_load_module(YASM_MODULE_LISTFMT, keyword) -#define yasm_load_parser(keyword) \ +#define yasm_load_parser(keyword) \ yasm_load_module(YASM_MODULE_PARSER, keyword) -#define yasm_load_preproc(keyword) \ +#define yasm_load_preproc(keyword) \ yasm_load_module(YASM_MODULE_PREPROC, keyword) -YASM_LIB_DECL void yasm_list_modules (yasm_module_type type, void (*printfunc) (const char *name, const char *keyword)); -#define yasm_list_arch(func) \ +#define yasm_list_arch(func) \ yasm_list_modules(YASM_MODULE_ARCH, func) -#define yasm_list_dbgfmt(func) \ +#define yasm_list_dbgfmt(func) \ yasm_list_modules(YASM_MODULE_DBGFMT, func) -#define yasm_list_objfmt(func) \ +#define yasm_list_objfmt(func) \ yasm_list_modules(YASM_MODULE_OBJFMT, func) -#define yasm_list_listfmt(func) \ +#define yasm_list_listfmt(func) \ yasm_list_modules(YASM_MODULE_LISTFMT, func) -#define yasm_list_parser(func) \ +#define yasm_list_parser(func) \ yasm_list_modules(YASM_MODULE_PARSER, func) -#define yasm_list_preproc(func) \ +#define yasm_list_preproc(func) \ yasm_list_modules(YASM_MODULE_PREPROC, func) -YASM_LIB_DECL -void yasm_register_module(yasm_module_type type, const char *keyword, - void *data); - #endif diff --git a/libyasm/module.in b/libyasm/module.in index a18778b6..f3b69420 100644 --- a/libyasm/module.in +++ b/libyasm/module.in @@ -25,13 +25,14 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include +/*@unused@*/ RCSID("$Id$"); #include typedef struct module { - const char *keyword; /* module keyword */ - void *data; /* associated data */ + const char *keyword; /* module keyword */ + void *data; /* associated data */ } module; EXTERN_LIST @@ -72,57 +73,29 @@ static struct { {preproc_modules, sizeof(preproc_modules)/sizeof(module)}, }; -typedef struct loaded_module { - yasm_module_type type; /* module type */ - const char *keyword; /* module keyword */ - void *data; /* associated data */ -} loaded_module; - -static loaded_module *loaded_modules = NULL; -static size_t num_loaded_modules = 0; - void * yasm_load_module(yasm_module_type type, const char *keyword) { size_t i; - module *modules; - size_t n; + module *modules = module_types[type].m; + size_t n = module_types[type].n; - /* Look for the module/symbol, first in loaded modules */ - if (loaded_modules) { - for (i=0; iname, arch->keyword); - break; - case YASM_MODULE_DBGFMT: - dbgfmt = data; - printfunc(dbgfmt->name, dbgfmt->keyword); - break; - case YASM_MODULE_OBJFMT: - objfmt = data; - printfunc(objfmt->name, objfmt->keyword); - break; - case YASM_MODULE_LISTFMT: - listfmt = data; - printfunc(listfmt->name, listfmt->keyword); - break; - case YASM_MODULE_PARSER: - parser = data; - printfunc(parser->name, parser->keyword); - break; - case YASM_MODULE_PREPROC: - preproc = data; - printfunc(preproc->name, preproc->keyword); - break; - } -} - -void -yasm_list_modules(yasm_module_type type, - void (*printfunc) (const char *name, const char *keyword)) -{ - size_t i; - module *modules; - size_t n;; - /* Go through available list, and try to load each one */ - if (loaded_modules) { - for (i=0; iname, arch->keyword); + break; + case YASM_MODULE_DBGFMT: + dbgfmt = modules[i].data; + printfunc(dbgfmt->name, dbgfmt->keyword); + break; + case YASM_MODULE_OBJFMT: + objfmt = modules[i].data; + printfunc(objfmt->name, objfmt->keyword); + break; + case YASM_MODULE_LISTFMT: + listfmt = modules[i].data; + printfunc(listfmt->name, listfmt->keyword); + break; + case YASM_MODULE_PARSER: + parser = modules[i].data; + printfunc(parser->name, parser->keyword); + break; + case YASM_MODULE_PREPROC: + preproc = modules[i].data; + printfunc(preproc->name, preproc->keyword); + break; + } } - - modules = module_types[type].m; - n = module_types[type].n; - for (i=0; iobjfmt))->module->output \ - (object, f, all_syms, ews) + (object, f, all_syms, ews) #define yasm_objfmt_destroy(objfmt) \ ((yasm_objfmt_base *)objfmt)->module->destroy(objfmt) #define yasm_objfmt_section_switch(object, vpms, oe_vpms, line) \ ((yasm_objfmt_base *)((object)->objfmt))->module->section_switch \ - (object, vpms, oe_vpms, line) + (object, vpms, oe_vpms, line) #define yasm_objfmt_add_default_section(object) \ ((yasm_objfmt_base *)((object)->objfmt))->module->add_default_section \ - (object) -#define yasm_objfmt_init_new_section(section, line) \ - ((yasm_objfmt_base *)((object)->objfmt))->module->init_new_section \ - (section, line) -#define yasm_objfmt_get_special_sym(object, name, parser) \ - ((yasm_objfmt_base *)((object)->objfmt))->module->get_special_sym \ - (object, name, parser) + (object) #endif diff --git a/libyasm/parser.h b/libyasm/parser.h index 93d4d332..14c2d409 100644 --- a/libyasm/parser.h +++ b/libyasm/parser.h @@ -2,6 +2,10 @@ * \file libyasm/parser.h * \brief YASM parser module interface. * + * \rcs + * $Id$ + * \endrcs + * * \license * Copyright (C) 2001-2007 Peter Johnson * @@ -47,21 +51,19 @@ typedef struct yasm_parser_module { /** Default preprocessor. */ const char *default_preproc_keyword; - /** NULL-terminated list of standard macro lookups. NULL if none. */ - const yasm_stdmac *stdmacs; - /** Parse a source file into an object. - * \param object object to parse into (already created) - * \param pp preprocessor - * \param save_input nonzero if the parser should save the original - * lines of source into the object's linemap (via - * yasm_linemap_add_data()). - * \param errwarns error/warning set + * \param object object to parse into (already created) + * \param pp preprocessor + * \param f initial starting file + * \param save_input nonzero if the parser should save the original + * lines of source into the object's linemap (via + * yasm_linemap_add_data()). + * \param errwarns error/warning set * \note Parse errors and warnings are stored into errwarns. */ void (*do_parse) - (yasm_object *object, yasm_preproc *pp, int save_input, - yasm_linemap *linemap, yasm_errwarns *errwarns); + (yasm_object *object, yasm_preproc *pp, FILE *f, int save_input, + yasm_linemap *linemap, yasm_errwarns *errwarns); } yasm_parser_module; #endif diff --git a/libyasm/phash.c b/libyasm/phash.c index cef8c781..01941c28 100644 --- a/libyasm/phash.c +++ b/libyasm/phash.c @@ -1,5 +1,7 @@ /* Modified for use with yasm by Peter Johnson. */ +#define YASM_LIB_INTERNAL #include "util.h" +/*@unused@*/ RCSID("$Id$"); /* -------------------------------------------------------------------- @@ -109,36 +111,36 @@ phash_lookup( /*---------------------------------------- handle most of the key */ while (len >= 12) { - a += (k[0] +((ub4)k[1]<<8) +((ub4)k[2]<<16) +((ub4)k[3]<<24)); - a &= 0xffffffff; - b += (k[4] +((ub4)k[5]<<8) +((ub4)k[6]<<16) +((ub4)k[7]<<24)); - b &= 0xffffffff; - c += (k[8] +((ub4)k[9]<<8) +((ub4)k[10]<<16)+((ub4)k[11]<<24)); - c &= 0xffffffff; - mix(a,b,c); - k += 12; len -= 12; + a += (k[0] +((ub4)k[1]<<8) +((ub4)k[2]<<16) +((ub4)k[3]<<24)); + a &= 0xffffffff; + b += (k[4] +((ub4)k[5]<<8) +((ub4)k[6]<<16) +((ub4)k[7]<<24)); + b &= 0xffffffff; + c += (k[8] +((ub4)k[9]<<8) +((ub4)k[10]<<16)+((ub4)k[11]<<24)); + c &= 0xffffffff; + mix(a,b,c); + k += 12; len -= 12; } /*------------------------------------- handle the last 11 bytes */ c += (ub4)length; switch(len) /* all the case statements fall through */ { - case 11: c+=((ub4)k[10]<<24); - case 10: c+=((ub4)k[9]<<16); - case 9 : c+=((ub4)k[8]<<8); - c &= 0xffffffff; - /* the first byte of c is reserved for the length */ - case 8 : b+=((ub4)k[7]<<24); - case 7 : b+=((ub4)k[6]<<16); - case 6 : b+=((ub4)k[5]<<8); - case 5 : b+=k[4]; - b &= 0xffffffff; - case 4 : a+=((ub4)k[3]<<24); - case 3 : a+=((ub4)k[2]<<16); - case 2 : a+=((ub4)k[1]<<8); - case 1 : a+=k[0]; - a &= 0xffffffff; - /* case 0: nothing left to add */ + case 11: c+=((ub4)k[10]<<24); + case 10: c+=((ub4)k[9]<<16); + case 9 : c+=((ub4)k[8]<<8); + c &= 0xffffffff; + /* the first byte of c is reserved for the length */ + case 8 : b+=((ub4)k[7]<<24); + case 7 : b+=((ub4)k[6]<<16); + case 6 : b+=((ub4)k[5]<<8); + case 5 : b+=k[4]; + b &= 0xffffffff; + case 4 : a+=((ub4)k[3]<<24); + case 3 : a+=((ub4)k[2]<<16); + case 2 : a+=((ub4)k[1]<<8); + case 1 : a+=k[0]; + a &= 0xffffffff; + /* case 0: nothing left to add */ } mix(a,b,c); /*-------------------------------------------- report the result */ @@ -206,56 +208,56 @@ phash_checksum( /*---------------------------------------- handle most of the key */ while (len >= 32) { - a += (k[0] +(k[1]<<8) +(k[2]<<16) +(k[3]<<24)); - b += (k[4] +(k[5]<<8) +(k[6]<<16) +(k[7]<<24)); - c += (k[8] +(k[9]<<8) +(k[10]<<16)+(k[11]<<24)); - d += (k[12]+(k[13]<<8)+(k[14]<<16)+(k[15]<<24)); - e += (k[16]+(k[17]<<8)+(k[18]<<16)+(k[19]<<24)); - f += (k[20]+(k[21]<<8)+(k[22]<<16)+(k[23]<<24)); - g += (k[24]+(k[25]<<8)+(k[26]<<16)+(k[27]<<24)); - h += (k[28]+(k[29]<<8)+(k[30]<<16)+(k[31]<<24)); - mixc(a,b,c,d,e,f,g,h); - mixc(a,b,c,d,e,f,g,h); - mixc(a,b,c,d,e,f,g,h); - mixc(a,b,c,d,e,f,g,h); - k += 32; len -= 32; + a += (k[0] +(k[1]<<8) +(k[2]<<16) +(k[3]<<24)); + b += (k[4] +(k[5]<<8) +(k[6]<<16) +(k[7]<<24)); + c += (k[8] +(k[9]<<8) +(k[10]<<16)+(k[11]<<24)); + d += (k[12]+(k[13]<<8)+(k[14]<<16)+(k[15]<<24)); + e += (k[16]+(k[17]<<8)+(k[18]<<16)+(k[19]<<24)); + f += (k[20]+(k[21]<<8)+(k[22]<<16)+(k[23]<<24)); + g += (k[24]+(k[25]<<8)+(k[26]<<16)+(k[27]<<24)); + h += (k[28]+(k[29]<<8)+(k[30]<<16)+(k[31]<<24)); + mixc(a,b,c,d,e,f,g,h); + mixc(a,b,c,d,e,f,g,h); + mixc(a,b,c,d,e,f,g,h); + mixc(a,b,c,d,e,f,g,h); + k += 32; len -= 32; } /*------------------------------------- handle the last 31 bytes */ h += (ub4)length; switch(len) { - case 31: h+=(k[30]<<24); - case 30: h+=(k[29]<<16); - case 29: h+=(k[28]<<8); - case 28: g+=(k[27]<<24); - case 27: g+=(k[26]<<16); - case 26: g+=(k[25]<<8); - case 25: g+=k[24]; - case 24: f+=(k[23]<<24); - case 23: f+=(k[22]<<16); - case 22: f+=(k[21]<<8); - case 21: f+=k[20]; - case 20: e+=(k[19]<<24); - case 19: e+=(k[18]<<16); - case 18: e+=(k[17]<<8); - case 17: e+=k[16]; - case 16: d+=(k[15]<<24); - case 15: d+=(k[14]<<16); - case 14: d+=(k[13]<<8); - case 13: d+=k[12]; - case 12: c+=(k[11]<<24); - case 11: c+=(k[10]<<16); - case 10: c+=(k[9]<<8); - case 9 : c+=k[8]; - case 8 : b+=(k[7]<<24); - case 7 : b+=(k[6]<<16); - case 6 : b+=(k[5]<<8); - case 5 : b+=k[4]; - case 4 : a+=(k[3]<<24); - case 3 : a+=(k[2]<<16); - case 2 : a+=(k[1]<<8); - case 1 : a+=k[0]; + case 31: h+=(k[30]<<24); + case 30: h+=(k[29]<<16); + case 29: h+=(k[28]<<8); + case 28: g+=(k[27]<<24); + case 27: g+=(k[26]<<16); + case 26: g+=(k[25]<<8); + case 25: g+=k[24]; + case 24: f+=(k[23]<<24); + case 23: f+=(k[22]<<16); + case 22: f+=(k[21]<<8); + case 21: f+=k[20]; + case 20: e+=(k[19]<<24); + case 19: e+=(k[18]<<16); + case 18: e+=(k[17]<<8); + case 17: e+=k[16]; + case 16: d+=(k[15]<<24); + case 15: d+=(k[14]<<16); + case 14: d+=(k[13]<<8); + case 13: d+=k[12]; + case 12: c+=(k[11]<<24); + case 11: c+=(k[10]<<16); + case 10: c+=(k[9]<<8); + case 9 : c+=k[8]; + case 8 : b+=(k[7]<<24); + case 7 : b+=(k[6]<<16); + case 6 : b+=(k[5]<<8); + case 5 : b+=k[4]; + case 4 : a+=(k[3]<<24); + case 3 : a+=(k[2]<<16); + case 2 : a+=(k[1]<<8); + case 1 : a+=k[0]; } mixc(a,b,c,d,e,f,g,h); mixc(a,b,c,d,e,f,g,h); diff --git a/libyasm/phash.h b/libyasm/phash.h index 2273a5df..bf4cb47c 100644 --- a/libyasm/phash.h +++ b/libyasm/phash.h @@ -1,4 +1,6 @@ -/* Modified for use with yasm by Peter Johnson. */ +/* Modified for use with yasm by Peter Johnson. + * $Id$ + */ /* ------------------------------------------------------------------------------ By Bob Jenkins, September 1996. @@ -8,12 +10,6 @@ Source is http://burtleburtle.net/bob/c/lookupa.h ------------------------------------------------------------------------------ */ -#ifndef YASM_LIB_DECL -#define YASM_LIB_DECL -#endif - -YASM_LIB_DECL unsigned long phash_lookup(const char *k, size_t length, - unsigned long level); -YASM_LIB_DECL + unsigned long level); void phash_checksum(const char *k, size_t length, unsigned long *state); diff --git a/libyasm/preproc.h b/libyasm/preproc.h index 751b19e4..7d16b735 100644 --- a/libyasm/preproc.h +++ b/libyasm/preproc.h @@ -2,6 +2,10 @@ * \file libyasm/preproc.h * \brief YASM preprocessor module interface. * + * \rcs + * $Id$ + * \endrcs + * * \license * Copyright (C) 2001-2007 Peter Johnson * @@ -52,29 +56,28 @@ typedef struct yasm_preproc_module { * Module-level implementation of yasm_preproc_create(). * Call yasm_preproc_create() instead of calling this function. * - * \param in_filename initial starting filename, or "-" to read from - * stdin - * \param symtab symbol table (may be NULL if none) - * \param lm line mapping repository - * \param errwarns error/warnning set. + * \param f initial starting file + * \param in_filename initial starting filename + * \param lm line mapping repository + * \param errwarns error/warnning set. * \return New preprocessor. * * \note Any preprocessor errors and warnings are stored into errwarns. */ - /*@only@*/ yasm_preproc * (*create) (const char *in_filename, - yasm_symtab *symtab, - yasm_linemap *lm, - yasm_errwarns *errwarns); + /*@only@*/ yasm_preproc * (*create) (FILE *f, const char *in_filename, + yasm_linemap *lm, + yasm_errwarns *errwarns); /** Module-level implementation of yasm_preproc_destroy(). * Call yasm_preproc_destroy() instead of calling this function. */ void (*destroy) (/*@only@*/ yasm_preproc *preproc); - /** Module-level implementation of yasm_preproc_get_line(). - * Call yasm_preproc_get_line() instead of calling this function. + /** Module-level implementation of yasm_preproc_input(). + * Call yasm_preproc_input() instead of calling this function. */ - char * (*get_line) (yasm_preproc *preproc); + size_t (*input) (yasm_preproc *preproc, /*@out@*/ char *buf, + size_t max_size); /** Module-level implementation of yasm_preproc_get_included_file(). * Call yasm_preproc_get_included_file() instead of calling this function. @@ -101,109 +104,97 @@ typedef struct yasm_preproc_module { * Call yasm_preproc_builtin_define() instead of calling this function. */ void (*define_builtin) (yasm_preproc *preproc, const char *macronameval); - - /** Module-level implementation of yasm_preproc_add_standard(). - * Call yasm_preproc_add_standard() instead of calling this function. - */ - void (*add_standard) (yasm_preproc *preproc, const char **macros); } yasm_preproc_module; /** Initialize preprocessor. * The preprocessor needs access to the object format module to find out * any output format specific macros. - * \param module preprocessor module - * \param in_filename initial starting filename, or "-" to read from stdin - * \param symtab symbol table (may be NULL if none) - * \param lm line mapping repository - * \param errwarns error/warning set + * \param module preprocessor module + * \param f initial starting file + * \param in_filename initial starting file filename + * \param lm line mapping repository + * \param errwarns error/warning set * \return New preprocessor. * \note Errors/warnings are stored into errwarns. */ /*@only@*/ yasm_preproc *yasm_preproc_create - (yasm_preproc_module *module, const char *in_filename, - yasm_symtab *symtab, yasm_linemap *lm, yasm_errwarns *errwarns); + (yasm_preproc_module *module, FILE *f, const char *in_filename, + yasm_linemap *lm, yasm_errwarns *errwarns); /** Cleans up any allocated preproc memory. - * \param preproc preprocessor + * \param preproc preprocessor */ void yasm_preproc_destroy(/*@only@*/ yasm_preproc *preproc); -/** Gets a single line of preprocessed source code. - * \param preproc preprocessor - * \return Allocated line of code, without the trailing \n. +/** Gets more preprocessed source code (up to max_size bytes) into buf. + * More than a single line may be returned in buf. + * \param preproc preprocessor + * \param buf destination buffer for preprocessed source + * \param max_size maximum number of bytes that can be returned in buf + * \return Actual number of bytes returned in buf. */ -char *yasm_preproc_get_line(yasm_preproc *preproc); +size_t yasm_preproc_input(yasm_preproc *preproc, /*@out@*/ char *buf, + size_t max_size); /** Get the next filename included by the source code. - * \param preproc preprocessor - * \param buf destination buffer for filename - * \param max_size maximum number of bytes that can be returned in buf + * \param preproc preprocessor + * \param buf destination buffer for filename + * \param max_size maximum number of bytes that can be returned in buf * \return Actual number of bytes returned in buf. */ size_t yasm_preproc_get_included_file(yasm_preproc *preproc, - /*@out@*/ char *buf, size_t max_size); + /*@out@*/ char *buf, size_t max_size); /** Pre-include a file. - * \param preproc preprocessor - * \param filename filename + * \param preproc preprocessor + * \param filename filename */ void yasm_preproc_add_include_file(yasm_preproc *preproc, - const char *filename); + const char *filename); /** Pre-define a macro. - * \param preproc preprocessor - * \param macronameval "name=value" string + * \param preproc preprocessor + * \param macronameval "name=value" string */ void yasm_preproc_predefine_macro(yasm_preproc *preproc, - const char *macronameval); + const char *macronameval); /** Un-define a macro. - * \param preproc preprocessor - * \param macroname macro name + * \param preproc preprocessor + * \param macroname macro name */ void yasm_preproc_undefine_macro(yasm_preproc *preproc, const char *macroname); /** Define a builtin macro, preprocessed before the "standard" macros. - * \param preproc preprocessor - * \param macronameval "name=value" string + * \param preproc preprocessor + * \param macronameval "name=value" string */ void yasm_preproc_define_builtin(yasm_preproc *preproc, - const char *macronameval); - -/** Define additional standard macros, preprocessed after the builtins but - * prior to any user-defined macros. - * \param preproc preprocessor - * \param macros NULL-terminated array of macro strings - */ -void yasm_preproc_add_standard(yasm_preproc *preproc, - const char **macros); + const char *macronameval); #ifndef YASM_DOXYGEN /* Inline macro implementations for preproc functions */ -#define yasm_preproc_create(module, in_filename, symtab, lm, ews) \ - module->create(in_filename, symtab, lm, ews) +#define yasm_preproc_create(module, f, in_filename, lm, ews) \ + module->create(f, in_filename, lm, ews) #define yasm_preproc_destroy(preproc) \ ((yasm_preproc_base *)preproc)->module->destroy(preproc) -#define yasm_preproc_get_line(preproc) \ - ((yasm_preproc_base *)preproc)->module->get_line(preproc) +#define yasm_preproc_input(preproc, buf, max_size) \ + ((yasm_preproc_base *)preproc)->module->input(preproc, buf, max_size) #define yasm_preproc_get_included_file(preproc, buf, max_size) \ ((yasm_preproc_base *)preproc)->module->get_included_file(preproc, buf, max_size) #define yasm_preproc_add_include_file(preproc, filename) \ ((yasm_preproc_base *)preproc)->module->add_include_file(preproc, filename) #define yasm_preproc_predefine_macro(preproc, macronameval) \ ((yasm_preproc_base *)preproc)->module->predefine_macro(preproc, \ - macronameval) + macronameval) #define yasm_preproc_undefine_macro(preproc, macroname) \ ((yasm_preproc_base *)preproc)->module->undefine_macro(preproc, macroname) #define yasm_preproc_define_builtin(preproc, macronameval) \ ((yasm_preproc_base *)preproc)->module->define_builtin(preproc, \ - macronameval) -#define yasm_preproc_add_standard(preproc, macros) \ - ((yasm_preproc_base *)preproc)->module->add_standard(preproc, \ - macros) + macronameval) #endif diff --git a/libyasm/section.c b/libyasm/section.c index dd067e07..d1299729 100644 --- a/libyasm/section.c +++ b/libyasm/section.c @@ -24,7 +24,9 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ +#define YASM_LIB_INTERNAL #include "util.h" +/*@unused@*/ RCSID("$Id$"); #include @@ -48,6 +50,9 @@ #include "dbgfmt.h" #include "objfmt.h" +#include "expr-int.h" +#include "bc-int.h" + #include "inttree.h" @@ -61,14 +66,16 @@ struct yasm_section { /* associated data; NULL if none */ /*@null@*/ /*@only@*/ yasm__assoc_data *assoc_data; - unsigned long align; /* Section alignment */ + /*@owned@*/ yasm_expr *start; /* Starting address of section contents */ - unsigned long opt_flags; /* storage for optimizer flags */ + unsigned long align; /* Section alignment */ - int code; /* section contains code (instructions) */ - int res_only; /* allow only resb family of bytecodes? */ - int def; /* "default" section, e.g. not specified by - using section directive */ + unsigned long opt_flags; /* storage for optimizer flags */ + + int code; /* section contains code (instructions) */ + int res_only; /* allow only resb family of bytecodes? */ + int def; /* "default" section, e.g. not specified by + using section directive */ /* the bytecodes for the section's contents */ /*@reldef@*/ STAILQ_HEAD(yasm_bytecodehead, yasm_bytecode) bcs; @@ -92,56 +99,39 @@ typedef struct yasm_directive_wrap { static void dir_extern(yasm_object *object, yasm_valparamhead *valparams, - yasm_valparamhead *objext_valparams, unsigned long line) + yasm_valparamhead *objext_valparams, unsigned long line) { yasm_valparam *vp = yasm_vps_first(valparams); yasm_symrec *sym; sym = yasm_symtab_declare(object->symtab, yasm_vp_id(vp), YASM_SYM_EXTERN, line); if (objext_valparams) { - yasm_valparamhead *vps = yasm_vps_create(); - *vps = *objext_valparams; /* structure copy */ - yasm_vps_initialize(objext_valparams); /* don't double-free */ - yasm_symrec_set_objext_valparams(sym, vps); + yasm_valparamhead *vps = yasm_vps_create(); + *vps = *objext_valparams; /* structure copy */ + yasm_vps_initialize(objext_valparams); /* don't double-free */ + yasm_symrec_set_objext_valparams(sym, vps); } } static void dir_global(yasm_object *object, yasm_valparamhead *valparams, - yasm_valparamhead *objext_valparams, unsigned long line) + yasm_valparamhead *objext_valparams, unsigned long line) { yasm_valparam *vp = yasm_vps_first(valparams); yasm_symrec *sym; sym = yasm_symtab_declare(object->symtab, yasm_vp_id(vp), YASM_SYM_GLOBAL, line); if (objext_valparams) { - yasm_valparamhead *vps = yasm_vps_create(); - *vps = *objext_valparams; /* structure copy */ - yasm_vps_initialize(objext_valparams); /* don't double-free */ - yasm_symrec_set_objext_valparams(sym, vps); + yasm_valparamhead *vps = yasm_vps_create(); + *vps = *objext_valparams; /* structure copy */ + yasm_vps_initialize(objext_valparams); /* don't double-free */ + yasm_symrec_set_objext_valparams(sym, vps); } } -static void -dir_privextern(yasm_object *object, yasm_valparamhead *valparams, - yasm_valparamhead *objext_valparams, unsigned long line) -{ - yasm_valparamhead vps; - - yasm_vps_initialize(&vps); - if (!objext_valparams) { - yasm_valparam *vp; - - vp = yasm_vp_create_id(NULL, yasm__xstrdup("private_extern"), '$'); - yasm_vps_append(&vps, vp); - objext_valparams = &vps; - } - dir_global(object, valparams, objext_valparams, line); -} - static void dir_common(yasm_object *object, yasm_valparamhead *valparams, - yasm_valparamhead *objext_valparams, unsigned long line) + yasm_valparamhead *objext_valparams, unsigned long line) { yasm_valparam *vp = yasm_vps_first(valparams); yasm_valparam *vp2 = yasm_vps_next(vp); @@ -149,44 +139,43 @@ dir_common(yasm_object *object, yasm_valparamhead *valparams, yasm_symrec *sym; if (!size) { - yasm_error_set(YASM_ERROR_SYNTAX, - N_("no size specified in %s declaration"), "COMMON"); - return; + yasm_error_set(YASM_ERROR_SYNTAX, + N_("no size specified in %s declaration"), "COMMON"); + return; } sym = yasm_symtab_declare(object->symtab, yasm_vp_id(vp), YASM_SYM_COMMON, line); yasm_symrec_set_common_size(sym, size); if (objext_valparams) { - yasm_valparamhead *vps = yasm_vps_create(); - *vps = *objext_valparams; /* structure copy */ - yasm_vps_initialize(objext_valparams); /* don't double-free */ - yasm_symrec_set_objext_valparams(sym, vps); + yasm_valparamhead *vps = yasm_vps_create(); + *vps = *objext_valparams; /* structure copy */ + yasm_vps_initialize(objext_valparams); /* don't double-free */ + yasm_symrec_set_objext_valparams(sym, vps); } } static void dir_section(yasm_object *object, yasm_valparamhead *valparams, - yasm_valparamhead *objext_valparams, unsigned long line) + yasm_valparamhead *objext_valparams, unsigned long line) { yasm_section *new_section = - yasm_objfmt_section_switch(object, valparams, objext_valparams, line); + yasm_objfmt_section_switch(object, valparams, objext_valparams, line); if (new_section) - object->cur_section = new_section; + object->cur_section = new_section; else - yasm_error_set(YASM_ERROR_SYNTAX, - N_("invalid argument to directive `%s'"), "SECTION"); + yasm_error_set(YASM_ERROR_SYNTAX, + N_("invalid argument to directive `%s'"), "SECTION"); } static const yasm_directive object_directives[] = { - { ".extern", "gas", dir_extern, YASM_DIR_ID_REQUIRED }, - { ".global", "gas", dir_global, YASM_DIR_ID_REQUIRED }, - { ".globl", "gas", dir_global, YASM_DIR_ID_REQUIRED }, - { ".private_extern","gas", dir_privextern, YASM_DIR_ID_REQUIRED }, - { "extern", "nasm", dir_extern, YASM_DIR_ID_REQUIRED }, - { "global", "nasm", dir_global, YASM_DIR_ID_REQUIRED }, - { "common", "nasm", dir_common, YASM_DIR_ID_REQUIRED }, - { "section", "nasm", dir_section, YASM_DIR_ARG_REQUIRED }, - { "segment", "nasm", dir_section, YASM_DIR_ARG_REQUIRED }, + { ".extern", "gas", dir_extern, YASM_DIR_ID_REQUIRED }, + { ".global", "gas", dir_global, YASM_DIR_ID_REQUIRED }, + { ".globl", "gas", dir_global, YASM_DIR_ID_REQUIRED }, + { "extern", "nasm", dir_extern, YASM_DIR_ID_REQUIRED }, + { "global", "nasm", dir_global, YASM_DIR_ID_REQUIRED }, + { "common", "nasm", dir_common, YASM_DIR_ID_REQUIRED }, + { "section", "nasm", dir_section, YASM_DIR_ARG_REQUIRED }, + { "segment", "nasm", dir_section, YASM_DIR_ARG_REQUIRED }, { NULL, NULL, NULL, 0 } }; @@ -206,33 +195,33 @@ static void directives_add(yasm_object *object, /*@null@*/ const yasm_directive *dir) { if (!dir) - return; + return; while (dir->name) { - HAMT *level2 = HAMT_search(object->directives, dir->parser); - int replace; - yasm_directive_wrap *wrap = yasm_xmalloc(sizeof(yasm_directive_wrap)); + HAMT *level2 = HAMT_search(object->directives, dir->parser); + int replace; + yasm_directive_wrap *wrap = yasm_xmalloc(sizeof(yasm_directive_wrap)); - if (!level2) { - replace = 0; - level2 = HAMT_insert(object->directives, dir->parser, - HAMT_create(1, yasm_internal_error_), - &replace, directive_level1_delete); - } - replace = 0; - wrap->directive = dir; - HAMT_insert(level2, dir->name, wrap, &replace, - directive_level2_delete); - dir++; + if (!level2) { + replace = 0; + level2 = HAMT_insert(object->directives, dir->parser, + HAMT_create(1, yasm_internal_error_), + &replace, directive_level1_delete); + } + replace = 0; + wrap->directive = dir; + HAMT_insert(level2, dir->name, wrap, &replace, + directive_level2_delete); + dir++; } } /*@-compdestroy@*/ yasm_object * yasm_object_create(const char *src_filename, const char *obj_filename, - /*@kept@*/ yasm_arch *arch, - const yasm_objfmt_module *objfmt_module, - const yasm_dbgfmt_module *dbgfmt_module) + /*@kept@*/ yasm_arch *arch, + const yasm_objfmt_module *objfmt_module, + const yasm_dbgfmt_module *dbgfmt_module) { yasm_object *object = yasm_xmalloc(sizeof(yasm_object)); int matched, i; @@ -240,10 +229,6 @@ yasm_object_create(const char *src_filename, const char *obj_filename, object->src_filename = yasm__xstrdup(src_filename); object->obj_filename = yasm__xstrdup(obj_filename); - /* No prefix/suffix */ - object->global_prefix = yasm__xstrdup(""); - object->global_suffix = yasm__xstrdup(""); - /* Create empty symbol table */ object->symtab = yasm_symtab_create(); @@ -262,11 +247,11 @@ yasm_object_create(const char *src_filename, const char *obj_filename, /* Initialize the object format */ object->objfmt = yasm_objfmt_create(objfmt_module, object); if (!object->objfmt) { - yasm_error_set(YASM_ERROR_GENERAL, - N_("object format `%s' does not support architecture `%s' machine `%s'"), - objfmt_module->keyword, ((yasm_arch_base *)arch)->module->keyword, - yasm_arch_get_machine(arch)); - goto error; + yasm_error_set(YASM_ERROR_GENERAL, + N_("object format `%s' does not support architecture `%s' machine `%s'"), + objfmt_module->keyword, ((yasm_arch_base *)arch)->module->keyword, + yasm_arch_get_machine(arch)); + goto error; } /* Get a fresh copy of objfmt_module as it may have changed. */ @@ -279,37 +264,33 @@ yasm_object_create(const char *src_filename, const char *obj_filename, * for the active object format. */ matched = 0; - for (i=0; objfmt_module->dbgfmt_keywords[i]; i++) { - if (yasm__strcasecmp(objfmt_module->dbgfmt_keywords[i], - dbgfmt_module->keyword) == 0) { - matched = 1; - break; - } - } - + for (i=0; objfmt_module->dbgfmt_keywords[i]; i++) + if (yasm__strcasecmp(objfmt_module->dbgfmt_keywords[i], + dbgfmt_module->keyword) == 0) + matched = 1; if (!matched) { - yasm_error_set(YASM_ERROR_GENERAL, - N_("`%s' is not a valid debug format for object format `%s'"), - dbgfmt_module->keyword, objfmt_module->keyword); - goto error; + yasm_error_set(YASM_ERROR_GENERAL, + N_("`%s' is not a valid debug format for object format `%s'"), + dbgfmt_module->keyword, objfmt_module->keyword); + goto error; } /* Initialize the debug format */ object->dbgfmt = yasm_dbgfmt_create(dbgfmt_module, object); if (!object->dbgfmt) { - yasm_error_set(YASM_ERROR_GENERAL, - N_("debug format `%s' does not work with object format `%s'"), - dbgfmt_module->keyword, objfmt_module->keyword); - goto error; + yasm_error_set(YASM_ERROR_GENERAL, + N_("debug format `%s' does not work with object format `%s'"), + dbgfmt_module->keyword, objfmt_module->keyword); + goto error; } /* Add directives to HAMT. Note ordering here determines priority. */ directives_add(object, - ((yasm_objfmt_base *)object->objfmt)->module->directives); + ((yasm_objfmt_base *)object->objfmt)->module->directives); directives_add(object, - ((yasm_dbgfmt_base *)object->dbgfmt)->module->directives); + ((yasm_dbgfmt_base *)object->dbgfmt)->module->directives); directives_add(object, - ((yasm_arch_base *)object->arch)->module->directives); + ((yasm_arch_base *)object->arch)->module->directives); directives_add(object, object_directives); return object; @@ -323,8 +304,8 @@ error: /*@-onlytrans@*/ yasm_section * yasm_object_get_general(yasm_object *object, const char *name, - unsigned long align, int code, int res_only, - int *isnew, unsigned long line) + yasm_expr *start, unsigned long align, int code, + int res_only, int *isnew, unsigned long line) { yasm_section *s; yasm_bytecode *bc; @@ -333,10 +314,10 @@ yasm_object_get_general(yasm_object *object, const char *name, * that name. */ STAILQ_FOREACH(s, &object->sections, link) { - if (strcmp(s->name, name) == 0) { - *isnew = 0; - return s; - } + if (strcmp(s->name, name) == 0) { + *isnew = 0; + return s; + } } /* No: we have to allocate and create a new one. */ @@ -348,6 +329,12 @@ yasm_object_get_general(yasm_object *object, const char *name, s->object = object; s->name = yasm__xstrdup(name); s->assoc_data = NULL; + if (start) + s->start = start; + else + s->start = + yasm_expr_create_ident(yasm_expr_int(yasm_intnum_create_uint(0)), + line); s->align = align; /* Initialize bytecodes with one empty bytecode (acts as "prior" for first @@ -367,9 +354,6 @@ yasm_object_get_general(yasm_object *object, const char *name, s->res_only = res_only; s->def = 0; - /* Initialize object format specific data */ - yasm_objfmt_init_new_section(s, line); - *isnew = 1; return s; } @@ -377,23 +361,23 @@ yasm_object_get_general(yasm_object *object, const char *name, int yasm_object_directive(yasm_object *object, const char *name, - const char *parser, yasm_valparamhead *valparams, - yasm_valparamhead *objext_valparams, - unsigned long line) + const char *parser, yasm_valparamhead *valparams, + yasm_valparamhead *objext_valparams, + unsigned long line) { HAMT *level2; yasm_directive_wrap *wrap; level2 = HAMT_search(object->directives, parser); if (!level2) - return 1; + return 1; wrap = HAMT_search(level2, name); if (!wrap) - return 1; + return 1; yasm_call_directive(wrap->directive, object, valparams, objext_valparams, - line); + line); return 0; } @@ -404,20 +388,6 @@ yasm_object_set_source_fn(yasm_object *object, const char *src_filename) object->src_filename = yasm__xstrdup(src_filename); } -void -yasm_object_set_global_prefix(yasm_object *object, const char *prefix) -{ - yasm_xfree(object->global_prefix); - object->global_prefix = yasm__xstrdup(prefix); -} - -void -yasm_object_set_global_suffix(yasm_object *object, const char *suffix) -{ - yasm_xfree(object->global_suffix); - object->global_suffix = yasm__xstrdup(suffix); -} - int yasm_section_is_code(yasm_section *sect) { @@ -456,14 +426,14 @@ yasm_section_get_object(const yasm_section *sect) void * yasm_section_get_data(yasm_section *sect, - const yasm_assoc_data_callback *callback) + const yasm_assoc_data_callback *callback) { return yasm__assoc_data_get(sect->assoc_data, callback); } void yasm_section_add_data(yasm_section *sect, - const yasm_assoc_data_callback *callback, void *data) + const yasm_assoc_data_callback *callback, void *data) { sect->assoc_data = yasm__assoc_data_add(sect->assoc_data, callback, data); } @@ -477,25 +447,21 @@ yasm_object_destroy(yasm_object *object) * due to an error in yasm_object_create(), so look out for NULLs. */ if (object->objfmt) - yasm_objfmt_destroy(object->objfmt); + yasm_objfmt_destroy(object->objfmt); if (object->dbgfmt) - yasm_dbgfmt_destroy(object->dbgfmt); + yasm_dbgfmt_destroy(object->dbgfmt); /* Delete sections */ cur = STAILQ_FIRST(&object->sections); while (cur) { - next = STAILQ_NEXT(cur, link); - yasm_section_destroy(cur); - cur = next; + next = STAILQ_NEXT(cur, link); + yasm_section_destroy(cur); + cur = next; } /* Delete directives HAMT */ HAMT_destroy(object->directives, directive_level1_delete); - /* Delete prefix/suffix */ - yasm_xfree(object->global_prefix); - yasm_xfree(object->global_suffix); - /* Delete associated filenames */ yasm_xfree(object->src_filename); yasm_xfree(object->obj_filename); @@ -505,7 +471,7 @@ yasm_object_destroy(yasm_object *object) /* Delete architecture */ if (object->arch) - yasm_arch_destroy(object->arch); + yasm_arch_destroy(object->arch); yasm_xfree(object); } @@ -521,8 +487,8 @@ yasm_object_print(const yasm_object *object, FILE *f, int indent_level) /* Print sections and bytecodes */ STAILQ_FOREACH(cur, &object->sections, link) { - fprintf(f, "%*sSection:\n", indent_level, ""); - yasm_section_print(cur, f, indent_level+1, 1); + fprintf(f, "%*sSection:\n", indent_level, ""); + yasm_section_print(cur, f, indent_level+1, 1); } } @@ -533,35 +499,35 @@ yasm_object_finalize(yasm_object *object, yasm_errwarns *errwarns) /* Iterate through sections */ STAILQ_FOREACH(sect, &object->sections, link) { - yasm_bytecode *cur = STAILQ_FIRST(§->bcs); - yasm_bytecode *prev; + yasm_bytecode *cur = STAILQ_FIRST(§->bcs); + yasm_bytecode *prev; - /* Skip our locally created empty bytecode first. */ - prev = cur; - cur = STAILQ_NEXT(cur, link); + /* Skip our locally created empty bytecode first. */ + prev = cur; + cur = STAILQ_NEXT(cur, link); - /* Iterate through the remainder, if any. */ - while (cur) { - /* Finalize */ - yasm_bc_finalize(cur, prev); - yasm_errwarn_propagate(errwarns, cur->line); - prev = cur; - cur = STAILQ_NEXT(cur, link); - } + /* Iterate through the remainder, if any. */ + while (cur) { + /* Finalize */ + yasm_bc_finalize(cur, prev); + yasm_errwarn_propagate(errwarns, cur->line); + prev = cur; + cur = STAILQ_NEXT(cur, link); + } } } int yasm_object_sections_traverse(yasm_object *object, /*@null@*/ void *d, - int (*func) (yasm_section *sect, - /*@null@*/ void *d)) + int (*func) (yasm_section *sect, + /*@null@*/ void *d)) { yasm_section *cur; STAILQ_FOREACH(cur, &object->sections, link) { - int retval = func(cur, d); - if (retval != 0) - return retval; + int retval = func(cur, d); + if (retval != 0) + return retval; } return 0; } @@ -573,8 +539,8 @@ yasm_object_find_general(yasm_object *object, const char *name) yasm_section *cur; STAILQ_FOREACH(cur, &object->sections, link) { - if (strcmp(cur->name, name) == 0) - return cur; + if (strcmp(cur->name, name) == 0) + return cur; } return NULL; } @@ -582,13 +548,13 @@ yasm_object_find_general(yasm_object *object, const char *name) void yasm_section_add_reloc(yasm_section *sect, yasm_reloc *reloc, - void (*destroy_func) (/*@only@*/ void *reloc)) + void (*destroy_func) (/*@only@*/ void *reloc)) { STAILQ_INSERT_TAIL(§->relocs, reloc, link); if (!destroy_func) - yasm_internal_error(N_("NULL destroy function given to add_reloc")); + yasm_internal_error(N_("NULL destroy function given to add_reloc")); else if (sect->destroy_reloc && destroy_func != sect->destroy_reloc) - yasm_internal_error(N_("different destroy function given to add_reloc")); + yasm_internal_error(N_("different destroy function given to add_reloc")); sect->destroy_reloc = destroy_func; } @@ -629,25 +595,21 @@ yasm_bytecode * yasm_section_bcs_append(yasm_section *sect, yasm_bytecode *bc) { if (bc) { - if (!sect) { - yasm_error_set(YASM_ERROR_VALUE, "Attempt to append bytecode to a NULL section or with a NULL bytecode"); - return NULL; - } - if (bc->callback) { - bc->section = sect; /* record parent section */ - STAILQ_INSERT_TAIL(§->bcs, bc, link); - return bc; - } else - yasm_xfree(bc); + if (bc->callback) { + bc->section = sect; /* record parent section */ + STAILQ_INSERT_TAIL(§->bcs, bc, link); + return bc; + } else + yasm_xfree(bc); } return (yasm_bytecode *)NULL; } int yasm_section_bcs_traverse(yasm_section *sect, - /*@null@*/ yasm_errwarns *errwarns, - /*@null@*/ void *d, - int (*func) (yasm_bytecode *bc, /*@null@*/ void *d)) + /*@null@*/ yasm_errwarns *errwarns, + /*@null@*/ void *d, + int (*func) (yasm_bytecode *bc, /*@null@*/ void *d)) { yasm_bytecode *cur = STAILQ_FIRST(§->bcs); @@ -656,12 +618,12 @@ yasm_section_bcs_traverse(yasm_section *sect, /* Iterate through the remainder, if any. */ while (cur) { - int retval = func(cur, d); - if (errwarns) - yasm_errwarn_propagate(errwarns, cur->line); - if (retval != 0) - return retval; - cur = STAILQ_NEXT(cur, link); + int retval = func(cur, d); + if (errwarns) + yasm_errwarn_propagate(errwarns, cur->line); + if (retval != 0) + return retval; + cur = STAILQ_NEXT(cur, link); } return 0; } @@ -672,9 +634,23 @@ yasm_section_get_name(const yasm_section *sect) return sect->name; } +void +yasm_section_set_start(yasm_section *sect, yasm_expr *start, + unsigned long line) +{ + yasm_expr_destroy(sect->start); + sect->start = start; +} + +const yasm_expr * +yasm_section_get_start(const yasm_section *sect) +{ + return sect->start; +} + void yasm_section_set_align(yasm_section *sect, unsigned long align, - unsigned long line) + unsigned long line) { sect->align = align; } @@ -692,26 +668,27 @@ yasm_section_destroy(yasm_section *sect) yasm_reloc *r_cur, *r_next; if (!sect) - return; + return; yasm_xfree(sect->name); yasm__assoc_data_destroy(sect->assoc_data); + yasm_expr_destroy(sect->start); /* Delete bytecodes */ cur = STAILQ_FIRST(§->bcs); while (cur) { - next = STAILQ_NEXT(cur, link); - yasm_bc_destroy(cur); - cur = next; + next = STAILQ_NEXT(cur, link); + yasm_bc_destroy(cur); + cur = next; } /* Delete relocations */ r_cur = STAILQ_FIRST(§->relocs); while (r_cur) { - r_next = STAILQ_NEXT(r_cur, link); - yasm_intnum_destroy(r_cur->addr); - sect->destroy_reloc(r_cur); - r_cur = r_next; + r_next = STAILQ_NEXT(r_cur, link); + yasm_intnum_destroy(r_cur->addr); + sect->destroy_reloc(r_cur); + r_cur = r_next; } yasm_xfree(sect); @@ -719,29 +696,32 @@ yasm_section_destroy(yasm_section *sect) void yasm_section_print(const yasm_section *sect, FILE *f, int indent_level, - int print_bcs) + int print_bcs) { if (!sect) { - fprintf(f, "%*s(none)\n", indent_level, ""); - return; + fprintf(f, "%*s(none)\n", indent_level, ""); + return; } fprintf(f, "%*sname=%s\n", indent_level, "", sect->name); + fprintf(f, "%*sstart=", indent_level, ""); + yasm_expr_print(sect->start, f); + fprintf(f, "\n"); if (sect->assoc_data) { - fprintf(f, "%*sAssociated data:\n", indent_level, ""); - yasm__assoc_data_print(sect->assoc_data, f, indent_level+1); + fprintf(f, "%*sAssociated data:\n", indent_level, ""); + yasm__assoc_data_print(sect->assoc_data, f, indent_level+1); } if (print_bcs) { - yasm_bytecode *cur; + yasm_bytecode *cur; - fprintf(f, "%*sBytecodes:\n", indent_level, ""); + fprintf(f, "%*sBytecodes:\n", indent_level, ""); - STAILQ_FOREACH(cur, §->bcs, link) { - fprintf(f, "%*sNext Bytecode:\n", indent_level+1, ""); - yasm_bc_print(cur, f, indent_level+2); - } + STAILQ_FOREACH(cur, §->bcs, link) { + fprintf(f, "%*sNext Bytecode:\n", indent_level+1, ""); + yasm_bc_print(cur, f, indent_level+2); + } } } @@ -803,10 +783,10 @@ yasm_section_print(const yasm_section *sect, FILE *f, int indent_level, * How times is handled: * * TIMES: Handled separately from bytecode "raw" size. If not span-dependent, - * trivial (just multiplied in at any bytecode size increase). Span - * dependent times update on any change (span ID 0). If the resultant - * next bytecode offset would be less than the old next bytecode offset, - * error. Otherwise increase offset and update dependent spans. + * trivial (just multiplied in at any bytecode size increase). Span + * dependent times update on any change (span ID 0). If the resultant + * next bytecode offset would be less than the old next bytecode offset, + * error. Otherwise increase offset and update dependent spans. * * To reduce interval tree size, a first expansion pass is performed * before the spans are added to the tree. @@ -858,14 +838,14 @@ typedef struct yasm_offset_setter { typedef struct yasm_span_term { yasm_bytecode *precbc, *precbc2; - yasm_span *span; /* span this term is a member of */ + yasm_span *span; /* span this term is a member of */ long cur_val, new_val; unsigned int subst; } yasm_span_term; struct yasm_span { - /*@reldef@*/ TAILQ_ENTRY(yasm_span) link; /* for allocation tracking */ - /*@reldef@*/ STAILQ_ENTRY(yasm_span) linkq; /* for Q */ + /*@reldef@*/ TAILQ_ENTRY(yasm_span) link; /* for allocation tracking */ + /*@reldef@*/ STAILQ_ENTRY(yasm_span) linkq; /* for Q */ /*@dependent@*/ yasm_bytecode *bc; @@ -892,34 +872,32 @@ struct yasm_span { * checking for circular references (cycles) with id=0 spans. */ yasm_span **backtrace; - int backtrace_size; /* First offset setter following this span's bytecode */ yasm_offset_setter *os; }; typedef struct optimize_data { - /*@reldef@*/ TAILQ_HEAD(yasm_span_head, yasm_span) spans; - /*@reldef@*/ STAILQ_HEAD(yasm_span_shead, yasm_span) QA, QB; + /*@reldef@*/ TAILQ_HEAD(, yasm_span) spans; + /*@reldef@*/ STAILQ_HEAD(, yasm_span) QA, QB; /*@only@*/ IntervalTree *itree; - /*@reldef@*/ STAILQ_HEAD(offset_setters_head, yasm_offset_setter) - offset_setters; - long len_diff; /* used only for optimize_term_expand */ - yasm_span *span; /* used only for check_cycle */ + /*@reldef@*/ STAILQ_HEAD(, yasm_offset_setter) offset_setters; + long len_diff; /* used only for optimize_term_expand */ + yasm_span *span; /* used only for check_cycle */ yasm_offset_setter *os; } optimize_data; static yasm_span * create_span(yasm_bytecode *bc, int id, /*@null@*/ const yasm_value *value, - long neg_thres, long pos_thres, yasm_offset_setter *os) + long neg_thres, long pos_thres, yasm_offset_setter *os) { yasm_span *span = yasm_xmalloc(sizeof(yasm_span)); span->bc = bc; if (value) - yasm_value_init_copy(&span->depval, value); + yasm_value_init_copy(&span->depval, value); else - yasm_value_initialize(&span->depval, NULL, 0); + yasm_value_initialize(&span->depval, NULL, 0); span->rel_term = NULL; span->terms = NULL; span->items = NULL; @@ -931,7 +909,6 @@ create_span(yasm_bytecode *bc, int id, /*@null@*/ const yasm_value *value, span->id = id; span->active = 1; span->backtrace = NULL; - span->backtrace_size = 0; span->os = os; return span; @@ -939,7 +916,7 @@ create_span(yasm_bytecode *bc, int id, /*@null@*/ const yasm_value *value, static void optimize_add_span(void *add_span_data, yasm_bytecode *bc, int id, - const yasm_value *value, long neg_thres, long pos_thres) + const yasm_value *value, long neg_thres, long pos_thres) { optimize_data *optd = (optimize_data *)add_span_data; yasm_span *span; @@ -949,16 +926,16 @@ optimize_add_span(void *add_span_data, yasm_bytecode *bc, int id, static void add_span_term(unsigned int subst, yasm_bytecode *precbc, - yasm_bytecode *precbc2, void *d) + yasm_bytecode *precbc2, void *d) { yasm_span *span = d; yasm_intnum *intn; if (subst >= span->num_terms) { - /* Linear expansion since total number is essentially always small */ - span->num_terms = subst+1; - span->terms = yasm_xrealloc(span->terms, - span->num_terms*sizeof(yasm_span_term)); + /* Linear expansion since total number is essentially always small */ + span->num_terms = subst+1; + span->terms = yasm_xrealloc(span->terms, + span->num_terms*sizeof(yasm_span_term)); } span->terms[subst].precbc = precbc; span->terms[subst].precbc2 = precbc2; @@ -967,7 +944,7 @@ add_span_term(unsigned int subst, yasm_bytecode *precbc, intn = yasm_calc_bc_dist(precbc, precbc2); if (!intn) - yasm_internal_error(N_("could not calculate bc distance")); + yasm_internal_error(N_("could not calculate bc distance")); span->terms[subst].cur_val = 0; span->terms[subst].new_val = yasm_intnum_get_int(intn); yasm_intnum_destroy(intn); @@ -980,50 +957,50 @@ span_create_terms(yasm_span *span) /* Split out sym-sym terms in absolute portion of dependent value */ if (span->depval.abs) { - span->num_terms = yasm_expr__bc_dist_subst(&span->depval.abs, span, - add_span_term); - if (span->num_terms > 0) { - span->items = yasm_xmalloc(span->num_terms*sizeof(yasm_expr__item)); - for (i=0; inum_terms; i++) { - /* Create items with dummy value */ - span->items[i].type = YASM_EXPR_INT; - span->items[i].data.intn = yasm_intnum_create_int(0); + span->num_terms = yasm_expr__bc_dist_subst(&span->depval.abs, span, + add_span_term); + if (span->num_terms > 0) { + span->items = yasm_xmalloc(span->num_terms*sizeof(yasm_expr__item)); + for (i=0; inum_terms; i++) { + /* Create items with dummy value */ + span->items[i].type = YASM_EXPR_INT; + span->items[i].data.intn = yasm_intnum_create_int(0); - /* Check for circular references */ - if (span->id <= 0 && - ((span->bc->bc_index > span->terms[i].precbc->bc_index && - span->bc->bc_index <= span->terms[i].precbc2->bc_index) || - (span->bc->bc_index > span->terms[i].precbc2->bc_index && - span->bc->bc_index <= span->terms[i].precbc->bc_index))) - yasm_error_set(YASM_ERROR_VALUE, - N_("circular reference detected")); - } - } + /* Check for circular references */ + if (span->id <= 0 && + ((span->bc->bc_index > span->terms[i].precbc->bc_index && + span->bc->bc_index <= span->terms[i].precbc2->bc_index) || + (span->bc->bc_index > span->terms[i].precbc2->bc_index && + span->bc->bc_index <= span->terms[i].precbc->bc_index))) + yasm_error_set(YASM_ERROR_VALUE, + N_("circular reference detected")); + } + } } /* Create term for relative portion of dependent value */ if (span->depval.rel) { - yasm_bytecode *rel_precbc; - int sym_local; + yasm_bytecode *rel_precbc; + int sym_local; - sym_local = yasm_symrec_get_label(span->depval.rel, &rel_precbc); - if (span->depval.wrt || span->depval.seg_of || span->depval.section_rel - || !sym_local) - return; /* we can't handle SEG, WRT, or external symbols */ - if (rel_precbc->section != span->bc->section) - return; /* not in this section */ - if (!span->depval.curpos_rel) - return; /* not PC-relative */ + sym_local = yasm_symrec_get_label(span->depval.rel, &rel_precbc); + if (span->depval.wrt || span->depval.seg_of || span->depval.section_rel + || !sym_local) + return; /* we can't handle SEG, WRT, or external symbols */ + if (rel_precbc->section != span->bc->section) + return; /* not in this section */ + if (!span->depval.curpos_rel) + return; /* not PC-relative */ - span->rel_term = yasm_xmalloc(sizeof(yasm_span_term)); - span->rel_term->precbc = NULL; - span->rel_term->precbc2 = rel_precbc; - span->rel_term->span = span; - span->rel_term->subst = ~0U; + span->rel_term = yasm_xmalloc(sizeof(yasm_span_term)); + span->rel_term->precbc = NULL; + span->rel_term->precbc2 = rel_precbc; + span->rel_term->span = span; + span->rel_term->subst = ~0U; - span->rel_term->cur_val = 0; - span->rel_term->new_val = yasm_bc_next_offset(rel_precbc) - - span->bc->offset; + span->rel_term->cur_val = 0; + span->rel_term->new_val = yasm_bc_next_offset(rel_precbc) - + span->bc->offset; } } @@ -1036,40 +1013,40 @@ recalc_normal_span(yasm_span *span) span->new_val = 0; if (span->depval.abs) { - yasm_expr *abs_copy = yasm_expr_copy(span->depval.abs); - /*@null@*/ /*@dependent@*/ yasm_intnum *num; + yasm_expr *abs_copy = yasm_expr_copy(span->depval.abs); + /*@null@*/ /*@dependent@*/ yasm_intnum *num; - /* Update sym-sym terms and substitute back into expr */ - unsigned int i; - for (i=0; inum_terms; i++) - yasm_intnum_set_int(span->items[i].data.intn, - span->terms[i].new_val); - yasm_expr__subst(abs_copy, span->num_terms, span->items); - num = yasm_expr_get_intnum(&abs_copy, 0); - if (num) - span->new_val = yasm_intnum_get_int(num); - else - span->new_val = LONG_MAX; /* too complex; force to longest form */ - yasm_expr_destroy(abs_copy); + /* Update sym-sym terms and substitute back into expr */ + unsigned int i; + for (i=0; inum_terms; i++) + yasm_intnum_set_int(span->items[i].data.intn, + span->terms[i].new_val); + yasm_expr__subst(abs_copy, span->num_terms, span->items); + num = yasm_expr_get_intnum(&abs_copy, 0); + if (num) + span->new_val = yasm_intnum_get_int(num); + else + span->new_val = LONG_MAX; /* too complex; force to longest form */ + yasm_expr_destroy(abs_copy); } if (span->rel_term) { - if (span->new_val != LONG_MAX && span->rel_term->new_val != LONG_MAX) - span->new_val += span->rel_term->new_val >> span->depval.rshift; - else - span->new_val = LONG_MAX; /* too complex; force to longest form */ + if (span->new_val != LONG_MAX && span->rel_term->new_val != LONG_MAX) + span->new_val += span->rel_term->new_val >> span->depval.rshift; + else + span->new_val = LONG_MAX; /* too complex; force to longest form */ } else if (span->depval.rel) - span->new_val = LONG_MAX; /* too complex; force to longest form */ + span->new_val = LONG_MAX; /* too complex; force to longest form */ if (span->new_val == LONG_MAX) - span->active = 0; + span->active = 0; /* If id<=0, flag update on any change */ if (span->id <= 0) - return (span->new_val != span->cur_val); + return (span->new_val != span->cur_val); return (span->new_val < span->neg_thres - || span->new_val > span->pos_thres); + || span->new_val > span->pos_thres); } /* Updates all bytecode offsets. For offset-based bytecodes, calls expand @@ -1082,33 +1059,33 @@ update_all_bc_offsets(yasm_object *object, yasm_errwarns *errwarns) int saw_error = 0; STAILQ_FOREACH(sect, &object->sections, link) { - unsigned long offset = 0; + unsigned long offset = 0; - yasm_bytecode *bc = STAILQ_FIRST(§->bcs); - yasm_bytecode *prevbc; + yasm_bytecode *bc = STAILQ_FIRST(§->bcs); + yasm_bytecode *prevbc; - /* Skip our locally created empty bytecode first. */ - prevbc = bc; - bc = STAILQ_NEXT(bc, link); + /* Skip our locally created empty bytecode first. */ + prevbc = bc; + bc = STAILQ_NEXT(bc, link); - /* Iterate through the remainder, if any. */ - while (bc) { - if (bc->callback->special == YASM_BC_SPECIAL_OFFSET) { - /* Recalculate/adjust len of offset-based bytecodes here */ - long neg_thres = 0; - long pos_thres = (long)yasm_bc_next_offset(bc); - int retval = yasm_bc_expand(bc, 1, 0, - (long)yasm_bc_next_offset(prevbc), - &neg_thres, &pos_thres); - yasm_errwarn_propagate(errwarns, bc->line); - if (retval < 0) - saw_error = 1; - } - bc->offset = offset; - offset += bc->len*bc->mult_int; - prevbc = bc; - bc = STAILQ_NEXT(bc, link); - } + /* Iterate through the remainder, if any. */ + while (bc) { + if (bc->callback->special == YASM_BC_SPECIAL_OFFSET) { + /* Recalculate/adjust len of offset-based bytecodes here */ + long neg_thres = 0; + long pos_thres = (long)yasm_bc_next_offset(bc); + int retval = yasm_bc_expand(bc, 1, 0, + (long)yasm_bc_next_offset(prevbc), + &neg_thres, &pos_thres); + yasm_errwarn_propagate(errwarns, bc->line); + if (retval < 0) + saw_error = 1; + } + bc->offset = offset; + offset += bc->len*bc->mult_int; + prevbc = bc; + bc = STAILQ_NEXT(bc, link); + } } return saw_error; } @@ -1120,16 +1097,16 @@ span_destroy(/*@only@*/ yasm_span *span) yasm_value_delete(&span->depval); if (span->rel_term) - yasm_xfree(span->rel_term); + yasm_xfree(span->rel_term); if (span->terms) - yasm_xfree(span->terms); + yasm_xfree(span->terms); if (span->items) { - for (i=0; inum_terms; i++) - yasm_intnum_destroy(span->items[i].data.intn); - yasm_xfree(span->items); + for (i=0; inum_terms; i++) + yasm_intnum_destroy(span->items[i].data.intn); + yasm_xfree(span->items); } if (span->backtrace) - yasm_xfree(span->backtrace); + yasm_xfree(span->backtrace); yasm_xfree(span); } @@ -1143,16 +1120,16 @@ optimize_cleanup(optimize_data *optd) s1 = TAILQ_FIRST(&optd->spans); while (s1) { - s2 = TAILQ_NEXT(s1, link); - span_destroy(s1); - s1 = s2; + s2 = TAILQ_NEXT(s1, link); + span_destroy(s1); + s1 = s2; } os1 = STAILQ_FIRST(&optd->offset_setters); while (os1) { - os2 = STAILQ_NEXT(os1, link); - yasm_xfree(os1); - os1 = os2; + os2 = STAILQ_NEXT(os1, link); + yasm_xfree(os1); + os1 = os2; } } @@ -1164,23 +1141,23 @@ optimize_itree_add(IntervalTree *itree, yasm_span *span, yasm_span_term *term) /* Update term length */ if (term->precbc) - precbc_index = term->precbc->bc_index; + precbc_index = term->precbc->bc_index; else - precbc_index = span->bc->bc_index-1; + precbc_index = span->bc->bc_index-1; if (term->precbc2) - precbc2_index = term->precbc2->bc_index; + precbc2_index = term->precbc2->bc_index; else - precbc2_index = span->bc->bc_index-1; + precbc2_index = span->bc->bc_index-1; if (precbc_index < precbc2_index) { - low = precbc_index+1; - high = precbc2_index; + low = precbc_index+1; + high = precbc2_index; } else if (precbc_index > precbc2_index) { - low = precbc2_index+1; - high = precbc_index; + low = precbc2_index+1; + high = precbc_index; } else - return; /* difference is same bc - always 0! */ + return; /* difference is same bc - always 0! */ IT_insert(itree, (long)low, (long)high, term); } @@ -1191,73 +1168,48 @@ check_cycle(IntervalTreeNode *node, void *d) optimize_data *optd = d; yasm_span_term *term = node->data; yasm_span *depspan = term->span; - int i; - int depspan_bt_alloc; + int bt_size = 0, dep_bt_size = 0; /* Only check for cycles in id=0 spans */ if (depspan->id > 0) - return; + return; /* Check for a circular reference by looking to see if this dependent * span is in our backtrace. */ if (optd->span->backtrace) { - for (i=0; ispan->backtrace_size; i++) { - if (optd->span->backtrace[i] == depspan) - yasm_error_set(YASM_ERROR_VALUE, - N_("circular reference detected")); - } + yasm_span *s; + while ((s = optd->span->backtrace[bt_size])) { + bt_size++; + if (s == depspan) + yasm_error_set(YASM_ERROR_VALUE, + N_("circular reference detected")); + } } /* Add our complete backtrace and ourselves to backtrace of dependent * span. */ if (!depspan->backtrace) { - depspan->backtrace = yasm_xmalloc((optd->span->backtrace_size+1)* - sizeof(yasm_span *)); - if (optd->span->backtrace_size > 0) - memcpy(depspan->backtrace, optd->span->backtrace, - optd->span->backtrace_size*sizeof(yasm_span *)); - depspan->backtrace[optd->span->backtrace_size] = optd->span; - depspan->backtrace_size = optd->span->backtrace_size+1; - return; + depspan->backtrace = yasm_xmalloc((bt_size+2)*sizeof(yasm_span *)); + if (bt_size > 0) + memcpy(depspan->backtrace, optd->span->backtrace, + bt_size*sizeof(yasm_span *)); + depspan->backtrace[bt_size] = optd->span; + depspan->backtrace[bt_size+1] = NULL; + return; } - /* Add our complete backtrace, checking for duplicates */ - depspan_bt_alloc = depspan->backtrace_size; - for (i=0; ispan->backtrace_size; i++) { - int present = 0; - int j; - for (j=0; jbacktrace_size; j++) { - if (optd->span->backtrace[i] == optd->span->backtrace[j]) { - present = 1; - break; - } - } - if (present) - continue; - /* Not already in array; add it. */ - if (depspan->backtrace_size >= depspan_bt_alloc) - { - depspan_bt_alloc *= 2; - depspan->backtrace = - yasm_xrealloc(depspan->backtrace, - depspan_bt_alloc*sizeof(yasm_span *)); - } - depspan->backtrace[depspan->backtrace_size] = optd->span->backtrace[i]; - depspan->backtrace_size++; - } - - /* Add ourselves. */ - if (depspan->backtrace_size >= depspan_bt_alloc) - { - depspan_bt_alloc++; - depspan->backtrace = - yasm_xrealloc(depspan->backtrace, - depspan_bt_alloc*sizeof(yasm_span *)); - } - depspan->backtrace[depspan->backtrace_size] = optd->span; - depspan->backtrace_size++; + while (depspan->backtrace[dep_bt_size]) + dep_bt_size++; + depspan->backtrace = + yasm_xrealloc(depspan->backtrace, + (dep_bt_size+bt_size+2)*sizeof(yasm_span *)); + if (bt_size > 0) + memcpy(&depspan->backtrace[dep_bt_size], optd->span->backtrace, + (bt_size-1)*sizeof(yasm_span *)); + depspan->backtrace[dep_bt_size+bt_size] = optd->span; + depspan->backtrace[dep_bt_size+bt_size+1] = NULL; } static void @@ -1271,38 +1223,38 @@ optimize_term_expand(IntervalTreeNode *node, void *d) /* Don't expand inactive spans */ if (!span->active) - return; + return; /* Update term length */ if (term->precbc) - precbc_index = term->precbc->bc_index; + precbc_index = term->precbc->bc_index; else - precbc_index = span->bc->bc_index-1; + precbc_index = span->bc->bc_index-1; if (term->precbc2) - precbc2_index = term->precbc2->bc_index; + precbc2_index = term->precbc2->bc_index; else - precbc2_index = span->bc->bc_index-1; + precbc2_index = span->bc->bc_index-1; if (precbc_index < precbc2_index) - term->new_val += len_diff; + term->new_val += len_diff; else - term->new_val -= len_diff; + term->new_val -= len_diff; /* If already on Q, don't re-add */ if (span->active == 2) - return; + return; /* Update term and check against thresholds */ if (!recalc_normal_span(span)) - return; /* didn't exceed thresholds, we're done */ + return; /* didn't exceed thresholds, we're done */ /* Exceeded thresholds, need to add to Q for expansion */ if (span->id <= 0) - STAILQ_INSERT_TAIL(&optd->QA, span, linkq); + STAILQ_INSERT_TAIL(&optd->QA, span, linkq); else - STAILQ_INSERT_TAIL(&optd->QB, span, linkq); - span->active = 2; /* Mark as being in Q */ + STAILQ_INSERT_TAIL(&optd->QB, span, linkq); + span->active = 2; /* Mark as being in Q */ } void @@ -1334,267 +1286,270 @@ yasm_object_optimize(yasm_object *object, yasm_errwarns *errwarns) /* Step 1a */ STAILQ_FOREACH(sect, &object->sections, link) { - unsigned long offset = 0; + unsigned long offset = 0; - yasm_bytecode *bc = STAILQ_FIRST(§->bcs); + yasm_bytecode *bc = STAILQ_FIRST(§->bcs); + yasm_bytecode *prevbc; - bc->bc_index = bc_index++; + bc->bc_index = bc_index++; - /* Skip our locally created empty bytecode first. */ - bc = STAILQ_NEXT(bc, link); + /* Skip our locally created empty bytecode first. */ + prevbc = bc; + bc = STAILQ_NEXT(bc, link); - /* Iterate through the remainder, if any. */ - while (bc) { - bc->bc_index = bc_index++; - bc->offset = offset; + /* Iterate through the remainder, if any. */ + while (bc) { + bc->bc_index = bc_index++; + bc->offset = offset; - retval = yasm_bc_calc_len(bc, optimize_add_span, &optd); - yasm_errwarn_propagate(errwarns, bc->line); - if (retval) - saw_error = 1; - else { - if (bc->callback->special == YASM_BC_SPECIAL_OFFSET) { - /* Remember it as offset setter */ - os->bc = bc; - os->thres = yasm_bc_next_offset(bc); + retval = yasm_bc_calc_len(bc, optimize_add_span, &optd); + yasm_errwarn_propagate(errwarns, bc->line); + if (retval) + saw_error = 1; + else { + if (bc->callback->special == YASM_BC_SPECIAL_OFFSET) { + /* Remember it as offset setter */ + os->bc = bc; + os->thres = yasm_bc_next_offset(bc); - /* Create new placeholder */ - os = yasm_xmalloc(sizeof(yasm_offset_setter)); - os->bc = NULL; - os->cur_val = 0; - os->new_val = 0; - os->thres = 0; - STAILQ_INSERT_TAIL(&optd.offset_setters, os, link); - optd.os = os; + /* Create new placeholder */ + os = yasm_xmalloc(sizeof(yasm_offset_setter)); + os->bc = NULL; + os->cur_val = 0; + os->new_val = 0; + os->thres = 0; + STAILQ_INSERT_TAIL(&optd.offset_setters, os, link); + optd.os = os; - if (bc->multiple) { - yasm_error_set(YASM_ERROR_VALUE, - N_("cannot combine multiples and setting assembly position")); - yasm_errwarn_propagate(errwarns, bc->line); - saw_error = 1; - } - } + if (bc->multiple) { + yasm_error_set(YASM_ERROR_VALUE, + N_("cannot combine multiples and setting assembly position")); + yasm_errwarn_propagate(errwarns, bc->line); + saw_error = 1; + } + } - offset += bc->len*bc->mult_int; - } + offset += bc->len*bc->mult_int; + } - bc = STAILQ_NEXT(bc, link); - } + prevbc = bc; + bc = STAILQ_NEXT(bc, link); + } } if (saw_error) { - optimize_cleanup(&optd); - return; + optimize_cleanup(&optd); + return; } /* Step 1b */ TAILQ_FOREACH_SAFE(span, &optd.spans, link, span_temp) { - span_create_terms(span); - if (yasm_error_occurred()) { - yasm_errwarn_propagate(errwarns, span->bc->line); - saw_error = 1; - } else if (recalc_normal_span(span)) { - retval = yasm_bc_expand(span->bc, span->id, span->cur_val, - span->new_val, &span->neg_thres, - &span->pos_thres); - yasm_errwarn_propagate(errwarns, span->bc->line); - if (retval < 0) - saw_error = 1; - else if (retval > 0) { - if (!span->active) { - yasm_error_set(YASM_ERROR_VALUE, - N_("secondary expansion of an external/complex value")); - yasm_errwarn_propagate(errwarns, span->bc->line); - saw_error = 1; - } - } else { - TAILQ_REMOVE(&optd.spans, span, link); - span_destroy(span); - continue; - } - } - span->cur_val = span->new_val; + span_create_terms(span); + if (yasm_error_occurred()) { + yasm_errwarn_propagate(errwarns, span->bc->line); + saw_error = 1; + } else if (recalc_normal_span(span)) { + retval = yasm_bc_expand(span->bc, span->id, span->cur_val, + span->new_val, &span->neg_thres, + &span->pos_thres); + yasm_errwarn_propagate(errwarns, span->bc->line); + if (retval < 0) + saw_error = 1; + else if (retval > 0) { + if (!span->active) { + yasm_error_set(YASM_ERROR_VALUE, + N_("secondary expansion of an external/complex value")); + yasm_errwarn_propagate(errwarns, span->bc->line); + saw_error = 1; + } + } else { + TAILQ_REMOVE(&optd.spans, span, link); + span_destroy(span); + continue; + } + } + span->cur_val = span->new_val; } if (saw_error) { - optimize_cleanup(&optd); - return; + optimize_cleanup(&optd); + return; } /* Step 1c */ if (update_all_bc_offsets(object, errwarns)) { - optimize_cleanup(&optd); - return; + optimize_cleanup(&optd); + return; } /* Step 1d */ STAILQ_INIT(&optd.QB); TAILQ_FOREACH(span, &optd.spans, link) { - yasm_intnum *intn; + yasm_intnum *intn; - /* Update span terms based on new bc offsets */ - for (i=0; inum_terms; i++) { - intn = yasm_calc_bc_dist(span->terms[i].precbc, - span->terms[i].precbc2); - if (!intn) - yasm_internal_error(N_("could not calculate bc distance")); - span->terms[i].cur_val = span->terms[i].new_val; - span->terms[i].new_val = yasm_intnum_get_int(intn); - yasm_intnum_destroy(intn); - } - if (span->rel_term) { - span->rel_term->cur_val = span->rel_term->new_val; - if (span->rel_term->precbc2) - span->rel_term->new_val = - yasm_bc_next_offset(span->rel_term->precbc2) - - span->bc->offset; - else - span->rel_term->new_val = span->bc->offset - - yasm_bc_next_offset(span->rel_term->precbc); - } + /* Update span terms based on new bc offsets */ + for (i=0; inum_terms; i++) { + intn = yasm_calc_bc_dist(span->terms[i].precbc, + span->terms[i].precbc2); + if (!intn) + yasm_internal_error(N_("could not calculate bc distance")); + span->terms[i].cur_val = span->terms[i].new_val; + span->terms[i].new_val = yasm_intnum_get_int(intn); + yasm_intnum_destroy(intn); + } + if (span->rel_term) { + span->rel_term->cur_val = span->rel_term->new_val; + if (span->rel_term->precbc2) + span->rel_term->new_val = + yasm_bc_next_offset(span->rel_term->precbc2) - + span->bc->offset; + else + span->rel_term->new_val = span->bc->offset - + yasm_bc_next_offset(span->rel_term->precbc); + } - if (recalc_normal_span(span)) { - /* Exceeded threshold, add span to QB */ - STAILQ_INSERT_TAIL(&optd.QB, span, linkq); - span->active = 2; - } + if (recalc_normal_span(span)) { + /* Exceeded threshold, add span to QB */ + STAILQ_INSERT_TAIL(&optd.QB, span, linkq); + span->active = 2; + } } /* Do we need step 2? If not, go ahead and exit. */ if (STAILQ_EMPTY(&optd.QB)) { - optimize_cleanup(&optd); - return; + optimize_cleanup(&optd); + return; } /* Update offset-setters values */ STAILQ_FOREACH(os, &optd.offset_setters, link) { - if (!os->bc) - continue; - os->thres = yasm_bc_next_offset(os->bc); - os->new_val = os->bc->offset; - os->cur_val = os->new_val; + if (!os->bc) + continue; + os->thres = yasm_bc_next_offset(os->bc); + os->new_val = os->bc->offset; + os->cur_val = os->new_val; } /* Build up interval tree */ TAILQ_FOREACH(span, &optd.spans, link) { - for (i=0; inum_terms; i++) - optimize_itree_add(optd.itree, span, &span->terms[i]); - if (span->rel_term) - optimize_itree_add(optd.itree, span, span->rel_term); + for (i=0; inum_terms; i++) + optimize_itree_add(optd.itree, span, &span->terms[i]); + if (span->rel_term) + optimize_itree_add(optd.itree, span, span->rel_term); } /* Look for cycles in times expansion (span.id==0) */ TAILQ_FOREACH(span, &optd.spans, link) { - if (span->id > 0) - continue; - optd.span = span; - IT_enumerate(optd.itree, (long)span->bc->bc_index, - (long)span->bc->bc_index, &optd, check_cycle); - if (yasm_error_occurred()) { - yasm_errwarn_propagate(errwarns, span->bc->line); - saw_error = 1; - } + if (span->id > 0) + continue; + optd.span = span; + IT_enumerate(optd.itree, (long)span->bc->bc_index, + (long)span->bc->bc_index, &optd, check_cycle); + if (yasm_error_occurred()) { + yasm_errwarn_propagate(errwarns, span->bc->line); + saw_error = 1; + } } if (saw_error) { - optimize_cleanup(&optd); - return; + optimize_cleanup(&optd); + return; } /* Step 2 */ STAILQ_INIT(&optd.QA); while (!STAILQ_EMPTY(&optd.QA) || !(STAILQ_EMPTY(&optd.QB))) { - unsigned long orig_len; - long offset_diff; + unsigned long orig_len; + long offset_diff; - /* QA is for TIMES, update those first, then update non-TIMES. - * This is so that TIMES can absorb increases before we look at - * expanding non-TIMES BCs. - */ - if (!STAILQ_EMPTY(&optd.QA)) { - span = STAILQ_FIRST(&optd.QA); - STAILQ_REMOVE_HEAD(&optd.QA, linkq); - } else { - span = STAILQ_FIRST(&optd.QB); - STAILQ_REMOVE_HEAD(&optd.QB, linkq); - } + /* QA is for TIMES, update those first, then update non-TIMES. + * This is so that TIMES can absorb increases before we look at + * expanding non-TIMES BCs. + */ + if (!STAILQ_EMPTY(&optd.QA)) { + span = STAILQ_FIRST(&optd.QA); + STAILQ_REMOVE_HEAD(&optd.QA, linkq); + } else { + span = STAILQ_FIRST(&optd.QB); + STAILQ_REMOVE_HEAD(&optd.QB, linkq); + } - if (!span->active) - continue; - span->active = 1; /* no longer in Q */ + if (!span->active) + continue; + span->active = 1; /* no longer in Q */ - /* Make sure we ended up ultimately exceeding thresholds; due to - * offset BCs we may have been placed on Q and then reduced in size - * again. - */ - if (!recalc_normal_span(span)) - continue; + /* Make sure we ended up ultimately exceeding thresholds; due to + * offset BCs we may have been placed on Q and then reduced in size + * again. + */ + if (!recalc_normal_span(span)) + continue; - orig_len = span->bc->len * span->bc->mult_int; + orig_len = span->bc->len * span->bc->mult_int; - retval = yasm_bc_expand(span->bc, span->id, span->cur_val, - span->new_val, &span->neg_thres, - &span->pos_thres); - yasm_errwarn_propagate(errwarns, span->bc->line); + retval = yasm_bc_expand(span->bc, span->id, span->cur_val, + span->new_val, &span->neg_thres, + &span->pos_thres); + yasm_errwarn_propagate(errwarns, span->bc->line); - if (retval < 0) { - /* error */ - saw_error = 1; - continue; - } else if (retval > 0) { - /* another threshold, keep active */ - for (i=0; inum_terms; i++) - span->terms[i].cur_val = span->terms[i].new_val; - if (span->rel_term) - span->rel_term->cur_val = span->rel_term->new_val; - span->cur_val = span->new_val; - } else - span->active = 0; /* we're done with this span */ + if (retval < 0) { + /* error */ + saw_error = 1; + continue; + } else if (retval > 0) { + /* another threshold, keep active */ + for (i=0; inum_terms; i++) + span->terms[i].cur_val = span->terms[i].new_val; + if (span->rel_term) + span->rel_term->cur_val = span->rel_term->new_val; + span->cur_val = span->new_val; + } else + span->active = 0; /* we're done with this span */ - optd.len_diff = span->bc->len * span->bc->mult_int - orig_len; - if (optd.len_diff == 0) - continue; /* didn't increase in size */ + optd.len_diff = span->bc->len * span->bc->mult_int - orig_len; + if (optd.len_diff == 0) + continue; /* didn't increase in size */ - /* Iterate over all spans dependent across the bc just expanded */ - IT_enumerate(optd.itree, (long)span->bc->bc_index, - (long)span->bc->bc_index, &optd, optimize_term_expand); + /* Iterate over all spans dependent across the bc just expanded */ + IT_enumerate(optd.itree, (long)span->bc->bc_index, + (long)span->bc->bc_index, &optd, optimize_term_expand); - /* Iterate over offset-setters that follow the bc just expanded. - * Stop iteration if: - * - no more offset-setters in this section - * - offset-setter didn't move its following offset - */ - os = span->os; - offset_diff = optd.len_diff; - while (os->bc && os->bc->section == span->bc->section - && offset_diff != 0) { - unsigned long old_next_offset = os->cur_val + os->bc->len; - long neg_thres_temp; + /* Iterate over offset-setters that follow the bc just expanded. + * Stop iteration if: + * - no more offset-setters in this section + * - offset-setter didn't move its following offset + */ + os = span->os; + offset_diff = optd.len_diff; + while (os->bc && os->bc->section == span->bc->section + && offset_diff != 0) { + unsigned long old_next_offset = os->cur_val + os->bc->len; + long neg_thres_temp; - if (offset_diff < 0 && (unsigned long)(-offset_diff) > os->new_val) - yasm_internal_error(N_("org/align went to negative offset")); - os->new_val += offset_diff; + if (offset_diff < 0 && (unsigned long)(-offset_diff) > os->new_val) + yasm_internal_error(N_("org/align went to negative offset")); + os->new_val += offset_diff; - orig_len = os->bc->len; - retval = yasm_bc_expand(os->bc, 1, (long)os->cur_val, - (long)os->new_val, &neg_thres_temp, - (long *)&os->thres); - yasm_errwarn_propagate(errwarns, os->bc->line); + orig_len = os->bc->len; + retval = yasm_bc_expand(os->bc, 1, (long)os->cur_val, + (long)os->new_val, &neg_thres_temp, + (long *)&os->thres); + yasm_errwarn_propagate(errwarns, os->bc->line); - offset_diff = os->new_val + os->bc->len - old_next_offset; - optd.len_diff = os->bc->len - orig_len; - if (optd.len_diff != 0) - IT_enumerate(optd.itree, (long)os->bc->bc_index, - (long)os->bc->bc_index, &optd, optimize_term_expand); + offset_diff = os->new_val + os->bc->len - old_next_offset; + optd.len_diff = os->bc->len - orig_len; + if (optd.len_diff != 0) + IT_enumerate(optd.itree, (long)os->bc->bc_index, + (long)os->bc->bc_index, &optd, optimize_term_expand); - os->cur_val = os->new_val; - os = STAILQ_NEXT(os, link); - } + os->cur_val = os->new_val; + os = STAILQ_NEXT(os, link); + } } if (saw_error) { - optimize_cleanup(&optd); - return; + optimize_cleanup(&optd); + return; } /* Step 3 */ diff --git a/libyasm/section.h b/libyasm/section.h index 2c7faa4d..04c5f33c 100644 --- a/libyasm/section.h +++ b/libyasm/section.h @@ -2,6 +2,10 @@ * \file libyasm/section.h * \brief YASM section interface. * + * \rcs + * $Id$ + * \endrcs + * * \license * Copyright (C) 2001-2007 Peter Johnson * @@ -30,36 +34,35 @@ #ifndef YASM_SECTION_H #define YASM_SECTION_H -#ifndef YASM_LIB_DECL -#define YASM_LIB_DECL -#endif - /** Basic YASM relocation. Object formats will need to extend this * structure with additional fields for relocation type, etc. */ typedef struct yasm_reloc yasm_reloc; +#ifdef YASM_LIB_INTERNAL struct yasm_reloc { - /*@reldef@*/ STAILQ_ENTRY(yasm_reloc) link; /**< Link to next reloc */ - yasm_intnum *addr; /**< Offset (address) within section */ - /*@dependent@*/ yasm_symrec *sym; /**< Relocated symbol */ + /*@reldef@*/ STAILQ_ENTRY(yasm_reloc) link; + yasm_intnum *addr; /**< Offset (address) within section */ + /*@dependent@*/ yasm_symrec *sym; /**< Relocated symbol */ }; +#endif /** An object. This is the internal representation of an object file. */ struct yasm_object { - /*@owned@*/ char *src_filename; /**< Source filename */ - /*@owned@*/ char *obj_filename; /**< Object filename */ + /*@owned@*/ char *src_filename; /**< Source filename */ + /*@owned@*/ char *obj_filename; /**< Object filename */ - /*@owned@*/ yasm_symtab *symtab; /**< Symbol table */ - /*@owned@*/ yasm_arch *arch; /**< Target architecture */ - /*@owned@*/ yasm_objfmt *objfmt; /**< Object format */ - /*@owned@*/ yasm_dbgfmt *dbgfmt; /**< Debug format */ + /*@owned@*/ yasm_symtab *symtab; /**< Symbol table */ + /*@owned@*/ yasm_arch *arch; /**< Target architecture */ + /*@owned@*/ yasm_objfmt *objfmt; /**< Object format */ + /*@owned@*/ yasm_dbgfmt *dbgfmt; /**< Debug format */ /** Currently active section. Used by some directives. NULL if no * section active. */ /*@dependent@*/ /*@null@*/ yasm_section *cur_section; +#ifdef YASM_LIB_INTERNAL /** Linked list of sections. */ /*@reldef@*/ STAILQ_HEAD(yasm_sectionhead, yasm_section) sections; @@ -67,25 +70,19 @@ struct yasm_object { * second level is directive name. */ /*@owned@*/ struct HAMT *directives; - - /** Prefix prepended to externally-visible symbols (empty string if none) */ - /*@owned@*/ char *global_prefix; - - /** Suffix appended to externally-visible symbols (empty string if none) */ - /*@owned@*/ char *global_suffix; +#endif }; /** Create a new object. A default section is created as the first section. * An empty symbol table (yasm_symtab) and line mapping (yasm_linemap) are * automatically created. - * \param src_filename source filename (e.g. "file.asm") - * \param obj_filename object filename (e.g. "file.o") - * \param arch architecture - * \param objfmt_module object format module - * \param dbgfmt_module debug format module + * \param src_filename source filename (e.g. "file.asm") + * \param obj_filename object filename (e.g. "file.o") + * \param arch architecture + * \param objfmt_module object format module + * \param dbgfmt_module debug format module * \return Newly allocated object, or NULL on error. */ -YASM_LIB_DECL /*@null@*/ /*@only@*/ yasm_object *yasm_object_create (const char *src_filename, const char *obj_filename, /*@kept@*/ yasm_arch *arch, @@ -95,254 +92,220 @@ YASM_LIB_DECL /** Create a new, or continue an existing, general section. The section is * added to the object if there's not already a section by that name. * \param object object - * \param name section name - * \param align alignment in bytes (0 if none) - * \param code if nonzero, section is intended to contain code - * (e.g. alignment should be made with NOP instructions, not 0) + * \param name section name + * \param start starting address (ignored if section already exists), + * NULL if 0 or don't care. + * \param align alignment in bytes (0 if none) + * \param code if nonzero, section is intended to contain code + * (e.g. alignment should be made with NOP instructions, not 0) * \param res_only if nonzero, only space-reserving bytecodes are allowed in - * the section (ignored if section already exists) - * \param isnew output; set to nonzero if section did not already exist + * the section (ignored if section already exists) + * \param isnew output; set to nonzero if section did not already exist * \param line virtual line of section declaration (ignored if section - * already exists) + * already exists) * \return New section. */ -YASM_LIB_DECL /*@dependent@*/ yasm_section *yasm_object_get_general - (yasm_object *object, const char *name, unsigned long align, int code, + (yasm_object *object, const char *name, + /*@null@*/ /*@only@*/ yasm_expr *start, unsigned long align, int code, int res_only, /*@out@*/ int *isnew, unsigned long line); /** Handle a directive. Passed down to object format, debug format, or * architecture as appropriate. - * \param object object - * \param name directive name - * \param parser parser keyword - * \param valparams value/parameters - * \param objext_valparams "object format-specific" value/parameters - * \param line virtual line (from yasm_linemap) + * \param object object + * \param name directive name + * \param parser parser keyword + * \param valparams value/parameters + * \param objext_valparams "object format-specific" value/parameters + * \param line virtual line (from yasm_linemap) * \return 0 if directive recognized, nonzero if unrecognized. */ -YASM_LIB_DECL int yasm_object_directive(yasm_object *object, const char *name, - const char *parser, yasm_valparamhead *valparams, - yasm_valparamhead *objext_valparams, - unsigned long line); + const char *parser, yasm_valparamhead *valparams, + yasm_valparamhead *objext_valparams, + unsigned long line); /** Delete (free allocated memory for) an object. All sections in the * object and all bytecodes within those sections are also deleted. - * \param object object + * \param object object */ -YASM_LIB_DECL void yasm_object_destroy(/*@only@*/ yasm_object *object); /** Print an object. For debugging purposes. - * \param object object - * \param f file - * \param indent_level indentation level + * \param object object + * \param f file + * \param indent_level indentation level */ -YASM_LIB_DECL void yasm_object_print(const yasm_object *object, FILE *f, int indent_level); /** Finalize an object after parsing. - * \param object object - * \param errwarns error/warning set + * \param object object + * \param errwarns error/warning set * \note Errors/warnings are stored into errwarns. */ -YASM_LIB_DECL void yasm_object_finalize(yasm_object *object, yasm_errwarns *errwarns); /** Traverses all sections in an object, calling a function on each section. - * \param object object - * \param d data pointer passed to func on each call - * \param func function + * \param object object + * \param d data pointer passed to func on each call + * \param func function * \return Stops early (and returns func's return value) if func returns a - * nonzero value; otherwise 0. + * nonzero value; otherwise 0. */ -YASM_LIB_DECL int yasm_object_sections_traverse (yasm_object *object, /*@null@*/ void *d, int (*func) (yasm_section *sect, /*@null@*/ void *d)); /** Find a general section in an object, based on its name. - * \param object object - * \param name section name + * \param object object + * \param name section name * \return Section matching name, or NULL if no match found. */ -YASM_LIB_DECL /*@dependent@*/ /*@null@*/ yasm_section *yasm_object_find_general (yasm_object *object, const char *name); /** Change the source filename for an object. - * \param object object - * \param src_filename new source filename (e.g. "file.asm") + * \param object object + * \param src_filename new source filename (e.g. "file.asm") */ -YASM_LIB_DECL void yasm_object_set_source_fn(yasm_object *object, const char *src_filename); -/** Change the prefix used for externally-visible symbols. - * \param object object - * \param prefix new prefix - */ -YASM_LIB_DECL -void yasm_object_set_global_prefix(yasm_object *object, const char *prefix); - -/** Change the suffix used for externally-visible symbols. - * \param object object - * \param suffix new suffix - */ -YASM_LIB_DECL -void yasm_object_set_global_suffix(yasm_object *object, const char *suffix); - /** Optimize an object. Takes the unoptimized object and optimizes it. * If successful, the object is ready for output to an object file. - * \param object object - * \param errwarns error/warning set + * \param object object + * \param errwarns error/warning set * \note Optimization failures are stored into errwarns. */ -YASM_LIB_DECL void yasm_object_optimize(yasm_object *object, yasm_errwarns *errwarns); /** Determine if a section is flagged to contain code. - * \param sect section + * \param sect section * \return Nonzero if section is flagged to contain code. */ -YASM_LIB_DECL int yasm_section_is_code(yasm_section *sect); /** Get yasm_optimizer-specific flags. For yasm_optimizer use only. - * \param sect section + * \param sect section * \return Optimizer-specific flags. */ -YASM_LIB_DECL unsigned long yasm_section_get_opt_flags(const yasm_section *sect); /** Set yasm_optimizer-specific flags. For yasm_optimizer use only. - * \param sect section + * \param sect section * \param opt_flags optimizer-specific flags. */ -YASM_LIB_DECL void yasm_section_set_opt_flags(yasm_section *sect, unsigned long opt_flags); /** Determine if a section was declared as the "default" section (e.g. not * created through a section directive). - * \param sect section + * \param sect section * \return Nonzero if section was declared as default. */ -YASM_LIB_DECL int yasm_section_is_default(const yasm_section *sect); /** Set section "default" flag to a new value. - * \param sect section - * \param def new value of default flag + * \param sect section + * \param def new value of default flag */ -YASM_LIB_DECL void yasm_section_set_default(yasm_section *sect, int def); /** Get object owner of a section. - * \param sect section + * \param sect section * \return Object this section is a part of. */ -YASM_LIB_DECL yasm_object *yasm_section_get_object(const yasm_section *sect); /** Get assocated data for a section and data callback. - * \param sect section + * \param sect section * \param callback callback used when adding data * \return Associated data (NULL if none). */ -YASM_LIB_DECL /*@dependent@*/ /*@null@*/ void *yasm_section_get_data (yasm_section *sect, const yasm_assoc_data_callback *callback); /** Add associated data to a section. * \attention Deletes any existing associated data for that data callback. - * \param sect section + * \param sect section * \param callback callback - * \param data data to associate + * \param data data to associate */ -YASM_LIB_DECL void yasm_section_add_data(yasm_section *sect, - const yasm_assoc_data_callback *callback, - /*@null@*/ /*@only@*/ void *data); + const yasm_assoc_data_callback *callback, + /*@null@*/ /*@only@*/ void *data); /** Add a relocation to a section. - * \param sect section - * \param reloc relocation - * \param destroy_func function that can destroy the relocation + * \param sect section + * \param reloc relocation + * \param destroy_func function that can destroy the relocation * \note Does not make a copy of reloc. The same destroy_func must be * used for all relocations in a section or an internal error will occur. * The section will destroy the relocation address; it is the caller's * responsibility to destroy any other allocated data. */ -YASM_LIB_DECL void yasm_section_add_reloc(yasm_section *sect, yasm_reloc *reloc, void (*destroy_func) (/*@only@*/ void *reloc)); /** Get the first relocation for a section. - * \param sect section + * \param sect section * \return First relocation for section. NULL if no relocations. */ -YASM_LIB_DECL /*@null@*/ yasm_reloc *yasm_section_relocs_first(yasm_section *sect); /** Get the next relocation for a section. - * \param reloc previous relocation + * \param reloc previous relocation * \return Next relocation for section. NULL if no more relocations. */ /*@null@*/ yasm_reloc *yasm_section_reloc_next(yasm_reloc *reloc); -#ifndef YASM_DOXYGEN -#define yasm_section_reloc_next(x) STAILQ_NEXT((x), link) + +#ifdef YASM_LIB_INTERNAL +#define yasm_section_reloc_next(x) STAILQ_NEXT((x), link) #endif /** Get the basic relocation information for a relocation. - * \param reloc relocation - * \param addrp address of relocation within section (returned) - * \param symp relocated symbol (returned) + * \param reloc relocation + * \param addrp address of relocation within section (returned) + * \param symp relocated symbol (returned) */ -YASM_LIB_DECL void yasm_reloc_get(yasm_reloc *reloc, yasm_intnum **addrp, - /*@dependent@*/ yasm_symrec **symp); + /*@dependent@*/ yasm_symrec **symp); /** Get the first bytecode in a section. - * \param sect section + * \param sect section * \return First bytecode in section (at least one empty bytecode is always - * present). + * present). */ -YASM_LIB_DECL yasm_bytecode *yasm_section_bcs_first(yasm_section *sect); /** Get the last bytecode in a section. - * \param sect section + * \param sect section * \return Last bytecode in section (at least one empty bytecode is always - * present). + * present). */ -YASM_LIB_DECL yasm_bytecode *yasm_section_bcs_last(yasm_section *sect); /** Add bytecode to the end of a section. * \note Does not make a copy of bc; so don't pass this function static or - * local variables, and discard the bc pointer after calling this - * function. - * \param sect section - * \param bc bytecode (may be NULL) + * local variables, and discard the bc pointer after calling this + * function. + * \param sect section + * \param bc bytecode (may be NULL) * \return If bytecode was actually appended (it wasn't NULL or empty), the - * bytecode; otherwise NULL. + * bytecode; otherwise NULL. */ -YASM_LIB_DECL /*@only@*/ /*@null@*/ yasm_bytecode *yasm_section_bcs_append (yasm_section *sect, /*@returned@*/ /*@only@*/ /*@null@*/ yasm_bytecode *bc); /** Traverses all bytecodes in a section, calling a function on each bytecode. - * \param sect section + * \param sect section * \param errwarns error/warning set (may be NULL) - * \param d data pointer passed to func on each call (may be NULL) - * \param func function + * \param d data pointer passed to func on each call (may be NULL) + * \param func function * \return Stops early (and returns func's return value) if func returns a - * nonzero value; otherwise 0. + * nonzero value; otherwise 0. * \note If errwarns is non-NULL, yasm_errwarn_propagate() is called after * each call to func (with the bytecode's line number). */ -YASM_LIB_DECL int yasm_section_bcs_traverse (yasm_section *sect, /*@null@*/ yasm_errwarns *errwarns, /*@null@*/ void *d, int (*func) (yasm_bytecode *bc, /*@null@*/ void *d)); @@ -351,33 +314,44 @@ int yasm_section_bcs_traverse * \param sect section * \return Section name. */ -YASM_LIB_DECL /*@observer@*/ const char *yasm_section_get_name(const yasm_section *sect); -/** Change alignment of a section. - * \param sect section - * \param align alignment in bytes - * \param line virtual line +/** Change starting address of a section. + * \param sect section + * \param start starting address + * \param line virtual line + */ +void yasm_section_set_start(yasm_section *sect, /*@only@*/ yasm_expr *start, + unsigned long line); + +/** Get starting address of a section. + * \param sect section + * \return Starting address. + */ +/*@observer@*/ const yasm_expr *yasm_section_get_start + (const yasm_section *sect); + +/** Change alignment of a section. + * \param sect section + * \param align alignment in bytes + * \param line virtual line */ -YASM_LIB_DECL void yasm_section_set_align(yasm_section *sect, unsigned long align, - unsigned long line); + unsigned long line); /** Get alignment of a section. - * \param sect section + * \param sect section * \return Alignment in bytes (0 if none). */ -YASM_LIB_DECL unsigned long yasm_section_get_align(const yasm_section *sect); /** Print a section. For debugging purposes. - * \param f file - * \param indent_level indentation level - * \param sect section - * \param print_bcs if nonzero, print bytecodes within section + * \param f file + * \param indent_level indentation level + * \param sect section + * \param print_bcs if nonzero, print bytecodes within section */ -YASM_LIB_DECL void yasm_section_print(/*@null@*/ const yasm_section *sect, FILE *f, - int indent_level, int print_bcs); + int indent_level, int print_bcs); #endif diff --git a/libyasm/strcasecmp.c b/libyasm/strcasecmp.c index a87bd88b..441d0456 100644 --- a/libyasm/strcasecmp.c +++ b/libyasm/strcasecmp.c @@ -3,7 +3,7 @@ * or strcmpi(). * * Copyright (c) 1987, 1993 - * The Regents of the University of California. All rights reserved. + * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -29,7 +29,10 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ +#define YASM_LIB_INTERNAL #include "util.h" +/*@unused@*/ RCSID("$Id$"); + #ifndef USE_OUR_OWN_STRCASECMP #undef yasm__strcasecmp @@ -37,7 +40,7 @@ #endif #if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)strcasecmp.c 8.1 (Berkeley) 6/4/93"; +static char sccsid[] = "@(#)strcasecmp.c 8.1 (Berkeley) 6/4/93"; #endif /* LIBC_SCCS and not lint */ #include @@ -54,14 +57,14 @@ yasm__strcasecmp(const char *s1, const char *s2) #elif HAVE_STRCMPI return strcmpi(s1, s2); #else - const unsigned char - *us1 = (const unsigned char *)s1, - *us2 = (const unsigned char *)s2; + const unsigned char + *us1 = (const unsigned char *)s1, + *us2 = (const unsigned char *)s2; - while (tolower(*us1) == tolower(*us2++)) - if (*us1++ == '\0') - return (0); - return (tolower(*us1) - tolower(*--us2)); + while (tolower(*us1) == tolower(*us2++)) + if (*us1++ == '\0') + return (0); + return (tolower(*us1) - tolower(*--us2)); #endif } @@ -77,18 +80,18 @@ yasm__strncasecmp(const char *s1, const char *s2, size_t n) #elif HAVE_STRCMPI return strncmpi(s1, s2, n); #else - const unsigned char - *us1 = (const unsigned char *)s1, - *us2 = (const unsigned char *)s2; + const unsigned char + *us1 = (const unsigned char *)s1, + *us2 = (const unsigned char *)s2; - if (n != 0) { - do { - if (tolower(*us1) != tolower(*us2++)) - return (tolower(*us1) - tolower(*--us2)); - if (*us1++ == '\0') - break; - } while (--n != 0); - } - return (0); + if (n != 0) { + do { + if (tolower(*us1) != tolower(*us2++)) + return (tolower(*us1) - tolower(*--us2)); + if (*us1++ == '\0') + break; + } while (--n != 0); + } + return (0); #endif } diff --git a/libyasm/strsep.c b/libyasm/strsep.c index 0fecd475..28e261f0 100644 --- a/libyasm/strsep.c +++ b/libyasm/strsep.c @@ -2,7 +2,7 @@ * strsep() implementation for systems that don't have it. * * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. + * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -28,12 +28,14 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ +#define YASM_LIB_INTERNAL #define NO_STRING_INLINES #include "util.h" +/*@unused@*/ RCSID("$Id$"); #if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)strsep.c 8.1 (Berkeley) 6/4/93"; +static char sccsid[] = "@(#)strsep.c 8.1 (Berkeley) 6/4/93"; #endif /* LIBC_SCCS and not lint */ #ifdef HAVE_STRSEP @@ -58,28 +60,28 @@ yasm__strsep(char **stringp, const char *delim) #ifdef HAVE_STRSEP return strsep(stringp, delim); #else - register char *s; - register const char *spanp; - register int c, sc; - char *tok; + register char *s; + register const char *spanp; + register int c, sc; + char *tok; - if ((s = *stringp) == NULL) - return (NULL); - for (tok = s;;) { - c = *s++; - spanp = delim; - do { - if ((sc = *spanp++) == c) { - if (c == 0) - s = NULL; - else - s[-1] = 0; - *stringp = s; - return (tok); - } - } while (sc != 0); - } - /* NOTREACHED */ + if ((s = *stringp) == NULL) + return (NULL); + for (tok = s;;) { + c = *s++; + spanp = delim; + do { + if ((sc = *spanp++) == c) { + if (c == 0) + s = NULL; + else + s[-1] = 0; + *stringp = s; + return (tok); + } + } while (sc != 0); + } + /* NOTREACHED */ #endif } /*@=nullstate@*/ diff --git a/libyasm/symrec.c b/libyasm/symrec.c index 694f0c67..9f51afd2 100644 --- a/libyasm/symrec.c +++ b/libyasm/symrec.c @@ -24,10 +24,13 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ +#define YASM_LIB_INTERNAL #include "util.h" +/*@unused@*/ RCSID("$Id$"); -#include -#include +#ifdef STDC_HEADERS +# include +#endif #include "libyasm-stdint.h" #include "coretype.h" @@ -47,14 +50,14 @@ typedef enum { - SYM_UNKNOWN, /* for unknown type (COMMON/EXTERN) */ - SYM_EQU, /* for EQU defined symbols (expressions) */ - SYM_LABEL, /* for labels */ - SYM_CURPOS, /* for labels representing the current - assembly position */ - SYM_SPECIAL /* for special symbols that need to be in - the symbol table but otherwise have no - purpose */ + SYM_UNKNOWN, /* for unknown type (COMMON/EXTERN) */ + SYM_EQU, /* for EQU defined symbols (expressions) */ + SYM_LABEL, /* for labels */ + SYM_CURPOS, /* for labels representing the current + assembly position */ + SYM_SPECIAL /* for special symbols that need to be in + the symbol table but otherwise have no + purpose */ } sym_type; struct yasm_symrec { @@ -62,17 +65,15 @@ struct yasm_symrec { sym_type type; yasm_sym_status status; yasm_sym_vis visibility; - unsigned long def_line; /* line where symbol was first defined */ - unsigned long decl_line; /* line where symbol was first declared */ - unsigned long use_line; /* line where symbol was first used */ + unsigned long def_line; /* line where symbol was first defined */ + unsigned long decl_line; /* line where symbol was first declared */ + unsigned long use_line; /* line where symbol was first used */ union { - yasm_expr *expn; /* equ value */ + yasm_expr *expn; /* equ value */ - /* bytecode immediately preceding a label */ - /*@dependent@*/ yasm_bytecode *precbc; + /* bytecode immediately preceding a label */ + /*@dependent@*/ yasm_bytecode *precbc; } value; - unsigned int size; /* 0 if not user-defined */ - const char *segment; /* for segmented systems like DOS */ /* associated data; NULL if none */ /*@null@*/ /*@only@*/ yasm__assoc_data *assoc_data; @@ -89,8 +90,6 @@ struct yasm_symtab { /*@only@*/ HAMT *sym_table; /* Symbols not in the table */ SLIST_HEAD(nontablesymhead_s, non_table_symrec_s) non_table_syms; - - int case_sensitive; }; static void @@ -136,46 +135,30 @@ yasm_symtab_create(void) yasm_symtab *symtab = yasm_xmalloc(sizeof(yasm_symtab)); symtab->sym_table = HAMT_create(0, yasm_internal_error_); SLIST_INIT(&symtab->non_table_syms); - symtab->case_sensitive = 1; return symtab; } -void -yasm_symtab_set_case_sensitive(yasm_symtab *symtab, int sensitive) -{ - symtab->case_sensitive = sensitive; -} - static void symrec_destroy_one(/*@only@*/ void *d) { yasm_symrec *sym = d; yasm_xfree(sym->name); if (sym->type == SYM_EQU && (sym->status & YASM_SYM_VALUED)) - yasm_expr_destroy(sym->value.expn); + yasm_expr_destroy(sym->value.expn); yasm__assoc_data_destroy(sym->assoc_data); yasm_xfree(sym); } static /*@partial@*/ yasm_symrec * -symrec_new_common(/*@keep@*/ char *name, int case_sensitive) +symrec_new_common(/*@keep@*/ char *name) { yasm_symrec *rec = yasm_xmalloc(sizeof(yasm_symrec)); - - if (!case_sensitive) { - char *c; - for (c=name; *c; c++) - *c = tolower(*c); - } - rec->name = name; rec->type = SYM_UNKNOWN; rec->def_line = 0; rec->decl_line = 0; rec->use_line = 0; rec->visibility = YASM_SYM_LOCAL; - rec->size = 0; - rec->segment = NULL; rec->assoc_data = NULL; return rec; } @@ -183,26 +166,20 @@ symrec_new_common(/*@keep@*/ char *name, int case_sensitive) static /*@partial@*/ /*@dependent@*/ yasm_symrec * symtab_get_or_new_in_table(yasm_symtab *symtab, /*@only@*/ char *name) { - yasm_symrec *rec = symrec_new_common(name, symtab->case_sensitive); + yasm_symrec *rec = symrec_new_common(name); int replace = 0; rec->status = YASM_SYM_NOSTATUS; - if (!symtab->case_sensitive) { - char *c; - for (c=name; *c; c++) - *c = tolower(*c); - } - return HAMT_insert(symtab->sym_table, name, rec, &replace, - symrec_destroy_one); + symrec_destroy_one); } static /*@partial@*/ /*@dependent@*/ yasm_symrec * symtab_get_or_new_not_in_table(yasm_symtab *symtab, /*@only@*/ char *name) { non_table_symrec *sym = yasm_xmalloc(sizeof(non_table_symrec)); - sym->rec = symrec_new_common(name, symtab->case_sensitive); + sym->rec = symrec_new_common(name); sym->rec->status = YASM_SYM_NOTINTABLE; @@ -219,15 +196,15 @@ symtab_get_or_new(yasm_symtab *symtab, const char *name, int in_table) char *symname = yasm__xstrdup(name); if (in_table) - return symtab_get_or_new_in_table(symtab, symname); + return symtab_get_or_new_in_table(symtab, symname); else - return symtab_get_or_new_not_in_table(symtab, symname); + return symtab_get_or_new_not_in_table(symtab, symname); } /*@=freshtrans =mustfree@*/ int yasm_symtab_traverse(yasm_symtab *symtab, void *d, - int (*func) (yasm_symrec *sym, void *d)) + int (*func) (yasm_symrec *sym, void *d)) { return HAMT_traverse(symtab->sym_table, d, (int (*) (void *, void *))func); } @@ -259,7 +236,7 @@ yasm_symtab_abs_sym(yasm_symtab *symtab) rec->use_line = 0; rec->type = SYM_EQU; rec->value.expn = - yasm_expr_create_ident(yasm_expr_int(yasm_intnum_create_uint(0)), 0); + yasm_expr_create_ident(yasm_expr_int(yasm_intnum_create_uint(0)), 0); rec->status |= YASM_SYM_DEFINED|YASM_SYM_VALUED|YASM_SYM_USED; return rec; } @@ -269,7 +246,7 @@ yasm_symtab_use(yasm_symtab *symtab, const char *name, unsigned long line) { yasm_symrec *rec = symtab_get_or_new(symtab, name, 1); if (rec->use_line == 0) - rec->use_line = line; /* set line number of first use */ + rec->use_line = line; /* set line number of first use */ rec->status |= YASM_SYM_USED; return rec; } @@ -277,51 +254,39 @@ yasm_symtab_use(yasm_symtab *symtab, const char *name, unsigned long line) yasm_symrec * yasm_symtab_get(yasm_symtab *symtab, const char *name) { - if (!symtab->case_sensitive) { - char *_name = yasm__xstrdup(name); - char *c; - yasm_symrec *ret; - for (c=_name; *c; c++) - *c = tolower(*c); - ret = HAMT_search(symtab->sym_table, _name); - yasm_xfree(_name); - return ret; - } else - return HAMT_search(symtab->sym_table, name); + return HAMT_search(symtab->sym_table, name); } static /*@dependent@*/ yasm_symrec * symtab_define(yasm_symtab *symtab, const char *name, sym_type type, - int in_table, unsigned long line) + int in_table, unsigned long line) { yasm_symrec *rec = symtab_get_or_new(symtab, name, in_table); /* Has it been defined before (either by DEFINED or COMMON/EXTERN)? */ if (rec->status & YASM_SYM_DEFINED) { - yasm_error_set_xref(rec->def_line!=0 ? rec->def_line : rec->decl_line, - N_("`%s' previously defined here"), name); - yasm_error_set(YASM_ERROR_GENERAL, N_("redefinition of `%s'"), - name); + yasm_error_set_xref(rec->def_line!=0 ? rec->def_line : rec->decl_line, + N_("`%s' previously defined here"), name); + yasm_error_set(YASM_ERROR_GENERAL, N_("redefinition of `%s'"), + name); } else { - if (rec->visibility & YASM_SYM_EXTERN) - yasm_warn_set(YASM_WARN_GENERAL, - N_("`%s' both defined and declared extern"), name); - rec->def_line = line; /* set line number of definition */ - rec->type = type; - rec->status |= YASM_SYM_DEFINED; - rec->size = 0; - rec->segment = NULL; + if (rec->visibility & YASM_SYM_EXTERN) + yasm_warn_set(YASM_WARN_GENERAL, + N_("`%s' both defined and declared extern"), name); + rec->def_line = line; /* set line number of definition */ + rec->type = type; + rec->status |= YASM_SYM_DEFINED; } return rec; } yasm_symrec * yasm_symtab_define_equ(yasm_symtab *symtab, const char *name, yasm_expr *e, - unsigned long line) + unsigned long line) { yasm_symrec *rec = symtab_define(symtab, name, SYM_EQU, 1, line); if (yasm_error_occurred()) - return rec; + return rec; rec->value.expn = e; rec->status |= YASM_SYM_VALUED; return rec; @@ -329,36 +294,36 @@ yasm_symtab_define_equ(yasm_symtab *symtab, const char *name, yasm_expr *e, yasm_symrec * yasm_symtab_define_label(yasm_symtab *symtab, const char *name, - yasm_bytecode *precbc, int in_table, - unsigned long line) + yasm_bytecode *precbc, int in_table, + unsigned long line) { yasm_symrec *rec = symtab_define(symtab, name, SYM_LABEL, in_table, line); if (yasm_error_occurred()) - return rec; + return rec; rec->value.precbc = precbc; if (in_table && precbc) - yasm_bc__add_symrec(precbc, rec); + yasm_bc__add_symrec(precbc, rec); return rec; } yasm_symrec * yasm_symtab_define_curpos(yasm_symtab *symtab, const char *name, - yasm_bytecode *precbc, unsigned long line) + yasm_bytecode *precbc, unsigned long line) { yasm_symrec *rec = symtab_define(symtab, name, SYM_CURPOS, 0, line); if (yasm_error_occurred()) - return rec; + return rec; rec->value.precbc = precbc; return rec; } yasm_symrec * yasm_symtab_define_special(yasm_symtab *symtab, const char *name, - yasm_sym_vis vis) + yasm_sym_vis vis) { yasm_symrec *rec = symtab_define(symtab, name, SYM_SPECIAL, 1, 0); if (yasm_error_occurred()) - return rec; + return rec; rec->status |= YASM_SYM_VALUED; rec->visibility = vis; return rec; @@ -366,7 +331,7 @@ yasm_symtab_define_special(yasm_symtab *symtab, const char *name, yasm_symrec * yasm_symtab_declare(yasm_symtab *symtab, const char *name, yasm_sym_vis vis, - unsigned long line) + unsigned long line) { yasm_symrec *rec = symtab_get_or_new(symtab, name, 1); yasm_symrec_declare(rec, vis, line); @@ -388,16 +353,16 @@ yasm_symrec_declare(yasm_symrec *rec, yasm_sym_vis vis, unsigned long line) * X 1 - 1 - */ if ((vis == YASM_SYM_GLOBAL) || - (!(rec->status & YASM_SYM_DEFINED) && - (!(rec->visibility & (YASM_SYM_COMMON | YASM_SYM_EXTERN)) || - ((rec->visibility & YASM_SYM_COMMON) && (vis == YASM_SYM_COMMON)) || - ((rec->visibility & YASM_SYM_EXTERN) && (vis == YASM_SYM_EXTERN))))) { - rec->decl_line = line; - rec->visibility |= vis; + (!(rec->status & YASM_SYM_DEFINED) && + (!(rec->visibility & (YASM_SYM_COMMON | YASM_SYM_EXTERN)) || + ((rec->visibility & YASM_SYM_COMMON) && (vis == YASM_SYM_COMMON)) || + ((rec->visibility & YASM_SYM_EXTERN) && (vis == YASM_SYM_EXTERN))))) { + rec->decl_line = line; + rec->visibility |= vis; } else - yasm_error_set(YASM_ERROR_GENERAL, - N_("duplicate definition of `%s'; first defined on line %lu"), - rec->name, rec->def_line!=0 ? rec->def_line : rec->decl_line); + yasm_error_set(YASM_ERROR_GENERAL, + N_("duplicate definition of `%s'; first defined on line %lu"), + rec->name, rec->def_line!=0 ? rec->def_line : rec->decl_line); } typedef struct symtab_finalize_info { @@ -413,16 +378,16 @@ symtab_parser_finalize_checksym(yasm_symrec *sym, /*@null@*/ void *d) /* error if a symbol is used but never defined or extern/common declared */ if ((sym->status & YASM_SYM_USED) && !(sym->status & YASM_SYM_DEFINED) && - !(sym->visibility & (YASM_SYM_EXTERN | YASM_SYM_COMMON))) { - if (info->undef_extern) - sym->visibility |= YASM_SYM_EXTERN; - else { - yasm_error_set(YASM_ERROR_GENERAL, - N_("undefined symbol `%s' (first use)"), sym->name); - yasm_errwarn_propagate(info->errwarns, sym->use_line); - if (sym->use_line < info->firstundef_line) - info->firstundef_line = sym->use_line; - } + !(sym->visibility & (YASM_SYM_EXTERN | YASM_SYM_COMMON))) { + if (info->undef_extern) + sym->visibility |= YASM_SYM_EXTERN; + else { + yasm_error_set(YASM_ERROR_GENERAL, + N_("undefined symbol `%s' (first use)"), sym->name); + yasm_errwarn_propagate(info->errwarns, sym->use_line); + if (sym->use_line < info->firstundef_line) + info->firstundef_line = sym->use_line; + } } return 0; @@ -430,7 +395,7 @@ symtab_parser_finalize_checksym(yasm_symrec *sym, /*@null@*/ void *d) void yasm_symtab_parser_finalize(yasm_symtab *symtab, int undef_extern, - yasm_errwarns *errwarns) + yasm_errwarns *errwarns) { symtab_finalize_info info; info.firstundef_line = ULONG_MAX; @@ -438,9 +403,9 @@ yasm_symtab_parser_finalize(yasm_symtab *symtab, int undef_extern, info.errwarns = errwarns; yasm_symtab_traverse(symtab, &info, symtab_parser_finalize_checksym); if (info.firstundef_line < ULONG_MAX) { - yasm_error_set(YASM_ERROR_GENERAL, - N_(" (Each undefined symbol is reported only once.)")); - yasm_errwarn_propagate(errwarns, info.firstundef_line); + yasm_error_set(YASM_ERROR_GENERAL, + N_(" (Each undefined symbol is reported only once.)")); + yasm_errwarn_propagate(errwarns, info.firstundef_line); } } @@ -450,10 +415,10 @@ yasm_symtab_destroy(yasm_symtab *symtab) HAMT_destroy(symtab->sym_table, symrec_destroy_one); while (!SLIST_EMPTY(&symtab->non_table_syms)) { - non_table_symrec *sym = SLIST_FIRST(&symtab->non_table_syms); - SLIST_REMOVE_HEAD(&symtab->non_table_syms, link); - symrec_destroy_one(sym->rec); - yasm_xfree(sym); + non_table_symrec *sym = SLIST_FIRST(&symtab->non_table_syms); + SLIST_REMOVE_HEAD(&symtab->non_table_syms, link); + symrec_destroy_one(sym->rec); + yasm_xfree(sym); } yasm_xfree(symtab); @@ -491,21 +456,6 @@ yasm_symrec_get_name(const yasm_symrec *sym) return sym->name; } -char * -yasm_symrec_get_global_name(const yasm_symrec *sym, const yasm_object *object) -{ - if (sym->visibility & (YASM_SYM_GLOBAL|YASM_SYM_COMMON|YASM_SYM_EXTERN)) { - char *name = yasm_xmalloc(strlen(object->global_prefix) + - strlen(sym->name) + - strlen(object->global_suffix) + 1); - strcpy(name, object->global_prefix); - strcat(name, sym->name); - strcat(name, object->global_suffix); - return name; - } - return yasm__xstrdup(sym->name); -} - yasm_sym_vis yasm_symrec_get_visibility(const yasm_symrec *sym) { @@ -540,52 +490,28 @@ const yasm_expr * yasm_symrec_get_equ(const yasm_symrec *sym) { if (sym->type == SYM_EQU && (sym->status & YASM_SYM_VALUED)) - return sym->value.expn; + return sym->value.expn; return (const yasm_expr *)NULL; } int yasm_symrec_get_label(const yasm_symrec *sym, - yasm_symrec_get_label_bytecodep *precbc) + yasm_symrec_get_label_bytecodep *precbc) { if (!(sym->type == SYM_LABEL || sym->type == SYM_CURPOS) - || !sym->value.precbc) { - *precbc = (yasm_symrec_get_label_bytecodep)0xDEADBEEF; - return 0; + || !sym->value.precbc) { + *precbc = (yasm_symrec_get_label_bytecodep)0xDEADBEEF; + return 0; } *precbc = sym->value.precbc; return 1; } -void -yasm_symrec_set_size(yasm_symrec *sym, int size) -{ - sym->size = size; -} - -int -yasm_symrec_get_size(const yasm_symrec *sym) -{ - return sym->size; -} - -void -yasm_symrec_set_segment(yasm_symrec *sym, const char *segment) -{ - sym->segment = segment; -} - -const char * -yasm_symrec_get_segment(const yasm_symrec *sym) -{ - return sym->segment; -} - int yasm_symrec_is_abs(const yasm_symrec *sym) { return (sym->def_line == 0 && sym->type == SYM_EQU && - sym->name[0] == '\0'); + sym->name[0] == '\0'); } int @@ -602,7 +528,7 @@ yasm_symrec_is_curpos(const yasm_symrec *sym) void yasm_symrec_set_objext_valparams(yasm_symrec *sym, - /*@only@*/ yasm_valparamhead *objext_valparams) + /*@only@*/ yasm_valparamhead *objext_valparams) { yasm_symrec_add_data(sym, &objext_valparams_cb, objext_valparams); } @@ -615,7 +541,7 @@ yasm_symrec_get_objext_valparams(yasm_symrec *sym) void yasm_symrec_set_common_size(yasm_symrec *sym, - /*@only@*/ yasm_expr *common_size) + /*@only@*/ yasm_expr *common_size) { yasm_expr **ep = yasm_xmalloc(sizeof(yasm_expr *)); *ep = common_size; @@ -630,14 +556,14 @@ yasm_symrec_get_common_size(yasm_symrec *sym) void * yasm_symrec_get_data(yasm_symrec *sym, - const yasm_assoc_data_callback *callback) + const yasm_assoc_data_callback *callback) { return yasm__assoc_data_get(sym->assoc_data, callback); } void yasm_symrec_add_data(yasm_symrec *sym, - const yasm_assoc_data_callback *callback, void *data) + const yasm_assoc_data_callback *callback, void *data) { sym->assoc_data = yasm__assoc_data_add(sym->assoc_data, callback, data); } @@ -646,69 +572,69 @@ void yasm_symrec_print(const yasm_symrec *sym, FILE *f, int indent_level) { switch (sym->type) { - case SYM_UNKNOWN: - fprintf(f, "%*s-Unknown (Common/Extern)-\n", indent_level, ""); - break; - case SYM_EQU: - fprintf(f, "%*s_EQU_\n", indent_level, ""); - fprintf(f, "%*sExpn=", indent_level, ""); - if (sym->status & YASM_SYM_VALUED) - yasm_expr_print(sym->value.expn, f); - else - fprintf(f, "***UNVALUED***"); - fprintf(f, "\n"); - break; - case SYM_LABEL: - case SYM_CURPOS: - fprintf(f, "%*s_%s_\n%*sSection:\n", indent_level, "", - sym->type == SYM_LABEL ? "Label" : "CurPos", - indent_level, ""); - yasm_section_print(yasm_bc_get_section(sym->value.precbc), f, - indent_level+1, 0); - fprintf(f, "%*sPreceding bytecode:\n", indent_level, ""); - yasm_bc_print(sym->value.precbc, f, indent_level+1); - break; - case SYM_SPECIAL: - fprintf(f, "%*s-Special-\n", indent_level, ""); - break; + case SYM_UNKNOWN: + fprintf(f, "%*s-Unknown (Common/Extern)-\n", indent_level, ""); + break; + case SYM_EQU: + fprintf(f, "%*s_EQU_\n", indent_level, ""); + fprintf(f, "%*sExpn=", indent_level, ""); + if (sym->status & YASM_SYM_VALUED) + yasm_expr_print(sym->value.expn, f); + else + fprintf(f, "***UNVALUED***"); + fprintf(f, "\n"); + break; + case SYM_LABEL: + case SYM_CURPOS: + fprintf(f, "%*s_%s_\n%*sSection:\n", indent_level, "", + sym->type == SYM_LABEL ? "Label" : "CurPos", + indent_level, ""); + yasm_section_print(yasm_bc_get_section(sym->value.precbc), f, + indent_level+1, 0); + fprintf(f, "%*sPreceding bytecode:\n", indent_level, ""); + yasm_bc_print(sym->value.precbc, f, indent_level+1); + break; + case SYM_SPECIAL: + fprintf(f, "%*s-Special-\n", indent_level, ""); + break; } fprintf(f, "%*sStatus=", indent_level, ""); if (sym->status == YASM_SYM_NOSTATUS) - fprintf(f, "None\n"); + fprintf(f, "None\n"); else { - if (sym->status & YASM_SYM_USED) - fprintf(f, "Used,"); - if (sym->status & YASM_SYM_DEFINED) - fprintf(f, "Defined,"); - if (sym->status & YASM_SYM_VALUED) - fprintf(f, "Valued,"); - if (sym->status & YASM_SYM_NOTINTABLE) - fprintf(f, "Not in Table,"); - fprintf(f, "\n"); + if (sym->status & YASM_SYM_USED) + fprintf(f, "Used,"); + if (sym->status & YASM_SYM_DEFINED) + fprintf(f, "Defined,"); + if (sym->status & YASM_SYM_VALUED) + fprintf(f, "Valued,"); + if (sym->status & YASM_SYM_NOTINTABLE) + fprintf(f, "Not in Table,"); + fprintf(f, "\n"); } fprintf(f, "%*sVisibility=", indent_level, ""); if (sym->visibility == YASM_SYM_LOCAL) - fprintf(f, "Local\n"); + fprintf(f, "Local\n"); else { - if (sym->visibility & YASM_SYM_GLOBAL) - fprintf(f, "Global,"); - if (sym->visibility & YASM_SYM_COMMON) - fprintf(f, "Common,"); - if (sym->visibility & YASM_SYM_EXTERN) - fprintf(f, "Extern,"); - fprintf(f, "\n"); + if (sym->visibility & YASM_SYM_GLOBAL) + fprintf(f, "Global,"); + if (sym->visibility & YASM_SYM_COMMON) + fprintf(f, "Common,"); + if (sym->visibility & YASM_SYM_EXTERN) + fprintf(f, "Extern,"); + fprintf(f, "\n"); } if (sym->assoc_data) { - fprintf(f, "%*sAssociated data:\n", indent_level, ""); - yasm__assoc_data_print(sym->assoc_data, f, indent_level+1); + fprintf(f, "%*sAssociated data:\n", indent_level, ""); + yasm__assoc_data_print(sym->assoc_data, f, indent_level+1); } fprintf(f, "%*sLine Index (Defined)=%lu\n", indent_level, "", - sym->def_line); + sym->def_line); fprintf(f, "%*sLine Index (Declared)=%lu\n", indent_level, "", - sym->decl_line); + sym->decl_line); fprintf(f, "%*sLine Index (Used)=%lu\n", indent_level, "", sym->use_line); } diff --git a/libyasm/symrec.h b/libyasm/symrec.h index b1f797c6..0426bc82 100644 --- a/libyasm/symrec.h +++ b/libyasm/symrec.h @@ -2,6 +2,10 @@ * \file libyasm/symrec.h * \brief YASM symbol table interface. * + * \rcs + * $Id$ + * \endrcs + * * \license * Copyright (C) 2001-2007 Michael Urman, Peter Johnson * @@ -30,19 +34,15 @@ #ifndef YASM_SYMREC_H #define YASM_SYMREC_H -#ifndef YASM_LIB_DECL -#define YASM_LIB_DECL -#endif - /** Symbol status. YASM_SYM_DEFINED is set by yasm_symtab_define_label(), * yasm_symtab_define_equ(), or yasm_symtab_declare()/yasm_symrec_declare() * with a visibility of #YASM_SYM_EXTERN or #YASM_SYM_COMMON. */ typedef enum yasm_sym_status { - YASM_SYM_NOSTATUS = 0, /**< no status */ - YASM_SYM_USED = 1 << 0, /**< for use before definition */ - YASM_SYM_DEFINED = 1 << 1, /**< once it's been defined in the file */ - YASM_SYM_VALUED = 1 << 2, /**< once its value has been determined */ + YASM_SYM_NOSTATUS = 0, /**< no status */ + YASM_SYM_USED = 1 << 0, /**< for use before definition */ + YASM_SYM_DEFINED = 1 << 1, /**< once it's been defined in the file */ + YASM_SYM_VALUED = 1 << 2, /**< once its value has been determined */ YASM_SYM_NOTINTABLE = 1 << 3 /**< if it's not in sym_table (ex. '$') */ } yasm_sym_status; @@ -50,15 +50,14 @@ typedef enum yasm_sym_status { * \note YASM_SYM_EXTERN and YASM_SYM_COMMON are mutually exclusive. */ typedef enum yasm_sym_vis { - YASM_SYM_LOCAL = 0, /**< Default, local only */ - YASM_SYM_GLOBAL = 1 << 0, /**< If symbol is declared GLOBAL */ - YASM_SYM_COMMON = 1 << 1, /**< If symbol is declared COMMON */ - YASM_SYM_EXTERN = 1 << 2, /**< If symbol is declared EXTERN */ - YASM_SYM_DLOCAL = 1 << 3 /**< If symbol is explicitly declared LOCAL */ + YASM_SYM_LOCAL = 0, /**< Default, local only */ + YASM_SYM_GLOBAL = 1 << 0, /**< If symbol is declared GLOBAL */ + YASM_SYM_COMMON = 1 << 1, /**< If symbol is declared COMMON */ + YASM_SYM_EXTERN = 1 << 2, /**< If symbol is declared EXTERN */ + YASM_SYM_DLOCAL = 1 << 3 /**< If symbol is explicitly declared LOCAL */ } yasm_sym_vis; /** Create a new symbol table. */ -YASM_LIB_DECL yasm_symtab *yasm_symtab_create(void); /** Destroy a symbol table and all internal symbols. @@ -66,17 +65,8 @@ yasm_symtab *yasm_symtab_create(void); * \warning All yasm_symrec *'s into this symbol table become invalid after * this is called! */ -YASM_LIB_DECL void yasm_symtab_destroy(/*@only@*/ yasm_symtab *symtab); -/** Set the symbol table to be case sensitive or not. - * Should be called before adding any symbol. - * \param symtab symbol table - * \param sensitive whether the symbol table should be case sensitive. - */ -YASM_LIB_DECL -void yasm_symtab_set_case_sensitive(yasm_symtab *symtab, int sensitive); - /** Get a reference to the symbol table's "absolute" symbol. This is * essentially an EQU with no name and value 0, and is used for relocating * absolute current-position-relative values. @@ -84,17 +74,15 @@ void yasm_symtab_set_case_sensitive(yasm_symtab *symtab, int sensitive); * \param symtab symbol table * \return Absolute symbol (dependent pointer, do not free). */ -YASM_LIB_DECL /*@dependent@*/ yasm_symrec *yasm_symtab_abs_sym(yasm_symtab *symtab); /** Get a reference to (use) a symbol. The symbol does not necessarily need to * be defined before it is used. * \param symtab symbol table - * \param name symbol name + * \param name symbol name * \param line virtual line where referenced * \return Symbol (dependent pointer, do not free). */ -YASM_LIB_DECL /*@dependent@*/ yasm_symrec *yasm_symtab_use (yasm_symtab *symtab, const char *name, unsigned long line); @@ -102,36 +90,33 @@ YASM_LIB_DECL * when an internal assembler usage of a symbol shouldn't be treated like a * normal user symbol usage. * \param symtab symbol table - * \param name symbol name + * \param name symbol name * \return Symbol (dependent pointer, do not free). May be NULL if symbol * doesn't exist. */ -YASM_LIB_DECL /*@null@*/ /*@dependent@*/ yasm_symrec *yasm_symtab_get (yasm_symtab *symtab, const char *name); /** Define a symbol as an EQU value. * \param symtab symbol table - * \param name symbol (EQU) name - * \param e EQU value (expression) + * \param name symbol (EQU) name + * \param e EQU value (expression) * \param line virtual line of EQU * \return Symbol (dependent pointer, do not free). */ -YASM_LIB_DECL /*@dependent@*/ yasm_symrec *yasm_symtab_define_equ (yasm_symtab *symtab, const char *name, /*@keep@*/ yasm_expr *e, unsigned long line); /** Define a symbol as a label. * \param symtab symbol table - * \param name symbol (label) name + * \param name symbol (label) name * \param precbc bytecode preceding label * \param in_table nonzero if the label should be inserted into the symbol * table (some specially-generated ones should not be) - * \param line virtual line of label + * \param line virtual line of label * \return Symbol (dependent pointer, do not free). */ -YASM_LIB_DECL /*@dependent@*/ yasm_symrec *yasm_symtab_define_label (yasm_symtab *symtab, const char *name, /*@dependent@*/ yasm_bytecode *precbc, int in_table, unsigned long line); @@ -141,12 +126,11 @@ YASM_LIB_DECL * as value_finalize_scan() looks for usage of this symbol type for special * handling. The symbol created is not inserted into the symbol table. * \param symtab symbol table - * \param name symbol (label) name + * \param name symbol (label) name * \param precbc bytecode preceding label - * \param line virtual line of label + * \param line virtual line of label * \return Symbol (dependent pointer, do not free). */ -YASM_LIB_DECL /*@dependent@*/ yasm_symrec *yasm_symtab_define_curpos (yasm_symtab *symtab, const char *name, /*@dependent@*/ yasm_bytecode *precbc, unsigned long line); @@ -155,23 +139,21 @@ YASM_LIB_DECL * defined name, but have no other data associated with it within the * standard symrec. * \param symtab symbol table - * \param name symbol name - * \param vis symbol visibility + * \param name symbol name + * \param vis symbol visibility * \return Symbol (dependent pointer, do not free). */ -YASM_LIB_DECL /*@dependent@*/ yasm_symrec *yasm_symtab_define_special (yasm_symtab *symtab, const char *name, yasm_sym_vis vis); /** Declare external visibility of a symbol. * \note Not all visibility combinations are allowed. * \param symtab symbol table - * \param name symbol name - * \param vis visibility + * \param name symbol name + * \param vis visibility * \param line virtual line of visibility-setting * \return Symbol (dependent pointer, do not free). */ -YASM_LIB_DECL /*@dependent@*/ yasm_symrec *yasm_symtab_declare (yasm_symtab *symtab, const char *name, yasm_sym_vis vis, unsigned long line); @@ -179,16 +161,15 @@ YASM_LIB_DECL /** Declare external visibility of a symbol. * \note Not all visibility combinations are allowed. * \param symrec symbol - * \param vis visibility + * \param vis visibility * \param line virtual line of visibility-setting */ -YASM_LIB_DECL void yasm_symrec_declare(yasm_symrec *symrec, yasm_sym_vis vis, - unsigned long line); + unsigned long line); /** Callback function for yasm_symrec_traverse(). - * \param sym symbol - * \param d data passed into yasm_symrec_traverse() + * \param sym symbol + * \param d data passed into yasm_symrec_traverse() * \return Nonzero to stop symbol traversal. */ typedef int (*yasm_symtab_traverse_callback) @@ -196,12 +177,11 @@ typedef int (*yasm_symtab_traverse_callback) /** Traverse all symbols in the symbol table. * \param symtab symbol table - * \param d data to pass to each call of callback function - * \param func callback function called on each symbol + * \param d data to pass to each call of callback function + * \param func callback function called on each symbol * \return Nonzero value returned by callback function if it ever returned * nonzero. */ -YASM_LIB_DECL int /*@alt void@*/ yasm_symtab_traverse (yasm_symtab *symtab, /*@null@*/ void *d, yasm_symtab_traverse_callback func); @@ -213,99 +193,78 @@ typedef struct yasm_symtab_iter yasm_symtab_iter; * \param symtab symbol table * \return Iterator for the symbol table. */ -YASM_LIB_DECL const yasm_symtab_iter *yasm_symtab_first(const yasm_symtab *symtab); /** Move a symbol table iterator to the next symbol in the symbol table. - * \param prev Previous iterator value + * \param prev Previous iterator value * \return Next iterator value, or NULL if no more symbols in the table. */ -YASM_LIB_DECL /*@null@*/ const yasm_symtab_iter *yasm_symtab_next (const yasm_symtab_iter *prev); /** Get the symbol corresponding to the current symbol table iterator value. - * \param cur iterator value + * \param cur iterator value * \return Corresponding symbol. */ -YASM_LIB_DECL yasm_symrec *yasm_symtab_iter_value(const yasm_symtab_iter *cur); /** Finalize symbol table after parsing stage. Checks for symbols that are * used but never defined or declared #YASM_SYM_EXTERN or #YASM_SYM_COMMON. - * \param symtab symbol table - * \param undef_extern if nonzero, all undef syms should be declared extern - * \param errwarns error/warning set + * \param symtab symbol table + * \param undef_extern if nonzero, all undef syms should be declared extern + * \param errwarns error/warning set * \note Errors/warnings are stored into errwarns. */ -YASM_LIB_DECL void yasm_symtab_parser_finalize(yasm_symtab *symtab, int undef_extern, - yasm_errwarns *errwarns); + yasm_errwarns *errwarns); /** Print the symbol table. For debugging purposes. - * \param symtab symbol table - * \param f file - * \param indent_level indentation level + * \param symtab symbol table + * \param f file + * \param indent_level indentation level */ -YASM_LIB_DECL void yasm_symtab_print(yasm_symtab *symtab, FILE *f, int indent_level); /** Get the name of a symbol. - * \param sym symbol + * \param sym symbol * \return Symbol name. */ -YASM_LIB_DECL /*@observer@*/ const char *yasm_symrec_get_name(const yasm_symrec *sym); -/** Get the externally-visible (global) name of a symbol. - * \param sym symbol - * \param object object - * \return Externally-visible symbol name (allocated, caller must free). - */ -YASM_LIB_DECL -/*@only@*/ char *yasm_symrec_get_global_name(const yasm_symrec *sym, - const yasm_object *object); - /** Get the visibility of a symbol. - * \param sym symbol + * \param sym symbol * \return Symbol visibility. */ -YASM_LIB_DECL yasm_sym_vis yasm_symrec_get_visibility(const yasm_symrec *sym); /** Get the status of a symbol. - * \param sym symbol + * \param sym symbol * \return Symbol status. */ -YASM_LIB_DECL yasm_sym_status yasm_symrec_get_status(const yasm_symrec *sym); /** Get the virtual line of where a symbol was first defined. - * \param sym symbol - * \return line virtual line + * \param sym symbol + * \return line virtual line */ -YASM_LIB_DECL unsigned long yasm_symrec_get_def_line(const yasm_symrec *sym); /** Get the virtual line of where a symbol was first declared. - * \param sym symbol - * \return line virtual line + * \param sym symbol + * \return line virtual line */ -YASM_LIB_DECL unsigned long yasm_symrec_get_decl_line(const yasm_symrec *sym); /** Get the virtual line of where a symbol was first used. - * \param sym symbol - * \return line virtual line + * \param sym symbol + * \return line virtual line */ -YASM_LIB_DECL unsigned long yasm_symrec_get_use_line(const yasm_symrec *sym); /** Get EQU value of a symbol. - * \param sym symbol + * \param sym symbol * \return EQU value, or NULL if symbol is not an EQU or is not defined. */ -YASM_LIB_DECL /*@observer@*/ /*@null@*/ const yasm_expr *yasm_symrec_get_equ (const yasm_symrec *sym); @@ -313,125 +272,86 @@ YASM_LIB_DECL typedef /*@dependent@*/ yasm_bytecode *yasm_symrec_get_label_bytecodep; /** Get the label location of a symbol. - * \param sym symbol + * \param sym symbol * \param precbc bytecode preceding label (output) * \return 0 if not symbol is not a label or if the symbol's visibility is * #YASM_SYM_EXTERN or #YASM_SYM_COMMON (not defined in the file). */ -YASM_LIB_DECL int yasm_symrec_get_label(const yasm_symrec *sym, - /*@out@*/ yasm_symrec_get_label_bytecodep *precbc); - -/** Set the size of a symbol. - * \param sym symbol - * \param size size to be set - */ -YASM_LIB_DECL -void yasm_symrec_set_size(yasm_symrec *sym, int size); - -/** Get the size of a symbol. - * \param sym symbol - * \return size of the symbol, 0 if none specified by the user. - */ -YASM_LIB_DECL -int yasm_symrec_get_size(const yasm_symrec *sym); - -/** Set the segment of a symbol. - * \param sym symbol - * \param segment segment to be set - */ -YASM_LIB_DECL -void yasm_symrec_set_segment(yasm_symrec *sym, const char *segment); - -/** Get the segment of a symbol. - * \param sym symbol - * \return segment of the symbol, NULL if none specified by the user. - */ -YASM_LIB_DECL -const char *yasm_symrec_get_segment(const yasm_symrec *sym); + /*@out@*/ yasm_symrec_get_label_bytecodep *precbc); /** Determine if symbol is the "absolute" symbol created by * yasm_symtab_abs_sym(). - * \param sym symbol + * \param sym symbol * \return 0 if symbol is not the "absolute" symbol, nonzero otherwise. */ -YASM_LIB_DECL int yasm_symrec_is_abs(const yasm_symrec *sym); /** Determine if symbol is a special symbol. - * \param sym symbol + * \param sym symbol * \return 0 if symbol is not a special symbol, nonzero otherwise. */ -YASM_LIB_DECL int yasm_symrec_is_special(const yasm_symrec *sym); /** Determine if symbol is a label representing the current assembly position. - * \param sym symbol + * \param sym symbol * \return 0 if symbol is not a current position label, nonzero otherwise. */ -YASM_LIB_DECL int yasm_symrec_is_curpos(const yasm_symrec *sym); /** Set object-extended valparams. - * \param sym symbol - * \param objext_valparams object-extended valparams + * \param sym symbol + * \param objext_valparams object-extended valparams */ -YASM_LIB_DECL void yasm_symrec_set_objext_valparams (yasm_symrec *sym, /*@only@*/ yasm_valparamhead *objext_valparams); /** Get object-extended valparams, if any, associated with symbol's * declaration. - * \param sym symbol + * \param sym symbol * \return Object-extended valparams (NULL if none). */ -YASM_LIB_DECL /*@null@*/ /*@dependent@*/ yasm_valparamhead *yasm_symrec_get_objext_valparams (yasm_symrec *sym); /** Set common size of symbol. - * \param sym symbol - * \param common_size common size expression + * \param sym symbol + * \param common_size common size expression */ -YASM_LIB_DECL void yasm_symrec_set_common_size (yasm_symrec *sym, /*@only@*/ yasm_expr *common_size); /** Get common size of symbol, if symbol is declared COMMON and a size was set * for it. - * \param sym symbol + * \param sym symbol * \return Common size (NULL if none). */ -YASM_LIB_DECL /*@dependent@*/ /*@null@*/ yasm_expr **yasm_symrec_get_common_size (yasm_symrec *sym); /** Get associated data for a symbol and data callback. - * \param sym symbol + * \param sym symbol * \param callback callback used when adding data * \return Associated data (NULL if none). */ -YASM_LIB_DECL /*@dependent@*/ /*@null@*/ void *yasm_symrec_get_data (yasm_symrec *sym, const yasm_assoc_data_callback *callback); /** Add associated data to a symbol. * \attention Deletes any existing associated data for that data callback. - * \param sym symbol + * \param sym symbol * \param callback callback - * \param data data to associate + * \param data data to associate */ -YASM_LIB_DECL void yasm_symrec_add_data(yasm_symrec *sym, - const yasm_assoc_data_callback *callback, - /*@only@*/ /*@null@*/ void *data); + const yasm_assoc_data_callback *callback, + /*@only@*/ /*@null@*/ void *data); /** Print a symbol. For debugging purposes. - * \param f file - * \param indent_level indentation level - * \param sym symbol + * \param f file + * \param indent_level indentation level + * \param sym symbol */ -YASM_LIB_DECL void yasm_symrec_print(const yasm_symrec *sym, FILE *f, int indent_level); #endif diff --git a/libyasm/tests/1shl0.asm b/libyasm/tests/1shl0.asm deleted file mode 100644 index d69930ad..00000000 --- a/libyasm/tests/1shl0.asm +++ /dev/null @@ -1 +0,0 @@ -dd (1<<0) diff --git a/libyasm/tests/1shl0.hex b/libyasm/tests/1shl0.hex deleted file mode 100644 index 607fb55a..00000000 --- a/libyasm/tests/1shl0.hex +++ /dev/null @@ -1,4 +0,0 @@ -01 -00 -00 -00 diff --git a/libyasm/tests/Makefile.inc b/libyasm/tests/Makefile.inc index 9c038a14..1528ef68 100644 --- a/libyasm/tests/Makefile.inc +++ b/libyasm/tests/Makefile.inc @@ -1,3 +1,5 @@ +# $Id$ + TESTS += bitvect_test TESTS += floatnum_test TESTS += leb128_test @@ -7,8 +9,6 @@ TESTS += uncstring_test TESTS += libyasm/tests/libyasm_test.sh EXTRA_DIST += libyasm/tests/libyasm_test.sh -EXTRA_DIST += libyasm/tests/1shl0.asm -EXTRA_DIST += libyasm/tests/1shl0.hex EXTRA_DIST += libyasm/tests/absloop-err.asm EXTRA_DIST += libyasm/tests/absloop-err.errwarn EXTRA_DIST += libyasm/tests/charconst64.asm @@ -21,10 +21,6 @@ EXTRA_DIST += libyasm/tests/emptydata.asm EXTRA_DIST += libyasm/tests/emptydata.hex EXTRA_DIST += libyasm/tests/equ-expand.asm EXTRA_DIST += libyasm/tests/equ-expand.hex -EXTRA_DIST += libyasm/tests/expr-fold-level.asm -EXTRA_DIST += libyasm/tests/expr-fold-level.hex -EXTRA_DIST += libyasm/tests/expr-simplify-identity.asm -EXTRA_DIST += libyasm/tests/expr-simplify-identity.hex EXTRA_DIST += libyasm/tests/expr-wide-ident.asm EXTRA_DIST += libyasm/tests/expr-wide-ident.hex EXTRA_DIST += libyasm/tests/externdef.asm @@ -66,8 +62,6 @@ EXTRA_DIST += libyasm/tests/strucsize.asm EXTRA_DIST += libyasm/tests/strucsize.hex EXTRA_DIST += libyasm/tests/times0.asm EXTRA_DIST += libyasm/tests/times0.hex -EXTRA_DIST += libyasm/tests/timesfwd.asm -EXTRA_DIST += libyasm/tests/timesfwd.hex EXTRA_DIST += libyasm/tests/timesover-err.asm EXTRA_DIST += libyasm/tests/timesover-err.errwarn EXTRA_DIST += libyasm/tests/timesunder.asm @@ -79,14 +73,6 @@ EXTRA_DIST += libyasm/tests/unary.asm EXTRA_DIST += libyasm/tests/unary.hex EXTRA_DIST += libyasm/tests/value-err.asm EXTRA_DIST += libyasm/tests/value-err.errwarn -EXTRA_DIST += libyasm/tests/value-samesym.asm -EXTRA_DIST += libyasm/tests/value-samesym.errwarn -EXTRA_DIST += libyasm/tests/value-samesym.hex -EXTRA_DIST += libyasm/tests/value-mask.asm -EXTRA_DIST += libyasm/tests/value-mask.errwarn -EXTRA_DIST += libyasm/tests/value-mask.hex -EXTRA_DIST += libyasm/tests/value-shr-symexpr.asm -EXTRA_DIST += libyasm/tests/value-shr-symexpr.hex check_PROGRAMS += bitvect_test check_PROGRAMS += floatnum_test diff --git a/libyasm/tests/absloop-err.errwarn b/libyasm/tests/absloop-err.errwarn index 29d3a334..79983393 100644 --- a/libyasm/tests/absloop-err.errwarn +++ b/libyasm/tests/absloop-err.errwarn @@ -1 +1 @@ --:6: error: circular reference detected in memory expression +-:6: circular reference detected in memory expression diff --git a/libyasm/tests/bitvect_test.c b/libyasm/tests/bitvect_test.c index b60b7ede..d000b515 100644 --- a/libyasm/tests/bitvect_test.c +++ b/libyasm/tests/bitvect_test.c @@ -1,4 +1,4 @@ -/* +/* $Id$ * * Copyright (C) 2001-2007 Peter Johnson * @@ -23,47 +23,53 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ -#include -#include -#include +#ifdef HAVE_CONFIG_H +# include +#endif + +#ifdef STDC_HEADERS +# include +# include +#endif + +#include -#include "util.h" #include "libyasm/bitvect.h" static int test_boot(void) { if (BitVector_Boot() != ErrCode_Ok) - return 1; + return 1; return 0; } typedef struct Val_s { const char *ascii; - unsigned char result[10]; /* 80 bit result, little endian */ + unsigned char result[10]; /* 80 bit result, little endian */ } Val; Val oct_small_vals[] = { - { "0", - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} + { "0", + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} }, - { "1", - {0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} + { "1", + {0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} }, - { "77", - {0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} + { "77", + {0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} }, }; Val oct_large_vals[] = { - { "7654321076543210", - {0x88, 0xC6, 0xFA, 0x88, 0xC6, 0xFA, 0x00, 0x00, 0x00, 0x00} + { "7654321076543210", + {0x88, 0xC6, 0xFA, 0x88, 0xC6, 0xFA, 0x00, 0x00, 0x00, 0x00} }, - { "12634727612534126530214", - {0x8C, 0xB0, 0x5A, 0xE1, 0xAA, 0xF8, 0x3A, 0x67, 0x05, 0x00} + { "12634727612534126530214", + {0x8C, 0xB0, 0x5A, 0xE1, 0xAA, 0xF8, 0x3A, 0x67, 0x05, 0x00} }, - { "61076543210", - {0x88, 0xC6, 0xFA, 0x88, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00} + { "61076543210", + {0x88, 0xC6, 0xFA, 0x88, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00} }, }; @@ -95,22 +101,22 @@ num_check(Val *val) strcpy((char *)ascii, val->ascii); strcpy(result_msg, "parser failure"); if(BitVector_from_Oct(testval, ascii) != ErrCode_Ok) - return 1; + return 1; result = BitVector_Block_Read(testval, &len); for (i=0; i<10; i++) - if (result[i] != val->result[i]) - ret = 1; + if (result[i] != val->result[i]) + ret = 1; if (ret) { - strcpy(result_msg, val->ascii); - for (i=0; i<10; i++) - sprintf((char *)ascii+3*i, "%02x ", result[i]); - strcat(result_msg, ": "); - strcat(result_msg, (char *)ascii); + strcpy(result_msg, val->ascii); + for (i=0; i<10; i++) + sprintf((char *)ascii+3*i, "%02x ", result[i]); + strcat(result_msg, ": "); + strcat(result_msg, (char *)ascii); } - yasm_xfree(result); + free(result); return ret; } @@ -122,8 +128,8 @@ test_oct_small_num(void) int i, num = sizeof(oct_small_vals)/sizeof(Val); for (i=0; i0 ? 'F':'.'); fflush(stdout); if (nf > 0) - sprintf(failed, "%s ** F: %s failed!\n", failed, testname); + sprintf(failed, "%s ** F: %s failed!\n", failed, testname); return nf; } -#define runtest(x,y,z) runtest_(#x,test_##x,y,z) +#define runtest(x,y,z) runtest_(#x,test_##x,y,z) int main(void) @@ -172,6 +178,6 @@ main(void) nf += runtest(oct_small_num, num_family_setup, num_family_teardown); nf += runtest(oct_large_num, num_family_setup, num_family_teardown); printf(" +%d-%d/3 %d%%\n%s", - 3-nf, nf, 100*(3-nf)/3, failed); + 3-nf, nf, 100*(3-nf)/3, failed); return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE; } diff --git a/libyasm/tests/combpath_test.c b/libyasm/tests/combpath_test.c index 90f2e241..55f3d498 100644 --- a/libyasm/tests/combpath_test.c +++ b/libyasm/tests/combpath_test.c @@ -1,4 +1,4 @@ -/* +/* $Id$ * * Copyright (C) 2006-2007 Peter Johnson * @@ -23,9 +23,16 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ +#ifdef HAVE_CONFIG_H +# include +#endif + +#ifdef STDC_HEADERS +# include +# include +#endif + #include -#include -#include #include "libyasm/file.h" #include "libyasm/coretype.h" @@ -97,18 +104,18 @@ run_test(Test_Entry *test) const char *funcname; if (test->combpath == &yasm__combpath_unix) - funcname = "unix"; + funcname = "unix"; else - funcname = "win"; + funcname = "win"; out = test->combpath(test->from, test->to); if (strcmp(out, test->out) != 0) { - sprintf(failmsg, - "combpath_%s(\"%s\", \"%s\"): expected \"%s\", got \"%s\"!", - funcname, test->from, test->to, test->out, out); - yasm_xfree(out); - return 1; + sprintf(failmsg, + "combpath_%s(\"%s\", \"%s\"): expected \"%s\", got \"%s\"!", + funcname, test->from, test->to, test->out, out); + yasm_xfree(out); + return 1; } yasm_xfree(out); @@ -125,15 +132,15 @@ main(void) failed[0] = '\0'; printf("Test combpath_test: "); for (i=0; i0 ? 'F':'.'); - fflush(stdout); - if (fail) - sprintf(failed, "%s ** F: %s\n", failed, failmsg); - nf += fail; + int fail = run_test(&tests[i]); + printf("%c", fail>0 ? 'F':'.'); + fflush(stdout); + if (fail) + sprintf(failed, "%s ** F: %s\n", failed, failmsg); + nf += fail; } printf(" +%d-%d/%d %d%%\n%s", - numtests-nf, nf, numtests, 100*(numtests-nf)/numtests, failed); + numtests-nf, nf, numtests, 100*(numtests-nf)/numtests, failed); return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE; } diff --git a/libyasm/tests/duplabel-err.errwarn b/libyasm/tests/duplabel-err.errwarn index 4ce13bff..69014ad8 100644 --- a/libyasm/tests/duplabel-err.errwarn +++ b/libyasm/tests/duplabel-err.errwarn @@ -1,4 +1,4 @@ --:16: error: redefinition of `label' --:12: error: `label' previously defined here --:18: error: redefinition of `label' --:12: error: `label' previously defined here +-:16: redefinition of `label' +-:12: `label' previously defined here +-:18: redefinition of `label' +-:12: `label' previously defined here diff --git a/libyasm/tests/expr-fold-level.asm b/libyasm/tests/expr-fold-level.asm deleted file mode 100644 index 814a62c5..00000000 --- a/libyasm/tests/expr-fold-level.asm +++ /dev/null @@ -1,4 +0,0 @@ -begin -A equ 09000h -a dd (A+(end-begin)+3) -end diff --git a/libyasm/tests/expr-fold-level.hex b/libyasm/tests/expr-fold-level.hex deleted file mode 100644 index aba10f6d..00000000 --- a/libyasm/tests/expr-fold-level.hex +++ /dev/null @@ -1,4 +0,0 @@ -07 -90 -00 -00 diff --git a/libyasm/tests/expr-simplify-identity.asm b/libyasm/tests/expr-simplify-identity.asm deleted file mode 100644 index cda9c3bb..00000000 --- a/libyasm/tests/expr-simplify-identity.asm +++ /dev/null @@ -1,4 +0,0 @@ -d_key equ 0 -cachedata: DQ 0 -dtable: -cmp al, [esi + (dtable-cachedata) + ebx*4 + d_key] diff --git a/libyasm/tests/expr-simplify-identity.hex b/libyasm/tests/expr-simplify-identity.hex deleted file mode 100644 index 4a236bc5..00000000 --- a/libyasm/tests/expr-simplify-identity.hex +++ /dev/null @@ -1,13 +0,0 @@ -00 -00 -00 -00 -00 -00 -00 -00 -67 -3a -44 -9e -08 diff --git a/libyasm/tests/floatnum_test.c b/libyasm/tests/floatnum_test.c index 2447e90b..69b27c18 100644 --- a/libyasm/tests/floatnum_test.c +++ b/libyasm/tests/floatnum_test.c @@ -1,4 +1,4 @@ -/* +/* $Id$ * * Copyright (C) 2001-2007 Peter Johnson * @@ -23,27 +23,34 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ +#ifdef HAVE_CONFIG_H +# include +#endif + +#ifdef STDC_HEADERS +# include +# include +#endif + #include -#include -#include #include "libyasm/floatnum.c" /* constants describing parameters of internal floating point format. * (these should match those in src/floatnum.c !) */ -#define MANT_BITS 80 -#define MANT_BYTES 10 +#define MANT_BITS 80 +#define MANT_BYTES 10 typedef struct Init_Entry_s { /* input ASCII value */ const char *ascii; /* correct output from ASCII conversion */ - unsigned char mantissa[MANT_BYTES]; /* little endian mantissa - first - byte is not checked for - correctness. */ - unsigned short exponent; /* bias 32767 exponent */ + unsigned char mantissa[MANT_BYTES]; /* little endian mantissa - first + byte is not checked for + correctness. */ + unsigned short exponent; /* bias 32767 exponent */ unsigned char sign; unsigned char flags; @@ -58,35 +65,35 @@ typedef struct Init_Entry_s { /* Values used for normalized tests */ static Init_Entry normalized_vals[] = { - { "3.141592653589793", - {0xc6,0x0d,0xe9,0xbd,0x68,0x21,0xa2,0xda,0x0f,0xc9},0x8000,0,0, - 0, {0xdb,0x0f,0x49,0x40}, - 0, {0x18,0x2d,0x44,0x54,0xfb,0x21,0x09,0x40}, - 0, {0xe9,0xbd,0x68,0x21,0xa2,0xda,0x0f,0xc9,0x00,0x40} + { "3.141592653589793", + {0xc6,0x0d,0xe9,0xbd,0x68,0x21,0xa2,0xda,0x0f,0xc9},0x8000,0,0, + 0, {0xdb,0x0f,0x49,0x40}, + 0, {0x18,0x2d,0x44,0x54,0xfb,0x21,0x09,0x40}, + 0, {0xe9,0xbd,0x68,0x21,0xa2,0xda,0x0f,0xc9,0x00,0x40} }, - { "-3.141592653589793", - {0xc6,0x0d,0xe9,0xbd,0x68,0x21,0xa2,0xda,0x0f,0xc9},0x8000,1,0, - 0, {0xdb,0x0f,0x49,0xc0}, - 0, {0x18,0x2d,0x44,0x54,0xfb,0x21,0x09,0xc0}, - 0, {0xe9,0xbd,0x68,0x21,0xa2,0xda,0x0f,0xc9,0x00,0xc0} + { "-3.141592653589793", + {0xc6,0x0d,0xe9,0xbd,0x68,0x21,0xa2,0xda,0x0f,0xc9},0x8000,1,0, + 0, {0xdb,0x0f,0x49,0xc0}, + 0, {0x18,0x2d,0x44,0x54,0xfb,0x21,0x09,0xc0}, + 0, {0xe9,0xbd,0x68,0x21,0xa2,0xda,0x0f,0xc9,0x00,0xc0} }, - { "1.e16", - {0x00,0x00,0x00,0x00,0x00,0x04,0xbf,0xc9,0x1b,0x8e},0x8034,0,0, - 0, {0xca,0x1b,0x0e,0x5a}, - 0, {0x00,0x80,0xe0,0x37,0x79,0xc3,0x41,0x43}, - 0, {0x00,0x00,0x00,0x04,0xbf,0xc9,0x1b,0x8e,0x34,0x40} + { "1.e16", + {0x00,0x00,0x00,0x00,0x00,0x04,0xbf,0xc9,0x1b,0x8e},0x8034,0,0, + 0, {0xca,0x1b,0x0e,0x5a}, + 0, {0x00,0x80,0xe0,0x37,0x79,0xc3,0x41,0x43}, + 0, {0x00,0x00,0x00,0x04,0xbf,0xc9,0x1b,0x8e,0x34,0x40} }, - { "1.6e-20", - {0xf6,0xd3,0xee,0x7b,0xda,0x74,0x50,0xa0,0x1d,0x97},0x7fbd,0,0, - 0, {0xa0,0x1d,0x97,0x1e}, - 0, {0x4f,0x9b,0x0e,0x0a,0xb4,0xe3,0xd2,0x3b}, - 0, {0xef,0x7b,0xda,0x74,0x50,0xa0,0x1d,0x97,0xbd,0x3f} + { "1.6e-20", + {0xf6,0xd3,0xee,0x7b,0xda,0x74,0x50,0xa0,0x1d,0x97},0x7fbd,0,0, + 0, {0xa0,0x1d,0x97,0x1e}, + 0, {0x4f,0x9b,0x0e,0x0a,0xb4,0xe3,0xd2,0x3b}, + 0, {0xef,0x7b,0xda,0x74,0x50,0xa0,0x1d,0x97,0xbd,0x3f} }, - { "-5876.", - {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xa0,0xb7},0x800b,1,0, - 0, {0x00,0xa0,0xb7,0xc5}, - 0, {0x00,0x00,0x00,0x00,0x00,0xf4,0xb6,0xc0}, - 0, {0x00,0x00,0x00,0x00,0x00,0x00,0xa0,0xb7,0x0b,0xc0} + { "-5876.", + {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xa0,0xb7},0x800b,1,0, + 0, {0x00,0xa0,0xb7,0xc5}, + 0, {0x00,0x00,0x00,0x00,0x00,0xf4,0xb6,0xc0}, + 0, {0x00,0x00,0x00,0x00,0x00,0x00,0xa0,0xb7,0x0b,0xc0} }, /* Edge cases for rounding wrap. */ { "1.00000", @@ -108,43 +115,43 @@ static Init_Entry normalized_vals[] = { */ static Init_Entry normalized_edgecase_vals[] = { /* 32-bit edges */ - { "1.1754943508222875e-38", - {0xd5,0xf2,0x82,0xff,0xff,0xff,0xff,0xff,0xff,0xff},0x7f80,0,0, - 0, {0x00,0x00,0x80,0x00}, - 0, {0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x38}, - 0, {0x83,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x80,0x3f} + { "1.1754943508222875e-38", + {0xd5,0xf2,0x82,0xff,0xff,0xff,0xff,0xff,0xff,0xff},0x7f80,0,0, + 0, {0x00,0x00,0x80,0x00}, + 0, {0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x38}, + 0, {0x83,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x80,0x3f} }, - { "3.4028234663852886e+38", - {0x21,0x35,0x0a,0x00,0x00,0x00,0x00,0xff,0xff,0xff},0x807e,0,0, - 0, {0xff,0xff,0x7f,0x7f}, - 0, {0x00,0x00,0x00,0xe0,0xff,0xff,0xef,0x47}, - 0, {0x0a,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0x7e,0x40} + { "3.4028234663852886e+38", + {0x21,0x35,0x0a,0x00,0x00,0x00,0x00,0xff,0xff,0xff},0x807e,0,0, + 0, {0xff,0xff,0x7f,0x7f}, + 0, {0x00,0x00,0x00,0xe0,0xff,0xff,0xef,0x47}, + 0, {0x0a,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0x7e,0x40} }, /* 64-bit edges */ - { "2.2250738585072014E-308", - {0x26,0x18,0x46,0x00,0x00,0x00,0x00,0x00,0x00,0x80},0x7c01,0,0, - -1, {0x00,0x00,0x00,0x00}, - 0, {0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00}, - 0, {0x46,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x01,0x3c} + { "2.2250738585072014E-308", + {0x26,0x18,0x46,0x00,0x00,0x00,0x00,0x00,0x00,0x80},0x7c01,0,0, + -1, {0x00,0x00,0x00,0x00}, + 0, {0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00}, + 0, {0x46,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x01,0x3c} }, - { "1.7976931348623157E+308", - {0x26,0x6b,0xac,0xf7,0xff,0xff,0xff,0xff,0xff,0xff},0x83fe,0,0, - 1, {0x00,0x00,0x80,0x7f}, - 0, {0xff,0xff,0xff,0xff,0xff,0xff,0xef,0x7f}, - 0, {0xac,0xf7,0xff,0xff,0xff,0xff,0xff,0xff,0xfe,0x43} + { "1.7976931348623157E+308", + {0x26,0x6b,0xac,0xf7,0xff,0xff,0xff,0xff,0xff,0xff},0x83fe,0,0, + 1, {0x00,0x00,0x80,0x7f}, + 0, {0xff,0xff,0xff,0xff,0xff,0xff,0xef,0x7f}, + 0, {0xac,0xf7,0xff,0xff,0xff,0xff,0xff,0xff,0xfe,0x43} }, /* 80-bit edges */ -/* { "3.3621E-4932", - {},,0,0, - -1, {0x00,0x00,0x00,0x00}, - -1, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, - 0, {} +/* { "3.3621E-4932", + {},,0,0, + -1, {0x00,0x00,0x00,0x00}, + -1, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, + 0, {} }, - { "1.1897E+4932", - {},,0,0, - 1, {0x00,0x00,0x80,0x7f}, - 1, {}, - 0, {} + { "1.1897E+4932", + {},,0,0, + 1, {0x00,0x00,0x80,0x7f}, + 1, {}, + 0, {} },*/ /* internal format edges */ /* { @@ -174,26 +181,26 @@ new_check_flt(Init_Entry *val) unsigned int len; mantissa = BitVector_Block_Read(flt->mantissa, &len); - for (i=1;imantissa[i]) - result = 1; - yasm_xfree(mantissa); + for (i=1;imantissa[i]) + result = 1; + free(mantissa); if (result) { - strcat(result_msg, "mantissa"); - return 1; + strcat(result_msg, "mantissa"); + return 1; } if (flt->exponent != val->exponent) { - strcat(result_msg, "exponent"); - return 1; + strcat(result_msg, "exponent"); + return 1; } if (flt->sign != val->sign) { - strcat(result_msg, "sign"); - return 1; + strcat(result_msg, "sign"); + return 1; } if (flt->flags != val->flags) { - strcat(result_msg, "flags"); - return 1; + strcat(result_msg, "flags"); + return 1; } return 0; } @@ -205,10 +212,10 @@ test_new_normalized(void) int i, num = sizeof(normalized_vals)/sizeof(Init_Entry); for (i=0; imantissa = BitVector_Create(MANT_BITS, TRUE); } @@ -239,7 +246,7 @@ static void get_family_teardown(void) { BitVector_Destroy(flt->mantissa); - yasm_xfree(flt); + free(flt); } static void @@ -268,21 +275,21 @@ append_get_return_value(int val) #endif static int get_common_check_result(int len, const unsigned char *val, - const unsigned char *correct) + const unsigned char *correct) { char str[64]; int i; int result = 0; for (i=0;i0 ? 'F':'.'); fflush(stdout); if (nf > 0) - sprintf(failed, "%s ** F: %s failed: %s!\n", failed, testname, + sprintf(failed, "%s ** F: %s failed: %s!\n", failed, testname, result_msg); return nf; } -#define runtest(x,y,z) runtest_(#x,test_##x,y,z) +#define runtest(x,y,z) runtest_(#x,test_##x,y,z) int main(void) { int nf = 0; if (BitVector_Boot() != ErrCode_Ok) - return EXIT_FAILURE; + return EXIT_FAILURE; yasm_floatnum_initialize(); failed[0] = '\0'; @@ -448,6 +455,6 @@ main(void) nf += runtest(get_extended_normalized, get_family_setup, get_family_teardown); nf += runtest(get_extended_normalized_edgecase, get_family_setup, get_family_teardown); printf(" +%d-%d/8 %d%%\n%s", - 8-nf, nf, 100*(8-nf)/8, failed); + 8-nf, nf, 100*(8-nf)/8, failed); return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE; } diff --git a/libyasm/tests/jmpsize1-err.errwarn b/libyasm/tests/jmpsize1-err.errwarn index 276b1eb8..9b821acc 100644 --- a/libyasm/tests/jmpsize1-err.errwarn +++ b/libyasm/tests/jmpsize1-err.errwarn @@ -1,2 +1,2 @@ --:132: error: short jump out of range --:263: error: short jump out of range +-:132: short jump out of range +-:263: short jump out of range diff --git a/libyasm/tests/leb128_test.c b/libyasm/tests/leb128_test.c index 87fc8d91..7699152b 100644 --- a/libyasm/tests/leb128_test.c +++ b/libyasm/tests/leb128_test.c @@ -1,4 +1,4 @@ -/* +/* $Id$ * * Copyright (C) 2005-2007 Peter Johnson * @@ -23,9 +23,16 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ +#ifdef HAVE_CONFIG_H +# include +#endif + +#ifdef STDC_HEADERS +# include +# include +#endif + #include -#include -#include #include "libyasm/intnum.c" @@ -84,38 +91,38 @@ run_output_test(Test_Entry *test) yasm_xfree(valstr); if (test->negate) - yasm_intnum_calc(intn, YASM_EXPR_NEG, NULL); + yasm_intnum_calc(intn, YASM_EXPR_NEG, NULL); size = yasm_intnum_size_leb128(intn, test->sign); if (size != test->outsize) { - yasm_intnum_destroy(intn); - sprintf(failmsg, "%ssigned %s%s size() bad size: expected %lu, got %lu!", - test->sign?"":"un", test->negate?"-":"", test->input, - test->outsize, size); - return 1; + yasm_intnum_destroy(intn); + sprintf(failmsg, "%ssigned %s%s size() bad size: expected %lu, got %lu!", + test->sign?"":"un", test->negate?"-":"", test->input, + test->outsize, size); + return 1; } for (i=0; isign); if (size != test->outsize) { - yasm_intnum_destroy(intn); - sprintf(failmsg, "%ssigned %s%s get() bad size: expected %lu, got %lu!", - test->sign?"":"un", test->negate?"-":"", test->input, - test->outsize, size); - return 1; + yasm_intnum_destroy(intn); + sprintf(failmsg, "%ssigned %s%s get() bad size: expected %lu, got %lu!", + test->sign?"":"un", test->negate?"-":"", test->input, + test->outsize, size); + return 1; } bad = 0; for (i=0; ioutsize && !bad; i++) { - if (out[i] != test->result[i]) - bad = 1; + if (out[i] != test->result[i]) + bad = 1; } if (bad) { - yasm_intnum_destroy(intn); - sprintf(failmsg, "%ssigned %s%s get() bad output!", - test->sign?"":"un", test->negate?"-":"", test->input); - return 1; + yasm_intnum_destroy(intn); + sprintf(failmsg, "%ssigned %s%s get() bad output!", + test->sign?"":"un", test->negate?"-":"", test->input); + return 1; } yasm_intnum_destroy(intn); @@ -133,25 +140,25 @@ run_input_test(Test_Entry *test) yasm_xfree(valstr); if (test->negate) - yasm_intnum_calc(intn, YASM_EXPR_NEG, NULL); + yasm_intnum_calc(intn, YASM_EXPR_NEG, NULL); testn = yasm_intnum_create_leb128(test->result, test->sign, &size); if (size != test->outsize) { - yasm_intnum_destroy(testn); - yasm_intnum_destroy(intn); - sprintf(failmsg, "%ssigned %s%s create() bad size: expected %lu, got %lu!", - test->sign?"":"un", test->negate?"-":"", test->input, - test->outsize, size); - return 1; + yasm_intnum_destroy(testn); + yasm_intnum_destroy(intn); + sprintf(failmsg, "%ssigned %s%s create() bad size: expected %lu, got %lu!", + test->sign?"":"un", test->negate?"-":"", test->input, + test->outsize, size); + return 1; } yasm_intnum_calc(intn, YASM_EXPR_EQ, testn); if (!yasm_intnum_is_pos1(intn)) { - yasm_intnum_destroy(testn); - yasm_intnum_destroy(intn); - sprintf(failmsg, "%ssigned %s%s create() bad output!", - test->sign?"":"un", test->negate?"-":"", test->input); - return 1; + yasm_intnum_destroy(testn); + yasm_intnum_destroy(intn); + sprintf(failmsg, "%ssigned %s%s create() bad output!", + test->sign?"":"un", test->negate?"-":"", test->input); + return 1; } yasm_intnum_destroy(testn); @@ -167,33 +174,33 @@ main(void) int i; if (BitVector_Boot() != ErrCode_Ok) - return EXIT_FAILURE; + return EXIT_FAILURE; yasm_intnum_initialize(); failed[0] = '\0'; printf("Test leb128_test: "); for (i=0; i0 ? 'F':'.'); - fflush(stdout); - if (fail) - sprintf(failed, "%s ** F: %s\n", failed, failmsg); - nf += fail; + fail = run_output_test(&tests[i]); + printf("%c", fail>0 ? 'F':'.'); + fflush(stdout); + if (fail) + sprintf(failed, "%s ** F: %s\n", failed, failmsg); + nf += fail; - fail = run_input_test(&tests[i]); - printf("%c", fail>0 ? 'F':'.'); - fflush(stdout); - if (fail) - sprintf(failed, "%s ** F: %s\n", failed, failmsg); - nf += fail; + fail = run_input_test(&tests[i]); + printf("%c", fail>0 ? 'F':'.'); + fflush(stdout); + if (fail) + sprintf(failed, "%s ** F: %s\n", failed, failmsg); + nf += fail; } yasm_intnum_cleanup(); printf(" +%d-%d/%d %d%%\n%s", - numtests*2-nf, nf, numtests*2, 100*(numtests*2-nf)/(numtests*2), - failed); + numtests*2-nf, nf, numtests*2, 100*(numtests*2-nf)/(numtests*2), + failed); return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE; } diff --git a/libyasm/tests/libyasm_test.sh b/libyasm/tests/libyasm_test.sh index 37f8717f..02457315 100755 --- a/libyasm/tests/libyasm_test.sh +++ b/libyasm/tests/libyasm_test.sh @@ -1,3 +1,4 @@ #! /bin/sh +# $Id$ ${srcdir}/out_test.sh libyasm_test libyasm/tests "libyasm" "-f bin" "" exit $? diff --git a/libyasm/tests/opt-circular1-err.errwarn b/libyasm/tests/opt-circular1-err.errwarn index 9b09e1c5..b26f47ad 100644 --- a/libyasm/tests/opt-circular1-err.errwarn +++ b/libyasm/tests/opt-circular1-err.errwarn @@ -1 +1 @@ --:1: error: circular reference detected +-:1: circular reference detected diff --git a/libyasm/tests/opt-circular2-err.errwarn b/libyasm/tests/opt-circular2-err.errwarn index 9b09e1c5..b26f47ad 100644 --- a/libyasm/tests/opt-circular2-err.errwarn +++ b/libyasm/tests/opt-circular2-err.errwarn @@ -1 +1 @@ --:1: error: circular reference detected +-:1: circular reference detected diff --git a/libyasm/tests/opt-circular3-err.errwarn b/libyasm/tests/opt-circular3-err.errwarn index 041cbba2..bf1d3fa2 100644 --- a/libyasm/tests/opt-circular3-err.errwarn +++ b/libyasm/tests/opt-circular3-err.errwarn @@ -1 +1 @@ --:6: error: circular reference detected +-:6: circular reference detected diff --git a/libyasm/tests/reserve-err1.errwarn b/libyasm/tests/reserve-err1.errwarn index e53fe3c7..e3da650a 100644 --- a/libyasm/tests/reserve-err1.errwarn +++ b/libyasm/tests/reserve-err1.errwarn @@ -1,2 +1,2 @@ --:7: error: multiple expression not absolute --:14: error: multiple expression not absolute +-:7: multiple expression not absolute +-:14: multiple expression not absolute diff --git a/libyasm/tests/reserve-err2.errwarn b/libyasm/tests/reserve-err2.errwarn index d3fbbabb..44c5efa9 100644 --- a/libyasm/tests/reserve-err2.errwarn +++ b/libyasm/tests/reserve-err2.errwarn @@ -1,6 +1,6 @@ --:3: error: multiple is negative --:4: error: expression must not contain floating point value --:5: error: expression must not contain floating point value --:10: error: multiple is negative --:11: error: expression must not contain floating point value --:12: error: expression must not contain floating point value +-:3: multiple is negative +-:4: expression must not contain floating point value +-:5: expression must not contain floating point value +-:10: multiple is negative +-:11: expression must not contain floating point value +-:12: expression must not contain floating point value diff --git a/libyasm/tests/splitpath_test.c b/libyasm/tests/splitpath_test.c index 7f873a47..b24ab23f 100644 --- a/libyasm/tests/splitpath_test.c +++ b/libyasm/tests/splitpath_test.c @@ -1,4 +1,4 @@ -/* +/* $Id$ * * Copyright (C) 2006-2007 Peter Johnson * @@ -23,9 +23,16 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ +#ifdef HAVE_CONFIG_H +# include +#endif + +#ifdef STDC_HEADERS +# include +# include +#endif + #include -#include -#include #include "libyasm/file.h" @@ -107,24 +114,24 @@ run_test(Test_Entry *test) const char *funcname; if (test->splitpath == &yasm__splitpath_unix) - funcname = "unix"; + funcname = "unix"; else - funcname = "win"; + funcname = "win"; headlen = test->splitpath(test->input, &tail); if (headlen != test->headlen) { - sprintf(failmsg, - "splitpath_%s(\"%s\") bad head len: expected %lu, got %lu!", - funcname, test->input, (unsigned long)test->headlen, - (unsigned long)headlen); - return 1; + sprintf(failmsg, + "splitpath_%s(\"%s\") bad head len: expected %lu, got %lu!", + funcname, test->input, (unsigned long)test->headlen, + (unsigned long)headlen); + return 1; } if (strcmp(tail, test->tail) != 0) { - sprintf(failmsg, - "splitpath_%s(\"%s\") bad tail: expected \"%s\", got \"%s\"!", - funcname, test->input, test->tail, tail); - return 1; + sprintf(failmsg, + "splitpath_%s(\"%s\") bad tail: expected \"%s\", got \"%s\"!", + funcname, test->input, test->tail, tail); + return 1; } return 0; @@ -140,15 +147,15 @@ main(void) failed[0] = '\0'; printf("Test splitpath_test: "); for (i=0; i0 ? 'F':'.'); - fflush(stdout); - if (fail) - sprintf(failed, "%s ** F: %s\n", failed, failmsg); - nf += fail; + int fail = run_test(&tests[i]); + printf("%c", fail>0 ? 'F':'.'); + fflush(stdout); + if (fail) + sprintf(failed, "%s ** F: %s\n", failed, failmsg); + nf += fail; } printf(" +%d-%d/%d %d%%\n%s", - numtests-nf, nf, numtests, 100*(numtests-nf)/numtests, failed); + numtests-nf, nf, numtests, 100*(numtests-nf)/numtests, failed); return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE; } diff --git a/libyasm/tests/timesfwd.asm b/libyasm/tests/timesfwd.asm deleted file mode 100644 index bdb36d3e..00000000 --- a/libyasm/tests/timesfwd.asm +++ /dev/null @@ -1,8 +0,0 @@ -[section .text] -[bits 64] -;[global foo] -;[global bar] -times (foo-bar+$$-$)&7 nop -foo: inc eax -bar: inc ecx - diff --git a/libyasm/tests/timesfwd.hex b/libyasm/tests/timesfwd.hex deleted file mode 100644 index 82904beb..00000000 --- a/libyasm/tests/timesfwd.hex +++ /dev/null @@ -1,10 +0,0 @@ -90 -90 -90 -90 -90 -90 -ff -c0 -ff -c1 diff --git a/libyasm/tests/timesover-err.errwarn b/libyasm/tests/timesover-err.errwarn index 81441ac3..c972a1d9 100644 --- a/libyasm/tests/timesover-err.errwarn +++ b/libyasm/tests/timesover-err.errwarn @@ -1 +1 @@ --:2: error: multiple is negative +-:2: multiple is negative diff --git a/libyasm/tests/uncstring_test.c b/libyasm/tests/uncstring_test.c index 73037642..351d3cc5 100644 --- a/libyasm/tests/uncstring_test.c +++ b/libyasm/tests/uncstring_test.c @@ -1,4 +1,4 @@ -/* +/* $Id$ * * Copyright (C) 2006-2007 Peter Johnson * @@ -23,9 +23,16 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ +#ifdef HAVE_CONFIG_H +# include +#endif + +#ifdef STDC_HEADERS +# include +# include +#endif + #include -#include -#include #include "util.h" #include "libyasm/errwarn.h" @@ -50,7 +57,7 @@ typedef struct Test_Entry { static Test_Entry tests[] = { {"noescape", 8, "noescape", 8, NULL}, - {"noescape2", 10, "noescape2", 10, NULL}, /* includes trailing zero */ + {"noescape2", 10, "noescape2", 10, NULL}, /* includes trailing zero */ {"\\\\\\b\\f\\n\\r\\t\\\"", 14, "\\\b\f\n\r\t\"", 7, NULL}, {"\\a", 2, "a", 1, NULL}, /* hex tests */ @@ -90,38 +97,38 @@ run_test(Test_Entry *test) yasm_unescape_cstring((unsigned char *)str, &len); if (len != test->result_len) { - sprintf(failmsg, - "unescape_cstring(\"%s\", %lu) bad output len: expected %lu, got %lu!", - test->input, (unsigned long)test->in_len, - (unsigned long)test->result_len, (unsigned long)len); - return 1; + sprintf(failmsg, + "unescape_cstring(\"%s\", %lu) bad output len: expected %lu, got %lu!", + test->input, (unsigned long)test->in_len, + (unsigned long)test->result_len, (unsigned long)len); + return 1; } if (strncmp(str, test->result, len) != 0) { - sprintf(failmsg, - "unescape_cstring(\"%s\", %lu) bad output: expected \"%s\", got \"%s\"!", - test->input, (unsigned long)test->in_len, test->result, str); - return 1; + sprintf(failmsg, + "unescape_cstring(\"%s\", %lu) bad output: expected \"%s\", got \"%s\"!", + test->input, (unsigned long)test->in_len, test->result, str); + return 1; } yasm_warn_fetch(&wclass, &wstr); if (wstr != NULL && test->warn == NULL) { - sprintf(failmsg, - "unescape_cstring(\"%s\", %lu) unexpected warning: %s!", - test->input, (unsigned long)test->in_len, wstr); - return 1; + sprintf(failmsg, + "unescape_cstring(\"%s\", %lu) unexpected warning: %s!", + test->input, (unsigned long)test->in_len, wstr); + return 1; } if (wstr == NULL && test->warn != NULL) { - sprintf(failmsg, - "unescape_cstring(\"%s\", %lu) expected warning: %s, did not get it!", - test->input, (unsigned long)test->in_len, test->warn); - return 1; + sprintf(failmsg, + "unescape_cstring(\"%s\", %lu) expected warning: %s, did not get it!", + test->input, (unsigned long)test->in_len, test->warn); + return 1; } if (wstr && test->warn && strcmp(wstr, test->warn) != 0) { - sprintf(failmsg, - "unescape_cstring(\"%s\", %lu) expected warning: %s, got %s!", - test->input, (unsigned long)test->in_len, test->warn, wstr); - return 1; + sprintf(failmsg, + "unescape_cstring(\"%s\", %lu) expected warning: %s, got %s!", + test->input, (unsigned long)test->in_len, test->warn, wstr); + return 1; } yasm_xfree(wstr); @@ -140,16 +147,16 @@ main(void) failed[0] = '\0'; printf("Test uncstring_test: "); for (i=0; i0 ? 'F':'.'); - fflush(stdout); - if (fail) - sprintf(failed, "%s ** F: %s\n", failed, failmsg); - nf += fail; + int fail = run_test(&tests[i]); + printf("%c", fail>0 ? 'F':'.'); + fflush(stdout); + if (fail) + sprintf(failed, "%s ** F: %s\n", failed, failmsg); + nf += fail; } printf(" +%d-%d/%d %d%%\n%s", - numtests-nf, nf, numtests, 100*(numtests-nf)/numtests, failed); + numtests-nf, nf, numtests, 100*(numtests-nf)/numtests, failed); yasm_errwarn_cleanup(); return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE; diff --git a/libyasm/tests/value-err.errwarn b/libyasm/tests/value-err.errwarn index a949cd85..a7535524 100644 --- a/libyasm/tests/value-err.errwarn +++ b/libyasm/tests/value-err.errwarn @@ -1,3 +1,3 @@ --:2: error: effective address too complex --:3: error: immediate expression too complex --:8: error: data expression too complex +-:2: effective address too complex +-:3: immediate expression too complex +-:8: data expression too complex diff --git a/libyasm/tests/value-mask.asm b/libyasm/tests/value-mask.asm deleted file mode 100644 index 3e939521..00000000 --- a/libyasm/tests/value-mask.asm +++ /dev/null @@ -1,5 +0,0 @@ -db label -db label & 0xff -section .bss -resb 500 -label: diff --git a/libyasm/tests/value-mask.errwarn b/libyasm/tests/value-mask.errwarn deleted file mode 100644 index 9df5a665..00000000 --- a/libyasm/tests/value-mask.errwarn +++ /dev/null @@ -1 +0,0 @@ --:1: warning: value does not fit in 8 bit field diff --git a/libyasm/tests/value-mask.hex b/libyasm/tests/value-mask.hex deleted file mode 100644 index 8cae27c3..00000000 --- a/libyasm/tests/value-mask.hex +++ /dev/null @@ -1,2 +0,0 @@ -f8 -f8 diff --git a/libyasm/tests/value-samesym.asm b/libyasm/tests/value-samesym.asm deleted file mode 100644 index da325992..00000000 --- a/libyasm/tests/value-samesym.asm +++ /dev/null @@ -1,2 +0,0 @@ -extern RW -mov [eax + (RW + 22032) - (RW + 23056)], eax diff --git a/libyasm/tests/value-samesym.errwarn b/libyasm/tests/value-samesym.errwarn deleted file mode 100644 index 58c850b3..00000000 --- a/libyasm/tests/value-samesym.errwarn +++ /dev/null @@ -1 +0,0 @@ --:1: warning: binary object format does not support extern variables diff --git a/libyasm/tests/value-samesym.hex b/libyasm/tests/value-samesym.hex deleted file mode 100644 index 4bab16b8..00000000 --- a/libyasm/tests/value-samesym.hex +++ /dev/null @@ -1,8 +0,0 @@ -67 -66 -89 -80 -00 -fc -ff -ff diff --git a/libyasm/tests/value-shr-symexpr.asm b/libyasm/tests/value-shr-symexpr.asm deleted file mode 100644 index 988abbff..00000000 --- a/libyasm/tests/value-shr-symexpr.asm +++ /dev/null @@ -1,6 +0,0 @@ -dw foo -dw (foo+((1<<9)-1)) -dw (foo+((1<<9)-1)) >> 9 -foo: -dw (bar+foo)>>(0+1) -bar: diff --git a/libyasm/tests/value-shr-symexpr.hex b/libyasm/tests/value-shr-symexpr.hex deleted file mode 100644 index b3169287..00000000 --- a/libyasm/tests/value-shr-symexpr.hex +++ /dev/null @@ -1,8 +0,0 @@ -06 -00 -05 -02 -01 -00 -07 -00 diff --git a/libyasm/valparam.c b/libyasm/valparam.c index 88e41a7c..b142f22e 100644 --- a/libyasm/valparam.c +++ b/libyasm/valparam.c @@ -24,7 +24,9 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ +#define YASM_LIB_INTERNAL #include "util.h" +/*@unused@*/ RCSID("$Id$"); #include "libyasm-stdint.h" #include "coretype.h" @@ -39,27 +41,27 @@ void yasm_call_directive(const yasm_directive *directive, yasm_object *object, - yasm_valparamhead *valparams, - yasm_valparamhead *objext_valparams, unsigned long line) + yasm_valparamhead *valparams, + yasm_valparamhead *objext_valparams, unsigned long line) { yasm_valparam *vp; if ((directive->flags & (YASM_DIR_ARG_REQUIRED|YASM_DIR_ID_REQUIRED)) && - (!valparams || !yasm_vps_first(valparams))) { - yasm_error_set(YASM_ERROR_SYNTAX, - N_("directive `%s' requires an argument"), - directive->name); - return; + (!valparams || !yasm_vps_first(valparams))) { + yasm_error_set(YASM_ERROR_SYNTAX, + N_("directive `%s' requires an argument"), + directive->name); + return; } if (valparams) { - vp = yasm_vps_first(valparams); + vp = yasm_vps_first(valparams); if ((directive->flags & YASM_DIR_ID_REQUIRED) && vp->type != YASM_PARAM_ID) { - yasm_error_set(YASM_ERROR_SYNTAX, - N_("directive `%s' requires an identifier parameter"), - directive->name); - return; - } + yasm_error_set(YASM_ERROR_SYNTAX, + N_("directive `%s' requires an identifier parameter"), + directive->name); + return; + } } directive->handler(object, valparams, objext_valparams, line); } @@ -101,15 +103,15 @@ yasm_vp_create_expr(/*@keep@*/ char *v, /*@keep@*/ yasm_expr *p) yasm_vp_expr(const yasm_valparam *vp, yasm_symtab *symtab, unsigned long line) { if (!vp) - return NULL; + return NULL; switch (vp->type) { case YASM_PARAM_ID: - return yasm_expr_create_ident(yasm_expr_sym( + return yasm_expr_create_ident(yasm_expr_sym( yasm_symtab_use(symtab, yasm_vp_id(vp), line)), line); case YASM_PARAM_EXPR: return yasm_expr_copy(vp->param.e); default: - return NULL; + return NULL; } } @@ -149,9 +151,9 @@ yasm_vps_delete(yasm_valparamhead *headp) cur = STAILQ_FIRST(headp); while (cur) { - next = STAILQ_NEXT(cur, link); - if (cur->val) - yasm_xfree(cur->val); + next = STAILQ_NEXT(cur, link); + if (cur->val) + yasm_xfree(cur->val); switch (cur->type) { case YASM_PARAM_ID: yasm_xfree(cur->param.id); @@ -163,8 +165,8 @@ yasm_vps_delete(yasm_valparamhead *headp) yasm_expr_destroy(cur->param.e); break; } - yasm_xfree(cur); - cur = next; + yasm_xfree(cur); + cur = next; } STAILQ_INIT(headp); } @@ -175,15 +177,15 @@ yasm_vps_print(const yasm_valparamhead *headp, FILE *f) const yasm_valparam *vp; if(!headp) { - fprintf(f, "(none)"); - return; + fprintf(f, "(none)"); + return; } yasm_vps_foreach(vp, headp) { - if (vp->val) - fprintf(f, "(\"%s\",", vp->val); - else - fprintf(f, "((nil),"); + if (vp->val) + fprintf(f, "(\"%s\",", vp->val); + else + fprintf(f, "((nil),"); switch (vp->type) { case YASM_PARAM_ID: fprintf(f, "%s", vp->param.id); @@ -195,9 +197,9 @@ yasm_vps_print(const yasm_valparamhead *headp, FILE *f) yasm_expr_print(vp->param.e, f); break; } - fprintf(f, ")"); - if (yasm_vps_next(vp)) - fprintf(f, ","); + fprintf(f, ")"); + if (yasm_vps_next(vp)) + fprintf(f, ","); } } @@ -216,6 +218,31 @@ yasm_vps_destroy(yasm_valparamhead *headp) yasm_xfree(headp); } +/* Non-macro yasm_vps_append() for non-YASM_LIB_INTERNAL users. */ +#undef yasm_vps_append +void +yasm_vps_append(yasm_valparamhead *headp, /*@keep@*/ yasm_valparam *vp) +{ + if (vp) + STAILQ_INSERT_TAIL(headp, vp, link); +} + +/* Non-macro yasm_vps_first() for non-YASM_LIB_INTERNAL users. */ +#undef yasm_vps_first +/*@null@*/ /*@dependent@*/ yasm_valparam * +yasm_vps_first(yasm_valparamhead *headp) +{ + return STAILQ_FIRST(headp); +} + +/* Non-macro yasm_vps_next() for non-YASM_LIB_INTERNAL users. */ +#undef yasm_vps_next +/*@null@*/ /*@dependent@*/ yasm_valparam * +yasm_vps_next(yasm_valparam *cur) +{ + return STAILQ_NEXT(cur, link); +} + int yasm_dir_helper(void *obj, yasm_valparam *vp_first, unsigned long line, const yasm_dir_help *help, size_t nhelp, void *data, @@ -301,23 +328,6 @@ yasm_dir_helper_flag_set(void *obj, yasm_valparam *vp, unsigned long line, return 0; } -int -yasm_dir_helper_expr(void *obj, yasm_valparam *vp, unsigned long line, - void *data, uintptr_t arg) -{ - yasm_object *object = (yasm_object *)obj; - yasm_expr **expr = (yasm_expr **)data; - - if (*expr) - yasm_expr_destroy(*expr); - if (!(*expr = yasm_vp_expr(vp, object->symtab, line))) { - yasm_error_set(YASM_ERROR_VALUE, N_("argument to `%s' is not an expression"), - vp->val); - return -1; - } - return 0; -} - int yasm_dir_helper_intn(void *obj, yasm_valparam *vp, unsigned long line, void *data, uintptr_t arg) diff --git a/libyasm/valparam.h b/libyasm/valparam.h index d7343d49..b3023a6d 100644 --- a/libyasm/valparam.h +++ b/libyasm/valparam.h @@ -2,6 +2,10 @@ * \file libyasm/valparam.h * \brief YASM value/parameter interface. * + * \rcs + * $Id$ + * \endrcs + * * \license * Copyright (C) 2001-2007 Peter Johnson * @@ -30,40 +34,36 @@ #ifndef YASM_VALPARAM_H #define YASM_VALPARAM_H -#ifndef YASM_LIB_DECL -#define YASM_LIB_DECL -#endif - +#ifdef YASM_LIB_INTERNAL /** Value/parameter pair. \internal */ struct yasm_valparam { /*@reldef@*/ STAILQ_ENTRY(yasm_valparam) link; /**< Next pair in list */ - /*@owned@*/ /*@null@*/ char *val; /**< Value */ + /*@owned@*/ /*@null@*/ char *val; /**< Value */ - /** Parameter type. */ enum yasm_param_type { YASM_PARAM_ID, /**< Identifier */ YASM_PARAM_STRING, /**< String */ YASM_PARAM_EXPR /**< Expression */ } type; /**< Parameter type */ - /** Parameter value. */ union yasm_param { /*@owned@*/ char *id; /**< Identifier */ /*@owned@*/ char *str; /**< String */ /*@owned@*/ yasm_expr *e; /**< Expression */ } param; /**< Parameter */ - /** Prefix character that indicates a raw identifier. When - * yasm_vp_string() is called on a #YASM_PARAM_ID, all characters are - * returned. When yasm_vp_id() is called on a #YASM_PARAM_ID, if the - * identifier begins with this character, this character is stripped - * from the returned value. + /* Prefix character that indicates a raw identifier. When yasm_vp_string() + * is called on a #YASM_PARAM_ID, all characters are returned. When + * yasm_vp_id() is called on a #YASM_PARAM_ID, if the identifier begins + * with this character, this character is stripped from the returned + * value. */ char id_prefix; }; /** Linked list of value/parameter pairs. \internal */ /*@reldef@*/ STAILQ_HEAD(yasm_valparamhead, yasm_valparam); +#endif /** Directive list entry structure. */ struct yasm_directive { @@ -73,47 +73,45 @@ struct yasm_directive { */ /*@null@*/ const char *name; - const char *parser; /**< Parser keyword */ + const char *parser; /**< Parser keyword */ /** Handler callback function for the directive. - * \param object object - * \param valparams value/parameters - * \param objext_valparams object format-specific value/parameters - * \param line virtual line (from yasm_linemap) + * \param object object + * \param valparams value/parameters + * \param objext_valparams object format-specific value/parameters + * \param line virtual line (from yasm_linemap) */ void (*handler) (yasm_object *object, yasm_valparamhead *valparams, - yasm_valparamhead *objext_valparams, unsigned long line); + yasm_valparamhead *objext_valparams, unsigned long line); /** Flags for pre-handler parameter checking. */ enum yasm_directive_flags { - YASM_DIR_ANY = 0, /**< Any valparams accepted */ - YASM_DIR_ARG_REQUIRED = 1, /**< Require at least 1 valparam */ - YASM_DIR_ID_REQUIRED = 2 /**< First valparam must be ID */ + YASM_DIR_ANY = 0, /**< Any valparams accepted */ + YASM_DIR_ARG_REQUIRED = 1, /**< Require at least 1 valparam */ + YASM_DIR_ID_REQUIRED = 2 /**< First valparam must be ID */ } flags; }; /** Call a directive. Performs any valparam checks asked for by the * directive prior to call. Note that for a variety of reasons, a directive * can generate an error. - * \param directive directive - * \param object object - * \param valparams value/parameters - * \param objext_valparams object format-specific value/parameters - * \param line virtual line (from yasm_linemap) + * \param directive directive + * \param object object + * \param valparams value/parameters + * \param objext_valparams object format-specific value/parameters + * \param line virtual line (from yasm_linemap) */ -YASM_LIB_DECL void yasm_call_directive(const yasm_directive *directive, yasm_object *object, - yasm_valparamhead *valparams, - yasm_valparamhead *objext_valparams, - unsigned long line); + yasm_valparamhead *valparams, + yasm_valparamhead *objext_valparams, + unsigned long line); /** Create a new valparam with identifier parameter. - * \param v value - * \param p parameter + * \param v value + * \param p parameter * \param id_prefix identifier prefix for raw identifiers * \return Newly allocated valparam. */ -YASM_LIB_DECL yasm_valparam *yasm_vp_create_id(/*@keep@*/ char *v, /*@keep@*/ char *p, int id_prefix); @@ -122,7 +120,6 @@ yasm_valparam *yasm_vp_create_id(/*@keep@*/ char *v, /*@keep@*/ char *p, * \param p parameter * \return Newly allocated valparam. */ -YASM_LIB_DECL yasm_valparam *yasm_vp_create_string(/*@keep@*/ char *v, /*@keep@*/ char *p); /** Create a new valparam with expression parameter. @@ -130,19 +127,17 @@ yasm_valparam *yasm_vp_create_string(/*@keep@*/ char *v, /*@keep@*/ char *p); * \param p parameter * \return Newly allocated valparam. */ -YASM_LIB_DECL yasm_valparam *yasm_vp_create_expr(/*@keep@*/ char *v, /*@keep@*/ yasm_expr *p); /** Get a valparam parameter as an expr. If the parameter is an identifier, * it's treated as a symbol (yasm_symtab_use() is called to convert it). - * \param vp valparam - * \param symtab symbol table - * \param line virtual line + * \param vp valparam + * \param symtab symbol table + * \param line virtual line * \return Expression, or NULL if vp is NULL or the parameter cannot be * converted to an expression. */ -YASM_LIB_DECL /*@null@*/ /*@only@*/ yasm_expr *yasm_vp_expr (const yasm_valparam *vp, yasm_symtab *symtab, unsigned long line); @@ -152,7 +147,6 @@ YASM_LIB_DECL * \return String, or NULL if vp is NULL or the parameter cannot be realized * as a string. */ -YASM_LIB_DECL /*@null@*/ /*@dependent@*/ const char *yasm_vp_string(const yasm_valparam *vp); /** Get a valparam parameter as an identifier. @@ -160,82 +154,74 @@ YASM_LIB_DECL * \return Identifier (string), or NULL if vp is NULL or the parameter is not * an identifier. */ -YASM_LIB_DECL /*@null@*/ /*@dependent@*/ const char *yasm_vp_id(const yasm_valparam *vp); /** Create a new linked list of valparams. * \return Newly allocated valparam list. */ -YASM_LIB_DECL yasm_valparamhead *yasm_vps_create(void); /** Destroy a list of valparams (created with yasm_vps_create). - * \param headp list of valparams + * \param headp list of valparams */ -YASM_LIB_DECL void yasm_vps_destroy(yasm_valparamhead *headp); +#ifdef YASM_LIB_INTERNAL /** Initialize linked list of valparams. - * \param headp linked list + * \param headp linked list */ -void yasm_vps_initialize(/*@out@*/ yasm_valparamhead *headp); -#ifndef YASM_DOXYGEN -#define yasm_vps_initialize(headp) STAILQ_INIT(headp) -#endif +#define yasm_vps_initialize(headp) STAILQ_INIT(headp) /** Destroy (free allocated memory for) linked list of valparams (created with * yasm_vps_initialize). * \warning Deletes val/params. - * \param headp linked list + * \param headp linked list */ -YASM_LIB_DECL void yasm_vps_delete(yasm_valparamhead *headp); +#endif /** Append valparam to tail of linked list. - * \param headp linked list - * \param vp valparam + * \param headp linked list + * \param vp valparam */ void yasm_vps_append(yasm_valparamhead *headp, /*@keep@*/ yasm_valparam *vp); -#ifndef YASM_DOXYGEN -#define yasm_vps_append(headp, vp) do { \ - if (vp) \ - STAILQ_INSERT_TAIL(headp, vp, link); \ +#ifdef YASM_LIB_INTERNAL +#define yasm_vps_append(headp, vp) do { \ + if (vp) \ + STAILQ_INSERT_TAIL(headp, vp, link); \ } while(0) #endif /** Get first valparam in linked list. - * \param headp linked list + * \param headp linked list * \return First valparam in linked list. */ /*@null@*/ /*@dependent@*/ yasm_valparam *yasm_vps_first (yasm_valparamhead *headp); -#ifndef YASM_DOXYGEN -#define yasm_vps_first(headp) STAILQ_FIRST(headp) +#ifdef YASM_LIB_INTERNAL +#define yasm_vps_first(headp) STAILQ_FIRST(headp) #endif /** Get next valparam in linked list. - * \param cur previous valparam in linked list + * \param cur previous valparam in linked list * \return Next valparam in linked list. */ /*@null@*/ /*@dependent@*/ yasm_valparam *yasm_vps_next(yasm_valparam *cur); -#ifndef YASM_DOXYGEN -#define yasm_vps_next(cur) STAILQ_NEXT(cur, link) -#endif +#ifdef YASM_LIB_INTERNAL +#define yasm_vps_next(cur) STAILQ_NEXT(cur, link) /** Iterate through linked list of valparams. * \internal - * \param iter iterator variable - * \param headp linked list + * \param iter iterator variable + * \param headp linked list */ -#ifndef YASM_DOXYGEN -#define yasm_vps_foreach(iter, headp) STAILQ_FOREACH(iter, headp, link) +#define yasm_vps_foreach(iter, headp) STAILQ_FOREACH(iter, headp, link) #endif /** Print linked list of valparams. For debugging purposes. - * \param f file - * \param headp linked list + * \param f file + * \param headp linked list */ -YASM_LIB_DECL void yasm_vps_print(/*@null@*/ const yasm_valparamhead *headp, FILE *f); /** Directive valparam parse helper structure. */ @@ -291,7 +277,6 @@ typedef struct yasm_dir_help { * \return -1 on error, 1 if any arguments matched (including via * catch-all callback), 0 if no match. */ -YASM_LIB_DECL int yasm_dir_helper(void *obj, yasm_valparam *vp_first, unsigned long line, const yasm_dir_help *help, size_t nhelp, void *data, int (*helper_valparam) (void *object, @@ -309,7 +294,6 @@ int yasm_dir_helper(void *obj, yasm_valparam *vp_first, unsigned long line, * \param arg flag to set * \return 0 */ -YASM_LIB_DECL int yasm_dir_helper_flag_set(void *obj, yasm_valparam *vp, unsigned long line, void *data, uintptr_t arg); @@ -323,7 +307,6 @@ int yasm_dir_helper_flag_set(void *obj, yasm_valparam *vp, unsigned long line, * \param arg flag to OR * \return 0 */ -YASM_LIB_DECL int yasm_dir_helper_flag_or(void *obj, yasm_valparam *vp, unsigned long line, void *data, uintptr_t arg); @@ -337,28 +320,9 @@ int yasm_dir_helper_flag_or(void *obj, yasm_valparam *vp, unsigned long line, * \param arg flag to AND * \return 0 */ -YASM_LIB_DECL int yasm_dir_helper_flag_and(void *obj, yasm_valparam *vp, unsigned long line, void *data, uintptr_t arg); -/** Standard helper for yasm_dir_helper() that parses an expr parameter. - * The #yasm_dir_help structure that uses this function should have - * needsparam=1. The obj parameter to yasm_dir_helper() when this helper - * is used MUST point to a #yasm_object. In addition, the data parameter - * that is ultimately passed to this function (e.g. yasm_dir_helper() data - * parameter plus #yasm_dir_help.off) must point to a #yasm_expr * - * initialized to NULL. - * \param obj object; must be #yasm_object - * \param vp valparam - * \param line virtual line number - * \param data pointer to #yasm_expr * - * \param arg unused argument - * \return -1 on error, 0 otherwise. - */ -YASM_LIB_DECL -int yasm_dir_helper_expr(void *obj, yasm_valparam *vp, unsigned long line, - void *data, uintptr_t arg); - /** Standard helper for yasm_dir_helper() that parses an intnum parameter. * The #yasm_dir_help structure that uses this function should have * needsparam=1. The obj parameter to yasm_dir_helper() when this helper @@ -373,7 +337,6 @@ int yasm_dir_helper_expr(void *obj, yasm_valparam *vp, unsigned long line, * \param arg unused argument * \return -1 on error, 0 otherwise. */ -YASM_LIB_DECL int yasm_dir_helper_intn(void *obj, yasm_valparam *vp, unsigned long line, void *data, uintptr_t arg); @@ -390,7 +353,6 @@ int yasm_dir_helper_intn(void *obj, yasm_valparam *vp, unsigned long line, * \param arg unused * \return -1 on error, 0 otherwise. */ -YASM_LIB_DECL int yasm_dir_helper_string(void *obj, yasm_valparam *vp, unsigned long line, void *data, uintptr_t arg); @@ -402,7 +364,6 @@ int yasm_dir_helper_string(void *obj, yasm_valparam *vp, unsigned long line, * \param data unused * \return 0 */ -YASM_LIB_DECL int yasm_dir_helper_valparam_warn(void *obj, yasm_valparam *vp, unsigned long line, void *data); #endif diff --git a/libyasm/value.c b/libyasm/value.c index 3ab73c1c..dc8d6f42 100644 --- a/libyasm/value.c +++ b/libyasm/value.c @@ -24,7 +24,9 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ +#define YASM_LIB_INTERNAL #include "util.h" +/*@unused@*/ RCSID("$Id$"); #include "libyasm-stdint.h" #include "coretype.h" @@ -42,10 +44,12 @@ #include "arch.h" +#include "expr-int.h" +#include "bc-int.h" void yasm_value_initialize(/*@out@*/ yasm_value *value, - /*@null@*/ /*@kept@*/ yasm_expr *e, unsigned int size) + /*@null@*/ /*@kept@*/ yasm_expr *e, unsigned int size) { value->abs = e; value->rel = NULL; @@ -56,14 +60,13 @@ yasm_value_initialize(/*@out@*/ yasm_value *value, value->ip_rel = 0; value->jump_target = 0; value->section_rel = 0; - value->no_warn = 0; value->sign = 0; value->size = size; } void yasm_value_init_sym(/*@out@*/ yasm_value *value, /*@null@*/ yasm_symrec *sym, - unsigned int size) + unsigned int size) { value->abs = NULL; value->rel = sym; @@ -74,7 +77,6 @@ yasm_value_init_sym(/*@out@*/ yasm_value *value, /*@null@*/ yasm_symrec *sym, value->ip_rel = 0; value->jump_target = 0; value->section_rel = 0; - value->no_warn = 0; value->sign = 0; value->size = size; } @@ -91,7 +93,6 @@ yasm_value_init_copy(yasm_value *value, const yasm_value *orig) value->ip_rel = orig->ip_rel; value->jump_target = orig->jump_target; value->section_rel = orig->section_rel; - value->no_warn = orig->no_warn; value->sign = orig->sign; value->size = orig->size; } @@ -100,14 +101,14 @@ void yasm_value_delete(yasm_value *value) { if (value->abs) - yasm_expr_destroy(value->abs); + yasm_expr_destroy(value->abs); value->abs = NULL; value->rel = NULL; } void yasm_value_set_curpos_rel(yasm_value *value, yasm_bytecode *bc, - unsigned int ip_rel) + unsigned int ip_rel) { value->curpos_rel = 1; value->ip_rel = ip_rel; @@ -116,14 +117,14 @@ yasm_value_set_curpos_rel(yasm_value *value, yasm_bytecode *bc, * to a custom absolute symbol. */ if (!value->rel) { - yasm_object *object = yasm_section_get_object(yasm_bc_get_section(bc)); - value->rel = yasm_symtab_abs_sym(object->symtab); + yasm_object *object = yasm_section_get_object(yasm_bc_get_section(bc)); + value->rel = yasm_symtab_abs_sym(object->symtab); } } static int value_finalize_scan(yasm_value *value, yasm_expr *e, - /*@null@*/ yasm_bytecode *expr_precbc, int ssym_not_ok) + /*@null@*/ yasm_bytecode *expr_precbc, int ssym_not_ok) { int i; /*@dependent@*/ yasm_section *sect; @@ -140,7 +141,7 @@ value_finalize_scan(yasm_value *value, yasm_expr *e, * This is a bitmask to keep things small, as this is a recursive * routine and we don't want to eat up stack space. */ - unsigned long used; /* for ADD */ + unsigned long used; /* for ADD */ /* Thanks to this running after a simplify, we don't need to iterate * down through IDENTs or handle SUB. @@ -154,291 +155,294 @@ value_finalize_scan(yasm_value *value, yasm_expr *e, * symrec with it. */ switch (e->op) { - case YASM_EXPR_ADD: - /* Okay for single symrec anywhere in expr. - * Check for single symrec anywhere. - * Handle symrec-symrec by checking for (-1*symrec) - * and symrec term pairs (where both symrecs are in the same - * segment). - */ - if (e->numterms > 32) - yasm__fatal(N_("expression on line %d has too many add terms;" - " internal limit of 32"), e->line); + case YASM_EXPR_ADD: + /* Okay for single symrec anywhere in expr. + * Check for single symrec anywhere. + * Handle symrec-symrec by checking for (-1*symrec) + * and symrec term pairs (where both symrecs are in the same + * segment). + */ + if (e->numterms > 32) + yasm__fatal(N_("expression on line %d has too many add terms;" + " internal limit of 32"), e->line); - used = 0; + used = 0; - for (i=0; inumterms; i++) { - int j; - yasm_expr *sube; - yasm_intnum *intn; - yasm_symrec *sym; - /*@dependent@*/ yasm_section *sect2; - /*@dependent@*/ /*@null@*/ yasm_bytecode *precbc2; + for (i=0; inumterms; i++) { + int j; + yasm_expr *sube; + yasm_intnum *intn; + yasm_symrec *sym; + /*@dependent@*/ yasm_section *sect2; + /*@dependent@*/ /*@null@*/ yasm_bytecode *precbc2; - /* First look for an (-1*symrec) term */ - if (e->terms[i].type != YASM_EXPR_EXPR) - continue; - sube = e->terms[i].data.expn; + /* First look for an (-1*symrec) term */ + if (e->terms[i].type != YASM_EXPR_EXPR) + continue; + sube = e->terms[i].data.expn; - if (sube->op != YASM_EXPR_MUL || sube->numterms != 2) { - /* recurse instead */ - if (value_finalize_scan(value, sube, expr_precbc, - ssym_not_ok)) - return 1; - continue; - } + if (sube->op != YASM_EXPR_MUL || sube->numterms != 2) { + /* recurse instead */ + if (value_finalize_scan(value, sube, expr_precbc, + ssym_not_ok)) + return 1; + continue; + } - if (sube->terms[0].type == YASM_EXPR_INT && - sube->terms[1].type == YASM_EXPR_SYM) { - intn = sube->terms[0].data.intn; - sym = sube->terms[1].data.sym; - } else if (sube->terms[0].type == YASM_EXPR_SYM && - sube->terms[1].type == YASM_EXPR_INT) { - sym = sube->terms[0].data.sym; - intn = sube->terms[1].data.intn; - } else { - if (value_finalize_scan(value, sube, expr_precbc, - ssym_not_ok)) - return 1; - continue; - } + if (sube->terms[0].type == YASM_EXPR_INT && + sube->terms[1].type == YASM_EXPR_SYM) { + intn = sube->terms[0].data.intn; + sym = sube->terms[1].data.sym; + } else if (sube->terms[0].type == YASM_EXPR_SYM && + sube->terms[1].type == YASM_EXPR_INT) { + sym = sube->terms[0].data.sym; + intn = sube->terms[1].data.intn; + } else { + if (value_finalize_scan(value, sube, expr_precbc, + ssym_not_ok)) + return 1; + continue; + } - if (!yasm_intnum_is_neg1(intn)) { - if (value_finalize_scan(value, sube, expr_precbc, - ssym_not_ok)) - return 1; - continue; - } + if (!yasm_intnum_is_neg1(intn)) { + if (value_finalize_scan(value, sube, expr_precbc, + ssym_not_ok)) + return 1; + continue; + } - /* Look for the same symrec term; even if both are external, - * they should cancel out. - */ - for (j=0; jnumterms; j++) { - if (e->terms[j].type == YASM_EXPR_SYM - && e->terms[j].data.sym == sym - && (used & (1<terms[i].type = YASM_EXPR_INT; - e->terms[i].data.intn = yasm_intnum_create_uint(0); - e->terms[j].type = YASM_EXPR_INT; - e->terms[j].data.intn = yasm_intnum_create_uint(0); + /* Now look for a unused symrec term in the same segment */ + for (j=0; jnumterms; j++) { + if (e->terms[j].type == YASM_EXPR_SYM + && yasm_symrec_get_label(e->terms[j].data.sym, + &precbc2) + && (sect = yasm_bc_get_section(precbc2)) + && sect == sect2 + && (used & (1<numterms) - continue; - - if (!yasm_symrec_get_label(sym, &precbc)) { - if (value_finalize_scan(value, sube, expr_precbc, - ssym_not_ok)) - return 1; - continue; - } - sect2 = yasm_bc_get_section(precbc); - - /* Now look for a unused symrec term in the same segment */ - for (j=0; jnumterms; j++) { - if (e->terms[j].type == YASM_EXPR_SYM - && yasm_symrec_get_label(e->terms[j].data.sym, - &precbc2) - && (sect = yasm_bc_get_section(precbc2)) - && sect == sect2 - && (used & (1<numterms && !value->curpos_rel - && (yasm_symrec_is_curpos(sym) - || (expr_precbc - && sect2 == yasm_bc_get_section(expr_precbc)))) { - for (j=0; jnumterms; j++) { - if (e->terms[j].type == YASM_EXPR_SYM - && !yasm_symrec_get_equ(e->terms[j].data.sym) - && !yasm_symrec_is_special(e->terms[j].data.sym) - && (used & (1<rel || ssym_not_ok) - return 1; - value->rel = e->terms[j].data.sym; - value->curpos_rel = 1; - if (yasm_symrec_is_curpos(sym)) { - /* Replace both symrec portions with 0 */ - yasm_expr_destroy(sube); - e->terms[i].type = YASM_EXPR_INT; - e->terms[i].data.intn = - yasm_intnum_create_uint(0); - e->terms[j].type = YASM_EXPR_INT; - e->terms[j].data.intn = - yasm_intnum_create_uint(0); - } else { - /* Replace positive portion with curpos */ - yasm_object *object = - yasm_section_get_object(sect2); - yasm_symtab *symtab = object->symtab; - e->terms[j].data.sym = - yasm_symtab_define_curpos - (symtab, ".", expr_precbc, e->line); - } - break; /* stop looking */ - } - } - } + /* We didn't match in the same segment. If the + * -1*symrec is actually -1*curpos, we can match + * unused symrec terms in other segments and generate + * a curpos-relative reloc. + * + * Similarly, handle -1*symrec in other segment via the + * following transformation: + * other-this = (other-.)+(.-this) + * We can only do this transformation if "this" is in + * this expr's segment. + * + * Don't do this if we've already become curpos-relative. + * The unmatched symrec will be caught below. + */ + if (j == e->numterms && !value->curpos_rel + && (yasm_symrec_is_curpos(sym) + || (expr_precbc + && sect2 == yasm_bc_get_section(expr_precbc)))) { + for (j=0; jnumterms; j++) { + if (e->terms[j].type == YASM_EXPR_SYM + && yasm_symrec_get_label(e->terms[j].data.sym, + &precbc2) + && (used & (1<rel || ssym_not_ok) + return 1; + value->rel = e->terms[j].data.sym; + value->curpos_rel = 1; + if (yasm_symrec_is_curpos(sym)) { + /* Replace both symrec portions with 0 */ + yasm_expr_destroy(sube); + e->terms[i].type = YASM_EXPR_INT; + e->terms[i].data.intn = + yasm_intnum_create_uint(0); + e->terms[j].type = YASM_EXPR_INT; + e->terms[j].data.intn = + yasm_intnum_create_uint(0); + } else { + /* Replace positive portion with curpos */ + yasm_object *object = + yasm_section_get_object(sect2); + yasm_symtab *symtab = object->symtab; + e->terms[j].data.sym = + yasm_symtab_define_curpos + (symtab, ".", expr_precbc, e->line); + } + break; /* stop looking */ + } + } + } - if (j == e->numterms) - return 1; /* We didn't find a match! */ - } + if (j == e->numterms) + return 1; /* We didn't find a match! */ + } - /* Look for unmatched symrecs. If we've already found one or - * we don't WANT to find one, error out. - */ - for (i=0; inumterms; i++) { - if (e->terms[i].type == YASM_EXPR_SYM - && (used & (1<rel || ssym_not_ok) - return 1; - value->rel = e->terms[i].data.sym; - /* and replace with 0 */ - e->terms[i].type = YASM_EXPR_INT; - e->terms[i].data.intn = yasm_intnum_create_uint(0); - } - } - break; - case YASM_EXPR_SHR: - /* Okay for single symrec in LHS and constant on RHS. - * Single symrecs are not okay on RHS. - * If RHS is non-constant, don't allow single symrec on LHS. - * XXX: should rshift be an expr instead?? - */ + /* Look for unmatched symrecs. If we've already found one or + * we don't WANT to find one, error out. + */ + for (i=0; inumterms; i++) { + if (e->terms[i].type == YASM_EXPR_SYM + && (used & (1<rel || ssym_not_ok) + return 1; + value->rel = e->terms[i].data.sym; + /* and replace with 0 */ + e->terms[i].type = YASM_EXPR_INT; + e->terms[i].data.intn = yasm_intnum_create_uint(0); + } + } + break; + case YASM_EXPR_SHR: + /* Okay for single symrec in LHS and constant on RHS. + * Single symrecs are not okay on RHS. + * If RHS is non-constant, don't allow single symrec on LHS. + * XXX: should rshift be an expr instead?? + */ - /* Check for single sym on LHS */ - if (e->terms[0].type != YASM_EXPR_SYM) - break; + /* Check for not allowed cases on RHS */ + switch (e->terms[1].type) { + case YASM_EXPR_REG: + case YASM_EXPR_FLOAT: + return 1; /* not legal */ + case YASM_EXPR_SYM: + return 1; + case YASM_EXPR_EXPR: + if (value_finalize_scan(value, e->terms[1].data.expn, + expr_precbc, 1)) + return 1; + break; + default: + break; + } - /* If we already have a sym, we can't take another one */ - if (value->rel || ssym_not_ok) - return 1; + /* Check for single sym and allowed cases on LHS */ + switch (e->terms[0].type) { + /*case YASM_EXPR_REG: ????? should this be illegal ????? */ + case YASM_EXPR_FLOAT: + return 1; /* not legal */ + case YASM_EXPR_SYM: + if (value->rel || ssym_not_ok) + return 1; + value->rel = e->terms[0].data.sym; + /* and replace with 0 */ + e->terms[0].type = YASM_EXPR_INT; + e->terms[0].data.intn = yasm_intnum_create_uint(0); + break; + case YASM_EXPR_EXPR: + /* recurse */ + if (value_finalize_scan(value, e->terms[0].data.expn, + expr_precbc, ssym_not_ok)) + return 1; + break; + default: + break; /* ignore */ + } - /* RHS must be a positive integer */ - if (e->terms[1].type != YASM_EXPR_INT) - return 1; /* can't shift sym by non-constant integer */ - shamt = yasm_intnum_get_uint(e->terms[1].data.intn); - if ((shamt + value->rshift) > YASM_VALUE_RSHIFT_MAX) - return 1; /* total shift would be too large */ + /* Handle RHS */ + if (!value->rel) + break; /* no handling needed */ + if (e->terms[1].type != YASM_EXPR_INT) + return 1; /* can't shift sym by non-constant integer */ + shamt = yasm_intnum_get_uint(e->terms[1].data.intn); + if ((shamt + value->rshift) > YASM_VALUE_RSHIFT_MAX) + return 1; /* total shift would be too large */ + value->rshift += shamt; - /* Update value */ - value->rshift += shamt; - value->rel = e->terms[0].data.sym; + /* Just leave SHR in place */ + break; + case YASM_EXPR_SEG: + /* Okay for single symrec (can only be done once). + * Not okay for anything BUT a single symrec as an immediate + * child. + */ + if (e->terms[0].type != YASM_EXPR_SYM) + return 1; - /* Replace symbol with 0 */ - e->terms[0].type = YASM_EXPR_INT; - e->terms[0].data.intn = yasm_intnum_create_uint(0); + if (value->seg_of) + return 1; /* multiple SEG not legal */ + value->seg_of = 1; - /* Just leave SHR in place */ - break; - case YASM_EXPR_SEG: - /* Okay for single symrec (can only be done once). - * Not okay for anything BUT a single symrec as an immediate - * child. - */ - if (e->terms[0].type != YASM_EXPR_SYM) - return 1; + if (value->rel || ssym_not_ok) + return 1; /* got a relative portion somewhere else? */ + value->rel = e->terms[0].data.sym; - if (value->seg_of) - return 1; /* multiple SEG not legal */ - value->seg_of = 1; + /* replace with ident'ed 0 */ + e->op = YASM_EXPR_IDENT; + e->terms[0].type = YASM_EXPR_INT; + e->terms[0].data.intn = yasm_intnum_create_uint(0); + break; + case YASM_EXPR_WRT: + /* Okay for single symrec in LHS and either a register or single + * symrec (as an immediate child) on RHS. + * If a single symrec on RHS, can only be done once. + * WRT reg is left in expr for arch to look at. + */ - if (value->rel || ssym_not_ok) - return 1; /* got a relative portion somewhere else? */ - value->rel = e->terms[0].data.sym; + /* Handle RHS */ + switch (e->terms[1].type) { + case YASM_EXPR_SYM: + if (value->wrt) + return 1; + value->wrt = e->terms[1].data.sym; + /* and drop the WRT portion */ + e->op = YASM_EXPR_IDENT; + e->numterms = 1; + break; + case YASM_EXPR_REG: + break; /* ignore */ + default: + return 1; + } - /* replace with ident'ed 0 */ - e->op = YASM_EXPR_IDENT; - e->terms[0].type = YASM_EXPR_INT; - e->terms[0].data.intn = yasm_intnum_create_uint(0); - break; - case YASM_EXPR_WRT: - /* Okay for single symrec in LHS and either a register or single - * symrec (as an immediate child) on RHS. - * If a single symrec on RHS, can only be done once. - * WRT reg is left in expr for arch to look at. - */ + /* Handle LHS */ + switch (e->terms[0].type) { + case YASM_EXPR_SYM: + if (value->rel || ssym_not_ok) + return 1; + value->rel = e->terms[0].data.sym; + /* and replace with 0 */ + e->terms[0].type = YASM_EXPR_INT; + e->terms[0].data.intn = yasm_intnum_create_uint(0); + break; + case YASM_EXPR_EXPR: + /* recurse */ + return value_finalize_scan(value, e->terms[0].data.expn, + expr_precbc, ssym_not_ok); + default: + break; /* ignore */ + } - /* Handle RHS */ - switch (e->terms[1].type) { - case YASM_EXPR_SYM: - if (value->wrt) - return 1; - value->wrt = e->terms[1].data.sym; - /* and drop the WRT portion */ - e->op = YASM_EXPR_IDENT; - e->numterms = 1; - break; - case YASM_EXPR_REG: - break; /* ignore */ - default: - return 1; - } - - /* Handle LHS */ - switch (e->terms[0].type) { - case YASM_EXPR_SYM: - if (value->rel || ssym_not_ok) - return 1; - value->rel = e->terms[0].data.sym; - /* and replace with 0 */ - e->terms[0].type = YASM_EXPR_INT; - e->terms[0].data.intn = yasm_intnum_create_uint(0); - break; - case YASM_EXPR_EXPR: - /* recurse */ - return value_finalize_scan(value, e->terms[0].data.expn, - expr_precbc, ssym_not_ok); - default: - break; /* ignore */ - } - - break; - default: - /* Single symrec not allowed anywhere */ - for (i=0; inumterms; i++) { - switch (e->terms[i].type) { - case YASM_EXPR_SYM: - return 1; - case YASM_EXPR_EXPR: - /* recurse */ - return value_finalize_scan(value, - e->terms[i].data.expn, - expr_precbc, 1); - default: - break; - } - } - break; + break; + default: + /* Single symrec not allowed anywhere */ + for (i=0; inumterms; i++) { + switch (e->terms[i].type) { + case YASM_EXPR_SYM: + return 1; + case YASM_EXPR_EXPR: + /* recurse */ + return value_finalize_scan(value, + e->terms[i].data.expn, + expr_precbc, 1); + default: + break; + } + } + break; } return 0; @@ -446,115 +450,74 @@ value_finalize_scan(yasm_value *value, yasm_expr *e, int yasm_value_finalize_expr(yasm_value *value, yasm_expr *e, - yasm_bytecode *precbc, unsigned int size) + yasm_bytecode *precbc, unsigned int size) { if (!e) { - yasm_value_initialize(value, NULL, size); - return 0; + yasm_value_initialize(value, NULL, size); + return 0; } - yasm_value_initialize(value, e, size); - return yasm_value_finalize(value, precbc); -} -int -yasm_value_finalize(yasm_value *value, yasm_bytecode *precbc) -{ - if (!value->abs) - return 0; - - value->abs = yasm_expr__level_tree(value->abs, 1, 1, 0, 0, NULL, NULL); + yasm_value_initialize(value, + yasm_expr__level_tree(e, 1, 1, 0, 0, NULL, NULL), + size); /* quit early if there was an issue in simplify() */ if (yasm_error_occurred()) - return 1; - - /* Strip top-level AND masking to an all-1s mask the same size - * of the value size. This allows forced avoidance of overflow warnings. - */ - if (value->abs->op == YASM_EXPR_AND) { - int term; - - /* Calculate 1<size); - yasm_intnum_calc(mask, YASM_EXPR_SHL, mask_tmp); - yasm_intnum_set_uint(mask_tmp, 1); - yasm_intnum_calc(mask, YASM_EXPR_SUB, mask_tmp); - yasm_intnum_destroy(mask_tmp); - - /* Walk terms and delete matching masks */ - for (term=value->abs->numterms-1; term>=0; term--) { - if (value->abs->terms[term].type == YASM_EXPR_INT && - yasm_intnum_compare(value->abs->terms[term].data.intn, - mask) == 0) { - /* Delete the intnum */ - yasm_intnum_destroy(value->abs->terms[term].data.intn); - - /* Slide everything to its right over by 1 */ - if (term != value->abs->numterms-1) /* if it wasn't last.. */ - memmove(&value->abs->terms[term], - &value->abs->terms[term+1], - (value->abs->numterms-1-term)* - sizeof(yasm_expr__item)); - - /* Update numterms */ - value->abs->numterms--; - - /* Indicate warnings have been disabled */ - value->no_warn = 1; - } - } - if (value->abs->numterms == 1) - value->abs->op = YASM_EXPR_IDENT; - yasm_intnum_destroy(mask); - } + return 1; /* Handle trivial (IDENT) cases immediately */ if (value->abs->op == YASM_EXPR_IDENT) { - switch (value->abs->terms[0].type) { - case YASM_EXPR_INT: - if (yasm_intnum_is_zero(value->abs->terms[0].data.intn)) { - yasm_expr_destroy(value->abs); - value->abs = NULL; - } - return 0; - case YASM_EXPR_REG: - case YASM_EXPR_FLOAT: - return 0; - case YASM_EXPR_SYM: - value->rel = value->abs->terms[0].data.sym; - yasm_expr_destroy(value->abs); - value->abs = NULL; - return 0; - case YASM_EXPR_EXPR: - /* Bring up lower values. */ - while (value->abs->op == YASM_EXPR_IDENT - && value->abs->terms[0].type == YASM_EXPR_EXPR) { - yasm_expr *sube = value->abs->terms[0].data.expn; - yasm_xfree(value->abs); - value->abs = sube; - } - break; - default: - yasm_internal_error(N_("unexpected expr term type")); - } + switch (value->abs->terms[0].type) { + case YASM_EXPR_INT: + if (yasm_intnum_is_zero(value->abs->terms[0].data.intn)) { + yasm_expr_destroy(value->abs); + value->abs = NULL; + } + return 0; + case YASM_EXPR_REG: + case YASM_EXPR_FLOAT: + return 0; + case YASM_EXPR_SYM: + value->rel = value->abs->terms[0].data.sym; + yasm_expr_destroy(value->abs); + value->abs = NULL; + return 0; + case YASM_EXPR_EXPR: + /* Bring up lower values. */ + while (value->abs->op == YASM_EXPR_IDENT + && value->abs->terms[0].type == YASM_EXPR_EXPR) { + yasm_expr *sube = value->abs->terms[0].data.expn; + yasm_xfree(value->abs); + value->abs = sube; + } + break; + default: + yasm_internal_error(N_("unexpected expr term type")); + } } if (value_finalize_scan(value, value->abs, precbc, 0)) - return 1; + return 1; value->abs = yasm_expr__level_tree(value->abs, 1, 1, 0, 0, NULL, NULL); /* Simplify 0 in abs to NULL */ if (value->abs->op == YASM_EXPR_IDENT - && value->abs->terms[0].type == YASM_EXPR_INT - && yasm_intnum_is_zero(value->abs->terms[0].data.intn)) { - yasm_expr_destroy(value->abs); - value->abs = NULL; + && value->abs->terms[0].type == YASM_EXPR_INT + && yasm_intnum_is_zero(value->abs->terms[0].data.intn)) { + yasm_expr_destroy(value->abs); + value->abs = NULL; } return 0; } +int +yasm_value_finalize(yasm_value *value, yasm_bytecode *precbc) +{ + unsigned int valsize = value->size; + return yasm_value_finalize_expr(value, value->abs, precbc, valsize); +} + yasm_intnum * yasm_value_get_intnum(yasm_value *value, yasm_bytecode *bc, int calc_bc_dist) { @@ -563,56 +526,56 @@ yasm_value_get_intnum(yasm_value *value, yasm_bytecode *bc, int calc_bc_dist) int sym_local; if (value->abs) { - /* Handle integer expressions, if non-integer or too complex, return - * NULL. - */ - intn = yasm_expr_get_intnum(&value->abs, calc_bc_dist); - if (!intn) - return NULL; + /* Handle integer expressions, if non-integer or too complex, return + * NULL. + */ + intn = yasm_expr_get_intnum(&value->abs, calc_bc_dist); + if (!intn) + return NULL; } if (value->rel) { - /* If relative portion is not in bc section, return NULL. - * Otherwise get the relative portion's offset. - */ - /*@dependent@*/ yasm_bytecode *rel_prevbc; - unsigned long dist; + /* If relative portion is not in bc section, return NULL. + * Otherwise get the relative portion's offset. + */ + /*@dependent@*/ yasm_bytecode *rel_prevbc; + unsigned long dist; - if (!bc) - return NULL; /* Can't calculate relative value */ + if (!bc) + return NULL; /* Can't calculate relative value */ - sym_local = yasm_symrec_get_label(value->rel, &rel_prevbc); - if (value->wrt || value->seg_of || value->section_rel || !sym_local) - return NULL; /* we can't handle SEG, WRT, or external symbols */ - if (rel_prevbc->section != bc->section) - return NULL; /* not in this section */ - if (!value->curpos_rel) - return NULL; /* not PC-relative */ + sym_local = yasm_symrec_get_label(value->rel, &rel_prevbc); + if (value->wrt || value->seg_of || value->section_rel || !sym_local) + return NULL; /* we can't handle SEG, WRT, or external symbols */ + if (rel_prevbc->section != bc->section) + return NULL; /* not in this section */ + if (!value->curpos_rel) + return NULL; /* not PC-relative */ - /* Calculate value relative to current assembly position */ - dist = yasm_bc_next_offset(rel_prevbc); - if (dist < bc->offset) { - outval = yasm_intnum_create_uint(bc->offset - dist); - yasm_intnum_calc(outval, YASM_EXPR_NEG, NULL); - } else { - dist -= bc->offset; - outval = yasm_intnum_create_uint(dist); - } + /* Calculate value relative to current assembly position */ + dist = yasm_bc_next_offset(rel_prevbc); + if (dist < bc->offset) { + outval = yasm_intnum_create_uint(bc->offset - dist); + yasm_intnum_calc(outval, YASM_EXPR_NEG, NULL); + } else { + dist -= bc->offset; + outval = yasm_intnum_create_uint(dist); + } - if (value->rshift > 0) { - /*@only@*/ yasm_intnum *shamt = - yasm_intnum_create_uint((unsigned long)value->rshift); - yasm_intnum_calc(outval, YASM_EXPR_SHR, shamt); - yasm_intnum_destroy(shamt); - } - /* Add in absolute portion */ - if (intn) - yasm_intnum_calc(outval, YASM_EXPR_ADD, intn); - return outval; + if (value->rshift > 0) { + /*@only@*/ yasm_intnum *shamt = + yasm_intnum_create_uint((unsigned long)value->rshift); + yasm_intnum_calc(outval, YASM_EXPR_SHR, shamt); + yasm_intnum_destroy(shamt); + } + /* Add in absolute portion */ + if (intn) + yasm_intnum_calc(outval, YASM_EXPR_ADD, intn); + return outval; } if (intn) - return yasm_intnum_copy(intn); + return yasm_intnum_copy(intn); /* No absolute or relative portions: output 0 */ return yasm_intnum_create_uint(0); @@ -620,8 +583,8 @@ yasm_value_get_intnum(yasm_value *value, yasm_bytecode *bc, int calc_bc_dist) int yasm_value_output_basic(yasm_value *value, /*@out@*/ unsigned char *buf, - size_t destsize, yasm_bytecode *bc, int warn, - yasm_arch *arch) + size_t destsize, yasm_bytecode *bc, int warn, + yasm_arch *arch) { /*@dependent@*/ /*@null@*/ yasm_intnum *intn = NULL; /*@only@*/ yasm_intnum *outval; @@ -629,111 +592,108 @@ yasm_value_output_basic(yasm_value *value, /*@out@*/ unsigned char *buf, int retval = 1; unsigned int valsize = value->size; - if (value->no_warn) - warn = 0; - if (value->abs) { - /* Handle floating point expressions */ - if (!value->rel && value->abs->op == YASM_EXPR_IDENT - && value->abs->terms[0].type == YASM_EXPR_FLOAT) { - if (yasm_arch_floatnum_tobytes(arch, value->abs->terms[0].data.flt, - buf, destsize, valsize, 0, warn)) - return -1; - else - return 1; - } + /* Handle floating point expressions */ + if (!value->rel && value->abs->op == YASM_EXPR_IDENT + && value->abs->terms[0].type == YASM_EXPR_FLOAT) { + if (yasm_arch_floatnum_tobytes(arch, value->abs->terms[0].data.flt, + buf, destsize, valsize, 0, warn)) + return -1; + else + return 1; + } - /* Check for complex float expressions */ - if (yasm_expr__contains(value->abs, YASM_EXPR_FLOAT)) { - yasm_error_set(YASM_ERROR_FLOATING_POINT, - N_("floating point expression too complex")); - return -1; - } + /* Check for complex float expressions */ + if (yasm_expr__contains(value->abs, YASM_EXPR_FLOAT)) { + yasm_error_set(YASM_ERROR_FLOATING_POINT, + N_("floating point expression too complex")); + return -1; + } - /* Handle normal integer expressions */ - intn = yasm_expr_get_intnum(&value->abs, 1); + /* Handle normal integer expressions */ + intn = yasm_expr_get_intnum(&value->abs, 1); - if (!intn) { - /* Second try before erroring: yasm_expr_get_intnum doesn't handle - * SEG:OFF, so try simplifying out any to just the OFF portion, - * then getting the intnum again. - */ - yasm_expr *seg = yasm_expr_extract_deep_segoff(&value->abs); - if (seg) - yasm_expr_destroy(seg); - intn = yasm_expr_get_intnum(&value->abs, 1); - } + if (!intn) { + /* Second try before erroring: yasm_expr_get_intnum doesn't handle + * SEG:OFF, so try simplifying out any to just the OFF portion, + * then getting the intnum again. + */ + yasm_expr *seg = yasm_expr_extract_deep_segoff(&value->abs); + if (seg) + yasm_expr_destroy(seg); + intn = yasm_expr_get_intnum(&value->abs, 1); + } - if (!intn) { - /* Still don't have an integer! */ - yasm_error_set(YASM_ERROR_TOO_COMPLEX, - N_("expression too complex")); - return -1; - } + if (!intn) { + /* Still don't have an integer! */ + yasm_error_set(YASM_ERROR_TOO_COMPLEX, + N_("expression too complex")); + return -1; + } } /* Adjust warn for signed/unsigned integer warnings */ if (warn != 0) - warn = value->sign ? -1 : 1; + warn = value->sign ? -1 : 1; if (value->rel) { - /* If relative portion is not in bc section, don't try to handle it - * here. Otherwise get the relative portion's offset. - */ - /*@dependent@*/ yasm_bytecode *rel_prevbc; - unsigned long dist; + /* If relative portion is not in bc section, don't try to handle it + * here. Otherwise get the relative portion's offset. + */ + /*@dependent@*/ yasm_bytecode *rel_prevbc; + unsigned long dist; - sym_local = yasm_symrec_get_label(value->rel, &rel_prevbc); - if (value->wrt || value->seg_of || value->section_rel || !sym_local) - return 0; /* we can't handle SEG, WRT, or external symbols */ - if (rel_prevbc->section != bc->section) - return 0; /* not in this section */ - if (!value->curpos_rel) - return 0; /* not PC-relative */ + sym_local = yasm_symrec_get_label(value->rel, &rel_prevbc); + if (value->wrt || value->seg_of || value->section_rel || !sym_local) + return 0; /* we can't handle SEG, WRT, or external symbols */ + if (rel_prevbc->section != bc->section) + return 0; /* not in this section */ + if (!value->curpos_rel) + return 0; /* not PC-relative */ - /* Calculate value relative to current assembly position */ - dist = yasm_bc_next_offset(rel_prevbc); - if (dist < bc->offset) { - outval = yasm_intnum_create_uint(bc->offset - dist); - yasm_intnum_calc(outval, YASM_EXPR_NEG, NULL); - } else { - dist -= bc->offset; - outval = yasm_intnum_create_uint(dist); - } + /* Calculate value relative to current assembly position */ + dist = yasm_bc_next_offset(rel_prevbc); + if (dist < bc->offset) { + outval = yasm_intnum_create_uint(bc->offset - dist); + yasm_intnum_calc(outval, YASM_EXPR_NEG, NULL); + } else { + dist -= bc->offset; + outval = yasm_intnum_create_uint(dist); + } - if (value->rshift > 0) { - /*@only@*/ yasm_intnum *shamt = - yasm_intnum_create_uint((unsigned long)value->rshift); - yasm_intnum_calc(outval, YASM_EXPR_SHR, shamt); - yasm_intnum_destroy(shamt); - } - /* Add in absolute portion */ - if (intn) - yasm_intnum_calc(outval, YASM_EXPR_ADD, intn); - /* Output! */ - if (yasm_arch_intnum_tobytes(arch, outval, buf, destsize, valsize, 0, - bc, warn)) - retval = -1; - yasm_intnum_destroy(outval); - return retval; + if (value->rshift > 0) { + /*@only@*/ yasm_intnum *shamt = + yasm_intnum_create_uint((unsigned long)value->rshift); + yasm_intnum_calc(outval, YASM_EXPR_SHR, shamt); + yasm_intnum_destroy(shamt); + } + /* Add in absolute portion */ + if (intn) + yasm_intnum_calc(outval, YASM_EXPR_ADD, intn); + /* Output! */ + if (yasm_arch_intnum_tobytes(arch, outval, buf, destsize, valsize, 0, + bc, warn)) + retval = -1; + yasm_intnum_destroy(outval); + return retval; } if (value->seg_of || value->rshift || value->curpos_rel || value->ip_rel - || value->section_rel) - return 0; /* We can't handle this with just an absolute */ + || value->section_rel) + return 0; /* We can't handle this with just an absolute */ if (intn) { - /* Output just absolute portion */ - if (yasm_arch_intnum_tobytes(arch, intn, buf, destsize, valsize, 0, bc, - warn)) - retval = -1; + /* Output just absolute portion */ + if (yasm_arch_intnum_tobytes(arch, intn, buf, destsize, valsize, 0, bc, + warn)) + retval = -1; } else { - /* No absolute or relative portions: output 0 */ - outval = yasm_intnum_create_uint(0); - if (yasm_arch_intnum_tobytes(arch, outval, buf, destsize, valsize, 0, - bc, warn)) - retval = -1; - yasm_intnum_destroy(outval); + /* No absolute or relative portions: output 0 */ + outval = yasm_intnum_create_uint(0); + if (yasm_arch_intnum_tobytes(arch, outval, buf, destsize, valsize, 0, + bc, warn)) + retval = -1; + yasm_intnum_destroy(outval); } return retval; } @@ -742,30 +702,28 @@ void yasm_value_print(const yasm_value *value, FILE *f, int indent_level) { fprintf(f, "%*s%u-bit, %ssigned", indent_level, "", value->size, - value->sign ? "" : "un"); + value->sign ? "" : "un"); fprintf(f, "%*sAbsolute portion=", indent_level, ""); yasm_expr_print(value->abs, f); fprintf(f, "\n"); if (value->rel) { - fprintf(f, "%*sRelative to=%s%s\n", indent_level, "", - value->seg_of ? "SEG " : "", - yasm_symrec_get_name(value->rel)); - if (value->wrt) - fprintf(f, "%*s(With respect to=%s)\n", indent_level, "", - yasm_symrec_get_name(value->wrt)); - if (value->rshift > 0) - fprintf(f, "%*s(Right shifted by=%u)\n", indent_level, "", - value->rshift); - if (value->curpos_rel) - fprintf(f, "%*s(Relative to current position)\n", indent_level, - ""); - if (value->ip_rel) - fprintf(f, "%*s(IP-relative)\n", indent_level, ""); - if (value->jump_target) - fprintf(f, "%*s(Jump target)\n", indent_level, ""); - if (value->section_rel) - fprintf(f, "%*s(Section-relative)\n", indent_level, ""); - if (value->no_warn) - fprintf(f, "%*s(Overflow warnings disabled)\n", indent_level, ""); + fprintf(f, "%*sRelative to=%s%s\n", indent_level, "", + value->seg_of ? "SEG " : "", + yasm_symrec_get_name(value->rel)); + if (value->wrt) + fprintf(f, "%*s(With respect to=%s)\n", indent_level, "", + yasm_symrec_get_name(value->wrt)); + if (value->rshift > 0) + fprintf(f, "%*s(Right shifted by=%u)\n", indent_level, "", + value->rshift); + if (value->curpos_rel) + fprintf(f, "%*s(Relative to current position)\n", indent_level, + ""); + if (value->ip_rel) + fprintf(f, "%*s(IP-relative)\n", indent_level, ""); + if (value->jump_target) + fprintf(f, "%*s(Jump target)\n", indent_level, ""); + if (value->section_rel) + fprintf(f, "%*s(Section-relative)\n", indent_level, ""); } } diff --git a/libyasm/value.h b/libyasm/value.h index 4dc294bc..787b3e49 100644 --- a/libyasm/value.h +++ b/libyasm/value.h @@ -2,6 +2,10 @@ * \file libyasm/value.h * \brief YASM value interface. * + * \rcs + * $Id$ + * \endrcs + * * \license * Copyright (C) 2006-2007 Peter Johnson * @@ -30,10 +34,6 @@ #ifndef YASM_VALUE_H #define YASM_VALUE_H -#ifndef YASM_LIB_DECL -#define YASM_LIB_DECL -#endif - /** Initialize a #yasm_value with just an expression. No processing is * performed, the expression is simply stuck into value.abs and the other * fields are initialized. Use yasm_expr_extract_value() to perform "smart" @@ -41,60 +41,54 @@ * parsing simply to ensure all fields of the value are initialized; after * the parse is complete, yasm_value_extract() should be called to finalize * the value. The value defaults to unsigned. - * \param value value to be initialized - * \param e expression (kept) - * \param size value size (in bits) + * \param value value to be initialized + * \param e expression (kept) + * \param size value size (in bits) */ -YASM_LIB_DECL void yasm_value_initialize(/*@out@*/ yasm_value *value, - /*@null@*/ /*@kept@*/ yasm_expr *e, - unsigned int size); + /*@null@*/ /*@kept@*/ yasm_expr *e, + unsigned int size); /** Initialize a #yasm_value with just a symrec. No processing is performed, * the symrec is simply stuck into value.rel and the other fields are * initialized. - * \param value value to be initialized - * \param sym symrec - * \param size value size (in bits) + * \param value value to be initialized + * \param sym symrec + * \param size value size (in bits) */ -YASM_LIB_DECL void yasm_value_init_sym(/*@out@*/ yasm_value *value, - /*@null@*/ yasm_symrec *sym, unsigned int size); + /*@null@*/ yasm_symrec *sym, unsigned int size); /** Initialize a #yasm_value as a copy of another yasm_value. Any expressions * within orig are copied, so it's safe to delete the copy. - * \param value value (copy to create) - * \param orig original value + * \param value value (copy to create) + * \param orig original value */ -YASM_LIB_DECL void yasm_value_init_copy(yasm_value *value, const yasm_value *orig); /** Frees any memory inside value; does not free value itself. - * \param value value + * \param value value */ -YASM_LIB_DECL void yasm_value_delete(yasm_value *value); /** Set a value to be relative to the current assembly position rather than * relative to the section start. - * \param value value - * \param bc bytecode containing value + * \param value value + * \param bc bytecode containing value * \param ip_rel if nonzero, indicates IP-relative data relocation, - * sometimes used to generate special relocations + * sometimes used to generate special relocations * \note If value is just an absolute value, will get an absolute symrec to * reference to (via bc's symbol table). */ -YASM_LIB_DECL void yasm_value_set_curpos_rel(yasm_value *value, yasm_bytecode *bc, - unsigned int ip_rel); + unsigned int ip_rel); /** Perform yasm_value_finalize_expr() on a value that already exists from * being initialized with yasm_value_initialize(). - * \param value value - * \param precbc previous bytecode to bytecode containing value + * \param value value + * \param precbc previous bytecode to bytecode containing value * \return Nonzero if value could not be split. */ -YASM_LIB_DECL int yasm_value_finalize(yasm_value *value, /*@null@*/ yasm_bytecode *precbc); /** Break a #yasm_expr into a #yasm_value constituent parts. Extracts @@ -104,10 +98,10 @@ int yasm_value_finalize(yasm_value *value, /*@null@*/ yasm_bytecode *precbc); * and yasm_value_finalize(). First expands references to symrecs in * absolute sections by expanding with the absolute section start plus the * symrec offset within the absolute section. - * \param value value to store split portions into - * \param e expression input - * \param precbc previous bytecode to bytecode containing expression - * \param size value size (in bits) + * \param value value to store split portions into + * \param e expression input + * \param precbc previous bytecode to bytecode containing expression + * \param size value size (in bits) * \return Nonzero if the expr could not be split into a value for some * reason (e.g. the relative portion was not added, but multiplied, * etc). @@ -116,39 +110,37 @@ int yasm_value_finalize(yasm_value *value, /*@null@*/ yasm_bytecode *precbc); * \note This should only be called after the parse is complete. Calling * before the parse is complete will usually result in an error return. */ -YASM_LIB_DECL int yasm_value_finalize_expr(/*@out@*/ yasm_value *value, - /*@null@*/ /*@kept@*/ yasm_expr *e, - /*@null@*/ yasm_bytecode *precbc, - unsigned int size); + /*@null@*/ /*@kept@*/ yasm_expr *e, + /*@null@*/ yasm_bytecode *precbc, + unsigned int size); /** Get value if absolute or PC-relative section-local relative. Returns NULL * otherwise. - * \param value value - * \param bc current bytecode (for PC-relative calculation); if - * NULL, NULL is returned for PC-relative values. - * \param calc_bc_dist if nonzero, calculates bytecode distances in absolute - * portion of value + * \param value value + * \param bc current bytecode (for PC-relative calculation); if + * NULL, NULL is returned for PC-relative values. + * \param calc_bc_dist if nonzero, calculates bytecode distances in absolute + * portion of value * \note Adds in value.rel (correctly) if PC-relative and in the same section * as bc (and there is no WRT or SEG). * \return Intnum if can be resolved to integer value, otherwise NULL. */ -YASM_LIB_DECL /*@null@*/ /*@only@*/ yasm_intnum *yasm_value_get_intnum (yasm_value *value, /*@null@*/ yasm_bytecode *bc, int calc_bc_dist); /** Output value if constant or PC-relative section-local. This should be * used from objfmt yasm_output_value_func() functions. * functions. - * \param value value - * \param buf buffer for byte representation - * \param destsize destination size (in bytes) - * \param bc current bytecode (usually passed into higher-level - * calling function) - * \param warn enables standard warnings: zero for none; - * nonzero for overflow/underflow floating point and - * integer warnings - * \param arch architecture + * \param value value + * \param buf buffer for byte representation + * \param destsize destination size (in bytes) + * \param bc current bytecode (usually passed into higher-level + * calling function) + * \param warn enables standard warnings: zero for none; + * nonzero for overflow/underflow floating point and + * integer warnings + * \param arch architecture * \note Adds in value.rel (correctly) if PC-relative and in the same section * as bc (and there is no WRT or SEG); if this is not the desired * behavior, e.g. a reloc is needed in this case, don't use this @@ -156,17 +148,15 @@ YASM_LIB_DECL * \return 0 if no value output due to value needing relocation; * 1 if value output; -1 if error. */ -YASM_LIB_DECL int yasm_value_output_basic (yasm_value *value, /*@out@*/ unsigned char *buf, size_t destsize, yasm_bytecode *bc, int warn, yasm_arch *arch); /** Print a value. For debugging purposes. - * \param value value - * \param indent_level indentation level - * \param f file + * \param value value + * \param indent_level indentation level + * \param f file */ -YASM_LIB_DECL void yasm_value_print(const yasm_value *value, FILE *f, int indent_level); #endif diff --git a/libyasm/xmalloc.c b/libyasm/xmalloc.c index 81b608c0..261f593b 100644 --- a/libyasm/xmalloc.c +++ b/libyasm/xmalloc.c @@ -24,7 +24,9 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ +#define YASM_LIB_INTERNAL #include "util.h" +RCSID("$Id$"); #include "coretype.h" #include "errwarn.h" @@ -46,15 +48,11 @@ static void def_xfree(/*@only@*/ /*@out@*/ /*@null@*/ void *p) /*@modifies p@*/; /* storage for global function pointers */ -YASM_LIB_DECL /*@only@*/ /*@out@*/ void * (*yasm_xmalloc) (size_t size) = def_xmalloc; -YASM_LIB_DECL /*@only@*/ void * (*yasm_xcalloc) (size_t nelem, size_t elsize) = def_xcalloc; -YASM_LIB_DECL /*@only@*/ void * (*yasm_xrealloc) (/*@only@*/ /*@out@*/ /*@returned@*/ /*@null@*/ void *oldmem, size_t size) /*@modifies oldmem@*/ = def_xrealloc; -YASM_LIB_DECL void (*yasm_xfree) (/*@only@*/ /*@out@*/ /*@null@*/ void *p) /*@modifies p@*/ = def_xfree; @@ -65,10 +63,10 @@ def_xmalloc(size_t size) void *newmem; if (size == 0) - size = 1; + size = 1; newmem = malloc(size); if (!newmem) - yasm__fatal(N_("out of memory")); + yasm__fatal(N_("out of memory")); return newmem; } @@ -79,11 +77,11 @@ def_xcalloc(size_t nelem, size_t elsize) void *newmem; if (nelem == 0 || elsize == 0) - nelem = elsize = 1; + nelem = elsize = 1; newmem = calloc(nelem, elsize); if (!newmem) - yasm__fatal(N_("out of memory")); + yasm__fatal(N_("out of memory")); return newmem; } @@ -94,13 +92,13 @@ def_xrealloc(void *oldmem, size_t size) void *newmem; if (size == 0) - size = 1; + size = 1; if (!oldmem) - newmem = malloc(size); + newmem = malloc(size); else - newmem = realloc(oldmem, size); + newmem = realloc(oldmem, size); if (!newmem) - yasm__fatal(N_("out of memory")); + yasm__fatal(N_("out of memory")); return newmem; } @@ -109,6 +107,6 @@ static void def_xfree(void *p) { if (!p) - return; + return; free(p); } diff --git a/libyasm/xstrdup.c b/libyasm/xstrdup.c index b187704f..cf15ef50 100644 --- a/libyasm/xstrdup.c +++ b/libyasm/xstrdup.c @@ -2,7 +2,7 @@ * strdup() implementation with error checking (using xmalloc). * * Copyright (c) 1988, 1993 - * The Regents of the University of California. All rights reserved. + * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -28,12 +28,14 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ +#define YASM_LIB_INTERNAL #include "util.h" +RCSID("$Id$"); #include "coretype.h" #if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)strdup.c 8.1 (Berkeley) 6/4/93"; +static char sccsid[] = "@(#)strdup.c 8.1 (Berkeley) 6/4/93"; #endif /* LIBC_SCCS and not lint */ @@ -44,13 +46,13 @@ static char sccsid[] = "@(#)strdup.c 8.1 (Berkeley) 6/4/93"; char * yasm__xstrdup(const char *str) { - size_t len; - char *copy; + size_t len; + char *copy; - len = strlen(str) + 1; - copy = yasm_xmalloc(len); - memcpy(copy, str, len); - return (copy); + len = strlen(str) + 1; + copy = yasm_xmalloc(len); + memcpy(copy, str, len); + return (copy); } char * diff --git a/m4/Makefile.inc b/m4/Makefile.inc index 1afffbbf..4dac7a1c 100644 --- a/m4/Makefile.inc +++ b/m4/Makefile.inc @@ -27,4 +27,4 @@ EXTRA_DIST += m4/progtest.m4 EXTRA_DIST += m4/stdint_h.m4 EXTRA_DIST += m4/uintmax_t.m4 EXTRA_DIST += m4/pythonhead.m4 -EXTRA_DIST += m4/cython.m4 +EXTRA_DIST += m4/pyrex.m4 diff --git a/m4/cython.m4 b/m4/cython.m4 deleted file mode 100644 index a7ed9ee1..00000000 --- a/m4/cython.m4 +++ /dev/null @@ -1,36 +0,0 @@ -dnl a macro to check for the installed Cython version -dnl CYTHON_CHECK_VERSION([VERSION [,[ACTION-IF-TRUE [,ACTION-IF-FALSE]]]) -dnl Check if a Cython version is installed -dnl Defines CYTHON_VERSION and CYTHON_FOUND -dnl taken from Enligntenment Foundation Libraries(GPL). -AC_DEFUN([CYTHON_CHECK_VERSION], -[ -AC_REQUIRE([AM_PATH_PYTHON]) -ifelse([$1], [], [_msg=""], [_msg=" >= $1"]) -AC_MSG_CHECKING(for Cython$_msg) -AC_CACHE_VAL(py_cv_cython, [ - -prog="from __future__ import print_function; import Cython.Compiler.Version; print(Cython.Compiler.Version.version)" -CYTHON_VERSION=`$PYTHON -c "$prog" 2>&AC_FD_CC` - -py_cv_cython=no -if test "x$CYTHON_VERSION" != "x"; then - py_cv_cython=yes -fi - -if test "x$py_cv_cython" = "xyes"; then - ifelse([$1], [], [:], - [AS_VERSION_COMPARE([$CYTHON_VERSION], [$1], [py_cv_cython=no])]) -fi -]) - -AC_MSG_RESULT([$py_cv_cython]) - -if test "x$py_cv_cython" = "xyes"; then - CYTHON_FOUND=yes - ifelse([$2], [], [:], [$2]) -else - CYTHON_FOUND=no - ifelse([$3], [], [AC_MSG_ERROR([Could not find usable Cython$_msg])], [$3]) -fi -]) diff --git a/m4/gettext.m4 b/m4/gettext.m4 index 8d1f0665..91c345e9 100644 --- a/m4/gettext.m4 +++ b/m4/gettext.m4 @@ -1,5 +1,5 @@ -# gettext.m4 serial 66 (gettext-0.18.2) -dnl Copyright (C) 1995-2013 Free Software Foundation, Inc. +# gettext.m4 serial 59 (gettext-0.16.1) +dnl Copyright (C) 1995-2006 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -15,7 +15,7 @@ dnl They are *not* in the public domain. dnl Authors: dnl Ulrich Drepper , 1995-2000. -dnl Bruno Haible , 2000-2006, 2008-2010. +dnl Bruno Haible , 2000-2006. dnl Macro to add for using GNU gettext. @@ -35,7 +35,7 @@ dnl will be ignored. If NEEDSYMBOL is specified and is dnl 'need-formatstring-macros', then GNU gettext implementations that don't dnl support the ISO C 99 formatstring macros will be ignored. dnl INTLDIR is used to find the intl libraries. If empty, -dnl the value '$(top_builddir)/intl/' is used. +dnl the value `$(top_builddir)/intl/' is used. dnl dnl The result of the configuration is one of three cases: dnl 1) GNU gettext, as included in the intl subdirectory, will be compiled @@ -60,8 +60,6 @@ AC_DEFUN([AM_GNU_GETTEXT], ifelse([$1], [], , [ifelse([$1], [external], , [ifelse([$1], [no-libtool], , [ifelse([$1], [use-libtool], , [errprint([ERROR: invalid first argument to AM_GNU_GETTEXT ])])])])]) - ifelse(ifelse([$1], [], [old])[]ifelse([$1], [no-libtool], [old]), [old], - [AC_DIAGNOSE([obsolete], [Use of AM_GNU_GETTEXT without [external] argument is deprecated.])]) ifelse([$2], [], , [ifelse([$2], [need-ngettext], , [ifelse([$2], [need-formatstring-macros], , [errprint([ERROR: invalid second argument to AM_GNU_GETTEXT ])])])]) @@ -97,7 +95,7 @@ AC_DEFUN([AM_GNU_GETTEXT], AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY]) ]) - dnl Sometimes, on Mac OS X, libintl requires linking with CoreFoundation. + dnl Sometimes, on MacOS X, libintl requires linking with CoreFoundation. gt_INTL_MACOSX dnl Set USE_NLS. @@ -125,11 +123,11 @@ AC_DEFUN([AM_GNU_GETTEXT], gt_use_preinstalled_gnugettext=no ifelse(gt_included_intl, yes, [ AC_MSG_CHECKING([whether included gettext is requested]) - AC_ARG_WITH([included-gettext], + AC_ARG_WITH(included-gettext, [ --with-included-gettext use the GNU gettext library included here], nls_cv_force_use_gnu_gettext=$withval, nls_cv_force_use_gnu_gettext=no) - AC_MSG_RESULT([$nls_cv_force_use_gnu_gettext]) + AC_MSG_RESULT($nls_cv_force_use_gnu_gettext) nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext" if test "$nls_cv_force_use_gnu_gettext" != "yes"; then @@ -157,18 +155,12 @@ changequote([,])dnl fi AC_CACHE_CHECK([for GNU gettext in libc], [$gt_func_gnugettext_libc], - [AC_LINK_IFELSE( - [AC_LANG_PROGRAM( - [[ -#include + [AC_TRY_LINK([#include $gt_revision_test_code extern int _nl_msg_cat_cntr; -extern int *_nl_domain_bindings; - ]], - [[ -bindtextdomain ("", ""); -return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_domain_bindings - ]])], +extern int *_nl_domain_bindings;], + [bindtextdomain ("", ""); +return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_domain_bindings], [eval "$gt_func_gnugettext_libc=yes"], [eval "$gt_func_gnugettext_libc=no"])]) @@ -189,47 +181,35 @@ return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_domain_b gt_save_LIBS="$LIBS" LIBS="$LIBS $LIBINTL" dnl Now see whether libintl exists and does not depend on libiconv. - AC_LINK_IFELSE( - [AC_LANG_PROGRAM( - [[ -#include + AC_TRY_LINK([#include $gt_revision_test_code extern int _nl_msg_cat_cntr; extern #ifdef __cplusplus "C" #endif -const char *_nl_expand_alias (const char *); - ]], - [[ -bindtextdomain ("", ""); -return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_expand_alias ("") - ]])], +const char *_nl_expand_alias (const char *);], + [bindtextdomain ("", ""); +return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_expand_alias ("")], [eval "$gt_func_gnugettext_libintl=yes"], [eval "$gt_func_gnugettext_libintl=no"]) dnl Now see whether libintl exists and depends on libiconv. if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" != yes; } && test -n "$LIBICONV"; then LIBS="$LIBS $LIBICONV" - AC_LINK_IFELSE( - [AC_LANG_PROGRAM( - [[ -#include + AC_TRY_LINK([#include $gt_revision_test_code extern int _nl_msg_cat_cntr; extern #ifdef __cplusplus "C" #endif -const char *_nl_expand_alias (const char *); - ]], - [[ -bindtextdomain ("", ""); -return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_expand_alias ("") - ]])], - [LIBINTL="$LIBINTL $LIBICONV" - LTLIBINTL="$LTLIBINTL $LTLIBICONV" - eval "$gt_func_gnugettext_libintl=yes" - ]) +const char *_nl_expand_alias (const char *);], + [bindtextdomain ("", ""); +return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_expand_alias ("")], + [LIBINTL="$LIBINTL $LIBICONV" + LTLIBINTL="$LTLIBINTL $LTLIBICONV" + eval "$gt_func_gnugettext_libintl=yes" + ]) fi CPPFLAGS="$gt_save_CPPFLAGS" LIBS="$gt_save_LIBS"]) @@ -287,7 +267,7 @@ return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_expand_a if test "$gt_use_preinstalled_gnugettext" = "yes" \ || test "$nls_cv_use_gnu_gettext" = "yes"; then - AC_DEFINE([ENABLE_NLS], [1], + AC_DEFINE(ENABLE_NLS, 1, [Define to 1 if translation of program messages to the user's native language is requested.]) else @@ -321,9 +301,9 @@ return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_expand_a fi dnl For backward compatibility. Some packages may be using this. - AC_DEFINE([HAVE_GETTEXT], [1], + AC_DEFINE(HAVE_GETTEXT, 1, [Define if the GNU gettext() function is already present or preinstalled.]) - AC_DEFINE([HAVE_DCGETTEXT], [1], + AC_DEFINE(HAVE_DCGETTEXT, 1, [Define if the GNU dcgettext() function is already present or preinstalled.]) fi @@ -339,9 +319,9 @@ return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_expand_a fi dnl Make all variables we use known to autoconf. - AC_SUBST([BUILD_INCLUDED_LIBINTL]) - AC_SUBST([USE_INCLUDED_LIBINTL]) - AC_SUBST([CATOBJEXT]) + AC_SUBST(BUILD_INCLUDED_LIBINTL) + AC_SUBST(USE_INCLUDED_LIBINTL) + AC_SUBST(CATOBJEXT) dnl For backward compatibility. Some configure.ins may be using this. nls_cv_header_intl= @@ -349,36 +329,74 @@ return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_expand_a dnl For backward compatibility. Some Makefiles may be using this. DATADIRNAME=share - AC_SUBST([DATADIRNAME]) + AC_SUBST(DATADIRNAME) dnl For backward compatibility. Some Makefiles may be using this. INSTOBJEXT=.mo - AC_SUBST([INSTOBJEXT]) + AC_SUBST(INSTOBJEXT) dnl For backward compatibility. Some Makefiles may be using this. GENCAT=gencat - AC_SUBST([GENCAT]) + AC_SUBST(GENCAT) dnl For backward compatibility. Some Makefiles may be using this. INTLOBJS= if test "$USE_INCLUDED_LIBINTL" = yes; then INTLOBJS="\$(GETTOBJS)" fi - AC_SUBST([INTLOBJS]) + AC_SUBST(INTLOBJS) dnl Enable libtool support if the surrounding package wishes it. INTL_LIBTOOL_SUFFIX_PREFIX=gt_libtool_suffix_prefix - AC_SUBST([INTL_LIBTOOL_SUFFIX_PREFIX]) + AC_SUBST(INTL_LIBTOOL_SUFFIX_PREFIX) ]) dnl For backward compatibility. Some Makefiles may be using this. INTLLIBS="$LIBINTL" - AC_SUBST([INTLLIBS]) + AC_SUBST(INTLLIBS) dnl Make all documented variables known to autoconf. - AC_SUBST([LIBINTL]) - AC_SUBST([LTLIBINTL]) - AC_SUBST([POSUB]) + AC_SUBST(LIBINTL) + AC_SUBST(LTLIBINTL) + AC_SUBST(POSUB) +]) + + +dnl Checks for special options needed on MacOS X. +dnl Defines INTL_MACOSX_LIBS. +AC_DEFUN([gt_INTL_MACOSX], +[ + dnl Check for API introduced in MacOS X 10.2. + AC_CACHE_CHECK([for CFPreferencesCopyAppValue], + gt_cv_func_CFPreferencesCopyAppValue, + [gt_save_LIBS="$LIBS" + LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation" + AC_TRY_LINK([#include ], + [CFPreferencesCopyAppValue(NULL, NULL)], + [gt_cv_func_CFPreferencesCopyAppValue=yes], + [gt_cv_func_CFPreferencesCopyAppValue=no]) + LIBS="$gt_save_LIBS"]) + if test $gt_cv_func_CFPreferencesCopyAppValue = yes; then + AC_DEFINE([HAVE_CFPREFERENCESCOPYAPPVALUE], 1, + [Define to 1 if you have the MacOS X function CFPreferencesCopyAppValue in the CoreFoundation framework.]) + fi + dnl Check for API introduced in MacOS X 10.3. + AC_CACHE_CHECK([for CFLocaleCopyCurrent], gt_cv_func_CFLocaleCopyCurrent, + [gt_save_LIBS="$LIBS" + LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation" + AC_TRY_LINK([#include ], [CFLocaleCopyCurrent();], + [gt_cv_func_CFLocaleCopyCurrent=yes], + [gt_cv_func_CFLocaleCopyCurrent=no]) + LIBS="$gt_save_LIBS"]) + if test $gt_cv_func_CFLocaleCopyCurrent = yes; then + AC_DEFINE([HAVE_CFLOCALECOPYCURRENT], 1, + [Define to 1 if you have the MacOS X function CFLocaleCopyCurrent in the CoreFoundation framework.]) + fi + INTL_MACOSX_LIBS= + if test $gt_cv_func_CFPreferencesCopyAppValue = yes || test $gt_cv_func_CFLocaleCopyCurrent = yes; then + INTL_MACOSX_LIBS="-Wl,-framework -Wl,CoreFoundation" + fi + AC_SUBST([INTL_MACOSX_LIBS]) ]) diff --git a/m4/iconv.m4 b/m4/iconv.m4 index a5036465..654c4158 100644 --- a/m4/iconv.m4 +++ b/m4/iconv.m4 @@ -1,5 +1,5 @@ -# iconv.m4 serial 18 (gettext-0.18.2) -dnl Copyright (C) 2000-2002, 2007-2013 Free Software Foundation, Inc. +# iconv.m4 serial AM4 (gettext-0.11.3) +dnl Copyright (C) 2000-2002 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -21,7 +21,6 @@ AC_DEFUN([AM_ICONV_LINK], [ dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and dnl those with the standalone portable GNU libiconv installed). - AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV dnl accordingly. @@ -30,170 +29,34 @@ AC_DEFUN([AM_ICONV_LINK], dnl Add $INCICONV to CPPFLAGS before performing the following checks, dnl because if the user has installed libiconv and not disabled its use dnl via --without-libiconv-prefix, he wants to use it. The first - dnl AC_LINK_IFELSE will then fail, the second AC_LINK_IFELSE will succeed. + dnl AC_TRY_LINK will then fail, the second AC_TRY_LINK will succeed. am_save_CPPFLAGS="$CPPFLAGS" AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCICONV]) - AC_CACHE_CHECK([for iconv], [am_cv_func_iconv], [ + AC_CACHE_CHECK(for iconv, am_cv_func_iconv, [ am_cv_func_iconv="no, consider installing GNU libiconv" am_cv_lib_iconv=no - AC_LINK_IFELSE( - [AC_LANG_PROGRAM( - [[ -#include -#include - ]], - [[iconv_t cd = iconv_open("",""); - iconv(cd,NULL,NULL,NULL,NULL); - iconv_close(cd);]])], - [am_cv_func_iconv=yes]) + AC_TRY_LINK([#include +#include ], + [iconv_t cd = iconv_open("",""); + iconv(cd,NULL,NULL,NULL,NULL); + iconv_close(cd);], + am_cv_func_iconv=yes) if test "$am_cv_func_iconv" != yes; then am_save_LIBS="$LIBS" LIBS="$LIBS $LIBICONV" - AC_LINK_IFELSE( - [AC_LANG_PROGRAM( - [[ -#include -#include - ]], - [[iconv_t cd = iconv_open("",""); - iconv(cd,NULL,NULL,NULL,NULL); - iconv_close(cd);]])], - [am_cv_lib_iconv=yes] - [am_cv_func_iconv=yes]) + AC_TRY_LINK([#include +#include ], + [iconv_t cd = iconv_open("",""); + iconv(cd,NULL,NULL,NULL,NULL); + iconv_close(cd);], + am_cv_lib_iconv=yes + am_cv_func_iconv=yes) LIBS="$am_save_LIBS" fi ]) if test "$am_cv_func_iconv" = yes; then - AC_CACHE_CHECK([for working iconv], [am_cv_func_iconv_works], [ - dnl This tests against bugs in AIX 5.1, AIX 6.1..7.1, HP-UX 11.11, - dnl Solaris 10. - am_save_LIBS="$LIBS" - if test $am_cv_lib_iconv = yes; then - LIBS="$LIBS $LIBICONV" - fi - AC_RUN_IFELSE( - [AC_LANG_SOURCE([[ -#include -#include -int main () -{ - int result = 0; - /* Test against AIX 5.1 bug: Failures are not distinguishable from successful - returns. */ - { - iconv_t cd_utf8_to_88591 = iconv_open ("ISO8859-1", "UTF-8"); - if (cd_utf8_to_88591 != (iconv_t)(-1)) - { - static const char input[] = "\342\202\254"; /* EURO SIGN */ - char buf[10]; - const char *inptr = input; - size_t inbytesleft = strlen (input); - char *outptr = buf; - size_t outbytesleft = sizeof (buf); - size_t res = iconv (cd_utf8_to_88591, - (char **) &inptr, &inbytesleft, - &outptr, &outbytesleft); - if (res == 0) - result |= 1; - iconv_close (cd_utf8_to_88591); - } - } - /* Test against Solaris 10 bug: Failures are not distinguishable from - successful returns. */ - { - iconv_t cd_ascii_to_88591 = iconv_open ("ISO8859-1", "646"); - if (cd_ascii_to_88591 != (iconv_t)(-1)) - { - static const char input[] = "\263"; - char buf[10]; - const char *inptr = input; - size_t inbytesleft = strlen (input); - char *outptr = buf; - size_t outbytesleft = sizeof (buf); - size_t res = iconv (cd_ascii_to_88591, - (char **) &inptr, &inbytesleft, - &outptr, &outbytesleft); - if (res == 0) - result |= 2; - iconv_close (cd_ascii_to_88591); - } - } - /* Test against AIX 6.1..7.1 bug: Buffer overrun. */ - { - iconv_t cd_88591_to_utf8 = iconv_open ("UTF-8", "ISO-8859-1"); - if (cd_88591_to_utf8 != (iconv_t)(-1)) - { - static const char input[] = "\304"; - static char buf[2] = { (char)0xDE, (char)0xAD }; - const char *inptr = input; - size_t inbytesleft = 1; - char *outptr = buf; - size_t outbytesleft = 1; - size_t res = iconv (cd_88591_to_utf8, - (char **) &inptr, &inbytesleft, - &outptr, &outbytesleft); - if (res != (size_t)(-1) || outptr - buf > 1 || buf[1] != (char)0xAD) - result |= 4; - iconv_close (cd_88591_to_utf8); - } - } -#if 0 /* This bug could be worked around by the caller. */ - /* Test against HP-UX 11.11 bug: Positive return value instead of 0. */ - { - iconv_t cd_88591_to_utf8 = iconv_open ("utf8", "iso88591"); - if (cd_88591_to_utf8 != (iconv_t)(-1)) - { - static const char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337"; - char buf[50]; - const char *inptr = input; - size_t inbytesleft = strlen (input); - char *outptr = buf; - size_t outbytesleft = sizeof (buf); - size_t res = iconv (cd_88591_to_utf8, - (char **) &inptr, &inbytesleft, - &outptr, &outbytesleft); - if ((int)res > 0) - result |= 8; - iconv_close (cd_88591_to_utf8); - } - } -#endif - /* Test against HP-UX 11.11 bug: No converter from EUC-JP to UTF-8 is - provided. */ - if (/* Try standardized names. */ - iconv_open ("UTF-8", "EUC-JP") == (iconv_t)(-1) - /* Try IRIX, OSF/1 names. */ - && iconv_open ("UTF-8", "eucJP") == (iconv_t)(-1) - /* Try AIX names. */ - && iconv_open ("UTF-8", "IBM-eucJP") == (iconv_t)(-1) - /* Try HP-UX names. */ - && iconv_open ("utf8", "eucJP") == (iconv_t)(-1)) - result |= 16; - return result; -}]])], - [am_cv_func_iconv_works=yes], - [am_cv_func_iconv_works=no], - [ -changequote(,)dnl - case "$host_os" in - aix* | hpux*) am_cv_func_iconv_works="guessing no" ;; - *) am_cv_func_iconv_works="guessing yes" ;; - esac -changequote([,])dnl - ]) - LIBS="$am_save_LIBS" - ]) - case "$am_cv_func_iconv_works" in - *no) am_func_iconv=no am_cv_lib_iconv=no ;; - *) am_func_iconv=yes ;; - esac - else - am_func_iconv=no am_cv_lib_iconv=no - fi - if test "$am_func_iconv" = yes; then - AC_DEFINE([HAVE_ICONV], [1], - [Define if you have the iconv() function and it works.]) + AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.]) fi if test "$am_cv_lib_iconv" = yes; then AC_MSG_CHECKING([how to link with libiconv]) @@ -205,64 +68,34 @@ changequote([,])dnl LIBICONV= LTLIBICONV= fi - AC_SUBST([LIBICONV]) - AC_SUBST([LTLIBICONV]) + AC_SUBST(LIBICONV) + AC_SUBST(LTLIBICONV) ]) -dnl Define AM_ICONV using AC_DEFUN_ONCE for Autoconf >= 2.64, in order to -dnl avoid warnings like -dnl "warning: AC_REQUIRE: `AM_ICONV' was expanded before it was required". -dnl This is tricky because of the way 'aclocal' is implemented: -dnl - It requires defining an auxiliary macro whose name ends in AC_DEFUN. -dnl Otherwise aclocal's initial scan pass would miss the macro definition. -dnl - It requires a line break inside the AC_DEFUN_ONCE and AC_DEFUN expansions. -dnl Otherwise aclocal would emit many "Use of uninitialized value $1" -dnl warnings. -m4_define([gl_iconv_AC_DEFUN], - m4_version_prereq([2.64], - [[AC_DEFUN_ONCE( - [$1], [$2])]], - [m4_ifdef([gl_00GNULIB], - [[AC_DEFUN_ONCE( - [$1], [$2])]], - [[AC_DEFUN( - [$1], [$2])]])])) -gl_iconv_AC_DEFUN([AM_ICONV], +AC_DEFUN([AM_ICONV], [ AM_ICONV_LINK if test "$am_cv_func_iconv" = yes; then AC_MSG_CHECKING([for iconv declaration]) - AC_CACHE_VAL([am_cv_proto_iconv], [ - AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM( - [[ + AC_CACHE_VAL(am_cv_proto_iconv, [ + AC_TRY_COMPILE([ #include #include extern #ifdef __cplusplus "C" #endif -#if defined(__STDC__) || defined(_MSC_VER) || defined(__cplusplus) +#if defined(__STDC__) || defined(__cplusplus) size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft); #else size_t iconv(); #endif - ]], - [[]])], - [am_cv_proto_iconv_arg1=""], - [am_cv_proto_iconv_arg1="const"]) +], [], am_cv_proto_iconv_arg1="", am_cv_proto_iconv_arg1="const") am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"]) am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'` - AC_MSG_RESULT([ - $am_cv_proto_iconv]) - AC_DEFINE_UNQUOTED([ICONV_CONST], [$am_cv_proto_iconv_arg1], + AC_MSG_RESULT([$]{ac_t:- + }[$]am_cv_proto_iconv) + AC_DEFINE_UNQUOTED(ICONV_CONST, $am_cv_proto_iconv_arg1, [Define as const if the declaration of iconv() needs const.]) - dnl Also substitute ICONV_CONST in the gnulib generated . - m4_ifdef([gl_ICONV_H_DEFAULTS], - [AC_REQUIRE([gl_ICONV_H_DEFAULTS]) - if test -n "$am_cv_proto_iconv_arg1"; then - ICONV_CONST="const" - fi - ]) fi ]) diff --git a/m4/lib-ld.m4 b/m4/lib-ld.m4 index c145e478..96c4e2c3 100644 --- a/m4/lib-ld.m4 +++ b/m4/lib-ld.m4 @@ -1,56 +1,50 @@ -# lib-ld.m4 serial 6 -dnl Copyright (C) 1996-2003, 2009-2013 Free Software Foundation, Inc. +# lib-ld.m4 serial 3 (gettext-0.13) +dnl Copyright (C) 1996-2003 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl Subroutines of libtool.m4, -dnl with replacements s/_*LT_PATH/AC_LIB_PROG/ and s/lt_/acl_/ to avoid -dnl collision with libtool.m4. +dnl with replacements s/AC_/AC_LIB/ and s/lt_cv/acl_cv/ to avoid collision +dnl with libtool.m4. -dnl From libtool-2.4. Sets the variable with_gnu_ld to yes or no. +dnl From libtool-1.4. Sets the variable with_gnu_ld to yes or no. AC_DEFUN([AC_LIB_PROG_LD_GNU], -[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], [acl_cv_prog_gnu_ld], -[# I'd rather use --version here, but apparently some GNU lds only accept -v. +[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], acl_cv_prog_gnu_ld, +[# I'd rather use --version here, but apparently some GNU ld's only accept -v. case `$LD -v 2>&1 /dev/null 2>&1 \ - && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \ - || PATH_SEPARATOR=';' - } + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh fi - ac_prog=ld if test "$GCC" = yes; then # Check if gcc -print-prog-name=ld gives a path. - AC_MSG_CHECKING([for ld used by $CC]) + AC_MSG_CHECKING([for ld used by GCC]) case $host in *-*-mingw*) # gcc leaves a trailing carriage return which upsets mingw @@ -60,12 +54,12 @@ if test "$GCC" = yes; then esac case $ac_prog in # Accept absolute paths. - [[\\/]]* | ?:[[\\/]]*) - re_direlt='/[[^/]][[^/]]*/\.\./' - # Canonicalize the pathname of ld - ac_prog=`echo "$ac_prog"| sed 's%\\\\%/%g'` - while echo "$ac_prog" | grep "$re_direlt" > /dev/null 2>&1; do - ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"` + [[\\/]* | [A-Za-z]:[\\/]*)] + [re_direlt='/[^/][^/]*/\.\./'] + # Canonicalize the path of ld + ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'` + while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do + ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"` done test -z "$LD" && LD="$ac_prog" ;; @@ -83,36 +77,33 @@ elif test "$with_gnu_ld" = yes; then else AC_MSG_CHECKING([for non-GNU ld]) fi -AC_CACHE_VAL([acl_cv_path_LD], +AC_CACHE_VAL(acl_cv_path_LD, [if test -z "$LD"; then - acl_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}" for ac_dir in $PATH; do - IFS="$acl_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then acl_cv_path_LD="$ac_dir/$ac_prog" # Check to see if the program is GNU ld. I'd rather use --version, - # but apparently some variants of GNU ld only accept -v. + # but apparently some GNU ld's only accept -v. # Break only if it was the GNU/non-GNU ld that we prefer. - case `"$acl_cv_path_LD" -v 2>&1 &1 < /dev/null` in *GNU* | *'with BFD'*) - test "$with_gnu_ld" != no && break - ;; + test "$with_gnu_ld" != no && break ;; *) - test "$with_gnu_ld" != yes && break - ;; + test "$with_gnu_ld" != yes && break ;; esac fi done - IFS="$acl_save_ifs" + IFS="$ac_save_ifs" else acl_cv_path_LD="$LD" # Let the user override the test with a path. fi]) LD="$acl_cv_path_LD" if test -n "$LD"; then - AC_MSG_RESULT([$LD]) + AC_MSG_RESULT($LD) else - AC_MSG_RESULT([no]) + AC_MSG_RESULT(no) fi test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH]) AC_LIB_PROG_LD_GNU diff --git a/m4/lib-link.m4 b/m4/lib-link.m4 index 073f0405..f95b7ba8 100644 --- a/m4/lib-link.m4 +++ b/m4/lib-link.m4 @@ -1,66 +1,58 @@ -# lib-link.m4 serial 26 (gettext-0.18.2) -dnl Copyright (C) 2001-2013 Free Software Foundation, Inc. +# lib-link.m4 serial 9 (gettext-0.16) +dnl Copyright (C) 2001-2006 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl From Bruno Haible. -AC_PREREQ([2.54]) +AC_PREREQ(2.50) dnl AC_LIB_LINKFLAGS(name [, dependencies]) searches for libname and dnl the libraries corresponding to explicit and implicit dependencies. dnl Sets and AC_SUBSTs the LIB${NAME} and LTLIB${NAME} variables and dnl augments the CPPFLAGS variable. -dnl Sets and AC_SUBSTs the LIB${NAME}_PREFIX variable to nonempty if libname -dnl was found in ${LIB${NAME}_PREFIX}/$acl_libdirstem. AC_DEFUN([AC_LIB_LINKFLAGS], [ AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) AC_REQUIRE([AC_LIB_RPATH]) - pushdef([Name],[m4_translit([$1],[./+-], [____])]) - pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-], - [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) + define([Name],[translit([$1],[./-], [___])]) + define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], + [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) AC_CACHE_CHECK([how to link with lib[]$1], [ac_cv_lib[]Name[]_libs], [ AC_LIB_LINKFLAGS_BODY([$1], [$2]) ac_cv_lib[]Name[]_libs="$LIB[]NAME" ac_cv_lib[]Name[]_ltlibs="$LTLIB[]NAME" ac_cv_lib[]Name[]_cppflags="$INC[]NAME" - ac_cv_lib[]Name[]_prefix="$LIB[]NAME[]_PREFIX" ]) LIB[]NAME="$ac_cv_lib[]Name[]_libs" LTLIB[]NAME="$ac_cv_lib[]Name[]_ltlibs" INC[]NAME="$ac_cv_lib[]Name[]_cppflags" - LIB[]NAME[]_PREFIX="$ac_cv_lib[]Name[]_prefix" AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME) AC_SUBST([LIB]NAME) AC_SUBST([LTLIB]NAME) - AC_SUBST([LIB]NAME[_PREFIX]) dnl Also set HAVE_LIB[]NAME so that AC_LIB_HAVE_LINKFLAGS can reuse the dnl results of this search when this library appears as a dependency. HAVE_LIB[]NAME=yes - popdef([NAME]) - popdef([Name]) + undefine([Name]) + undefine([NAME]) ]) -dnl AC_LIB_HAVE_LINKFLAGS(name, dependencies, includes, testcode, [missing-message]) +dnl AC_LIB_HAVE_LINKFLAGS(name, dependencies, includes, testcode) dnl searches for libname and the libraries corresponding to explicit and dnl implicit dependencies, together with the specified include files and -dnl the ability to compile and link the specified testcode. The missing-message -dnl defaults to 'no' and may contain additional hints for the user. -dnl If found, it sets and AC_SUBSTs HAVE_LIB${NAME}=yes and the LIB${NAME} -dnl and LTLIB${NAME} variables and augments the CPPFLAGS variable, and +dnl the ability to compile and link the specified testcode. If found, it +dnl sets and AC_SUBSTs HAVE_LIB${NAME}=yes and the LIB${NAME} and +dnl LTLIB${NAME} variables and augments the CPPFLAGS variable, and dnl #defines HAVE_LIB${NAME} to 1. Otherwise, it sets and AC_SUBSTs dnl HAVE_LIB${NAME}=no and LIB${NAME} and LTLIB${NAME} to empty. -dnl Sets and AC_SUBSTs the LIB${NAME}_PREFIX variable to nonempty if libname -dnl was found in ${LIB${NAME}_PREFIX}/$acl_libdirstem. AC_DEFUN([AC_LIB_HAVE_LINKFLAGS], [ AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) AC_REQUIRE([AC_LIB_RPATH]) - pushdef([Name],[m4_translit([$1],[./+-], [____])]) - pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-], - [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) + define([Name],[translit([$1],[./-], [___])]) + define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], + [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) dnl Search for lib[]Name and define LIB[]NAME, LTLIB[]NAME and INC[]NAME dnl accordingly. @@ -74,26 +66,13 @@ AC_DEFUN([AC_LIB_HAVE_LINKFLAGS], AC_CACHE_CHECK([for lib[]$1], [ac_cv_lib[]Name], [ ac_save_LIBS="$LIBS" - dnl If $LIB[]NAME contains some -l options, add it to the end of LIBS, - dnl because these -l options might require -L options that are present in - dnl LIBS. -l options benefit only from the -L options listed before it. - dnl Otherwise, add it to the front of LIBS, because it may be a static - dnl library that depends on another static library that is present in LIBS. - dnl Static libraries benefit only from the static libraries listed after - dnl it. - case " $LIB[]NAME" in - *" -l"*) LIBS="$LIBS $LIB[]NAME" ;; - *) LIBS="$LIB[]NAME $LIBS" ;; - esac - AC_LINK_IFELSE( - [AC_LANG_PROGRAM([[$3]], [[$4]])], - [ac_cv_lib[]Name=yes], - [ac_cv_lib[]Name='m4_if([$5], [], [no], [[$5]])']) + LIBS="$LIBS $LIB[]NAME" + AC_TRY_LINK([$3], [$4], [ac_cv_lib[]Name=yes], [ac_cv_lib[]Name=no]) LIBS="$ac_save_LIBS" ]) if test "$ac_cv_lib[]Name" = yes; then HAVE_LIB[]NAME=yes - AC_DEFINE([HAVE_LIB]NAME, 1, [Define if you have the lib][$1 library.]) + AC_DEFINE([HAVE_LIB]NAME, 1, [Define if you have the $1 library.]) AC_MSG_CHECKING([how to link with lib[]$1]) AC_MSG_RESULT([$LIB[]NAME]) else @@ -103,25 +82,17 @@ AC_DEFUN([AC_LIB_HAVE_LINKFLAGS], CPPFLAGS="$ac_save_CPPFLAGS" LIB[]NAME= LTLIB[]NAME= - LIB[]NAME[]_PREFIX= fi AC_SUBST([HAVE_LIB]NAME) AC_SUBST([LIB]NAME) AC_SUBST([LTLIB]NAME) - AC_SUBST([LIB]NAME[_PREFIX]) - popdef([NAME]) - popdef([Name]) + undefine([Name]) + undefine([NAME]) ]) dnl Determine the platform dependent parameters needed to use rpath: -dnl acl_libext, -dnl acl_shlibext, -dnl acl_libname_spec, -dnl acl_library_names_spec, -dnl acl_hardcode_libdir_flag_spec, -dnl acl_hardcode_libdir_separator, -dnl acl_hardcode_direct, -dnl acl_hardcode_minus_L. +dnl libext, shlibext, hardcode_libdir_flag_spec, hardcode_libdir_separator, +dnl hardcode_direct, hardcode_minus_L. AC_DEFUN([AC_LIB_RPATH], [ dnl Tell automake >= 1.10 to complain if config.rpath is missing. @@ -130,7 +101,7 @@ AC_DEFUN([AC_LIB_RPATH], AC_REQUIRE([AC_LIB_PROG_LD]) dnl we use $LD, $with_gnu_ld AC_REQUIRE([AC_CANONICAL_HOST]) dnl we use $host AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT]) dnl we use $ac_aux_dir - AC_CACHE_CHECK([for shared library run path origin], [acl_cv_rpath], [ + AC_CACHE_CHECK([for shared library run path origin], acl_cv_rpath, [ CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \ ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh . ./conftest.sh @@ -138,66 +109,35 @@ AC_DEFUN([AC_LIB_RPATH], acl_cv_rpath=done ]) wl="$acl_cv_wl" - acl_libext="$acl_cv_libext" - acl_shlibext="$acl_cv_shlibext" - acl_libname_spec="$acl_cv_libname_spec" - acl_library_names_spec="$acl_cv_library_names_spec" - acl_hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec" - acl_hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator" - acl_hardcode_direct="$acl_cv_hardcode_direct" - acl_hardcode_minus_L="$acl_cv_hardcode_minus_L" + libext="$acl_cv_libext" + shlibext="$acl_cv_shlibext" + hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec" + hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator" + hardcode_direct="$acl_cv_hardcode_direct" + hardcode_minus_L="$acl_cv_hardcode_minus_L" dnl Determine whether the user wants rpath handling at all. - AC_ARG_ENABLE([rpath], + AC_ARG_ENABLE(rpath, [ --disable-rpath do not hardcode runtime library paths], :, enable_rpath=yes) ]) -dnl AC_LIB_FROMPACKAGE(name, package) -dnl declares that libname comes from the given package. The configure file -dnl will then not have a --with-libname-prefix option but a -dnl --with-package-prefix option. Several libraries can come from the same -dnl package. This declaration must occur before an AC_LIB_LINKFLAGS or similar -dnl macro call that searches for libname. -AC_DEFUN([AC_LIB_FROMPACKAGE], -[ - pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-], - [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) - define([acl_frompackage_]NAME, [$2]) - popdef([NAME]) - pushdef([PACK],[$2]) - pushdef([PACKUP],[m4_translit(PACK,[abcdefghijklmnopqrstuvwxyz./+-], - [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) - define([acl_libsinpackage_]PACKUP, - m4_ifdef([acl_libsinpackage_]PACKUP, [m4_defn([acl_libsinpackage_]PACKUP)[, ]],)[lib$1]) - popdef([PACKUP]) - popdef([PACK]) -]) - dnl AC_LIB_LINKFLAGS_BODY(name [, dependencies]) searches for libname and dnl the libraries corresponding to explicit and implicit dependencies. dnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables. -dnl Also, sets the LIB${NAME}_PREFIX variable to nonempty if libname was found -dnl in ${LIB${NAME}_PREFIX}/$acl_libdirstem. AC_DEFUN([AC_LIB_LINKFLAGS_BODY], [ AC_REQUIRE([AC_LIB_PREPARE_MULTILIB]) - pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-], - [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) - pushdef([PACK],[m4_ifdef([acl_frompackage_]NAME, [acl_frompackage_]NAME, lib[$1])]) - pushdef([PACKUP],[m4_translit(PACK,[abcdefghijklmnopqrstuvwxyz./+-], - [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) - pushdef([PACKLIBS],[m4_ifdef([acl_frompackage_]NAME, [acl_libsinpackage_]PACKUP, lib[$1])]) - dnl Autoconf >= 2.61 supports dots in --with options. - pushdef([P_A_C_K],[m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]),[2.61]),[-1],[m4_translit(PACK,[.],[_])],PACK)]) + define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], + [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) dnl By default, look in $includedir and $libdir. use_additional=yes AC_LIB_WITH_FINAL_PREFIX([ eval additional_includedir=\"$includedir\" eval additional_libdir=\"$libdir\" ]) - AC_ARG_WITH(P_A_C_K[-prefix], -[[ --with-]]P_A_C_K[[-prefix[=DIR] search for ]PACKLIBS[ in DIR/include and DIR/lib - --without-]]P_A_C_K[[-prefix don't search for ]PACKLIBS[ in includedir and libdir]], + AC_LIB_ARG_WITH([lib$1-prefix], +[ --with-lib$1-prefix[=DIR] search for lib$1 in DIR/include and DIR/lib + --without-lib$1-prefix don't search for lib$1 in includedir and libdir], [ if test "X$withval" = "Xno"; then use_additional=no @@ -210,10 +150,6 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY], else additional_includedir="$withval/include" additional_libdir="$withval/$acl_libdirstem" - if test "$acl_libdirstem2" != "$acl_libdirstem" \ - && ! test -d "$withval/$acl_libdirstem"; then - additional_libdir="$withval/$acl_libdirstem2" - fi fi fi ]) @@ -222,10 +158,6 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY], LIB[]NAME= LTLIB[]NAME= INC[]NAME= - LIB[]NAME[]_PREFIX= - dnl HAVE_LIB${NAME} is an indicator that LIB${NAME}, LTLIB${NAME} have been - dnl computed. So it has to be reset here. - HAVE_LIB[]NAME= rpathdirs= ltrpathdirs= names_already_handled= @@ -245,7 +177,7 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY], names_already_handled="$names_already_handled $name" dnl See if it was already located by an earlier AC_LIB_LINKFLAGS dnl or AC_LIB_HAVE_LINKFLAGS call. - uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./+-|ABCDEFGHIJKLMNOPQRSTUVWXYZ____|'` + uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'` eval value=\"\$HAVE_LIB$uppername\" if test -n "$value"; then if test "$value" = yes; then @@ -265,55 +197,29 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY], found_la= found_so= found_a= - eval libname=\"$acl_libname_spec\" # typically: libname=lib$name - if test -n "$acl_shlibext"; then - shrext=".$acl_shlibext" # typically: shrext=.so - else - shrext= - fi if test $use_additional = yes; then - dir="$additional_libdir" - dnl The same code as in the loop below: - dnl First look for a shared library. - if test -n "$acl_shlibext"; then - if test -f "$dir/$libname$shrext"; then - found_dir="$dir" - found_so="$dir/$libname$shrext" + if test -n "$shlibext" \ + && { test -f "$additional_libdir/lib$name.$shlibext" \ + || { test "$shlibext" = dll \ + && test -f "$additional_libdir/lib$name.dll.a"; }; }; then + found_dir="$additional_libdir" + if test -f "$additional_libdir/lib$name.$shlibext"; then + found_so="$additional_libdir/lib$name.$shlibext" else - if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then - ver=`(cd "$dir" && \ - for f in "$libname$shrext".*; do echo "$f"; done \ - | sed -e "s,^$libname$shrext\\\\.,," \ - | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ - | sed 1q ) 2>/dev/null` - if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then - found_dir="$dir" - found_so="$dir/$libname$shrext.$ver" - fi - else - eval library_names=\"$acl_library_names_spec\" - for f in $library_names; do - if test -f "$dir/$f"; then - found_dir="$dir" - found_so="$dir/$f" - break - fi - done + found_so="$additional_libdir/lib$name.dll.a" + fi + if test -f "$additional_libdir/lib$name.la"; then + found_la="$additional_libdir/lib$name.la" + fi + else + if test -f "$additional_libdir/lib$name.$libext"; then + found_dir="$additional_libdir" + found_a="$additional_libdir/lib$name.$libext" + if test -f "$additional_libdir/lib$name.la"; then + found_la="$additional_libdir/lib$name.la" fi fi fi - dnl Then look for a static library. - if test "X$found_dir" = "X"; then - if test -f "$dir/$libname.$acl_libext"; then - found_dir="$dir" - found_a="$dir/$libname.$acl_libext" - fi - fi - if test "X$found_dir" != "X"; then - if test -f "$dir/$libname.la"; then - found_la="$dir/$libname.la" - fi - fi fi if test "X$found_dir" = "X"; then for x in $LDFLAGS $LTLIB[]NAME; do @@ -321,44 +227,26 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY], case "$x" in -L*) dir=`echo "X$x" | sed -e 's/^X-L//'` - dnl First look for a shared library. - if test -n "$acl_shlibext"; then - if test -f "$dir/$libname$shrext"; then - found_dir="$dir" - found_so="$dir/$libname$shrext" + if test -n "$shlibext" \ + && { test -f "$dir/lib$name.$shlibext" \ + || { test "$shlibext" = dll \ + && test -f "$dir/lib$name.dll.a"; }; }; then + found_dir="$dir" + if test -f "$dir/lib$name.$shlibext"; then + found_so="$dir/lib$name.$shlibext" else - if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then - ver=`(cd "$dir" && \ - for f in "$libname$shrext".*; do echo "$f"; done \ - | sed -e "s,^$libname$shrext\\\\.,," \ - | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ - | sed 1q ) 2>/dev/null` - if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then - found_dir="$dir" - found_so="$dir/$libname$shrext.$ver" - fi - else - eval library_names=\"$acl_library_names_spec\" - for f in $library_names; do - if test -f "$dir/$f"; then - found_dir="$dir" - found_so="$dir/$f" - break - fi - done - fi + found_so="$dir/lib$name.dll.a" fi - fi - dnl Then look for a static library. - if test "X$found_dir" = "X"; then - if test -f "$dir/$libname.$acl_libext"; then + if test -f "$dir/lib$name.la"; then + found_la="$dir/lib$name.la" + fi + else + if test -f "$dir/lib$name.$libext"; then found_dir="$dir" - found_a="$dir/$libname.$acl_libext" - fi - fi - if test "X$found_dir" != "X"; then - if test -f "$dir/$libname.la"; then - found_la="$dir/$libname.la" + found_a="$dir/lib$name.$libext" + if test -f "$dir/lib$name.la"; then + found_la="$dir/lib$name.la" + fi fi fi ;; @@ -375,9 +263,7 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY], dnl Linking with a shared library. We attempt to hardcode its dnl directory into the executable's runpath, unless it's the dnl standard /usr/lib. - if test "$enable_rpath" = no \ - || test "X$found_dir" = "X/usr/$acl_libdirstem" \ - || test "X$found_dir" = "X/usr/$acl_libdirstem2"; then + if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/$acl_libdirstem"; then dnl No hardcoding is needed. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" else @@ -396,12 +282,12 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY], ltrpathdirs="$ltrpathdirs $found_dir" fi dnl The hardcoding into $LIBNAME is system dependent. - if test "$acl_hardcode_direct" = yes; then + if test "$hardcode_direct" = yes; then dnl Using DIR/libNAME.so during linking hardcodes DIR into the dnl resulting binary. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" else - if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then + if test -n "$hardcode_libdir_flag_spec" && test "$hardcode_minus_L" = no; then dnl Use an explicit option to hardcode DIR into the resulting dnl binary. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" @@ -432,13 +318,13 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY], if test -z "$haveit"; then LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir" fi - if test "$acl_hardcode_minus_L" != no; then + if test "$hardcode_minus_L" != no; then dnl FIXME: Not sure whether we should use dnl "-L$found_dir -l$name" or "-L$found_dir $found_so" dnl here. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" else - dnl We cannot use $acl_hardcode_runpath_var and LD_RUN_PATH + dnl We cannot use $hardcode_runpath_var and LD_RUN_PATH dnl here, because this doesn't fit in flags passed to the dnl compiler. So give up. No hardcoding. This affects only dnl very old systems. @@ -465,16 +351,6 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY], case "$found_dir" in */$acl_libdirstem | */$acl_libdirstem/) basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem/"'*$,,'` - if test "$name" = '$1'; then - LIB[]NAME[]_PREFIX="$basedir" - fi - additional_includedir="$basedir/include" - ;; - */$acl_libdirstem2 | */$acl_libdirstem2/) - basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem2/"'*$,,'` - if test "$name" = '$1'; then - LIB[]NAME[]_PREFIX="$basedir" - fi additional_includedir="$basedir/include" ;; esac @@ -535,11 +411,9 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY], dnl 3. if it's already present in $LDFLAGS or the already dnl constructed $LIBNAME, dnl 4. if it doesn't exist as a directory. - if test "X$additional_libdir" != "X/usr/$acl_libdirstem" \ - && test "X$additional_libdir" != "X/usr/$acl_libdirstem2"; then + if test "X$additional_libdir" != "X/usr/$acl_libdirstem"; then haveit= - if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem" \ - || test "X$additional_libdir" = "X/usr/local/$acl_libdirstem2"; then + if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem"; then if test -n "$GCC"; then case $host_os in linux* | gnu* | k*bsd*-gnu) haveit=yes;; @@ -638,18 +512,18 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY], done done if test "X$rpathdirs" != "X"; then - if test -n "$acl_hardcode_libdir_separator"; then + if test -n "$hardcode_libdir_separator"; then dnl Weird platform: only the last -rpath option counts, the user must dnl pass all path elements in one option. We can arrange that for a dnl single library, but not when more than one $LIBNAMEs are used. alldirs= for found_dir in $rpathdirs; do - alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$found_dir" + alldirs="${alldirs}${alldirs:+$hardcode_libdir_separator}$found_dir" done - dnl Note: acl_hardcode_libdir_flag_spec uses $libdir and $wl. + dnl Note: hardcode_libdir_flag_spec uses $libdir and $wl. acl_save_libdir="$libdir" libdir="$alldirs" - eval flag=\"$acl_hardcode_libdir_flag_spec\" + eval flag=\"$hardcode_libdir_flag_spec\" libdir="$acl_save_libdir" LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag" else @@ -657,7 +531,7 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY], for found_dir in $rpathdirs; do acl_save_libdir="$libdir" libdir="$found_dir" - eval flag=\"$acl_hardcode_libdir_flag_spec\" + eval flag=\"$hardcode_libdir_flag_spec\" libdir="$acl_save_libdir" LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag" done @@ -670,11 +544,6 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY], LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-R$found_dir" done fi - popdef([P_A_C_K]) - popdef([PACKLIBS]) - popdef([PACKUP]) - popdef([PACK]) - popdef([NAME]) ]) dnl AC_LIB_APPENDTOVAR(VAR, CONTENTS) appends the elements of CONTENTS to VAR, @@ -711,7 +580,7 @@ AC_DEFUN([AC_LIB_LINKFLAGS_FROM_LIBS], AC_REQUIRE([AC_LIB_PREPARE_MULTILIB]) $1= if test "$enable_rpath" != no; then - if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then + if test -n "$hardcode_libdir_flag_spec" && test "$hardcode_minus_L" = no; then dnl Use an explicit option to hardcode directories into the resulting dnl binary. rpathdirs= @@ -720,8 +589,7 @@ AC_DEFUN([AC_LIB_LINKFLAGS_FROM_LIBS], if test -n "$next"; then dir="$next" dnl No need to hardcode the standard /usr/lib. - if test "X$dir" != "X/usr/$acl_libdirstem" \ - && test "X$dir" != "X/usr/$acl_libdirstem2"; then + if test "X$dir" != "X/usr/$acl_libdirstem"; then rpathdirs="$rpathdirs $dir" fi next= @@ -730,8 +598,7 @@ AC_DEFUN([AC_LIB_LINKFLAGS_FROM_LIBS], -L) next=yes ;; -L*) dir=`echo "X$opt" | sed -e 's,^X-L,,'` dnl No need to hardcode the standard /usr/lib. - if test "X$dir" != "X/usr/$acl_libdirstem" \ - && test "X$dir" != "X/usr/$acl_libdirstem2"; then + if test "X$dir" != "X/usr/$acl_libdirstem"; then rpathdirs="$rpathdirs $dir" fi next= ;; @@ -747,16 +614,16 @@ AC_DEFUN([AC_LIB_LINKFLAGS_FROM_LIBS], done else dnl The linker is used for linking directly. - if test -n "$acl_hardcode_libdir_separator"; then + if test -n "$hardcode_libdir_separator"; then dnl Weird platform: only the last -rpath option counts, the user dnl must pass all path elements in one option. alldirs= for dir in $rpathdirs; do - alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$dir" + alldirs="${alldirs}${alldirs:+$hardcode_libdir_separator}$dir" done acl_save_libdir="$libdir" libdir="$alldirs" - eval flag=\"$acl_hardcode_libdir_flag_spec\" + eval flag=\"$hardcode_libdir_flag_spec\" libdir="$acl_save_libdir" $1="$flag" else @@ -764,7 +631,7 @@ AC_DEFUN([AC_LIB_LINKFLAGS_FROM_LIBS], for dir in $rpathdirs; do acl_save_libdir="$libdir" libdir="$dir" - eval flag=\"$acl_hardcode_libdir_flag_spec\" + eval flag=\"$hardcode_libdir_flag_spec\" libdir="$acl_save_libdir" $1="${$1}${$1:+ }$flag" done diff --git a/m4/lib-prefix.m4 b/m4/lib-prefix.m4 index 60908e8f..a8684e17 100644 --- a/m4/lib-prefix.m4 +++ b/m4/lib-prefix.m4 @@ -1,5 +1,5 @@ -# lib-prefix.m4 serial 7 (gettext-0.18) -dnl Copyright (C) 2001-2005, 2008-2013 Free Software Foundation, Inc. +# lib-prefix.m4 serial 5 (gettext-0.15) +dnl Copyright (C) 2001-2005 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -153,72 +153,33 @@ AC_DEFUN([AC_LIB_WITH_FINAL_PREFIX], prefix="$acl_save_prefix" ]) -dnl AC_LIB_PREPARE_MULTILIB creates -dnl - a variable acl_libdirstem, containing the basename of the libdir, either -dnl "lib" or "lib64" or "lib/64", -dnl - a variable acl_libdirstem2, as a secondary possible value for -dnl acl_libdirstem, either the same as acl_libdirstem or "lib/sparcv9" or -dnl "lib/amd64". +dnl AC_LIB_PREPARE_MULTILIB creates a variable acl_libdirstem, containing +dnl the basename of the libdir, either "lib" or "lib64". AC_DEFUN([AC_LIB_PREPARE_MULTILIB], [ - dnl There is no formal standard regarding lib and lib64. - dnl On glibc systems, the current practice is that on a system supporting - dnl 32-bit and 64-bit instruction sets or ABIs, 64-bit libraries go under - dnl $prefix/lib64 and 32-bit libraries go under $prefix/lib. We determine - dnl the compiler's default mode by looking at the compiler's library search - dnl path. If at least one of its elements ends in /lib64 or points to a - dnl directory whose absolute pathname ends in /lib64, we assume a 64-bit ABI. - dnl Otherwise we use the default, namely "lib". - dnl On Solaris systems, the current practice is that on a system supporting - dnl 32-bit and 64-bit instruction sets or ABIs, 64-bit libraries go under - dnl $prefix/lib/64 (which is a symlink to either $prefix/lib/sparcv9 or - dnl $prefix/lib/amd64) and 32-bit libraries go under $prefix/lib. - AC_REQUIRE([AC_CANONICAL_HOST]) + dnl There is no formal standard regarding lib and lib64. The current + dnl practice is that on a system supporting 32-bit and 64-bit instruction + dnl sets or ABIs, 64-bit libraries go under $prefix/lib64 and 32-bit + dnl libraries go under $prefix/lib. We determine the compiler's default + dnl mode by looking at the compiler's library search path. If at least + dnl of its elements ends in /lib64 or points to a directory whose absolute + dnl pathname ends in /lib64, we assume a 64-bit ABI. Otherwise we use the + dnl default, namely "lib". acl_libdirstem=lib - acl_libdirstem2= - case "$host_os" in - solaris*) - dnl See Solaris 10 Software Developer Collection > Solaris 64-bit Developer's Guide > The Development Environment - dnl . - dnl "Portable Makefiles should refer to any library directories using the 64 symbolic link." - dnl But we want to recognize the sparcv9 or amd64 subdirectory also if the - dnl symlink is missing, so we set acl_libdirstem2 too. - AC_CACHE_CHECK([for 64-bit host], [gl_cv_solaris_64bit], - [AC_EGREP_CPP([sixtyfour bits], [ -#ifdef _LP64 -sixtyfour bits -#endif - ], [gl_cv_solaris_64bit=yes], [gl_cv_solaris_64bit=no]) - ]) - if test $gl_cv_solaris_64bit = yes; then - acl_libdirstem=lib/64 - case "$host_cpu" in - sparc*) acl_libdirstem2=lib/sparcv9 ;; - i*86 | x86_64) acl_libdirstem2=lib/amd64 ;; + searchpath=`(LC_ALL=C $CC -print-search-dirs) 2>/dev/null | sed -n -e 's,^libraries: ,,p' | sed -e 's,^=,,'` + if test -n "$searchpath"; then + acl_save_IFS="${IFS= }"; IFS=":" + for searchdir in $searchpath; do + if test -d "$searchdir"; then + case "$searchdir" in + */lib64/ | */lib64 ) acl_libdirstem=lib64 ;; + *) searchdir=`cd "$searchdir" && pwd` + case "$searchdir" in + */lib64 ) acl_libdirstem=lib64 ;; + esac ;; esac fi - ;; - *) - searchpath=`(LC_ALL=C $CC -print-search-dirs) 2>/dev/null | sed -n -e 's,^libraries: ,,p' | sed -e 's,^=,,'` - if test -n "$searchpath"; then - acl_save_IFS="${IFS= }"; IFS=":" - for searchdir in $searchpath; do - if test -d "$searchdir"; then - case "$searchdir" in - */lib64/ | */lib64 ) acl_libdirstem=lib64 ;; - */../ | */.. ) - # Better ignore directories of this form. They are misleading. - ;; - *) searchdir=`cd "$searchdir" && pwd` - case "$searchdir" in - */lib64 ) acl_libdirstem=lib64 ;; - esac ;; - esac - fi - done - IFS="$acl_save_IFS" - fi - ;; - esac - test -n "$acl_libdirstem2" || acl_libdirstem2="$acl_libdirstem" + done + IFS="$acl_save_IFS" + fi ]) diff --git a/m4/nls.m4 b/m4/nls.m4 index 8f8a147b..7967cc2f 100644 --- a/m4/nls.m4 +++ b/m4/nls.m4 @@ -1,6 +1,5 @@ -# nls.m4 serial 5 (gettext-0.18) -dnl Copyright (C) 1995-2003, 2005-2006, 2008-2013 Free Software Foundation, -dnl Inc. +# nls.m4 serial 3 (gettext-0.15) +dnl Copyright (C) 1995-2003, 2005-2006 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -18,15 +17,15 @@ dnl Authors: dnl Ulrich Drepper , 1995-2000. dnl Bruno Haible , 2000-2003. -AC_PREREQ([2.50]) +AC_PREREQ(2.50) AC_DEFUN([AM_NLS], [ AC_MSG_CHECKING([whether NLS is requested]) dnl Default is enabled NLS - AC_ARG_ENABLE([nls], + AC_ARG_ENABLE(nls, [ --disable-nls do not use Native Language Support], USE_NLS=$enableval, USE_NLS=yes) - AC_MSG_RESULT([$USE_NLS]) - AC_SUBST([USE_NLS]) + AC_MSG_RESULT($USE_NLS) + AC_SUBST(USE_NLS) ]) diff --git a/m4/po.m4 b/m4/po.m4 index 1c70b6c1..00133ef3 100644 --- a/m4/po.m4 +++ b/m4/po.m4 @@ -1,5 +1,5 @@ -# po.m4 serial 21 (gettext-0.18.3) -dnl Copyright (C) 1995-2013 Free Software Foundation, Inc. +# po.m4 serial 13 (gettext-0.15) +dnl Copyright (C) 1995-2006 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -17,21 +17,16 @@ dnl Authors: dnl Ulrich Drepper , 1995-2000. dnl Bruno Haible , 2000-2003. -AC_PREREQ([2.60]) +AC_PREREQ(2.50) dnl Checks for all prerequisites of the po subdirectory. AC_DEFUN([AM_PO_SUBDIRS], [ AC_REQUIRE([AC_PROG_MAKE_SET])dnl AC_REQUIRE([AC_PROG_INSTALL])dnl - AC_REQUIRE([AC_PROG_MKDIR_P])dnl - AC_REQUIRE([AC_PROG_SED])dnl + AC_REQUIRE([AM_PROG_MKDIR_P])dnl defined by automake AC_REQUIRE([AM_NLS])dnl - dnl Release version of the gettext macros. This is used to ensure that - dnl the gettext macros and po/Makefile.in.in are in sync. - AC_SUBST([GETTEXT_MACRO_VERSION], [0.18]) - dnl Perform the following tests also if --disable-nls has been given, dnl because they are needed for "make dist" to work. @@ -42,7 +37,7 @@ AC_DEFUN([AM_PO_SUBDIRS], [$ac_dir/$ac_word --statistics /dev/null >&]AS_MESSAGE_LOG_FD[ 2>&1 && (if $ac_dir/$ac_word --statistics /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi)], :) - AC_PATH_PROG([GMSGFMT], [gmsgfmt], [$MSGFMT]) + AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT) dnl Test whether it is GNU msgfmt >= 0.15. changequote(,)dnl @@ -89,10 +84,6 @@ changequote([,])dnl test -n "$localedir" || localedir='${datadir}/locale' AC_SUBST([localedir]) - dnl Support for AM_XGETTEXT_OPTION. - test -n "${XGETTEXT_EXTRA_OPTIONS+set}" || XGETTEXT_EXTRA_OPTIONS= - AC_SUBST([XGETTEXT_EXTRA_OPTIONS]) - AC_CONFIG_COMMANDS([po-directories], [[ for ac_file in $CONFIG_FILES; do # Support "outfile[:infile[:infile...]]" @@ -103,7 +94,7 @@ changequote([,])dnl case "$ac_file" in */Makefile.in) # Adjust a relative srcdir. ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'` - ac_dir_suffix=/`echo "$ac_dir"|sed 's%^\./%%'` + ac_dir_suffix="/`echo "$ac_dir"|sed 's%^\./%%'`" ac_dots=`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'` # In autoconf-2.13 it is called $ac_given_srcdir. # In autoconf-2.50 it is called $srcdir. @@ -119,8 +110,7 @@ changequote([,])dnl if test -f "$ac_given_srcdir/$ac_dir/POTFILES.in"; then rm -f "$ac_dir/POTFILES" test -n "$as_me" && echo "$as_me: creating $ac_dir/POTFILES" || echo "creating $ac_dir/POTFILES" - gt_tab=`printf '\t'` - cat "$ac_given_srcdir/$ac_dir/POTFILES.in" | sed -e "/^#/d" -e "/^[ ${gt_tab}]*\$/d" -e "s,.*, $top_srcdir/& \\\\," | sed -e "\$s/\(.*\) \\\\/\1/" > "$ac_dir/POTFILES" + cat "$ac_given_srcdir/$ac_dir/POTFILES.in" | sed -e "/^#/d" -e "/^[ ]*\$/d" -e "s,.*, $top_srcdir/& \\\\," | sed -e "\$s/\(.*\) \\\\/\1/" > "$ac_dir/POTFILES" POMAKEFILEDEPS="POTFILES.in" # ALL_LINGUAS, POFILES, UPDATEPOFILES, DUMMYPOFILES, GMOFILES depend # on $ac_dir but don't depend on user-specified configuration @@ -131,12 +121,12 @@ changequote([,])dnl test -n "$as_me" && echo "$as_me: setting ALL_LINGUAS in configure.in is obsolete" || echo "setting ALL_LINGUAS in configure.in is obsolete" fi ALL_LINGUAS_=`sed -e "/^#/d" -e "s/#.*//" "$ac_given_srcdir/$ac_dir/LINGUAS"` - # Hide the ALL_LINGUAS assignment from automake < 1.5. + # Hide the ALL_LINGUAS assigment from automake < 1.5. eval 'ALL_LINGUAS''=$ALL_LINGUAS_' POMAKEFILEDEPS="$POMAKEFILEDEPS LINGUAS" else # The set of available languages was given in configure.in. - # Hide the ALL_LINGUAS assignment from automake < 1.5. + # Hide the ALL_LINGUAS assigment from automake < 1.5. eval 'ALL_LINGUAS''=$OBSOLETE_ALL_LINGUAS' fi # Compute POFILES @@ -228,7 +218,7 @@ AC_DEFUN([AM_POSTPROCESS_PO_MAKEFILE], changequote(,)dnl # Adjust a relative srcdir. ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'` - ac_dir_suffix=/`echo "$ac_dir"|sed 's%^\./%%'` + ac_dir_suffix="/`echo "$ac_dir"|sed 's%^\./%%'`" ac_dots=`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'` # In autoconf-2.13 it is called $ac_given_srcdir. # In autoconf-2.50 it is called $srcdir. @@ -256,7 +246,6 @@ EOT fi # A sed script that extracts the value of VARIABLE from a Makefile. - tab=`printf '\t'` sed_x_variable=' # Test if the hold space is empty. x @@ -264,9 +253,9 @@ s/P/P/ x ta # Yes it was empty. Look if we have the expected variable definition. -/^['"${tab}"' ]*VARIABLE['"${tab}"' ]*=/{ +/^[ ]*VARIABLE[ ]*=/{ # Seen the first line of the variable definition. - s/^['"${tab}"' ]*VARIABLE['"${tab}"' ]*=// + s/^[ ]*VARIABLE[ ]*=// ba } bd @@ -318,7 +307,7 @@ changequote([,])dnl sed_x_LINGUAS=`$gt_echo "$sed_x_variable" | sed -e '/^ *#/d' -e 's/VARIABLE/LINGUAS/g'` ALL_LINGUAS_=`sed -n -e "$sed_x_LINGUAS" < "$ac_file"` fi - # Hide the ALL_LINGUAS assignment from automake < 1.5. + # Hide the ALL_LINGUAS assigment from automake < 1.5. eval 'ALL_LINGUAS''=$ALL_LINGUAS_' # Compute POFILES # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).po) @@ -408,15 +397,14 @@ changequote([,])dnl fi sed -e "s|@POTFILES_DEPS@|$POTFILES_DEPS|g" -e "s|@POFILES@|$POFILES|g" -e "s|@UPDATEPOFILES@|$UPDATEPOFILES|g" -e "s|@DUMMYPOFILES@|$DUMMYPOFILES|g" -e "s|@GMOFILES@|$GMOFILES|g" -e "s|@PROPERTIESFILES@|$PROPERTIESFILES|g" -e "s|@CLASSFILES@|$CLASSFILES|g" -e "s|@QMFILES@|$QMFILES|g" -e "s|@MSGFILES@|$MSGFILES|g" -e "s|@RESOURCESDLLFILES@|$RESOURCESDLLFILES|g" -e "s|@CATALOGS@|$CATALOGS|g" -e "s|@JAVACATALOGS@|$JAVACATALOGS|g" -e "s|@QTCATALOGS@|$QTCATALOGS|g" -e "s|@TCLCATALOGS@|$TCLCATALOGS|g" -e "s|@CSHARPCATALOGS@|$CSHARPCATALOGS|g" -e 's,^#distdir:,distdir:,' < "$ac_file" > "$ac_file.tmp" - tab=`printf '\t'` if grep -l '@TCLCATALOGS@' "$ac_file" > /dev/null; then # Add dependencies that cannot be formulated as a simple suffix rule. for lang in $ALL_LINGUAS; do frobbedlang=`echo $lang | sed -e 's/\..*$//' -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'` cat >> "$ac_file.tmp" <> "$ac_file.tmp" <, 1996. -AC_PREREQ([2.50]) +AC_PREREQ(2.50) # Search path for a program which passes the given test. @@ -27,14 +27,15 @@ AC_DEFUN([AM_PATH_PROG_WITH_TEST], # Prepare PATH_SEPARATOR. # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then - # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which - # contains only /bin. Note that ksh looks also at the FPATH variable, - # so we have to set that as well for the test. - PATH_SEPARATOR=: - (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \ - && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \ - || PATH_SEPARATOR=';' - } + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh fi # Find out how to test for executable files. Don't use a zero-byte file, @@ -54,7 +55,7 @@ rm -f conf$$.file # Extract the first word of "$2", so it can be a program name with args. set dummy $2; ac_word=[$]2 AC_MSG_CHECKING([for $ac_word]) -AC_CACHE_VAL([ac_cv_path_$1], +AC_CACHE_VAL(ac_cv_path_$1, [case "[$]$1" in [[\\/]]* | ?:[[\\/]]*) ac_cv_path_$1="[$]$1" # Let the user override the test with a path. @@ -83,9 +84,9 @@ ifelse([$4], , , [ test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4" esac])dnl $1="$ac_cv_path_$1" if test ifelse([$4], , [-n "[$]$1"], ["[$]$1" != "$4"]); then - AC_MSG_RESULT([$][$1]) + AC_MSG_RESULT([$]$1) else - AC_MSG_RESULT([no]) + AC_MSG_RESULT(no) fi -AC_SUBST([$1])dnl +AC_SUBST($1)dnl ]) diff --git a/m4/pyrex.m4 b/m4/pyrex.m4 new file mode 100644 index 00000000..379c5e3d --- /dev/null +++ b/m4/pyrex.m4 @@ -0,0 +1,17 @@ +dnl a macro to check for the installed Pyrex version; note PYTHON needs to +dnl be set before this function is called. +dnl PYREX_CHECK_VERSION([MIN-VERSION], [ACTION-IF-TRUE], [ACTION-IF-FALSE]) +AC_DEFUN([PYREX_CHECK_VERSION], + [prog="import sys +from Pyrex.Compiler.Version import version +# split strings by '.' and convert to numeric. Append some zeros +# because we need at least 4 digits for the hex conversion. +pyrexver = map(int, version.rstrip('abcdefghijklmnopqrstuvwxyz').split('.')) + [[0, 0, 0]] +pyrexverhex = 0 +for i in xrange(0, 4): pyrexverhex = (pyrexverhex << 8) + pyrexver[[i]] +minver = map(int, '$1'.split('.')) + [[0, 0, 0]] +minverhex = 0 +for i in xrange(0, 4): minverhex = (minverhex << 8) + minver[[i]] +sys.exit(pyrexverhex < minverhex)" + AS_IF([AM_RUN_LOG([$PYTHON -c "$prog"])], [$2], [$3])]) + diff --git a/m4/pythonhead.m4 b/m4/pythonhead.m4 index 15b7a333..1e0f2b63 100644 --- a/m4/pythonhead.m4 +++ b/m4/pythonhead.m4 @@ -1,39 +1,16 @@ dnl a macro to check for ability to create python extensions dnl AM_CHECK_PYTHON_HEADERS([ACTION-IF-POSSIBLE], [ACTION-IF-NOT-POSSIBLE]) dnl function also defines PYTHON_INCLUDES -dnl update taken from dbus-python(GPL). AC_DEFUN([AM_CHECK_PYTHON_HEADERS], [AC_REQUIRE([AM_PATH_PYTHON]) - -AC_PATH_PROGS([PYTHON_CONFIG], [python${PYTHON_VERSION}-config python-config], [no]) -if test "${PYTHON_CONFIG}" = "no"; then - AC_MSG_ERROR([cannot find python${PYTHON_VERSION}-config or python-config in PATH]) +AC_MSG_CHECKING(for headers required to compile python extensions) +dnl deduce PYTHON_INCLUDES +py_prefix=`$PYTHON -c "import sys; print sys.prefix"` +py_exec_prefix=`$PYTHON -c "import sys; print sys.exec_prefix"` +PYTHON_INCLUDES="-I${py_prefix}/include/python${PYTHON_VERSION}" +if test "$py_prefix" != "$py_exec_prefix"; then + PYTHON_INCLUDES="$PYTHON_INCLUDES -I${py_exec_prefix}/include/python${PYTHON_VERSION}" fi - -AC_ARG_VAR([PYTHON_INCLUDES], [CPPFLAGS for Python, overriding output of python2.x-config --includes, e.g. "-I/opt/misc/include/python2.7"]) - -if test "${PYTHON_INCLUDES+set}" = set; then - AC_MSG_NOTICE([PYTHON_INCLUDES overridden to: $PYTHON_INCLUDES]) -else - dnl deduce PYTHON_INCLUDES - AC_MSG_CHECKING(for Python headers using $PYTHON_CONFIG --includes) - PYTHON_INCLUDES=`$PYTHON_CONFIG --includes` - if test $? = 0; then - AC_MSG_RESULT($PYTHON_INCLUDES) - else - AC_MSG_RESULT([failed, will try another way]) - py_prefix=`$PYTHON -c "import sys; print(sys.prefix)"` - py_exec_prefix=`$PYTHON -c "import sys; print(sys.exec_prefix)"` - AC_MSG_CHECKING(for Python headers in $py_prefix and $py_exec_prefix) - PYTHON_INCLUDES="-I${py_prefix}/include/python${PYTHON_VERSION}" - if test "$py_prefix" != "$py_exec_prefix"; then - PYTHON_INCLUDES="$PYTHON_INCLUDES -I${py_exec_prefix}/include/python${PYTHON_VERSION}" - fi - AC_MSG_RESULT($PYTHON_INCLUDES) - fi -fi - -AC_MSG_CHECKING(whether those headers are sufficient) AC_SUBST(PYTHON_INCLUDES) dnl check if the headers exist: save_CPPFLAGS="$CPPFLAGS" diff --git a/modules/CMakeLists.txt b/modules/CMakeLists.txt deleted file mode 100644 index 6e59cb52..00000000 --- a/modules/CMakeLists.txt +++ /dev/null @@ -1,104 +0,0 @@ -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) - -INCLUDE(arch/CMakeLists.txt) -INCLUDE(listfmts/CMakeLists.txt) -INCLUDE(parsers/CMakeLists.txt) -INCLUDE(preprocs/CMakeLists.txt) -INCLUDE(dbgfmts/CMakeLists.txt) -INCLUDE(objfmts/CMakeLists.txt) - -MESSAGE(STATUS "Standard modules: ${YASM_MODULES}") - -# -# Generate init_plugin.c -# This file provides the yasm_init_plugin() function for yasmstd. -# - -SET(INIT_PLUGIN_C ${CMAKE_CURRENT_BINARY_DIR}/init_plugin.c) -SET(INIT_PLUGIN_C_REV 1) - -# Don't regen if no changes; default to regen -SET(regen_init_plugin_c TRUE) -IF(EXISTS ${INIT_PLUGIN_C}) - FILE(READ ${INIT_PLUGIN_C} _old_init_plugin_c) - STRING(REGEX MATCHALL "[^\n]*\n" _lines "${_old_init_plugin_c}") - #MESSAGE(STATUS "Lines: ${_lines}") - - LIST(GET _lines 0 _line0) - STRING(REGEX MATCH "([A-Za-z][A-Za-z0-9_]+[ ]?)+" _old_modules "${_line0}") - #MESSAGE(STATUS "Old modules: ${_old_modules}") - STRING(REPLACE ";" " " _modules_str "${YASM_MODULES}") - STRING(COMPARE EQUAL "${_old_modules}" "${_modules_str} " _modules_match) - - LIST(GET _lines 1 _line1) - STRING(REGEX MATCH "rev [0-9]+" _old_modules_rev "${_line1}") - #MESSAGE(STATUS "Old modules rev: ${_old_modules_rev}") - STRING(COMPARE EQUAL "${_old_modules_rev}" "rev ${INIT_PLUGIN_C_REV}" - _modules_rev_match) - - IF(_modules_match AND _modules_rev_match) - SET(regen_init_plugin_c FALSE) - ENDIF(_modules_match AND _modules_rev_match) -ENDIF(EXISTS ${INIT_PLUGIN_C}) - -IF(regen_init_plugin_c) - MESSAGE(STATUS "Generating standard plugin initialization file") - STRING(REPLACE ";" " " _modules_str "${YASM_MODULES}") - FILE(WRITE ${INIT_PLUGIN_C} "/* ${_modules_str} \n") - FILE(APPEND ${INIT_PLUGIN_C} " rev ${INIT_PLUGIN_C_REV}\n") - FILE(APPEND ${INIT_PLUGIN_C} " */\n\n") - FILE(APPEND ${INIT_PLUGIN_C} "#include \n") - FILE(APPEND ${INIT_PLUGIN_C} "#include \n\n") - FOREACH(module ${YASM_MODULES}) - STRING(REGEX MATCHALL "[a-zA-Z][a-zA-Z0-9]+" _modulepath ${module}) - LIST(GET _modulepath 0 _type) - LIST(GET _modulepath 1 _keyword) - FILE(APPEND ${INIT_PLUGIN_C} - "extern yasm_${_type}_module yasm_${_keyword}_LTX_${_type};\n") - ENDFOREACH(module) - IF(BUILD_SHARED_LIBS) - FILE(APPEND ${INIT_PLUGIN_C} "\n#ifdef _WIN32\n") - FILE(APPEND ${INIT_PLUGIN_C} "__declspec(dllexport)\n") - FILE(APPEND ${INIT_PLUGIN_C} "#endif\n") - ENDIF(BUILD_SHARED_LIBS) - FILE(APPEND ${INIT_PLUGIN_C} "void\n") - FILE(APPEND ${INIT_PLUGIN_C} "yasm_init_plugin(void)\n") - FILE(APPEND ${INIT_PLUGIN_C} "{\n") - FOREACH(module ${YASM_MODULES}) - STRING(REGEX MATCHALL "[a-zA-Z][a-zA-Z0-9]+" _modulepath ${module}) - LIST(GET _modulepath 0 _type) - LIST(GET _modulepath 1 _keyword) - SET(_data "yasm_${_keyword}_LTX_${_type}") - STRING(TOUPPER "${_type}" _type) - FILE(APPEND ${INIT_PLUGIN_C} - " yasm_register_module(YASM_MODULE_${_type}, \"${_keyword}\", &${_data});\n") - ENDFOREACH(module) - FILE(APPEND ${INIT_PLUGIN_C} "}\n") -ELSE(regen_init_plugin_c) - MESSAGE(STATUS "Not regenerating static modules file (unchanged)") -ENDIF(regen_init_plugin_c) - -SET_SOURCE_FILES_PROPERTIES(init_plugin.c GENERATED) - -SET(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}) - -IF(BUILD_SHARED_LIBS) - ADD_LIBRARY(yasmstd MODULE - init_plugin.c - ${YASM_MODULES_SRC} - ) - TARGET_LINK_LIBRARIES(yasmstd libyasm) - - IF(WIN32) - SET_PROPERTY(TARGET yasmstd PROPERTY PREFIX "") - INSTALL(TARGETS yasmstd LIBRARY DESTINATION bin) - ELSE(WIN32) - INSTALL(TARGETS yasmstd LIBRARY DESTINATION lib) - ENDIF(WIN32) -ELSE(BUILD_SHARED_LIBS) - ADD_LIBRARY(yasmstd - init_plugin.c - ${YASM_MODULES_SRC} - ) - TARGET_LINK_LIBRARIES(yasmstd libyasm) -ENDIF(BUILD_SHARED_LIBS) diff --git a/modules/Makefile.inc b/modules/Makefile.inc index c220a84c..3ff8fd31 100644 --- a/modules/Makefile.inc +++ b/modules/Makefile.inc @@ -1,3 +1,5 @@ +# $Id$ + EXTRA_DIST += modules/arch/Makefile.inc EXTRA_DIST += modules/listfmts/Makefile.inc EXTRA_DIST += modules/parsers/Makefile.inc diff --git a/modules/arch/CMakeLists.txt b/modules/arch/CMakeLists.txt deleted file mode 100644 index ea65fbd0..00000000 --- a/modules/arch/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -INCLUDE(arch/lc3b/CMakeLists.txt) -INCLUDE(arch/x86/CMakeLists.txt) diff --git a/modules/arch/Makefile.inc b/modules/arch/Makefile.inc index 5c5d9d15..7dc98dfc 100644 --- a/modules/arch/Makefile.inc +++ b/modules/arch/Makefile.inc @@ -1,10 +1,12 @@ +# $Id$ + EXTRA_DIST += modules/arch/x86/Makefile.inc EXTRA_DIST += modules/arch/lc3b/Makefile.inc include modules/arch/x86/Makefile.inc -include modules/arch/lc3b/Makefile.inc +#include modules/arch/lc3b/Makefile.inc -notrans_dist_man_MANS += yasm_arch.7 +dist_man_MANS += yasm_arch.7 if BUILD_MAN yasm_arch.7: modules/arch/yasm_arch.xml diff --git a/modules/arch/lc3b/CMakeLists.txt b/modules/arch/lc3b/CMakeLists.txt deleted file mode 100644 index 0d5df705..00000000 --- a/modules/arch/lc3b/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -YASM_RE2C( - ${CMAKE_CURRENT_SOURCE_DIR}/arch/lc3b/lc3bid.re - ${CMAKE_CURRENT_BINARY_DIR}/lc3bid.c - -s - ) - -YASM_ADD_MODULE(arch_lc3b - arch/lc3b/lc3barch.c - arch/lc3b/lc3bbc.c - lc3bid.c - ) diff --git a/modules/arch/lc3b/Makefile.inc b/modules/arch/lc3b/Makefile.inc index fc30583d..6fbc60ce 100644 --- a/modules/arch/lc3b/Makefile.inc +++ b/modules/arch/lc3b/Makefile.inc @@ -1,13 +1,17 @@ +# $Id$ + libyasm_a_SOURCES += modules/arch/lc3b/lc3barch.c libyasm_a_SOURCES += modules/arch/lc3b/lc3barch.h libyasm_a_SOURCES += modules/arch/lc3b/lc3bbc.c -nodist_libyasm_a_SOURCES += lc3bid.c +libyasm_a_SOURCES += lc3bid.c YASM_MODULES += arch_lc3b lc3bid.c: $(srcdir)/modules/arch/lc3b/lc3bid.re re2c$(EXEEXT) $(top_builddir)/re2c$(EXEEXT) -s -o $@ $(srcdir)/modules/arch/lc3b/lc3bid.re +BUILT_SOURCES += lc3bid.c + CLEANFILES += lc3bid.c EXTRA_DIST += modules/arch/lc3b/tests/Makefile.inc diff --git a/modules/arch/lc3b/lc3barch.c b/modules/arch/lc3b/lc3barch.c index 05145286..a691ffbf 100644 --- a/modules/arch/lc3b/lc3barch.c +++ b/modules/arch/lc3b/lc3barch.c @@ -25,7 +25,9 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include +/*@unused@*/ RCSID("$Id$"); +#define YASM_LIB_INTERNAL #include #include "lc3barch.h" @@ -36,20 +38,20 @@ yasm_arch_module yasm_lc3b_LTX_arch; static /*@only@*/ yasm_arch * lc3b_create(const char *machine, const char *parser, - /*@out@*/ yasm_arch_create_error *error) + /*@out@*/ yasm_arch_create_error *error) { yasm_arch_base *arch; *error = YASM_ARCH_CREATE_OK; if (yasm__strcasecmp(machine, "lc3b") != 0) { - *error = YASM_ARCH_CREATE_BAD_MACHINE; - return NULL; + *error = YASM_ARCH_CREATE_BAD_MACHINE; + return NULL; } if (yasm__strcasecmp(parser, "nasm") != 0) { - *error = YASM_ARCH_CREATE_BAD_PARSER; - return NULL; + *error = YASM_ARCH_CREATE_BAD_PARSER; + return NULL; } arch = yasm_xmalloc(sizeof(yasm_arch_base)); @@ -81,99 +83,89 @@ lc3b_set_var(yasm_arch *arch, const char *var, unsigned long val) return 1; } +static int +lc3b_parse_directive(/*@unused@*/ yasm_arch *arch, + /*@unused@*/ const char *name, + /*@unused@*/ /*@null@*/ yasm_valparamhead *valparams, + /*@unused@*/ /*@null@*/ + yasm_valparamhead *objext_valparams, + /*@unused@*/ yasm_object *object, + /*@unused@*/ unsigned long line) +{ + return 1; +} + static const unsigned char ** lc3b_get_fill(const yasm_arch *arch) { /* NOP pattern is all 0's per LC-3b Assembler 3.50 output */ static const unsigned char *fill[16] = { - NULL, /* unused */ - NULL, /* 1 - illegal; all opcodes are 2 bytes long */ - (const unsigned char *) - "\x00\x00", /* 4 */ - NULL, /* 3 - illegal */ - (const unsigned char *) - "\x00\x00\x00\x00", /* 4 */ - NULL, /* 5 - illegal */ - (const unsigned char *) - "\x00\x00\x00\x00\x00\x00", /* 6 */ - NULL, /* 7 - illegal */ - (const unsigned char *) - "\x00\x00\x00\x00\x00\x00" /* 8 */ - "\x00\x00", - NULL, /* 9 - illegal */ - (const unsigned char *) - "\x00\x00\x00\x00\x00\x00" /* 10 */ - "\x00\x00\x00\x00", - NULL, /* 11 - illegal */ - (const unsigned char *) - "\x00\x00\x00\x00\x00\x00" /* 12 */ - "\x00\x00\x00\x00\x00\x00", - NULL, /* 13 - illegal */ - (const unsigned char *) - "\x00\x00\x00\x00\x00\x00" /* 14 */ - "\x00\x00\x00\x00\x00\x00\x00\x00", - NULL /* 15 - illegal */ + NULL, /* unused */ + NULL, /* 1 - illegal; all opcodes are 2 bytes long */ + (const unsigned char *) + "\x00\x00", /* 4 */ + NULL, /* 3 - illegal */ + (const unsigned char *) + "\x00\x00\x00\x00", /* 4 */ + NULL, /* 5 - illegal */ + (const unsigned char *) + "\x00\x00\x00\x00\x00\x00", /* 6 */ + NULL, /* 7 - illegal */ + (const unsigned char *) + "\x00\x00\x00\x00\x00\x00" /* 8 */ + "\x00\x00", + NULL, /* 9 - illegal */ + (const unsigned char *) + "\x00\x00\x00\x00\x00\x00" /* 10 */ + "\x00\x00\x00\x00", + NULL, /* 11 - illegal */ + (const unsigned char *) + "\x00\x00\x00\x00\x00\x00" /* 12 */ + "\x00\x00\x00\x00\x00\x00", + NULL, /* 13 - illegal */ + (const unsigned char *) + "\x00\x00\x00\x00\x00\x00" /* 14 */ + "\x00\x00\x00\x00\x00\x00\x00\x00", + NULL /* 15 - illegal */ }; return fill; } static unsigned int -lc3b_get_reg_size(/*@unused@*/ yasm_arch *arch, /*@unused@*/ uintptr_t reg) +lc3b_get_reg_size(/*@unused@*/ yasm_arch *arch, /*@unused@*/ unsigned long reg) { return 16; } -static uintptr_t +static unsigned long lc3b_reggroup_get_reg(/*@unused@*/ yasm_arch *arch, - /*@unused@*/ uintptr_t reggroup, - /*@unused@*/ unsigned long regindex) + /*@unused@*/ unsigned long reggroup, + /*@unused@*/ unsigned long regindex) { return 0; } static void -lc3b_reg_print(/*@unused@*/ yasm_arch *arch, uintptr_t reg, FILE *f) +lc3b_reg_print(/*@unused@*/ yasm_arch *arch, unsigned long reg, FILE *f) { fprintf(f, "r%u", (unsigned int)(reg&7)); } static int lc3b_floatnum_tobytes(yasm_arch *arch, const yasm_floatnum *flt, - unsigned char *buf, size_t destsize, size_t valsize, - size_t shift, int warn) + unsigned char *buf, size_t destsize, size_t valsize, + size_t shift, int warn) { yasm_error_set(YASM_ERROR_FLOATING_POINT, - N_("LC-3b does not support floating point")); + N_("LC-3b does not support floating point")); return 1; } static yasm_effaddr * lc3b_ea_create_expr(yasm_arch *arch, yasm_expr *e) { - yasm_effaddr *ea = yasm_xmalloc(sizeof(yasm_effaddr)); - yasm_value_initialize(&ea->disp, e, 0); - ea->need_nonzero_len = 0; - ea->need_disp = 1; - ea->nosplit = 0; - ea->strong = 0; - ea->segreg = 0; - ea->pc_rel = 0; - ea->not_pc_rel = 0; - return ea; -} - -void -yasm_lc3b__ea_destroy(/*@only@*/ yasm_effaddr *ea) -{ - yasm_value_delete(&ea->disp); - yasm_xfree(ea); -} - -static void -lc3b_ea_print(const yasm_effaddr *ea, FILE *f, int indent_level) -{ - fprintf(f, "%*sDisp:\n", indent_level, ""); - yasm_value_print(&ea->disp, f, indent_level+1); + yasm_expr_destroy(e); + return NULL; } /* Define lc3b machines -- see arch.h for details */ @@ -186,27 +178,27 @@ static yasm_arch_machine lc3b_machines[] = { yasm_arch_module yasm_lc3b_LTX_arch = { "LC-3b", "lc3b", - NULL, lc3b_create, lc3b_destroy, lc3b_get_machine, lc3b_get_address_size, lc3b_set_var, + yasm_lc3b__parse_cpu, yasm_lc3b__parse_check_insnprefix, yasm_lc3b__parse_check_regtmod, + lc3b_parse_directive, lc3b_get_fill, + yasm_lc3b__finalize_insn, lc3b_floatnum_tobytes, yasm_lc3b__intnum_tobytes, lc3b_get_reg_size, lc3b_reggroup_get_reg, lc3b_reg_print, - NULL, /*yasm_lc3b__segreg_print*/ + NULL, /*yasm_lc3b__segreg_print*/ lc3b_ea_create_expr, - yasm_lc3b__ea_destroy, - lc3b_ea_print, - yasm_lc3b__create_empty_insn, lc3b_machines, "lc3b", 16, + 512, 2 }; diff --git a/modules/arch/lc3b/lc3barch.h b/modules/arch/lc3b/lc3barch.h index 9ded8cbe..e4c5ab2e 100644 --- a/modules/arch/lc3b/lc3barch.h +++ b/modules/arch/lc3b/lc3barch.h @@ -1,4 +1,4 @@ -/* +/* $Id$ * LC-3b Architecture header file * * Copyright (C) 2003-2007 Peter Johnson @@ -29,42 +29,45 @@ /* Types of immediate. All immediates are stored in the LSBs of the insn. */ typedef enum lc3b_imm_type { - LC3B_IMM_NONE = 0, /* no immediate */ - LC3B_IMM_4, /* 4-bit */ - LC3B_IMM_5, /* 5-bit */ - LC3B_IMM_6_WORD, /* 6-bit, word-multiple (byte>>1) */ - LC3B_IMM_6_BYTE, /* 6-bit, byte-multiple */ - LC3B_IMM_8, /* 8-bit, word-multiple (byte>>1) */ - LC3B_IMM_9, /* 9-bit, signed, word-multiple (byte>>1) */ - LC3B_IMM_9_PC /* 9-bit, signed, word-multiple, PC relative */ + LC3B_IMM_NONE = 0, /* no immediate */ + LC3B_IMM_4, /* 4-bit */ + LC3B_IMM_5, /* 5-bit */ + LC3B_IMM_6_WORD, /* 6-bit, word-multiple (byte>>1) */ + LC3B_IMM_6_BYTE, /* 6-bit, byte-multiple */ + LC3B_IMM_8, /* 8-bit, word-multiple (byte>>1) */ + LC3B_IMM_9, /* 9-bit, signed, word-multiple (byte>>1) */ + LC3B_IMM_9_PC /* 9-bit, signed, word-multiple, PC relative */ } lc3b_imm_type; /* Bytecode types */ typedef struct lc3b_insn { - yasm_value imm; /* immediate or relative value */ - lc3b_imm_type imm_type; /* size of the immediate */ + yasm_value imm; /* immediate or relative value */ + lc3b_imm_type imm_type; /* size of the immediate */ - unsigned int opcode; /* opcode */ + /* PC origin if needed */ + /*@null@*/ /*@dependent@*/ yasm_bytecode *origin_prevbc; + + unsigned int opcode; /* opcode */ } lc3b_insn; void yasm_lc3b__bc_transform_insn(yasm_bytecode *bc, lc3b_insn *insn); +void yasm_lc3b__parse_cpu(yasm_arch *arch, const char *cpuid, size_t cpuid_len); + yasm_arch_insnprefix yasm_lc3b__parse_check_insnprefix - (yasm_arch *arch, const char *id, size_t id_len, unsigned long line, - /*@out@*/ /*@only@*/ yasm_bytecode **bc, /*@out@*/ uintptr_t *prefix); + (yasm_arch *arch, unsigned long data[4], const char *id, size_t id_len); yasm_arch_regtmod yasm_lc3b__parse_check_regtmod - (yasm_arch *arch, const char *id, size_t id_len, - /*@out@*/ uintptr_t *data); + (yasm_arch *arch, unsigned long *data, const char *id, size_t id_len); + +void yasm_lc3b__finalize_insn + (yasm_arch *arch, yasm_bytecode *bc, yasm_bytecode *prev_bc, + const unsigned long data[4], int num_operands, + /*@null@*/ yasm_insn_operands *operands, int num_prefixes, + unsigned long **prefixes, int num_segregs, const unsigned long *segregs); int yasm_lc3b__intnum_tobytes (yasm_arch *arch, const yasm_intnum *intn, unsigned char *buf, size_t destsize, size_t valsize, int shift, const yasm_bytecode *bc, int warn); - -/*@only@*/ yasm_bytecode *yasm_lc3b__create_empty_insn(yasm_arch *arch, - unsigned long line); - -void yasm_lc3b__ea_destroy(/*@only@*/ yasm_effaddr *ea); - #endif diff --git a/modules/arch/lc3b/lc3bbc.c b/modules/arch/lc3b/lc3bbc.c index d077c7c5..4d7496f6 100644 --- a/modules/arch/lc3b/lc3bbc.c +++ b/modules/arch/lc3b/lc3bbc.c @@ -25,7 +25,10 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include +/*@unused@*/ RCSID("$Id$"); +#define YASM_LIB_INTERNAL +#define YASM_BC_INTERNAL #include #include "lc3barch.h" @@ -35,17 +38,12 @@ static void lc3b_bc_insn_destroy(void *contents); static void lc3b_bc_insn_print(const void *contents, FILE *f, - int indent_level); -static int lc3b_bc_insn_calc_len(yasm_bytecode *bc, - yasm_bc_add_span_func add_span, - void *add_span_data); -static int lc3b_bc_insn_expand(yasm_bytecode *bc, int span, long old_val, - long new_val, /*@out@*/ long *neg_thres, - /*@out@*/ long *pos_thres); + int indent_level); +static yasm_bc_resolve_flags lc3b_bc_insn_resolve + (yasm_bytecode *bc, int save, yasm_calc_bc_dist_func calc_bc_dist); static int lc3b_bc_insn_tobytes(yasm_bytecode *bc, unsigned char **bufp, - unsigned char *bufstart, - void *d, yasm_output_value_func output_value, - /*@null@*/ yasm_output_reloc_func output_reloc); + void *d, yasm_output_value_func output_value, + /*@null@*/ yasm_output_reloc_func output_reloc); /* Bytecode callback structures */ @@ -53,9 +51,7 @@ static const yasm_bytecode_callback lc3b_bc_callback_insn = { lc3b_bc_insn_destroy, lc3b_bc_insn_print, yasm_bc_finalize_common, - NULL, - lc3b_bc_insn_calc_len, - lc3b_bc_insn_expand, + lc3b_bc_insn_resolve, lc3b_bc_insn_tobytes, 0 }; @@ -83,165 +79,177 @@ lc3b_bc_insn_print(const void *contents, FILE *f, int indent_level) fprintf(f, "%*s_Instruction_\n", indent_level, ""); fprintf(f, "%*sImmediate Value:", indent_level, ""); if (!insn->imm.abs) - fprintf(f, " (nil)\n"); + fprintf(f, " (nil)\n"); else { - indent_level++; - fprintf(f, "\n"); - yasm_value_print(&insn->imm, f, indent_level); - fprintf(f, "%*sType=", indent_level, ""); - switch (insn->imm_type) { - case LC3B_IMM_NONE: - fprintf(f, "NONE-SHOULDN'T HAPPEN"); - break; - case LC3B_IMM_4: - fprintf(f, "4-bit"); - break; - case LC3B_IMM_5: - fprintf(f, "5-bit"); - break; - case LC3B_IMM_6_WORD: - fprintf(f, "6-bit, word-multiple"); - break; - case LC3B_IMM_6_BYTE: - fprintf(f, "6-bit, byte-multiple"); - break; - case LC3B_IMM_8: - fprintf(f, "8-bit, word-multiple"); - break; - case LC3B_IMM_9: - fprintf(f, "9-bit, signed, word-multiple"); - break; - case LC3B_IMM_9_PC: - fprintf(f, "9-bit, signed, word-multiple, PC-relative"); - break; - } - indent_level--; + indent_level++; + fprintf(f, "\n"); + yasm_value_print(&insn->imm, f, indent_level); + fprintf(f, "%*sType=", indent_level, ""); + switch (insn->imm_type) { + case LC3B_IMM_NONE: + fprintf(f, "NONE-SHOULDN'T HAPPEN"); + break; + case LC3B_IMM_4: + fprintf(f, "4-bit"); + break; + case LC3B_IMM_5: + fprintf(f, "5-bit"); + break; + case LC3B_IMM_6_WORD: + fprintf(f, "6-bit, word-multiple"); + break; + case LC3B_IMM_6_BYTE: + fprintf(f, "6-bit, byte-multiple"); + break; + case LC3B_IMM_8: + fprintf(f, "8-bit, word-multiple"); + break; + case LC3B_IMM_9: + fprintf(f, "9-bit, signed, word-multiple"); + break; + case LC3B_IMM_9_PC: + fprintf(f, "9-bit, signed, word-multiple, PC-relative"); + break; + } + indent_level--; } /* FIXME fprintf(f, "\n%*sOrigin=", indent_level, ""); if (insn->origin) { - fprintf(f, "\n"); - yasm_symrec_print(insn->origin, f, indent_level+1); + fprintf(f, "\n"); + yasm_symrec_print(insn->origin, f, indent_level+1); } else - fprintf(f, "(nil)\n"); + fprintf(f, "(nil)\n"); */ fprintf(f, "%*sOpcode: %04x\n", indent_level, "", - (unsigned int)insn->opcode); + (unsigned int)insn->opcode); } -static int -lc3b_bc_insn_calc_len(yasm_bytecode *bc, yasm_bc_add_span_func add_span, - void *add_span_data) +static yasm_bc_resolve_flags +lc3b_bc_insn_resolve(yasm_bytecode *bc, int save, + yasm_calc_bc_dist_func calc_bc_dist) { lc3b_insn *insn = (lc3b_insn *)bc->contents; yasm_bytecode *target_prevbc; + /*@only@*/ yasm_intnum *num; + long rel; /* Fixed size instruction length */ - bc->len += 2; + bc->len = 2; - /* Only need to worry about out-of-range to PC-relative */ - if (insn->imm_type != LC3B_IMM_9_PC) - return 0; + /* Only need to worry about out-of-range to PC-relative, and only if we're + * saving. + */ + if (insn->imm_type != LC3B_IMM_9_PC || !save) + return YASM_BC_RESOLVE_MIN_LEN; - if (insn->imm.rel - && (!yasm_symrec_get_label(insn->imm.rel, &target_prevbc) - || target_prevbc->section != bc->section)) { - /* External or out of segment, so we can't check distance. */ - return 0; + if (!insn->imm.rel) + num = yasm_intnum_create_uint(0); + else if (!yasm_symrec_get_label(insn->imm.rel, &target_prevbc) + || target_prevbc->section != insn->origin_prevbc->section + || !(num = calc_bc_dist(insn->origin_prevbc, target_prevbc))) { + /* External or out of segment, so we can't check distance. */ + return YASM_BC_RESOLVE_MIN_LEN; } + if (insn->imm.abs) { + /*@only@*/ yasm_expr *temp = yasm_expr_copy(insn->imm.abs); + /*@dependent@*/ /*@null@*/ yasm_intnum *num2; + num2 = yasm_expr_get_intnum(&temp, calc_bc_dist); + if (!num2) { + yasm_error_set(YASM_ERROR_TOO_COMPLEX, + N_("jump target too complex")); + yasm_expr_destroy(temp); + return YASM_BC_RESOLVE_ERROR | YASM_BC_RESOLVE_UNKNOWN_LEN; + } + yasm_intnum_calc(num, YASM_EXPR_ADD, num2); + yasm_expr_destroy(temp); + } + + rel = yasm_intnum_get_int(num); + yasm_intnum_destroy(num); + rel -= 2; /* 9-bit signed, word-multiple displacement */ - add_span(add_span_data, bc, 1, &insn->imm, -512+(long)bc->len, - 511+(long)bc->len); - return 0; + if (rel < -512 || rel > 511) { + yasm_error_set(YASM_ERROR_OVERFLOW, N_("target out of range")); + return YASM_BC_RESOLVE_ERROR | YASM_BC_RESOLVE_UNKNOWN_LEN; + } + return YASM_BC_RESOLVE_MIN_LEN; } static int -lc3b_bc_insn_expand(yasm_bytecode *bc, int span, long old_val, long new_val, - /*@out@*/ long *neg_thres, /*@out@*/ long *pos_thres) -{ - yasm_error_set(YASM_ERROR_VALUE, N_("jump target out of range")); - return -1; -} - -static int -lc3b_bc_insn_tobytes(yasm_bytecode *bc, unsigned char **bufp, - unsigned char *bufstart, void *d, - yasm_output_value_func output_value, - /*@unused@*/ yasm_output_reloc_func output_reloc) +lc3b_bc_insn_tobytes(yasm_bytecode *bc, unsigned char **bufp, void *d, + yasm_output_value_func output_value, + /*@unused@*/ yasm_output_reloc_func output_reloc) { lc3b_insn *insn = (lc3b_insn *)bc->contents; /*@only@*/ yasm_intnum *delta; - unsigned long buf_off = (unsigned long)(*bufp - bufstart); /* Output opcode */ YASM_SAVE_16_L(*bufp, insn->opcode); /* Insert immediate into opcode. */ switch (insn->imm_type) { - case LC3B_IMM_NONE: - break; - case LC3B_IMM_4: - insn->imm.size = 4; - if (output_value(&insn->imm, *bufp, 2, buf_off, bc, 1, d)) - return 1; - break; - case LC3B_IMM_5: - insn->imm.size = 5; - insn->imm.sign = 1; - if (output_value(&insn->imm, *bufp, 2, buf_off, bc, 1, d)) - return 1; - break; - case LC3B_IMM_6_WORD: - insn->imm.size = 6; - if (output_value(&insn->imm, *bufp, 2, buf_off, bc, 1, d)) - return 1; - break; - case LC3B_IMM_6_BYTE: - insn->imm.size = 6; - insn->imm.sign = 1; - if (output_value(&insn->imm, *bufp, 2, buf_off, bc, 1, d)) - return 1; - break; - case LC3B_IMM_8: - insn->imm.size = 8; - if (output_value(&insn->imm, *bufp, 2, buf_off, bc, 1, d)) - return 1; - break; - case LC3B_IMM_9_PC: - /* Adjust relative displacement to end of bytecode */ - delta = yasm_intnum_create_int(-1); - if (!insn->imm.abs) - insn->imm.abs = yasm_expr_create_ident(yasm_expr_int(delta), - bc->line); - else - insn->imm.abs = - yasm_expr_create(YASM_EXPR_ADD, - yasm_expr_expr(insn->imm.abs), - yasm_expr_int(delta), bc->line); + case LC3B_IMM_NONE: + break; + case LC3B_IMM_4: + insn->imm.size = 4; + if (output_value(&insn->imm, *bufp, 2, 0, bc, 1, d)) + return 1; + break; + case LC3B_IMM_5: + insn->imm.size = 5; + if (output_value(&insn->imm, *bufp, 2, 0, bc, -1, d)) + return 1; + break; + case LC3B_IMM_6_WORD: + insn->imm.size = 6; + if (output_value(&insn->imm, *bufp, 2, 0, bc, 1, d)) + return 1; + break; + case LC3B_IMM_6_BYTE: + insn->imm.size = 6; + if (output_value(&insn->imm, *bufp, 2, 0, bc, -1, d)) + return 1; + break; + case LC3B_IMM_8: + insn->imm.size = 8; + if (output_value(&insn->imm, *bufp, 2, 0, bc, 1, d)) + return 1; + break; + case LC3B_IMM_9_PC: + /* Adjust relative displacement to end of bytecode */ + delta = yasm_intnum_create_int(-1); + if (!insn->imm.abs) + insn->imm.abs = yasm_expr_create_ident(yasm_expr_int(delta), + bc->line); + else + insn->imm.abs = + yasm_expr_create(YASM_EXPR_ADD, + yasm_expr_expr(insn->imm.abs), + yasm_expr_int(delta), bc->line); - insn->imm.size = 9; - insn->imm.sign = 1; - if (output_value(&insn->imm, *bufp, 2, buf_off, bc, 1, d)) - return 1; - break; - case LC3B_IMM_9: - insn->imm.size = 9; - if (output_value(&insn->imm, *bufp, 2, buf_off, bc, 1, d)) - return 1; - break; - default: - yasm_internal_error(N_("Unrecognized immediate type")); + insn->imm.size = 9; + if (output_value(&insn->imm, *bufp, 2, 0, bc, -1, d)) + return 1; + break; + case LC3B_IMM_9: + insn->imm.size = 9; + if (output_value(&insn->imm, *bufp, 2, 0, bc, 1, d)) + return 1; + break; + default: + yasm_internal_error(N_("Unrecognized immediate type")); } - *bufp += 2; /* all instructions are 2 bytes in size */ + *bufp += 2; /* all instructions are 2 bytes in size */ return 0; } int yasm_lc3b__intnum_tobytes(yasm_arch *arch, const yasm_intnum *intn, - unsigned char *buf, size_t destsize, size_t valsize, - int shift, const yasm_bytecode *bc, int warn) + unsigned char *buf, size_t destsize, size_t valsize, + int shift, const yasm_bytecode *bc, int warn) { /* Write value out. */ yasm_intnum_get_sized(intn, buf, destsize, valsize, shift, 0, warn); diff --git a/modules/arch/lc3b/lc3bid.re b/modules/arch/lc3b/lc3bid.re index cd8f1303..2dce1a4b 100644 --- a/modules/arch/lc3b/lc3bid.re +++ b/modules/arch/lc3b/lc3bid.re @@ -25,7 +25,11 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include +RCSID("$Id$"); +#define YASM_LIB_INTERNAL +#define YASM_BC_INTERNAL +#define YASM_EXPR_INTERNAL #include #include "modules/arch/lc3b/lc3barch.h" @@ -35,8 +39,8 @@ * parameters are read from the arch-specific data in LSB->MSB order. * (only for asthetic reasons in the lexer code below, no practical reason). */ -#define MOD_OpHAdd (1UL<<0) /* Parameter adds to upper 8 bits of insn */ -#define MOD_OpLAdd (1UL<<1) /* Parameter adds to lower 8 bits of insn */ +#define MOD_OpHAdd (1UL<<0) /* Parameter adds to upper 8 bits of insn */ +#define MOD_OpLAdd (1UL<<1) /* Parameter adds to lower 8 bits of insn */ /* Operand types. These are more detailed than the "general" types for all * architectures, as they include the size, for instance. @@ -67,25 +71,25 @@ * 6 = 9-bit signed immediate, word-multiple * 7 = 9-bit signed offset from next PC ($+2), word-multiple */ -#define OPT_Imm 0x0 -#define OPT_Reg 0x1 -#define OPT_MASK 0x1 +#define OPT_Imm 0x0 +#define OPT_Reg 0x1 +#define OPT_MASK 0x1 -#define OPA_None (0<<1) -#define OPA_DR (1<<1) -#define OPA_SR (2<<1) -#define OPA_Imm (3<<1) -#define OPA_MASK (3<<1) +#define OPA_None (0<<1) +#define OPA_DR (1<<1) +#define OPA_SR (2<<1) +#define OPA_Imm (3<<1) +#define OPA_MASK (3<<1) -#define OPI_None (LC3B_IMM_NONE<<3) -#define OPI_4 (LC3B_IMM_4<<3) -#define OPI_5 (LC3B_IMM_5<<3) -#define OPI_6W (LC3B_IMM_6_WORD<<3) -#define OPI_6B (LC3B_IMM_6_BYTE<<3) -#define OPI_8 (LC3B_IMM_8<<3) -#define OPI_9 (LC3B_IMM_9<<3) -#define OPI_9PC (LC3B_IMM_9_PC<<3) -#define OPI_MASK (7<<3) +#define OPI_None (LC3B_IMM_NONE<<3) +#define OPI_4 (LC3B_IMM_4<<3) +#define OPI_5 (LC3B_IMM_5<<3) +#define OPI_6W (LC3B_IMM_6_WORD<<3) +#define OPI_6B (LC3B_IMM_6_BYTE<<3) +#define OPI_8 (LC3B_IMM_8<<3) +#define OPI_9 (LC3B_IMM_9<<3) +#define OPI_9PC (LC3B_IMM_9_PC<<3) +#define OPI_MASK (7<<3) typedef struct lc3b_insn_info { /* Opcode modifiers for variations of instruction. As each modifier reads @@ -106,42 +110,22 @@ typedef struct lc3b_insn_info { unsigned int operands[3]; } lc3b_insn_info; -typedef struct lc3b_id_insn { - yasm_insn insn; /* base structure */ +/* Define lexer arch-specific data with 0-3 modifiers. */ +#define DEF_INSN_DATA(group, mod) do { \ + data[0] = (unsigned long)group##_insn; \ + data[1] = ((mod)<<8) | \ + ((unsigned char)(sizeof(group##_insn)/sizeof(lc3b_insn_info))); \ + } while (0) - /* instruction parse group - NULL if empty instruction (just prefixes) */ - /*@null@*/ const lc3b_insn_info *group; - - /* Modifier data */ - unsigned long mod_data; - - /* Number of elements in the instruction parse group */ - unsigned int num_info:8; -} lc3b_id_insn; - -static void lc3b_id_insn_destroy(void *contents); -static void lc3b_id_insn_print(const void *contents, FILE *f, int indent_level); -static void lc3b_id_insn_finalize(yasm_bytecode *bc, yasm_bytecode *prev_bc); - -static const yasm_bytecode_callback lc3b_id_insn_callback = { - lc3b_id_insn_destroy, - lc3b_id_insn_print, - lc3b_id_insn_finalize, - NULL, - yasm_bc_calc_len_common, - yasm_bc_expand_common, - yasm_bc_tobytes_common, - YASM_BC_SPECIAL_INSN -}; +#define RET_INSN(group, mod) do { \ + DEF_INSN_DATA(group, mod); \ + return YASM_ARCH_INSN; \ + } while (0) /* * Instruction groupings */ -static const lc3b_insn_info empty_insn[] = { - { 0, 0, 0, {0, 0, 0} } -}; - static const lc3b_insn_info addand_insn[] = { { MOD_OpHAdd, 0x1000, 3, {OPT_Reg|OPA_DR, OPT_Reg|OPA_SR, OPT_Reg|OPA_Imm|OPI_5} }, @@ -188,150 +172,149 @@ static const lc3b_insn_info trap_insn[] = { { 0, 0xF000, 1, {OPT_Imm|OPA_Imm|OPI_8, 0, 0} } }; -static void -lc3b_id_insn_finalize(yasm_bytecode *bc, yasm_bytecode *prev_bc) +void +yasm_lc3b__finalize_insn(yasm_arch *arch, yasm_bytecode *bc, + yasm_bytecode *prev_bc, const unsigned long data[4], + int num_operands, + /*@null@*/ yasm_insn_operands *operands, + int num_prefixes, unsigned long **prefixes, + int num_segregs, const unsigned long *segregs) { - lc3b_id_insn *id_insn = (lc3b_id_insn *)bc->contents; lc3b_insn *insn; - int num_info = id_insn->num_info; - const lc3b_insn_info *info = id_insn->group; - unsigned long mod_data = id_insn->mod_data; + int num_info = (int)(data[1]&0xFF); + lc3b_insn_info *info = (lc3b_insn_info *)data[0]; + unsigned long mod_data = data[1] >> 8; int found = 0; yasm_insn_operand *op; int i; - yasm_insn_finalize(&id_insn->insn); - /* Just do a simple linear search through the info array for a match. * First match wins. */ for (; num_info>0 && !found; num_info--, info++) { - int mismatch = 0; + int mismatch = 0; - /* Match # of operands */ - if (id_insn->insn.num_operands != info->num_operands) - continue; + /* Match # of operands */ + if (num_operands != info->num_operands) + continue; - if (id_insn->insn.num_operands == 0) { - found = 1; /* no operands -> must have a match here. */ - break; - } + if (!operands) { + found = 1; /* no operands -> must have a match here. */ + break; + } - /* Match each operand type and size */ - for(i = 0, op = yasm_insn_ops_first(&id_insn->insn); - op && inum_operands && !mismatch; - op = yasm_insn_op_next(op), i++) { - /* Check operand type */ - switch ((int)(info->operands[i] & OPT_MASK)) { - case OPT_Imm: - if (op->type != YASM_INSN__OPERAND_IMM) - mismatch = 1; - break; - case OPT_Reg: - if (op->type != YASM_INSN__OPERAND_REG) - mismatch = 1; - break; - default: - yasm_internal_error(N_("invalid operand type")); - } + /* Match each operand type and size */ + for(i = 0, op = yasm_ops_first(operands); op && inum_operands && + !mismatch; op = yasm_operand_next(op), i++) { + /* Check operand type */ + switch ((int)(info->operands[i] & OPT_MASK)) { + case OPT_Imm: + if (op->type != YASM_INSN__OPERAND_IMM) + mismatch = 1; + break; + case OPT_Reg: + if (op->type != YASM_INSN__OPERAND_REG) + mismatch = 1; + break; + default: + yasm_internal_error(N_("invalid operand type")); + } - if (mismatch) - break; - } + if (mismatch) + break; + } - if (!mismatch) { - found = 1; - break; - } + if (!mismatch) { + found = 1; + break; + } } if (!found) { - /* Didn't find a matching one */ - yasm_error_set(YASM_ERROR_TYPE, - N_("invalid combination of opcode and operands")); - return; + /* Didn't find a matching one */ + yasm_error_set(YASM_ERROR_TYPE, + N_("invalid combination of opcode and operands")); + return; } /* Copy what we can from info */ insn = yasm_xmalloc(sizeof(lc3b_insn)); yasm_value_initialize(&insn->imm, NULL, 0); insn->imm_type = LC3B_IMM_NONE; + insn->origin_prevbc = NULL; insn->opcode = info->opcode; /* Apply modifiers */ if (info->modifiers & MOD_OpHAdd) { - insn->opcode += ((unsigned int)(mod_data & 0xFF))<<8; - mod_data >>= 8; + insn->opcode += ((unsigned int)(mod_data & 0xFF))<<8; + mod_data >>= 8; } if (info->modifiers & MOD_OpLAdd) { - insn->opcode += (unsigned int)(mod_data & 0xFF); - /*mod_data >>= 8;*/ + insn->opcode += (unsigned int)(mod_data & 0xFF); + /*mod_data >>= 8;*/ } /* Go through operands and assign */ - if (id_insn->insn.num_operands > 0) { - for(i = 0, op = yasm_insn_ops_first(&id_insn->insn); - op && inum_operands; op = yasm_insn_op_next(op), i++) { + if (operands) { + for(i = 0, op = yasm_ops_first(operands); op && inum_operands; + op = yasm_operand_next(op), i++) { - switch ((int)(info->operands[i] & OPA_MASK)) { - case OPA_None: - /* Throw away the operand contents */ - if (op->type == YASM_INSN__OPERAND_IMM) - yasm_expr_destroy(op->data.val); - break; - case OPA_DR: - if (op->type != YASM_INSN__OPERAND_REG) - yasm_internal_error(N_("invalid operand conversion")); - insn->opcode |= ((unsigned int)(op->data.reg & 0x7)) << 9; - break; - case OPA_SR: - if (op->type != YASM_INSN__OPERAND_REG) - yasm_internal_error(N_("invalid operand conversion")); - insn->opcode |= ((unsigned int)(op->data.reg & 0x7)) << 6; - break; - case OPA_Imm: - insn->imm_type = (info->operands[i] & OPI_MASK)>>3; - switch (op->type) { - case YASM_INSN__OPERAND_IMM: - if (insn->imm_type == LC3B_IMM_6_WORD - || insn->imm_type == LC3B_IMM_8 - || insn->imm_type == LC3B_IMM_9 - || insn->imm_type == LC3B_IMM_9_PC) - op->data.val = yasm_expr_create(YASM_EXPR_SHR, - yasm_expr_expr(op->data.val), - yasm_expr_int(yasm_intnum_create_uint(1)), - op->data.val->line); - if (yasm_value_finalize_expr(&insn->imm, - op->data.val, - prev_bc, 0)) - yasm_error_set(YASM_ERROR_TOO_COMPLEX, - N_("immediate expression too complex")); - break; - case YASM_INSN__OPERAND_REG: - if (yasm_value_finalize_expr(&insn->imm, - yasm_expr_create_ident(yasm_expr_int( - yasm_intnum_create_uint(op->data.reg & 0x7)), - bc->line), prev_bc, 0)) - yasm_internal_error(N_("reg expr too complex?")); - break; - default: - yasm_internal_error(N_("invalid operand conversion")); - } - break; - default: - yasm_internal_error(N_("unknown operand action")); - } + switch ((int)(info->operands[i] & OPA_MASK)) { + case OPA_None: + /* Throw away the operand contents */ + if (op->type == YASM_INSN__OPERAND_IMM) + yasm_expr_destroy(op->data.val); + break; + case OPA_DR: + if (op->type != YASM_INSN__OPERAND_REG) + yasm_internal_error(N_("invalid operand conversion")); + insn->opcode |= ((unsigned int)(op->data.reg & 0x7)) << 9; + break; + case OPA_SR: + if (op->type != YASM_INSN__OPERAND_REG) + yasm_internal_error(N_("invalid operand conversion")); + insn->opcode |= ((unsigned int)(op->data.reg & 0x7)) << 6; + break; + case OPA_Imm: + insn->imm_type = (info->operands[i] & OPI_MASK)>>3; + switch (op->type) { + case YASM_INSN__OPERAND_IMM: + if (insn->imm_type == LC3B_IMM_6_WORD + || insn->imm_type == LC3B_IMM_8 + || insn->imm_type == LC3B_IMM_9 + || insn->imm_type == LC3B_IMM_9_PC) + op->data.val = yasm_expr_create(YASM_EXPR_SHR, + yasm_expr_expr(op->data.val), + yasm_expr_int(yasm_intnum_create_uint(1)), + op->data.val->line); + if (yasm_value_finalize_expr(&insn->imm, + op->data.val, 0)) + yasm_error_set(YASM_ERROR_TOO_COMPLEX, + N_("immediate expression too complex")); + break; + case YASM_INSN__OPERAND_REG: + if (yasm_value_finalize_expr(&insn->imm, + yasm_expr_create_ident(yasm_expr_int( + yasm_intnum_create_uint(op->data.reg & 0x7)), + bc->line), 0)) + yasm_internal_error(N_("reg expr too complex?")); + break; + default: + yasm_internal_error(N_("invalid operand conversion")); + } + break; + default: + yasm_internal_error(N_("unknown operand action")); + } + } - /* Clear so it doesn't get destroyed */ - op->type = YASM_INSN__OPERAND_REG; - } - - if (insn->imm_type == LC3B_IMM_9_PC) { - if (insn->imm.seg_of || insn->imm.rshift > 1 - || insn->imm.curpos_rel) - yasm_error_set(YASM_ERROR_VALUE, N_("invalid jump target")); - insn->imm.curpos_rel = 1; - } + if (insn->imm_type == LC3B_IMM_9_PC) { + insn->origin_prevbc = prev_bc; + if (insn->imm.seg_of || insn->imm.rshift > 1 + || insn->imm.curpos_rel) + yasm_error_set(YASM_ERROR_VALUE, N_("invalid jump target")); + insn->imm.curpos_rel = 1; + } } /* Transform the bytecode */ @@ -339,144 +322,92 @@ lc3b_id_insn_finalize(yasm_bytecode *bc, yasm_bytecode *prev_bc) } -#define YYCTYPE unsigned char -#define YYCURSOR id -#define YYLIMIT id_end -#define YYMARKER marker -#define YYFILL(n) (void)(n) +#define YYCTYPE unsigned char +#define YYCURSOR id +#define YYLIMIT id +#define YYMARKER marker +#define YYFILL(n) (void)(n) + +void +yasm_lc3b__parse_cpu(yasm_arch *arch, const char *cpuid, size_t cpuid_len) +{ +} yasm_arch_regtmod -yasm_lc3b__parse_check_regtmod(yasm_arch *arch, const char *oid, size_t id_len, - uintptr_t *data) +yasm_lc3b__parse_check_regtmod(yasm_arch *arch, unsigned long *data, + const char *oid, size_t id_len) { const YYCTYPE *id = (const YYCTYPE *)oid; - const YYCTYPE *const id_end = (const YYCTYPE *)(oid + id_len); /*const char *marker;*/ /*!re2c - /* integer registers */ - 'r' [0-7] { - *data = (oid[1]-'0'); - return YASM_ARCH_REG; - } + /* integer registers */ + 'r' [0-7] { + *data = (oid[1]-'0'); + return YASM_ARCH_REG; + } - /* catchalls */ - [\001-\377]+ { - return YASM_ARCH_NOTREGTMOD; - } - [\000] { - return YASM_ARCH_NOTREGTMOD; - } + /* catchalls */ + [\001-\377]+ { + return YASM_ARCH_NOTREGTMOD; + } + [\000] { + return YASM_ARCH_NOTREGTMOD; + } */ } -#define RET_INSN(g, m) \ - do { \ - group = g##_insn; \ - mod = m; \ - nelems = NELEMS(g##_insn); \ - goto done; \ - } while(0) - yasm_arch_insnprefix -yasm_lc3b__parse_check_insnprefix(yasm_arch *arch, const char *oid, - size_t id_len, unsigned long line, - yasm_bytecode **bc, uintptr_t *prefix) +yasm_lc3b__parse_check_insnprefix(yasm_arch *arch, unsigned long data[4], + const char *oid, size_t id_len) { const YYCTYPE *id = (const YYCTYPE *)oid; - const YYCTYPE *const id_end = (const YYCTYPE *)(oid + id_len); - const lc3b_insn_info *group = empty_insn; - unsigned long mod = 0; - unsigned int nelems = NELEMS(empty_insn); - lc3b_id_insn *id_insn; - - *bc = (yasm_bytecode *)NULL; - *prefix = 0; - /*const char *marker;*/ /*!re2c - /* instructions */ + /* instructions */ - 'add' { RET_INSN(addand, 0x00); } - 'and' { RET_INSN(addand, 0x40); } + 'add' { RET_INSN(addand, 0x00); } + 'and' { RET_INSN(addand, 0x40); } - 'br' { RET_INSN(br, 0x00); } - 'brn' { RET_INSN(br, 0x08); } - 'brz' { RET_INSN(br, 0x04); } - 'brp' { RET_INSN(br, 0x02); } - 'brnz' { RET_INSN(br, 0x0C); } - 'brnp' { RET_INSN(br, 0x0A); } - 'brzp' { RET_INSN(br, 0x06); } - 'brnzp' { RET_INSN(br, 0x0E); } - 'jsr' { RET_INSN(br, 0x40); } + 'br' { RET_INSN(br, 0x00); } + 'brn' { RET_INSN(br, 0x08); } + 'brz' { RET_INSN(br, 0x04); } + 'brp' { RET_INSN(br, 0x02); } + 'brnz' { RET_INSN(br, 0x0C); } + 'brnp' { RET_INSN(br, 0x0A); } + 'brzp' { RET_INSN(br, 0x06); } + 'brnzp' { RET_INSN(br, 0x0E); } + 'jsr' { RET_INSN(br, 0x40); } - 'jmp' { RET_INSN(jmp, 0); } + 'jmp' { RET_INSN(jmp, 0); } - 'lea' { RET_INSN(lea, 0); } + 'lea' { RET_INSN(lea, 0); } - 'ld' { RET_INSN(ldst, 0x20); } - 'ldi' { RET_INSN(ldst, 0xA0); } - 'st' { RET_INSN(ldst, 0x30); } - 'sti' { RET_INSN(ldst, 0xB0); } + 'ld' { RET_INSN(ldst, 0x20); } + 'ldi' { RET_INSN(ldst, 0xA0); } + 'st' { RET_INSN(ldst, 0x30); } + 'sti' { RET_INSN(ldst, 0xB0); } - 'ldb' { RET_INSN(ldstb, 0x60); } - 'stb' { RET_INSN(ldstb, 0x70); } + 'ldb' { RET_INSN(ldstb, 0x60); } + 'stb' { RET_INSN(ldstb, 0x70); } - 'not' { RET_INSN(not, 0); } + 'not' { RET_INSN(not, 0); } - 'ret' { RET_INSN(nooperand, 0xCE); } - 'rti' { RET_INSN(nooperand, 0x80); } - 'nop' { RET_INSN(nooperand, 0); } + 'ret' { RET_INSN(nooperand, 0xCE); } + 'rti' { RET_INSN(nooperand, 0x80); } + 'nop' { RET_INSN(nooperand, 0); } - 'lshf' { RET_INSN(shift, 0x00); } - 'rshfl' { RET_INSN(shift, 0x10); } - 'rshfa' { RET_INSN(shift, 0x30); } + 'lshf' { RET_INSN(shift, 0x00); } + 'rshfl' { RET_INSN(shift, 0x10); } + 'rshfa' { RET_INSN(shift, 0x30); } - 'trap' { RET_INSN(trap, 0); } + 'trap' { RET_INSN(trap, 0); } - /* catchalls */ - [\001-\377]+ { - return YASM_ARCH_NOTINSNPREFIX; - } - [\000] { - return YASM_ARCH_NOTINSNPREFIX; - } + /* catchalls */ + [\001-\377]+ { + return YASM_ARCH_NOTINSNPREFIX; + } + [\000] { + return YASM_ARCH_NOTINSNPREFIX; + } */ - -done: - id_insn = yasm_xmalloc(sizeof(lc3b_id_insn)); - yasm_insn_initialize(&id_insn->insn); - id_insn->group = group; - id_insn->mod_data = mod; - id_insn->num_info = nelems; - *bc = yasm_bc_create_common(&lc3b_id_insn_callback, id_insn, line); - return YASM_ARCH_INSN; -} - -static void -lc3b_id_insn_destroy(void *contents) -{ - lc3b_id_insn *id_insn = (lc3b_id_insn *)contents; - yasm_insn_delete(&id_insn->insn, yasm_lc3b__ea_destroy); - yasm_xfree(contents); -} - -static void -lc3b_id_insn_print(const void *contents, FILE *f, int indent_level) -{ - const lc3b_id_insn *id_insn = (const lc3b_id_insn *)contents; - yasm_insn_print(&id_insn->insn, f, indent_level); - /*TODO*/ -} - -/*@only@*/ yasm_bytecode * -yasm_lc3b__create_empty_insn(yasm_arch *arch, unsigned long line) -{ - lc3b_id_insn *id_insn = yasm_xmalloc(sizeof(lc3b_id_insn)); - - yasm_insn_initialize(&id_insn->insn); - id_insn->group = empty_insn; - id_insn->mod_data = 0; - id_insn->num_info = NELEMS(empty_insn); - - return yasm_bc_create_common(&lc3b_id_insn_callback, id_insn, line); } diff --git a/modules/arch/lc3b/tests/Makefile.inc b/modules/arch/lc3b/tests/Makefile.inc index 1ca39a3d..43ffb70b 100644 --- a/modules/arch/lc3b/tests/Makefile.inc +++ b/modules/arch/lc3b/tests/Makefile.inc @@ -1,3 +1,5 @@ +# $Id$ + TESTS += modules/arch/lc3b/tests/lc3b_test.sh EXTRA_DIST += modules/arch/lc3b/tests/lc3b_test.sh @@ -5,8 +7,10 @@ EXTRA_DIST += modules/arch/lc3b/tests/lc3b-basic.asm EXTRA_DIST += modules/arch/lc3b/tests/lc3b-basic.errwarn EXTRA_DIST += modules/arch/lc3b/tests/lc3b-basic.hex EXTRA_DIST += modules/arch/lc3b/tests/lc3b-br.asm +EXTRA_DIST += modules/arch/lc3b/tests/lc3b-br.errwarn EXTRA_DIST += modules/arch/lc3b/tests/lc3b-br.hex EXTRA_DIST += modules/arch/lc3b/tests/lc3b-ea-err.asm EXTRA_DIST += modules/arch/lc3b/tests/lc3b-ea-err.errwarn EXTRA_DIST += modules/arch/lc3b/tests/lc3b-mp22NC.asm +EXTRA_DIST += modules/arch/lc3b/tests/lc3b-mp22NC.errwarn EXTRA_DIST += modules/arch/lc3b/tests/lc3b-mp22NC.hex diff --git a/modules/arch/lc3b/tests/lc3b-ea-err.errwarn b/modules/arch/lc3b/tests/lc3b-ea-err.errwarn index e49df726..afc28697 100644 --- a/modules/arch/lc3b/tests/lc3b-ea-err.errwarn +++ b/modules/arch/lc3b/tests/lc3b-ea-err.errwarn @@ -1 +1 @@ --:1: error: invalid combination of opcode and operands +-:1: invalid combination of opcode and operands diff --git a/modules/arch/lc3b/tests/lc3b_test.sh b/modules/arch/lc3b/tests/lc3b_test.sh index 5c115817..30ca95df 100755 --- a/modules/arch/lc3b/tests/lc3b_test.sh +++ b/modules/arch/lc3b/tests/lc3b_test.sh @@ -1,3 +1,4 @@ #! /bin/sh +# $Id$ ${srcdir}/out_test.sh lc3b_test modules/arch/lc3b/tests "lc3b arch" "-a lc3b -f bin" "" exit $? diff --git a/modules/arch/x86/CMakeLists.txt b/modules/arch/x86/CMakeLists.txt deleted file mode 100644 index d15c9948..00000000 --- a/modules/arch/x86/CMakeLists.txt +++ /dev/null @@ -1,50 +0,0 @@ -ADD_CUSTOM_COMMAND( - OUTPUT - ${CMAKE_CURRENT_BINARY_DIR}/x86insns.c - ${CMAKE_CURRENT_BINARY_DIR}/x86insn_gas.gperf - ${CMAKE_CURRENT_BINARY_DIR}/x86insn_nasm.gperf - COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/arch/x86/gen_x86_insn.py - ${CMAKE_CURRENT_BINARY_DIR}/x86insns.c - ${CMAKE_CURRENT_BINARY_DIR}/x86insn_gas.gperf - ${CMAKE_CURRENT_BINARY_DIR}/x86insn_nasm.gperf - MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/arch/x86/gen_x86_insn.py - ) - -YASM_GENPERF( - ${CMAKE_CURRENT_SOURCE_DIR}/arch/x86/x86cpu.gperf - ${CMAKE_CURRENT_BINARY_DIR}/x86cpu.c - ) - -YASM_GENPERF( - ${CMAKE_CURRENT_SOURCE_DIR}/arch/x86/x86regtmod.gperf - ${CMAKE_CURRENT_BINARY_DIR}/x86regtmod.c - ) - -YASM_GENPERF( - ${CMAKE_CURRENT_BINARY_DIR}/x86insn_nasm.gperf - ${CMAKE_CURRENT_BINARY_DIR}/x86insn_nasm.c - ) - -YASM_GENPERF( - ${CMAKE_CURRENT_BINARY_DIR}/x86insn_gas.gperf - ${CMAKE_CURRENT_BINARY_DIR}/x86insn_gas.c - ) - -YASM_ADD_MODULE(arch_x86 - arch/x86/x86arch.c - arch/x86/x86bc.c - arch/x86/x86expr.c - arch/x86/x86id.c - x86cpu.c - x86regtmod.c - ) - -SET(insn_DEPS - ${CMAKE_CURRENT_BINARY_DIR}/x86insn_nasm.c - ${CMAKE_CURRENT_BINARY_DIR}/x86insn_gas.c - ${CMAKE_CURRENT_BINARY_DIR}/x86insns.c - ) - -SET_SOURCE_FILES_PROPERTIES(arch/x86/x86id.c PROPERTIES - OBJECT_DEPENDS "${insn_DEPS}" - ) diff --git a/modules/arch/x86/Makefile.inc b/modules/arch/x86/Makefile.inc index e7b162e3..24e90fa7 100644 --- a/modules/arch/x86/Makefile.inc +++ b/modules/arch/x86/Makefile.inc @@ -1,56 +1,22 @@ +# $Id$ + libyasm_a_SOURCES += modules/arch/x86/x86arch.c libyasm_a_SOURCES += modules/arch/x86/x86arch.h libyasm_a_SOURCES += modules/arch/x86/x86bc.c libyasm_a_SOURCES += modules/arch/x86/x86expr.c libyasm_a_SOURCES += modules/arch/x86/x86id.c -nodist_libyasm_a_SOURCES += x86cpu.c -nodist_libyasm_a_SOURCES += x86regtmod.c YASM_MODULES += arch_x86 -modules/arch/x86/x86id.c: x86insn_nasm.c x86insn_gas.c x86insns.c +modules/arch/x86/x86id.c: x86parse.c -EXTRA_DIST += modules/arch/x86/gen_x86_insn.py +EXTRA_DIST += modules/arch/x86/x86parse.gap -if HAVE_PYTHON -x86insn_nasm.gperf x86insn_gas.gperf x86insns.c: $(srcdir)/modules/arch/x86/gen_x86_insn.py - $(PYTHON) $(srcdir)/modules/arch/x86/gen_x86_insn.py -else -x86insn_nasm.gperf: $(srcdir)/x86insn_nasm.gperf - @echo Python must be installed to regenerate x86 instructions files - cp $(srcdir)/x86insn_nasm.gperf $@ -x86insn_gas.gperf: $(srcdir)/x86insn_gas.gperf - @echo Python must be installed to regenerate x86 instructions files - cp $(srcdir)/x86insn_gas.gperf $@ -endif +x86parse.c: $(srcdir)/modules/arch/x86/x86parse.gap gap$(EXEEXT) + $(top_builddir)/gap$(EXEEXT) $(srcdir)/modules/arch/x86/x86parse.gap $@ -BUILT_SOURCES += x86insns.c -BUILT_SOURCES += x86insn_nasm.gperf -BUILT_SOURCES += x86insn_gas.gperf -EXTRA_DIST += x86insns.c -EXTRA_DIST += x86insn_nasm.gperf -EXTRA_DIST += x86insn_gas.gperf -MAINTAINERCLEANFILES += x86insns.c -MAINTAINERCLEANFILES += x86insn_nasm.gperf -MAINTAINERCLEANFILES += x86insn_gas.gperf - -EXTRA_DIST += modules/arch/x86/x86cpu.gperf -EXTRA_DIST += modules/arch/x86/x86regtmod.gperf - -# Use suffix rules for gperf files -x86insn_nasm.c: x86insn_nasm.gperf genperf$(EXEEXT) -x86insn_gas.c: x86insn_gas.gperf genperf$(EXEEXT) -x86cpu.c: $(srcdir)/modules/arch/x86/x86cpu.gperf genperf$(EXEEXT) - $(top_builddir)/genperf$(EXEEXT) $(srcdir)/modules/arch/x86/x86cpu.gperf $@ -x86regtmod.c: $(srcdir)/modules/arch/x86/x86regtmod.gperf genperf$(EXEEXT) - $(top_builddir)/genperf$(EXEEXT) $(srcdir)/modules/arch/x86/x86regtmod.gperf $@ - -BUILT_SOURCES += x86insn_nasm.c -BUILT_SOURCES += x86insn_gas.c -CLEANFILES += x86insn_nasm.c -CLEANFILES += x86insn_gas.c -CLEANFILES += x86cpu.c -CLEANFILES += x86regtmod.c +BUILT_SOURCES += x86parse.c +CLEANFILES += x86parse.c EXTRA_DIST += modules/arch/x86/tests/Makefile.inc diff --git a/modules/arch/x86/gen_x86_insn.py b/modules/arch/x86/gen_x86_insn.py deleted file mode 100755 index ba41a4f1..00000000 --- a/modules/arch/x86/gen_x86_insn.py +++ /dev/null @@ -1,8516 +0,0 @@ -#! /usr/bin/env python -# x86 instructions and prefixes data and code generation -# -# Copyright (C) 2002-2007 Peter Johnson -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND OTHER CONTRIBUTORS ``AS IS'' -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR OTHER CONTRIBUTORS BE -# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -# NOTE: operands are arranged in NASM / Intel order (e.g. dest, src) - -from sys import stdout, version_info - -scriptname = "gen_x86_insn.py" -scriptrev = "HEAD" - -ordered_cpus = [ - "086", "186", "286", "386", "486", "586", "686", "K6", "Athlon", "P3", - "P4", "IA64", "Hammer"] -ordered_cpu_features = [ - "FPU", "Cyrix", "AMD", "MMX", "3DNow", "SMM", "SSE", "SSE2", - "SSE3", "SVM", "PadLock", "SSSE3", "SSE41", "SSE42", "SSE4a", "SSE5", - "AES", "AVX", "FMA", "CLMUL", "MOVBE", "XOP", "FMA4", "F16C", - "FSGSBASE", "RDRAND", "XSAVEOPT", "EPTVPID", "SMX", "AVX2", "BMI1", - "BMI2", "INVPCID", "LZCNT", "TBM", "TSX", "SHA", "SMAP", "RDSEED", "ADX", - "PRFCHW"] -unordered_cpu_features = ["Priv", "Prot", "Undoc", "Obs"] - -# Predefined VEX prefix field values -VEXW0 = 0xC0 -VEXW1 = 0xC8 -VEXL0 = 0xC0 -VEXL1 = 0xC4 -VEXpp = 0xC0 # OR with value - -# Predefined XOP prefix field values -XOPW0 = 0x80 -XOPW1 = 0x88 -XOPL0 = 0x80 -XOPL1 = 0x84 -XOPpp = 0x80 # OR with value - -def lprint(s, f = stdout, e = '\n') : - f.write(s + e) - -def cpu_lcd(cpu1, cpu2): - """Find the lowest common denominator of two CPU sets.""" - retval = set() - - # CPU - cpu1cpus = set(ordered_cpus) & set(cpu1) - if not cpu1cpus: - cpu1cpus.add("086") - cpu1mincpu = min(ordered_cpus.index(x) for x in cpu1cpus) - cpu2cpus = set(ordered_cpus) & set(cpu2) - if not cpu2cpus: - cpu2cpus.add("086") - cpu2mincpu = min(ordered_cpus.index(x) for x in cpu1cpus) - cpumin = ordered_cpus[min(cpu1mincpu, cpu2mincpu)] - if cpumin == "086": - cpumin = "Any" - - if cpumin != "Any": - retval.add(cpumin) - - # Feature - cpu1features = set(ordered_cpu_features) & set(cpu1) - if not cpu1features: - cpu1minfeature = -1 - else: - cpu1minfeature = min(ordered_cpu_features.index(x) - for x in cpu1features) - - cpu2features = set(ordered_cpu_features) & set(cpu2) - if not cpu2features: - cpu2minfeature = -1 - else: - cpu2minfeature = min(ordered_cpu_features.index(x) - for x in cpu2features) - - if cpu1minfeature != -1 and cpu2minfeature != -1: - featuremin = ordered_cpu_features[min(cpu1minfeature, cpu2minfeature)] - retval.add(featuremin) - - # Unordered features - for feature in set(unordered_cpu_features) & set(cpu1) & set(cpu2): - retval.add(feature) - - return retval - -class Operand(object): - def __init__(self, **kwargs): - self.type = kwargs.pop("type") - self.size = kwargs.pop("size", "Any") - self.relaxed = kwargs.pop("relaxed", False) - self.dest = kwargs.pop("dest", None) - self.tmod = kwargs.pop("tmod", None) - self.opt = kwargs.pop("opt", None) - - if kwargs: - for arg in kwargs: - lprint("Warning: unrecognized arg %s" % arg) - - def __str__(self): - return "{"+ ", ".join(["OPT_%s" % self.type, - "OPS_%s" % self.size, - "%d" % self.relaxed, - self.dest == "EA64" and "1" or "0", - "OPTM_%s" % self.tmod, - "OPA_%s" % (self.dest == "EA64" - and "EA" or self.dest), - "OPAP_%s" % self.opt]) + "}" - - def __eq__(self, other): - return (self.type == other.type and - self.size == other.size and - self.relaxed == other.relaxed and - self.dest == other.dest and - self.tmod == other.tmod and - self.opt == other.opt) - - def __ne__(self, other): - return (self.type != other.type or - self.size != other.size or - self.relaxed != other.relaxed or - self.dest != other.dest or - self.tmod != other.tmod or - self.opt != other.opt) - -class GroupForm(object): - def __init__(self, **kwargs): - # Parsers - self.parsers = set(kwargs.pop("parsers", ["gas", "nasm"])) - - # CPU feature flags initialization - self.cpu = set(kwargs.pop("cpu", [])) - - # Misc flags - self.misc_flags = set(kwargs.pop("misc_flags", [])) - if kwargs.pop("only64", False): - self.misc_flags.add("ONLY_64") - if kwargs.pop("not64", False): - self.misc_flags.add("NOT_64") - if kwargs.pop("onlyavx", False): - self.misc_flags.add("ONLY_AVX") - if kwargs.pop("notavx", False): - self.misc_flags.add("NOT_AVX") - - # Operation size - self.opersize = kwargs.pop("opersize", 0) - if self.opersize == 8: - self.opersize = 0 - - if self.opersize == 64: - self.misc_flags.add("ONLY_64") - elif self.opersize == 32 and "ONLY_64" not in self.misc_flags: - self.cpu.add("386") - - # Default operation size in 64-bit mode - self.def_opersize_64 = kwargs.pop("def_opersize_64", 0) - - # GAS suffix - self.gen_suffix = kwargs.pop("gen_suffix", True) - self.suffixes = kwargs.pop("suffixes", None) - suffix = kwargs.pop("suffix", None) - if suffix is not None: - self.suffixes = [suffix] - - req_suffix = kwargs.pop("req_suffix", False) - if not req_suffix: - if self.suffixes is None: - self.suffixes = ["Z"] - else: - self.suffixes.append("Z") - - if self.suffixes is not None: - self.suffixes = set(x.upper() for x in self.suffixes) - - # Special instruction prefix - self.special_prefix = "0" - if "prefix" in kwargs: - self.special_prefix = "0x%02X" % kwargs.pop("prefix") - - # VEX prefix - if "vex" in kwargs: - self.misc_flags.add("ONLY_AVX") - vexW = kwargs.pop("vexw", 0) - if vexW not in [0, 1]: - raise ValueError("VEX.W must be 0 or 1") - - vexL = kwargs.pop("vex") - if vexL == 128 or vexL == 0: - vexL = 0 - elif vexL == 256: - vexL = 1 - else: - raise ValueError("VEX.L must be 128 or 256") - - if self.special_prefix in ["0", "0x00"]: - vexpp = 0 - elif self.special_prefix == "0x66": - vexpp = 1 - elif self.special_prefix == "0xF3": - vexpp = 2 - elif self.special_prefix == "0xF2": - vexpp = 3 - else: - raise ValueError("Cannot combine VEX and special prefix %s" - % self.special_prefix) - - self.special_prefix = "0x%02X" % (0xC0 + vexW*8 + vexL*4 + vexpp) - - # XOP prefix - if "xop" in kwargs: - xopW = kwargs.pop("xopw", 0) - if xopW not in [0, 1]: - raise ValueError("XOP.W must be 0 or 1") - - xopL = kwargs.pop("xop") - if xopL == 128 or xopL == 0: - xopL = 0 - elif xopL == 256: - xopL = 1 - else: - raise ValueError("XOP.L must be 128 or 256") - - # XOPpp is currently reserved (0) - xoppp = 0 - if self.special_prefix not in ["0", "0x00"]: - raise ValueError("Cannot combine XOP and special prefix %s" - % self.special_prefix) - self.special_prefix = "0x%02X" % (0x80 + xopW*8 + xopL*4 + xoppp) - - # Spare value - self.spare = kwargs.pop("spare", 0) - - # Build opcodes string (C array initializer) - if "opcode" in kwargs: - # Usual case, just a single opcode - self.opcode = kwargs.pop("opcode") - self.opcode_len = len(self.opcode) - elif "opcode1" in kwargs and "opcode2" in kwargs: - # Two opcode case; the first opcode is the "optimized" opcode, - # the second is the "relaxed" opcode. For this to work, an - # opt="foo" must be set for one of the operands. - self.opcode1 = kwargs.pop("opcode1") - self.opcode2 = kwargs.pop("opcode2") - self.opcode_len = len(self.opcode1) - else: - raise KeyError("missing opcode") - - # Build operands string (C array initializer) - self.operands = kwargs.pop("operands") - for op in self.operands: - if op.type in ["Reg", "RM", "Areg", "Creg", "Dreg"]: - if op.size == 64: - self.misc_flags.add("ONLY_64") - elif op.size == 32 and "ONLY_64" not in self.misc_flags: - self.cpu.add("386") - if op.type in ["Imm", "ImmNotSegOff"]: - if op.size == 64: - self.misc_flags.add("ONLY_64") - elif op.size == 32 and "ONLY_64" not in self.misc_flags: - self.cpu.add("386") - if op.type in ["FS", "GS"] and "ONLY_64" not in self.misc_flags: - self.cpu.add("386") - if op.type in ["CR4"] and "ONLY_64" not in self.misc_flags: - self.cpu.add("586") - if op.dest == "EA64": - self.misc_flags.add("ONLY_64") - - # Modifiers - self.modifiers = kwargs.pop("modifiers", []) - - # GAS flags - self.gas_only = ("nasm" not in self.parsers) - self.gas_illegal = ("gas" not in self.parsers) - self.gas_no_rev = (kwargs.pop("gas_no_reverse", False) or - kwargs.pop("gas_no_rev", False)) - - # CPU feature flags finalization - # Remove redundancies - maxcpu = -1 - maxcpu_set = self.cpu & set(ordered_cpus) - if maxcpu_set: - maxcpu = max(ordered_cpus.index(x) for x in maxcpu_set) - if maxcpu != -1: - for cpu in ordered_cpus[0:maxcpu]: - self.cpu.discard(cpu) - - if kwargs: - for arg in kwargs: - lprint("Warning: unrecognized arg %s" % arg) - - def __str__(self): - if hasattr(self, "opcode"): - opcodes_str = ["0x%02X" % x for x in self.opcode] - elif hasattr(self, "opcode1") and hasattr(self, "opcode2"): - opcodes_str = ["0x%02X" % x for x in self.opcode1] - opcodes_str.extend("0x%02X" % x for x in self.opcode2) - # Ensure opcodes initializer string is 3 long - opcodes_str.extend(["0", "0", "0"]) - opcodes_str = "{" + ', '.join(opcodes_str[0:3]) + "}" - - cpus_str = "|".join("CPU_%s" % x for x in sorted(self.cpu)) - - if len(self.modifiers) > 4: - raise ValueError("too many modifiers: %s" % (self.modifiers,)) - - cpus_str = [] - if self.cpu is not None: - if len(self.cpu) > 3: - raise ValueError("too many CPUs: %s" % (self.cpu,)) - - # Ensure CPUs initializer string is at least 3 long - cpus_str.extend("CPU_%s" % x for x in sorted(self.cpu)) - - # Ensure cpus initializer string is 3 long; 0=CPU_Any - cpus_str.extend(["0", "0", "0"]) - - - mods = ["MOD_%s" % x for x in self.modifiers] - # Ensure mods initializer string is 4 long - mods.extend(["0", "0", "0", "0"]) - mod_str = "{" + ', '.join(mods[0:4]) + "}" - - gas_flags = [] - if self.gas_only: - gas_flags.append("GAS_ONLY") - if self.gas_illegal: - gas_flags.append("GAS_ILLEGAL") - if self.gas_no_rev: - gas_flags.append("GAS_NO_REV") - if self.suffixes: - gas_flags.extend("SUF_%s" % x for x in sorted(self.suffixes)) - gas_flags = "|".join(gas_flags) - - # Build instruction info structure initializer - return "{ "+ ", ".join([gas_flags or "0", - "|".join(self.misc_flags) or "0", - cpus_str[0], - cpus_str[1], - cpus_str[2], - mod_str, - "%d" % (self.opersize or 0), - "%d" % (self.def_opersize_64 or 0), - self.special_prefix or "0", - "%d" % self.opcode_len, - opcodes_str, - "%d" % (self.spare or 0), - "%d" % len(self.operands), - "%d" % self.all_operands_index]) + " }" - -groups = {} -groupnames_ordered = [] -def add_group(name, **kwargs): - forms = groups.setdefault(name, []) - forms.append(GroupForm(**kwargs)) - groupnames_ordered.append(name) - -class Insn(object): - def __init__(self, groupname, suffix=None, parser=None, modifiers=None, - cpu=None, misc_flags=None, only64=False, not64=False, - avx=False): - self.groupname = groupname - if suffix is None: - self.suffix = None - else: - self.suffix = suffix.upper() - - self.parsers = None - if suffix is not None: - self.parsers = set(["gas"]) - if parser is not None: - self.parsers = set([parser]) - - if modifiers is None: - self.modifiers = [] - else: - self.modifiers = modifiers - if cpu is None: - self.cpu = None - else: - self.cpu = set(cpu) - - if misc_flags is None: - self.misc_flags = None - else: - self.misc_flags = set([x for x in misc_flags]) - - if only64: - if self.misc_flags is None: - self.misc_flags = set() - self.misc_flags.add("ONLY_64") - if not64: - if self.misc_flags is None: - self.misc_flags = set() - self.misc_flags.add("NOT_64") - if avx: - if self.misc_flags is None: - self.misc_flags = set() - self.misc_flags.add("ONLY_AVX") - if self.cpu is None: - self.cpu = set(["AVX"]) - - def auto_cpu(self, parser): - """Determine lowest common denominator CPU from group and suffix. - Does nothing if CPU is already set.""" - if self.cpu is not None: - return - # Scan through group, matching parser and suffix - for form in groups[self.groupname]: - if parser not in form.parsers: - continue - if (self.suffix is not None and len(self.suffix) == 1 and - (form.suffixes is None or self.suffix not in form.suffixes)): - continue - if self.cpu is None: - self.cpu = set(form.cpu) - else: - self.cpu = cpu_lcd(self.cpu, form.cpu) - - def auto_misc_flags(self, parser): - """Determine lowest common denominator flags from group and suffix. - Does nothing if flags is already set.""" - if self.misc_flags is not None: - return - # Scan through group, matching parser and suffix - for form in groups[self.groupname]: - if parser not in form.parsers: - continue - if (self.suffix is not None and len(self.suffix) == 1 and - (form.suffixes is None or self.suffix not in form.suffixes)): - continue - if self.misc_flags is None: - self.misc_flags = set(form.misc_flags) - else: - self.misc_flags &= form.misc_flags - - def copy(self): - """Return a shallow copy.""" - return Insn(self.groupname, - suffix=self.suffix, - modifiers=self.modifiers, - cpu=self.cpu, - misc_flags=self.misc_flags) - - def __str__(self): - if self.suffix is None: - suffix_str = "SUF_Z" - elif len(self.suffix) == 1: - suffix_str = "SUF_" + self.suffix - else: - suffix_str = self.suffix - - cpus_str = [] - if self.cpu is not None: - if len(self.cpu) > 3: - raise ValueError("too many CPUs: %s" % (self.cpu,)) - cpus_str.extend("CPU_%s" % x for x in sorted(self.cpu)) - - # Ensure cpus initializer string is 3 long - cpus_str.extend(["0", "0", "0"]) - - if len(self.modifiers) > 4: - raise ValueError("too many modifiers") - mods_str = ["0x%02X" % x for x in self.modifiers] - - # Ensure modifiers is at least 4 long - mods_str.extend(["0", "0", "0", "0"]) - - return ",\t".join(["%s_insn" % self.groupname, - "%d" % len(groups[self.groupname]), - suffix_str, - mods_str[0], - mods_str[1], - mods_str[2], - "|".join(self.misc_flags or []) or "0", - cpus_str[0], - cpus_str[1], - cpus_str[2]]) - -insns = {} -def add_insn(name, groupname, **kwargs): - opts = insns.setdefault(name, []) - opts.append(Insn(groupname, **kwargs)) - -class Prefix(object): - def __init__(self, groupname, value, only64=False): - self.groupname = groupname - self.value = value - self.only64 = only64 - - def __str__(self): - return ",\t".join(["NULL", - "X86_%s>>8" % self.groupname, - "0x%02X" % self.value, - "0", - "0", - "0", - self.only64 and "ONLY_64" or "0", - "0", - "0", - "0"]) - -gas_insns = {} -nasm_insns = {} - -def add_prefix(name, groupname, value, parser=None, **kwargs): - prefix = Prefix(groupname, value, **kwargs) - if parser is None or parser == "gas": - gas_insns[name] = prefix - if parser is None or parser == "nasm": - nasm_insns[name] = prefix - -def finalize_insns(): - unused_groups = set(groups.keys()) - for name in insns: - for insn in insns[name]: - group = groups[insn.groupname] - unused_groups.discard(insn.groupname) - - parsers = set() - for form in group: - parsers |= form.parsers - if insn.parsers is not None: - parsers &= insn.parsers - - if "gas" in parsers: - suffixes = set() - if insn.suffix is None: - for form in group: - if form.gen_suffix and form.suffixes is not None: - suffixes |= form.suffixes - - if not suffixes: - suffixes.add("Z") - for suffix in suffixes: - if suffix == "Z": - keyword = name - else: - keyword = name+suffix - keyword = keyword.lower() - if keyword in gas_insns: - raise ValueError("duplicate gas instruction %s" % - keyword) - newinsn = insn.copy() - if insn.suffix is None: - newinsn.suffix = suffix - newinsn.auto_cpu("gas") - newinsn.auto_misc_flags("gas") - gas_insns[keyword] = newinsn - - if "nasm" in parsers: - keyword = name - if keyword in nasm_insns: - raise ValueError("duplicate nasm instruction %s" % keyword) - newinsn = insn.copy() - newinsn.auto_cpu("nasm") - newinsn.auto_misc_flags("nasm") - nasm_insns[keyword] = newinsn - - unused_groups.discard("empty") - unused_groups.discard("not64") - if unused_groups: - lprint("warning: unused groups: %s" % ", ".join(unused_groups)) - -def output_insns(f, parser, insns): - lprint("/* Generated by %s r%s, do not edit */" % \ - (scriptname, scriptrev), f) - lprint("""%%ignore-case -%%language=ANSI-C -%%compare-strncmp -%%readonly-tables -%%enum -%%struct-type -%%define hash-function-name insnprefix_%s_hash -%%define lookup-function-name insnprefix_%s_find -struct insnprefix_parse_data; -%%%%""" % (parser, parser), f) - for keyword in sorted(insns): - lprint("%s,\t%s" % (keyword.lower(), insns[keyword]), f) - -def output_gas_insns(f): - output_insns(f, "gas", gas_insns) - -def output_nasm_insns(f): - output_insns(f, "nasm", nasm_insns) - -def output_groups(f): - # Merge all operand lists into single list - # Sort by number of operands to shorten output - all_operands = [] - if version_info[0] == 2: - gi = groups.itervalues() - else: - gi = groups.values() - for form in sorted((form for g in gi for form in g), - key=lambda x:len(x.operands), reverse=True): - num_operands = len(form.operands) - for i in range(len(all_operands)): - if all_operands[i:i+num_operands] == form.operands: - form.all_operands_index = i - break - else: - form.all_operands_index = len(all_operands) - all_operands.extend(form.operands) - - # Output operands list - lprint("/* Generated by %s r%s, do not edit */" % \ - (scriptname, scriptrev), f) - lprint("static const x86_info_operand insn_operands[] = {", f) - lprint(" ", f, '') - lprint(",\n ".join(str(x) for x in all_operands), f) - lprint("};\n", f) - - # Output groups - seen = set() - for name in groupnames_ordered: - if name in seen: - continue - seen.add(name) - lprint("static const x86_insn_info %s_insn[] = {" % name, f) - lprint(" ", f, '') - lprint(",\n ".join(str(x) for x in groups[name]), f) - lprint("};\n", f) - -##################################################################### -# General instruction groupings -##################################################################### - -# -# Empty instruction -# -add_group("empty", opcode=[], operands=[]) - -# -# Placeholder for instructions invalid in 64-bit mode -# -add_group("not64", opcode=[], operands=[], not64=True) - -# -# One byte opcode instructions with no operands -# -add_group("onebyte", - modifiers=["Op0Add", "OpSizeR", "DOpS64R"], - opcode=[0x00], - operands=[]) - -# -# One byte opcode instructions with "special" prefix with no operands -# -add_group("onebyte_prefix", - modifiers=["PreAdd", "Op0Add"], - prefix=0x00, - opcode=[0x00], - operands=[]) - -# -# Two byte opcode instructions with no operands -# -add_group("twobyte", - gen_suffix=False, - suffixes=["l", "q"], - modifiers=["Op0Add", "Op1Add"], - opcode=[0x00, 0x00], - operands=[]) - -# -# Three byte opcode instructions with no operands -# -add_group("threebyte", - modifiers=["Op0Add", "Op1Add", "Op2Add"], - opcode=[0x00, 0x00, 0x00], - operands=[]) - -# -# Four byte opcode instructions with no operands -# -add_group("fourbyte", - modifiers=["Op0Add", "Op1Add", "Op2Add", "Op3Add"], - opcode=[0x00, 0x00, 0x00, 0x00], - operands=[]) - -# -# One byte opcode instructions with general memory operand -# -add_group("onebytemem", - gen_suffix=False, - suffixes=["l", "q", "s"], - modifiers=["SpAdd", "Op0Add"], - opcode=[0x00], - spare=0, - operands=[Operand(type="Mem", dest="EA")]) - -# -# Two byte opcode instructions with general memory operand -# -add_group("twobytemem", - gen_suffix=False, - suffixes=["w", "l", "q", "s"], - modifiers=["SpAdd", "Op0Add", "Op1Add"], - opcode=[0x00, 0x00], - spare=0, - operands=[Operand(type="Mem", relaxed=True, dest="EA")]) - -# -# mov -# - -# Absolute forms for non-64-bit mode -for sfx, sz in zip("bwl", [8, 16, 32]): - add_group("mov", - suffix=sfx, - not64=True, - opersize=sz, - opcode=[0xA0+(sz!=8)], - operands=[Operand(type="Areg", size=sz, dest=None), - Operand(type="MemOffs", size=sz, relaxed=True, dest="EA")]) - -for sfx, sz in zip("bwl", [8, 16, 32]): - add_group("mov", - suffix=sfx, - not64=True, - opersize=sz, - opcode=[0xA2+(sz!=8)], - operands=[Operand(type="MemOffs", size=sz, relaxed=True, dest="EA"), - Operand(type="Areg", size=sz, dest=None)]) - -# 64-bit absolute forms for 64-bit mode. Disabled for GAS, see movabs -for sz in (8, 16, 32, 64): - add_group("mov", - opersize=sz, - opcode=[0xA0+(sz!=8)], - only64=True, - operands=[Operand(type="Areg", size=sz, dest=None), - Operand(type="MemOffs", size=sz, relaxed=True, dest="EA64")]) - -for sz in (8, 16, 32, 64): - add_group("mov", - only64=True, - opersize=sz, - opcode=[0xA2+(sz!=8)], - operands=[Operand(type="MemOffs", size=sz, relaxed=True, dest="EA64"), - Operand(type="Areg", size=sz, dest=None)]) - -# General 32-bit forms using Areg / short absolute option -for sfx, sz in zip("bwlq", [8, 16, 32, 64]): - add_group("mov", - suffix=sfx, - opersize=sz, - opcode1=[0x88+(sz!=8)], - opcode2=[0xA2+(sz!=8)], - operands=[ - Operand(type="RM", size=sz, relaxed=True, dest="EA", opt="ShortMov"), - Operand(type="Areg", size=sz, dest="Spare")]) - -# General 32-bit forms -for sfx, sz in zip("bwlq", [8, 16, 32, 64]): - add_group("mov", - suffix=sfx, - opersize=sz, - opcode=[0x88+(sz!=8)], - operands=[Operand(type="RM", size=sz, relaxed=True, dest="EA"), - Operand(type="Reg", size=sz, dest="Spare")]) - -# General 32-bit forms using Areg / short absolute option -for sfx, sz in zip("bwlq", [8, 16, 32, 64]): - add_group("mov", - suffix=sfx, - opersize=sz, - opcode1=[0x8A+(sz!=8)], - opcode2=[0xA0+(sz!=8)], - operands=[Operand(type="Areg", size=sz, dest="Spare"), - Operand(type="RM", size=sz, relaxed=True, dest="EA", - opt="ShortMov")]) - -# General 32-bit forms -for sfx, sz in zip("bwlq", [8, 16, 32, 64]): - add_group("mov", - suffix=sfx, - opersize=sz, - opcode=[0x8A+(sz!=8)], - operands=[Operand(type="Reg", size=sz, dest="Spare"), - Operand(type="RM", size=sz, relaxed=True, dest="EA")]) - -# Segment register forms -add_group("mov", - suffix="w", - opcode=[0x8C], - operands=[Operand(type="Mem", size=16, relaxed=True, dest="EA"), - Operand(type="SegReg", size=16, relaxed=True, dest="Spare")]) -for sfx, sz in zip("wlq", [16, 32, 64]): - add_group("mov", - suffix=sfx, - opersize=sz, - opcode=[0x8C], - operands=[ - Operand(type="Reg", size=sz, dest="EA"), - Operand(type="SegReg", size=16, relaxed=True, dest="Spare")]) -add_group("mov", - suffix="w", - opcode=[0x8E], - operands=[Operand(type="SegReg", size=16, relaxed=True, dest="Spare"), - Operand(type="RM", size=16, relaxed=True, dest="EA")]) -for sfx, sz in zip("lq", [32, 64]): - add_group("mov", - suffix=sfx, - opcode=[0x8E], - operands=[ - Operand(type="SegReg", size=16, relaxed=True, dest="Spare"), - Operand(type="Reg", size=sz, dest="EA")]) - -# Immediate forms -add_group("mov", - suffix="b", - opcode=[0xB0], - operands=[Operand(type="Reg", size=8, dest="Op0Add"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) -for sfx, sz in zip("wl", [16, 32]): - add_group("mov", - suffix=sfx, - opersize=sz, - opcode=[0xB8], - operands=[Operand(type="Reg", size=sz, dest="Op0Add"), - Operand(type="Imm", size=sz, relaxed=True, dest="Imm")]) -# 64-bit forced size form -add_group("mov", - parsers=["nasm"], - opersize=64, - opcode=[0xB8], - operands=[Operand(type="Reg", size=64, dest="Op0Add"), - Operand(type="Imm", size=64, dest="Imm")]) -add_group("mov", - suffix="q", - opersize=64, - opcode1=[0xB8], - opcode2=[0xC7], - operands=[Operand(type="Reg", size=64, dest="Op0Add"), - Operand(type="Imm", size=64, relaxed=True, dest="Imm", - opt="SImm32Avail")]) -# Need two sets here, one for strictness on left side, one for right. -for sfx, sz, immsz in zip("bwlq", [8, 16, 32, 64], [8, 16, 32, 32]): - add_group("mov", - suffix=sfx, - opersize=sz, - opcode=[0xC6+(sz!=8)], - operands=[Operand(type="RM", size=sz, relaxed=True, dest="EA"), - Operand(type="Imm", size=immsz, dest="Imm")]) -for sfx, sz, immsz in zip("bwlq", [8, 16, 32, 64], [8, 16, 32, 32]): - add_group("mov", - suffix=sfx, - opersize=sz, - opcode=[0xC6+(sz!=8)], - operands=[Operand(type="RM", size=sz, dest="EA"), - Operand(type="Imm", size=immsz, relaxed=True, dest="Imm")]) - -# CR forms -add_group("mov", - suffix="l", - not64=True, - cpu=["Priv"], - opcode=[0x0F, 0x22], - operands=[Operand(type="CR4", size=32, dest="Spare"), - Operand(type="Reg", size=32, dest="EA")]) -add_group("mov", - suffix="l", - not64=True, - cpu=["Priv"], - opcode=[0x0F, 0x22], - operands=[Operand(type="CRReg", size=32, dest="Spare"), - Operand(type="Reg", size=32, dest="EA")]) -add_group("mov", - suffix="q", - cpu=["Priv"], - opcode=[0x0F, 0x22], - operands=[Operand(type="CRReg", size=32, dest="Spare"), - Operand(type="Reg", size=64, dest="EA")]) -add_group("mov", - suffix="l", - not64=True, - cpu=["Priv"], - opcode=[0x0F, 0x20], - operands=[Operand(type="Reg", size=32, dest="EA"), - Operand(type="CR4", size=32, dest="Spare")]) -add_group("mov", - suffix="l", - cpu=["Priv"], - not64=True, - opcode=[0x0F, 0x20], - operands=[Operand(type="Reg", size=32, dest="EA"), - Operand(type="CRReg", size=32, dest="Spare")]) -add_group("mov", - suffix="q", - cpu=["Priv"], - opcode=[0x0F, 0x20], - operands=[Operand(type="Reg", size=64, dest="EA"), - Operand(type="CRReg", size=32, dest="Spare")]) - -# DR forms -add_group("mov", - suffix="l", - not64=True, - cpu=["Priv"], - opcode=[0x0F, 0x23], - operands=[Operand(type="DRReg", size=32, dest="Spare"), - Operand(type="Reg", size=32, dest="EA")]) -add_group("mov", - suffix="q", - cpu=["Priv"], - opcode=[0x0F, 0x23], - operands=[Operand(type="DRReg", size=32, dest="Spare"), - Operand(type="Reg", size=64, dest="EA")]) -add_group("mov", - suffix="l", - not64=True, - cpu=["Priv"], - opcode=[0x0F, 0x21], - operands=[Operand(type="Reg", size=32, dest="EA"), - Operand(type="DRReg", size=32, dest="Spare")]) -add_group("mov", - suffix="q", - cpu=["Priv"], - opcode=[0x0F, 0x21], - operands=[Operand(type="Reg", size=64, dest="EA"), - Operand(type="DRReg", size=32, dest="Spare")]) - -# MMX forms for GAS parser (copied from movq) -add_group("mov", - suffix="q", - cpu=["MMX"], - parsers=["gas"], - opcode=[0x0F, 0x6F], - operands=[Operand(type="SIMDReg", size=64, dest="Spare"), - Operand(type="SIMDRM", size=64, relaxed=True, dest="EA")]) -add_group("mov", - suffix="q", - cpu=["MMX"], - parsers=["gas"], - opersize=64, - opcode=[0x0F, 0x6E], - operands=[Operand(type="SIMDReg", size=64, dest="Spare"), - Operand(type="RM", size=64, relaxed=True, dest="EA")]) -add_group("mov", - suffix="q", - cpu=["MMX"], - parsers=["gas"], - opcode=[0x0F, 0x7F], - operands=[Operand(type="SIMDRM", size=64, relaxed=True, dest="EA"), - Operand(type="SIMDReg", size=64, dest="Spare")]) -add_group("mov", - suffix="q", - cpu=["MMX"], - parsers=["gas"], - opersize=64, - opcode=[0x0F, 0x7E], - operands=[Operand(type="RM", size=64, relaxed=True, dest="EA"), - Operand(type="SIMDReg", size=64, dest="Spare")]) - -# SSE2 forms for GAS parser (copied from movq) -add_group("mov", - suffix="q", - cpu=["SSE2"], - parsers=["gas"], - prefix=0xF3, - opcode=[0x0F, 0x7E], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="EA")]) -add_group("mov", - suffix="q", - cpu=["SSE2"], - parsers=["gas"], - prefix=0xF3, - opcode=[0x0F, 0x7E], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDRM", size=64, relaxed=True, dest="EA")]) -add_group("mov", - suffix="q", - cpu=["SSE2"], - parsers=["gas"], - opersize=64, - prefix=0x66, - opcode=[0x0F, 0x6E], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="RM", size=64, relaxed=True, dest="EA")]) -add_group("mov", - suffix="q", - cpu=["SSE2"], - parsers=["gas"], - prefix=0x66, - opcode=[0x0F, 0xD6], - operands=[Operand(type="SIMDRM", size=64, relaxed=True, dest="EA"), - Operand(type="SIMDReg", size=128, dest="Spare")]) -add_group("mov", - suffix="q", - cpu=["SSE2"], - parsers=["gas"], - opersize=64, - prefix=0x66, - opcode=[0x0F, 0x7E], - operands=[Operand(type="RM", size=64, relaxed=True, dest="EA"), - Operand(type="SIMDReg", size=128, dest="Spare")]) - -add_insn("mov", "mov") - -# -# 64-bit absolute move (for GAS). -# These are disabled for GAS for normal mov above. -# -add_group("movabs", - suffix="b", - only64=True, - opcode=[0xA0], - operands=[Operand(type="Areg", size=8, dest=None), - Operand(type="MemOffs", size=8, relaxed=True, dest="EA64")]) -for sfx, sz in zip("wlq", [16, 32, 64]): - add_group("movabs", - only64=True, - suffix=sfx, - opersize=sz, - opcode=[0xA1], - operands=[Operand(type="Areg", size=sz, dest=None), - Operand(type="MemOffs", size=sz, relaxed=True, - dest="EA64")]) - -add_group("movabs", - suffix="b", - only64=True, - opcode=[0xA2], - operands=[Operand(type="MemOffs", size=8, relaxed=True, dest="EA64"), - Operand(type="Areg", size=8, dest=None)]) -for sfx, sz in zip("wlq", [16, 32, 64]): - add_group("movabs", - suffix=sfx, - only64=True, - opersize=sz, - opcode=[0xA3], - operands=[Operand(type="MemOffs", size=sz, relaxed=True, - dest="EA64"), - Operand(type="Areg", size=sz, dest=None)]) - -# 64-bit immediate form -add_group("movabs", - suffix="q", - opersize=64, - opcode=[0xB8], - operands=[Operand(type="Reg", size=64, dest="Op0Add"), - Operand(type="Imm", size=64, relaxed=True, dest="Imm")]) - -add_insn("movabs", "movabs", parser="gas") - -# -# Move with sign/zero extend -# -add_group("movszx", - suffix="b", - cpu=["386"], - modifiers=["Op1Add"], - opersize=16, - opcode=[0x0F, 0x00], - operands=[Operand(type="Reg", size=16, dest="Spare"), - Operand(type="RM", size=8, relaxed=True, dest="EA")]) -add_group("movszx", - suffix="b", - cpu=["386"], - modifiers=["Op1Add"], - opersize=32, - opcode=[0x0F, 0x00], - operands=[Operand(type="Reg", size=32, dest="Spare"), - Operand(type="RM", size=8, dest="EA")]) -add_group("movszx", - suffix="b", - modifiers=["Op1Add"], - opersize=64, - opcode=[0x0F, 0x00], - operands=[Operand(type="Reg", size=64, dest="Spare"), - Operand(type="RM", size=8, dest="EA")]) -add_group("movszx", - suffix="w", - cpu=["386"], - modifiers=["Op1Add"], - opersize=32, - opcode=[0x0F, 0x01], - operands=[Operand(type="Reg", size=32, dest="Spare"), - Operand(type="RM", size=16, dest="EA")]) -add_group("movszx", - suffix="w", - modifiers=["Op1Add"], - opersize=64, - opcode=[0x0F, 0x01], - operands=[Operand(type="Reg", size=64, dest="Spare"), - Operand(type="RM", size=16, dest="EA")]) - -add_insn("movsbw", "movszx", suffix="b", modifiers=[0xBE]) -add_insn("movsbl", "movszx", suffix="b", modifiers=[0xBE]) -add_insn("movswl", "movszx", suffix="w", modifiers=[0xBE]) -add_insn("movsbq", "movszx", suffix="b", modifiers=[0xBE], only64=True) -add_insn("movswq", "movszx", suffix="w", modifiers=[0xBE], only64=True) -add_insn("movsx", "movszx", modifiers=[0xBE]) -add_insn("movzbw", "movszx", suffix="b", modifiers=[0xB6]) -add_insn("movzbl", "movszx", suffix="b", modifiers=[0xB6]) -add_insn("movzwl", "movszx", suffix="w", modifiers=[0xB6]) -add_insn("movzbq", "movszx", suffix="b", modifiers=[0xB6], only64=True) -add_insn("movzwq", "movszx", suffix="w", modifiers=[0xB6], only64=True) -add_insn("movzx", "movszx", modifiers=[0xB6]) - -# -# Move with sign-extend doubleword (64-bit mode only) -# -add_group("movsxd", - suffix="l", - opersize=64, - opcode=[0x63], - operands=[Operand(type="Reg", size=64, dest="Spare"), - Operand(type="RM", size=32, dest="EA")]) - -add_insn("movslq", "movsxd", suffix="l") -add_insn("movsxd", "movsxd", parser="nasm") - -# -# Push instructions -# -add_group("push", - def_opersize_64=64, - opcode=[0x50], - operands=[Operand(type="Reg", size="BITS", dest="Op0Add")]) -add_group("push", - suffix="w", - opersize=16, - def_opersize_64=64, - opcode=[0x50], - operands=[Operand(type="Reg", size=16, dest="Op0Add")]) -add_group("push", - suffix="l", - not64=True, - opersize=32, - opcode=[0x50], - operands=[Operand(type="Reg", size=32, dest="Op0Add")]) -add_group("push", - suffix="q", - only64=True, - def_opersize_64=64, - opcode=[0x50], - operands=[Operand(type="Reg", size=64, dest="Op0Add")]) - -add_group("push", - def_opersize_64=64, - opcode=[0xFF], - spare=6, - operands=[Operand(type="RM", size="BITS", dest="EA")]) -add_group("push", - suffix="w", - opersize=16, - def_opersize_64=64, - opcode=[0xFF], - spare=6, - operands=[Operand(type="RM", size=16, dest="EA")]) -add_group("push", - suffix="l", - not64=True, - opersize=32, - opcode=[0xFF], - spare=6, - operands=[Operand(type="RM", size=32, dest="EA")]) -add_group("push", - suffix="q", - only64=True, - def_opersize_64=64, - opcode=[0xFF], - spare=6, - operands=[Operand(type="RM", size=64, dest="EA")]) - -add_group("push", - cpu=["186"], - parsers=["nasm"], - def_opersize_64=64, - opcode=[0x6A], - operands=[Operand(type="Imm", size=8, dest="SImm")]) -add_group("push", - cpu=["186"], - parsers=["gas"], - def_opersize_64=64, - opcode=[0x6A], - operands=[Operand(type="Imm", size=8, relaxed=True, dest="SImm")]) -add_group("push", - suffix="q", - only64=True, - opersize=64, - def_opersize_64=64, - opcode1=[0x6A], - opcode2=[0x68], - operands=[Operand(type="Imm", size=32, relaxed=True, dest="SImm", - opt="SImm8")]) -add_group("push", - not64=True, - cpu=["186"], - parsers=["nasm"], - opcode1=[0x6A], - opcode2=[0x68], - operands=[Operand(type="Imm", size="BITS", relaxed=True, dest="Imm", - opt="SImm8")]) -add_group("push", - suffix="w", - cpu=["186"], - opersize=16, - def_opersize_64=64, - opcode1=[0x6A], - opcode2=[0x68], - operands=[Operand(type="Imm", size=16, relaxed=True, dest="Imm", - opt="SImm8")]) -add_group("push", - suffix="l", - not64=True, - opersize=32, - opcode1=[0x6A], - opcode2=[0x68], - operands=[Operand(type="Imm", size=32, relaxed=True, dest="Imm", - opt="SImm8")]) -# Need these when we don't match the BITS size, but they need to be -# below the above line so the optimizer can kick in by default. -add_group("push", - cpu=["186"], - parsers=["nasm"], - opersize=16, - def_opersize_64=64, - opcode=[0x68], - operands=[Operand(type="Imm", size=16, dest="Imm")]) -add_group("push", - not64=True, - parsers=["nasm"], - opersize=32, - opcode=[0x68], - operands=[Operand(type="Imm", size=32, dest="Imm")]) -add_group("push", - only64=True, - parsers=["nasm"], - opersize=64, - def_opersize_64=64, - opcode=[0x68], - operands=[Operand(type="Imm", size=32, dest="SImm")]) -add_group("push", - not64=True, - opcode=[0x0E], - operands=[Operand(type="CS", dest=None)]) -add_group("push", - suffix="w", - not64=True, - opersize=16, - opcode=[0x0E], - operands=[Operand(type="CS", size=16, dest=None)]) -add_group("push", - suffix="l", - not64=True, - opersize=32, - opcode=[0x0E], - operands=[Operand(type="CS", size=32, dest=None)]) -add_group("push", - not64=True, - opcode=[0x16], - operands=[Operand(type="SS", dest=None)]) -add_group("push", - suffix="w", - not64=True, - opersize=16, - opcode=[0x16], - operands=[Operand(type="SS", size=16, dest=None)]) -add_group("push", - suffix="l", - not64=True, - opersize=32, - opcode=[0x16], - operands=[Operand(type="SS", size=32, dest=None)]) -add_group("push", - not64=True, - opcode=[0x1E], - operands=[Operand(type="DS", dest=None)]) -add_group("push", - suffix="w", - not64=True, - opersize=16, - opcode=[0x1E], - operands=[Operand(type="DS", size=16, dest=None)]) -add_group("push", - suffix="l", - not64=True, - opersize=32, - opcode=[0x1E], - operands=[Operand(type="DS", size=32, dest=None)]) -add_group("push", - not64=True, - opcode=[0x06], - operands=[Operand(type="ES", dest=None)]) -add_group("push", - suffix="w", - not64=True, - opersize=16, - opcode=[0x06], - operands=[Operand(type="ES", size=16, dest=None)]) -add_group("push", - suffix="l", - not64=True, - opersize=32, - opcode=[0x06], - operands=[Operand(type="ES", size=32, dest=None)]) -add_group("push", - opcode=[0x0F, 0xA0], - operands=[Operand(type="FS", dest=None)]) -add_group("push", - suffix="w", - opersize=16, - opcode=[0x0F, 0xA0], - operands=[Operand(type="FS", size=16, dest=None)]) -add_group("push", - suffix="l", - opersize=32, - opcode=[0x0F, 0xA0], - operands=[Operand(type="FS", size=32, dest=None)]) -add_group("push", - opcode=[0x0F, 0xA8], - operands=[Operand(type="GS", dest=None)]) -add_group("push", - suffix="w", - opersize=16, - opcode=[0x0F, 0xA8], - operands=[Operand(type="GS", size=16, dest=None)]) -add_group("push", - suffix="l", - opersize=32, - opcode=[0x0F, 0xA8], - operands=[Operand(type="GS", size=32, dest=None)]) - -add_insn("push", "push") -add_insn("pusha", "onebyte", modifiers=[0x60, 0], cpu=["186"], not64=True) -add_insn("pushad", "onebyte", parser="nasm", modifiers=[0x60, 32], - cpu=["386"], not64=True) -add_insn("pushal", "onebyte", parser="gas", modifiers=[0x60, 32], - cpu=["386"], not64=True) -add_insn("pushaw", "onebyte", modifiers=[0x60, 16], cpu=["186"], not64=True) - -# -# Pop instructions -# -add_group("pop", - def_opersize_64=64, - opcode=[0x58], - operands=[Operand(type="Reg", size="BITS", dest="Op0Add")]) -add_group("pop", - suffix="w", - opersize=16, - def_opersize_64=64, - opcode=[0x58], - operands=[Operand(type="Reg", size=16, dest="Op0Add")]) -add_group("pop", - suffix="l", - not64=True, - opersize=32, - opcode=[0x58], - operands=[Operand(type="Reg", size=32, dest="Op0Add")]) -add_group("pop", - suffix="q", - only64=True, - def_opersize_64=64, - opcode=[0x58], - operands=[Operand(type="Reg", size=64, dest="Op0Add")]) - -add_group("pop", - def_opersize_64=64, - opcode=[0x8F], - operands=[Operand(type="RM", size="BITS", dest="EA")]) -add_group("pop", - suffix="w", - opersize=16, - def_opersize_64=64, - opcode=[0x8F], - operands=[Operand(type="RM", size=16, dest="EA")]) -add_group("pop", - suffix="l", - not64=True, - opersize=32, - opcode=[0x8F], - operands=[Operand(type="RM", size=32, dest="EA")]) -add_group("pop", - suffix="q", - only64=True, - def_opersize_64=64, - opcode=[0x8F], - operands=[Operand(type="RM", size=64, dest="EA")]) - -# POP CS is debateably valid on the 8086, if obsolete and undocumented. -# We don't include it because it's VERY unlikely it will ever be used -# anywhere. If someone really wants it they can db 0x0F it. -#add_group("pop", -# cpu=["Undoc", "Obs"], -# opcode=[0x0F], -# operands=[Operand(type="CS", dest=None)]) -add_group("pop", - not64=True, - opcode=[0x17], - operands=[Operand(type="SS", dest=None)]) -add_group("pop", - not64=True, - opersize=16, - opcode=[0x17], - operands=[Operand(type="SS", size=16, dest=None)]) -add_group("pop", - not64=True, - opersize=32, - opcode=[0x17], - operands=[Operand(type="SS", size=32, dest=None)]) -add_group("pop", - not64=True, - opcode=[0x1F], - operands=[Operand(type="DS", dest=None)]) -add_group("pop", - not64=True, - opersize=16, - opcode=[0x1F], - operands=[Operand(type="DS", size=16, dest=None)]) -add_group("pop", - not64=True, - opersize=32, - opcode=[0x1F], - operands=[Operand(type="DS", size=32, dest=None)]) -add_group("pop", - not64=True, - opcode=[0x07], - operands=[Operand(type="ES", dest=None)]) -add_group("pop", - not64=True, - opersize=16, - opcode=[0x07], - operands=[Operand(type="ES", size=16, dest=None)]) -add_group("pop", - not64=True, - opersize=32, - opcode=[0x07], - operands=[Operand(type="ES", size=32, dest=None)]) -add_group("pop", - opcode=[0x0F, 0xA1], - operands=[Operand(type="FS", dest=None)]) -add_group("pop", - opersize=16, - opcode=[0x0F, 0xA1], - operands=[Operand(type="FS", size=16, dest=None)]) -add_group("pop", - opersize=32, - opcode=[0x0F, 0xA1], - operands=[Operand(type="FS", size=32, dest=None)]) -add_group("pop", - opcode=[0x0F, 0xA9], - operands=[Operand(type="GS", dest=None)]) -add_group("pop", - opersize=16, - opcode=[0x0F, 0xA9], - operands=[Operand(type="GS", size=16, dest=None)]) -add_group("pop", - opersize=32, - opcode=[0x0F, 0xA9], - operands=[Operand(type="GS", size=32, dest=None)]) - -add_insn("pop", "pop") -add_insn("popa", "onebyte", modifiers=[0x61, 0], cpu=["186"], not64=True) -add_insn("popad", "onebyte", parser="nasm", modifiers=[0x61, 32], - cpu=["386"], not64=True) -add_insn("popal", "onebyte", parser="gas", modifiers=[0x61, 32], - cpu=["386"], not64=True) -add_insn("popaw", "onebyte", modifiers=[0x61, 16], cpu=["186"], not64=True) - -# -# Exchange instructions -# -add_group("xchg", - suffix="b", - opcode=[0x86], - operands=[Operand(type="RM", size=8, relaxed=True, dest="EA"), - Operand(type="Reg", size=8, dest="Spare")]) -add_group("xchg", - suffix="b", - opcode=[0x86], - operands=[Operand(type="Reg", size=8, dest="Spare"), - Operand(type="RM", size=8, relaxed=True, dest="EA")]) -# We could be extra-efficient in the 64-bit mode case here. -# XCHG AX, AX in 64-bit mode is a NOP, as it doesn't clear the -# high 48 bits of RAX. Thus we don't need the operand-size prefix. -# But this feels too clever, and probably not what the user really -# expects in the generated code, so we don't do it. -#add_group("xchg", -# suffix="w", -# only64=True, -# opcode=[0x90], -# operands=[Operand(type="Areg", size=16, dest=None), -# Operand(type="AReg", size=16, dest="Op0Add")]) -add_group("xchg", - suffix="w", - opersize=16, - opcode=[0x90], - operands=[Operand(type="Areg", size=16, dest=None), - Operand(type="Reg", size=16, dest="Op0Add")]) -add_group("xchg", - suffix="w", - opersize=16, - opcode=[0x90], - operands=[Operand(type="Reg", size=16, dest="Op0Add"), - Operand(type="Areg", size=16, dest=None)]) -add_group("xchg", - suffix="w", - opersize=16, - opcode=[0x87], - operands=[Operand(type="RM", size=16, relaxed=True, dest="EA"), - Operand(type="Reg", size=16, dest="Spare")]) -add_group("xchg", - suffix="w", - opersize=16, - opcode=[0x87], - operands=[Operand(type="Reg", size=16, dest="Spare"), - Operand(type="RM", size=16, relaxed=True, dest="EA")]) -# Be careful with XCHG EAX, EAX in 64-bit mode. This needs to use -# the long form rather than the NOP form, as the long form clears -# the high 32 bits of RAX. This makes all 32-bit forms in 64-bit -# mode have consistent operation. -# -# FIXME: due to a hard-to-fix bug in how we handle generating gas suffix CPU -# rules, this causes xchgl to be CPU_Any instead of CPU_386. A hacky patch -# could fix it, but it's doubtful anyone will ever notice, so leave it. -add_group("xchg", - suffix="l", - only64=True, - opersize=32, - opcode=[0x87], - operands=[Operand(type="Areg", size=32, dest="EA"), - Operand(type="Areg", size=32, dest="Spare")]) -add_group("xchg", - suffix="l", - opersize=32, - opcode=[0x90], - operands=[Operand(type="Areg", size=32, dest=None), - Operand(type="Reg", size=32, dest="Op0Add")]) -add_group("xchg", - suffix="l", - opersize=32, - opcode=[0x90], - operands=[Operand(type="Reg", size=32, dest="Op0Add"), - Operand(type="Areg", size=32, dest=None)]) -add_group("xchg", - suffix="l", - opersize=32, - opcode=[0x87], - operands=[Operand(type="RM", size=32, relaxed=True, dest="EA"), - Operand(type="Reg", size=32, dest="Spare")]) -add_group("xchg", - suffix="l", - opersize=32, - opcode=[0x87], - operands=[Operand(type="Reg", size=32, dest="Spare"), - Operand(type="RM", size=32, relaxed=True, dest="EA")]) -# Be efficient with XCHG RAX, RAX. -# This is a NOP and thus doesn't need the REX prefix. -add_group("xchg", - suffix="q", - only64=True, - opcode=[0x90], - operands=[Operand(type="Areg", size=64, dest=None), - Operand(type="Areg", size=64, dest="Op0Add")]) -add_group("xchg", - suffix="q", - opersize=64, - opcode=[0x90], - operands=[Operand(type="Areg", size=64, dest=None), - Operand(type="Reg", size=64, dest="Op0Add")]) -add_group("xchg", - suffix="q", - opersize=64, - opcode=[0x90], - operands=[Operand(type="Reg", size=64, dest="Op0Add"), - Operand(type="Areg", size=64, dest=None)]) -add_group("xchg", - suffix="q", - opersize=64, - opcode=[0x87], - operands=[Operand(type="RM", size=64, relaxed=True, dest="EA"), - Operand(type="Reg", size=64, dest="Spare")]) -add_group("xchg", - suffix="q", - opersize=64, - opcode=[0x87], - operands=[Operand(type="Reg", size=64, dest="Spare"), - Operand(type="RM", size=64, relaxed=True, dest="EA")]) - -add_insn("xchg", "xchg") - -##################################################################### -# In/out from ports -##################################################################### -add_group("in", - suffix="b", - opcode=[0xE4], - operands=[Operand(type="Areg", size=8, dest=None), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) -for sfx, sz in zip("wl", [16, 32]): - add_group("in", - suffix=sfx, - opersize=sz, - opcode=[0xE5], - operands=[Operand(type="Areg", size=sz, dest=None), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) -add_group("in", - suffix="b", - opcode=[0xEC], - operands=[Operand(type="Areg", size=8, dest=None), - Operand(type="Dreg", size=16, dest=None)]) -for sfx, sz in zip("wl", [16, 32]): - add_group("in", - suffix=sfx, - opersize=sz, - opcode=[0xED], - operands=[Operand(type="Areg", size=sz, dest=None), - Operand(type="Dreg", size=16, dest=None)]) -# GAS-only variants (implicit accumulator register) -add_group("in", - suffix="b", - parsers=["gas"], - opcode=[0xE4], - operands=[Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) -for sfx, sz in zip("wl", [16, 32]): - add_group("in", - suffix=sfx, - parsers=["gas"], - opersize=sz, - opcode=[0xE5], - operands=[Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) -add_group("in", - suffix="b", - parsers=["gas"], - opcode=[0xEC], - operands=[Operand(type="Dreg", size=16, dest=None)]) -add_group("in", - suffix="w", - parsers=["gas"], - opersize=16, - opcode=[0xED], - operands=[Operand(type="Dreg", size=16, dest=None)]) -add_group("in", - suffix="l", - cpu=["386"], - parsers=["gas"], - opersize=32, - opcode=[0xED], - operands=[Operand(type="Dreg", size=16, dest=None)]) - -add_insn("in", "in") - -add_group("out", - suffix="b", - opcode=[0xE6], - operands=[Operand(type="Imm", size=8, relaxed=True, dest="Imm"), - Operand(type="Areg", size=8, dest=None)]) -for sfx, sz in zip("wl", [16, 32]): - add_group("out", - suffix=sfx, - opersize=sz, - opcode=[0xE7], - operands=[Operand(type="Imm", size=8, relaxed=True, dest="Imm"), - Operand(type="Areg", size=sz, dest=None)]) -add_group("out", - suffix="b", - opcode=[0xEE], - operands=[Operand(type="Dreg", size=16, dest=None), - Operand(type="Areg", size=8, dest=None)]) -for sfx, sz in zip("wl", [16, 32]): - add_group("out", - suffix=sfx, - opersize=sz, - opcode=[0xEF], - operands=[Operand(type="Dreg", size=16, dest=None), - Operand(type="Areg", size=sz, dest=None)]) -# GAS-only variants (implicit accumulator register) -add_group("out", - suffix="b", - parsers=["gas"], - opcode=[0xE6], - operands=[Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) -add_group("out", - suffix="w", - parsers=["gas"], - opersize=16, - opcode=[0xE7], - operands=[Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) -add_group("out", - suffix="l", - cpu=["386"], - parsers=["gas"], - opersize=32, - opcode=[0xE7], - operands=[Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) -add_group("out", - suffix="b", - parsers=["gas"], - opcode=[0xEE], - operands=[Operand(type="Dreg", size=16, dest=None)]) -add_group("out", - suffix="w", - parsers=["gas"], - opersize=16, - opcode=[0xEF], - operands=[Operand(type="Dreg", size=16, dest=None)]) -add_group("out", - suffix="l", - cpu=["386"], - parsers=["gas"], - opersize=32, - opcode=[0xEF], - operands=[Operand(type="Dreg", size=16, dest=None)]) - -add_insn("out", "out") - -# -# Load effective address -# -for sfx, sz in zip("wlq", [16, 32, 64]): - add_group("lea", - suffix=sfx, - opersize=sz, - opcode=[0x8D], - operands=[Operand(type="Reg", size=sz, dest="Spare"), - Operand(type="Mem", relaxed=True, dest="EA")]) - -add_insn("lea", "lea") - -# -# Load segment registers from memory -# -for sfx, sz in zip("wl", [16, 32]): - add_group("ldes", - suffix=sfx, - not64=True, - modifiers=["Op0Add"], - opersize=sz, - opcode=[0x00], - operands=[Operand(type="Reg", size=sz, dest="Spare"), - Operand(type="Mem", relaxed=True, dest="EA")]) - -add_insn("lds", "ldes", modifiers=[0xC5]) -add_insn("les", "ldes", modifiers=[0xC4]) - -for sfx, sz in zip("wlq", [16, 32, 64]): - add_group("lfgss", - suffix=sfx, - cpu=["386"], - modifiers=["Op1Add"], - opersize=sz, - opcode=[0x0F, 0x00], - operands=[Operand(type="Reg", size=sz, dest="Spare"), - Operand(type="Mem", relaxed=True, dest="EA")]) - -add_insn("lfs", "lfgss", modifiers=[0xB4]) -add_insn("lgs", "lfgss", modifiers=[0xB5]) -add_insn("lss", "lfgss", modifiers=[0xB2]) - -# -# Flags registers instructions -# -add_insn("clc", "onebyte", modifiers=[0xF8]) -add_insn("cld", "onebyte", modifiers=[0xFC]) -add_insn("cli", "onebyte", modifiers=[0xFA]) -add_insn("clts", "twobyte", modifiers=[0x0F, 0x06], cpu=["286", "Priv"]) -add_insn("cmc", "onebyte", modifiers=[0xF5]) -add_insn("lahf", "onebyte", modifiers=[0x9F]) -add_insn("sahf", "onebyte", modifiers=[0x9E]) -add_insn("pushf", "onebyte", modifiers=[0x9C, 0, 64]) -add_insn("pushfd", "onebyte", parser="nasm", modifiers=[0x9C, 32], - cpu=["386"], not64=True) -add_insn("pushfl", "onebyte", parser="gas", modifiers=[0x9C, 32], - cpu=["386"], not64=True) -add_insn("pushfw", "onebyte", modifiers=[0x9C, 16, 64]) -add_insn("pushfq", "onebyte", modifiers=[0x9C, 64, 64], only64=True) -add_insn("popf", "onebyte", modifiers=[0x9D, 0, 64]) -add_insn("popfd", "onebyte", parser="nasm", modifiers=[0x9D, 32], - cpu=["386"], not64=True) -add_insn("popfl", "onebyte", parser="gas", modifiers=[0x9D, 32], - cpu=["386"], not64=True) -add_insn("popfw", "onebyte", modifiers=[0x9D, 16, 64]) -add_insn("popfq", "onebyte", modifiers=[0x9D, 64, 64], only64=True) -add_insn("stc", "onebyte", modifiers=[0xF9]) -add_insn("std", "onebyte", modifiers=[0xFD]) -add_insn("sti", "onebyte", modifiers=[0xFB]) - -# -# Arithmetic - general -# -add_group("arith", - suffix="b", - modifiers=["Op0Add"], - opcode=[0x04], - operands=[Operand(type="Areg", size=8, dest=None), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) -for sfx, sz, immsz in zip("wlq", [16, 32, 64], [16, 32, 32]): - add_group("arith", - suffix=sfx, - modifiers=["Op2Add", "Op1AddSp"], - opersize=sz, - opcode1=[0x83, 0xC0], - opcode2=[0x05], - operands=[Operand(type="Areg", size=sz, dest=None), - Operand(type="Imm", size=immsz, relaxed=True, dest="Imm", - opt="SImm8")]) - -add_group("arith", - suffix="b", - modifiers=["Gap", "SpAdd"], - opcode=[0x80], - spare=0, - operands=[Operand(type="RM", size=8, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) -add_group("arith", - suffix="b", - modifiers=["Gap", "SpAdd"], - opcode=[0x80], - spare=0, - operands=[Operand(type="RM", size=8, relaxed=True, dest="EA"), - Operand(type="Imm", size=8, dest="Imm")]) - -add_group("arith", - suffix="w", - modifiers=["Gap", "SpAdd"], - opersize=16, - opcode=[0x83], - spare=0, - operands=[Operand(type="RM", size=16, dest="EA"), - Operand(type="Imm", size=8, dest="SImm")]) -add_group("arith", - parsers=["nasm"], - modifiers=["Gap", "SpAdd"], - opersize=16, - opcode1=[0x83], - opcode2=[0x81], - spare=0, - operands=[Operand(type="RM", size=16, relaxed=True, dest="EA"), - Operand(type="Imm", size=16, dest="Imm", opt="SImm8")]) -add_group("arith", - suffix="w", - modifiers=["Gap", "SpAdd"], - opersize=16, - opcode1=[0x83], - opcode2=[0x81], - spare=0, - operands=[ - Operand(type="RM", size=16, dest="EA"), - Operand(type="Imm", size=16, relaxed=True, dest="Imm", opt="SImm8")]) - -add_group("arith", - suffix="l", - modifiers=["Gap", "SpAdd"], - opersize=32, - opcode=[0x83], - spare=0, - operands=[Operand(type="RM", size=32, dest="EA"), - Operand(type="Imm", size=8, dest="SImm")]) -# Not64 because we can't tell if add [], dword in 64-bit mode is supposed -# to be a qword destination or a dword destination. -add_group("arith", - not64=True, - parsers=["nasm"], - modifiers=["Gap", "SpAdd"], - opersize=32, - opcode1=[0x83], - opcode2=[0x81], - spare=0, - operands=[Operand(type="RM", size=32, relaxed=True, dest="EA"), - Operand(type="Imm", size=32, dest="Imm", opt="SImm8")]) -add_group("arith", - suffix="l", - modifiers=["Gap", "SpAdd"], - opersize=32, - opcode1=[0x83], - opcode2=[0x81], - spare=0, - operands=[ - Operand(type="RM", size=32, dest="EA"), - Operand(type="Imm", size=32, relaxed=True, dest="Imm", opt="SImm8")]) - -# No relaxed-RM mode for 64-bit destinations; see above Not64 comment. -add_group("arith", - suffix="q", - modifiers=["Gap", "SpAdd"], - opersize=64, - opcode=[0x83], - spare=0, - operands=[Operand(type="RM", size=64, dest="EA"), - Operand(type="Imm", size=8, dest="SImm")]) -add_group("arith", - suffix="q", - modifiers=["Gap", "SpAdd"], - opersize=64, - opcode1=[0x83], - opcode2=[0x81], - spare=0, - operands=[ - Operand(type="RM", size=64, dest="EA"), - Operand(type="Imm", size=32, relaxed=True, dest="Imm", opt="SImm8")]) - -for sfx, sz in zip("bwlq", [8, 16, 32, 64]): - add_group("arith", - suffix=sfx, - modifiers=["Op0Add"], - opersize=sz, - opcode=[0x00+(sz!=8)], - operands=[Operand(type="RM", size=sz, relaxed=True, dest="EA"), - Operand(type="Reg", size=sz, dest="Spare")]) -for sfx, sz in zip("bwlq", [8, 16, 32, 64]): - add_group("arith", - suffix=sfx, - modifiers=["Op0Add"], - opersize=sz, - opcode=[0x02+(sz!=8)], - operands=[Operand(type="Reg", size=sz, dest="Spare"), - Operand(type="RM", size=sz, relaxed=True, dest="EA")]) - -add_insn("add", "arith", modifiers=[0x00, 0]) -add_insn("or", "arith", modifiers=[0x08, 1]) -add_insn("adc", "arith", modifiers=[0x10, 2]) -add_insn("sbb", "arith", modifiers=[0x18, 3]) -add_insn("and", "arith", modifiers=[0x20, 4]) -add_insn("sub", "arith", modifiers=[0x28, 5]) -add_insn("xor", "arith", modifiers=[0x30, 6]) -add_insn("cmp", "arith", modifiers=[0x38, 7]) - -# -# Arithmetic - inc/dec -# -add_group("incdec", - suffix="b", - modifiers=["Gap", "SpAdd"], - opcode=[0xFE], - spare=0, - operands=[Operand(type="RM", size=8, dest="EA")]) -for sfx, sz in zip("wl", [16, 32]): - add_group("incdec", - suffix=sfx, - not64=True, - modifiers=["Op0Add"], - opersize=sz, - opcode=[0x00], - operands=[Operand(type="Reg", size=sz, dest="Op0Add")]) - add_group("incdec", - suffix=sfx, - modifiers=["Gap", "SpAdd"], - opersize=sz, - opcode=[0xFF], - spare=0, - operands=[Operand(type="RM", size=sz, dest="EA")]) -add_group("incdec", - suffix="q", - modifiers=["Gap", "SpAdd"], - opersize=64, - opcode=[0xFF], - spare=0, - operands=[Operand(type="RM", size=64, dest="EA")]) - -add_insn("inc", "incdec", modifiers=[0x40, 0]) -add_insn("dec", "incdec", modifiers=[0x48, 1]) - -# -# Arithmetic - mul/neg/not F6 opcodes -# -for sfx, sz in zip("bwlq", [8, 16, 32, 64]): - add_group("f6", - suffix=sfx, - modifiers=["SpAdd"], - opersize=sz, - opcode=[0xF6+(sz!=8)], - spare=0, - operands=[Operand(type="RM", size=sz, dest="EA")]) - -add_insn("not", "f6", modifiers=[2]) -add_insn("neg", "f6", modifiers=[3]) -add_insn("mul", "f6", modifiers=[4]) - -# -# Arithmetic - div/idiv F6 opcodes -# These allow explicit accumulator in GAS mode. -# -for sfx, sz in zip("bwlq", [8, 16, 32, 64]): - add_group("div", - suffix=sfx, - modifiers=["SpAdd"], - opersize=sz, - opcode=[0xF6+(sz!=8)], - spare=0, - operands=[Operand(type="RM", size=sz, dest="EA")]) -# Versions with explicit accumulator -for sfx, sz in zip("bwlq", [8, 16, 32, 64]): - add_group("div", - suffix=sfx, - modifiers=["SpAdd"], - opersize=sz, - opcode=[0xF6+(sz!=8)], - spare=0, - operands=[Operand(type="Areg", size=sz, dest=None), - Operand(type="RM", size=sz, dest="EA")]) - -add_insn("div", "div", modifiers=[6]) -add_insn("idiv", "div", modifiers=[7]) - -# -# Arithmetic - test instruction -# -for sfx, sz, immsz in zip("bwlq", [8, 16, 32, 64], [8, 16, 32, 32]): - add_group("test", - suffix=sfx, - opersize=sz, - opcode=[0xA8+(sz!=8)], - operands=[Operand(type="Areg", size=sz, dest=None), - Operand(type="Imm", size=immsz, relaxed=True, dest="Imm")]) - -for sfx, sz, immsz in zip("bwlq", [8, 16, 32, 64], [8, 16, 32, 32]): - add_group("test", - suffix=sfx, - opersize=sz, - opcode=[0xF6+(sz!=8)], - operands=[Operand(type="RM", size=sz, dest="EA"), - Operand(type="Imm", size=immsz, relaxed=True, dest="Imm")]) - add_group("test", - suffix=sfx, - opersize=sz, - opcode=[0xF6+(sz!=8)], - operands=[Operand(type="RM", size=sz, relaxed=True, dest="EA"), - Operand(type="Imm", size=immsz, dest="Imm")]) - -for sfx, sz in zip("bwlq", [8, 16, 32, 64]): - add_group("test", - suffix=sfx, - opersize=sz, - opcode=[0x84+(sz!=8)], - operands=[Operand(type="RM", size=sz, relaxed=True, dest="EA"), - Operand(type="Reg", size=sz, dest="Spare")]) -for sfx, sz in zip("bwlq", [8, 16, 32, 64]): - add_group("test", - suffix=sfx, - opersize=sz, - opcode=[0x84+(sz!=8)], - operands=[Operand(type="Reg", size=sz, dest="Spare"), - Operand(type="RM", size=sz, relaxed=True, dest="EA")]) - -add_insn("test", "test") - -# -# Arithmetic - aad/aam -# -add_group("aadm", - modifiers=["Op0Add"], - opcode=[0xD4, 0x0A], - operands=[]) -add_group("aadm", - modifiers=["Op0Add"], - opcode=[0xD4], - operands=[Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) - -add_insn("aaa", "onebyte", modifiers=[0x37], not64=True) -add_insn("aas", "onebyte", modifiers=[0x3F], not64=True) -add_insn("daa", "onebyte", modifiers=[0x27], not64=True) -add_insn("das", "onebyte", modifiers=[0x2F], not64=True) -add_insn("aad", "aadm", modifiers=[0x01], not64=True) -add_insn("aam", "aadm", modifiers=[0x00], not64=True) - -# -# Conversion instructions -# -add_insn("cbw", "onebyte", modifiers=[0x98, 16]) -add_insn("cwde", "onebyte", modifiers=[0x98, 32], cpu=["386"]) -add_insn("cdqe", "onebyte", modifiers=[0x98, 64], only64=True) -add_insn("cwd", "onebyte", modifiers=[0x99, 16]) -add_insn("cdq", "onebyte", modifiers=[0x99, 32], cpu=["386"]) -add_insn("cqo", "onebyte", modifiers=[0x99, 64], only64=True) - -# -# Conversion instructions - GAS / AT&T naming -# -add_insn("cbtw", "onebyte", parser="gas", modifiers=[0x98, 16]) -add_insn("cwtl", "onebyte", parser="gas", modifiers=[0x98, 32], cpu=["386"]) -add_insn("cltq", "onebyte", parser="gas", modifiers=[0x98, 64], only64=True) -add_insn("cwtd", "onebyte", parser="gas", modifiers=[0x99, 16]) -add_insn("cltd", "onebyte", parser="gas", modifiers=[0x99, 32], cpu=["386"]) -add_insn("cqto", "onebyte", parser="gas", modifiers=[0x99, 64], only64=True) - -# -# Arithmetic - imul -# -for sfx, sz in zip("bwlq", [8, 16, 32, 64]): - add_group("imul", - suffix=sfx, - opersize=sz, - opcode=[0xF6+(sz!=8)], - spare=5, - operands=[Operand(type="RM", size=sz, dest="EA")]) -for sfx, sz in zip("wlq", [16, 32, 64]): - add_group("imul", - suffix=sfx, - cpu=["386"], - opersize=sz, - opcode=[0x0F, 0xAF], - operands=[Operand(type="Reg", size=sz, dest="Spare"), - Operand(type="RM", size=sz, relaxed=True, dest="EA")]) -for sfx, sz in zip("wlq", [16, 32, 64]): - add_group("imul", - suffix=sfx, - cpu=["186"], - opersize=sz, - opcode=[0x6B], - operands=[Operand(type="Reg", size=sz, dest="Spare"), - Operand(type="RM", size=sz, relaxed=True, dest="EA"), - Operand(type="Imm", size=8, dest="SImm")]) -for sfx, sz in zip("wlq", [16, 32, 64]): - add_group("imul", - suffix=sfx, - cpu=["186"], - opersize=sz, - opcode=[0x6B], - operands=[Operand(type="Reg", size=sz, dest="SpareEA"), - Operand(type="Imm", size=8, dest="SImm")]) -for sfx, sz, immsz in zip("wlq", [16, 32, 64], [16, 32, 32]): - add_group("imul", - suffix=sfx, - cpu=["186"], - opersize=sz, - opcode1=[0x6B], - opcode2=[0x69], - operands=[Operand(type="Reg", size=sz, dest="Spare"), - Operand(type="RM", size=sz, relaxed=True, dest="EA"), - Operand(type="Imm", size=immsz, relaxed=True, dest="SImm", - opt="SImm8")]) -for sfx, sz, immsz in zip("wlq", [16, 32, 64], [16, 32, 32]): - add_group("imul", - suffix=sfx, - cpu=["186"], - opersize=sz, - opcode1=[0x6B], - opcode2=[0x69], - operands=[Operand(type="Reg", size=sz, dest="SpareEA"), - Operand(type="Imm", size=immsz, relaxed=True, dest="SImm", - opt="SImm8")]) - -add_insn("imul", "imul") - -# -# Shifts - standard -# -for sfx, sz in zip("bwlq", [8, 16, 32, 64]): - add_group("shift", - suffix=sfx, - modifiers=["SpAdd"], - opersize=sz, - opcode=[0xD2+(sz!=8)], - spare=0, - operands=[Operand(type="RM", size=sz, dest="EA"), - Operand(type="Creg", size=8, dest=None)]) - add_group("shift", - suffix=sfx, - modifiers=["SpAdd"], - opersize=sz, - opcode=[0xD0+(sz!=8)], - spare=0, - operands=[Operand(type="RM", size=sz, dest="EA"), - Operand(type="Imm1", size=8, relaxed=True, dest=None)]) - add_group("shift", - suffix=sfx, - cpu=["186"], - modifiers=["SpAdd"], - opersize=sz, - opcode=[0xC0+(sz!=8)], - spare=0, - operands=[Operand(type="RM", size=sz, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) -# In GAS mode, single operands are equivalent to shifting by 1 forms -for sfx, sz in zip("bwlq", [8, 16, 32, 64]): - add_group("shift", - suffix=sfx, - parsers=["gas"], - modifiers=["SpAdd"], - opersize=sz, - opcode=[0xD0+(sz!=8)], - spare=0, - operands=[Operand(type="RM", size=sz, dest="EA")]) - -add_insn("rol", "shift", modifiers=[0]) -add_insn("ror", "shift", modifiers=[1]) -add_insn("rcl", "shift", modifiers=[2]) -add_insn("rcr", "shift", modifiers=[3]) -add_insn("sal", "shift", modifiers=[4]) -add_insn("shl", "shift", modifiers=[4]) -add_insn("shr", "shift", modifiers=[5]) -add_insn("sar", "shift", modifiers=[7]) - -# -# Shifts - doubleword -# -for sfx, sz in zip("wlq", [16, 32, 64]): - add_group("shlrd", - suffix=sfx, - cpu=["386"], - modifiers=["Op1Add"], - opersize=sz, - opcode=[0x0F, 0x00], - operands=[Operand(type="RM", size=sz, relaxed=True, dest="EA"), - Operand(type="Reg", size=sz, dest="Spare"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) - add_group("shlrd", - suffix=sfx, - cpu=["386"], - modifiers=["Op1Add"], - opersize=sz, - opcode=[0x0F, 0x01], - operands=[Operand(type="RM", size=sz, relaxed=True, dest="EA"), - Operand(type="Reg", size=sz, dest="Spare"), - Operand(type="Creg", size=8, dest=None)]) -# GAS parser supports two-operand form for shift with CL count -for sfx, sz in zip("wlq", [16, 32, 64]): - add_group("shlrd", - suffix=sfx, - cpu=["386"], - parsers=["gas"], - modifiers=["Op1Add"], - opersize=sz, - opcode=[0x0F, 0x01], - operands=[Operand(type="RM", size=sz, relaxed=True, dest="EA"), - Operand(type="Reg", size=sz, dest="Spare")]) - -add_insn("shld", "shlrd", modifiers=[0xA4]) -add_insn("shrd", "shlrd", modifiers=[0xAC]) - -##################################################################### -# Control transfer instructions (unconditional) -##################################################################### -# -# call -# -add_group("call", - opcode=[], - operands=[Operand(type="ImmNotSegOff", dest="JmpRel")]) -add_group("call", - suffix="w", - opersize=16, - opcode=[], - operands=[Operand(type="ImmNotSegOff", size=16, dest="JmpRel")]) -add_group("call", - suffix="l", - not64=True, - opersize=32, - opcode=[], - operands=[Operand(type="ImmNotSegOff", size=32, dest="JmpRel")]) -add_group("call", - suffixes=["l", "q"], - only64=True, - opersize=64, - opcode=[], - operands=[Operand(type="ImmNotSegOff", size=32, dest="JmpRel")]) - -add_group("call", - opersize=16, - not64=True, #there should not be 16bit call in 64bit mode - opcode=[0xE8], - operands=[Operand(type="Imm", size=16, tmod="Near", dest="JmpRel")]) -add_group("call", - not64=True, - opersize=32, - opcode=[0xE8], - operands=[Operand(type="Imm", size=32, tmod="Near", dest="JmpRel")]) -add_group("call", - only64=True, - opersize=64, - def_opersize_64=64, - opcode=[0xE8], - operands=[Operand(type="Imm", size=32, tmod="Near", dest="JmpRel")]) -add_group("call", - def_opersize_64=64, - opcode=[0xE8], - operands=[Operand(type="Imm", tmod="Near", dest="JmpRel")]) - -add_group("call", - suffix="w", - req_suffix=True, - opersize=16, - opcode=[0xFF], - spare=2, - operands=[Operand(type="RM", size=16, dest="EA")]) -add_group("call", - suffix="l", - req_suffix=True, - not64=True, - opersize=32, - opcode=[0xFF], - spare=2, - operands=[Operand(type="RM", size=32, dest="EA")]) -add_group("call", - suffix="q", - req_suffix=True, - opersize=64, - def_opersize_64=64, - opcode=[0xFF], - spare=2, - operands=[Operand(type="RM", size=64, dest="EA")]) -add_group("call", - parsers=["gas"], - def_opersize_64=64, - opcode=[0xFF], - spare=2, - operands=[Operand(type="Reg", size="BITS", dest="EA")]) -add_group("call", - def_opersize_64=64, - opcode=[0xFF], - spare=2, - operands=[Operand(type="Mem", dest="EA")]) -add_group("call", - parsers=["nasm"], - opersize=16, - def_opersize_64=64, - opcode=[0xFF], - spare=2, - operands=[Operand(type="RM", size=16, tmod="Near", dest="EA")]) -add_group("call", - parsers=["nasm"], - not64=True, - opersize=32, - opcode=[0xFF], - spare=2, - operands=[Operand(type="RM", size=32, tmod="Near", dest="EA")]) -add_group("call", - parsers=["nasm"], - opersize=64, - def_opersize_64=64, - opcode=[0xFF], - spare=2, - operands=[Operand(type="RM", size=64, tmod="Near", dest="EA")]) -add_group("call", - parsers=["nasm"], - def_opersize_64=64, - opcode=[0xFF], - spare=2, - operands=[Operand(type="Mem", tmod="Near", dest="EA")]) - -# Far indirect (through memory). Needs explicit FAR override (NASM only) -for sz in [16, 32, 64]: - add_group("call", - parsers=["nasm"], - opersize=sz, - opcode=[0xFF], - spare=3, - operands=[Operand(type="Mem", size=sz, tmod="Far", dest="EA")]) -add_group("call", - parsers=["nasm"], - opcode=[0xFF], - spare=3, - operands=[Operand(type="Mem", tmod="Far", dest="EA")]) - -# With explicit FAR override -for sz in [16, 32]: - add_group("call", - parsers=["nasm"], - not64=True, - opersize=sz, - opcode=[0x9A], - operands=[Operand(type="Imm", size=sz, tmod="Far", dest="JmpFar")]) -add_group("call", - parsers=["nasm"], - not64=True, - opcode=[0x9A], - operands=[Operand(type="Imm", tmod="Far", dest="JmpFar")]) - -# Since not caught by first ImmNotSegOff group, implicitly FAR (in NASM). -for sz in [16, 32]: - add_group("call", - parsers=["nasm"], - not64=True, - opersize=sz, - opcode=[0x9A], - operands=[Operand(type="Imm", size=sz, dest="JmpFar")]) -add_group("call", - parsers=["nasm"], - not64=True, - opcode=[0x9A], - operands=[Operand(type="Imm", dest="JmpFar")]) - -# Two-operand FAR (GAS only) -for sfx, sz in zip("wl", [16, 32]): - add_group("call", - suffix=sfx, - req_suffix=True, - parsers=["gas"], - not64=True, - gas_no_reverse=True, - opersize=sz, - opcode=[0x9A], - operands=[Operand(type="Imm", size=16, relaxed=True, dest="JmpFar"), - Operand(type="Imm", size=sz, relaxed=True, dest="JmpFar")]) -add_group("call", - parsers=["gas"], - not64=True, - gas_no_reverse=True, - opcode=[0x9A], - operands=[Operand(type="Imm", size=16, relaxed=True, dest="JmpFar"), - Operand(type="Imm", size="BITS", relaxed=True, dest="JmpFar")]) - -add_insn("call", "call") - -# -# jmp -# -add_group("jmp", - opcode=[], - operands=[Operand(type="ImmNotSegOff", dest="JmpRel")]) -add_group("jmp", - suffix="w", - opersize=16, - opcode=[], - operands=[Operand(type="ImmNotSegOff", size=16, dest="JmpRel")]) -add_group("jmp", - suffix="l", - not64=True, - opersize=32, - opcode=[0x00], - operands=[Operand(type="ImmNotSegOff", size=32, dest="JmpRel")]) -add_group("jmp", - suffixes=["l", "q"], - only64=True, - opersize=64, - opcode=[0x00], - operands=[Operand(type="ImmNotSegOff", size=32, dest="JmpRel")]) - -add_group("jmp", - def_opersize_64=64, - opcode=[0xEB], - operands=[Operand(type="Imm", tmod="Short", dest="JmpRel")]) -add_group("jmp", - opersize=16, - def_opersize_64=64, - opcode=[0xE9], - operands=[Operand(type="Imm", size=16, tmod="Near", dest="JmpRel")]) -add_group("jmp", - not64=True, - cpu=["386"], - opersize=32, - opcode=[0xE9], - operands=[Operand(type="Imm", size=32, tmod="Near", dest="JmpRel")]) -add_group("jmp", - only64=True, - opersize=64, - def_opersize_64=64, - opcode=[0xE9], - operands=[Operand(type="Imm", size=32, tmod="Near", dest="JmpRel")]) -add_group("jmp", - def_opersize_64=64, - opcode=[0xE9], - operands=[Operand(type="Imm", tmod="Near", dest="JmpRel")]) - -add_group("jmp", - suffix="w", - req_suffix=True, - opersize=16, - def_opersize_64=64, - opcode=[0xFF], - spare=4, - operands=[Operand(type="RM", size=16, dest="EA")]) -add_group("jmp", - suffix="l", - req_suffix=True, - not64=True, - opersize=32, - opcode=[0xFF], - spare=4, - operands=[Operand(type="RM", size=32, dest="EA")]) -add_group("jmp", - suffix="q", - req_suffix=True, - opersize=64, - def_opersize_64=64, - opcode=[0xFF], - spare=4, - operands=[Operand(type="RM", size=64, dest="EA")]) -add_group("jmp", - parsers=["gas"], - def_opersize_64=64, - opcode=[0xFF], - spare=4, - operands=[Operand(type="Reg", size="BITS", dest="EA")]) -add_group("jmp", - def_opersize_64=64, - opcode=[0xFF], - spare=4, - operands=[Operand(type="Mem", dest="EA")]) -add_group("jmp", - parsers=["nasm"], - opersize=16, - def_opersize_64=64, - opcode=[0xFF], - spare=4, - operands=[Operand(type="RM", size=16, tmod="Near", dest="EA")]) -add_group("jmp", - parsers=["nasm"], - not64=True, - cpu=["386"], - opersize=32, - opcode=[0xFF], - spare=4, - operands=[Operand(type="RM", size=32, tmod="Near", dest="EA")]) -add_group("jmp", - parsers=["nasm"], - opersize=64, - def_opersize_64=64, - opcode=[0xFF], - spare=4, - operands=[Operand(type="RM", size=64, tmod="Near", dest="EA")]) -add_group("jmp", - parsers=["nasm"], - def_opersize_64=64, - opcode=[0xFF], - spare=4, - operands=[Operand(type="Mem", tmod="Near", dest="EA")]) - -# Far indirect (through memory). Needs explicit FAR override. -for sz in [16, 32, 64]: - add_group("jmp", - opersize=sz, - opcode=[0xFF], - spare=5, - operands=[Operand(type="Mem", size=sz, tmod="Far", dest="EA")]) -add_group("jmp", - opcode=[0xFF], - spare=5, - operands=[Operand(type="Mem", tmod="Far", dest="EA")]) - -# With explicit FAR override -for sz in [16, 32]: - add_group("jmp", - not64=True, - opersize=sz, - opcode=[0xEA], - operands=[Operand(type="Imm", size=sz, tmod="Far", dest="JmpFar")]) -add_group("jmp", - not64=True, - opcode=[0xEA], - operands=[Operand(type="Imm", tmod="Far", dest="JmpFar")]) - -# Since not caught by first ImmNotSegOff group, implicitly FAR (in NASM). -for sz in [16, 32]: - add_group("jmp", - parsers=["nasm"], - not64=True, - opersize=sz, - opcode=[0xEA], - operands=[Operand(type="Imm", size=sz, dest="JmpFar")]) -add_group("jmp", - parsers=["nasm"], - not64=True, - opcode=[0xEA], - operands=[Operand(type="Imm", dest="JmpFar")]) - -# Two-operand FAR (GAS only) -for sfx, sz in zip("wl", [16, 32]): - add_group("jmp", - parsers=["gas"], - suffix=sfx, - req_suffix=True, - not64=True, - gas_no_reverse=True, - opersize=sz, - opcode=[0xEA], - operands=[Operand(type="Imm", size=16, relaxed=True, dest="JmpFar"), - Operand(type="Imm", size=sz, relaxed=True, dest="JmpFar")]) -add_group("jmp", - parsers=["gas"], - not64=True, - gas_no_reverse=True, - opcode=[0xEA], - operands=[Operand(type="Imm", size=16, relaxed=True, dest="JmpFar"), - Operand(type="Imm", size="BITS", relaxed=True, dest="JmpFar")]) - -add_insn("jmp", "jmp") - -# -# GAS far calls/jumps -# - -# Far indirect (through memory) -for sfx, sz in zip("wlq", [16, 32, 64]): - add_group("ljmpcall", - suffix=sfx, - req_suffix=True, - opersize=sz, - modifiers=["SpAdd"], - opcode=[0xFF], - spare=0, - operands=[Operand(type="Mem", size=sz, relaxed=True, dest="EA")]) -add_group("ljmpcall", - modifiers=["SpAdd"], - opcode=[0xFF], - spare=0, - operands=[Operand(type="Mem", size="BITS", relaxed=True, dest="EA")]) - -# Two-operand far -for sfx, sz in zip("wl", [16, 32]): - add_group("ljmpcall", - not64=True, - gas_no_reverse=True, - suffix=sfx, - req_suffix=True, - opersize=sz, - modifiers=["Gap", "Op0Add"], - opcode=[0x00], - operands=[Operand(type="Imm", size=16, relaxed=True, dest="JmpFar"), - Operand(type="Imm", size=sz, relaxed=True, dest="JmpFar")]) -add_group("ljmpcall", - not64=True, - gas_no_reverse=True, - modifiers=["Gap", "Op0Add"], - opcode=[0x00], - operands=[Operand(type="Imm", size=16, relaxed=True, dest="JmpFar"), - Operand(type="Imm", size="BITS", relaxed=True, dest="JmpFar")]) - -add_insn("ljmp", "ljmpcall", parser="gas", modifiers=[5, 0xEA]) -add_insn("lcall", "ljmpcall", parser="gas", modifiers=[3, 0x9A]) - -# -# ret -# -add_group("retnf", - not64=True, - modifiers=["Op0Add"], - opcode=[0x01], - operands=[]) -add_group("retnf", - not64=True, - modifiers=["Op0Add"], - opcode=[0x00], - operands=[Operand(type="Imm", size=16, relaxed=True, dest="Imm")]) -add_group("retnf", - only64=True, - modifiers=["Op0Add", "OpSizeR"], - opcode=[0x01], - operands=[]) -add_group("retnf", - only64=True, - modifiers=["Op0Add", "OpSizeR"], - opcode=[0x00], - operands=[Operand(type="Imm", size=16, relaxed=True, dest="Imm")]) -add_group("retnf", - gen_suffix=False, - suffixes=["w", "l", "q"], - modifiers=["Op0Add", "OpSizeR"], - opcode=[0x01], - operands=[]) -# GAS suffix versions -add_group("retnf", - gen_suffix=False, - suffixes=["w", "l", "q"], - modifiers=["Op0Add", "OpSizeR"], - opcode=[0x00], - operands=[Operand(type="Imm", size=16, relaxed=True, dest="Imm")]) - -add_insn("ret", "retnf", modifiers=[0xC2]) -add_insn("retw", "retnf", parser="gas", modifiers=[0xC2, 16]) -add_insn("retl", "retnf", parser="gas", modifiers=[0xC2], not64=True) -add_insn("retq", "retnf", parser="gas", modifiers=[0xC2], only64=True) -add_insn("retn", "retnf", parser="nasm", modifiers=[0xC2]) -add_insn("retf", "retnf", parser="nasm", modifiers=[0xCA, 64]) -add_insn("lret", "retnf", parser="gas", modifiers=[0xCA], suffix="z") -add_insn("lretw", "retnf", parser="gas", modifiers=[0xCA, 16], suffix="w") -add_insn("lretl", "retnf", parser="gas", modifiers=[0xCA], suffix="l") -add_insn("lretq", "retnf", parser="gas", modifiers=[0xCA, 64], only64=True, - suffix="q") - -# -# enter -# -add_group("enter", - suffix="l", - not64=True, - cpu=["186"], - gas_no_reverse=True, - opcode=[0xC8], - operands=[ - Operand(type="Imm", size=16, relaxed=True, dest="EA", opt="A16"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) -add_group("enter", - suffix="q", - only64=True, - cpu=["186"], - gas_no_reverse=True, - opersize=64, - def_opersize_64=64, - opcode=[0xC8], - operands=[ - Operand(type="Imm", size=16, relaxed=True, dest="EA", opt="A16"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) -# GAS suffix version -add_group("enter", - suffix="w", - cpu=["186"], - parsers=["gas"], - gas_no_reverse=True, - opersize=16, - opcode=[0xC8], - operands=[ - Operand(type="Imm", size=16, relaxed=True, dest="EA", opt="A16"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) - -add_insn("enter", "enter") - -# -# leave -# -add_insn("leave", "onebyte", modifiers=[0xC9, 0, 64], cpu=["186"]) -add_insn("leavew", "onebyte", parser="gas", modifiers=[0xC9, 16, 0], - cpu=["186"]) -add_insn("leavel", "onebyte", parser="gas", modifiers=[0xC9, 0, 64], - cpu=["186"]) -add_insn("leaveq", "onebyte", parser="gas", modifiers=[0xC9, 0, 64], - only64=True) - -##################################################################### -# Conditional jumps -##################################################################### -add_group("jcc", - opcode=[], - operands=[Operand(type="Imm", dest="JmpRel")]) -add_group("jcc", - opersize=16, - opcode=[], - operands=[Operand(type="Imm", size=16, dest="JmpRel")]) -add_group("jcc", - not64=True, - opersize=32, - opcode=[], - operands=[Operand(type="Imm", size=32, dest="JmpRel")]) -add_group("jcc", - only64=True, - opersize=64, - opcode=[], - operands=[Operand(type="Imm", size=32, dest="JmpRel")]) - -add_group("jcc", - modifiers=["Op0Add"], - def_opersize_64=64, - opcode=[0x70], - operands=[Operand(type="Imm", tmod="Short", dest="JmpRel")]) -add_group("jcc", - cpu=["186"], - modifiers=["Op1Add"], - opersize=16, - def_opersize_64=64, - opcode=[0x0F, 0x80], - operands=[Operand(type="Imm", size=16, tmod="Near", dest="JmpRel")]) -add_group("jcc", - not64=True, - cpu=["386"], - modifiers=["Op1Add"], - opersize=32, - opcode=[0x0F, 0x80], - operands=[Operand(type="Imm", size=32, tmod="Near", dest="JmpRel")]) -add_group("jcc", - only64=True, - modifiers=["Op1Add"], - opersize=64, - def_opersize_64=64, - opcode=[0x0F, 0x80], - operands=[Operand(type="Imm", size=32, tmod="Near", dest="JmpRel")]) -add_group("jcc", - cpu=["186"], - modifiers=["Op1Add"], - def_opersize_64=64, - opcode=[0x0F, 0x80], - operands=[Operand(type="Imm", tmod="Near", dest="JmpRel")]) - -add_insn("jo", "jcc", modifiers=[0x00]) -add_insn("jno", "jcc", modifiers=[0x01]) -add_insn("jb", "jcc", modifiers=[0x02]) -add_insn("jc", "jcc", modifiers=[0x02]) -add_insn("jnae", "jcc", modifiers=[0x02]) -add_insn("jnb", "jcc", modifiers=[0x03]) -add_insn("jnc", "jcc", modifiers=[0x03]) -add_insn("jae", "jcc", modifiers=[0x03]) -add_insn("je", "jcc", modifiers=[0x04]) -add_insn("jz", "jcc", modifiers=[0x04]) -add_insn("jne", "jcc", modifiers=[0x05]) -add_insn("jnz", "jcc", modifiers=[0x05]) -add_insn("jbe", "jcc", modifiers=[0x06]) -add_insn("jna", "jcc", modifiers=[0x06]) -add_insn("jnbe", "jcc", modifiers=[0x07]) -add_insn("ja", "jcc", modifiers=[0x07]) -add_insn("js", "jcc", modifiers=[0x08]) -add_insn("jns", "jcc", modifiers=[0x09]) -add_insn("jp", "jcc", modifiers=[0x0A]) -add_insn("jpe", "jcc", modifiers=[0x0A]) -add_insn("jnp", "jcc", modifiers=[0x0B]) -add_insn("jpo", "jcc", modifiers=[0x0B]) -add_insn("jl", "jcc", modifiers=[0x0C]) -add_insn("jnge", "jcc", modifiers=[0x0C]) -add_insn("jnl", "jcc", modifiers=[0x0D]) -add_insn("jge", "jcc", modifiers=[0x0D]) -add_insn("jle", "jcc", modifiers=[0x0E]) -add_insn("jng", "jcc", modifiers=[0x0E]) -add_insn("jnle", "jcc", modifiers=[0x0F]) -add_insn("jg", "jcc", modifiers=[0x0F]) - -# -# jcxz -# -add_group("jcxz", - modifiers=["AdSizeR"], - opcode=[], - operands=[Operand(type="Imm", dest="JmpRel")]) -add_group("jcxz", - modifiers=["AdSizeR"], - def_opersize_64=64, - opcode=[0xE3], - operands=[Operand(type="Imm", tmod="Short", dest="JmpRel")]) - -add_insn("jcxz", "jcxz", modifiers=[16]) -add_insn("jecxz", "jcxz", modifiers=[32], cpu=["386"]) -add_insn("jrcxz", "jcxz", modifiers=[64], only64=True) - -##################################################################### -# Loop instructions -##################################################################### -add_group("loop", - opcode=[], - operands=[Operand(type="Imm", dest="JmpRel")]) -add_group("loop", - not64=True, - opcode=[], - operands=[Operand(type="Imm", dest="JmpRel"), - Operand(type="Creg", size=16, dest="AdSizeR")]) -add_group("loop", - def_opersize_64=64, - opcode=[], - operands=[Operand(type="Imm", dest="JmpRel"), - Operand(type="Creg", size=32, dest="AdSizeR")]) -add_group("loop", - def_opersize_64=64, - opcode=[], - operands=[Operand(type="Imm", dest="JmpRel"), - Operand(type="Creg", size=64, dest="AdSizeR")]) - -add_group("loop", - not64=True, - modifiers=["Op0Add"], - opcode=[0xE0], - operands=[Operand(type="Imm", tmod="Short", dest="JmpRel")]) -for sz in [16, 32, 64]: - add_group("loop", - modifiers=["Op0Add"], - def_opersize_64=64, - opcode=[0xE0], - operands=[Operand(type="Imm", tmod="Short", dest="JmpRel"), - Operand(type="Creg", size=sz, dest="AdSizeR")]) - -add_insn("loop", "loop", modifiers=[2]) -add_insn("loopz", "loop", modifiers=[1]) -add_insn("loope", "loop", modifiers=[1]) -add_insn("loopnz", "loop", modifiers=[0]) -add_insn("loopne", "loop", modifiers=[0]) - -# GAS w/l/q suffixes have to set addrsize via modifiers -for sfx, sz in zip("wlq", [16, 32, 64]): - add_group("loop"+sfx, - not64=(sz == 16), - only64=(sz == 64), - modifiers=["Gap", "AdSizeR"], - def_opersize_64=64, - opcode=[], - operands=[Operand(type="Imm", dest="JmpRel")]) - add_group("loop"+sfx, - not64=(sz == 16), - only64=(sz == 64), - modifiers=["Op0Add", "AdSizeR"], - def_opersize_64=64, - opcode=[0xE0], - operands=[Operand(type="Imm", tmod="Short", dest="JmpRel")]) - - add_group("loop"+sfx, - not64=(sz == 16), - only64=(sz == 64), - def_opersize_64=64, - opcode=[], - operands=[Operand(type="Imm", dest="JmpRel"), - Operand(type="Creg", size=sz, dest="AdSizeR")]) - add_group("loop"+sfx, - not64=(sz == 16), - only64=(sz == 64), - modifiers=["Op0Add"], - def_opersize_64=64, - opcode=[0xE0], - operands=[Operand(type="Imm", tmod="Short", dest="JmpRel"), - Operand(type="Creg", size=sz, dest="AdSizeR")]) - - add_insn("loop"+sfx, "loop"+sfx, parser="gas", modifiers=[2, sz]) - add_insn("loopz"+sfx, "loop"+sfx, parser="gas", modifiers=[1, sz]) - add_insn("loope"+sfx, "loop"+sfx, parser="gas", modifiers=[1, sz]) - add_insn("loopnz"+sfx, "loop"+sfx, parser="gas", modifiers=[0, sz]) - add_insn("loopne"+sfx, "loop"+sfx, parser="gas", modifiers=[0, sz]) - -##################################################################### -# Set byte on flag instructions -##################################################################### -add_group("setcc", - suffix="b", - cpu=["386"], - modifiers=["Op1Add"], - opcode=[0x0F, 0x90], - spare=2, - operands=[Operand(type="RM", size=8, relaxed=True, dest="EA")]) - -add_insn("seto", "setcc", modifiers=[0x00]) -add_insn("setno", "setcc", modifiers=[0x01]) -add_insn("setb", "setcc", modifiers=[0x02]) -add_insn("setc", "setcc", modifiers=[0x02]) -add_insn("setnae", "setcc", modifiers=[0x02]) -add_insn("setnb", "setcc", modifiers=[0x03]) -add_insn("setnc", "setcc", modifiers=[0x03]) -add_insn("setae", "setcc", modifiers=[0x03]) -add_insn("sete", "setcc", modifiers=[0x04]) -add_insn("setz", "setcc", modifiers=[0x04]) -add_insn("setne", "setcc", modifiers=[0x05]) -add_insn("setnz", "setcc", modifiers=[0x05]) -add_insn("setbe", "setcc", modifiers=[0x06]) -add_insn("setna", "setcc", modifiers=[0x06]) -add_insn("setnbe", "setcc", modifiers=[0x07]) -add_insn("seta", "setcc", modifiers=[0x07]) -add_insn("sets", "setcc", modifiers=[0x08]) -add_insn("setns", "setcc", modifiers=[0x09]) -add_insn("setp", "setcc", modifiers=[0x0A]) -add_insn("setpe", "setcc", modifiers=[0x0A]) -add_insn("setnp", "setcc", modifiers=[0x0B]) -add_insn("setpo", "setcc", modifiers=[0x0B]) -add_insn("setl", "setcc", modifiers=[0x0C]) -add_insn("setnge", "setcc", modifiers=[0x0C]) -add_insn("setnl", "setcc", modifiers=[0x0D]) -add_insn("setge", "setcc", modifiers=[0x0D]) -add_insn("setle", "setcc", modifiers=[0x0E]) -add_insn("setng", "setcc", modifiers=[0x0E]) -add_insn("setnle", "setcc", modifiers=[0x0F]) -add_insn("setg", "setcc", modifiers=[0x0F]) - -##################################################################### -# String instructions -##################################################################### -add_insn("cmpsb", "onebyte", modifiers=[0xA6, 0]) -add_insn("cmpsw", "onebyte", modifiers=[0xA7, 16]) - -# cmpsd has to be non-onebyte for SSE2 forms below -add_group("cmpsd", - parsers=["nasm"], - notavx=True, - opersize=32, - opcode=[0xA7], - operands=[]) - -add_insn("cmpsd", "cmpsd", cpu=[]) - -add_insn("cmpsl", "onebyte", parser="gas", modifiers=[0xA7, 32], cpu=["386"]) -add_insn("cmpsq", "onebyte", modifiers=[0xA7, 64], only64=True) -add_insn("insb", "onebyte", modifiers=[0x6C, 0]) -add_insn("insw", "onebyte", modifiers=[0x6D, 16]) -add_insn("insd", "onebyte", parser="nasm", modifiers=[0x6D, 32], cpu=["386"]) -add_insn("insl", "onebyte", parser="gas", modifiers=[0x6D, 32], cpu=["386"]) -add_insn("outsb", "onebyte", modifiers=[0x6E, 0]) -add_insn("outsw", "onebyte", modifiers=[0x6F, 16]) -add_insn("outsd", "onebyte", parser="nasm", modifiers=[0x6F, 32], - cpu=["386"]) -add_insn("outsl", "onebyte", parser="gas", modifiers=[0x6F, 32], cpu=["386"]) -add_insn("lodsb", "onebyte", modifiers=[0xAC, 0]) -add_insn("lodsw", "onebyte", modifiers=[0xAD, 16]) -add_insn("lodsd", "onebyte", parser="nasm", modifiers=[0xAD, 32], - cpu=["386"]) -add_insn("lodsl", "onebyte", parser="gas", modifiers=[0xAD, 32], cpu=["386"]) -add_insn("lodsq", "onebyte", modifiers=[0xAD, 64], only64=True) -add_insn("movsb", "onebyte", modifiers=[0xA4, 0]) -add_insn("movsw", "onebyte", modifiers=[0xA5, 16]) - -# movsd has to be non-onebyte for SSE2 forms below -add_group("movsd", - parsers=["nasm", "gas"], - notavx=True, - opersize=32, - opcode=[0xA5], - operands=[]) - -add_insn("movsd", "movsd", cpu=["386"]) - -add_insn("movsl", "onebyte", parser="gas", modifiers=[0xA5, 32], cpu=["386"]) -add_insn("movsq", "onebyte", modifiers=[0xA5, 64], only64=True) -# smov alias for movs in GAS mode -add_insn("smovb", "onebyte", parser="gas", modifiers=[0xA4, 0]) -add_insn("smovw", "onebyte", parser="gas", modifiers=[0xA5, 16]) -add_insn("smovl", "onebyte", parser="gas", modifiers=[0xA5, 32], cpu=["386"]) -add_insn("smovq", "onebyte", parser="gas", modifiers=[0xA5, 64], only64=True) -add_insn("scasb", "onebyte", modifiers=[0xAE, 0]) -add_insn("scasw", "onebyte", modifiers=[0xAF, 16]) -add_insn("scasd", "onebyte", parser="nasm", modifiers=[0xAF, 32], - cpu=["386"]) -add_insn("scasl", "onebyte", parser="gas", modifiers=[0xAF, 32], cpu=["386"]) -add_insn("scasq", "onebyte", modifiers=[0xAF, 64], only64=True) -# ssca alias for scas in GAS mode -add_insn("sscab", "onebyte", parser="gas", modifiers=[0xAE, 0]) -add_insn("sscaw", "onebyte", parser="gas", modifiers=[0xAF, 16]) -add_insn("sscal", "onebyte", parser="gas", modifiers=[0xAF, 32], cpu=["386"]) -add_insn("sscaq", "onebyte", parser="gas", modifiers=[0xAF, 64], only64=True) -add_insn("stosb", "onebyte", modifiers=[0xAA, 0]) -add_insn("stosw", "onebyte", modifiers=[0xAB, 16]) -add_insn("stosd", "onebyte", parser="nasm", modifiers=[0xAB, 32], - cpu=["386"]) -add_insn("stosl", "onebyte", parser="gas", modifiers=[0xAB, 32], cpu=["386"]) -add_insn("stosq", "onebyte", modifiers=[0xAB, 64], only64=True) -add_insn("xlatb", "onebyte", modifiers=[0xD7, 0]) - -##################################################################### -# Bit manipulation -##################################################################### - -# -# bit tests -# -for sfx, sz in zip("wlq", [16, 32, 64]): - add_group("bittest", - suffix=sfx, - cpu=["386"], - modifiers=["Op1Add"], - opersize=sz, - opcode=[0x0F, 0x00], - operands=[Operand(type="RM", size=sz, relaxed=True, dest="EA"), - Operand(type="Reg", size=sz, dest="Spare")]) -for sfx, sz in zip("wlq", [16, 32, 64]): - add_group("bittest", - suffix=sfx, - cpu=["386"], - modifiers=["Gap", "SpAdd"], - opersize=sz, - opcode=[0x0F, 0xBA], - spare=0, - operands=[Operand(type="RM", size=sz, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) - -add_insn("bt", "bittest", modifiers=[0xA3, 4]) -add_insn("bts", "bittest", modifiers=[0xAB, 5]) -add_insn("btr", "bittest", modifiers=[0xB3, 6]) -add_insn("btc", "bittest", modifiers=[0xBB, 7]) - -# -# bit scans - also used for lar/lsl -# -for sfx, sz in zip("wlq", [16, 32, 64]): - add_group("bsfr", - suffix=sfx, - modifiers=["Op1Add"], - opersize=sz, - opcode=[0x0F, 0x00], - operands=[Operand(type="Reg", size=sz, dest="Spare"), - Operand(type="RM", size=sz, relaxed=True, dest="EA")]) - -add_insn("bsf", "bsfr", modifiers=[0xBC], cpu=["386"]) -add_insn("bsr", "bsfr", modifiers=[0xBD], cpu=["386"]) - -##################################################################### -# Interrupts and operating system instructions -##################################################################### -add_group("int", - opcode=[0xCD], - operands=[Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) - -add_insn("int", "int") -add_insn("int3", "onebyte", modifiers=[0xCC]) -add_insn("int03", "onebyte", parser="nasm", modifiers=[0xCC]) -add_insn("into", "onebyte", modifiers=[0xCE], not64=True) -add_insn("iret", "onebyte", modifiers=[0xCF]) -add_insn("iretw", "onebyte", modifiers=[0xCF, 16]) -add_insn("iretd", "onebyte", parser="nasm", modifiers=[0xCF, 32], - cpu=["386"]) -add_insn("iretl", "onebyte", parser="gas", modifiers=[0xCF, 32], cpu=["386"]) -add_insn("iretq", "onebyte", modifiers=[0xCF, 64], only64=True) -add_insn("rsm", "twobyte", modifiers=[0x0F, 0xAA], cpu=["586", "SMM"]) - -for sfx, sz in zip("wl", [16, 32]): - add_group("bound", - suffix=sfx, - cpu=["186"], - not64=True, - opersize=sz, - opcode=[0x62], - operands=[Operand(type="Reg", size=sz, dest="Spare"), - Operand(type="Mem", size=sz, relaxed=True, dest="EA")]) - -add_insn("bound", "bound") -add_insn("hlt", "onebyte", modifiers=[0xF4], cpu=["Priv"]) -add_insn("nop", "onebyte", modifiers=[0x90]) - -# -# Protection control -# -for sfx, sz, sz2 in zip("wlq", [16, 32, 64], [16, 32, 32]): - add_group("larlsl", - suffix=sfx, - modifiers=["Op1Add"], - opersize=sz, - opcode=[0x0F, 0x00], - operands=[Operand(type="Reg", size=sz, dest="Spare"), - Operand(type="Reg", size=sz2, dest="EA")]) - add_group("larlsl", - suffix=sfx, - modifiers=["Op1Add"], - opersize=sz, - opcode=[0x0F, 0x00], - operands=[Operand(type="Reg", size=sz, dest="Spare"), - Operand(type="RM", size=16, relaxed=True, dest="EA")]) - -add_insn("lar", "larlsl", modifiers=[0x02], cpu=["286", "Prot"]) -add_insn("lsl", "larlsl", modifiers=[0x03], cpu=["286", "Prot"]) - -add_group("arpl", - suffix="w", - cpu=["Prot", "286"], - not64=True, - opcode=[0x63], - operands=[Operand(type="RM", size=16, relaxed=True, dest="EA"), - Operand(type="Reg", size=16, dest="Spare")]) - -add_insn("arpl", "arpl") - -for sfx in [None, "w", "l", "q"]: - add_insn("lgdt"+(sfx or ""), "twobytemem", suffix=sfx, - modifiers=[2, 0x0F, 0x01], cpu=["286", "Priv"]) - add_insn("lidt"+(sfx or ""), "twobytemem", suffix=sfx, - modifiers=[3, 0x0F, 0x01], cpu=["286", "Priv"]) - add_insn("sgdt"+(sfx or ""), "twobytemem", suffix=sfx, - modifiers=[0, 0x0F, 0x01], cpu=["286", "Priv"]) - add_insn("sidt"+(sfx or ""), "twobytemem", suffix=sfx, - modifiers=[1, 0x0F, 0x01], cpu=["286", "Priv"]) - -for sfx, sz in zip("wlq", [16, 32, 64]): - add_group("str", - suffix=sfx, - cpu=["Prot", "286"], - opersize=sz, - opcode=[0x0F, 0x00], - spare=1, - operands=[Operand(type="Reg", size=sz, dest="EA")]) -add_group("str", - suffixes=["w", "l"], - cpu=["Prot", "286"], - opcode=[0x0F, 0x00], - spare=1, - operands=[Operand(type="RM", size=16, relaxed=True, dest="EA")]) - -add_insn("str", "str") - -add_group("prot286", - suffix="w", - cpu=["286"], - modifiers=["SpAdd", "Op1Add"], - opcode=[0x0F, 0x00], - spare=0, - operands=[Operand(type="RM", size=16, relaxed=True, dest="EA")]) - -add_insn("lldt", "prot286", modifiers=[2, 0], cpu=["286", "Prot", "Priv"]) -add_insn("ltr", "prot286", modifiers=[3, 0], cpu=["286", "Prot", "Priv"]) -add_insn("verr", "prot286", modifiers=[4, 0], cpu=["286", "Prot"]) -add_insn("verw", "prot286", modifiers=[5, 0], cpu=["286", "Prot"]) -add_insn("lmsw", "prot286", modifiers=[6, 1], cpu=["286", "Priv"]) - -for sfx, sz in zip("wlq", [16, 32, 64]): - add_group("sldtmsw", - suffix=sfx, - only64=(sz==64), - cpu=[(sz==32) and "386" or "286"], - modifiers=["SpAdd", "Op1Add"], - opcode=[0x0F, 0x00], - spare=0, - operands=[Operand(type="Mem", size=sz, relaxed=True, dest="EA")]) -for sfx, sz in zip("wlq", [16, 32, 64]): - add_group("sldtmsw", - suffix=sfx, - cpu=["286"], - modifiers=["SpAdd", "Op1Add"], - opersize=sz, - opcode=[0x0F, 0x00], - spare=0, - operands=[Operand(type="Reg", size=sz, dest="EA")]) - -add_insn("sldt", "sldtmsw", modifiers=[0, 0]) -add_insn("smsw", "sldtmsw", modifiers=[4, 1]) - -##################################################################### -# Floating point instructions -##################################################################### -add_insn("fcompp", "twobyte", modifiers=[0xDE, 0xD9], cpu=["FPU"]) -add_insn("fucompp", "twobyte", modifiers=[0xDA, 0xE9], cpu=["286", "FPU"]) -add_insn("ftst", "twobyte", modifiers=[0xD9, 0xE4], cpu=["FPU"]) -add_insn("fxam", "twobyte", modifiers=[0xD9, 0xE5], cpu=["FPU"]) -add_insn("fld1", "twobyte", modifiers=[0xD9, 0xE8], cpu=["FPU"]) -add_insn("fldl2t", "twobyte", modifiers=[0xD9, 0xE9], cpu=["FPU"]) -add_insn("fldl2e", "twobyte", modifiers=[0xD9, 0xEA], cpu=["FPU"]) -add_insn("fldpi", "twobyte", modifiers=[0xD9, 0xEB], cpu=["FPU"]) -add_insn("fldlg2", "twobyte", modifiers=[0xD9, 0xEC], cpu=["FPU"]) -add_insn("fldln2", "twobyte", modifiers=[0xD9, 0xED], cpu=["FPU"]) -add_insn("fldz", "twobyte", modifiers=[0xD9, 0xEE], cpu=["FPU"]) -add_insn("f2xm1", "twobyte", modifiers=[0xD9, 0xF0], cpu=["FPU"]) -add_insn("fyl2x", "twobyte", modifiers=[0xD9, 0xF1], cpu=["FPU"]) -add_insn("fptan", "twobyte", modifiers=[0xD9, 0xF2], cpu=["FPU"]) -add_insn("fpatan", "twobyte", modifiers=[0xD9, 0xF3], cpu=["FPU"]) -add_insn("fxtract", "twobyte", modifiers=[0xD9, 0xF4], cpu=["FPU"]) -add_insn("fprem1", "twobyte", modifiers=[0xD9, 0xF5], cpu=["286", "FPU"]) -add_insn("fdecstp", "twobyte", modifiers=[0xD9, 0xF6], cpu=["FPU"]) -add_insn("fincstp", "twobyte", modifiers=[0xD9, 0xF7], cpu=["FPU"]) -add_insn("fprem", "twobyte", modifiers=[0xD9, 0xF8], cpu=["FPU"]) -add_insn("fyl2xp1", "twobyte", modifiers=[0xD9, 0xF9], cpu=["FPU"]) -add_insn("fsqrt", "twobyte", modifiers=[0xD9, 0xFA], cpu=["FPU"]) -add_insn("fsincos", "twobyte", modifiers=[0xD9, 0xFB], cpu=["286", "FPU"]) -add_insn("frndint", "twobyte", modifiers=[0xD9, 0xFC], cpu=["FPU"]) -add_insn("fscale", "twobyte", modifiers=[0xD9, 0xFD], cpu=["FPU"]) -add_insn("fsin", "twobyte", modifiers=[0xD9, 0xFE], cpu=["286", "FPU"]) -add_insn("fcos", "twobyte", modifiers=[0xD9, 0xFF], cpu=["286", "FPU"]) -add_insn("fchs", "twobyte", modifiers=[0xD9, 0xE0], cpu=["FPU"]) -add_insn("fabs", "twobyte", modifiers=[0xD9, 0xE1], cpu=["FPU"]) -add_insn("fninit", "twobyte", modifiers=[0xDB, 0xE3], cpu=["FPU"]) -add_insn("finit", "threebyte", modifiers=[0x9B, 0xDB, 0xE3], cpu=["FPU"]) -add_insn("fnclex", "twobyte", modifiers=[0xDB, 0xE2], cpu=["FPU"]) -add_insn("fclex", "threebyte", modifiers=[0x9B, 0xDB, 0xE2], cpu=["FPU"]) -for sfx in [None, "l", "s"]: - add_insn("fnstenv"+(sfx or ""), "onebytemem", suffix=sfx, - modifiers=[6, 0xD9], cpu=["FPU"]) - add_insn("fstenv"+(sfx or ""), "twobytemem", suffix=sfx, - modifiers=[6, 0x9B, 0xD9], cpu=["FPU"]) - add_insn("fldenv"+(sfx or ""), "onebytemem", suffix=sfx, - modifiers=[4, 0xD9], cpu=["FPU"]) - add_insn("fnsave"+(sfx or ""), "onebytemem", suffix=sfx, - modifiers=[6, 0xDD], cpu=["FPU"]) - add_insn("fsave"+(sfx or ""), "twobytemem", suffix=sfx, - modifiers=[6, 0x9B, 0xDD], cpu=["FPU"]) - add_insn("frstor"+(sfx or ""), "onebytemem", suffix=sfx, - modifiers=[4, 0xDD], cpu=["FPU"]) -add_insn("fnop", "twobyte", modifiers=[0xD9, 0xD0], cpu=["FPU"]) -add_insn("fwait", "onebyte", modifiers=[0x9B], cpu=["FPU"]) -# Prefixes; should the others be here too? should wait be a prefix? -add_insn("wait", "onebyte", modifiers=[0x9B]) - -# -# load/store with pop (integer and normal) -# -add_group("fld", - suffix="s", - cpu=["FPU"], - opcode=[0xD9], - operands=[Operand(type="Mem", size=32, dest="EA")]) -add_group("fld", - suffix="l", - cpu=["FPU"], - opcode=[0xDD], - operands=[Operand(type="Mem", size=64, dest="EA")]) -add_group("fld", - cpu=["FPU"], - opcode=[0xDB], - spare=5, - operands=[Operand(type="Mem", size=80, dest="EA")]) -add_group("fld", - cpu=["FPU"], - opcode=[0xD9, 0xC0], - operands=[Operand(type="Reg", size=80, dest="Op1Add")]) - -add_insn("fld", "fld") - -add_group("fstp", - suffix="s", - cpu=["FPU"], - opcode=[0xD9], - spare=3, - operands=[Operand(type="Mem", size=32, dest="EA")]) -add_group("fstp", - suffix="l", - cpu=["FPU"], - opcode=[0xDD], - spare=3, - operands=[Operand(type="Mem", size=64, dest="EA")]) -add_group("fstp", - cpu=["FPU"], - opcode=[0xDB], - spare=7, - operands=[Operand(type="Mem", size=80, dest="EA")]) -add_group("fstp", - cpu=["FPU"], - opcode=[0xDD, 0xD8], - operands=[Operand(type="Reg", size=80, dest="Op1Add")]) - -add_insn("fstp", "fstp") - -# -# Long memory version of floating point load/store for GAS -# -add_group("fldstpt", - cpu=["FPU"], - modifiers=["SpAdd"], - opcode=[0xDB], - spare=0, - operands=[Operand(type="Mem", size=80, relaxed=True, dest="EA")]) - -add_insn("fldt", "fldstpt", modifiers=[5]) -add_insn("fstpt", "fldstpt", modifiers=[7]) - -add_group("fildstp", - suffix="s", - cpu=["FPU"], - modifiers=["SpAdd"], - opcode=[0xDF], - spare=0, - operands=[Operand(type="Mem", size=16, dest="EA")]) -add_group("fildstp", - suffix="l", - cpu=["FPU"], - modifiers=["SpAdd"], - opcode=[0xDB], - spare=0, - operands=[Operand(type="Mem", size=32, dest="EA")]) -add_group("fildstp", - suffix="q", - cpu=["FPU"], - modifiers=["Gap", "Op0Add", "SpAdd"], - opcode=[0xDD], - spare=0, - operands=[Operand(type="Mem", size=64, dest="EA")]) -# No-suffix alias for memory for GAS compat -> "s" version generated -add_group("fildstp", - cpu=["FPU"], - parsers=["gas"], - modifiers=["SpAdd"], - opcode=[0xDF], - spare=0, - operands=[Operand(type="Mem", size=16, relaxed=True, dest="EA")]) - -add_insn("fild", "fildstp", modifiers=[0, 2, 5]) -add_insn("fistp", "fildstp", modifiers=[3, 2, 7]) - -add_group("fbldstp", - cpu=["FPU"], - modifiers=["SpAdd"], - opcode=[0xDF], - spare=0, - operands=[Operand(type="Mem", size=80, relaxed=True, dest="EA")]) - -add_insn("fbld", "fbldstp", modifiers=[4]) -add_insn("fildll", "fbldstp", parser="gas", modifiers=[5]) -add_insn("fbstp", "fbldstp", modifiers=[6]) -add_insn("fistpll", "fbldstp", parser="gas", modifiers=[7]) - -# -# store (normal) -# -add_group("fst", - suffix="s", - cpu=["FPU"], - opcode=[0xD9], - spare=2, - operands=[Operand(type="Mem", size=32, dest="EA")]) -add_group("fst", - suffix="l", - cpu=["FPU"], - opcode=[0xDD], - spare=2, - operands=[Operand(type="Mem", size=64, dest="EA")]) -add_group("fst", - cpu=["FPU"], - opcode=[0xDD, 0xD0], - operands=[Operand(type="Reg", size=80, dest="Op1Add")]) - -add_insn("fst", "fst") - -# -# exchange (with ST0) -# -add_group("fxch", - cpu=["FPU"], - opcode=[0xD9, 0xC8], - operands=[Operand(type="Reg", size=80, dest="Op1Add")]) -add_group("fxch", - cpu=["FPU"], - opcode=[0xD9, 0xC8], - operands=[Operand(type="ST0", size=80, dest=None), - Operand(type="Reg", size=80, dest="Op1Add")]) -add_group("fxch", - cpu=["FPU"], - opcode=[0xD9, 0xC8], - operands=[Operand(type="Reg", size=80, dest="Op1Add"), - Operand(type="ST0", size=80, dest=None)]) -add_group("fxch", - cpu=["FPU"], - opcode=[0xD9, 0xC9], - operands=[]) - -add_insn("fxch", "fxch") - -# -# comparisons -# -add_group("fcom", - suffix="s", - cpu=["FPU"], - modifiers=["Gap", "SpAdd"], - opcode=[0xD8], - spare=0, - operands=[Operand(type="Mem", size=32, dest="EA")]) -add_group("fcom", - suffix="l", - cpu=["FPU"], - modifiers=["Gap", "SpAdd"], - opcode=[0xDC], - spare=0, - operands=[Operand(type="Mem", size=64, dest="EA")]) -add_group("fcom", - cpu=["FPU"], - modifiers=["Op1Add"], - opcode=[0xD8, 0x00], - operands=[Operand(type="Reg", size=80, dest="Op1Add")]) -# No-suffix alias for memory for GAS compat -> "s" version generated -add_group("fcom", - cpu=["FPU"], - parsers=["gas"], - modifiers=["Gap", "SpAdd"], - opcode=[0xD8], - spare=0, - operands=[Operand(type="Mem", size=32, relaxed=True, dest="EA")]) -# Alias for fcom %st(1) for GAS compat -add_group("fcom", - cpu=["FPU"], - parsers=["gas"], - modifiers=["Op1Add"], - opcode=[0xD8, 0x01], - operands=[]) -add_group("fcom", - cpu=["FPU"], - parsers=["nasm"], - modifiers=["Op1Add"], - opcode=[0xD8, 0x00], - operands=[Operand(type="ST0", size=80, dest=None), - Operand(type="Reg", size=80, dest="Op1Add")]) - -add_insn("fcom", "fcom", modifiers=[0xD0, 2]) -add_insn("fcomp", "fcom", modifiers=[0xD8, 3]) - -# -# extended comparisons -# -add_group("fcom2", - cpu=["FPU", "286"], - modifiers=["Op0Add", "Op1Add"], - opcode=[0x00, 0x00], - operands=[Operand(type="Reg", size=80, dest="Op1Add")]) -add_group("fcom2", - cpu=["FPU", "286"], - modifiers=["Op0Add", "Op1Add"], - opcode=[0x00, 0x00], - operands=[Operand(type="ST0", size=80, dest=None), - Operand(type="Reg", size=80, dest="Op1Add")]) - -add_insn("fucom", "fcom2", modifiers=[0xDD, 0xE0]) -add_insn("fucomp", "fcom2", modifiers=[0xDD, 0xE8]) - -# -# arithmetic -# -add_group("farith", - suffix="s", - cpu=["FPU"], - modifiers=["Gap", "Gap", "SpAdd"], - opcode=[0xD8], - spare=0, - operands=[Operand(type="Mem", size=32, dest="EA")]) -add_group("farith", - suffix="l", - cpu=["FPU"], - modifiers=["Gap", "Gap", "SpAdd"], - opcode=[0xDC], - spare=0, - operands=[Operand(type="Mem", size=64, dest="EA")]) -add_group("farith", - cpu=["FPU"], - modifiers=["Gap", "Op1Add"], - opcode=[0xD8, 0x00], - operands=[Operand(type="Reg", size=80, dest="Op1Add")]) -add_group("farith", - cpu=["FPU"], - modifiers=["Gap", "Op1Add"], - opcode=[0xD8, 0x00], - operands=[Operand(type="ST0", size=80, dest=None), - Operand(type="Reg", size=80, dest="Op1Add")]) -add_group("farith", - cpu=["FPU"], - modifiers=["Op1Add"], - opcode=[0xDC, 0x00], - operands=[Operand(type="Reg", size=80, tmod="To", dest="Op1Add")]) -add_group("farith", - cpu=["FPU"], - parsers=["nasm"], - modifiers=["Op1Add"], - opcode=[0xDC, 0x00], - operands=[Operand(type="Reg", size=80, dest="Op1Add"), - Operand(type="ST0", size=80, dest=None)]) -add_group("farith", - cpu=["FPU"], - parsers=["gas"], - modifiers=["Gap", "Op1Add"], - opcode=[0xDC, 0x00], - operands=[Operand(type="Reg", size=80, dest="Op1Add"), - Operand(type="ST0", size=80, dest=None)]) - -add_insn("fadd", "farith", modifiers=[0xC0, 0xC0, 0]) -add_insn("fsub", "farith", modifiers=[0xE8, 0xE0, 4]) -add_insn("fsubr", "farith", modifiers=[0xE0, 0xE8, 5]) -add_insn("fmul", "farith", modifiers=[0xC8, 0xC8, 1]) -add_insn("fdiv", "farith", modifiers=[0xF8, 0xF0, 6]) -add_insn("fdivr", "farith", modifiers=[0xF0, 0xF8, 7]) - -add_group("farithp", - cpu=["FPU"], - modifiers=["Op1Add"], - opcode=[0xDE, 0x01], - operands=[]) -add_group("farithp", - cpu=["FPU"], - modifiers=["Op1Add"], - opcode=[0xDE, 0x00], - operands=[Operand(type="Reg", size=80, dest="Op1Add")]) -add_group("farithp", - cpu=["FPU"], - modifiers=["Op1Add"], - opcode=[0xDE, 0x00], - operands=[Operand(type="Reg", size=80, dest="Op1Add"), - Operand(type="ST0", size=80, dest=None)]) - -add_insn("faddp", "farithp", modifiers=[0xC0]) -add_insn("fsubp", "farithp", parser="nasm", modifiers=[0xE8]) -add_insn("fsubp", "farithp", parser="gas", modifiers=[0xE0]) -add_insn("fsubrp", "farithp", parser="nasm", modifiers=[0xE0]) -add_insn("fsubrp", "farithp", parser="gas", modifiers=[0xE8]) -add_insn("fmulp", "farithp", modifiers=[0xC8]) -add_insn("fdivp", "farithp", parser="nasm", modifiers=[0xF8]) -add_insn("fdivp", "farithp", parser="gas", modifiers=[0xF0]) -add_insn("fdivrp", "farithp", parser="nasm", modifiers=[0xF0]) -add_insn("fdivrp", "farithp", parser="gas", modifiers=[0xF8]) - -# -# integer arith/store wo pop/compare -# -add_group("fiarith", - suffix="s", - cpu=["FPU"], - modifiers=["SpAdd", "Op0Add"], - opcode=[0x04], - spare=0, - operands=[Operand(type="Mem", size=16, dest="EA")]) -add_group("fiarith", - suffix="l", - cpu=["FPU"], - modifiers=["SpAdd", "Op0Add"], - opcode=[0x00], - spare=0, - operands=[Operand(type="Mem", size=32, dest="EA")]) - -add_insn("fist", "fiarith", modifiers=[2, 0xDB]) -add_insn("ficom", "fiarith", modifiers=[2, 0xDA]) -add_insn("ficomp", "fiarith", modifiers=[3, 0xDA]) -add_insn("fiadd", "fiarith", modifiers=[0, 0xDA]) -add_insn("fisub", "fiarith", modifiers=[4, 0xDA]) -add_insn("fisubr", "fiarith", modifiers=[5, 0xDA]) -add_insn("fimul", "fiarith", modifiers=[1, 0xDA]) -add_insn("fidiv", "fiarith", modifiers=[6, 0xDA]) -add_insn("fidivr", "fiarith", modifiers=[7, 0xDA]) - -# -# processor control -# -add_group("fldnstcw", - suffix="w", - cpu=["FPU"], - modifiers=["SpAdd"], - opcode=[0xD9], - spare=0, - operands=[Operand(type="Mem", size=16, relaxed=True, dest="EA")]) - -add_insn("fldcw", "fldnstcw", modifiers=[5]) -add_insn("fnstcw", "fldnstcw", modifiers=[7]) - -add_group("fstcw", - suffix="w", - cpu=["FPU"], - opcode=[0x9B, 0xD9], - spare=7, - operands=[Operand(type="Mem", size=16, relaxed=True, dest="EA")]) - -add_insn("fstcw", "fstcw") - -add_group("fnstsw", - suffix="w", - cpu=["FPU"], - opcode=[0xDD], - spare=7, - operands=[Operand(type="Mem", size=16, relaxed=True, dest="EA")]) -add_group("fnstsw", - suffix="w", - cpu=["FPU"], - opcode=[0xDF, 0xE0], - operands=[Operand(type="Areg", size=16, dest=None)]) - -add_insn("fnstsw", "fnstsw") - -add_group("fstsw", - suffix="w", - cpu=["FPU"], - opcode=[0x9B, 0xDD], - spare=7, - operands=[Operand(type="Mem", size=16, relaxed=True, dest="EA")]) -add_group("fstsw", - suffix="w", - cpu=["FPU"], - opcode=[0x9B, 0xDF, 0xE0], - operands=[Operand(type="Areg", size=16, dest=None)]) - -add_insn("fstsw", "fstsw") - -add_group("ffree", - cpu=["FPU"], - modifiers=["Op0Add"], - opcode=[0x00, 0xC0], - operands=[Operand(type="Reg", size=80, dest="Op1Add")]) - -add_insn("ffree", "ffree", modifiers=[0xDD]) -add_insn("ffreep", "ffree", modifiers=[0xDF], cpu=["686", "FPU", "Undoc"]) - -##################################################################### -# 486 extensions -##################################################################### -add_group("bswap", - suffix="l", - cpu=["486"], - opersize=32, - opcode=[0x0F, 0xC8], - operands=[Operand(type="Reg", size=32, dest="Op1Add")]) -add_group("bswap", - suffix="q", - opersize=64, - opcode=[0x0F, 0xC8], - operands=[Operand(type="Reg", size=64, dest="Op1Add")]) - -add_insn("bswap", "bswap") - -for sfx, sz in zip("bwlq", [8, 16, 32, 64]): - add_group("cmpxchgxadd", - suffix=sfx, - cpu=["486"], - modifiers=["Op1Add"], - opersize=sz, - opcode=[0x0F, 0x00+(sz!=8)], - operands=[Operand(type="RM", size=sz, relaxed=True, dest="EA"), - Operand(type="Reg", size=sz, dest="Spare")]) - -add_insn("xadd", "cmpxchgxadd", modifiers=[0xC0]) -add_insn("cmpxchg", "cmpxchgxadd", modifiers=[0xB0]) -add_insn("cmpxchg486", "cmpxchgxadd", parser="nasm", modifiers=[0xA6], - cpu=["486", "Undoc"]) - -add_insn("invd", "twobyte", modifiers=[0x0F, 0x08], cpu=["486", "Priv"]) -add_insn("wbinvd", "twobyte", modifiers=[0x0F, 0x09], cpu=["486", "Priv"]) -add_insn("invlpg", "twobytemem", modifiers=[7, 0x0F, 0x01], - cpu=["486", "Priv"]) - -##################################################################### -# 586+ and late 486 extensions -##################################################################### -add_insn("cpuid", "twobyte", modifiers=[0x0F, 0xA2], cpu=["486"]) - -##################################################################### -# Pentium extensions -##################################################################### -add_insn("wrmsr", "twobyte", modifiers=[0x0F, 0x30], cpu=["586", "Priv"]) -add_insn("rdtsc", "twobyte", modifiers=[0x0F, 0x31], cpu=["586"]) -add_insn("rdmsr", "twobyte", modifiers=[0x0F, 0x32], cpu=["586", "Priv"]) - -add_group("cmpxchg8b", - suffix="q", - cpu=["586"], - opcode=[0x0F, 0xC7], - spare=1, - operands=[Operand(type="Mem", size=64, relaxed=True, dest="EA")]) - -add_insn("cmpxchg8b", "cmpxchg8b") - -##################################################################### -# Pentium II/Pentium Pro extensions -##################################################################### -add_insn("sysenter", "twobyte", modifiers=[0x0F, 0x34], cpu=["686"], - not64=True) -add_insn("sysexit", "twobyte", modifiers=[0x0F, 0x35], cpu=["686", "Priv"], - not64=True) -for sfx in [None, "q"]: - add_insn("fxsave"+(sfx or ""), "twobytemem", suffix=sfx, - modifiers=[0, 0x0F, 0xAE], cpu=["686", "FPU"]) - add_insn("fxrstor"+(sfx or ""), "twobytemem", suffix=sfx, - modifiers=[1, 0x0F, 0xAE], cpu=["686", "FPU"]) -add_insn("rdpmc", "twobyte", modifiers=[0x0F, 0x33], cpu=["686"]) -add_insn("ud2", "twobyte", modifiers=[0x0F, 0x0B], cpu=["286"]) -add_insn("ud1", "twobyte", modifiers=[0x0F, 0xB9], cpu=["286", "Undoc"]) - -for sfx, sz in zip("wlq", [16, 32, 64]): - add_group("cmovcc", - suffix=sfx, - cpu=["686"], - modifiers=["Op1Add"], - opersize=sz, - opcode=[0x0F, 0x40], - operands=[Operand(type="Reg", size=sz, dest="Spare"), - Operand(type="RM", size=sz, relaxed=True, dest="EA")]) - -add_insn("cmovo", "cmovcc", modifiers=[0x00]) -add_insn("cmovno", "cmovcc", modifiers=[0x01]) -add_insn("cmovb", "cmovcc", modifiers=[0x02]) -add_insn("cmovc", "cmovcc", modifiers=[0x02]) -add_insn("cmovnae", "cmovcc", modifiers=[0x02]) -add_insn("cmovnb", "cmovcc", modifiers=[0x03]) -add_insn("cmovnc", "cmovcc", modifiers=[0x03]) -add_insn("cmovae", "cmovcc", modifiers=[0x03]) -add_insn("cmove", "cmovcc", modifiers=[0x04]) -add_insn("cmovz", "cmovcc", modifiers=[0x04]) -add_insn("cmovne", "cmovcc", modifiers=[0x05]) -add_insn("cmovnz", "cmovcc", modifiers=[0x05]) -add_insn("cmovbe", "cmovcc", modifiers=[0x06]) -add_insn("cmovna", "cmovcc", modifiers=[0x06]) -add_insn("cmovnbe", "cmovcc", modifiers=[0x07]) -add_insn("cmova", "cmovcc", modifiers=[0x07]) -add_insn("cmovs", "cmovcc", modifiers=[0x08]) -add_insn("cmovns", "cmovcc", modifiers=[0x09]) -add_insn("cmovp", "cmovcc", modifiers=[0x0A]) -add_insn("cmovpe", "cmovcc", modifiers=[0x0A]) -add_insn("cmovnp", "cmovcc", modifiers=[0x0B]) -add_insn("cmovpo", "cmovcc", modifiers=[0x0B]) -add_insn("cmovl", "cmovcc", modifiers=[0x0C]) -add_insn("cmovnge", "cmovcc", modifiers=[0x0C]) -add_insn("cmovnl", "cmovcc", modifiers=[0x0D]) -add_insn("cmovge", "cmovcc", modifiers=[0x0D]) -add_insn("cmovle", "cmovcc", modifiers=[0x0E]) -add_insn("cmovng", "cmovcc", modifiers=[0x0E]) -add_insn("cmovnle", "cmovcc", modifiers=[0x0F]) -add_insn("cmovg", "cmovcc", modifiers=[0x0F]) - -add_group("fcmovcc", - cpu=["FPU", "686"], - modifiers=["Op0Add", "Op1Add"], - opcode=[0x00, 0x00], - operands=[Operand(type="ST0", size=80, dest=None), - Operand(type="Reg", size=80, dest="Op1Add")]) - -add_insn("fcmovb", "fcmovcc", modifiers=[0xDA, 0xC0]) -add_insn("fcmove", "fcmovcc", modifiers=[0xDA, 0xC8]) -add_insn("fcmovbe", "fcmovcc", modifiers=[0xDA, 0xD0]) -add_insn("fcmovu", "fcmovcc", modifiers=[0xDA, 0xD8]) -add_insn("fcmovnb", "fcmovcc", modifiers=[0xDB, 0xC0]) -add_insn("fcmovne", "fcmovcc", modifiers=[0xDB, 0xC8]) -add_insn("fcmovnbe", "fcmovcc", modifiers=[0xDB, 0xD0]) -add_insn("fcmovnu", "fcmovcc", modifiers=[0xDB, 0xD8]) - -add_insn("fcomi", "fcom2", modifiers=[0xDB, 0xF0], cpu=["686", "FPU"]) -add_insn("fucomi", "fcom2", modifiers=[0xDB, 0xE8], cpu=["686", "FPU"]) -add_insn("fcomip", "fcom2", modifiers=[0xDF, 0xF0], cpu=["686", "FPU"]) -add_insn("fucomip", "fcom2", modifiers=[0xDF, 0xE8], cpu=["686", "FPU"]) - -##################################################################### -# Pentium4 extensions -##################################################################### -add_group("movnti", - suffix="l", - cpu=["P4"], - opcode=[0x0F, 0xC3], - operands=[Operand(type="Mem", size=32, relaxed=True, dest="EA"), - Operand(type="Reg", size=32, dest="Spare")]) -add_group("movnti", - suffix="q", - cpu=["P4"], - opersize=64, - opcode=[0x0F, 0xC3], - operands=[Operand(type="Mem", size=64, relaxed=True, dest="EA"), - Operand(type="Reg", size=64, dest="Spare")]) - -add_insn("movnti", "movnti") - -add_group("clflush", - cpu=["P3"], - opcode=[0x0F, 0xAE], - spare=7, - operands=[Operand(type="Mem", size=8, relaxed=True, dest="EA")]) - -add_insn("clflush", "clflush") - -add_insn("lfence", "threebyte", modifiers=[0x0F, 0xAE, 0xE8], cpu=["P3"]) -add_insn("mfence", "threebyte", modifiers=[0x0F, 0xAE, 0xF0], cpu=["P3"]) -add_insn("pause", "onebyte_prefix", modifiers=[0xF3, 0x90], cpu=["P4"]) - -##################################################################### -# MMX/SSE2 instructions -##################################################################### - -add_insn("emms", "twobyte", modifiers=[0x0F, 0x77], cpu=["MMX"]) - -# -# movd -# -add_group("movd", - cpu=["MMX"], - opcode=[0x0F, 0x6E], - operands=[Operand(type="SIMDReg", size=64, dest="Spare"), - Operand(type="RM", size=32, relaxed=True, dest="EA")]) -add_group("movd", - cpu=["MMX"], - opersize=64, - opcode=[0x0F, 0x6E], - operands=[Operand(type="SIMDReg", size=64, dest="Spare"), - Operand(type="RM", size=64, relaxed=True, dest="EA")]) -add_group("movd", - cpu=["MMX"], - opcode=[0x0F, 0x7E], - operands=[Operand(type="RM", size=32, relaxed=True, dest="EA"), - Operand(type="SIMDReg", size=64, dest="Spare")]) -add_group("movd", - cpu=["MMX"], - opersize=64, - opcode=[0x0F, 0x7E], - operands=[Operand(type="RM", size=64, relaxed=True, dest="EA"), - Operand(type="SIMDReg", size=64, dest="Spare")]) -add_group("movd", - cpu=["SSE2"], - prefix=0x66, - opcode=[0x0F, 0x6E], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="RM", size=32, relaxed=True, dest="EA")]) -add_group("movd", - cpu=["SSE2"], - opersize=64, - prefix=0x66, - opcode=[0x0F, 0x6E], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="RM", size=64, relaxed=True, dest="EA")]) -add_group("movd", - cpu=["SSE2"], - prefix=0x66, - opcode=[0x0F, 0x7E], - operands=[Operand(type="RM", size=32, relaxed=True, dest="EA"), - Operand(type="SIMDReg", size=128, dest="Spare")]) -add_group("movd", - cpu=["SSE2"], - opersize=64, - prefix=0x66, - opcode=[0x0F, 0x7E], - operands=[Operand(type="RM", size=64, relaxed=True, dest="EA"), - Operand(type="SIMDReg", size=128, dest="Spare")]) - -add_insn("movd", "movd") - -# -# movq -# - -# MMX forms -add_group("movq", - cpu=["MMX"], - parsers=["nasm"], - opcode=[0x0F, 0x6F], - operands=[Operand(type="SIMDReg", size=64, dest="Spare"), - Operand(type="SIMDRM", size=64, relaxed=True, dest="EA")]) -add_group("movq", - cpu=["MMX"], - parsers=["nasm"], - opersize=64, - opcode=[0x0F, 0x6E], - operands=[Operand(type="SIMDReg", size=64, dest="Spare"), - Operand(type="RM", size=64, relaxed=True, dest="EA")]) -add_group("movq", - cpu=["MMX"], - parsers=["nasm"], - opcode=[0x0F, 0x7F], - operands=[Operand(type="SIMDRM", size=64, relaxed=True, dest="EA"), - Operand(type="SIMDReg", size=64, dest="Spare")]) -add_group("movq", - cpu=["MMX"], - parsers=["nasm"], - opersize=64, - opcode=[0x0F, 0x7E], - operands=[Operand(type="RM", size=64, relaxed=True, dest="EA"), - Operand(type="SIMDReg", size=64, dest="Spare")]) - -# SSE2 forms -add_group("movq", - cpu=["SSE2"], - parsers=["nasm"], - prefix=0xF3, - opcode=[0x0F, 0x7E], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="EA")]) -add_group("movq", - cpu=["SSE2"], - parsers=["nasm"], - prefix=0xF3, - opcode=[0x0F, 0x7E], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDRM", size=64, relaxed=True, dest="EA")]) -add_group("movq", - cpu=["SSE2"], - parsers=["nasm"], - opersize=64, - prefix=0x66, - opcode=[0x0F, 0x6E], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="RM", size=64, relaxed=True, dest="EA")]) -add_group("movq", - cpu=["SSE2"], - parsers=["nasm"], - prefix=0x66, - opcode=[0x0F, 0xD6], - operands=[Operand(type="SIMDRM", size=64, relaxed=True, dest="EA"), - Operand(type="SIMDReg", size=128, dest="Spare")]) -add_group("movq", - cpu=["SSE2"], - parsers=["nasm"], - opersize=64, - prefix=0x66, - opcode=[0x0F, 0x7E], - operands=[Operand(type="RM", size=64, relaxed=True, dest="EA"), - Operand(type="SIMDReg", size=128, dest="Spare")]) - -add_insn("movq", "movq") - -add_group("mmxsse2", - cpu=["MMX"], - modifiers=["Op1Add"], - opcode=[0x0F, 0x00], - operands=[Operand(type="SIMDReg", size=64, dest="Spare"), - Operand(type="SIMDRM", size=64, relaxed=True, dest="EA")]) -add_group("mmxsse2", - cpu=["SSE2"], - modifiers=["Op1Add"], - prefix=0x66, - opcode=[0x0F, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDRM", size=128, relaxed=True, dest="EA")]) - -add_insn("packssdw", "mmxsse2", modifiers=[0x6B]) -add_insn("packsswb", "mmxsse2", modifiers=[0x63]) -add_insn("packuswb", "mmxsse2", modifiers=[0x67]) -add_insn("paddb", "mmxsse2", modifiers=[0xFC]) -add_insn("paddw", "mmxsse2", modifiers=[0xFD]) -add_insn("paddd", "mmxsse2", modifiers=[0xFE]) -add_insn("paddq", "mmxsse2", modifiers=[0xD4]) -add_insn("paddsb", "mmxsse2", modifiers=[0xEC]) -add_insn("paddsw", "mmxsse2", modifiers=[0xED]) -add_insn("paddusb", "mmxsse2", modifiers=[0xDC]) -add_insn("paddusw", "mmxsse2", modifiers=[0xDD]) -add_insn("pand", "mmxsse2", modifiers=[0xDB]) -add_insn("pandn", "mmxsse2", modifiers=[0xDF]) -add_insn("pcmpeqb", "mmxsse2", modifiers=[0x74]) -add_insn("pcmpeqw", "mmxsse2", modifiers=[0x75]) -add_insn("pcmpeqd", "mmxsse2", modifiers=[0x76]) -add_insn("pcmpgtb", "mmxsse2", modifiers=[0x64]) -add_insn("pcmpgtw", "mmxsse2", modifiers=[0x65]) -add_insn("pcmpgtd", "mmxsse2", modifiers=[0x66]) -add_insn("pmaddwd", "mmxsse2", modifiers=[0xF5]) -add_insn("pmulhw", "mmxsse2", modifiers=[0xE5]) -add_insn("pmullw", "mmxsse2", modifiers=[0xD5]) -add_insn("por", "mmxsse2", modifiers=[0xEB]) -add_insn("psubb", "mmxsse2", modifiers=[0xF8]) -add_insn("psubw", "mmxsse2", modifiers=[0xF9]) -add_insn("psubd", "mmxsse2", modifiers=[0xFA]) -add_insn("psubq", "mmxsse2", modifiers=[0xFB]) -add_insn("psubsb", "mmxsse2", modifiers=[0xE8]) -add_insn("psubsw", "mmxsse2", modifiers=[0xE9]) -add_insn("psubusb", "mmxsse2", modifiers=[0xD8]) -add_insn("psubusw", "mmxsse2", modifiers=[0xD9]) -add_insn("punpckhbw", "mmxsse2", modifiers=[0x68]) -add_insn("punpckhwd", "mmxsse2", modifiers=[0x69]) -add_insn("punpckhdq", "mmxsse2", modifiers=[0x6A]) -add_insn("punpcklbw", "mmxsse2", modifiers=[0x60]) -add_insn("punpcklwd", "mmxsse2", modifiers=[0x61]) -add_insn("punpckldq", "mmxsse2", modifiers=[0x62]) -add_insn("pxor", "mmxsse2", modifiers=[0xEF]) - -# AVX versions don't support the MMX registers -add_insn("vpackssdw", "xmm_xmm128_256avx2", modifiers=[0x66, 0x6B, VEXL0], avx=True) -add_insn("vpacksswb", "xmm_xmm128_256avx2", modifiers=[0x66, 0x63, VEXL0], avx=True) -add_insn("vpackuswb", "xmm_xmm128_256avx2", modifiers=[0x66, 0x67, VEXL0], avx=True) -add_insn("vpaddb", "xmm_xmm128_256avx2", modifiers=[0x66, 0xFC, VEXL0], avx=True) -add_insn("vpaddw", "xmm_xmm128_256avx2", modifiers=[0x66, 0xFD, VEXL0], avx=True) -add_insn("vpaddd", "xmm_xmm128_256avx2", modifiers=[0x66, 0xFE, VEXL0], avx=True) -add_insn("vpaddq", "xmm_xmm128_256avx2", modifiers=[0x66, 0xD4, VEXL0], avx=True) -add_insn("vpaddsb", "xmm_xmm128_256avx2", modifiers=[0x66, 0xEC, VEXL0], avx=True) -add_insn("vpaddsw", "xmm_xmm128_256avx2", modifiers=[0x66, 0xED, VEXL0], avx=True) -add_insn("vpaddusb", "xmm_xmm128_256avx2", modifiers=[0x66, 0xDC, VEXL0], avx=True) -add_insn("vpaddusw", "xmm_xmm128_256avx2", modifiers=[0x66, 0xDD, VEXL0], avx=True) -add_insn("vpand", "xmm_xmm128_256avx2", modifiers=[0x66, 0xDB, VEXL0], avx=True) -add_insn("vpandn", "xmm_xmm128_256avx2", modifiers=[0x66, 0xDF, VEXL0], avx=True) -add_insn("vpcmpeqb", "xmm_xmm128_256avx2", modifiers=[0x66, 0x74, VEXL0], avx=True) -add_insn("vpcmpeqw", "xmm_xmm128_256avx2", modifiers=[0x66, 0x75, VEXL0], avx=True) -add_insn("vpcmpeqd", "xmm_xmm128_256avx2", modifiers=[0x66, 0x76, VEXL0], avx=True) -add_insn("vpcmpgtb", "xmm_xmm128_256avx2", modifiers=[0x66, 0x64, VEXL0], avx=True) -add_insn("vpcmpgtw", "xmm_xmm128_256avx2", modifiers=[0x66, 0x65, VEXL0], avx=True) -add_insn("vpcmpgtd", "xmm_xmm128_256avx2", modifiers=[0x66, 0x66, VEXL0], avx=True) -add_insn("vpmaddwd", "xmm_xmm128_256avx2", modifiers=[0x66, 0xF5, VEXL0], avx=True) -add_insn("vpmulhw", "xmm_xmm128_256avx2", modifiers=[0x66, 0xE5, VEXL0], avx=True) -add_insn("vpmullw", "xmm_xmm128_256avx2", modifiers=[0x66, 0xD5, VEXL0], avx=True) -add_insn("vpor", "xmm_xmm128_256avx2", modifiers=[0x66, 0xEB, VEXL0], avx=True) -add_insn("vpsubb", "xmm_xmm128_256avx2", modifiers=[0x66, 0xF8, VEXL0], avx=True) -add_insn("vpsubw", "xmm_xmm128_256avx2", modifiers=[0x66, 0xF9, VEXL0], avx=True) -add_insn("vpsubd", "xmm_xmm128_256avx2", modifiers=[0x66, 0xFA, VEXL0], avx=True) -add_insn("vpsubq", "xmm_xmm128_256avx2", modifiers=[0x66, 0xFB, VEXL0], avx=True) -add_insn("vpsubsb", "xmm_xmm128_256avx2", modifiers=[0x66, 0xE8, VEXL0], avx=True) -add_insn("vpsubsw", "xmm_xmm128_256avx2", modifiers=[0x66, 0xE9, VEXL0], avx=True) -add_insn("vpsubusb", "xmm_xmm128_256avx2", modifiers=[0x66, 0xD8, VEXL0], avx=True) -add_insn("vpsubusw", "xmm_xmm128_256avx2", modifiers=[0x66, 0xD9, VEXL0], avx=True) -add_insn("vpunpckhbw", "xmm_xmm128_256avx2", modifiers=[0x66, 0x68, VEXL0], avx=True) -add_insn("vpunpckhwd", "xmm_xmm128_256avx2", modifiers=[0x66, 0x69, VEXL0], avx=True) -add_insn("vpunpckhdq", "xmm_xmm128_256avx2", modifiers=[0x66, 0x6A, VEXL0], avx=True) -add_insn("vpunpcklbw", "xmm_xmm128_256avx2", modifiers=[0x66, 0x60, VEXL0], avx=True) -add_insn("vpunpcklwd", "xmm_xmm128_256avx2", modifiers=[0x66, 0x61, VEXL0], avx=True) -add_insn("vpunpckldq", "xmm_xmm128_256avx2", modifiers=[0x66, 0x62, VEXL0], avx=True) -add_insn("vpxor", "xmm_xmm128_256avx2", modifiers=[0x66, 0xEF, VEXL0], avx=True) - -add_group("pshift", - cpu=["MMX"], - modifiers=["Op1Add"], - opcode=[0x0F, 0x00], - operands=[Operand(type="SIMDReg", size=64, dest="Spare"), - Operand(type="SIMDRM", size=64, relaxed=True, dest="EA")]) -add_group("pshift", - cpu=["MMX"], - modifiers=["Gap", "Op1Add", "SpAdd"], - opcode=[0x0F, 0x00], - spare=0, - operands=[Operand(type="SIMDReg", size=64, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) -add_group("pshift", - cpu=["SSE2"], - modifiers=["Op1Add"], - prefix=0x66, - opcode=[0x0F, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDRM", size=128, relaxed=True, dest="EA")]) -add_group("pshift", - cpu=["SSE2"], - modifiers=["Gap", "Op1Add", "SpAdd"], - prefix=0x66, - opcode=[0x0F, 0x00], - spare=0, - operands=[Operand(type="SIMDReg", size=128, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) - -add_insn("psllw", "pshift", modifiers=[0xF1, 0x71, 6]) -add_insn("pslld", "pshift", modifiers=[0xF2, 0x72, 6]) -add_insn("psllq", "pshift", modifiers=[0xF3, 0x73, 6]) -add_insn("psraw", "pshift", modifiers=[0xE1, 0x71, 4]) -add_insn("psrad", "pshift", modifiers=[0xE2, 0x72, 4]) -add_insn("psrlw", "pshift", modifiers=[0xD1, 0x71, 2]) -add_insn("psrld", "pshift", modifiers=[0xD2, 0x72, 2]) -add_insn("psrlq", "pshift", modifiers=[0xD3, 0x73, 2]) - -# Ran out of modifiers, so AVX has to be separate -for cpu, sz in zip(["AVX", "AVX2"], [128, 256]): - add_group("vpshift", - cpu=[cpu], - modifiers=["Op1Add"], - vex=sz, - prefix=0x66, - opcode=[0x0F, 0x00], - operands=[Operand(type="SIMDReg", size=sz, dest="SpareVEX"), - Operand(type="SIMDRM", size=128, relaxed=True, dest="EA")]) - add_group("vpshift", - cpu=[cpu], - modifiers=["Gap", "Op1Add", "SpAdd"], - vex=sz, - prefix=0x66, - opcode=[0x0F, 0x00], - spare=0, - operands=[Operand(type="SIMDReg", size=sz, dest="EAVEX"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) - add_group("vpshift", - cpu=[cpu], - modifiers=["Op1Add"], - vex=sz, - prefix=0x66, - opcode=[0x0F, 0x00], - operands=[Operand(type="SIMDReg", size=sz, dest="Spare"), - Operand(type="SIMDReg", size=sz, dest="VEX"), - Operand(type="SIMDRM", size=128, relaxed=True, dest="EA")]) - add_group("vpshift", - cpu=[cpu], - modifiers=["Gap", "Op1Add", "SpAdd"], - vex=sz, - prefix=0x66, - opcode=[0x0F, 0x00], - spare=0, - operands=[Operand(type="SIMDReg", size=sz, dest="VEX"), - Operand(type="SIMDReg", size=sz, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) - -add_insn("vpsllw", "vpshift", modifiers=[0xF1, 0x71, 6]) -add_insn("vpslld", "vpshift", modifiers=[0xF2, 0x72, 6]) -add_insn("vpsllq", "vpshift", modifiers=[0xF3, 0x73, 6]) -add_insn("vpsraw", "vpshift", modifiers=[0xE1, 0x71, 4]) -add_insn("vpsrad", "vpshift", modifiers=[0xE2, 0x72, 4]) -add_insn("vpsrlw", "vpshift", modifiers=[0xD1, 0x71, 2]) -add_insn("vpsrld", "vpshift", modifiers=[0xD2, 0x72, 2]) -add_insn("vpsrlq", "vpshift", modifiers=[0xD3, 0x73, 2]) - -# -# PIII (Katmai) new instructions / SIMD instructions -# -add_insn("pavgb", "mmxsse2", modifiers=[0xE0], cpu=["P3", "MMX"]) -add_insn("pavgw", "mmxsse2", modifiers=[0xE3], cpu=["P3", "MMX"]) -add_insn("pmaxsw", "mmxsse2", modifiers=[0xEE], cpu=["P3", "MMX"]) -add_insn("pmaxub", "mmxsse2", modifiers=[0xDE], cpu=["P3", "MMX"]) -add_insn("pminsw", "mmxsse2", modifiers=[0xEA], cpu=["P3", "MMX"]) -add_insn("pminub", "mmxsse2", modifiers=[0xDA], cpu=["P3", "MMX"]) -add_insn("pmulhuw", "mmxsse2", modifiers=[0xE4], cpu=["P3", "MMX"]) -add_insn("psadbw", "mmxsse2", modifiers=[0xF6], cpu=["P3", "MMX"]) - -# AVX versions don't support MMX register -add_insn("vpavgb", "xmm_xmm128_256avx2", modifiers=[0x66, 0xE0, VEXL0], avx=True) -add_insn("vpavgw", "xmm_xmm128_256avx2", modifiers=[0x66, 0xE3, VEXL0], avx=True) -add_insn("vpmaxsw", "xmm_xmm128_256avx2", modifiers=[0x66, 0xEE, VEXL0], avx=True) -add_insn("vpmaxub", "xmm_xmm128_256avx2", modifiers=[0x66, 0xDE, VEXL0], avx=True) -add_insn("vpminsw", "xmm_xmm128_256avx2", modifiers=[0x66, 0xEA, VEXL0], avx=True) -add_insn("vpminub", "xmm_xmm128_256avx2", modifiers=[0x66, 0xDA, VEXL0], avx=True) -add_insn("vpmulhuw", "xmm_xmm128_256avx2", modifiers=[0x66, 0xE4, VEXL0], avx=True) -add_insn("vpsadbw", "xmm_xmm128_256avx2", modifiers=[0x66, 0xF6, VEXL0], avx=True) - -add_insn("prefetchnta", "twobytemem", modifiers=[0, 0x0F, 0x18], cpu=["P3"]) -add_insn("prefetcht0", "twobytemem", modifiers=[1, 0x0F, 0x18], cpu=["P3"]) -add_insn("prefetcht1", "twobytemem", modifiers=[2, 0x0F, 0x18], cpu=["P3"]) -add_insn("prefetcht2", "twobytemem", modifiers=[3, 0x0F, 0x18], cpu=["P3"]) - -add_insn("sfence", "threebyte", modifiers=[0x0F, 0xAE, 0xF8], cpu=["P3"]) - -add_group("xmm_xmm128_256", - cpu=["SSE"], - modifiers=["PreAdd", "Op1Add", "SetVEX"], - prefix=0x00, - opcode=[0x0F, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="SpareVEX"), - Operand(type="SIMDRM", size=128, relaxed=True, dest="EA")]) -add_group("xmm_xmm128_256", - cpu=["AVX"], - modifiers=["PreAdd", "Op1Add"], - vex=128, - prefix=0x00, - opcode=[0x0F, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="VEX"), - Operand(type="SIMDRM", size=128, relaxed=True, dest="EA")]) -add_group("xmm_xmm128_256", - cpu=["AVX"], - modifiers=["PreAdd", "Op1Add"], - vex=256, - prefix=0x00, - opcode=[0x0F, 0x00], - operands=[Operand(type="SIMDReg", size=256, dest="SpareVEX"), - Operand(type="SIMDRM", size=256, relaxed=True, dest="EA")]) -add_group("xmm_xmm128_256", - cpu=["AVX"], - modifiers=["PreAdd", "Op1Add"], - vex=256, - prefix=0x00, - opcode=[0x0F, 0x00], - operands=[Operand(type="SIMDReg", size=256, dest="Spare"), - Operand(type="SIMDReg", size=256, dest="VEX"), - Operand(type="SIMDRM", size=256, relaxed=True, dest="EA")]) - -# Same as above, except 256-bit version only available in AVX2 -add_group("xmm_xmm128_256avx2", - cpu=["SSE"], - modifiers=["PreAdd", "Op1Add", "SetVEX"], - prefix=0x00, - opcode=[0x0F, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="SpareVEX"), - Operand(type="SIMDRM", size=128, relaxed=True, dest="EA")]) -add_group("xmm_xmm128_256avx2", - cpu=["AVX"], - modifiers=["PreAdd", "Op1Add"], - vex=128, - prefix=0x00, - opcode=[0x0F, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="VEX"), - Operand(type="SIMDRM", size=128, relaxed=True, dest="EA")]) -add_group("xmm_xmm128_256avx2", - cpu=["AVX2"], - modifiers=["PreAdd", "Op1Add"], - vex=256, - prefix=0x00, - opcode=[0x0F, 0x00], - operands=[Operand(type="SIMDReg", size=256, dest="SpareVEX"), - Operand(type="SIMDRM", size=256, relaxed=True, dest="EA")]) -add_group("xmm_xmm128_256avx2", - cpu=["AVX2"], - modifiers=["PreAdd", "Op1Add"], - vex=256, - prefix=0x00, - opcode=[0x0F, 0x00], - operands=[Operand(type="SIMDReg", size=256, dest="Spare"), - Operand(type="SIMDReg", size=256, dest="VEX"), - Operand(type="SIMDRM", size=256, relaxed=True, dest="EA")]) - -# Version that does not allow YMM registers -add_group("xmm_xmm128", - cpu=["SSE"], - modifiers=["PreAdd", "Op1Add", "SetVEX"], - prefix=0x00, - opcode=[0x0F, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="SpareVEX"), - Operand(type="SIMDRM", size=128, relaxed=True, dest="EA")]) -add_group("xmm_xmm128", - cpu=["AVX"], - modifiers=["PreAdd", "Op1Add"], - vex=128, - prefix=0x00, - opcode=[0x0F, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="VEX"), - Operand(type="SIMDRM", size=128, relaxed=True, dest="EA")]) - -add_insn("addps", "xmm_xmm128", modifiers=[0, 0x58]) -add_insn("andnps", "xmm_xmm128", modifiers=[0, 0x55]) -add_insn("andps", "xmm_xmm128", modifiers=[0, 0x54]) -add_insn("divps", "xmm_xmm128", modifiers=[0, 0x5E]) -add_insn("maxps", "xmm_xmm128", modifiers=[0, 0x5F]) -add_insn("minps", "xmm_xmm128", modifiers=[0, 0x5D]) -add_insn("mulps", "xmm_xmm128", modifiers=[0, 0x59]) -add_insn("orps", "xmm_xmm128", modifiers=[0, 0x56]) -add_insn("rcpps", "xmm_xmm128", modifiers=[0, 0x53]) -add_insn("rsqrtps", "xmm_xmm128", modifiers=[0, 0x52]) -add_insn("sqrtps", "xmm_xmm128", modifiers=[0, 0x51]) -add_insn("subps", "xmm_xmm128", modifiers=[0, 0x5C]) -add_insn("unpckhps", "xmm_xmm128", modifiers=[0, 0x15]) -add_insn("unpcklps", "xmm_xmm128", modifiers=[0, 0x14]) -add_insn("xorps", "xmm_xmm128", modifiers=[0, 0x57]) - -add_insn("vaddps", "xmm_xmm128_256", modifiers=[0, 0x58, VEXL0], avx=True) -add_insn("vandnps", "xmm_xmm128_256", modifiers=[0, 0x55, VEXL0], avx=True) -add_insn("vandps", "xmm_xmm128_256", modifiers=[0, 0x54, VEXL0], avx=True) -add_insn("vdivps", "xmm_xmm128_256", modifiers=[0, 0x5E, VEXL0], avx=True) -add_insn("vmaxps", "xmm_xmm128_256", modifiers=[0, 0x5F, VEXL0], avx=True) -add_insn("vminps", "xmm_xmm128_256", modifiers=[0, 0x5D, VEXL0], avx=True) -add_insn("vmulps", "xmm_xmm128_256", modifiers=[0, 0x59, VEXL0], avx=True) -add_insn("vorps", "xmm_xmm128_256", modifiers=[0, 0x56, VEXL0], avx=True) -# vrcpps, vrsqrtps, and vsqrtps don't add third operand -add_insn("vsubps", "xmm_xmm128_256", modifiers=[0, 0x5C, VEXL0], avx=True) -add_insn("vunpckhps", "xmm_xmm128_256", modifiers=[0, 0x15, VEXL0], avx=True) -add_insn("vunpcklps", "xmm_xmm128_256", modifiers=[0, 0x14, VEXL0], avx=True) -add_insn("vxorps", "xmm_xmm128_256", modifiers=[0, 0x57, VEXL0], avx=True) - -add_group("cvt_rx_xmm32", - suffix="l", - cpu=["SSE"], - modifiers=["PreAdd", "Op1Add", "SetVEX"], - prefix=0x00, - opcode=[0x0F, 0x00], - operands=[Operand(type="Reg", size=32, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="EA")]) -add_group("cvt_rx_xmm32", - suffix="l", - cpu=["SSE"], - modifiers=["PreAdd", "Op1Add", "SetVEX"], - prefix=0x00, - opcode=[0x0F, 0x00], - operands=[Operand(type="Reg", size=32, dest="Spare"), - Operand(type="Mem", size=32, relaxed=True, dest="EA")]) -# REX -add_group("cvt_rx_xmm32", - suffix="q", - cpu=["SSE"], - modifiers=["PreAdd", "Op1Add", "SetVEX"], - opersize=64, - prefix=0x00, - opcode=[0x0F, 0x00], - operands=[Operand(type="Reg", size=64, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="EA")]) -add_group("cvt_rx_xmm32", - suffix="q", - cpu=["SSE"], - modifiers=["PreAdd", "Op1Add", "SetVEX"], - opersize=64, - prefix=0x00, - opcode=[0x0F, 0x00], - operands=[Operand(type="Reg", size=64, dest="Spare"), - Operand(type="Mem", size=32, relaxed=True, dest="EA")]) - -add_insn("cvtss2si", "cvt_rx_xmm32", modifiers=[0xF3, 0x2D]) -add_insn("cvttss2si", "cvt_rx_xmm32", modifiers=[0xF3, 0x2C]) -add_insn("vcvtss2si", "cvt_rx_xmm32", modifiers=[0xF3, 0x2D, VEXL0], avx=True) -add_insn("vcvttss2si", "cvt_rx_xmm32", modifiers=[0xF3, 0x2C, VEXL0], avx=True) - -add_group("cvt_mm_xmm64", - cpu=["SSE"], - modifiers=["Op1Add"], - opcode=[0x0F, 0x00], - operands=[Operand(type="SIMDReg", size=64, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="EA")]) -add_group("cvt_mm_xmm64", - cpu=["SSE"], - modifiers=["Op1Add"], - opcode=[0x0F, 0x00], - operands=[Operand(type="SIMDReg", size=64, dest="Spare"), - Operand(type="Mem", size=64, relaxed=True, dest="EA")]) - -add_insn("cvtps2pi", "cvt_mm_xmm64", modifiers=[0x2D]) -add_insn("cvttps2pi", "cvt_mm_xmm64", modifiers=[0x2C]) - -add_group("cvt_xmm_mm_ps", - cpu=["SSE"], - modifiers=["Op1Add"], - opcode=[0x0F, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDRM", size=64, relaxed=True, dest="EA")]) - -add_insn("cvtpi2ps", "cvt_xmm_mm_ps", modifiers=[0x2A]) - -# Memory size can be relaxed only in BITS=32 case, where there's no -# ambiguity. -add_group("cvt_xmm_rmx", - suffix="l", - cpu=["SSE"], - modifiers=["PreAdd", "Op1Add", "SetVEX"], - prefix=0x00, - opcode=[0x0F, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="SpareVEX"), - Operand(type="RM", size=32, dest="EA")]) -add_group("cvt_xmm_rmx", - suffix="l", - cpu=["SSE"], - not64=True, - modifiers=["PreAdd", "Op1Add", "SetVEX"], - prefix=0x00, - opcode=[0x0F, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="SpareVEX"), - Operand(type="RM", size=32, relaxed=True, dest="EA")]) -# REX -add_group("cvt_xmm_rmx", - suffix="q", - cpu=["SSE"], - modifiers=["PreAdd", "Op1Add", "SetVEX"], - opersize=64, - prefix=0x00, - opcode=[0x0F, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="SpareVEX"), - Operand(type="RM", size=64, dest="EA")]) -add_group("cvt_xmm_rmx", - suffix="l", - cpu=["AVX"], - not64=True, - modifiers=["PreAdd", "Op1Add"], - vex=128, - prefix=0x00, - opcode=[0x0F, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="VEX"), - Operand(type="RM", size=32, relaxed=True, dest="EA")]) -add_group("cvt_xmm_rmx", - suffix="l", - cpu=["AVX"], - modifiers=["PreAdd", "Op1Add"], - vex=128, - prefix=0x00, - opcode=[0x0F, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="VEX"), - Operand(type="RM", size=32, dest="EA")]) -add_group("cvt_xmm_rmx", - suffix="q", - cpu=["AVX"], - modifiers=["PreAdd", "Op1Add"], - vex=128, - opersize=64, - prefix=0x00, - opcode=[0x0F, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="VEX"), - Operand(type="RM", size=64, dest="EA")]) - -add_insn("cvtsi2ss", "cvt_xmm_rmx", modifiers=[0xF3, 0x2A]) -add_insn("vcvtsi2ss", "cvt_xmm_rmx", modifiers=[0xF3, 0x2A, VEXL0], avx=True) - -add_group("xmm_xmm32", - cpu=["SSE"], - modifiers=["PreAdd", "Op1Add", "SetVEX"], - prefix=0x00, - opcode=[0x0F, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="SpareVEX"), - Operand(type="SIMDReg", size=128, dest="EA")]) -add_group("xmm_xmm32", - cpu=["SSE"], - modifiers=["PreAdd", "Op1Add", "SetVEX"], - prefix=0x00, - opcode=[0x0F, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="SpareVEX"), - Operand(type="Mem", size=32, relaxed=True, dest="EA")]) -add_group("xmm_xmm32", - cpu=["AVX"], - modifiers=["PreAdd", "Op1Add"], - vex=128, - prefix=0x00, - opcode=[0x0F, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="VEX"), - Operand(type="SIMDReg", size=128, dest="EA")]) -add_group("xmm_xmm32", - cpu=["AVX"], - modifiers=["PreAdd", "Op1Add"], - vex=128, - prefix=0x00, - opcode=[0x0F, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="VEX"), - Operand(type="Mem", size=32, relaxed=True, dest="EA")]) - -add_insn("addss", "xmm_xmm32", modifiers=[0xF3, 0x58]) -add_insn("comiss", "xmm_xmm32", modifiers=[0, 0x2F]) -add_insn("divss", "xmm_xmm32", modifiers=[0xF3, 0x5E]) -add_insn("maxss", "xmm_xmm32", modifiers=[0xF3, 0x5F]) -add_insn("minss", "xmm_xmm32", modifiers=[0xF3, 0x5D]) -add_insn("mulss", "xmm_xmm32", modifiers=[0xF3, 0x59]) -add_insn("rcpss", "xmm_xmm32", modifiers=[0xF3, 0x53]) -add_insn("rsqrtss", "xmm_xmm32", modifiers=[0xF3, 0x52]) -add_insn("sqrtss", "xmm_xmm32", modifiers=[0xF3, 0x51]) -add_insn("subss", "xmm_xmm32", modifiers=[0xF3, 0x5C]) -add_insn("ucomiss", "xmm_xmm32", modifiers=[0, 0x2E]) - -add_insn("vaddss", "xmm_xmm32", modifiers=[0xF3, 0x58, VEXL0], avx=True) -# vcomiss and vucomiss are only two operand -add_insn("vdivss", "xmm_xmm32", modifiers=[0xF3, 0x5E, VEXL0], avx=True) -add_insn("vmaxss", "xmm_xmm32", modifiers=[0xF3, 0x5F, VEXL0], avx=True) -add_insn("vminss", "xmm_xmm32", modifiers=[0xF3, 0x5D, VEXL0], avx=True) -add_insn("vmulss", "xmm_xmm32", modifiers=[0xF3, 0x59, VEXL0], avx=True) -add_insn("vrcpss", "xmm_xmm32", modifiers=[0xF3, 0x53, VEXL0], avx=True) -add_insn("vrsqrtss", "xmm_xmm32", modifiers=[0xF3, 0x52, VEXL0], avx=True) -add_insn("vsqrtss", "xmm_xmm32", modifiers=[0xF3, 0x51, VEXL0], avx=True) -add_insn("vsubss", "xmm_xmm32", modifiers=[0xF3, 0x5C, VEXL0], avx=True) - -add_group("ssecmp_128", - cpu=["SSE"], - modifiers=["Imm8", "PreAdd", "SetVEX"], - opcode=[0x0F, 0xC2], - operands=[Operand(type="SIMDReg", size=128, dest="SpareVEX"), - Operand(type="SIMDRM", size=128, relaxed=True, dest="EA")]) -add_group("ssecmp_128", - cpu=["AVX"], - modifiers=["Imm8", "PreAdd"], - vex=128, - opcode=[0x0F, 0xC2], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="VEX"), - Operand(type="SIMDRM", size=128, relaxed=True, dest="EA")]) -add_group("ssecmp_128", - cpu=["AVX"], - modifiers=["Imm8", "PreAdd"], - vex=256, - opcode=[0x0F, 0xC2], - operands=[Operand(type="SIMDReg", size=256, dest="Spare"), - Operand(type="SIMDReg", size=256, dest="VEX"), - Operand(type="SIMDRM", size=256, relaxed=True, dest="EA")]) - -add_group("ssecmp_32", - cpu=["SSE"], - modifiers=["Imm8", "PreAdd", "SetVEX"], - prefix=0x00, - opcode=[0x0F, 0xC2], - operands=[Operand(type="SIMDReg", size=128, dest="SpareVEX"), - Operand(type="SIMDReg", size=128, dest="EA")]) -add_group("ssecmp_32", - cpu=["SSE"], - modifiers=["Imm8", "PreAdd", "SetVEX"], - prefix=0x00, - opcode=[0x0F, 0xC2], - operands=[Operand(type="SIMDReg", size=128, dest="SpareVEX"), - Operand(type="Mem", size=32, relaxed=True, dest="EA")]) -add_group("ssecmp_32", - cpu=["AVX"], - modifiers=["Imm8", "PreAdd"], - vex=128, - prefix=0x00, - opcode=[0x0F, 0xC2], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="VEX"), - Operand(type="SIMDReg", size=128, dest="EA")]) -add_group("ssecmp_32", - cpu=["AVX"], - modifiers=["Imm8", "PreAdd"], - vex=128, - prefix=0x00, - opcode=[0x0F, 0xC2], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="VEX"), - Operand(type="Mem", size=32, relaxed=True, dest="EA")]) - -ssecoms = [(0x0, "eq"), - (0x1, "lt"), - (0x2, "le"), - (0x3, "unord"), - (0x4, "neq"), - (0x5, "nlt"), - (0x6, "nle"), - (0x7, "ord")] -for ib, cc in ssecoms: - add_insn("cmp"+cc+"ps", "ssecmp_128", modifiers=[ib]) - add_insn("cmp"+cc+"ss", "ssecmp_32", modifiers=[ib, 0xF3]) - -avxcoms = [(0x00, "eq"), - (0x01, "lt"), - (0x02, "le"), - (0x03, "unord"), - (0x04, "neq"), - (0x05, "nlt"), - (0x06, "nle"), - (0x07, "ord"), - (0x08, "eq_uq"), - (0x09, "nge"), - (0x0a, "ngt"), - (0x0b, "false"), - (0x0c, "neq_oq"), - (0x0d, "ge"), - (0x0e, "gt"), - (0x0f, "true"), - (0x10, "eq_os"), - (0x11, "lt_oq"), - (0x12, "le_oq"), - (0x13, "unord_s"), - (0x14, "neq_us"), - (0x15, "nlt_uq"), - (0x16, "nle_uq"), - (0x17, "ord_s"), - (0x18, "eq_us"), - (0x19, "nge_uq"), - (0x1a, "ngt_uq"), - (0x1b, "false_os"), - (0x1c, "neq_os"), - (0x1d, "ge_oq"), - (0x1e, "gt_oq"), - (0x1f, "true_us")] -for ib, cc in avxcoms: - add_insn("vcmp"+cc+"ps", "ssecmp_128", modifiers=[ib, 0, VEXL0], avx=True) - add_insn("vcmp"+cc+"ss", "ssecmp_32", modifiers=[ib, 0xF3, VEXL0], avx=True) - -add_group("xmm_xmm128_imm", - cpu=["SSE"], - modifiers=["PreAdd", "Op1Add", "SetVEX"], - opcode=[0x0F, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDRM", size=128, relaxed=True, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) - -add_insn("cmpps", "xmm_xmm128_imm", modifiers=[0, 0xC2]) -add_insn("shufps", "xmm_xmm128_imm", modifiers=[0, 0xC6]) - -# YMM register AVX2 version of above -add_group("xmm_xmm128_imm_256avx2", - cpu=["SSE"], - modifiers=["PreAdd", "Op1Add", "SetVEX"], - opcode=[0x0F, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDRM", size=128, relaxed=True, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) -add_group("xmm_xmm128_imm_256avx2", - cpu=["AVX2"], - modifiers=["PreAdd", "Op1Add"], - vex=256, - opcode=[0x0F, 0x00], - operands=[Operand(type="SIMDReg", size=256, dest="Spare"), - Operand(type="SIMDRM", size=256, relaxed=True, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) - -# YMM register and 4-operand version of above -add_group("xmm_xmm128_imm_256", - cpu=["SSE"], - modifiers=["PreAdd", "Op1Add", "SetVEX"], - opcode=[0x0F, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="SpareVEX"), - Operand(type="SIMDRM", size=128, relaxed=True, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) -add_group("xmm_xmm128_imm_256", - cpu=["AVX"], - modifiers=["PreAdd", "Op1Add"], - vex=128, - opcode=[0x0F, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="VEX"), - Operand(type="SIMDRM", size=128, relaxed=True, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) -add_group("xmm_xmm128_imm_256", - cpu=["AVX"], - modifiers=["PreAdd", "Op1Add"], - vex=256, - opcode=[0x0F, 0x00], - operands=[Operand(type="SIMDReg", size=256, dest="Spare"), - Operand(type="SIMDReg", size=256, dest="VEX"), - Operand(type="SIMDRM", size=256, relaxed=True, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) - -add_insn("vcmpps", "xmm_xmm128_imm_256", modifiers=[0, 0xC2, VEXL0], avx=True) -add_insn("vshufps", "xmm_xmm128_imm_256", modifiers=[0, 0xC6, VEXL0], avx=True) - -add_group("xmm_xmm32_imm", - cpu=["SSE"], - modifiers=["PreAdd", "Op1Add", "SetVEX"], - prefix=0x00, - opcode=[0x0F, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="SpareVEX"), - Operand(type="SIMDReg", size=128, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) -add_group("xmm_xmm32_imm", - cpu=["SSE"], - modifiers=["PreAdd", "Op1Add", "SetVEX"], - prefix=0x00, - opcode=[0x0F, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="SpareVEX"), - Operand(type="Mem", size=32, relaxed=True, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) -add_group("xmm_xmm32_imm", - cpu=["AVX"], - modifiers=["PreAdd", "Op1Add"], - vex=128, - prefix=0x00, - opcode=[0x0F, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="VEX"), - Operand(type="SIMDReg", size=128, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) -add_group("xmm_xmm32_imm", - cpu=["AVX"], - modifiers=["PreAdd", "Op1Add"], - vex=128, - prefix=0x00, - opcode=[0x0F, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="VEX"), - Operand(type="Mem", size=32, relaxed=True, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) - -add_insn("cmpss", "xmm_xmm32_imm", modifiers=[0xF3, 0xC2]) -add_insn("vcmpss", "xmm_xmm32_imm", modifiers=[0xF3, 0xC2, VEXL0], avx=True) - -add_group("ldstmxcsr", - cpu=["SSE"], - modifiers=["SpAdd", "SetVEX"], - opcode=[0x0F, 0xAE], - spare=0, - operands=[Operand(type="Mem", size=32, relaxed=True, dest="EA")]) - -add_insn("ldmxcsr", "ldstmxcsr", modifiers=[2]) -add_insn("stmxcsr", "ldstmxcsr", modifiers=[3]) -add_insn("vldmxcsr", "ldstmxcsr", modifiers=[2, VEXL0], avx=True) -add_insn("vstmxcsr", "ldstmxcsr", modifiers=[3, VEXL0], avx=True) - -add_group("maskmovq", - cpu=["MMX", "P3"], - opcode=[0x0F, 0xF7], - operands=[Operand(type="SIMDReg", size=64, dest="Spare"), - Operand(type="SIMDReg", size=64, dest="EA")]) - -add_insn("maskmovq", "maskmovq") - -# Too many modifiers, so can't reuse first two cases for AVX version -# Just repeat and disable first two with noavx. -add_group("movau", - cpu=["SSE"], - modifiers=["PreAdd", "Op1Add"], - notavx=True, - prefix=0x00, - opcode=[0x0F, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDRM", size=128, relaxed=True, dest="EA")]) -add_group("movau", - cpu=["SSE"], - notavx=True, - modifiers=["PreAdd", "Op1Add", "Op1Add"], - prefix=0x00, - opcode=[0x0F, 0x00], - operands=[Operand(type="SIMDRM", size=128, relaxed=True, dest="EA"), - Operand(type="SIMDReg", size=128, dest="Spare")]) -add_group("movau", - cpu=["AVX"], - modifiers=["PreAdd", "Op1Add"], - vex=128, - opcode=[0x0F, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDRM", size=128, relaxed=True, dest="EA")]) -add_group("movau", - cpu=["AVX"], - modifiers=["PreAdd", "Op1Add", "Op1Add"], - vex=128, - opcode=[0x0F, 0x00], - operands=[Operand(type="SIMDRM", size=128, relaxed=True, dest="EA"), - Operand(type="SIMDReg", size=128, dest="Spare")]) -add_group("movau", - cpu=["AVX"], - modifiers=["PreAdd", "Op1Add"], - vex=256, - opcode=[0x0F, 0x00], - operands=[Operand(type="SIMDReg", size=256, dest="Spare"), - Operand(type="SIMDRM", size=256, relaxed=True, dest="EA")]) -add_group("movau", - cpu=["AVX"], - modifiers=["PreAdd", "Op1Add", "Op1Add"], - vex=256, - opcode=[0x0F, 0x00], - operands=[Operand(type="SIMDRM", size=256, relaxed=True, dest="EA"), - Operand(type="SIMDReg", size=256, dest="Spare")]) - -add_insn("movaps", "movau", modifiers=[0, 0x28, 0x01]) -add_insn("movups", "movau", modifiers=[0, 0x10, 0x01]) -add_insn("vmovaps", "movau", modifiers=[0, 0x28, 0x01], avx=True) -add_insn("vmovups", "movau", modifiers=[0, 0x10, 0x01], avx=True) - -add_group("movhllhps", - cpu=["SSE"], - modifiers=["Op1Add", "SetVEX"], - opcode=[0x0F, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="SpareVEX"), - Operand(type="SIMDReg", size=128, dest="EA")]) -add_group("movhllhps", - cpu=["AVX"], - modifiers=["Op1Add"], - vex=128, - opcode=[0x0F, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="VEX"), - Operand(type="SIMDReg", size=128, dest="EA")]) - -add_insn("movhlps", "movhllhps", modifiers=[0x12]) -add_insn("movlhps", "movhllhps", modifiers=[0x16]) -add_insn("vmovhlps", "movhllhps", modifiers=[0x12, VEXL0], avx=True) -add_insn("vmovlhps", "movhllhps", modifiers=[0x16, VEXL0], avx=True) - -add_group("movhlp", - cpu=["SSE"], - modifiers=["PreAdd", "Op1Add", "SetVEX"], - prefix=0x00, - opcode=[0x0F, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="SpareVEX"), - Operand(type="Mem", size=64, relaxed=True, dest="EA")]) -add_group("movhlp", - cpu=["SSE"], - modifiers=["PreAdd", "Op1Add", "SetVEX"], - prefix=0x00, - opcode=[0x0F, 0x01], - operands=[Operand(type="Mem", size=64, relaxed=True, dest="EA"), - Operand(type="SIMDReg", size=128, dest="Spare")]) -add_group("movhlp", - cpu=["AVX"], - modifiers=["PreAdd", "Op1Add"], - vex=128, - prefix=0x00, - opcode=[0x0F, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="VEX"), - Operand(type="Mem", size=64, relaxed=True, dest="EA")]) - -add_insn("movhps", "movhlp", modifiers=[0, 0x16]) -add_insn("movlps", "movhlp", modifiers=[0, 0x12]) -add_insn("vmovhps", "movhlp", modifiers=[0, 0x16, VEXL0], avx=True) -add_insn("vmovlps", "movhlp", modifiers=[0, 0x12, VEXL0], avx=True) - -add_group("movmsk", - suffix="l", - cpu=["SSE"], - modifiers=["PreAdd", "SetVEX"], - prefix=0x00, - opcode=[0x0F, 0x50], - operands=[Operand(type="Reg", size=32, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="EA")]) -add_group("movmsk", - suffix="q", - cpu=["SSE"], - modifiers=["PreAdd", "SetVEX"], - prefix=0x00, - opersize=64, - opcode=[0x0F, 0x50], - operands=[Operand(type="Reg", size=64, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="EA")]) -add_group("movmsk", - suffix="l", - cpu=["AVX"], - modifiers=["PreAdd"], - vex=256, - prefix=0x00, - opcode=[0x0F, 0x50], - operands=[Operand(type="Reg", size=32, dest="Spare"), - Operand(type="SIMDReg", size=256, dest="EA")]) -add_group("movmsk", - suffix="q", - cpu=["SSE"], - modifiers=["PreAdd"], - vex=256, - prefix=0x00, - opersize=64, - opcode=[0x0F, 0x50], - operands=[Operand(type="Reg", size=64, dest="Spare"), - Operand(type="SIMDReg", size=256, dest="EA")]) - -add_insn("movmskps", "movmsk") -add_insn("vmovmskps", "movmsk", modifiers=[0, VEXL0], avx=True) - -add_group("movnt", - cpu=["SSE"], - modifiers=["PreAdd", "Op1Add", "SetVEX"], - prefix=0x00, - opcode=[0x0F, 0x00], - operands=[Operand(type="Mem", size=128, relaxed=True, dest="EA"), - Operand(type="SIMDReg", size=128, dest="Spare")]) -add_group("movnt", - cpu=["AVX"], - modifiers=["PreAdd", "Op1Add"], - vex=256, - prefix=0x00, - opcode=[0x0F, 0x00], - operands=[Operand(type="Mem", size=256, relaxed=True, dest="EA"), - Operand(type="SIMDReg", size=256, dest="Spare")]) - -add_insn("movntps", "movnt", modifiers=[0, 0x2B]) -add_insn("vmovntps", "movnt", modifiers=[0, 0x2B, VEXL0], avx=True) - -add_group("movntq", - cpu=["SSE"], - opcode=[0x0F, 0xE7], - operands=[Operand(type="Mem", size=64, relaxed=True, dest="EA"), - Operand(type="SIMDReg", size=64, dest="Spare")]) - -add_insn("movntq", "movntq") - -add_group("movss", - cpu=["SSE"], - modifiers=["SetVEX"], - prefix=0xF3, - opcode=[0x0F, 0x10], - operands=[Operand(type="SIMDReg", size=128, dest="SpareVEX"), - Operand(type="SIMDReg", size=128, dest="EA")]) -add_group("movss", - cpu=["SSE"], - modifiers=["SetVEX"], - prefix=0xF3, - opcode=[0x0F, 0x10], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="Mem", size=32, relaxed=True, dest="EA")]) -add_group("movss", - cpu=["SSE"], - modifiers=["SetVEX"], - prefix=0xF3, - opcode=[0x0F, 0x11], - operands=[Operand(type="Mem", size=32, relaxed=True, dest="EA"), - Operand(type="SIMDReg", size=128, dest="Spare")]) -add_group("movss", - cpu=["AVX"], - vex=128, - prefix=0xF3, - opcode=[0x0F, 0x10], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="VEX"), - Operand(type="SIMDReg", size=128, dest="EA")]) - -add_insn("movss", "movss") -add_insn("vmovss", "movss", modifiers=[VEXL0], avx=True) - -add_group("pextrw", - suffix="l", - cpu=["MMX", "P3"], - notavx=True, - opcode=[0x0F, 0xC5], - operands=[Operand(type="Reg", size=32, dest="Spare"), - Operand(type="SIMDReg", size=64, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) -add_group("pextrw", - suffix="l", - cpu=["SSE2"], - modifiers=["SetVEX"], - prefix=0x66, - opcode=[0x0F, 0xC5], - operands=[Operand(type="Reg", size=32, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) -add_group("pextrw", - suffix="q", - cpu=["MMX", "P3"], - notavx=True, - opersize=64, - opcode=[0x0F, 0xC5], - operands=[Operand(type="Reg", size=64, dest="Spare"), - Operand(type="SIMDReg", size=64, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) -add_group("pextrw", - suffix="q", - cpu=["SSE2"], - modifiers=["SetVEX"], - opersize=64, - prefix=0x66, - opcode=[0x0F, 0xC5], - operands=[Operand(type="Reg", size=64, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) -# SSE41 instructions -add_group("pextrw", - cpu=["SSE41"], - modifiers=["SetVEX"], - prefix=0x66, - opcode=[0x0F, 0x3A, 0x15], - operands=[Operand(type="Mem", size=16, relaxed=True, dest="EA"), - Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) -add_group("pextrw", - cpu=["SSE41"], - modifiers=["SetVEX"], - opersize=32, - prefix=0x66, - opcode=[0x0F, 0x3A, 0x15], - operands=[Operand(type="Reg", size=32, dest="EA"), - Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) -add_group("pextrw", - cpu=["SSE41"], - modifiers=["SetVEX"], - opersize=64, - prefix=0x66, - opcode=[0x0F, 0x3A, 0x15], - operands=[Operand(type="Reg", size=64, dest="EA"), - Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) - -add_insn("pextrw", "pextrw") -add_insn("vpextrw", "pextrw", modifiers=[VEXL0], avx=True) - -add_group("pinsrw", - suffix="l", - cpu=["MMX", "P3"], - notavx=True, - opcode=[0x0F, 0xC4], - operands=[Operand(type="SIMDReg", size=64, dest="Spare"), - Operand(type="Reg", size=32, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) -add_group("pinsrw", - suffix="q", - cpu=["MMX", "P3"], - notavx=True, - def_opersize_64=64, - opersize=64, - opcode=[0x0F, 0xC4], - operands=[Operand(type="SIMDReg", size=64, dest="Spare"), - Operand(type="Reg", size=64, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) -add_group("pinsrw", - suffix="l", - cpu=["MMX", "P3"], - notavx=True, - opcode=[0x0F, 0xC4], - operands=[Operand(type="SIMDReg", size=64, dest="Spare"), - Operand(type="Mem", size=16, relaxed=True, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) -add_group("pinsrw", - suffix="l", - cpu=["SSE2"], - modifiers=["SetVEX"], - prefix=0x66, - opcode=[0x0F, 0xC4], - operands=[Operand(type="SIMDReg", size=128, dest="SpareVEX"), - Operand(type="Reg", size=32, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) -add_group("pinsrw", - suffix="q", - cpu=["SSE2"], - modifiers=["SetVEX"], - def_opersize_64=64, - opersize=64, - prefix=0x66, - opcode=[0x0F, 0xC4], - operands=[Operand(type="SIMDReg", size=128, dest="SpareVEX"), - Operand(type="Reg", size=64, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) -add_group("pinsrw", - suffix="l", - cpu=["SSE2"], - modifiers=["SetVEX"], - prefix=0x66, - opcode=[0x0F, 0xC4], - operands=[Operand(type="SIMDReg", size=128, dest="SpareVEX"), - Operand(type="Mem", size=16, relaxed=True, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) -add_group("pinsrw", - suffix="l", - cpu=["AVX"], - vex=128, - prefix=0x66, - opcode=[0x0F, 0xC4], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="VEX"), - Operand(type="Reg", size=32, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) -add_group("pinsrw", - suffix="q", - cpu=["AVX"], - vex=128, - def_opersize_64=64, - opersize=64, - prefix=0x66, - opcode=[0x0F, 0xC4], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="VEX"), - Operand(type="Reg", size=64, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) -add_group("pinsrw", - suffix="l", - cpu=["AVX"], - vex=128, - prefix=0x66, - opcode=[0x0F, 0xC4], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="VEX"), - Operand(type="Mem", size=16, relaxed=True, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) - -add_insn("pinsrw", "pinsrw") -add_insn("vpinsrw", "pinsrw", modifiers=[VEXL0], avx=True) - -add_group("pmovmskb", - suffix="l", - cpu=["MMX", "P3"], - notavx=True, - opcode=[0x0F, 0xD7], - operands=[Operand(type="Reg", size=32, dest="Spare"), - Operand(type="SIMDReg", size=64, dest="EA")]) -add_group("pmovmskb", - suffix="l", - cpu=["SSE2"], - modifiers=["SetVEX"], - prefix=0x66, - opcode=[0x0F, 0xD7], - operands=[Operand(type="Reg", size=32, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="EA")]) -add_group("pmovmskb", - suffix="l", - cpu=["AVX2"], - vex=256, - prefix=0x66, - opcode=[0x0F, 0xD7], - operands=[Operand(type="Reg", size=32, dest="Spare"), - Operand(type="SIMDReg", size=256, dest="EA")]) -add_group("pmovmskb", - suffix="q", - cpu=["MMX", "P3"], - notavx=True, - opersize=64, - def_opersize_64=64, - opcode=[0x0F, 0xD7], - operands=[Operand(type="Reg", size=64, dest="Spare"), - Operand(type="SIMDReg", size=64, dest="EA")]) -add_group("pmovmskb", - suffix="q", - cpu=["SSE2"], - modifiers=["SetVEX"], - opersize=64, - def_opersize_64=64, - prefix=0x66, - opcode=[0x0F, 0xD7], - operands=[Operand(type="Reg", size=64, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="EA")]) -add_group("pmovmskb", - suffix="q", - cpu=["SSE2"], - vex=256, - opersize=64, - def_opersize_64=64, - prefix=0x66, - opcode=[0x0F, 0xD7], - operands=[Operand(type="Reg", size=64, dest="Spare"), - Operand(type="SIMDReg", size=256, dest="EA")]) - -add_insn("pmovmskb", "pmovmskb") -add_insn("vpmovmskb", "pmovmskb", modifiers=[VEXL0], avx=True) - -add_group("pshufw", - cpu=["MMX", "P3"], - opcode=[0x0F, 0x70], - operands=[Operand(type="SIMDReg", size=64, dest="Spare"), - Operand(type="SIMDRM", size=64, relaxed=True, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) - -add_insn("pshufw", "pshufw") - -##################################################################### -# SSE2 instructions -##################################################################### -add_group("xmm_xmm64", - cpu=["SSE2"], - modifiers=["PreAdd", "Op1Add", "SetVEX"], - prefix=0x00, - opcode=[0x0F, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="SpareVEX"), - Operand(type="SIMDReg", size=128, dest="EA")]) -add_group("xmm_xmm64", - cpu=["SSE2"], - modifiers=["PreAdd", "Op1Add", "SetVEX"], - prefix=0x00, - opcode=[0x0F, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="SpareVEX"), - Operand(type="Mem", size=64, relaxed=True, dest="EA")]) -add_group("xmm_xmm64", - cpu=["AVX"], - modifiers=["PreAdd", "Op1Add"], - vex=128, - prefix=0x00, - opcode=[0x0F, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="VEX"), - Operand(type="SIMDReg", size=128, dest="EA")]) -add_group("xmm_xmm64", - cpu=["AVX"], - modifiers=["PreAdd", "Op1Add"], - vex=128, - prefix=0x00, - opcode=[0x0F, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="VEX"), - Operand(type="Mem", size=64, relaxed=True, dest="EA")]) - -add_insn("addsd", "xmm_xmm64", modifiers=[0xF2, 0x58]) -add_insn("comisd", "xmm_xmm64", modifiers=[0x66, 0x2F]) -add_insn("cvtdq2pd", "xmm_xmm64", modifiers=[0xF3, 0xE6]) -add_insn("cvtps2pd", "xmm_xmm64", modifiers=[0, 0x5A]) -add_insn("cvtsd2ss", "xmm_xmm64", modifiers=[0xF2, 0x5A]) -add_insn("divsd", "xmm_xmm64", modifiers=[0xF2, 0x5E]) -add_insn("maxsd", "xmm_xmm64", modifiers=[0xF2, 0x5F]) -add_insn("minsd", "xmm_xmm64", modifiers=[0xF2, 0x5D]) -add_insn("mulsd", "xmm_xmm64", modifiers=[0xF2, 0x59]) -add_insn("subsd", "xmm_xmm64", modifiers=[0xF2, 0x5C]) -add_insn("sqrtsd", "xmm_xmm64", modifiers=[0xF2, 0x51]) -add_insn("ucomisd", "xmm_xmm64", modifiers=[0x66, 0x2E]) - -add_insn("vaddsd", "xmm_xmm64", modifiers=[0xF2, 0x58, VEXL0], avx=True) -# vcomisd and vucomisd are only two operand -# vcvtdq2pd and vcvtps2pd can take ymm, xmm version -add_insn("vcvtsd2ss", "xmm_xmm64", modifiers=[0xF2, 0x5A, VEXL0], avx=True) -add_insn("vdivsd", "xmm_xmm64", modifiers=[0xF2, 0x5E, VEXL0], avx=True) -add_insn("vmaxsd", "xmm_xmm64", modifiers=[0xF2, 0x5F, VEXL0], avx=True) -add_insn("vminsd", "xmm_xmm64", modifiers=[0xF2, 0x5D, VEXL0], avx=True) -add_insn("vmulsd", "xmm_xmm64", modifiers=[0xF2, 0x59, VEXL0], avx=True) -add_insn("vsubsd", "xmm_xmm64", modifiers=[0xF2, 0x5C, VEXL0], avx=True) -add_insn("vsqrtsd", "xmm_xmm64", modifiers=[0xF2, 0x51, VEXL0], avx=True) - -add_insn("addpd", "xmm_xmm128", modifiers=[0x66, 0x58], cpu=["SSE2"]) -add_insn("andnpd", "xmm_xmm128", modifiers=[0x66, 0x55], cpu=["SSE2"]) -add_insn("andpd", "xmm_xmm128", modifiers=[0x66, 0x54], cpu=["SSE2"]) -add_insn("cvtdq2ps", "xmm_xmm128", modifiers=[0, 0x5B], cpu=["SSE2"]) -add_insn("cvtpd2dq", "xmm_xmm128", modifiers=[0xF2, 0xE6], cpu=["SSE2"]) -add_insn("cvtpd2ps", "xmm_xmm128", modifiers=[0x66, 0x5A], cpu=["SSE2"]) -add_insn("cvtps2dq", "xmm_xmm128", modifiers=[0x66, 0x5B], cpu=["SSE2"]) -add_insn("divpd", "xmm_xmm128", modifiers=[0x66, 0x5E], cpu=["SSE2"]) -add_insn("maxpd", "xmm_xmm128", modifiers=[0x66, 0x5F], cpu=["SSE2"]) -add_insn("minpd", "xmm_xmm128", modifiers=[0x66, 0x5D], cpu=["SSE2"]) -add_insn("mulpd", "xmm_xmm128", modifiers=[0x66, 0x59], cpu=["SSE2"]) -add_insn("orpd", "xmm_xmm128", modifiers=[0x66, 0x56], cpu=["SSE2"]) -add_insn("sqrtpd", "xmm_xmm128", modifiers=[0x66, 0x51], cpu=["SSE2"]) -add_insn("subpd", "xmm_xmm128", modifiers=[0x66, 0x5C], cpu=["SSE2"]) -add_insn("unpckhpd", "xmm_xmm128", modifiers=[0x66, 0x15], cpu=["SSE2"]) -add_insn("unpcklpd", "xmm_xmm128", modifiers=[0x66, 0x14], cpu=["SSE2"]) -add_insn("xorpd", "xmm_xmm128", modifiers=[0x66, 0x57], cpu=["SSE2"]) - -add_insn("vaddpd", "xmm_xmm128_256", modifiers=[0x66, 0x58, VEXL0], avx=True) -add_insn("vandnpd", "xmm_xmm128_256", modifiers=[0x66, 0x55, VEXL0], avx=True) -add_insn("vandpd", "xmm_xmm128_256", modifiers=[0x66, 0x54, VEXL0], avx=True) -# vcvtdq2ps and vcvtps2dq are 2-operand, YMM capable -# vcvtpd2dq and vcvtpd2ps take xmm, ymm combination -add_insn("vdivpd", "xmm_xmm128_256", modifiers=[0x66, 0x5E, VEXL0], avx=True) -add_insn("vmaxpd", "xmm_xmm128_256", modifiers=[0x66, 0x5F, VEXL0], avx=True) -add_insn("vminpd", "xmm_xmm128_256", modifiers=[0x66, 0x5D, VEXL0], avx=True) -add_insn("vmulpd", "xmm_xmm128_256", modifiers=[0x66, 0x59, VEXL0], avx=True) -add_insn("vorpd", "xmm_xmm128_256", modifiers=[0x66, 0x56, VEXL0], avx=True) -# vsqrtpd doesn't add third operand -add_insn("vsubpd", "xmm_xmm128_256", modifiers=[0x66, 0x5C, VEXL0], avx=True) -add_insn("vunpckhpd", "xmm_xmm128_256", modifiers=[0x66, 0x15, VEXL0], avx=True) -add_insn("vunpcklpd", "xmm_xmm128_256", modifiers=[0x66, 0x14, VEXL0], avx=True) -add_insn("vxorpd", "xmm_xmm128_256", modifiers=[0x66, 0x57, VEXL0], avx=True) - -add_group("ssecmp_64", - cpu=["SSE2"], - modifiers=["Imm8", "PreAdd", "SetVEX"], - prefix=0x00, - opcode=[0x0F, 0xC2], - operands=[Operand(type="SIMDReg", size=128, dest="SpareVEX"), - Operand(type="SIMDReg", size=128, dest="EA")]) -add_group("ssecmp_64", - cpu=["SSE2"], - modifiers=["Imm8", "PreAdd", "SetVEX"], - prefix=0x00, - opcode=[0x0F, 0xC2], - operands=[Operand(type="SIMDReg", size=128, dest="SpareVEX"), - Operand(type="Mem", size=64, relaxed=True, dest="EA")]) -add_group("ssecmp_64", - cpu=["AVX"], - modifiers=["Imm8", "PreAdd"], - vex=128, - prefix=0x00, - opcode=[0x0F, 0xC2], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="VEX"), - Operand(type="SIMDReg", size=128, dest="EA")]) -add_group("ssecmp_64", - cpu=["AVX"], - modifiers=["Imm8", "PreAdd"], - vex=128, - prefix=0x00, - opcode=[0x0F, 0xC2], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="VEX"), - Operand(type="Mem", size=64, relaxed=True, dest="EA")]) - -for ib, cc in ssecoms: - add_insn("cmp"+cc+"sd", "ssecmp_64", modifiers=[ib, 0xF2]) - add_insn("cmp"+cc+"pd", "ssecmp_128", modifiers=[ib, 0x66]) - -for ib, cc in avxcoms: - add_insn("vcmp"+cc+"sd", "ssecmp_64", modifiers=[ib, 0xF2, VEXL0], avx=True) - add_insn("vcmp"+cc+"pd", "ssecmp_128", modifiers=[ib, 0x66, VEXL0], avx=True) - -add_insn("cmppd", "xmm_xmm128_imm", modifiers=[0x66, 0xC2], cpu=["SSE2"]) -add_insn("shufpd", "xmm_xmm128_imm", modifiers=[0x66, 0xC6], cpu=["SSE2"]) -add_insn("vcmppd", "xmm_xmm128_imm_256", modifiers=[0x66, 0xC2, VEXL0], avx=True) -add_insn("vshufpd", "xmm_xmm128_imm_256", modifiers=[0x66, 0xC6, VEXL0], avx=True) - -add_insn("cvtsi2sd", "cvt_xmm_rmx", modifiers=[0xF2, 0x2A], cpu=["SSE2"]) -add_insn("vcvtsi2sd", "cvt_xmm_rmx", modifiers=[0xF2, 0x2A, VEXL0], avx=True) - -add_group("cvt_rx_xmm64", - suffix="l", - cpu=["SSE2"], - modifiers=["PreAdd", "Op1Add", "SetVEX"], - prefix=0x00, - opcode=[0x0F, 0x00], - operands=[Operand(type="Reg", size=32, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="EA")]) -add_group("cvt_rx_xmm64", - suffix="l", - cpu=["SSE2"], - modifiers=["PreAdd", "Op1Add", "SetVEX"], - prefix=0x00, - opcode=[0x0F, 0x00], - operands=[Operand(type="Reg", size=32, dest="Spare"), - Operand(type="Mem", size=64, relaxed=True, dest="EA")]) -# REX -add_group("cvt_rx_xmm64", - suffix="q", - cpu=["SSE2"], - modifiers=["PreAdd", "Op1Add", "SetVEX"], - opersize=64, - prefix=0x00, - opcode=[0x0F, 0x00], - operands=[Operand(type="Reg", size=64, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="EA")]) -add_group("cvt_rx_xmm64", - suffix="q", - cpu=["SSE2"], - modifiers=["PreAdd", "Op1Add", "SetVEX"], - opersize=64, - prefix=0x00, - opcode=[0x0F, 0x00], - operands=[Operand(type="Reg", size=64, dest="Spare"), - Operand(type="Mem", size=64, relaxed=True, dest="EA")]) - -add_insn("cvtsd2si", "cvt_rx_xmm64", modifiers=[0xF2, 0x2D]) -add_insn("vcvtsd2si", "cvt_rx_xmm64", modifiers=[0xF2, 0x2D, VEXL0], avx=True) - -add_group("cvt_mm_xmm", - cpu=["SSE2"], - modifiers=["PreAdd", "Op1Add"], - prefix=0x00, - opcode=[0x0F, 0x00], - operands=[Operand(type="SIMDReg", size=64, dest="Spare"), - Operand(type="SIMDRM", size=128, relaxed=True, dest="EA")]) - -add_insn("cvtpd2pi", "cvt_mm_xmm", modifiers=[0x66, 0x2D], cpu=["SSE2"]) - -add_group("cvt_xmm_mm_ss", - cpu=["SSE"], - modifiers=["PreAdd", "Op1Add"], - prefix=0x00, - opcode=[0x0F, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDRM", size=64, relaxed=True, dest="EA")]) - -add_insn("cvtpi2pd", "cvt_xmm_mm_ss", modifiers=[0x66, 0x2A], cpu=["SSE2"]) - -# cmpsd SSE2 form -add_group("cmpsd", - cpu=["SSE2"], - modifiers=["SetVEX"], - prefix=0xF2, - opcode=[0x0F, 0xC2], - operands=[Operand(type="SIMDReg", size=128, dest="SpareVEX"), - Operand(type="SIMDReg", size=128, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) -add_group("cmpsd", - cpu=["SSE2"], - modifiers=["SetVEX"], - prefix=0xF2, - opcode=[0x0F, 0xC2], - operands=[Operand(type="SIMDReg", size=128, dest="SpareVEX"), - Operand(type="Mem", size=64, relaxed=True, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) -add_group("cmpsd", - cpu=["AVX"], - vex=128, - prefix=0xF2, - opcode=[0x0F, 0xC2], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="VEX"), - Operand(type="SIMDReg", size=128, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) -add_group("cmpsd", - cpu=["AVX"], - vex=128, - prefix=0xF2, - opcode=[0x0F, 0xC2], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="VEX"), - Operand(type="Mem", size=64, relaxed=True, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) - -# cmpsd is added in string instructions above, so don't re-add_insn() -add_insn("vcmpsd", "cmpsd", modifiers=[VEXL0], avx=True) - -add_insn("movapd", "movau", modifiers=[0x66, 0x28, 0x01], cpu=["SSE2"]) -add_insn("movupd", "movau", modifiers=[0x66, 0x10, 0x01], cpu=["SSE2"]) -add_insn("vmovapd", "movau", modifiers=[0x66, 0x28, 0x01], avx=True) -add_insn("vmovupd", "movau", modifiers=[0x66, 0x10, 0x01], avx=True) - -add_insn("movhpd", "movhlp", modifiers=[0x66, 0x16], cpu=["SSE2"]) -add_insn("movlpd", "movhlp", modifiers=[0x66, 0x12], cpu=["SSE2"]) -add_insn("vmovhpd", "movhlp", modifiers=[0x66, 0x16, VEXL0], avx=True) -add_insn("vmovlpd", "movhlp", modifiers=[0x66, 0x12, VEXL0], avx=True) - -add_insn("movmskpd", "movmsk", modifiers=[0x66], cpu=["SSE2"]) -add_insn("vmovmskpd", "movmsk", modifiers=[0x66, VEXL0], avx=True) - -add_insn("movntpd", "movnt", modifiers=[0x66, 0x2B], cpu=["SSE2"]) -add_insn("movntdq", "movnt", modifiers=[0x66, 0xE7], cpu=["SSE2"]) -add_insn("vmovntpd", "movnt", modifiers=[0x66, 0x2B, VEXL0], avx=True) -add_insn("vmovntdq", "movnt", modifiers=[0x66, 0xE7, VEXL0], avx=True) - -# movsd SSE2 forms -add_group("movsd", - cpu=["SSE2"], - modifiers=["SetVEX"], - prefix=0xF2, - opcode=[0x0F, 0x10], - operands=[Operand(type="SIMDReg", size=128, dest="SpareVEX"), - Operand(type="SIMDReg", size=128, dest="EA")]) -add_group("movsd", - cpu=["SSE2"], - modifiers=["SetVEX"], - prefix=0xF2, - opcode=[0x0F, 0x10], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="Mem", size=64, relaxed=True, dest="EA")]) -add_group("movsd", - cpu=["SSE2"], - modifiers=["SetVEX"], - prefix=0xF2, - opcode=[0x0F, 0x11], - operands=[Operand(type="Mem", size=64, relaxed=True, dest="EA"), - Operand(type="SIMDReg", size=128, dest="Spare")]) -add_group("movsd", - cpu=["AVX"], - vex=128, - prefix=0xF2, - opcode=[0x0F, 0x10], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="VEX"), - Operand(type="SIMDReg", size=128, dest="EA")]) -# movsd is added in string instructions above, so don't re-add_insn() -add_insn("vmovsd", "movsd", modifiers=[VEXL0], avx=True) - -##################################################################### -# P4 VMX Instructions -##################################################################### - -add_group("eptvpid", - modifiers=["Op2Add"], - suffix="l", - not64=True, - cpu=["EPTVPID"], - opersize=32, - prefix=0x66, - opcode=[0x0F, 0x38, 0x80], - operands=[Operand(type="Reg", size=32, dest="Spare"), - Operand(type="Mem", size=128, relaxed=True, dest="EA")]) -add_group("eptvpid", - modifiers=["Op2Add"], - suffix="q", - cpu=["EPTVPID"], - opersize=64, - prefix=0x66, - opcode=[0x0F, 0x38, 0x80], - operands=[Operand(type="Reg", size=64, dest="Spare"), - Operand(type="Mem", size=128, relaxed=True, dest="EA")]) -add_insn("invept", "eptvpid", modifiers=[0]) -add_insn("invvpid", "eptvpid", modifiers=[1]) - -add_insn("vmcall", "threebyte", modifiers=[0x0F, 0x01, 0xC1], cpu=["P4"]) -add_insn("vmlaunch", "threebyte", modifiers=[0x0F, 0x01, 0xC2], cpu=["P4"]) -add_insn("vmresume", "threebyte", modifiers=[0x0F, 0x01, 0xC3], cpu=["P4"]) -add_insn("vmxoff", "threebyte", modifiers=[0x0F, 0x01, 0xC4], cpu=["P4"]) - -add_group("vmxmemrd", - suffix="l", - not64=True, - cpu=["P4"], - opersize=32, - opcode=[0x0F, 0x78], - operands=[Operand(type="RM", size=32, relaxed=True, dest="EA"), - Operand(type="Reg", size=32, dest="Spare")]) -add_group("vmxmemrd", - suffix="q", - cpu=["P4"], - opersize=64, - def_opersize_64=64, - opcode=[0x0F, 0x78], - operands=[Operand(type="RM", size=64, relaxed=True, dest="EA"), - Operand(type="Reg", size=64, dest="Spare")]) -add_insn("vmread", "vmxmemrd") - -add_group("vmxmemwr", - suffix="l", - not64=True, - cpu=["P4"], - opersize=32, - opcode=[0x0F, 0x79], - operands=[Operand(type="Reg", size=32, dest="Spare"), - Operand(type="RM", size=32, relaxed=True, dest="EA")]) -add_group("vmxmemwr", - suffix="q", - cpu=["P4"], - opersize=64, - def_opersize_64=64, - opcode=[0x0F, 0x79], - operands=[Operand(type="Reg", size=64, dest="Spare"), - Operand(type="RM", size=64, relaxed=True, dest="EA")]) -add_insn("vmwrite", "vmxmemwr") - -add_group("vmxtwobytemem", - modifiers=["SpAdd"], - cpu=["P4"], - opcode=[0x0F, 0xC7], - spare=0, - operands=[Operand(type="Mem", size=64, relaxed=True, dest="EA")]) -add_insn("vmptrld", "vmxtwobytemem", modifiers=[6]) -add_insn("vmptrst", "vmxtwobytemem", modifiers=[7]) - -add_group("vmxthreebytemem", - modifiers=["PreAdd"], - cpu=["P4"], - prefix=0x00, - opcode=[0x0F, 0xC7], - spare=6, - operands=[Operand(type="Mem", size=64, relaxed=True, dest="EA")]) -add_insn("vmclear", "vmxthreebytemem", modifiers=[0x66]) -add_insn("vmxon", "vmxthreebytemem", modifiers=[0xF3]) - -add_insn("endbr32", "fourbyte", modifiers=[0xF3, 0x0F, 0x1E, 0xFB]) -add_insn("endbr64", "fourbyte", modifiers=[0xF3, 0x0F, 0x1E, 0xFA]) - -##################################################################### -# Intel SMX Instructions -##################################################################### -add_insn("getsec", "twobyte", modifiers=[0x0F, 0x37], cpu=["SMX"]) - -add_insn("cvttpd2pi", "cvt_mm_xmm", modifiers=[0x66, 0x2C], cpu=["SSE2"]) -add_insn("cvttsd2si", "cvt_rx_xmm64", modifiers=[0xF2, 0x2C], cpu=["SSE2"]) -add_insn("cvttpd2dq", "xmm_xmm128", modifiers=[0x66, 0xE6], cpu=["SSE2"]) -add_insn("cvttps2dq", "xmm_xmm128", modifiers=[0xF3, 0x5B], cpu=["SSE2"]) -add_insn("pmuludq", "mmxsse2", modifiers=[0xF4], cpu=["SSE2"]) -add_insn("pshufd", "xmm_xmm128_imm", modifiers=[0x66, 0x70], cpu=["SSE2"]) -add_insn("pshufhw", "xmm_xmm128_imm", modifiers=[0xF3, 0x70], cpu=["SSE2"]) -add_insn("pshuflw", "xmm_xmm128_imm", modifiers=[0xF2, 0x70], cpu=["SSE2"]) -add_insn("punpckhqdq", "xmm_xmm128", modifiers=[0x66, 0x6D], cpu=["SSE2"]) -add_insn("punpcklqdq", "xmm_xmm128", modifiers=[0x66, 0x6C], cpu=["SSE2"]) - -add_insn("vcvttsd2si", "cvt_rx_xmm64", modifiers=[0xF2, 0x2C, VEXL0], avx=True) -# vcvttpd2dq takes xmm, ymm combination -# vcvttps2dq is two-operand -add_insn("vpmuludq", "xmm_xmm128_256avx2", modifiers=[0x66, 0xF4, VEXL0], avx=True) -add_insn("vpshufd", "xmm_xmm128_imm_256avx2", modifiers=[0x66, 0x70, VEXL0], avx=True) -add_insn("vpshufhw", "xmm_xmm128_imm_256avx2", modifiers=[0xF3, 0x70, VEXL0], avx=True) -add_insn("vpshuflw", "xmm_xmm128_imm_256avx2", modifiers=[0xF2, 0x70, VEXL0], avx=True) -add_insn("vpunpckhqdq", "xmm_xmm128_256avx2", modifiers=[0x66, 0x6D, VEXL0], avx=True) -add_insn("vpunpcklqdq", "xmm_xmm128_256avx2", modifiers=[0x66, 0x6C, VEXL0], avx=True) - -add_insn("cvtss2sd", "xmm_xmm32", modifiers=[0xF3, 0x5A], cpu=["SSE2"]) -add_insn("vcvtss2sd", "xmm_xmm32", modifiers=[0xF3, 0x5A, VEXL0], avx=True) - -add_group("maskmovdqu", - cpu=["SSE2"], - modifiers=["SetVEX"], - prefix=0x66, - opcode=[0x0F, 0xF7], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="EA")]) - -add_insn("maskmovdqu", "maskmovdqu") -add_insn("vmaskmovdqu", "maskmovdqu", modifiers=[VEXL0], avx=True) - -add_insn("movdqa", "movau", modifiers=[0x66, 0x6F, 0x10], cpu=["SSE2"]) -add_insn("movdqu", "movau", modifiers=[0xF3, 0x6F, 0x10], cpu=["SSE2"]) -add_insn("vmovdqa", "movau", modifiers=[0x66, 0x6F, 0x10], avx=True) -add_insn("vmovdqu", "movau", modifiers=[0xF3, 0x6F, 0x10], avx=True) - -add_group("movdq2q", - cpu=["SSE2"], - prefix=0xF2, - opcode=[0x0F, 0xD6], - operands=[Operand(type="SIMDReg", size=64, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="EA")]) - -add_insn("movdq2q", "movdq2q") - -add_group("movq2dq", - cpu=["SSE2"], - prefix=0xF3, - opcode=[0x0F, 0xD6], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDReg", size=64, dest="EA")]) - -add_insn("movq2dq", "movq2dq") - -add_group("pslrldq", - cpu=["SSE2"], - modifiers=["SpAdd", "SetVEX"], - prefix=0x66, - opcode=[0x0F, 0x73], - spare=0, - operands=[Operand(type="SIMDReg", size=128, dest="EAVEX"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) -add_group("pslrldq", - cpu=["SSE2"], - modifiers=["SpAdd", "SetVEX"], - prefix=0x66, - opcode=[0x0F, 0x73], - spare=0, - operands=[Operand(type="SIMDReg", size=128, dest="VEX"), - Operand(type="SIMDReg", size=128, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) -add_group("pslrldq", - cpu=["AVX2"], - modifiers=["SpAdd"], - vex=256, - prefix=0x66, - opcode=[0x0F, 0x73], - spare=0, - operands=[Operand(type="SIMDReg", size=256, dest="EAVEX"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) -add_group("pslrldq", - cpu=["AVX2"], - modifiers=["SpAdd"], - vex=256, - prefix=0x66, - opcode=[0x0F, 0x73], - spare=0, - operands=[Operand(type="SIMDReg", size=256, dest="VEX"), - Operand(type="SIMDReg", size=256, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) - -add_insn("pslldq", "pslrldq", modifiers=[7]) -add_insn("psrldq", "pslrldq", modifiers=[3]) -add_insn("vpslldq", "pslrldq", modifiers=[7, VEXL0], avx=True) -add_insn("vpsrldq", "pslrldq", modifiers=[3, VEXL0], avx=True) - -##################################################################### -# SSE3 / PNI Prescott New Instructions instructions -##################################################################### -add_insn("addsubpd", "xmm_xmm128", modifiers=[0x66, 0xD0], cpu=["SSE3"]) -add_insn("addsubps", "xmm_xmm128", modifiers=[0xF2, 0xD0], cpu=["SSE3"]) -add_insn("haddpd", "xmm_xmm128", modifiers=[0x66, 0x7C], cpu=["SSE3"]) -add_insn("haddps", "xmm_xmm128", modifiers=[0xF2, 0x7C], cpu=["SSE3"]) -add_insn("hsubpd", "xmm_xmm128", modifiers=[0x66, 0x7D], cpu=["SSE3"]) -add_insn("hsubps", "xmm_xmm128", modifiers=[0xF2, 0x7D], cpu=["SSE3"]) - -add_insn("vaddsubpd", "xmm_xmm128_256", modifiers=[0x66, 0xD0, VEXL0], avx=True) -add_insn("vaddsubps", "xmm_xmm128_256", modifiers=[0xF2, 0xD0, VEXL0], avx=True) -add_insn("vhaddpd", "xmm_xmm128_256", modifiers=[0x66, 0x7C, VEXL0], avx=True) -add_insn("vhaddps", "xmm_xmm128_256", modifiers=[0xF2, 0x7C, VEXL0], avx=True) -add_insn("vhsubpd", "xmm_xmm128_256", modifiers=[0x66, 0x7D, VEXL0], avx=True) -add_insn("vhsubps", "xmm_xmm128_256", modifiers=[0xF2, 0x7D, VEXL0], avx=True) - -add_insn("movshdup", "xmm_xmm128", modifiers=[0xF3, 0x16], cpu=["SSE3"]) -add_insn("movsldup", "xmm_xmm128", modifiers=[0xF3, 0x12], cpu=["SSE3"]) -add_insn("fisttp", "fildstp", modifiers=[1, 0, 1], cpu=["SSE3"]) -add_insn("fisttpll", "fildstp", suffix="q", modifiers=[7], cpu=["SSE3"]) -add_insn("movddup", "xmm_xmm64", modifiers=[0xF2, 0x12], cpu=["SSE3"]) -add_insn("monitor", "threebyte", modifiers=[0x0F, 0x01, 0xC8], cpu=["SSE3"]) -add_insn("mwait", "threebyte", modifiers=[0x0F, 0x01, 0xC9], cpu=["SSE3"]) - -add_group("lddqu", - cpu=["SSE3"], - modifiers=["SetVEX"], - prefix=0xF2, - opcode=[0x0F, 0xF0], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="Mem", size=128, relaxed=True, dest="EA")]) -add_group("lddqu", - cpu=["AVX"], - vex=256, - prefix=0xF2, - opcode=[0x0F, 0xF0], - operands=[Operand(type="SIMDReg", size=256, dest="Spare"), - Operand(type="Mem", size=256, relaxed=True, dest="EA")]) - -add_insn("lddqu", "lddqu") -add_insn("vlddqu", "lddqu", modifiers=[VEXL0], avx=True) - -##################################################################### -# SSSE3 / TNI Tejas New Intructions instructions -##################################################################### - -add_group("ssse3", - cpu=["SSSE3"], - notavx=True, - modifiers=["Op2Add"], - opcode=[0x0F, 0x38, 0x00], - operands=[Operand(type="SIMDReg", size=64, dest="Spare"), - Operand(type="SIMDRM", size=64, relaxed=True, dest="EA")]) -add_group("ssse3", - cpu=["SSSE3"], - modifiers=["Op2Add", "SetVEX"], - prefix=0x66, - opcode=[0x0F, 0x38, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="SpareVEX"), - Operand(type="SIMDRM", size=128, relaxed=True, dest="EA")]) -add_group("ssse3", - cpu=["AVX"], - modifiers=["Op2Add"], - vex=128, - prefix=0x66, - opcode=[0x0F, 0x38, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="VEX"), - Operand(type="SIMDRM", size=128, relaxed=True, dest="EA")]) -add_group("ssse3", - cpu=["AVX2"], - modifiers=["Op2Add"], - vex=256, - prefix=0x66, - opcode=[0x0F, 0x38, 0x00], - operands=[Operand(type="SIMDReg", size=256, dest="SpareVEX"), - Operand(type="SIMDRM", size=256, relaxed=True, dest="EA")]) -add_group("ssse3", - cpu=["AVX2"], - modifiers=["Op2Add"], - vex=256, - prefix=0x66, - opcode=[0x0F, 0x38, 0x00], - operands=[Operand(type="SIMDReg", size=256, dest="Spare"), - Operand(type="SIMDReg", size=256, dest="VEX"), - Operand(type="SIMDRM", size=256, relaxed=True, dest="EA")]) - -add_insn("pshufb", "ssse3", modifiers=[0x00]) -add_insn("phaddw", "ssse3", modifiers=[0x01]) -add_insn("phaddd", "ssse3", modifiers=[0x02]) -add_insn("phaddsw", "ssse3", modifiers=[0x03]) -add_insn("pmaddubsw", "ssse3", modifiers=[0x04]) -add_insn("phsubw", "ssse3", modifiers=[0x05]) -add_insn("phsubd", "ssse3", modifiers=[0x06]) -add_insn("phsubsw", "ssse3", modifiers=[0x07]) -add_insn("psignb", "ssse3", modifiers=[0x08]) -add_insn("psignw", "ssse3", modifiers=[0x09]) -add_insn("psignd", "ssse3", modifiers=[0x0A]) -add_insn("pmulhrsw", "ssse3", modifiers=[0x0B]) -add_insn("pabsb", "ssse3", modifiers=[0x1C]) -add_insn("pabsw", "ssse3", modifiers=[0x1D]) -add_insn("pabsd", "ssse3", modifiers=[0x1E]) - -add_insn("vpshufb", "ssse3", modifiers=[0x00, VEXL0], avx=True) -add_insn("vphaddw", "ssse3", modifiers=[0x01, VEXL0], avx=True) -add_insn("vphaddd", "ssse3", modifiers=[0x02, VEXL0], avx=True) -add_insn("vphaddsw", "ssse3", modifiers=[0x03, VEXL0], avx=True) -add_insn("vpmaddubsw", "ssse3", modifiers=[0x04, VEXL0], avx=True) -add_insn("vphsubw", "ssse3", modifiers=[0x05, VEXL0], avx=True) -add_insn("vphsubd", "ssse3", modifiers=[0x06, VEXL0], avx=True) -add_insn("vphsubsw", "ssse3", modifiers=[0x07, VEXL0], avx=True) -add_insn("vpsignb", "ssse3", modifiers=[0x08, VEXL0], avx=True) -add_insn("vpsignw", "ssse3", modifiers=[0x09, VEXL0], avx=True) -add_insn("vpsignd", "ssse3", modifiers=[0x0A, VEXL0], avx=True) -add_insn("vpmulhrsw", "ssse3", modifiers=[0x0B, VEXL0], avx=True) -# vpabsb/vpabsw/vpabsd are 2 operand only - -add_group("ssse3imm", - cpu=["SSSE3"], - modifiers=["Op2Add"], - opcode=[0x0F, 0x3A, 0x00], - operands=[Operand(type="SIMDReg", size=64, dest="Spare"), - Operand(type="SIMDRM", size=64, relaxed=True, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) -add_group("ssse3imm", - cpu=["SSSE3"], - modifiers=["Op2Add"], - prefix=0x66, - opcode=[0x0F, 0x3A, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDRM", size=128, relaxed=True, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) - -add_insn("palignr", "ssse3imm", modifiers=[0x0F]) -add_insn("vpalignr", "sse4imm_256avx2", modifiers=[0x0F, VEXL0], avx=True) - -##################################################################### -# SSE4.1 / SSE4.2 instructions -##################################################################### - -add_group("sse4", - cpu=["SSE41"], - modifiers=["Op2Add", "SetVEX"], - prefix=0x66, - opcode=[0x0F, 0x38, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDRM", size=128, relaxed=True, dest="EA")]) -add_group("sse4", - cpu=["AVX"], - modifiers=["Op2Add"], - vex=256, - prefix=0x66, - opcode=[0x0F, 0x38, 0x00], - operands=[Operand(type="SIMDReg", size=256, dest="Spare"), - Operand(type="SIMDRM", size=256, relaxed=True, dest="EA")]) - -add_insn("packusdw", "sse4", modifiers=[0x2B]) -add_insn("pcmpeqq", "sse4", modifiers=[0x29]) -add_insn("pcmpgtq", "sse4", modifiers=[0x37]) -add_insn("phminposuw", "sse4", modifiers=[0x41]) -add_insn("pmaxsb", "sse4", modifiers=[0x3C]) -add_insn("pmaxsd", "sse4", modifiers=[0x3D]) -add_insn("pmaxud", "sse4", modifiers=[0x3F]) -add_insn("pmaxuw", "sse4", modifiers=[0x3E]) -add_insn("pminsb", "sse4", modifiers=[0x38]) -add_insn("pminsd", "sse4", modifiers=[0x39]) -add_insn("pminud", "sse4", modifiers=[0x3B]) -add_insn("pminuw", "sse4", modifiers=[0x3A]) -add_insn("pmuldq", "sse4", modifiers=[0x28]) -add_insn("pmulld", "sse4", modifiers=[0x40]) -add_insn("ptest", "sse4", modifiers=[0x17]) - -# AVX versions use ssse3, and disable MMX version, as they're 3-operand -add_insn("vpackusdw", "ssse3", modifiers=[0x2B, VEXL0], avx=True) -add_insn("vpcmpeqq", "ssse3", modifiers=[0x29, VEXL0], avx=True) -add_insn("vpcmpgtq", "ssse3", modifiers=[0x37, VEXL0], avx=True) -# vphminposuw is 2 operand only -add_insn("vpmaxsb", "ssse3", modifiers=[0x3C, VEXL0], avx=True) -add_insn("vpmaxsd", "ssse3", modifiers=[0x3D, VEXL0], avx=True) -add_insn("vpmaxud", "ssse3", modifiers=[0x3F, VEXL0], avx=True) -add_insn("vpmaxuw", "ssse3", modifiers=[0x3E, VEXL0], avx=True) -add_insn("vpminsb", "ssse3", modifiers=[0x38, VEXL0], avx=True) -add_insn("vpminsd", "ssse3", modifiers=[0x39, VEXL0], avx=True) -add_insn("vpminud", "ssse3", modifiers=[0x3B, VEXL0], avx=True) -add_insn("vpminuw", "ssse3", modifiers=[0x3A, VEXL0], avx=True) -add_insn("vpmuldq", "ssse3", modifiers=[0x28, VEXL0], avx=True) -add_insn("vpmulld", "ssse3", modifiers=[0x40, VEXL0], avx=True) -# vptest uses SSE4 style (2 operand only), and takes 256-bit operands -add_insn("vptest", "sse4", modifiers=[0x17, VEXL0], avx=True) - -add_group("sse4imm_256", - cpu=["SSE41"], - modifiers=["Op2Add", "SetVEX"], - prefix=0x66, - opcode=[0x0F, 0x3A, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="SpareVEX"), - Operand(type="SIMDRM", size=128, relaxed=True, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) -add_group("sse4imm_256", - cpu=["AVX"], - modifiers=["Op2Add"], - vex=128, - prefix=0x66, - opcode=[0x0F, 0x3A, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="VEX"), - Operand(type="SIMDRM", size=128, relaxed=True, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) -add_group("sse4imm_256", - cpu=["AVX"], - modifiers=["Op2Add"], - vex=256, - prefix=0x66, - opcode=[0x0F, 0x3A, 0x00], - operands=[Operand(type="SIMDReg", size=256, dest="SpareVEX"), - Operand(type="SIMDRM", size=256, relaxed=True, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) -add_group("sse4imm_256", - cpu=["AVX"], - modifiers=["Op2Add"], - vex=256, - prefix=0x66, - opcode=[0x0F, 0x3A, 0x00], - operands=[Operand(type="SIMDReg", size=256, dest="Spare"), - Operand(type="SIMDReg", size=256, dest="VEX"), - Operand(type="SIMDRM", size=256, relaxed=True, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) - -# Same as above except AVX2 required for 256-bit. -add_group("sse4imm_256avx2", - cpu=["SSE41"], - modifiers=["Op2Add", "SetVEX"], - prefix=0x66, - opcode=[0x0F, 0x3A, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="SpareVEX"), - Operand(type="SIMDRM", size=128, relaxed=True, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) -add_group("sse4imm_256avx2", - cpu=["AVX"], - modifiers=["Op2Add"], - vex=128, - prefix=0x66, - opcode=[0x0F, 0x3A, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="VEX"), - Operand(type="SIMDRM", size=128, relaxed=True, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) -add_group("sse4imm_256avx2", - cpu=["AVX2"], - modifiers=["Op2Add"], - vex=256, - prefix=0x66, - opcode=[0x0F, 0x3A, 0x00], - operands=[Operand(type="SIMDReg", size=256, dest="SpareVEX"), - Operand(type="SIMDRM", size=256, relaxed=True, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) -add_group("sse4imm_256avx2", - cpu=["AVX2"], - modifiers=["Op2Add"], - vex=256, - prefix=0x66, - opcode=[0x0F, 0x3A, 0x00], - operands=[Operand(type="SIMDReg", size=256, dest="Spare"), - Operand(type="SIMDReg", size=256, dest="VEX"), - Operand(type="SIMDRM", size=256, relaxed=True, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) - -# Version that does not allow YMM registers -add_group("sse4imm", - cpu=["SSE41"], - modifiers=["Op2Add", "SetVEX"], - prefix=0x66, - opcode=[0x0F, 0x3A, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="SpareVEX"), - Operand(type="SIMDRM", size=128, relaxed=True, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) -add_group("sse4imm", - cpu=["AVX"], - modifiers=["Op2Add"], - vex=128, - prefix=0x66, - opcode=[0x0F, 0x3A, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="VEX"), - Operand(type="SIMDRM", size=128, relaxed=True, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) - -for sz in [32, 64]: - add_group("sse4m%dimm" % sz, - cpu=["SSE41"], - modifiers=["Op2Add", "SetVEX"], - prefix=0x66, - opcode=[0x0F, 0x3A, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="SpareVEX"), - Operand(type="SIMDReg", size=128, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) - add_group("sse4m%dimm" % sz, - cpu=["SSE41"], - modifiers=["Op2Add", "SetVEX"], - prefix=0x66, - opcode=[0x0F, 0x3A, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="SpareVEX"), - Operand(type="Mem", size=sz, relaxed=True, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) - add_group("sse4m%dimm" % sz, - cpu=["AVX"], - modifiers=["Op2Add"], - vex=128, - prefix=0x66, - opcode=[0x0F, 0x3A, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="VEX"), - Operand(type="SIMDReg", size=128, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) - add_group("sse4m%dimm" % sz, - cpu=["AVX"], - modifiers=["Op2Add"], - vex=128, - prefix=0x66, - opcode=[0x0F, 0x3A, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="VEX"), - Operand(type="Mem", size=sz, relaxed=True, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) - -add_insn("blendpd", "sse4imm", modifiers=[0x0D]) -add_insn("blendps", "sse4imm", modifiers=[0x0C]) -add_insn("dppd", "sse4imm", modifiers=[0x41]) -add_insn("dpps", "sse4imm", modifiers=[0x40]) -add_insn("mpsadbw", "sse4imm", modifiers=[0x42]) -add_insn("pblendw", "sse4imm", modifiers=[0x0E]) -add_insn("roundpd", "sse4imm", modifiers=[0x09]) -add_insn("roundps", "sse4imm", modifiers=[0x08]) -add_insn("roundsd", "sse4m64imm", modifiers=[0x0B]) -add_insn("roundss", "sse4m32imm", modifiers=[0x0A]) - -# vdppd does not allow YMM registers -# vmpsadbw and vpblendw do not allow YMM registers unless AVX2 -add_insn("vblendpd", "sse4imm_256", modifiers=[0x0D, VEXL0], avx=True) -add_insn("vblendps", "sse4imm_256", modifiers=[0x0C, VEXL0], avx=True) -add_insn("vdppd", "sse4imm", modifiers=[0x41, VEXL0], avx=True) -add_insn("vdpps", "sse4imm_256", modifiers=[0x40, VEXL0], avx=True) -add_insn("vmpsadbw", "sse4imm_256avx2", modifiers=[0x42, VEXL0], avx=True) -add_insn("vpblendw", "sse4imm_256avx2", modifiers=[0x0E, VEXL0], avx=True) -# vroundpd and vroundps don't add another register operand -add_insn("vroundsd", "sse4m64imm", modifiers=[0x0B, VEXL0], avx=True) -add_insn("vroundss", "sse4m32imm", modifiers=[0x0A, VEXL0], avx=True) - -add_group("sse4xmm0", - cpu=["SSE41"], - modifiers=["Op2Add"], - prefix=0x66, - opcode=[0x0F, 0x38, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDRM", size=128, relaxed=True, dest="EA")]) -add_group("sse4xmm0", - cpu=["SSE41"], - modifiers=["Op2Add"], - prefix=0x66, - opcode=[0x0F, 0x38, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDRM", size=128, relaxed=True, dest="EA"), - Operand(type="XMM0", size=128, dest=None)]) - -add_insn("blendvpd", "sse4xmm0", modifiers=[0x15]) -add_insn("blendvps", "sse4xmm0", modifiers=[0x14]) -add_insn("pblendvb", "sse4xmm0", modifiers=[0x10]) - -# implicit XMM0 can't be VEX-encoded -add_group("avx_sse4xmm0", - cpu=["AVX"], - modifiers=["Op2Add"], - vex=128, - prefix=0x66, - opcode=[0x0F, 0x3A, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="VEX"), - Operand(type="SIMDRM", size=128, relaxed=True, dest="EA"), - Operand(type="SIMDReg", size=128, dest="VEXImmSrc")]) -add_group("avx_sse4xmm0", - cpu=["AVX"], - modifiers=["Op2Add"], - vex=256, - prefix=0x66, - opcode=[0x0F, 0x3A, 0x00], - operands=[Operand(type="SIMDReg", size=256, dest="Spare"), - Operand(type="SIMDReg", size=256, dest="VEX"), - Operand(type="SIMDRM", size=256, relaxed=True, dest="EA"), - Operand(type="SIMDReg", size=256, dest="VEXImmSrc")]) - -add_insn("vblendvpd", "avx_sse4xmm0", modifiers=[0x4B]) -add_insn("vblendvps", "avx_sse4xmm0", modifiers=[0x4A]) - -# vpblendvb didn't have a 256-bit form until AVX2 -add_group("avx2_sse4xmm0", - cpu=["AVX"], - modifiers=["Op2Add"], - vex=128, - prefix=0x66, - opcode=[0x0F, 0x3A, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="VEX"), - Operand(type="SIMDRM", size=128, relaxed=True, dest="EA"), - Operand(type="SIMDReg", size=128, dest="VEXImmSrc")]) -add_group("avx2_sse4xmm0", - cpu=["AVX2"], - modifiers=["Op2Add"], - vex=256, - prefix=0x66, - opcode=[0x0F, 0x3A, 0x00], - operands=[Operand(type="SIMDReg", size=256, dest="Spare"), - Operand(type="SIMDReg", size=256, dest="VEX"), - Operand(type="SIMDRM", size=256, relaxed=True, dest="EA"), - Operand(type="SIMDReg", size=256, dest="VEXImmSrc")]) - -add_insn("vpblendvb", "avx2_sse4xmm0", modifiers=[0x4C]) - -for sfx, sz in zip("bwl", [8, 16, 32]): - add_group("crc32", - suffix=sfx, - cpu=["SSE42"], - opersize=sz, - prefix=0xF2, - opcode=[0x0F, 0x38, 0xF0+(sz!=8)], - operands=[Operand(type="Reg", size=32, dest="Spare"), - Operand(type="RM", size=sz, relaxed=(sz==32), dest="EA")]) -for sfx, sz in zip("bq", [8, 64]): - add_group("crc32", - suffix=sfx, - cpu=["SSE42"], - opersize=64, - prefix=0xF2, - opcode=[0x0F, 0x38, 0xF0+(sz!=8)], - operands=[Operand(type="Reg", size=64, dest="Spare"), - Operand(type="RM", size=sz, relaxed=(sz==64), dest="EA")]) - -add_insn("crc32", "crc32") - -add_group("extractps", - cpu=["SSE41"], - modifiers=["SetVEX"], - prefix=0x66, - opcode=[0x0F, 0x3A, 0x17], - operands=[Operand(type="RM", size=32, relaxed=True, dest="EA"), - Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) -add_group("extractps", - cpu=["SSE41"], - modifiers=["SetVEX"], - opersize=64, - prefix=0x66, - opcode=[0x0F, 0x3A, 0x17], - operands=[Operand(type="Reg", size=64, dest="EA"), - Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) - -add_insn("extractps", "extractps") -add_insn("vextractps", "extractps", modifiers=[VEXL0], avx=True) - -add_group("insertps", - cpu=["SSE41"], - modifiers=["SetVEX"], - prefix=0x66, - opcode=[0x0F, 0x3A, 0x21], - operands=[Operand(type="SIMDReg", size=128, dest="SpareVEX"), - Operand(type="Mem", size=32, relaxed=True, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) -add_group("insertps", - cpu=["SSE41"], - modifiers=["SetVEX"], - prefix=0x66, - opcode=[0x0F, 0x3A, 0x21], - operands=[Operand(type="SIMDReg", size=128, dest="SpareVEX"), - Operand(type="SIMDReg", size=128, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) -add_group("insertps", - cpu=["AVX"], - vex=128, - prefix=0x66, - opcode=[0x0F, 0x3A, 0x21], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="VEX"), - Operand(type="Mem", size=32, relaxed=True, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) -add_group("insertps", - cpu=["AVX"], - vex=128, - prefix=0x66, - opcode=[0x0F, 0x3A, 0x21], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="VEX"), - Operand(type="SIMDReg", size=128, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) - -add_insn("insertps", "insertps") -add_insn("vinsertps", "insertps", modifiers=[VEXL0], avx=True) - -add_group("movntdqa", - cpu=["SSE41"], - modifiers=["SetVEX"], - prefix=0x66, - opcode=[0x0F, 0x38, 0x2A], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="Mem", size=128, relaxed=True, dest="EA")]) -add_group("movntdqa", - cpu=["AVX2"], - vex=256, - prefix=0x66, - opcode=[0x0F, 0x38, 0x2A], - operands=[Operand(type="SIMDReg", size=256, dest="Spare"), - Operand(type="Mem", size=256, relaxed=True, dest="EA")]) - -add_insn("movntdqa", "movntdqa") -add_insn("vmovntdqa", "movntdqa", modifiers=[VEXL0], avx=True) - -add_group("sse4pcmpstr", - cpu=["SSE42"], - modifiers=["Op2Add", "SetVEX"], - prefix=0x66, - opcode=[0x0F, 0x3A, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDRM", size=128, relaxed=True, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) - -add_insn("pcmpestri", "sse4pcmpstr", modifiers=[0x61]) -add_insn("pcmpestrm", "sse4pcmpstr", modifiers=[0x60]) -add_insn("pcmpistri", "sse4pcmpstr", modifiers=[0x63]) -add_insn("pcmpistrm", "sse4pcmpstr", modifiers=[0x62]) - -add_insn("vpcmpestri", "sse4pcmpstr", modifiers=[0x61, VEXL0], avx=True) -add_insn("vpcmpestrm", "sse4pcmpstr", modifiers=[0x60, VEXL0], avx=True) -add_insn("vpcmpistri", "sse4pcmpstr", modifiers=[0x63, VEXL0], avx=True) -add_insn("vpcmpistrm", "sse4pcmpstr", modifiers=[0x62, VEXL0], avx=True) - -add_group("pextrb", - cpu=["SSE41"], - modifiers=["SetVEX"], - prefix=0x66, - opcode=[0x0F, 0x3A, 0x14], - operands=[Operand(type="Mem", size=8, relaxed=True, dest="EA"), - Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) -add_group("pextrb", - cpu=["SSE41"], - modifiers=["SetVEX"], - prefix=0x66, - opcode=[0x0F, 0x3A, 0x14], - operands=[Operand(type="Reg", size=32, dest="EA"), - Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) -add_group("pextrb", - cpu=["SSE41"], - modifiers=["SetVEX"], - opersize=64, - prefix=0x66, - opcode=[0x0F, 0x3A, 0x14], - operands=[Operand(type="Reg", size=64, dest="EA"), - Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) - -add_insn("pextrb", "pextrb") -add_insn("vpextrb", "pextrb", modifiers=[VEXL0], avx=True) - -add_group("pextrd", - cpu=["SSE41"], - modifiers=["SetVEX"], - prefix=0x66, - opcode=[0x0F, 0x3A, 0x16], - operands=[Operand(type="RM", size=32, relaxed=True, dest="EA"), - Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) - -add_insn("pextrd", "pextrd") -add_insn("vpextrd", "pextrd", modifiers=[VEXL0], avx=True) - -add_group("pextrq", - cpu=["SSE41"], - modifiers=["SetVEX"], - opersize=64, - prefix=0x66, - opcode=[0x0F, 0x3A, 0x16], - operands=[Operand(type="RM", size=64, relaxed=True, dest="EA"), - Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) - -add_insn("pextrq", "pextrq") -add_insn("vpextrq", "pextrq", modifiers=[VEXL0], avx=True) - -add_group("pinsrb", - cpu=["SSE41"], - modifiers=["SetVEX"], - prefix=0x66, - opcode=[0x0F, 0x3A, 0x20], - operands=[Operand(type="SIMDReg", size=128, dest="SpareVEX"), - Operand(type="Mem", size=8, relaxed=True, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) -add_group("pinsrb", - cpu=["SSE41"], - modifiers=["SetVEX"], - prefix=0x66, - opcode=[0x0F, 0x3A, 0x20], - operands=[Operand(type="SIMDReg", size=128, dest="SpareVEX"), - Operand(type="Reg", size=32, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) -add_group("pinsrb", - cpu=["AVX"], - vex=128, - prefix=0x66, - opcode=[0x0F, 0x3A, 0x20], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="VEX"), - Operand(type="Mem", size=8, relaxed=True, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) -add_group("pinsrb", - cpu=["AVX"], - vex=128, - prefix=0x66, - opcode=[0x0F, 0x3A, 0x20], - operands=[Operand(type="SIMDReg", size=128, dest="SpareVEX"), - Operand(type="SIMDReg", size=128, dest="VEX"), - Operand(type="Reg", size=32, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) - -add_insn("pinsrb", "pinsrb") -add_insn("vpinsrb", "pinsrb", modifiers=[VEXL0], avx=True) - -add_group("pinsrd", - cpu=["SSE41"], - modifiers=["SetVEX"], - prefix=0x66, - opcode=[0x0F, 0x3A, 0x22], - operands=[Operand(type="SIMDReg", size=128, dest="SpareVEX"), - Operand(type="RM", size=32, relaxed=True, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) -add_group("pinsrd", - cpu=["AVX"], - vex=128, - prefix=0x66, - opcode=[0x0F, 0x3A, 0x22], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="VEX"), - Operand(type="RM", size=32, relaxed=True, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) - -add_insn("pinsrd", "pinsrd") -add_insn("vpinsrd", "pinsrd", modifiers=[VEXL0], avx=True) - -add_group("pinsrq", - cpu=["SSE41"], - modifiers=["SetVEX"], - opersize=64, - prefix=0x66, - opcode=[0x0F, 0x3A, 0x22], - operands=[Operand(type="SIMDReg", size=128, dest="SpareVEX"), - Operand(type="RM", size=64, relaxed=True, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) -add_group("pinsrq", - cpu=["AVX"], - vex=128, - opersize=64, - prefix=0x66, - opcode=[0x0F, 0x3A, 0x22], - operands=[Operand(type="SIMDReg", size=128, dest="SpareVEX"), - Operand(type="SIMDReg", size=128, dest="VEX"), - Operand(type="RM", size=64, relaxed=True, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) - -add_insn("pinsrq", "pinsrq") -add_insn("vpinsrq", "pinsrq", modifiers=[VEXL0], avx=True) - -for sz in [16, 32, 64]: - add_group("sse4m%d" % sz, - cpu=["SSE41"], - modifiers=["Op2Add", "SetVEX"], - prefix=0x66, - opcode=[0x0F, 0x38, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="Mem", size=sz, relaxed=True, dest="EA")]) - add_group("sse4m%d" % sz, - cpu=["SSE41"], - modifiers=["Op2Add", "SetVEX"], - prefix=0x66, - opcode=[0x0F, 0x38, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="EA")]) - add_group("sse4m%d" % sz, - cpu=["AVX2"], - modifiers=["Op2Add"], - vex=256, - prefix=0x66, - opcode=[0x0F, 0x38, 0x00], - operands=[Operand(type="SIMDReg", size=256, dest="Spare"), - Operand(type="Mem", size=sz*2, relaxed=True, dest="EA")]) - add_group("sse4m%d" % sz, - cpu=["AVX2"], - modifiers=["Op2Add"], - vex=256, - prefix=0x66, - opcode=[0x0F, 0x38, 0x00], - operands=[Operand(type="SIMDReg", size=256, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="EA")]) - -add_insn("pmovsxbw", "sse4m64", modifiers=[0x20]) -add_insn("pmovsxwd", "sse4m64", modifiers=[0x23]) -add_insn("pmovsxdq", "sse4m64", modifiers=[0x25]) -add_insn("pmovzxbw", "sse4m64", modifiers=[0x30]) -add_insn("pmovzxwd", "sse4m64", modifiers=[0x33]) -add_insn("pmovzxdq", "sse4m64", modifiers=[0x35]) - -add_insn("vpmovsxbw", "sse4m64", modifiers=[0x20, VEXL0], avx=True) -add_insn("vpmovsxwd", "sse4m64", modifiers=[0x23, VEXL0], avx=True) -add_insn("vpmovsxdq", "sse4m64", modifiers=[0x25, VEXL0], avx=True) -add_insn("vpmovzxbw", "sse4m64", modifiers=[0x30, VEXL0], avx=True) -add_insn("vpmovzxwd", "sse4m64", modifiers=[0x33, VEXL0], avx=True) -add_insn("vpmovzxdq", "sse4m64", modifiers=[0x35, VEXL0], avx=True) - -add_insn("pmovsxbd", "sse4m32", modifiers=[0x21]) -add_insn("pmovsxwq", "sse4m32", modifiers=[0x24]) -add_insn("pmovzxbd", "sse4m32", modifiers=[0x31]) -add_insn("pmovzxwq", "sse4m32", modifiers=[0x34]) - -add_insn("vpmovsxbd", "sse4m32", modifiers=[0x21, VEXL0], avx=True) -add_insn("vpmovsxwq", "sse4m32", modifiers=[0x24, VEXL0], avx=True) -add_insn("vpmovzxbd", "sse4m32", modifiers=[0x31, VEXL0], avx=True) -add_insn("vpmovzxwq", "sse4m32", modifiers=[0x34, VEXL0], avx=True) - -add_insn("pmovsxbq", "sse4m16", modifiers=[0x22]) -add_insn("pmovzxbq", "sse4m16", modifiers=[0x32]) - -add_insn("vpmovsxbq", "sse4m16", modifiers=[0x22, VEXL0], avx=True) -add_insn("vpmovzxbq", "sse4m16", modifiers=[0x32, VEXL0], avx=True) - -for sfx, sz in zip("wlq", [16, 32, 64]): - add_group("cnt", - suffix=sfx, - modifiers=["Op1Add"], - opersize=sz, - prefix=0xF3, - opcode=[0x0F, 0x00], - operands=[Operand(type="Reg", size=sz, dest="Spare"), - Operand(type="RM", size=sz, relaxed=True, dest="EA")]) - -add_insn("popcnt", "cnt", modifiers=[0xB8], cpu=["SSE42"]) - -##################################################################### -# Intel AVX instructions -##################################################################### - -# Most AVX instructions are mixed in with above SSEx groups. -# Some make more sense to have separate groups due to naming conflicts -# that the v-named versions don't have to deal with. -add_group("vmovd", - cpu=["AVX"], - vex=128, - prefix=0x66, - opcode=[0x0F, 0x6E], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="RM", size=32, relaxed=True, dest="EA")]) -add_group("vmovd", - cpu=["AVX"], - vex=128, - prefix=0x66, - opcode=[0x0F, 0x7E], - operands=[Operand(type="RM", size=32, relaxed=True, dest="EA"), - Operand(type="SIMDReg", size=128, dest="Spare")]) - -add_insn("vmovd", "vmovd") - -add_group("vmovq", - cpu=["AVX"], - vex=128, - prefix=0xF3, - opcode=[0x0F, 0x7E], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="EA")]) -add_group("vmovq", - cpu=["AVX"], - vex=128, - prefix=0xF3, - opcode=[0x0F, 0x7E], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="Mem", size=64, relaxed=True, dest="EA")]) -add_group("vmovq", - cpu=["AVX"], - vex=128, - prefix=0x66, - opcode=[0x0F, 0xD6], - operands=[Operand(type="Mem", size=64, relaxed=True, dest="EA"), - Operand(type="SIMDReg", size=128, dest="Spare")]) -add_group("vmovq", - cpu=["AVX"], - vex=128, - opersize=64, - prefix=0x66, - opcode=[0x0F, 0x6E], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="RM", size=64, relaxed=True, dest="EA")]) -add_group("vmovq", - cpu=["AVX"], - vex=128, - opersize=64, - prefix=0x66, - opcode=[0x0F, 0x7E], - operands=[Operand(type="RM", size=64, relaxed=True, dest="EA"), - Operand(type="SIMDReg", size=128, dest="Spare")]) - -add_insn("vmovq", "vmovq") - -# Some AVX variants don't add third operand -add_group("avx_xmm_xmm128", - cpu=["AVX"], - modifiers=["PreAdd", "Op1Add"], - vex=128, - prefix=0x00, - opcode=[0x0F, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDRM", size=128, relaxed=True, dest="EA")]) -add_group("avx_xmm_xmm128", - cpu=["AVX"], - modifiers=["PreAdd", "Op1Add"], - vex=256, - prefix=0x00, - opcode=[0x0F, 0x00], - operands=[Operand(type="SIMDReg", size=256, dest="Spare"), - Operand(type="SIMDRM", size=256, relaxed=True, dest="EA")]) - -add_insn("vmovshdup", "avx_xmm_xmm128", modifiers=[0xF3, 0x16]) -add_insn("vmovsldup", "avx_xmm_xmm128", modifiers=[0xF3, 0x12]) -add_insn("vrcpps", "avx_xmm_xmm128", modifiers=[0, 0x53]) -add_insn("vrsqrtps", "avx_xmm_xmm128", modifiers=[0, 0x52]) -add_insn("vsqrtps", "avx_xmm_xmm128", modifiers=[0, 0x51]) -add_insn("vsqrtpd", "avx_xmm_xmm128", modifiers=[0x66, 0x51]) -add_insn("vcvtdq2ps", "avx_xmm_xmm128", modifiers=[0, 0x5B]) -add_insn("vcvtps2dq", "avx_xmm_xmm128", modifiers=[0x66, 0x5B]) -add_insn("vcvttps2dq", "avx_xmm_xmm128", modifiers=[0xF3, 0x5B]) - -add_group("avx_sse4imm", - cpu=["SSE41"], - modifiers=["Op2Add"], - vex=128, - prefix=0x66, - opcode=[0x0F, 0x3A, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDRM", size=128, relaxed=True, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) -add_group("avx_sse4imm", - cpu=["AVX"], - modifiers=["Op2Add"], - vex=128, - prefix=0x66, - opcode=[0x0F, 0x3A, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDRM", size=128, relaxed=True, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) -add_group("avx_sse4imm", - cpu=["AVX"], - modifiers=["Op2Add"], - vex=256, - prefix=0x66, - opcode=[0x0F, 0x3A, 0x00], - operands=[Operand(type="SIMDReg", size=256, dest="Spare"), - Operand(type="SIMDRM", size=256, relaxed=True, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) - -add_insn("vroundpd", "avx_sse4imm", modifiers=[0x09]) -add_insn("vroundps", "avx_sse4imm", modifiers=[0x08]) - -add_group("vmovddup", - cpu=["AVX"], - modifiers=["PreAdd", "Op1Add"], - vex=128, - prefix=0x00, - opcode=[0x0F, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="EA")]) -add_group("vmovddup", - cpu=["AVX"], - modifiers=["PreAdd", "Op1Add"], - vex=128, - prefix=0x00, - opcode=[0x0F, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="Mem", size=64, relaxed=True, dest="EA")]) -add_group("vmovddup", - cpu=["AVX"], - modifiers=["PreAdd", "Op1Add"], - vex=256, - prefix=0x00, - opcode=[0x0F, 0x00], - operands=[Operand(type="SIMDReg", size=256, dest="Spare"), - Operand(type="SIMDRM", size=256, relaxed=True, dest="EA")]) - -add_insn("vmovddup", "vmovddup", modifiers=[0xF2, 0x12]) - -# Some xmm_xmm64 combinations only take two operands in AVX -# (VEX.vvvv must be 1111b) -add_group("avx_xmm_xmm64", - cpu=["SSE2"], - modifiers=["PreAdd", "Op1Add"], - vex=128, - prefix=0x00, - opcode=[0x0F, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="EA")]) -add_group("avx_xmm_xmm64", - cpu=["SSE2"], - modifiers=["PreAdd", "Op1Add"], - vex=128, - prefix=0x00, - opcode=[0x0F, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="Mem", size=64, relaxed=True, dest="EA")]) - -add_insn("vcomisd", "avx_xmm_xmm64", modifiers=[0x66, 0x2F], avx=True) -add_insn("vucomisd", "avx_xmm_xmm64", modifiers=[0x66, 0x2E], avx=True) - -# Some xmm_xmm64 combinations only take two operands in AVX -# (VEX.vvvv must be 1111b) -add_group("avx_xmm_xmm32", - cpu=["SSE"], - modifiers=["PreAdd", "Op1Add"], - vex=128, - prefix=0x00, - opcode=[0x0F, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="EA")]) -add_group("avx_xmm_xmm32", - cpu=["SSE"], - modifiers=["PreAdd", "Op1Add"], - vex=128, - prefix=0x00, - opcode=[0x0F, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="Mem", size=32, relaxed=True, dest="EA")]) - -add_insn("vcomiss", "avx_xmm_xmm32", modifiers=[0, 0x2F], avx=True) -add_insn("vucomiss", "avx_xmm_xmm32", modifiers=[0, 0x2E], avx=True) - -# Some conversion functions take ymm, xmm combination -add_group("avx_cvt_xmm64", - cpu=["AVX"], - modifiers=["PreAdd", "Op1Add"], - vex=128, - prefix=0x00, - opcode=[0x0F, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="EA")]) -add_group("avx_cvt_xmm64", - cpu=["AVX"], - modifiers=["PreAdd", "Op1Add"], - vex=128, - prefix=0x00, - opcode=[0x0F, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="Mem", size=64, relaxed=True, dest="EA")]) -add_group("avx_cvt_xmm64", - cpu=["AVX"], - modifiers=["PreAdd", "Op1Add"], - vex=256, - prefix=0x00, - opcode=[0x0F, 0x00], - operands=[Operand(type="SIMDReg", size=256, dest="Spare"), - Operand(type="SIMDRM", size=128, relaxed=True, dest="EA")]) - -add_insn("vcvtdq2pd", "avx_cvt_xmm64", modifiers=[0xF3, 0xE6]) -add_insn("vcvtps2pd", "avx_cvt_xmm64", modifiers=[0, 0x5A]) - -# Some SSE3 opcodes are only two operand in AVX -# (VEX.vvvv must be 1111b) -add_group("avx_ssse3_2op", - cpu=["AVX"], - modifiers=["Op2Add"], - vex=128, - prefix=0x66, - opcode=[0x0F, 0x38, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDRM", size=128, relaxed=True, dest="EA")]) -add_insn("vphminposuw", "avx_ssse3_2op", modifiers=[0x41], avx=True) - -# VPABS* are extended to 256-bit in AVX2 -for cpu, sz in zip(["AVX", "AVX2"], [128, 256]): - add_group("avx2_ssse3_2op", - cpu=[cpu], - modifiers=["Op2Add"], - vex=sz, - prefix=0x66, - opcode=[0x0F, 0x38, 0x00], - operands=[Operand(type="SIMDReg", size=sz, dest="Spare"), - Operand(type="SIMDRM", size=sz, relaxed=True, dest="EA")]) -add_insn("vpabsb", "avx2_ssse3_2op", modifiers=[0x1C], avx=True) -add_insn("vpabsw", "avx2_ssse3_2op", modifiers=[0x1D], avx=True) -add_insn("vpabsd", "avx2_ssse3_2op", modifiers=[0x1E], avx=True) - -# Some conversion functions take xmm, ymm combination -# Need separate x and y versions for gas mode -add_group("avx_cvt_xmm128_x", - cpu=["AVX"], - modifiers=["PreAdd", "Op1Add"], - vex=128, - prefix=0x00, - opcode=[0x0F, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDRM", size=128, relaxed=True, dest="EA")]) -add_group("avx_cvt_xmm128_y", - cpu=["AVX"], - modifiers=["PreAdd", "Op1Add"], - vex=256, - prefix=0x00, - opcode=[0x0F, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDRM", size=256, relaxed=True, dest="EA")]) - -add_group("avx_cvt_xmm128", - cpu=["AVX"], - modifiers=["PreAdd", "Op1Add"], - vex=128, - prefix=0x00, - opcode=[0x0F, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDRM", size=128, dest="EA")]) -add_group("avx_cvt_xmm128", - cpu=["AVX"], - modifiers=["PreAdd", "Op1Add"], - vex=256, - prefix=0x00, - opcode=[0x0F, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDRM", size=256, dest="EA")]) - -add_insn("vcvtpd2dqx", "avx_cvt_xmm128_x", modifiers=[0xF2, 0xE6], parser="gas") -add_insn("vcvtpd2dqy", "avx_cvt_xmm128_y", modifiers=[0xF2, 0xE6], parser="gas") -add_insn("vcvtpd2dq", "avx_cvt_xmm128", modifiers=[0xF2, 0xE6]) - -add_insn("vcvtpd2psx", "avx_cvt_xmm128_x", modifiers=[0x66, 0x5A], parser="gas") -add_insn("vcvtpd2psy", "avx_cvt_xmm128_y", modifiers=[0x66, 0x5A], parser="gas") -add_insn("vcvtpd2ps", "avx_cvt_xmm128", modifiers=[0x66, 0x5A]) - -add_insn("vcvttpd2dqx", "avx_cvt_xmm128_x", modifiers=[0x66, 0xE6], parser="gas") -add_insn("vcvttpd2dqy", "avx_cvt_xmm128_y", modifiers=[0x66, 0xE6], parser="gas") -add_insn("vcvttpd2dq", "avx_cvt_xmm128", modifiers=[0x66, 0xE6]) - -# Instructions new to AVX -add_insn("vtestps", "sse4", modifiers=[0x0E, VEXL0], avx=True) -add_insn("vtestpd", "sse4", modifiers=[0x0F, VEXL0], avx=True) - -add_group("vbroadcastss", - cpu=["AVX"], - vex=128, - prefix=0x66, - opcode=[0x0F, 0x38, 0x18], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="Mem", size=32, relaxed=True, dest="EA")]) -add_group("vbroadcastss", - cpu=["AVX"], - vex=256, - prefix=0x66, - opcode=[0x0F, 0x38, 0x18], - operands=[Operand(type="SIMDReg", size=256, dest="Spare"), - Operand(type="Mem", size=32, relaxed=True, dest="EA")]) -add_group("vbroadcastss", - cpu=["AVX2"], - vex=128, - prefix=0x66, - opcode=[0x0F, 0x38, 0x18], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="EA")]) -add_group("vbroadcastss", - cpu=["AVX2"], - vex=256, - prefix=0x66, - opcode=[0x0F, 0x38, 0x18], - operands=[Operand(type="SIMDReg", size=256, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="EA")]) - -add_insn("vbroadcastss", "vbroadcastss") - -add_group("vbroadcastsd", - cpu=["AVX"], - vex=256, - prefix=0x66, - opcode=[0x0F, 0x38, 0x19], - operands=[Operand(type="SIMDReg", size=256, dest="Spare"), - Operand(type="Mem", size=64, relaxed=True, dest="EA")]) -add_group("vbroadcastsd", - cpu=["AVX2"], - vex=256, - prefix=0x66, - opcode=[0x0F, 0x38, 0x19], - operands=[Operand(type="SIMDReg", size=256, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="EA")]) - -add_insn("vbroadcastsd", "vbroadcastsd") - -add_group("vbroadcastif128", - modifiers=["Op2Add"], - vex=256, - prefix=0x66, - opcode=[0x0F, 0x38, 0x00], - operands=[Operand(type="SIMDReg", size=256, dest="Spare"), - Operand(type="Mem", size=128, relaxed=True, dest="EA")]) - -add_insn("vbroadcastf128", "vbroadcastif128", modifiers=[0x1A], cpu=["AVX"]) -add_insn("vbroadcasti128", "vbroadcastif128", modifiers=[0x5A], cpu=["AVX2"]) - -add_group("vextractif128", - modifiers=["Op2Add"], - vex=256, - prefix=0x66, - opcode=[0x0F, 0x3A, 0x00], - operands=[Operand(type="SIMDRM", size=128, relaxed=True, dest="EA"), - Operand(type="SIMDReg", size=256, dest="Spare"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) - -add_insn("vextractf128", "vextractif128", modifiers=[0x19], cpu=["AVX"]) -add_insn("vextracti128", "vextractif128", modifiers=[0x39], cpu=["AVX2"]) - -add_group("vinsertif128", - modifiers=["Op2Add"], - vex=256, - prefix=0x66, - opcode=[0x0F, 0x3A, 0x00], - operands=[Operand(type="SIMDReg", size=256, dest="Spare"), - Operand(type="SIMDReg", size=256, dest="VEX"), - Operand(type="SIMDRM", size=128, relaxed=True, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) - -add_insn("vinsertf128", "vinsertif128", modifiers=[0x18], cpu=["AVX"]) -add_insn("vinserti128", "vinsertif128", modifiers=[0x38], cpu=["AVX2"]) - -add_group("vzero", - cpu=["AVX"], - modifiers=["SetVEX"], - opcode=[0x0F, 0x77], - operands=[]) - -add_insn("vzeroall", "vzero", modifiers=[VEXL1]) -add_insn("vzeroupper", "vzero", modifiers=[VEXL0]) - -add_group("vmaskmov", - modifiers=["Op2Add"], - vex=128, - prefix=0x66, - opcode=[0x0F, 0x38, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="VEX"), - Operand(type="SIMDRM", size=128, relaxed=True, dest="EA")]) -add_group("vmaskmov", - modifiers=["Op2Add"], - vex=256, - prefix=0x66, - opcode=[0x0F, 0x38, 0x00], - operands=[Operand(type="SIMDReg", size=256, dest="Spare"), - Operand(type="SIMDReg", size=256, dest="VEX"), - Operand(type="SIMDRM", size=256, relaxed=True, dest="EA")]) -add_group("vmaskmov", - modifiers=["Op2Add"], - vex=128, - prefix=0x66, - opcode=[0x0F, 0x38, 0x02], - operands=[Operand(type="SIMDRM", size=128, relaxed=True, dest="EA"), - Operand(type="SIMDReg", size=128, dest="VEX"), - Operand(type="SIMDReg", size=128, dest="Spare")]) -add_group("vmaskmov", - modifiers=["Op2Add"], - vex=256, - prefix=0x66, - opcode=[0x0F, 0x38, 0x02], - operands=[Operand(type="SIMDRM", size=256, relaxed=True, dest="EA"), - Operand(type="SIMDReg", size=256, dest="VEX"), - Operand(type="SIMDReg", size=256, dest="Spare")]) - -add_insn("vmaskmovps", "vmaskmov", modifiers=[0x2C], cpu=["AVX"]) -add_insn("vmaskmovpd", "vmaskmov", modifiers=[0x2D], cpu=["AVX"]) - -add_group("vpermil", - cpu=["AVX"], - modifiers=["Op2Add"], - vex=128, - prefix=0x66, - opcode=[0x0F, 0x38, 0x08], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="VEX"), - Operand(type="SIMDRM", size=128, relaxed=True, dest="EA")]) -add_group("vpermil", - cpu=["AVX"], - modifiers=["Op2Add"], - vex=256, - prefix=0x66, - opcode=[0x0F, 0x38, 0x08], - operands=[Operand(type="SIMDReg", size=256, dest="Spare"), - Operand(type="SIMDReg", size=256, dest="VEX"), - Operand(type="SIMDRM", size=256, relaxed=True, dest="EA")]) -add_group("vpermil", - cpu=["AVX"], - modifiers=["Op2Add"], - vex=128, - prefix=0x66, - opcode=[0x0F, 0x3A, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDRM", size=128, relaxed=True, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) -add_group("vpermil", - cpu=["AVX"], - modifiers=["Op2Add"], - vex=256, - prefix=0x66, - opcode=[0x0F, 0x3A, 0x00], - operands=[Operand(type="SIMDReg", size=256, dest="Spare"), - Operand(type="SIMDRM", size=256, relaxed=True, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) - -add_insn("vpermilpd", "vpermil", modifiers=[0x05]) -add_insn("vpermilps", "vpermil", modifiers=[0x04]) - -add_group("vperm2f128", - cpu=["AVX"], - vex=256, - prefix=0x66, - opcode=[0x0F, 0x3A, 0x06], - operands=[Operand(type="SIMDReg", size=256, dest="Spare"), - Operand(type="SIMDReg", size=256, dest="VEX"), - Operand(type="SIMDRM", size=256, relaxed=True, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) - -add_insn("vperm2f128", "vperm2f128") - -##################################################################### -# Intel AVX2 instructions -##################################################################### - -# Most AVX2 instructions are mixed in with above SSEx/AVX groups. -# Some make more sense to have separate groups. - -# vex.vvvv=1111b -add_group("vperm_var_avx2", - cpu=["AVX2"], - modifiers=["Op2Add"], - vex=256, - vexw=0, - prefix=0x66, - opcode=[0x0F, 0x38, 0x00], - operands=[Operand(type="SIMDReg", size=256, dest="Spare"), - Operand(type="SIMDReg", size=256, dest="VEX"), - Operand(type="SIMDRM", size=256, relaxed=True, dest="EA")]) - -add_insn("vpermd", "vperm_var_avx2", modifiers=[0x36]) -add_insn("vpermps", "vperm_var_avx2", modifiers=[0x16]) - -# vex.vvvv=1111b -add_group("vperm_imm_avx2", - cpu=["AVX2"], - modifiers=["Op2Add"], - vex=256, - vexw=1, - prefix=0x66, - opcode=[0x0F, 0x3A, 0x00], - operands=[Operand(type="SIMDReg", size=256, dest="Spare"), - Operand(type="SIMDRM", size=256, relaxed=True, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) - -add_insn("vpermq", "vperm_imm_avx2", modifiers=[0x00]) -add_insn("vpermpd", "vperm_imm_avx2", modifiers=[0x01]) - -add_group("vperm2i128_avx2", - cpu=["AVX2"], - vex=256, - prefix=0x66, - opcode=[0x0F, 0x3A, 0x46], - operands=[Operand(type="SIMDReg", size=256, dest="Spare"), - Operand(type="SIMDReg", size=256, dest="VEX"), - Operand(type="SIMDRM", size=256, relaxed=True, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) - -add_insn("vperm2i128", "vperm2i128_avx2") - -# vex.vvvv=1111b -for sz in [128, 256]: - add_group("vpbroadcastb_avx2", - cpu=["AVX2"], - vex=sz, - vexw=0, - prefix=0x66, - opcode=[0x0F, 0x38, 0x78], - operands=[Operand(type="SIMDReg", size=sz, dest="Spare"), - Operand(type="SIMDReg", size=128, relaxed=True, dest="EA")]) -# vex.vvvv=1111b -for sz in [128, 256]: - add_group("vpbroadcastb_avx2", - cpu=["AVX2"], - vex=sz, - vexw=0, - prefix=0x66, - opcode=[0x0F, 0x38, 0x78], - operands=[Operand(type="SIMDReg", size=sz, dest="Spare"), - Operand(type="RM", size=8, relaxed=True, dest="EA")]) - -add_insn("vpbroadcastb", "vpbroadcastb_avx2") - -# vex.vvvv=1111b -for sz in [128, 256]: - add_group("vpbroadcastw_avx2", - cpu=["AVX2"], - vex=sz, - vexw=0, - prefix=0x66, - opcode=[0x0F, 0x38, 0x79], - operands=[Operand(type="SIMDReg", size=sz, dest="Spare"), - Operand(type="SIMDReg", size=128, relaxed=True, dest="EA")]) -# vex.vvvv=1111b -for sz in [128, 256]: - add_group("vpbroadcastw_avx2", - cpu=["AVX2"], - vex=sz, - vexw=0, - prefix=0x66, - opcode=[0x0F, 0x38, 0x79], - operands=[Operand(type="SIMDReg", size=sz, dest="Spare"), - Operand(type="RM", size=16, relaxed=True, dest="EA")]) - -add_insn("vpbroadcastw", "vpbroadcastw_avx2") - -# vex.vvvv=1111b -for sz in [128, 256]: - add_group("vpbroadcastd_avx2", - cpu=["AVX2"], - vex=sz, - vexw=0, - prefix=0x66, - opcode=[0x0F, 0x38, 0x58], - operands=[Operand(type="SIMDReg", size=sz, dest="Spare"), - Operand(type="SIMDReg", size=128, relaxed=True, dest="EA")]) -# vex.vvvv=1111b -for sz in [128, 256]: - add_group("vpbroadcastd_avx2", - cpu=["AVX2"], - vex=sz, - vexw=0, - prefix=0x66, - opcode=[0x0F, 0x38, 0x58], - operands=[Operand(type="SIMDReg", size=sz, dest="Spare"), - Operand(type="RM", size=32, relaxed=True, dest="EA")]) - -add_insn("vpbroadcastd", "vpbroadcastd_avx2") - -# vex.vvvv=1111b -for sz in [128, 256]: - add_group("vpbroadcastq_avx2", - cpu=["AVX2"], - vex=sz, - vexw=0, - prefix=0x66, - opcode=[0x0F, 0x38, 0x59], - operands=[Operand(type="SIMDReg", size=sz, dest="Spare"), - Operand(type="SIMDReg", size=128, relaxed=True, dest="EA")]) -# vex.vvvv=1111b -for sz in [128, 256]: - add_group("vpbroadcastq_avx2", - cpu=["AVX2"], - vex=sz, - vexw=0, - prefix=0x66, - opcode=[0x0F, 0x38, 0x59], - operands=[Operand(type="SIMDReg", size=sz, dest="Spare"), - Operand(type="SIMDRM", size=64, relaxed=True, dest="EA")]) - -add_insn("vpbroadcastq", "vpbroadcastq_avx2") - -for sz in [128, 256]: - add_group("vpshiftv_vexw0_avx2", - cpu=["AVX2"], - modifiers=["Op2Add"], - vex=sz, - vexw=0, - prefix=0x66, - opcode=[0x0F, 0x38, 0x00], - operands=[Operand(type="SIMDReg", size=sz, dest="Spare"), - Operand(type="SIMDReg", size=sz, dest="VEX"), - Operand(type="SIMDRM", size=sz, relaxed=True, dest="EA")]) - -for sz in [128, 256]: - add_group("vpshiftv_vexw1_avx2", - cpu=["AVX2"], - modifiers=["Op2Add"], - vex=sz, - vexw=1, - prefix=0x66, - opcode=[0x0F, 0x38, 0x00], - operands=[Operand(type="SIMDReg", size=sz, dest="Spare"), - Operand(type="SIMDReg", size=sz, dest="VEX"), - Operand(type="SIMDRM", size=sz, relaxed=True, dest="EA")]) - -add_insn("vpsrlvd", "vpshiftv_vexw0_avx2", modifiers=[0x45]) -add_insn("vpsrlvq", "vpshiftv_vexw1_avx2", modifiers=[0x45]) -add_insn("vpsravd", "vpshiftv_vexw0_avx2", modifiers=[0x46]) - -add_insn("vpsllvd", "vpshiftv_vexw0_avx2", modifiers=[0x47]) -add_insn("vpsllvq", "vpshiftv_vexw1_avx2", modifiers=[0x47]) - -add_insn("vpmaskmovd", "vmaskmov", modifiers=[0x8C], cpu=["AVX2"]) - -# vex.vvvv=1111b -for sz in [128, 256]: - add_group("vmaskmov_vexw1_avx2", - cpu=["AVX2"], - modifiers=["Op2Add"], - vex=sz, - vexw=1, - prefix=0x66, - opcode=[0x0F, 0x38, 0x00], - operands=[Operand(type="SIMDReg", size=sz, dest="Spare"), - Operand(type="SIMDReg", size=sz, dest="VEX"), - Operand(type="SIMDRM", size=sz, relaxed=True, dest="EA")]) - -for sz in [128, 256]: - add_group("vmaskmov_vexw1_avx2", - cpu=["AVX2"], - modifiers=["Op2Add"], - vex=sz, - vexw=1, - prefix=0x66, - opcode=[0x0F, 0x38, 0x02], - operands=[Operand(type="SIMDRM", size=sz, relaxed=True, dest="EA"), - Operand(type="SIMDReg", size=sz, dest="VEX"), - Operand(type="SIMDReg", size=sz, dest="Spare")]) - -add_insn("vpmaskmovq", "vmaskmov_vexw1_avx2", modifiers=[0x8C]) - -for sz in [128, 256]: - add_group("vex_66_0F3A_imm8_avx2", - cpu=["AVX2"], - modifiers=["Op2Add"], - vex=sz, - vexw=0, - prefix=0x66, - opcode=[0x0F, 0x3A, 0x00], - operands=[Operand(type="SIMDReg", size=sz, dest="Spare"), - Operand(type="SIMDReg", size=sz, dest="VEX"), - Operand(type="SIMDRM", size=sz, relaxed=True, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) - -add_insn("vpblendd", "vex_66_0F3A_imm8_avx2", modifiers=[0x02]) - -# Vector register in EA. -add_group("gather_64x_64x", - cpu=["AVX2"], - modifiers=["Op2Add"], - vex=128, - vexw=1, - prefix=0x66, - opcode=[0x0F, 0x38, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="MemXMMIndex", size=64, relaxed=True, dest="EA"), - Operand(type="SIMDReg", size=128, dest="VEX")]) -add_group("gather_64x_64x", - cpu=["AVX2"], - modifiers=["Op2Add"], - vex=256, - vexw=1, - prefix=0x66, - opcode=[0x0F, 0x38, 0x00], - operands=[Operand(type="SIMDReg", size=256, dest="Spare"), - Operand(type="MemXMMIndex", size=64, relaxed=True, dest="EA"), - Operand(type="SIMDReg", size=256, dest="VEX")]) -add_insn("vgatherdpd", "gather_64x_64x", modifiers=[0x92]) -add_insn("vpgatherdq", "gather_64x_64x", modifiers=[0x90]) - -add_group("gather_64x_64y", - cpu=["AVX2"], - modifiers=["Op2Add"], - vex=128, - vexw=1, - prefix=0x66, - opcode=[0x0F, 0x38, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="MemXMMIndex", size=64, relaxed=True, dest="EA"), - Operand(type="SIMDReg", size=128, dest="VEX")]) -add_group("gather_64x_64y", - cpu=["AVX2"], - modifiers=["Op2Add"], - vex=256, - vexw=1, - prefix=0x66, - opcode=[0x0F, 0x38, 0x00], - operands=[Operand(type="SIMDReg", size=256, dest="Spare"), - Operand(type="MemYMMIndex", size=64, relaxed=True, dest="EA"), - Operand(type="SIMDReg", size=256, dest="VEX")]) -add_insn("vgatherqpd", "gather_64x_64y", modifiers=[0x93]) -add_insn("vpgatherqq", "gather_64x_64y", modifiers=[0x91]) - -add_group("gather_32x_32y", - cpu=["AVX2"], - modifiers=["Op2Add"], - vex=128, - vexw=0, - prefix=0x66, - opcode=[0x0F, 0x38, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="MemXMMIndex", size=32, relaxed=True, dest="EA"), - Operand(type="SIMDReg", size=128, dest="VEX")]) -add_group("gather_32x_32y", - cpu=["AVX2"], - modifiers=["Op2Add"], - vex=256, - vexw=0, - prefix=0x66, - opcode=[0x0F, 0x38, 0x00], - operands=[Operand(type="SIMDReg", size=256, dest="Spare"), - Operand(type="MemYMMIndex", size=32, relaxed=True, dest="EA"), - Operand(type="SIMDReg", size=256, dest="VEX")]) -add_insn("vgatherdps", "gather_32x_32y", modifiers=[0x92]) -add_insn("vpgatherdd", "gather_32x_32y", modifiers=[0x90]) - -add_group("gather_32x_32y_128", - cpu=["AVX2"], - modifiers=["Op2Add"], - vex=128, - vexw=0, - prefix=0x66, - opcode=[0x0F, 0x38, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="MemXMMIndex", size=32, relaxed=True, dest="EA"), - Operand(type="SIMDReg", size=128, dest="VEX")]) -add_group("gather_32x_32y_128", - cpu=["AVX2"], - modifiers=["Op2Add"], - vex=256, - vexw=0, - prefix=0x66, - opcode=[0x0F, 0x38, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="MemYMMIndex", size=32, relaxed=True, dest="EA"), - Operand(type="SIMDReg", size=128, dest="VEX")]) -add_insn("vgatherqps", "gather_32x_32y_128", modifiers=[0x93]) -add_insn("vpgatherqd", "gather_32x_32y_128", modifiers=[0x91]) - -##################################################################### -# Intel TSX instructions -##################################################################### -add_prefix("xacquire", "ACQREL", 0xF2) -add_prefix("xrelease", "ACQREL", 0xF3) - -add_group("tsx_xabort", - cpu=["TSX"], - opcode=[0xC6, 0xF8], - operands=[Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) -add_insn("xabort", "tsx_xabort") - - - -add_group("tsx_xbegin", - cpu=["TSX"], - opcode=[0xC7, 0xF8], - operands=[Operand(type="Imm", size=32, tmod="Near", dest="JmpRel")]) - -add_group("tsx_xbegin", - cpu=["TSX"], - opersize=16, - not64=True, #there should not be 16bit xbegin in 64bit mode - opcode=[0xC7, 0xF8], - operands=[Operand(type="Imm", size=16, tmod="Near", dest="JmpRel")]) -add_insn("xbegin", "tsx_xbegin") - -add_group("tsx_0x0F_0x01", - cpu=["TSX"], - modifiers=["Op2Add"], - opcode=[0x0F, 0x01, 0x00], - operands=[]) -add_insn("xend", "tsx_0x0F_0x01", modifiers=[0xD5]) -add_insn("xtest", "tsx_0x0F_0x01", modifiers=[0xD6]) - - - - - -##################################################################### -# Intel FMA instructions -##################################################################### - -### 128/256b FMA PS -add_group("vfma_ps", - cpu=["FMA"], - modifiers=["Op2Add"], - vex=128, - vexw=0, # single precision - prefix=0x66, - opcode=[0x0F, 0x38, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="VEX"), - Operand(type="SIMDRM", size=128, relaxed=True, dest="EA")]) -add_group("vfma_ps", - cpu=["FMA"], - modifiers=["Op2Add"], - vex=256, - vexw=0, # single precision - prefix=0x66, - opcode=[0x0F, 0x38, 0x00], - operands=[Operand(type="SIMDReg", size=256, dest="Spare"), - Operand(type="SIMDReg", size=256, dest="VEX"), - Operand(type="SIMDRM", size=256, relaxed=True, dest="EA")]) - -### 128/256b FMA PD(W=1) -add_group("vfma_pd", - cpu=["FMA"], - modifiers=["Op2Add"], - vex=128, - vexw=1, # double precision - prefix=0x66, - opcode=[0x0F, 0x38, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="VEX"), - Operand(type="SIMDRM", size=128, relaxed=True, dest="EA")]) -add_group("vfma_pd", - cpu=["FMA"], - modifiers=["Op2Add"], - vex=256, - vexw=1, # double precision - prefix=0x66, - opcode=[0x0F, 0x38, 0x00], - operands=[Operand(type="SIMDReg", size=256, dest="Spare"), - Operand(type="SIMDReg", size=256, dest="VEX"), - Operand(type="SIMDRM", size=256, relaxed=True, dest="EA")]) - -add_group("vfma_ss", - cpu=["FMA"], - modifiers=["Op2Add"], - vex=128, - vexw=0, - prefix=0x66, - opcode=[0x0F, 0x38, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="VEX"), - Operand(type="SIMDReg", size=128, dest="EA")]) - -add_group("vfma_ss", - cpu=["FMA"], - modifiers=["Op2Add"], - vex=128, - vexw=0, - prefix=0x66, - opcode=[0x0F, 0x38, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="VEX"), - Operand(type="Mem", size=32, relaxed=True, dest="EA")]) - -add_group("vfma_sd", - cpu=["FMA"], - modifiers=["Op2Add"], - vex=128, - vexw=1, - prefix=0x66, - opcode=[0x0F, 0x38, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="VEX"), - Operand(type="SIMDReg", size=128, dest="EA")]) - -add_group("vfma_sd", - cpu=["FMA"], - modifiers=["Op2Add"], - vex=128, - vexw=1, - prefix=0x66, - opcode=[0x0F, 0x38, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="VEX"), - Operand(type="Mem", size=64, relaxed=True, dest="EA")]) - -for orderval, order in enumerate(["132", "213", "231"]): - ov = orderval << 4 - for combval, comb in enumerate(["ps", "pd", "ss", "sd"]): - cv = combval >> 1 - add_insn("vfmadd"+order+comb, "vfma_"+comb, modifiers=[0x98+ov+cv]) - add_insn("vfmsub"+order+comb, "vfma_"+comb, modifiers=[0x9A+ov+cv]) - add_insn("vfnmsub"+order+comb, "vfma_"+comb, modifiers=[0x9E+ov+cv]) - add_insn("vfnmadd"+order+comb, "vfma_"+comb, modifiers=[0x9C+ov+cv]) - - # no ss/sd for these - for comb in ["ps", "pd"]: - add_insn("vfmaddsub"+order+comb, "vfma_"+comb, modifiers=[0x96+ov]) - add_insn("vfmsubadd"+order+comb, "vfma_"+comb, modifiers=[0x97+ov]) - -##################################################################### -# Intel AES instructions -##################################################################### - -add_group("aes", - cpu=["AES"], - modifiers=["Op1Add", "Op2Add", "SetVEX"], - prefix=0x66, - opcode=[0x0F, 0x00, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="SpareVEX"), - Operand(type="SIMDRM", size=128, relaxed=True, dest="EA")]) -add_group("aes", - cpu=["AES", "AVX"], - modifiers=["Op1Add", "Op2Add"], - vex=128, - prefix=0x66, - opcode=[0x0F, 0x00, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="VEX"), - Operand(type="SIMDRM", size=128, relaxed=True, dest="EA")]) - - -add_insn("aesenc", "aes", modifiers=[0x38, 0xDC]) -add_insn("aesenclast", "aes", modifiers=[0x38, 0xDD]) -add_insn("aesdec", "aes", modifiers=[0x38, 0xDE]) -add_insn("aesdeclast", "aes", modifiers=[0x38, 0xDF]) - -add_insn("vaesenc", "aes", modifiers=[0x38, 0xDC, VEXL0], avx=True) -add_insn("vaesenclast", "aes", modifiers=[0x38, 0xDD, VEXL0], avx=True) -add_insn("vaesdec", "aes", modifiers=[0x38, 0xDE, VEXL0], avx=True) -add_insn("vaesdeclast", "aes", modifiers=[0x38, 0xDF, VEXL0], avx=True) - -add_group("aesimc", - cpu=["AES"], - modifiers=["Op1Add", "Op2Add", "SetVEX"], - prefix=0x66, - opcode=[0x0F, 0x00, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDRM", size=128, relaxed=True, dest="EA")]) - -add_insn("aesimc", "aesimc", modifiers=[0x38, 0xDB]) -add_insn("vaesimc", "aesimc", modifiers=[0x38, 0xDB, VEXL0], avx=True) - - -add_group("aes_imm", - cpu=["AES"], - modifiers=["Op1Add", "Op2Add", "SetVEX"], - prefix=0x66, - opcode=[0x0F, 0x00, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDRM", size=128, relaxed=True, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) - -add_insn("aeskeygenassist", "aes_imm", modifiers=[0x3A, 0xDF]) -add_insn("vaeskeygenassist", "aes_imm", modifiers=[0x3A, 0xDF, VEXL0], - avx=True) - -##################################################################### -# Intel PCLMULQDQ instruction -##################################################################### - -add_group("pclmulqdq", - cpu=["CLMUL"], - modifiers=["Op1Add", "Op2Add", "SetVEX"], - prefix=0x66, - opcode=[0x0F, 0x00, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="SpareVEX"), - Operand(type="SIMDRM", size=128, relaxed=True, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) -add_group("pclmulqdq", - cpu=["CLMUL", "AVX"], - modifiers=["Op1Add", "Op2Add"], - vex=128, - prefix=0x66, - opcode=[0x0F, 0x00, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="VEX"), - Operand(type="SIMDRM", size=128, relaxed=True, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) - -add_insn("pclmulqdq", "pclmulqdq", modifiers=[0x3A, 0x44]) -add_insn("vpclmulqdq", "pclmulqdq", modifiers=[0x3A, 0x44, VEXL0], avx=True) - -add_group("pclmulqdq_fixed", - cpu=["CLMUL"], - modifiers=["Imm8", "SetVEX"], - prefix=0x66, - opcode=[0x0F, 0x3A, 0x44], - operands=[Operand(type="SIMDReg", size=128, dest="SpareVEX"), - Operand(type="SIMDRM", size=128, relaxed=True, dest="EA")]) -add_group("pclmulqdq_fixed", - cpu=["CLMUL", "AVX"], - modifiers=["Imm8"], - vex=128, - prefix=0x66, - opcode=[0x0F, 0x3A, 0x44], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="VEX"), - Operand(type="SIMDRM", size=128, relaxed=True, dest="EA")]) - -for comb, combval in zip(["lql","hql","lqh","hqh"], [0x00,0x01,0x10,0x11]): - add_insn("pclmul"+comb+"qdq", "pclmulqdq_fixed", modifiers=[combval]) - add_insn("vpclmul"+comb+"qdq", "pclmulqdq_fixed", - modifiers=[combval, VEXL0], avx=True) - -##################################################################### -# AVX Post-32nm instructions -##################################################################### - -# RDRAND -add_group("rdrand", - modifiers=['SpAdd'], - opersize=16, - opcode=[0x0F, 0xC7], - operands=[Operand(type="Reg", size=16, dest="EA")]) -add_group("rdrand", - #suffix="l", - modifiers=['SpAdd'], - opersize=32, - opcode=[0x0F, 0xC7], - operands=[Operand(type="Reg", size=32, dest="EA")]) -add_group("rdrand", - modifiers=['SpAdd'], - opersize=64, - opcode=[0x0F, 0xC7], - operands=[Operand(type="Reg", size=64, dest="EA")]) -add_insn("rdrand", "rdrand", modifiers=[6], cpu=["RDRAND"]) -add_insn("rdseed", "rdrand", modifiers=[7], cpu=["RDSEED"]) - -# FSGSBASE instructions -add_group("fs_gs_base", - only64=True, - cpu=["FSGSBASE"], - modifiers=['SpAdd'], - opersize=32, - prefix=0xF3, - opcode=[0x0F, 0xAE], - operands=[Operand(type="Reg", size=32, dest="EA")]) -add_group("fs_gs_base", - only64=True, - cpu=["FSGSBASE"], - opersize=64, - modifiers=['SpAdd'], - prefix=0xF3, - opcode=[0x0F, 0xAE], - operands=[Operand(type="Reg", size=64, dest="EA")]) - -add_insn("rdfsbase", "fs_gs_base", modifiers=[0], only64=True) -add_insn("rdgsbase", "fs_gs_base", modifiers=[1], only64=True) -add_insn("wrfsbase", "fs_gs_base", modifiers=[2], only64=True) -add_insn("wrgsbase", "fs_gs_base", modifiers=[3], only64=True) - -# Float-16 conversion instructions -for g in ['ps2ph', 'ph2ps']: - operands1=[] - operands1.append(Operand(type="SIMDReg", size=128, dest="EA")) - operands1.append(Operand(type="SIMDReg", size=128, dest="Spare")) - - operands2=[] - operands2.append(Operand(type="Mem", size=64, dest="EA")) - operands2.append(Operand(type="SIMDReg", size=128, dest="Spare")) - - operands3=[] - operands3.append(Operand(type="SIMDReg", size=128, dest="EA")) - operands3.append(Operand(type="SIMDReg", size=256, dest="Spare")) - - operands4=[] - operands4.append(Operand(type="Mem", size=128, dest="EA")) - operands4.append(Operand(type="SIMDReg", size=256, dest="Spare")) - - if g == 'ph2ps': - operands1.reverse() - operands2.reverse() - operands3.reverse() - operands4.reverse() - map = 0x38 - elif g == 'ps2ph': - immop = Operand(type="Imm", size=8, relaxed=True, dest="Imm") - operands1.append(immop) - operands2.append(immop) - operands3.append(immop) - operands4.append(immop) - map = 0x3A - - add_group("avx_cvt" + g, - cpu=["F16C", "AVX"], - modifiers=["PreAdd", "Op2Add"], - vex=128, - prefix=0x00, - opcode=[0x0F, map, 0x00], - operands=operands1) - - add_group("avx_cvt" + g, - cpu=["F16C", "AVX"], - modifiers=["PreAdd", "Op2Add"], - vex=128, - prefix=0x00, - opcode=[0x0F, map, 0x00], - operands=operands2) - - add_group("avx_cvt" + g, - cpu=["F16C", "AVX"], - modifiers=["PreAdd", "Op2Add"], - vex=256, - prefix=0x00, - opcode=[0x0F, map, 0x00], - operands=operands3) - - add_group("avx_cvt" + g, - cpu=["F16C", "AVX"], - modifiers=["PreAdd", "Op2Add"], - vex=256, - prefix=0x00, - opcode=[0x0F, map, 0x00], - operands=operands4) - -add_insn("vcvtps2ph", "avx_cvtps2ph", modifiers=[0x66, 0x1D], avx=True) -add_insn("vcvtph2ps", "avx_cvtph2ps", modifiers=[0x66, 0x13], avx=True) - -##################################################################### -# AMD SSE4a instructions -##################################################################### - -add_group("extrq", - cpu=["SSE4a"], - prefix=0x66, - opcode=[0x0F, 0x78], - operands=[Operand(type="SIMDReg", size=128, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) -add_group("extrq", - cpu=["SSE4a"], - prefix=0x66, - opcode=[0x0F, 0x79], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="EA")]) - -add_insn("extrq", "extrq") - -add_group("insertq", - cpu=["SSE4a"], - prefix=0xF2, - opcode=[0x0F, 0x78], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) -add_group("insertq", - cpu=["SSE4a"], - prefix=0xF2, - opcode=[0x0F, 0x79], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="EA")]) - -add_insn("insertq", "insertq") - -add_group("movntsd", - cpu=["SSE4a"], - prefix=0xF2, - opcode=[0x0F, 0x2B], - operands=[Operand(type="Mem", size=64, relaxed=True, dest="EA"), - Operand(type="SIMDReg", size=128, dest="Spare")]) - -add_insn("movntsd", "movntsd") - -add_group("movntss", - cpu=["SSE4a"], - prefix=0xF3, - opcode=[0x0F, 0x2B], - operands=[Operand(type="Mem", size=32, relaxed=True, dest="EA"), - Operand(type="SIMDReg", size=128, dest="Spare")]) - -add_insn("movntss", "movntss") - -##################################################################### -# AMD XOP instructions -##################################################################### - -add_group("vfrc_pdps", - cpu=["XOP"], - modifiers=["Op1Add"], - xop=128, - opcode=[0x09, 0x80], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDRM", size=128, relaxed=True, dest="EA")]) -add_group("vfrc_pdps", - cpu=["XOP"], - modifiers=["Op1Add"], - xop=256, - opcode=[0x09, 0x80], - operands=[Operand(type="SIMDReg", size=256, dest="Spare"), - Operand(type="SIMDRM", size=256, relaxed=True, dest="EA")]) -add_insn("vfrczpd", "vfrc_pdps", modifiers=[0x01]) -add_insn("vfrczps", "vfrc_pdps", modifiers=[0x00]) - -add_group("vfrczsd", - cpu=["XOP"], - xop=128, - opcode=[0x09, 0x83], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="EA")]) -add_group("vfrczsd", - cpu=["XOP"], - xop=128, - opcode=[0x09, 0x83], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="Mem", size=64, relaxed=True, dest="EA")]) -add_insn("vfrczsd", "vfrczsd") - -add_group("vfrczss", - cpu=["XOP"], - xop=128, - opcode=[0x09, 0x82], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="EA")]) -add_group("vfrczss", - cpu=["XOP"], - xop=128, - opcode=[0x09, 0x82], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="Mem", size=32, relaxed=True, dest="EA")]) -add_insn("vfrczss", "vfrczss") - -add_group("vpcmov", - cpu=["XOP"], - xop=128, - xopw=0, - opcode=[0x08, 0xA2], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="VEX"), - Operand(type="SIMDRM", size=128, relaxed=True, dest="EA"), - Operand(type="SIMDReg", size=128, dest="VEXImmSrc")]) -add_group("vpcmov", - cpu=["XOP"], - xop=128, - xopw=1, - opcode=[0x08, 0xA2], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="VEX"), - Operand(type="SIMDReg", size=128, dest="VEXImmSrc"), - Operand(type="SIMDRM", size=128, relaxed=True, dest="EA")]) -add_group("vpcmov", - cpu=["XOP"], - xop=256, - xopw=0, - opcode=[0x08, 0xA2], - operands=[Operand(type="SIMDReg", size=256, dest="Spare"), - Operand(type="SIMDReg", size=256, dest="VEX"), - Operand(type="SIMDRM", size=256, relaxed=True, dest="EA"), - Operand(type="SIMDReg", size=256, dest="VEXImmSrc")]) -add_group("vpcmov", - cpu=["XOP"], - xop=256, - xopw=1, - opcode=[0x08, 0xA2], - operands=[Operand(type="SIMDReg", size=256, dest="Spare"), - Operand(type="SIMDReg", size=256, dest="VEX"), - Operand(type="SIMDReg", size=256, dest="VEXImmSrc"), - Operand(type="SIMDRM", size=256, relaxed=True, dest="EA")]) - -add_insn("vpcmov", "vpcmov") - -add_group("vpcom", - cpu=["XOP"], - modifiers=["Op1Add", "Imm8"], - xop=128, - opcode=[0x08, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="VEX"), - Operand(type="SIMDRM", size=128, relaxed=True, dest="EA")]) -add_group("vpcom_imm", - cpu=["XOP"], - modifiers=["Op1Add"], - xop=128, - opcode=[0x08, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="VEX"), - Operand(type="SIMDRM", size=128, relaxed=True, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) - -for opc, sfx in [(0xCC, "b"), - (0xCE, "d"), - (0xCD, "w"), - (0xCF, "q"), - (0xEC, "ub"), - (0xEE, "ud"), - (0xEF, "uq"), - (0xED, "uw")]: - add_insn("vpcom"+sfx, "vpcom_imm", modifiers=[opc]) - for ib, cc in enumerate(["lt", "le", "gt", "ge", - "eq", "neq", "false", "true"]): - add_insn("vpcom"+cc+sfx, "vpcom", modifiers=[opc, ib]) - # ne alias for neq - add_insn("vpcomne"+sfx, "vpcom", modifiers=[opc, 5]) - -add_group("vphaddsub", - cpu=["XOP"], - modifiers=["Op1Add"], - xop=128, - opcode=[0x09, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDRM", size=128, relaxed=True, dest="EA")]) - -add_insn("vphaddbw", "vphaddsub", modifiers=[0xC1]) -add_insn("vphaddbd", "vphaddsub", modifiers=[0xC2]) -add_insn("vphaddbq", "vphaddsub", modifiers=[0xC3]) -add_insn("vphaddwd", "vphaddsub", modifiers=[0xC6]) -add_insn("vphaddwq", "vphaddsub", modifiers=[0xC7]) -add_insn("vphadddq", "vphaddsub", modifiers=[0xCB]) - -add_insn("vphaddubw", "vphaddsub", modifiers=[0xD1]) -add_insn("vphaddubd", "vphaddsub", modifiers=[0xD2]) -add_insn("vphaddubq", "vphaddsub", modifiers=[0xD3]) -add_insn("vphadduwd", "vphaddsub", modifiers=[0xD6]) -add_insn("vphadduwq", "vphaddsub", modifiers=[0xD7]) -add_insn("vphaddudq", "vphaddsub", modifiers=[0xDB]) - -add_insn("vphsubbw", "vphaddsub", modifiers=[0xE1]) -add_insn("vphsubwd", "vphaddsub", modifiers=[0xE2]) -add_insn("vphsubdq", "vphaddsub", modifiers=[0xE3]) - -add_group("vpma", - cpu=["XOP"], - modifiers=["Op1Add"], - xop=128, - opcode=[0x08, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="VEX"), - Operand(type="SIMDRM", size=128, relaxed=True, dest="EA"), - Operand(type="SIMDReg", size=128, dest="VEXImmSrc")]) - -add_insn("vpmacsdd", "vpma", modifiers=[0x9E]) -add_insn("vpmacsdqh", "vpma", modifiers=[0x9F]) -add_insn("vpmacsdql", "vpma", modifiers=[0x97]) -add_insn("vpmacssdd", "vpma", modifiers=[0x8E]) -add_insn("vpmacssdqh", "vpma", modifiers=[0x8F]) -add_insn("vpmacssdql", "vpma", modifiers=[0x87]) -add_insn("vpmacsswd", "vpma", modifiers=[0x86]) -add_insn("vpmacssww", "vpma", modifiers=[0x85]) -add_insn("vpmacswd", "vpma", modifiers=[0x96]) -add_insn("vpmacsww", "vpma", modifiers=[0x95]) -add_insn("vpmadcsswd", "vpma", modifiers=[0xA6]) -add_insn("vpmadcswd", "vpma", modifiers=[0xB6]) - -add_group("vpperm", - cpu=["XOP"], - xop=128, - xopw=0, - opcode=[0x08, 0xA3], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="VEX"), - Operand(type="SIMDRM", size=128, relaxed=True, dest="EA"), - Operand(type="SIMDReg", size=128, dest="VEXImmSrc")]) -add_group("vpperm", - cpu=["XOP"], - xop=128, - xopw=1, - opcode=[0x08, 0xA3], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="VEX"), - Operand(type="SIMDReg", size=128, dest="VEXImmSrc"), - Operand(type="SIMDRM", size=128, relaxed=True, dest="EA")]) -add_insn("vpperm", "vpperm") - -add_group("vprot", - cpu=["XOP"], - modifiers=["Op1Add"], - xop=128, - xopw=0, - opcode=[0x09, 0x90], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDRM", size=128, relaxed=True, dest="EA"), - Operand(type="SIMDReg", size=128, dest="VEX")]) -add_group("vprot", - cpu=["XOP"], - modifiers=["Op1Add"], - xop=128, - xopw=1, - opcode=[0x09, 0x90], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="VEX"), - Operand(type="SIMDRM", size=128, relaxed=True, dest="EA")]) -add_group("vprot", - cpu=["XOP"], - modifiers=["Op1Add"], - xop=128, - opcode=[0x08, 0xC0], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDRM", size=128, relaxed=True, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) -for opc, sfx in enumerate(["b", "w", "d", "q"]): - add_insn("vprot"+sfx, "vprot", modifiers=[opc]) - -add_group("amd_vpshift", - cpu=["XOP"], - modifiers=["Op1Add"], - xop=128, - xopw=0, - opcode=[0x09, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDRM", size=128, relaxed=True, dest="EA"), - Operand(type="SIMDReg", size=128, dest="VEX")]) -add_group("amd_vpshift", - cpu=["XOP"], - modifiers=["Op1Add"], - xop=128, - xopw=1, - opcode=[0x09, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="VEX"), - Operand(type="SIMDRM", size=128, relaxed=True, dest="EA")]) -for opc, sfx in enumerate(["b", "w", "d", "q"]): - add_insn("vpsha"+sfx, "amd_vpshift", modifiers=[0x98+opc]) - add_insn("vpshl"+sfx, "amd_vpshift", modifiers=[0x94+opc]) - -##################################################################### -# AMD FMA4 instructions (same as original Intel FMA instructions) -##################################################################### - -add_group("fma_128_256", - cpu=["FMA4"], - modifiers=["Op2Add"], - vex=128, - vexw=0, - prefix=0x66, - opcode=[0x0F, 0x3A, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="VEX"), - Operand(type="SIMDRM", size=128, relaxed=True, dest="EA"), - Operand(type="SIMDReg", size=128, dest="VEXImmSrc")]) -add_group("fma_128_256", - cpu=["FMA4"], - modifiers=["Op2Add"], - vex=128, - vexw=1, - prefix=0x66, - opcode=[0x0F, 0x3A, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="VEX"), - Operand(type="SIMDReg", size=128, dest="VEXImmSrc"), - Operand(type="SIMDRM", size=128, relaxed=True, dest="EA")]) -add_group("fma_128_256", - cpu=["FMA4"], - modifiers=["Op2Add"], - vex=256, - vexw=0, - prefix=0x66, - opcode=[0x0F, 0x3A, 0x00], - operands=[Operand(type="SIMDReg", size=256, dest="Spare"), - Operand(type="SIMDReg", size=256, dest="VEX"), - Operand(type="SIMDRM", size=256, relaxed=True, dest="EA"), - Operand(type="SIMDReg", size=256, dest="VEXImmSrc")]) -add_group("fma_128_256", - cpu=["FMA4"], - modifiers=["Op2Add"], - vex=256, - vexw=1, - prefix=0x66, - opcode=[0x0F, 0x3A, 0x00], - operands=[Operand(type="SIMDReg", size=256, dest="Spare"), - Operand(type="SIMDReg", size=256, dest="VEX"), - Operand(type="SIMDReg", size=256, dest="VEXImmSrc"), - Operand(type="SIMDRM", size=256, relaxed=True, dest="EA")]) - -add_insn("vfmaddpd", "fma_128_256", modifiers=[0x69]) -add_insn("vfmaddps", "fma_128_256", modifiers=[0x68]) -add_insn("vfmaddsubpd", "fma_128_256", modifiers=[0x5D]) -add_insn("vfmaddsubps", "fma_128_256", modifiers=[0x5C]) -add_insn("vfmsubaddpd", "fma_128_256", modifiers=[0x5F]) -add_insn("vfmsubaddps", "fma_128_256", modifiers=[0x5E]) -add_insn("vfmsubpd", "fma_128_256", modifiers=[0x6D]) -add_insn("vfmsubps", "fma_128_256", modifiers=[0x6C]) -add_insn("vfnmaddpd", "fma_128_256", modifiers=[0x79]) -add_insn("vfnmaddps", "fma_128_256", modifiers=[0x78]) -add_insn("vfnmsubpd", "fma_128_256", modifiers=[0x7D]) -add_insn("vfnmsubps", "fma_128_256", modifiers=[0x7C]) - -for sz in [32, 64]: - add_group("fma_128_m%d" % sz, - cpu=["FMA4"], - modifiers=["Op2Add"], - vex=128, - vexw=0, - prefix=0x66, - opcode=[0x0F, 0x3A, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="VEX"), - Operand(type="SIMDReg", size=128, dest="EA"), - Operand(type="SIMDReg", size=128, dest="VEXImmSrc")]) - add_group("fma_128_m%d" % sz, - cpu=["FMA4"], - modifiers=["Op2Add"], - vex=128, - vexw=0, - prefix=0x66, - opcode=[0x0F, 0x3A, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="VEX"), - Operand(type="Mem", size=sz, relaxed=True, dest="EA"), - Operand(type="SIMDReg", size=128, dest="VEXImmSrc")]) - add_group("fma_128_m%d" % sz, - cpu=["FMA4"], - modifiers=["Op2Add"], - vex=128, - vexw=1, - prefix=0x66, - opcode=[0x0F, 0x3A, 0x00], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDReg", size=128, dest="VEX"), - Operand(type="SIMDReg", size=128, dest="VEXImmSrc"), - Operand(type="Mem", size=sz, relaxed=True, dest="EA")]) - -add_insn("vfmaddsd", "fma_128_m64", modifiers=[0x6B]) -add_insn("vfmaddss", "fma_128_m32", modifiers=[0x6A]) -add_insn("vfmsubsd", "fma_128_m64", modifiers=[0x6F]) -add_insn("vfmsubss", "fma_128_m32", modifiers=[0x6E]) -add_insn("vfnmaddsd", "fma_128_m64", modifiers=[0x7B]) -add_insn("vfnmaddss", "fma_128_m32", modifiers=[0x7A]) -add_insn("vfnmsubsd", "fma_128_m64", modifiers=[0x7F]) -add_insn("vfnmsubss", "fma_128_m32", modifiers=[0x7E]) - -##################################################################### -# Intel XSAVE and XSAVEOPT instructions -##################################################################### -add_insn("xgetbv", "threebyte", modifiers=[0x0F, 0x01, 0xD0], - cpu=["XSAVE", "386"]) -add_insn("xsetbv", "threebyte", modifiers=[0x0F, 0x01, 0xD1], - cpu=["XSAVE", "386", "Priv"]) -add_insn("xsave", "twobytemem", modifiers=[4, 0x0F, 0xAE], - cpu=["XSAVE", "386"]) -add_insn("xrstor", "twobytemem", modifiers=[5, 0x0F, 0xAE], - cpu=["XSAVE", "386"]) - -add_insn("xsaveopt", "twobytemem", modifiers=[6, 0x0F, 0xAE], - cpu=["XSAVEOPT"]) - -add_group("xsaveopt64", - modifiers=["SpAdd", "Op0Add", "Op1Add"], - opcode=[0x00, 0x00], - spare=0, - opersize=64, - operands=[Operand(type="Mem", relaxed=True, dest="EA")]) -add_insn("xsaveopt64", "xsaveopt64", modifiers=[6, 0x0F, 0xAE], - cpu=["XSAVEOPT"], only64=True) - -##################################################################### -# Intel MOVBE instruction -##################################################################### -for sfx, sz in zip("wlq", [16, 32, 64]): - add_group("movbe", - cpu=["MOVBE"], - suffix=sfx, - opersize=sz, - opcode=[0x0F, 0x38, 0xF0], - operands=[Operand(type="Reg", size=sz, dest="Spare"), - Operand(type="Mem", size=sz, relaxed=True, dest="EA")]) - add_group("movbe", - cpu=["MOVBE"], - suffix=sfx, - opersize=sz, - opcode=[0x0F, 0x38, 0xF1], - operands=[Operand(type="Mem", size=sz, relaxed=True, dest="EA"), - Operand(type="Reg", size=sz, dest="Spare")]) -add_insn("movbe", "movbe") - -##################################################################### -# Intel advanced bit manipulations (BMI1/2) -##################################################################### - -add_insn("tzcnt", "cnt", modifiers=[0xBC], cpu=["BMI1"]) -# LZCNT is present as AMD ext - -for sfx, sz in zip("lq", [32, 64]): - add_group("vex_gpr_ndd_rm_0F38_regext", - suffix=sfx, - modifiers=["PreAdd", "Op2Add", "SpAdd" ], - opersize=sz, - prefix=0x00, - opcode=[0x0F, 0x38, 0x00], - vex=0, ## VEX.L=0 - operands=[Operand(type="Reg", size=sz, dest="VEX"), - Operand(type="RM", size=sz, relaxed=True, dest="EA")]) - - -add_insn("blsr", "vex_gpr_ndd_rm_0F38_regext", modifiers=[0x00, 0xF3, 1], - cpu=["BMI1"]) -add_insn("blsmsk", "vex_gpr_ndd_rm_0F38_regext", modifiers=[0x00, 0xF3, 2], - cpu=["BMI1"]) -add_insn("blsi", "vex_gpr_ndd_rm_0F38_regext", modifiers=[0x00, 0xF3, 3], - cpu=["BMI1"]) - -for sfx, sz in zip("lq", [32, 64]): - add_group("vex_gpr_reg_rm_0F_imm8", - suffix=sfx, - modifiers=["PreAdd", "Op1Add", "Op2Add"], - opersize=sz, - prefix=0x00, - opcode=[0x0F, 0x00, 0x00], - vex=0, ## VEX.L=0 - operands=[Operand(type="Reg", size=sz, dest="Spare"), - Operand(type="RM", size=sz, relaxed=True, dest="EA"), - Operand(type="Imm", size=8, relaxed=True, dest="Imm")]) - -add_insn("rorx", "vex_gpr_reg_rm_0F_imm8", modifiers=[0xF2, 0x3A, 0xF0], - cpu=["BMI2"]) - -for sfx, sz in zip("lq", [32, 64]): # no 16-bit forms - add_group("vex_gpr_reg_nds_rm_0F", - suffix=sfx, - modifiers=["PreAdd", "Op1Add", "Op2Add"], - opersize=sz, - prefix=0x00, - opcode=[0x0F, 0x00, 0x00], - vex=0, - operands=[Operand(type="Reg", size=sz, dest="Spare"), - Operand(type="Reg", size=sz, dest="VEX"), - Operand(type="RM", size=sz, relaxed=True, dest="EA")]) - -add_insn("andn", "vex_gpr_reg_nds_rm_0F", modifiers=[0x00, 0x38, 0xF2], - cpu=["BMI1"]) - -add_insn("pdep", "vex_gpr_reg_nds_rm_0F", modifiers=[0xF2, 0x38, 0xF5], - cpu=["BMI2"]) -add_insn("pext", "vex_gpr_reg_nds_rm_0F", modifiers=[0xF3, 0x38, 0xF5], - cpu=["BMI2"]) - -for sfx, sz in zip("lq", [32, 64]): # no 16-bit forms - add_group("vex_gpr_reg_rm_nds_0F", - suffix=sfx, - modifiers=["PreAdd", "Op1Add", "Op2Add"], - opersize=sz, - prefix=0x00, - opcode=[0x0F, 0x00, 0x00], - vex=0, - operands=[Operand(type="Reg", size=sz, dest="Spare"), - Operand(type="RM", size=sz, relaxed=True, dest="EA"), - Operand(type="Reg", size=sz, dest="VEX")]) - -add_insn("bzhi", "vex_gpr_reg_rm_nds_0F", modifiers=[0x00, 0x38, 0xF5], - cpu=["BMI2"]) -add_insn("shlx", "vex_gpr_reg_rm_nds_0F", modifiers=[0x66, 0x38, 0xF7], - cpu=["BMI2"]) -add_insn("shrx", "vex_gpr_reg_rm_nds_0F", modifiers=[0xF2, 0x38, 0xF7], - cpu=["BMI2"]) -add_insn("sarx", "vex_gpr_reg_rm_nds_0F", modifiers=[0xF3, 0x38, 0xF7], - cpu=["BMI2"]) - -add_insn("mulx", "vex_gpr_reg_nds_rm_0F", modifiers=[0xF2, 0x38, 0xF6], - cpu=["BMI2"]) - -for sfx, sz in zip("lq", [32, 64]): # no 16-bit forms - add_group("bextr", - cpu=["BMI1"], - suffix=sfx, - opersize=sz, - prefix=0x00, - opcode=[0x0F, 0x38, 0xF7], - vex=0, - operands=[Operand(type="Reg", size=sz, dest="Spare"), - Operand(type="RM", size=sz, relaxed=True, dest="EA"), - Operand(type="Reg", size=sz, dest="VEX")]) - add_group("bextr", # TBM alternate form of bextr - cpu=["TBM"], - suffix=sfx, - opersize=sz, - prefix=0x00, - opcode=[0x0A, 0x10], - xop=128, - xopw=(sz==64), - onlyavx=True, - operands=[Operand(type="Reg", size=sz, dest="Spare"), - Operand(type="RM", size=sz, relaxed=True, dest="EA"), - Operand(type="Imm", size=32, relaxed=True, dest="Imm")]) - -add_insn("bextr", "bextr") - -##################################################################### -# Intel INVPCID instruction -##################################################################### -add_group("invpcid", - cpu=["INVPCID", "Priv"], - not64=True, - prefix=0x66, - opcode=[0x0F, 0x38, 0x82], - operands=[Operand(type="Reg", size=32, dest="Spare"), - Operand(type="Mem", size=128, relaxed=True, dest="EA")]) -add_group("invpcid", - cpu=["INVPCID", "Priv"], - only64=True, - def_opersize_64=64, - prefix=0x66, - opcode=[0x0F, 0x38, 0x82], - operands=[Operand(type="Reg", size=64, dest="Spare"), - Operand(type="Mem", size=128, relaxed=True, dest="EA")]) -add_insn("invpcid", "invpcid") - - -##################################################################### -# Intel SHA instructions -##################################################################### -add_group("intel_SHA1MSG1", - cpu=["SHA"], - opcode=[0x0F, 0x38, 0xC9], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDRM", size=128, dest="EA", relaxed=True)]) -add_group("intel_SHA1MSG2", - cpu=["SHA"], - opcode=[0x0F, 0x38, 0xCA], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDRM", size=128, dest="EA", relaxed=True)]) -add_group("intel_SHA1NEXTE", - cpu=["SHA"], - opcode=[0x0F, 0x38, 0xC8], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDRM", size=128, dest="EA", relaxed=True)]) -add_group("intel_SHA1RNDS4", - cpu=["SHA"], - opcode=[0x0F, 0x3A, 0xCC], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDRM", size=128, dest="EA", relaxed=True), - Operand(type="Imm", size=8, dest="Imm", relaxed=True)]) -add_group("intel_SHA256MSG1", - cpu=["SHA"], - opcode=[0x0F, 0x38, 0xCC], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDRM", size=128, dest="EA", relaxed=True)]) -add_group("intel_SHA256MSG2", - cpu=["SHA"], - opcode=[0x0F, 0x38, 0xCD], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDRM", size=128, dest="EA", relaxed=True)]) -add_group("intel_SHA256RNDS2", - cpu=["SHA"], - opcode=[0x0F, 0x38, 0xCB], - operands=[Operand(type="SIMDReg", size=128, dest="Spare"), - Operand(type="SIMDRM", size=128, dest="EA")]) - -add_insn("SHA1MSG1", "intel_SHA1MSG1") -add_insn("SHA1MSG2", "intel_SHA1MSG2") -add_insn("SHA1NEXTE", "intel_SHA1NEXTE") -add_insn("SHA1RNDS4", "intel_SHA1RNDS4") -add_insn("SHA256MSG1", "intel_SHA256MSG1") -add_insn("SHA256MSG2", "intel_SHA256MSG2") -add_insn("SHA256RNDS2", "intel_SHA256RNDS2") - -##################################################################### -# Intel SMAP instructions -##################################################################### -add_insn("clac", "threebyte", modifiers=[0x0F, 0x01, 0xCA], cpu=["SMAP"]) -add_insn("stac", "threebyte", modifiers=[0x0F, 0x01, 0xCB], cpu=["SMAP"]) - -##################################################################### -# Intel ADX instructions -##################################################################### -for sfx, sz in zip("lq", [32, 64]): - add_group("vex_gpr_ndd_rm_0F38", - suffix=sfx, - modifiers=["PreAdd", "Op2Add"], - opersize=sz, - prefix=0x00, - opcode=[0x0F, 0x38, 0x00], - operands=[Operand(type="Reg", size=sz, dest="Spare"), - Operand(type="RM", size=sz, relaxed=True, dest="EA")]) - -add_insn("adcx", "vex_gpr_ndd_rm_0F38", modifiers=[0x66, 0xF6], cpu=["ADX"]) -add_insn("adox", "vex_gpr_ndd_rm_0F38", modifiers=[0xF3, 0xF6], cpu=["ADX"]) - - -##################################################################### -# AMD trailing bit manipulation (TBM) -##################################################################### - -for sfx, sz in zip("lq", [32, 64]): # no 16-bit forms - add_group("xop_gpr_reg_rm_09", - cpu=["TBM"], - suffix=sfx, - modifiers=["Op1Add","SpAdd"], - opersize=sz, - prefix=0x00, - opcode=[0x09, 0x00], - xop=128, - xopw=(sz==64), - operands=[Operand(type="Reg", size=sz, dest="VEX"), - Operand(type="RM", size=sz, relaxed=True, dest="EA")]) - -add_insn("blcfill", "xop_gpr_reg_rm_09", modifiers=[0x01, 1]) -add_insn("blci", "xop_gpr_reg_rm_09", modifiers=[0x02, 6]) -add_insn("blcic", "xop_gpr_reg_rm_09", modifiers=[0x01, 5]) -add_insn("blcmsk", "xop_gpr_reg_rm_09", modifiers=[0x02, 1]) -add_insn("blcs", "xop_gpr_reg_rm_09", modifiers=[0x01, 3]) -add_insn("blsfill", "xop_gpr_reg_rm_09", modifiers=[0x01, 2]) -add_insn("blsic", "xop_gpr_reg_rm_09", modifiers=[0x01, 6]) -add_insn("t1mskc", "xop_gpr_reg_rm_09", modifiers=[0x01, 7]) -add_insn("tzmsk", "xop_gpr_reg_rm_09", modifiers=[0x01, 4]) - -##################################################################### -# AMD 3DNow! instructions -##################################################################### - -add_insn("prefetch", "twobytemem", modifiers=[0x00, 0x0F, 0x0D], cpu=["3DNow"]) -add_insn("prefetchw", "twobytemem", modifiers=[0x01, 0x0F, 0x0D], cpu=["PRFCHW"]) -add_insn("femms", "twobyte", modifiers=[0x0F, 0x0E], cpu=["3DNow"]) - -add_group("now3d", - cpu=["3DNow"], - modifiers=["Imm8"], - opcode=[0x0F, 0x0F], - operands=[Operand(type="SIMDReg", size=64, dest="Spare"), - Operand(type="SIMDRM", size=64, relaxed=True, dest="EA")]) - -add_insn("pavgusb", "now3d", modifiers=[0xBF]) -add_insn("pf2id", "now3d", modifiers=[0x1D]) -add_insn("pf2iw", "now3d", modifiers=[0x1C], cpu=["Athlon", "3DNow"]) -add_insn("pfacc", "now3d", modifiers=[0xAE]) -add_insn("pfadd", "now3d", modifiers=[0x9E]) -add_insn("pfcmpeq", "now3d", modifiers=[0xB0]) -add_insn("pfcmpge", "now3d", modifiers=[0x90]) -add_insn("pfcmpgt", "now3d", modifiers=[0xA0]) -add_insn("pfmax", "now3d", modifiers=[0xA4]) -add_insn("pfmin", "now3d", modifiers=[0x94]) -add_insn("pfmul", "now3d", modifiers=[0xB4]) -add_insn("pfnacc", "now3d", modifiers=[0x8A], cpu=["Athlon", "3DNow"]) -add_insn("pfpnacc", "now3d", modifiers=[0x8E], cpu=["Athlon", "3DNow"]) -add_insn("pfrcp", "now3d", modifiers=[0x96]) -add_insn("pfrcpit1", "now3d", modifiers=[0xA6]) -add_insn("pfrcpit2", "now3d", modifiers=[0xB6]) -add_insn("pfrsqit1", "now3d", modifiers=[0xA7]) -add_insn("pfrsqrt", "now3d", modifiers=[0x97]) -add_insn("pfsub", "now3d", modifiers=[0x9A]) -add_insn("pfsubr", "now3d", modifiers=[0xAA]) -add_insn("pi2fd", "now3d", modifiers=[0x0D]) -add_insn("pi2fw", "now3d", modifiers=[0x0C], cpu=["Athlon", "3DNow"]) -add_insn("pmulhrw", "now3d", modifiers=[0xB7]) -add_insn("pswapd", "now3d", modifiers=[0xBB], cpu=["Athlon", "3DNow"]) - -##################################################################### -# AMD extensions -##################################################################### - -add_insn("syscall", "twobyte", modifiers=[0x0F, 0x05], cpu=["686", "AMD"]) -for sfx in [None, "l", "q"]: - add_insn("sysret"+(sfx or ""), "twobyte", suffix=sfx, modifiers=[0x0F, 0x07], - cpu=["686", "AMD", "Priv"]) -add_insn("lzcnt", "cnt", modifiers=[0xBD], cpu=["LZCNT"]) - -##################################################################### -# AMD x86-64 extensions -##################################################################### - -add_insn("swapgs", "threebyte", modifiers=[0x0F, 0x01, 0xF8], only64=True) -add_insn("rdtscp", "threebyte", modifiers=[0x0F, 0x01, 0xF9], - cpu=["686", "AMD", "Priv"]) - -add_group("cmpxchg16b", - only64=True, - opersize=64, - opcode=[0x0F, 0xC7], - spare=1, - operands=[Operand(type="Mem", size=128, relaxed=True, dest="EA")]) - -add_insn("cmpxchg16b", "cmpxchg16b") - -##################################################################### -# AMD Pacifica SVM instructions -##################################################################### - -add_insn("clgi", "threebyte", modifiers=[0x0F, 0x01, 0xDD], cpu=["SVM"]) -add_insn("stgi", "threebyte", modifiers=[0x0F, 0x01, 0xDC], cpu=["SVM"]) -add_insn("vmmcall", "threebyte", modifiers=[0x0F, 0x01, 0xD9], cpu=["SVM"]) - -add_group("invlpga", - cpu=["SVM"], - opcode=[0x0F, 0x01, 0xDF], - operands=[]) -add_group("invlpga", - cpu=["SVM"], - opcode=[0x0F, 0x01, 0xDF], - operands=[Operand(type="MemrAX", dest="AdSizeEA"), - Operand(type="Creg", size=32, dest=None)]) - -add_insn("invlpga", "invlpga") - -add_group("skinit", - cpu=["SVM"], - opcode=[0x0F, 0x01, 0xDE], - operands=[]) -add_group("skinit", - cpu=["SVM"], - opcode=[0x0F, 0x01, 0xDE], - operands=[Operand(type="MemEAX", dest=None)]) - -add_insn("skinit", "skinit") - -add_group("svm_rax", - cpu=["SVM"], - modifiers=["Op2Add"], - opcode=[0x0F, 0x01, 0x00], - operands=[]) -add_group("svm_rax", - cpu=["SVM"], - modifiers=["Op2Add"], - opcode=[0x0F, 0x01, 0x00], - operands=[Operand(type="MemrAX", dest="AdSizeEA")]) - -add_insn("vmload", "svm_rax", modifiers=[0xDA]) -add_insn("vmrun", "svm_rax", modifiers=[0xD8]) -add_insn("vmsave", "svm_rax", modifiers=[0xDB]) - - -##################################################################### -# AMD Excavator, new instructions MONITORX, MWAITX -##################################################################### - -add_insn("monitorx", "threebyte", modifiers=[0x0F, 0x01, 0xFA], cpu=["AMD"]) -add_insn("mwaitx", "threebyte", modifiers=[0x0F, 0x01, 0xFB], cpu=["AMD"]) - -##################################################################### -# AMD Zen, new instructions CLZERO -##################################################################### - -add_insn("clzero", "threebyte", modifiers=[0x0F, 0x01, 0xFC], cpu=["AMD"]) - -##################################################################### -# VIA PadLock instructions -##################################################################### - -add_group("padlock", - cpu=["PadLock"], - modifiers=["Imm8", "PreAdd", "Op1Add"], - prefix=0x00, - opcode=[0x0F, 0x00], - operands=[]) - -add_insn("xstore", "padlock", modifiers=[0xC0, 0x00, 0xA7]) -add_insn("xstorerng", "padlock", modifiers=[0xC0, 0x00, 0xA7]) -add_insn("xcryptecb", "padlock", modifiers=[0xC8, 0xF3, 0xA7]) -add_insn("xcryptcbc", "padlock", modifiers=[0xD0, 0xF3, 0xA7]) -add_insn("xcryptctr", "padlock", modifiers=[0xD8, 0xF3, 0xA7]) -add_insn("xcryptcfb", "padlock", modifiers=[0xE0, 0xF3, 0xA7]) -add_insn("xcryptofb", "padlock", modifiers=[0xE8, 0xF3, 0xA7]) -add_insn("montmul", "padlock", modifiers=[0xC0, 0xF3, 0xA6]) -add_insn("xsha1", "padlock", modifiers=[0xC8, 0xF3, 0xA6]) -add_insn("xsha256", "padlock", modifiers=[0xD0, 0xF3, 0xA6]) - -##################################################################### -# Cyrix MMX instructions -##################################################################### - -add_group("cyrixmmx", - cpu=["MMX", "Cyrix"], - modifiers=["Op1Add"], - opcode=[0x0F, 0x00], - operands=[Operand(type="SIMDReg", size=64, dest="Spare"), - Operand(type="SIMDRM", size=64, relaxed=True, dest="EA")]) - -add_insn("paddsiw", "cyrixmmx", modifiers=[0x51]) -add_insn("paveb", "cyrixmmx", modifiers=[0x50]) -add_insn("pdistib", "cyrixmmx", modifiers=[0x54]) -add_insn("pmagw", "cyrixmmx", modifiers=[0x52]) -add_insn("pmulhriw", "cyrixmmx", modifiers=[0x5D]) -add_insn("pmulhrwc", "cyrixmmx", modifiers=[0x59]) -add_insn("pmvgezb", "cyrixmmx", modifiers=[0x5C]) -add_insn("pmvlzb", "cyrixmmx", modifiers=[0x5B]) -add_insn("pmvnzb", "cyrixmmx", modifiers=[0x5A]) -add_insn("pmvzb", "cyrixmmx", modifiers=[0x58]) -add_insn("psubsiw", "cyrixmmx", modifiers=[0x55]) - -add_group("pmachriw", - cpu=["MMX", "Cyrix"], - opcode=[0x0F, 0x5E], - operands=[Operand(type="SIMDReg", size=64, dest="Spare"), - Operand(type="Mem", size=64, relaxed=True, dest="EA")]) - -add_insn("pmachriw", "pmachriw") - -##################################################################### -# Cyrix extensions -##################################################################### - -add_insn("smint", "twobyte", modifiers=[0x0F, 0x38], cpu=["686", "Cyrix"]) -add_insn("smintold", "twobyte", modifiers=[0x0F, 0x7E], cpu=["486", "Cyrix", "Obs"]) - -add_group("rdwrshr", - cpu=["Cyrix", "SMM", "686"], - modifiers=["Op1Add"], - opcode=[0x0F, 0x36], - operands=[Operand(type="RM", size=32, relaxed=True, dest="EA")]) - -add_insn("rdshr", "rdwrshr", modifiers=[0x00]) -add_insn("wrshr", "rdwrshr", modifiers=[0x01]) - -add_group("rsdc", - cpu=["Cyrix", "SMM", "486"], - opcode=[0x0F, 0x79], - operands=[Operand(type="SegReg", size=16, relaxed=True, dest="Spare"), - Operand(type="Mem", size=80, relaxed=True, dest="EA")]) - -add_insn("rsdc", "rsdc") - -add_group("cyrixsmm", - cpu=["Cyrix", "SMM", "486"], - modifiers=["Op1Add"], - opcode=[0x0F, 0x00], - operands=[Operand(type="Mem", size=80, relaxed=True, dest="EA")]) - -add_insn("rsldt", "cyrixsmm", modifiers=[0x7B]) -add_insn("rsts", "cyrixsmm", modifiers=[0x7D]) -add_insn("svldt", "cyrixsmm", modifiers=[0x7A]) -add_insn("svts", "cyrixsmm", modifiers=[0x7C]) - -add_group("svdc", - cpu=["Cyrix", "SMM", "486"], - opcode=[0x0F, 0x78], - operands=[Operand(type="Mem", size=80, relaxed=True, dest="EA"), - Operand(type="SegReg", size=16, relaxed=True, dest="Spare")]) - -add_insn("svdc", "svdc") - -##################################################################### -# Obsolete/undocumented instructions -##################################################################### - -add_insn("fsetpm", "twobyte", modifiers=[0xDB, 0xE4], cpu=["286", "FPU", "Obs"]) -add_insn("loadall", "twobyte", modifiers=[0x0F, 0x07], cpu=["386", "Undoc"]) -add_insn("loadall286", "twobyte", modifiers=[0x0F, 0x05], cpu=["286", "Undoc"]) -add_insn("salc", "onebyte", modifiers=[0xD6], cpu=["Undoc"], not64=True) -add_insn("smi", "onebyte", modifiers=[0xF1], cpu=["386", "Undoc"]) - -add_group("ibts", - cpu=["Undoc", "Obs", "386"], - opersize=16, - opcode=[0x0F, 0xA7], - operands=[Operand(type="RM", size=16, relaxed=True, dest="EA"), - Operand(type="Reg", size=16, dest="Spare")]) -add_group("ibts", - cpu=["Undoc", "Obs", "386"], - opersize=32, - opcode=[0x0F, 0xA7], - operands=[Operand(type="RM", size=32, relaxed=True, dest="EA"), - Operand(type="Reg", size=32, dest="Spare")]) - -add_insn("ibts", "ibts") - -add_group("umov", - cpu=["Undoc", "386"], - opcode=[0x0F, 0x10], - operands=[Operand(type="RM", size=8, relaxed=True, dest="EA"), - Operand(type="Reg", size=8, dest="Spare")]) -add_group("umov", - cpu=["Undoc", "386"], - opersize=16, - opcode=[0x0F, 0x11], - operands=[Operand(type="RM", size=16, relaxed=True, dest="EA"), - Operand(type="Reg", size=16, dest="Spare")]) -add_group("umov", - cpu=["Undoc", "386"], - opersize=32, - opcode=[0x0F, 0x11], - operands=[Operand(type="RM", size=32, relaxed=True, dest="EA"), - Operand(type="Reg", size=32, dest="Spare")]) -add_group("umov", - cpu=["Undoc", "386"], - opcode=[0x0F, 0x12], - operands=[Operand(type="Reg", size=8, dest="Spare"), - Operand(type="RM", size=8, relaxed=True, dest="EA")]) -add_group("umov", - cpu=["Undoc", "386"], - opersize=16, - opcode=[0x0F, 0x13], - operands=[Operand(type="Reg", size=16, dest="Spare"), - Operand(type="RM", size=16, relaxed=True, dest="EA")]) -add_group("umov", - cpu=["Undoc", "386"], - opersize=32, - opcode=[0x0F, 0x13], - operands=[Operand(type="Reg", size=32, dest="Spare"), - Operand(type="RM", size=32, relaxed=True, dest="EA")]) - -add_insn("umov", "umov") - -add_group("xbts", - cpu=["Undoc", "Obs", "386"], - opersize=16, - opcode=[0x0F, 0xA6], - operands=[Operand(type="Reg", size=16, dest="Spare"), - Operand(type="Mem", size=16, relaxed=True, dest="EA")]) -add_group("xbts", - cpu=["Undoc", "Obs", "386"], - opersize=32, - opcode=[0x0F, 0xA6], - operands=[Operand(type="Reg", size=32, dest="Spare"), - Operand(type="Mem", size=32, relaxed=True, dest="EA")]) - -add_insn("xbts", "xbts") - -finalize_insns() - -##################################################################### -# Prefixes -##################################################################### -# operand size overrides -for sz in [16, 32, 64]: - add_prefix("o%d" % sz, "OPERSIZE", sz, parser="nasm", only64=(sz==64)) - add_prefix("data%d" % sz, "OPERSIZE", sz, parser="gas", only64=(sz==64)) -add_prefix("word", "OPERSIZE", 16, parser="gas") -add_prefix("dword", "OPERSIZE", 32, parser="gas") -add_prefix("qword", "OPERSIZE", 64, parser="gas", only64=True) - -# address size overrides -for sz in [16, 32, 64]: - add_prefix("a%d" % sz, "ADDRSIZE", sz, parser="nasm", only64=(sz==64)) - add_prefix("addr%d" % sz, "ADDRSIZE", sz, parser="gas", only64=(sz==64)) -add_prefix("aword", "ADDRSIZE", 16, parser="gas") -add_prefix("adword", "ADDRSIZE", 32, parser="gas") -add_prefix("aqword", "ADDRSIZE", 64, parser="gas", only64=True) - -# instruction prefixes -add_prefix("lock", "LOCKREP", 0xF0) -add_prefix("repne", "LOCKREP", 0xF2) -add_prefix("repnz", "LOCKREP", 0xF2) -add_prefix("rep", "LOCKREP", 0xF3) -add_prefix("repe", "LOCKREP", 0xF3) -add_prefix("repz", "LOCKREP", 0xF3) - -# other prefixes, limited to GAS-only at the moment -# Hint taken/not taken for jumps -add_prefix("ht", "SEGREG", 0x3E, parser="gas") -add_prefix("hnt", "SEGREG", 0x2E, parser="gas") - -# REX byte explicit prefixes -for val, suf in enumerate(["", "z", "y", "yz", "x", "xz", "xy", "xyz"]): - add_prefix("rex" + suf, "REX", 0x40+val, parser="gas", only64=True) - add_prefix("rex64" + suf, "REX", 0x48+val, parser="gas", only64=True) - -##################################################################### -# Output generation -##################################################################### - -output_groups(open("x86insns.c", "wt")) -output_gas_insns(open("x86insn_gas.gperf", "wt")) -output_nasm_insns(open("x86insn_nasm.gperf", "wt")) - diff --git a/modules/arch/x86/tests/Makefile.inc b/modules/arch/x86/tests/Makefile.inc index c633e6c1..ad735995 100644 --- a/modules/arch/x86/tests/Makefile.inc +++ b/modules/arch/x86/tests/Makefile.inc @@ -1,7 +1,8 @@ +# $Id$ + TESTS += modules/arch/x86/tests/x86_test.sh EXTRA_DIST += modules/arch/x86/tests/x86_test.sh -EXTRA_DIST += modules/arch/x86/tests/gen-fma-test.py EXTRA_DIST += modules/arch/x86/tests/addbyte.asm EXTRA_DIST += modules/arch/x86/tests/addbyte.errwarn EXTRA_DIST += modules/arch/x86/tests/addbyte.hex @@ -10,33 +11,13 @@ EXTRA_DIST += modules/arch/x86/tests/addrop.errwarn EXTRA_DIST += modules/arch/x86/tests/addrop.hex EXTRA_DIST += modules/arch/x86/tests/addrop-err.asm EXTRA_DIST += modules/arch/x86/tests/addrop-err.errwarn -EXTRA_DIST += modules/arch/x86/tests/aes.asm -EXTRA_DIST += modules/arch/x86/tests/aes.hex -EXTRA_DIST += modules/arch/x86/tests/amd200707.asm -EXTRA_DIST += modules/arch/x86/tests/amd200707.hex -EXTRA_DIST += modules/arch/x86/tests/amd-fma4.asm -EXTRA_DIST += modules/arch/x86/tests/amd-fma4.hex EXTRA_DIST += modules/arch/x86/tests/arithsmall.asm EXTRA_DIST += modules/arch/x86/tests/arithsmall.errwarn EXTRA_DIST += modules/arch/x86/tests/arithsmall.hex -EXTRA_DIST += modules/arch/x86/tests/avx.asm -EXTRA_DIST += modules/arch/x86/tests/avx.hex -EXTRA_DIST += modules/arch/x86/tests/avx16.asm -EXTRA_DIST += modules/arch/x86/tests/avx16.hex -EXTRA_DIST += modules/arch/x86/tests/avx2.asm -EXTRA_DIST += modules/arch/x86/tests/avx2.hex -EXTRA_DIST += modules/arch/x86/tests/avxcc.asm -EXTRA_DIST += modules/arch/x86/tests/avxcc.hex EXTRA_DIST += modules/arch/x86/tests/bittest.asm EXTRA_DIST += modules/arch/x86/tests/bittest.hex -EXTRA_DIST += modules/arch/x86/tests/bmi1.asm -EXTRA_DIST += modules/arch/x86/tests/bmi1.hex -EXTRA_DIST += modules/arch/x86/tests/bmi2.asm -EXTRA_DIST += modules/arch/x86/tests/bmi2.hex EXTRA_DIST += modules/arch/x86/tests/bswap64.asm EXTRA_DIST += modules/arch/x86/tests/bswap64.hex -EXTRA_DIST += modules/arch/x86/tests/clmul.asm -EXTRA_DIST += modules/arch/x86/tests/clmul.hex EXTRA_DIST += modules/arch/x86/tests/cmpxchg.asm EXTRA_DIST += modules/arch/x86/tests/cmpxchg.hex EXTRA_DIST += modules/arch/x86/tests/cpubasic-err.asm @@ -60,10 +41,6 @@ EXTRA_DIST += modules/arch/x86/tests/effaddr.hex EXTRA_DIST += modules/arch/x86/tests/enter.asm EXTRA_DIST += modules/arch/x86/tests/enter.errwarn EXTRA_DIST += modules/arch/x86/tests/enter.hex -EXTRA_DIST += modules/arch/x86/tests/eptvpid.asm -EXTRA_DIST += modules/arch/x86/tests/eptvpid.hex -EXTRA_DIST += modules/arch/x86/tests/f16c.asm -EXTRA_DIST += modules/arch/x86/tests/f16c.hex EXTRA_DIST += modules/arch/x86/tests/far64.asm EXTRA_DIST += modules/arch/x86/tests/far64.hex EXTRA_DIST += modules/arch/x86/tests/farbasic.asm @@ -72,19 +49,10 @@ EXTRA_DIST += modules/arch/x86/tests/farithr.asm EXTRA_DIST += modules/arch/x86/tests/farithr.hex EXTRA_DIST += modules/arch/x86/tests/fcmov.asm EXTRA_DIST += modules/arch/x86/tests/fcmov.hex -EXTRA_DIST += modules/arch/x86/tests/fma.asm -EXTRA_DIST += modules/arch/x86/tests/fma.hex -EXTRA_DIST += modules/arch/x86/tests/fsgsbase.asm -EXTRA_DIST += modules/arch/x86/tests/fsgsbase.hex EXTRA_DIST += modules/arch/x86/tests/fwdequ64.asm EXTRA_DIST += modules/arch/x86/tests/fwdequ64.hex EXTRA_DIST += modules/arch/x86/tests/genopcode.asm EXTRA_DIST += modules/arch/x86/tests/genopcode.hex -EXTRA_DIST += modules/arch/x86/tests/imm64.asm -EXTRA_DIST += modules/arch/x86/tests/imm64.errwarn -EXTRA_DIST += modules/arch/x86/tests/imm64.hex -EXTRA_DIST += modules/arch/x86/tests/invpcid.asm -EXTRA_DIST += modules/arch/x86/tests/invpcid.hex EXTRA_DIST += modules/arch/x86/tests/iret.asm EXTRA_DIST += modules/arch/x86/tests/iret.hex EXTRA_DIST += modules/arch/x86/tests/jmp64-1.asm @@ -99,20 +67,12 @@ EXTRA_DIST += modules/arch/x86/tests/jmp64-5.asm EXTRA_DIST += modules/arch/x86/tests/jmp64-5.hex EXTRA_DIST += modules/arch/x86/tests/jmp64-6.asm EXTRA_DIST += modules/arch/x86/tests/jmp64-6.hex -EXTRA_DIST += modules/arch/x86/tests/jmpfar.asm -EXTRA_DIST += modules/arch/x86/tests/jmpfar.hex -EXTRA_DIST += modules/arch/x86/tests/larlsl.asm -EXTRA_DIST += modules/arch/x86/tests/larlsl.hex -EXTRA_DIST += modules/arch/x86/tests/lds.asm -EXTRA_DIST += modules/arch/x86/tests/lds.hex -EXTRA_DIST += modules/arch/x86/tests/lfs64.asm -EXTRA_DIST += modules/arch/x86/tests/lfs64.hex +EXTRA_DIST += modules/arch/x86/tests/lds-err.asm +EXTRA_DIST += modules/arch/x86/tests/lds-err.errwarn EXTRA_DIST += modules/arch/x86/tests/loopadsz.asm EXTRA_DIST += modules/arch/x86/tests/loopadsz.hex EXTRA_DIST += modules/arch/x86/tests/lsahf.asm EXTRA_DIST += modules/arch/x86/tests/lsahf.hex -EXTRA_DIST += modules/arch/x86/tests/lzcnt.asm -EXTRA_DIST += modules/arch/x86/tests/lzcnt.hex EXTRA_DIST += modules/arch/x86/tests/mem64-err.asm EXTRA_DIST += modules/arch/x86/tests/mem64-err.errwarn EXTRA_DIST += modules/arch/x86/tests/mem64.asm @@ -122,10 +82,6 @@ EXTRA_DIST += modules/arch/x86/tests/mem64hi32.asm EXTRA_DIST += modules/arch/x86/tests/mem64hi32.hex EXTRA_DIST += modules/arch/x86/tests/mem64rip.asm EXTRA_DIST += modules/arch/x86/tests/mem64rip.hex -EXTRA_DIST += modules/arch/x86/tests/mixcase.asm -EXTRA_DIST += modules/arch/x86/tests/mixcase.hex -EXTRA_DIST += modules/arch/x86/tests/movbe.asm -EXTRA_DIST += modules/arch/x86/tests/movbe.hex EXTRA_DIST += modules/arch/x86/tests/movdq32.asm EXTRA_DIST += modules/arch/x86/tests/movdq32.hex EXTRA_DIST += modules/arch/x86/tests/movdq64.asm @@ -141,9 +97,6 @@ EXTRA_DIST += modules/arch/x86/tests/nomem64.errwarn EXTRA_DIST += modules/arch/x86/tests/nomem64.hex EXTRA_DIST += modules/arch/x86/tests/o64.asm EXTRA_DIST += modules/arch/x86/tests/o64.hex -EXTRA_DIST += modules/arch/x86/tests/o64loop.asm -EXTRA_DIST += modules/arch/x86/tests/o64loop.errwarn -EXTRA_DIST += modules/arch/x86/tests/o64loop.hex EXTRA_DIST += modules/arch/x86/tests/opersize.asm EXTRA_DIST += modules/arch/x86/tests/opersize.hex EXTRA_DIST += modules/arch/x86/tests/opsize-err.asm @@ -153,8 +106,6 @@ EXTRA_DIST += modules/arch/x86/tests/overflow.errwarn EXTRA_DIST += modules/arch/x86/tests/overflow.hex EXTRA_DIST += modules/arch/x86/tests/padlock.asm EXTRA_DIST += modules/arch/x86/tests/padlock.hex -EXTRA_DIST += modules/arch/x86/tests/pinsrb.asm -EXTRA_DIST += modules/arch/x86/tests/pinsrb.hex EXTRA_DIST += modules/arch/x86/tests/pshift.asm EXTRA_DIST += modules/arch/x86/tests/pshift.hex EXTRA_DIST += modules/arch/x86/tests/push64.asm @@ -167,30 +118,14 @@ EXTRA_DIST += modules/arch/x86/tests/pushf-err.errwarn EXTRA_DIST += modules/arch/x86/tests/pushnosize.asm EXTRA_DIST += modules/arch/x86/tests/pushnosize.errwarn EXTRA_DIST += modules/arch/x86/tests/pushnosize.hex -EXTRA_DIST += modules/arch/x86/tests/rdrnd.asm -EXTRA_DIST += modules/arch/x86/tests/rdrnd.hex EXTRA_DIST += modules/arch/x86/tests/rep.asm EXTRA_DIST += modules/arch/x86/tests/rep.hex EXTRA_DIST += modules/arch/x86/tests/ret.asm EXTRA_DIST += modules/arch/x86/tests/ret.hex -EXTRA_DIST += modules/arch/x86/tests/riprel1.asm -EXTRA_DIST += modules/arch/x86/tests/riprel1.hex -EXTRA_DIST += modules/arch/x86/tests/riprel2.asm -EXTRA_DIST += modules/arch/x86/tests/riprel2.errwarn -EXTRA_DIST += modules/arch/x86/tests/riprel2.hex -EXTRA_DIST += modules/arch/x86/tests/ripseg.asm -EXTRA_DIST += modules/arch/x86/tests/ripseg.errwarn -EXTRA_DIST += modules/arch/x86/tests/ripseg.hex EXTRA_DIST += modules/arch/x86/tests/segmov.asm EXTRA_DIST += modules/arch/x86/tests/segmov.hex -EXTRA_DIST += modules/arch/x86/tests/segoff.asm -EXTRA_DIST += modules/arch/x86/tests/segoff.hex -EXTRA_DIST += modules/arch/x86/tests/segoff-err.asm -EXTRA_DIST += modules/arch/x86/tests/segoff-err.errwarn EXTRA_DIST += modules/arch/x86/tests/shift.asm EXTRA_DIST += modules/arch/x86/tests/shift.hex -EXTRA_DIST += modules/arch/x86/tests/shift64.asm -EXTRA_DIST += modules/arch/x86/tests/shift64.hex EXTRA_DIST += modules/arch/x86/tests/simd-1.asm EXTRA_DIST += modules/arch/x86/tests/simd-1.hex EXTRA_DIST += modules/arch/x86/tests/simd-2.asm @@ -199,8 +134,6 @@ EXTRA_DIST += modules/arch/x86/tests/simd64-1.asm EXTRA_DIST += modules/arch/x86/tests/simd64-1.hex EXTRA_DIST += modules/arch/x86/tests/simd64-2.asm EXTRA_DIST += modules/arch/x86/tests/simd64-2.hex -EXTRA_DIST += modules/arch/x86/tests/smx.asm -EXTRA_DIST += modules/arch/x86/tests/smx.hex EXTRA_DIST += modules/arch/x86/tests/sse-prefix.asm EXTRA_DIST += modules/arch/x86/tests/sse-prefix.hex EXTRA_DIST += modules/arch/x86/tests/sse3.asm @@ -209,8 +142,6 @@ EXTRA_DIST += modules/arch/x86/tests/sse4.asm EXTRA_DIST += modules/arch/x86/tests/sse4.hex EXTRA_DIST += modules/arch/x86/tests/sse4-err.asm EXTRA_DIST += modules/arch/x86/tests/sse4-err.errwarn -EXTRA_DIST += modules/arch/x86/tests/ssewidth.asm -EXTRA_DIST += modules/arch/x86/tests/ssewidth.hex EXTRA_DIST += modules/arch/x86/tests/ssse3.asm EXTRA_DIST += modules/arch/x86/tests/ssse3.c EXTRA_DIST += modules/arch/x86/tests/ssse3.hex @@ -235,26 +166,12 @@ EXTRA_DIST += modules/arch/x86/tests/vmx.asm EXTRA_DIST += modules/arch/x86/tests/vmx.hex EXTRA_DIST += modules/arch/x86/tests/vmx-err.asm EXTRA_DIST += modules/arch/x86/tests/vmx-err.errwarn -EXTRA_DIST += modules/arch/x86/tests/vsib.asm -EXTRA_DIST += modules/arch/x86/tests/vsib.hex -EXTRA_DIST += modules/arch/x86/tests/vsib-err.asm -EXTRA_DIST += modules/arch/x86/tests/vsib-err.errwarn -EXTRA_DIST += modules/arch/x86/tests/vsib2-err.asm -EXTRA_DIST += modules/arch/x86/tests/vsib2-err.errwarn EXTRA_DIST += modules/arch/x86/tests/x86label.asm EXTRA_DIST += modules/arch/x86/tests/x86label.hex EXTRA_DIST += modules/arch/x86/tests/xchg64.asm EXTRA_DIST += modules/arch/x86/tests/xchg64.hex EXTRA_DIST += modules/arch/x86/tests/xmm64.asm EXTRA_DIST += modules/arch/x86/tests/xmm64.hex -EXTRA_DIST += modules/arch/x86/tests/xop-all.asm -EXTRA_DIST += modules/arch/x86/tests/xop-all.hex -EXTRA_DIST += modules/arch/x86/tests/xop-basic.asm -EXTRA_DIST += modules/arch/x86/tests/xop-basic.hex -EXTRA_DIST += modules/arch/x86/tests/xop-cc.asm -EXTRA_DIST += modules/arch/x86/tests/xop-cc.hex -EXTRA_DIST += modules/arch/x86/tests/xsave.asm -EXTRA_DIST += modules/arch/x86/tests/xsave.hex EXTRA_DIST += modules/arch/x86/tests/gas32/Makefile.inc EXTRA_DIST += modules/arch/x86/tests/gas64/Makefile.inc diff --git a/modules/arch/x86/tests/addrop-err.errwarn b/modules/arch/x86/tests/addrop-err.errwarn index 0bf0b548..72040ee7 100644 --- a/modules/arch/x86/tests/addrop-err.errwarn +++ b/modules/arch/x86/tests/addrop-err.errwarn @@ -1 +1 @@ --:2: error: invalid effective address (displacement size) +-:2: invalid effective address (displacement size) diff --git a/modules/arch/x86/tests/adx.asm b/modules/arch/x86/tests/adx.asm deleted file mode 100644 index 3feb88e0..00000000 --- a/modules/arch/x86/tests/adx.asm +++ /dev/null @@ -1,10 +0,0 @@ -[bits 64] -adcx eax, ebx -adcx ebx, [0] -adcx rax, rbx -adcx rbx, [0] - -adox eax, ebx -adox ebx, [0] -adox rax, rbx -adox rbx, [0] diff --git a/modules/arch/x86/tests/adx.hex b/modules/arch/x86/tests/adx.hex deleted file mode 100644 index f6188af3..00000000 --- a/modules/arch/x86/tests/adx.hex +++ /dev/null @@ -1,64 +0,0 @@ -66 -0f -38 -f6 -c3 -66 -0f -38 -f6 -1c -25 -00 -00 -00 -00 -66 -48 -0f -38 -f6 -c3 -66 -48 -0f -38 -f6 -1c -25 -00 -00 -00 -00 -f3 -0f -38 -f6 -c3 -f3 -0f -38 -f6 -1c -25 -00 -00 -00 -00 -f3 -48 -0f -38 -f6 -c3 -f3 -48 -0f -38 -f6 -1c -25 -00 -00 -00 -00 diff --git a/modules/arch/x86/tests/aes.asm b/modules/arch/x86/tests/aes.asm deleted file mode 100644 index 52c587d5..00000000 --- a/modules/arch/x86/tests/aes.asm +++ /dev/null @@ -1,80 +0,0 @@ -[bits 64] -aesenc xmm1, xmm2 -aesenc xmm1, [rax] -aesenc xmm1, dqword [rax] -aesenc xmm10, xmm12 -aesenc xmm10, [rax+r15*4] -aesenc xmm10, [r14+r15*4] -vaesenc xmm1, xmm2 -vaesenc xmm1, [rax] -vaesenc xmm1, dqword [rax] -vaesenc xmm1, xmm2, xmm3 -vaesenc xmm1, xmm2, [rax] -vaesenc xmm1, xmm2, dqword [rax] - -aesenclast xmm1, xmm2 -aesenclast xmm1, [rax] -aesenclast xmm1, dqword [rax] -vaesenclast xmm1, xmm2 -vaesenclast xmm1, [rax] -vaesenclast xmm1, dqword [rax] -vaesenclast xmm1, xmm2, xmm3 -vaesenclast xmm1, xmm2, [rax] -vaesenclast xmm1, xmm2, dqword [rax] - -aesdec xmm1, xmm2 -aesdec xmm1, [rax] -aesdec xmm1, dqword [rax] -vaesdec xmm1, xmm2 -vaesdec xmm1, [rax] -vaesdec xmm1, dqword [rax] -vaesdec xmm1, xmm2, xmm3 -vaesdec xmm1, xmm2, [rax] -vaesdec xmm1, xmm2, dqword [rax] - -aesdeclast xmm1, xmm2 -aesdeclast xmm1, [rax] -aesdeclast xmm1, dqword [rax] -vaesdeclast xmm1, xmm2 -vaesdeclast xmm1, [rax] -vaesdeclast xmm1, dqword [rax] -vaesdeclast xmm1, xmm2, xmm3 -vaesdeclast xmm1, xmm2, [rax] -vaesdeclast xmm1, xmm2, dqword [rax] - -aesimc xmm1, xmm2 -aesimc xmm1, [rax] -aesimc xmm1, dqword [rax] -vaesimc xmm1, xmm2 -vaesimc xmm1, [rax] -vaesimc xmm1, dqword [rax] -; no 3-operand form - -aeskeygenassist xmm1, xmm2, 5 -aeskeygenassist xmm1, [rax], byte 5 -aeskeygenassist xmm1, dqword [rax], 5 -vaeskeygenassist xmm1, xmm2, 5 -vaeskeygenassist xmm1, [rax], byte 5 -vaeskeygenassist xmm1, dqword [rax], 5 - -pclmulqdq xmm1, xmm2, 5 -pclmulqdq xmm1, [rax], byte 5 -pclmulqdq xmm1, dqword [rax], 5 - -; pclmulqdq variants -pclmullqlqdq xmm1, xmm2 -pclmullqlqdq xmm1, [rax] -pclmullqlqdq xmm1, dqword [rax] - -pclmulhqlqdq xmm1, xmm2 -pclmulhqlqdq xmm1, [rax] -pclmulhqlqdq xmm1, dqword [rax] - -pclmullqhqdq xmm1, xmm2 -pclmullqhqdq xmm1, [rax] -pclmullqhqdq xmm1, dqword [rax] - -pclmulhqhqdq xmm1, xmm2 -pclmulhqhqdq xmm1, [rax] -pclmulhqhqdq xmm1, dqword [rax] - diff --git a/modules/arch/x86/tests/aes.hex b/modules/arch/x86/tests/aes.hex deleted file mode 100644 index 6583be83..00000000 --- a/modules/arch/x86/tests/aes.hex +++ /dev/null @@ -1,356 +0,0 @@ -66 -0f -38 -dc -ca -66 -0f -38 -dc -08 -66 -0f -38 -dc -08 -66 -45 -0f -38 -dc -d4 -66 -46 -0f -38 -dc -14 -b8 -66 -47 -0f -38 -dc -14 -be -c4 -e2 -71 -dc -ca -c4 -e2 -71 -dc -08 -c4 -e2 -71 -dc -08 -c4 -e2 -69 -dc -cb -c4 -e2 -69 -dc -08 -c4 -e2 -69 -dc -08 -66 -0f -38 -dd -ca -66 -0f -38 -dd -08 -66 -0f -38 -dd -08 -c4 -e2 -71 -dd -ca -c4 -e2 -71 -dd -08 -c4 -e2 -71 -dd -08 -c4 -e2 -69 -dd -cb -c4 -e2 -69 -dd -08 -c4 -e2 -69 -dd -08 -66 -0f -38 -de -ca -66 -0f -38 -de -08 -66 -0f -38 -de -08 -c4 -e2 -71 -de -ca -c4 -e2 -71 -de -08 -c4 -e2 -71 -de -08 -c4 -e2 -69 -de -cb -c4 -e2 -69 -de -08 -c4 -e2 -69 -de -08 -66 -0f -38 -df -ca -66 -0f -38 -df -08 -66 -0f -38 -df -08 -c4 -e2 -71 -df -ca -c4 -e2 -71 -df -08 -c4 -e2 -71 -df -08 -c4 -e2 -69 -df -cb -c4 -e2 -69 -df -08 -c4 -e2 -69 -df -08 -66 -0f -38 -db -ca -66 -0f -38 -db -08 -66 -0f -38 -db -08 -c4 -e2 -79 -db -ca -c4 -e2 -79 -db -08 -c4 -e2 -79 -db -08 -66 -0f -3a -df -ca -05 -66 -0f -3a -df -08 -05 -66 -0f -3a -df -08 -05 -c4 -e3 -79 -df -ca -05 -c4 -e3 -79 -df -08 -05 -c4 -e3 -79 -df -08 -05 -66 -0f -3a -44 -ca -05 -66 -0f -3a -44 -08 -05 -66 -0f -3a -44 -08 -05 -66 -0f -3a -44 -ca -00 -66 -0f -3a -44 -08 -00 -66 -0f -3a -44 -08 -00 -66 -0f -3a -44 -ca -01 -66 -0f -3a -44 -08 -01 -66 -0f -3a -44 -08 -01 -66 -0f -3a -44 -ca -10 -66 -0f -3a -44 -08 -10 -66 -0f -3a -44 -08 -10 -66 -0f -3a -44 -ca -11 -66 -0f -3a -44 -08 -11 -66 -0f -3a -44 -08 -11 diff --git a/modules/arch/x86/tests/amd-fma4.asm b/modules/arch/x86/tests/amd-fma4.asm deleted file mode 100644 index 25fdc50d..00000000 --- a/modules/arch/x86/tests/amd-fma4.asm +++ /dev/null @@ -1,109 +0,0 @@ -[bits 64] -vfmaddpd xmm0, xmm1, xmm2, xmm3 -vfmaddpd xmm0, xmm1, [rax], xmm3 -vfmaddpd xmm0, xmm1, dqword [rax], xmm3 -vfmaddpd xmm0, xmm1, xmm2, [rax] -vfmaddpd xmm0, xmm1, xmm2, dqword [rax] -vfmaddpd ymm0, ymm1, ymm2, ymm3 -vfmaddpd ymm0, ymm1, [rax], ymm3 -vfmaddpd ymm0, ymm1, yword [rax], ymm3 -vfmaddpd ymm0, ymm1, ymm2, [rax] -vfmaddpd ymm0, ymm1, ymm2, yword [rax] - -vfmaddps xmm0, xmm1, xmm2, xmm3 -vfmaddps xmm0, xmm1, dqword [rax], xmm3 -vfmaddps xmm0, xmm1, xmm2, dqword [rax] -vfmaddps ymm0, ymm1, ymm2, ymm3 -vfmaddps ymm0, ymm1, yword [rax], ymm3 -vfmaddps ymm0, ymm1, ymm2, yword [rax] - -vfmaddsd xmm0, xmm1, xmm2, xmm3 -vfmaddsd xmm0, xmm1, [rax], xmm3 -vfmaddsd xmm0, xmm1, qword [rax], xmm3 -vfmaddsd xmm0, xmm1, xmm2, [rax] -vfmaddsd xmm0, xmm1, xmm2, qword [rax] - -vfmaddss xmm0, xmm1, xmm2, xmm3 -vfmaddss xmm0, xmm1, dword [rax], xmm3 -vfmaddss xmm0, xmm1, xmm2, dword [rax] - -vfmaddsubpd xmm0, xmm1, xmm2, xmm3 -vfmaddsubpd xmm0, xmm1, dqword [rax], xmm3 -vfmaddsubpd xmm0, xmm1, xmm2, dqword [rax] -vfmaddsubpd ymm0, ymm1, ymm2, ymm3 -vfmaddsubpd ymm0, ymm1, yword [rax], ymm3 -vfmaddsubpd ymm0, ymm1, ymm2, yword [rax] - -vfmaddsubps xmm0, xmm1, xmm2, xmm3 -vfmaddsubps xmm0, xmm1, dqword [rax], xmm3 -vfmaddsubps xmm0, xmm1, xmm2, dqword [rax] -vfmaddsubps ymm0, ymm1, ymm2, ymm3 -vfmaddsubps ymm0, ymm1, yword [rax], ymm3 -vfmaddsubps ymm0, ymm1, ymm2, yword [rax] - -vfmsubpd xmm0, xmm1, xmm2, xmm3 -vfmsubpd xmm0, xmm1, dqword [rax], xmm3 -vfmsubpd xmm0, xmm1, xmm2, dqword [rax] -vfmsubpd ymm0, ymm1, ymm2, ymm3 -vfmsubpd ymm0, ymm1, yword [rax], ymm3 -vfmsubpd ymm0, ymm1, ymm2, yword [rax] - -vfmsubps xmm0, xmm1, xmm2, xmm3 -vfmsubps xmm0, xmm1, dqword [rax], xmm3 -vfmsubps xmm0, xmm1, xmm2, dqword [rax] -vfmsubps ymm0, ymm1, ymm2, ymm3 -vfmsubps ymm0, ymm1, yword [rax], ymm3 -vfmsubps ymm0, ymm1, ymm2, yword [rax] - -vfmsubsd xmm0, xmm1, xmm2, xmm3 -vfmsubsd xmm0, xmm1, qword [rax], xmm3 -vfmsubsd xmm0, xmm1, xmm2, qword [rax] - -vfmsubss xmm0, xmm1, xmm2, xmm3 -vfmsubss xmm0, xmm1, dword [rax], xmm3 -vfmsubss xmm0, xmm1, xmm2, dword [rax] - -vfnmaddpd xmm0, xmm1, xmm2, xmm3 -vfnmaddpd xmm0, xmm1, dqword [rax], xmm3 -vfnmaddpd xmm0, xmm1, xmm2, dqword [rax] -vfnmaddpd ymm0, ymm1, ymm2, ymm3 -vfnmaddpd ymm0, ymm1, yword [rax], ymm3 -vfnmaddpd ymm0, ymm1, ymm2, yword [rax] - -vfnmaddps xmm0, xmm1, xmm2, xmm3 -vfnmaddps xmm0, xmm1, dqword [rax], xmm3 -vfnmaddps xmm0, xmm1, xmm2, dqword [rax] -vfnmaddps ymm0, ymm1, ymm2, ymm3 -vfnmaddps ymm0, ymm1, yword [rax], ymm3 -vfnmaddps ymm0, ymm1, ymm2, yword [rax] - -vfnmaddsd xmm0, xmm1, xmm2, xmm3 -vfnmaddsd xmm0, xmm1, qword [rax], xmm3 -vfnmaddsd xmm0, xmm1, xmm2, qword [rax] - -vfnmaddss xmm0, xmm1, xmm2, xmm3 -vfnmaddss xmm0, xmm1, dword [rax], xmm3 -vfnmaddss xmm0, xmm1, xmm2, dword [rax] - -vfnmsubpd xmm0, xmm1, xmm2, xmm3 -vfnmsubpd xmm0, xmm1, dqword [rax], xmm3 -vfnmsubpd xmm0, xmm1, xmm2, dqword [rax] -vfnmsubpd ymm0, ymm1, ymm2, ymm3 -vfnmsubpd ymm0, ymm1, yword [rax], ymm3 -vfnmsubpd ymm0, ymm1, ymm2, yword [rax] - -vfnmsubps xmm0, xmm1, xmm2, xmm3 -vfnmsubps xmm0, xmm1, dqword [rax], xmm3 -vfnmsubps xmm0, xmm1, xmm2, dqword [rax] -vfnmsubps ymm0, ymm1, ymm2, ymm3 -vfnmsubps ymm0, ymm1, yword [rax], ymm3 -vfnmsubps ymm0, ymm1, ymm2, yword [rax] - -vfnmsubsd xmm0, xmm1, xmm2, xmm3 -vfnmsubsd xmm0, xmm1, qword [rax], xmm3 -vfnmsubsd xmm0, xmm1, xmm2, qword [rax] - -vfnmsubss xmm0, xmm1, xmm2, xmm3 -vfnmsubss xmm0, xmm1, dword [rax], xmm3 -vfnmsubss xmm0, xmm1, xmm2, dword [rax] - diff --git a/modules/arch/x86/tests/amd-fma4.hex b/modules/arch/x86/tests/amd-fma4.hex deleted file mode 100644 index a1193179..00000000 --- a/modules/arch/x86/tests/amd-fma4.hex +++ /dev/null @@ -1,540 +0,0 @@ -c4 -e3 -71 -69 -c2 -30 -c4 -e3 -71 -69 -00 -30 -c4 -e3 -71 -69 -00 -30 -c4 -e3 -f1 -69 -00 -20 -c4 -e3 -f1 -69 -00 -20 -c4 -e3 -75 -69 -c2 -30 -c4 -e3 -75 -69 -00 -30 -c4 -e3 -75 -69 -00 -30 -c4 -e3 -f5 -69 -00 -20 -c4 -e3 -f5 -69 -00 -20 -c4 -e3 -71 -68 -c2 -30 -c4 -e3 -71 -68 -00 -30 -c4 -e3 -f1 -68 -00 -20 -c4 -e3 -75 -68 -c2 -30 -c4 -e3 -75 -68 -00 -30 -c4 -e3 -f5 -68 -00 -20 -c4 -e3 -71 -6b -c2 -30 -c4 -e3 -71 -6b -00 -30 -c4 -e3 -71 -6b -00 -30 -c4 -e3 -f1 -6b -00 -20 -c4 -e3 -f1 -6b -00 -20 -c4 -e3 -71 -6a -c2 -30 -c4 -e3 -71 -6a -00 -30 -c4 -e3 -f1 -6a -00 -20 -c4 -e3 -71 -5d -c2 -30 -c4 -e3 -71 -5d -00 -30 -c4 -e3 -f1 -5d -00 -20 -c4 -e3 -75 -5d -c2 -30 -c4 -e3 -75 -5d -00 -30 -c4 -e3 -f5 -5d -00 -20 -c4 -e3 -71 -5c -c2 -30 -c4 -e3 -71 -5c -00 -30 -c4 -e3 -f1 -5c -00 -20 -c4 -e3 -75 -5c -c2 -30 -c4 -e3 -75 -5c -00 -30 -c4 -e3 -f5 -5c -00 -20 -c4 -e3 -71 -6d -c2 -30 -c4 -e3 -71 -6d -00 -30 -c4 -e3 -f1 -6d -00 -20 -c4 -e3 -75 -6d -c2 -30 -c4 -e3 -75 -6d -00 -30 -c4 -e3 -f5 -6d -00 -20 -c4 -e3 -71 -6c -c2 -30 -c4 -e3 -71 -6c -00 -30 -c4 -e3 -f1 -6c -00 -20 -c4 -e3 -75 -6c -c2 -30 -c4 -e3 -75 -6c -00 -30 -c4 -e3 -f5 -6c -00 -20 -c4 -e3 -71 -6f -c2 -30 -c4 -e3 -71 -6f -00 -30 -c4 -e3 -f1 -6f -00 -20 -c4 -e3 -71 -6e -c2 -30 -c4 -e3 -71 -6e -00 -30 -c4 -e3 -f1 -6e -00 -20 -c4 -e3 -71 -79 -c2 -30 -c4 -e3 -71 -79 -00 -30 -c4 -e3 -f1 -79 -00 -20 -c4 -e3 -75 -79 -c2 -30 -c4 -e3 -75 -79 -00 -30 -c4 -e3 -f5 -79 -00 -20 -c4 -e3 -71 -78 -c2 -30 -c4 -e3 -71 -78 -00 -30 -c4 -e3 -f1 -78 -00 -20 -c4 -e3 -75 -78 -c2 -30 -c4 -e3 -75 -78 -00 -30 -c4 -e3 -f5 -78 -00 -20 -c4 -e3 -71 -7b -c2 -30 -c4 -e3 -71 -7b -00 -30 -c4 -e3 -f1 -7b -00 -20 -c4 -e3 -71 -7a -c2 -30 -c4 -e3 -71 -7a -00 -30 -c4 -e3 -f1 -7a -00 -20 -c4 -e3 -71 -7d -c2 -30 -c4 -e3 -71 -7d -00 -30 -c4 -e3 -f1 -7d -00 -20 -c4 -e3 -75 -7d -c2 -30 -c4 -e3 -75 -7d -00 -30 -c4 -e3 -f5 -7d -00 -20 -c4 -e3 -71 -7c -c2 -30 -c4 -e3 -71 -7c -00 -30 -c4 -e3 -f1 -7c -00 -20 -c4 -e3 -75 -7c -c2 -30 -c4 -e3 -75 -7c -00 -30 -c4 -e3 -f5 -7c -00 -20 -c4 -e3 -71 -7f -c2 -30 -c4 -e3 -71 -7f -00 -30 -c4 -e3 -f1 -7f -00 -20 -c4 -e3 -71 -7e -c2 -30 -c4 -e3 -71 -7e -00 -30 -c4 -e3 -f1 -7e -00 -20 diff --git a/modules/arch/x86/tests/amd200707.asm b/modules/arch/x86/tests/amd200707.asm deleted file mode 100644 index 42c26a3c..00000000 --- a/modules/arch/x86/tests/amd200707.asm +++ /dev/null @@ -1,31 +0,0 @@ -bits 64 -extrq xmm0, 5, 4 -extrq xmm6, 0, 7 -extrq xmm2, xmm3 -insertq xmm0, xmm1, 5, 4 -insertq xmm5, xmm6, 0, 7 -insertq xmm2, xmm3 -movntsd [0], xmm1 -movntsd qword [0], xmm5 -movntss [0], xmm3 -movntss dword [0], xmm7 - -lzcnt ax, bx -lzcnt cx, word [0] -lzcnt dx, [0] -lzcnt eax, ebx -lzcnt ecx, dword [0] -lzcnt edx, [0] -lzcnt rax, rbx -lzcnt rcx, qword [0] -lzcnt rdx, [0] - -popcnt ax, bx -popcnt cx, word [0] -popcnt dx, [0] -popcnt eax, ebx -popcnt ecx, dword [0] -popcnt edx, [0] -popcnt rax, rbx -popcnt rcx, qword [0] -popcnt rdx, [0] diff --git a/modules/arch/x86/tests/amd200707.hex b/modules/arch/x86/tests/amd200707.hex deleted file mode 100644 index 28b58a12..00000000 --- a/modules/arch/x86/tests/amd200707.hex +++ /dev/null @@ -1,212 +0,0 @@ -66 -0f -78 -c0 -05 -04 -66 -0f -78 -c6 -00 -07 -66 -0f -79 -d3 -f2 -0f -78 -c1 -05 -04 -f2 -0f -78 -ee -00 -07 -f2 -0f -79 -d3 -f2 -0f -2b -0c -25 -00 -00 -00 -00 -f2 -0f -2b -2c -25 -00 -00 -00 -00 -f3 -0f -2b -1c -25 -00 -00 -00 -00 -f3 -0f -2b -3c -25 -00 -00 -00 -00 -66 -f3 -0f -bd -c3 -66 -f3 -0f -bd -0c -25 -00 -00 -00 -00 -66 -f3 -0f -bd -14 -25 -00 -00 -00 -00 -f3 -0f -bd -c3 -f3 -0f -bd -0c -25 -00 -00 -00 -00 -f3 -0f -bd -14 -25 -00 -00 -00 -00 -f3 -48 -0f -bd -c3 -f3 -48 -0f -bd -0c -25 -00 -00 -00 -00 -f3 -48 -0f -bd -14 -25 -00 -00 -00 -00 -66 -f3 -0f -b8 -c3 -66 -f3 -0f -b8 -0c -25 -00 -00 -00 -00 -66 -f3 -0f -b8 -14 -25 -00 -00 -00 -00 -f3 -0f -b8 -c3 -f3 -0f -b8 -0c -25 -00 -00 -00 -00 -f3 -0f -b8 -14 -25 -00 -00 -00 -00 -f3 -48 -0f -b8 -c3 -f3 -48 -0f -b8 -0c -25 -00 -00 -00 -00 -f3 -48 -0f -b8 -14 -25 -00 -00 -00 -00 diff --git a/modules/arch/x86/tests/avx.asm b/modules/arch/x86/tests/avx.asm deleted file mode 100644 index eff8cc97..00000000 --- a/modules/arch/x86/tests/avx.asm +++ /dev/null @@ -1,2617 +0,0 @@ -; Exhaustive test of AVX instructions -; Also includes based-upon SSE instructions for comparison -; -; Copyright (C) 2008 Peter Johnson -; -; Redistribution and use in source and binary forms, with or without -; modification, are permitted provided that the following conditions -; are met: -; 1. Redistributions of source code must retain the above copyright -; notice, this list of conditions and the following disclaimer. -; 2. Redistributions in binary form must reproduce the above copyright -; notice, this list of conditions and the following disclaimer in the -; documentation and/or other materials provided with the distribution. -; -; THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND OTHER CONTRIBUTORS ``AS IS'' -; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -; ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR OTHER CONTRIBUTORS BE -; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -; POSSIBILITY OF SUCH DAMAGE. -; - -[bits 64] -addpd xmm1, xmm2 -addpd xmm1, [rax] -addpd xmm1, dqword [rax] -addpd xmm10, xmm12 -addpd xmm10, [rax+r15*4] -addpd xmm10, [r14+r15*4] - -vaddpd xmm1, xmm2 -vaddpd xmm1, [rax] -vaddpd xmm1, dqword [rax] -vaddpd xmm10, xmm12 -vaddpd xmm10, [rax+r15*4] -vaddpd xmm10, [r14+r15*4] - -vaddpd xmm1, xmm2, xmm3 -vaddpd xmm1, xmm2, [rax] -vaddpd xmm1, xmm2, dqword [rax] -vaddpd xmm10, xmm12, xmm13 -vaddpd xmm10, xmm12, [rax+r15*4] -vaddpd xmm10, xmm12, [r14+r15*4] - -vaddpd ymm1, ymm2, ymm3 -vaddpd ymm1, ymm2, [rax] -vaddpd ymm1, ymm2, yword [rax] -vaddpd ymm10, ymm12, ymm13 -vaddpd ymm10, ymm12, [rax+r15*4] -vaddpd ymm10, ymm12, [r14+r15*4] - -; Further instructions won't test high 8 registers (validated above) -addps xmm1, xmm2 -addps xmm1, [rax] -addps xmm1, dqword [rax] -vaddps xmm1, xmm2 -vaddps xmm1, [rax] -vaddps xmm1, dqword [rax] -vaddps xmm1, xmm2, xmm3 -vaddps xmm1, xmm2, [rax] -vaddps xmm1, xmm2, dqword [rax] -vaddps ymm1, ymm2, ymm3 -vaddps ymm1, ymm2, [rax] -vaddps ymm1, ymm2, yword [rax] - -addsd xmm1, xmm2 -addsd xmm1, [rax] -addsd xmm1, qword [rax] -vaddsd xmm1, xmm2 -vaddsd xmm1, [rax] -vaddsd xmm1, qword [rax] -vaddsd xmm1, xmm2, xmm3 -vaddsd xmm1, xmm2, [rax] -vaddsd xmm1, xmm2, qword [rax] - -addss xmm1, xmm2 -addss xmm1, [rax] -addss xmm1, dword [rax] -vaddss xmm1, xmm2 -vaddss xmm1, [rax] -vaddss xmm1, dword [rax] -vaddss xmm1, xmm2, xmm3 -vaddss xmm1, xmm2, [rax] -vaddss xmm1, xmm2, dword [rax] - -addsubpd xmm1, xmm2 -addsubpd xmm1, [rax] -addsubpd xmm1, dqword [rax] -vaddsubpd xmm1, xmm2 -vaddsubpd xmm1, [rax] -vaddsubpd xmm1, dqword [rax] -vaddsubpd xmm1, xmm2, xmm3 -vaddsubpd xmm1, xmm2, [rax] -vaddsubpd xmm1, xmm2, dqword [rax] -vaddsubpd ymm1, ymm2, ymm3 -vaddsubpd ymm1, ymm2, [rax] -vaddsubpd ymm1, ymm2, yword [rax] - -addsubps xmm1, xmm2 -addsubps xmm1, [rax] -addsubps xmm1, dqword [rax] -vaddsubps xmm1, xmm2 -vaddsubps xmm1, [rax] -vaddsubps xmm1, dqword [rax] -vaddsubps xmm1, xmm2, xmm3 -vaddsubps xmm1, xmm2, [rax] -vaddsubps xmm1, xmm2, dqword [rax] -vaddsubps ymm1, ymm2, ymm3 -vaddsubps ymm1, ymm2, [rax] -vaddsubps ymm1, ymm2, yword [rax] - -andpd xmm1, xmm2 -andpd xmm1, [rax] -andpd xmm1, dqword [rax] -vandpd xmm1, xmm2 -vandpd xmm1, [rax] -vandpd xmm1, dqword [rax] -vandpd xmm1, xmm2, xmm3 -vandpd xmm1, xmm2, [rax] -vandpd xmm1, xmm2, dqword [rax] -vandpd ymm1, ymm2, ymm3 -vandpd ymm1, ymm2, [rax] -vandpd ymm1, ymm2, yword [rax] - -andps xmm1, xmm2 -andps xmm1, [rax] -andps xmm1, dqword [rax] -vandps xmm1, xmm2 -vandps xmm1, [rax] -vandps xmm1, dqword [rax] -vandps xmm1, xmm2, xmm3 -vandps xmm1, xmm2, [rax] -vandps xmm1, xmm2, dqword [rax] -vandps ymm1, ymm2, ymm3 -vandps ymm1, ymm2, [rax] -vandps ymm1, ymm2, yword [rax] - -andnpd xmm1, xmm2 -andnpd xmm1, [rax] -andnpd xmm1, dqword [rax] -vandnpd xmm1, xmm2 -vandnpd xmm1, [rax] -vandnpd xmm1, dqword [rax] -vandnpd xmm1, xmm2, xmm3 -vandnpd xmm1, xmm2, [rax] -vandnpd xmm1, xmm2, dqword [rax] -vandnpd ymm1, ymm2, ymm3 -vandnpd ymm1, ymm2, [rax] -vandnpd ymm1, ymm2, yword [rax] - -andnps xmm1, xmm2 -andnps xmm1, [rax] -andnps xmm1, dqword [rax] -vandnps xmm1, xmm2 -vandnps xmm1, [rax] -vandnps xmm1, dqword [rax] -vandnps xmm1, xmm2, xmm3 -vandnps xmm1, xmm2, [rax] -vandnps xmm1, xmm2, dqword [rax] -vandnps ymm1, ymm2, ymm3 -vandnps ymm1, ymm2, [rax] -vandnps ymm1, ymm2, yword [rax] - -blendpd xmm1, xmm2, 5 -blendpd xmm1, [rax], byte 5 -blendpd xmm1, dqword [rax], 5 -vblendpd xmm1, xmm2, 5 -vblendpd xmm1, [rax], byte 5 -vblendpd xmm1, dqword [rax], 5 -vblendpd xmm1, xmm2, xmm3, 5 -vblendpd xmm1, xmm2, [rax], byte 5 -vblendpd xmm1, xmm2, dqword [rax], 5 -vblendpd ymm1, ymm2, ymm3, 5 -vblendpd ymm1, ymm2, [rax], byte 5 -vblendpd ymm1, ymm2, yword [rax], 5 - -blendps xmm1, xmm2, 5 -blendps xmm1, [rax], byte 5 -blendps xmm1, dqword [rax], 5 -vblendps xmm1, xmm2, 5 -vblendps xmm1, [rax], byte 5 -vblendps xmm1, dqword [rax], 5 -vblendps xmm1, xmm2, xmm3, 5 -vblendps xmm1, xmm2, [rax], byte 5 -vblendps xmm1, xmm2, dqword [rax], 5 -vblendps ymm1, ymm2, ymm3, 5 -vblendps ymm1, ymm2, [rax], byte 5 -vblendps ymm1, ymm2, yword [rax], 5 - -; blendvpd doesn't have vex-encoded version of implicit xmm0 -blendvpd xmm1, xmm3 -blendvpd xmm1, [rax] -blendvpd xmm1, dqword [rax] -blendvpd xmm1, xmm3, xmm0 -blendvpd xmm1, [rax], xmm0 -blendvpd xmm1, dqword [rax], xmm0 -vblendvpd xmm1, xmm2, xmm3, xmm4 -vblendvpd xmm1, xmm2, [rax], xmm4 -vblendvpd xmm1, xmm2, dqword [rax], xmm4 -vblendvpd ymm1, ymm2, ymm3, ymm4 -vblendvpd ymm1, ymm2, [rax], ymm4 -vblendvpd ymm1, ymm2, yword [rax], ymm4 - -; blendvps doesn't have vex-encoded version of implicit xmm0 -blendvps xmm1, xmm3 -blendvps xmm1, [rax] -blendvps xmm1, dqword [rax] -blendvps xmm1, xmm3, xmm0 -blendvps xmm1, [rax], xmm0 -blendvps xmm1, dqword [rax], xmm0 -vblendvps xmm1, xmm2, xmm3, xmm4 -vblendvps xmm1, xmm2, [rax], xmm4 -vblendvps xmm1, xmm2, dqword [rax], xmm4 -vblendvps ymm1, ymm2, ymm3, ymm4 -vblendvps ymm1, ymm2, [rax], ymm4 -vblendvps ymm1, ymm2, yword [rax], ymm4 - -vbroadcastss xmm1, [rax] -vbroadcastss xmm1, dword [rax] -vbroadcastss ymm1, [rax] -vbroadcastss ymm1, dword [rax] - -vbroadcastsd ymm1, [rax] -vbroadcastsd ymm1, qword [rax] - -vbroadcastf128 ymm1, [rax] -vbroadcastf128 ymm1, dqword [rax] - -cmppd xmm1, xmm2, 5 -cmppd xmm1, [rax], byte 5 -cmppd xmm1, dqword [rax], 5 -vcmppd xmm1, xmm2, 5 -vcmppd xmm1, [rax], byte 5 -vcmppd xmm1, dqword [rax], 5 -vcmppd xmm1, xmm2, xmm3, 5 -vcmppd xmm1, xmm2, [rax], byte 5 -vcmppd xmm1, xmm2, dqword [rax], 5 -vcmppd ymm1, ymm2, ymm3, 5 -vcmppd ymm1, ymm2, [rax], byte 5 -vcmppd ymm1, ymm2, yword [rax], 5 - -cmpps xmm1, xmm2, 5 -cmpps xmm1, [rax], byte 5 -cmpps xmm1, dqword [rax], 5 -vcmpps xmm1, xmm2, 5 -vcmpps xmm1, [rax], byte 5 -vcmpps xmm1, dqword [rax], 5 -vcmpps xmm1, xmm2, xmm3, 5 -vcmpps xmm1, xmm2, [rax], byte 5 -vcmpps xmm1, xmm2, dqword [rax], 5 -vcmpps ymm1, ymm2, ymm3, 5 -vcmpps ymm1, ymm2, [rax], byte 5 -vcmpps ymm1, ymm2, yword [rax], 5 - -cmpsd xmm1, xmm2, 5 -cmpsd xmm1, [rax], byte 5 -cmpsd xmm1, qword [rax], 5 -vcmpsd xmm1, xmm2, 5 -vcmpsd xmm1, [rax], byte 5 -vcmpsd xmm1, qword [rax], 5 -vcmpsd xmm1, xmm2, xmm3, 5 -vcmpsd xmm1, xmm2, [rax], byte 5 -vcmpsd xmm1, xmm2, qword [rax], 5 - -cmpss xmm1, xmm2, 5 -cmpss xmm1, [rax], byte 5 -cmpss xmm1, dword [rax], 5 -vcmpss xmm1, xmm2, 5 -vcmpss xmm1, [rax], byte 5 -vcmpss xmm1, dword [rax], 5 -vcmpss xmm1, xmm2, xmm3, 5 -vcmpss xmm1, xmm2, [rax], byte 5 -vcmpss xmm1, xmm2, dword [rax], 5 - -comisd xmm1, xmm2 -comisd xmm1, [rax] -comisd xmm1, qword [rax] -vcomisd xmm1, xmm2 -vcomisd xmm1, [rax] -vcomisd xmm1, qword [rax] - -comiss xmm1, xmm2 -comiss xmm1, [rax] -comiss xmm1, dword [rax] -vcomiss xmm1, xmm2 -vcomiss xmm1, [rax] -vcomiss xmm1, dword [rax] - -cvtdq2pd xmm1, xmm2 -cvtdq2pd xmm1, [rax] -cvtdq2pd xmm1, qword [rax] -vcvtdq2pd xmm1, xmm2 -vcvtdq2pd xmm1, [rax] -vcvtdq2pd xmm1, qword [rax] -vcvtdq2pd ymm1, xmm2 -vcvtdq2pd ymm1, [rax] -vcvtdq2pd ymm1, dqword [rax] - -cvtdq2ps xmm1, xmm2 -cvtdq2ps xmm1, [rax] -cvtdq2ps xmm1, dqword [rax] -vcvtdq2ps xmm1, xmm2 -vcvtdq2ps xmm1, [rax] -vcvtdq2ps xmm1, dqword [rax] -vcvtdq2ps ymm1, ymm2 -vcvtdq2ps ymm1, [rax] -vcvtdq2ps ymm1, yword [rax] - -; These require memory operand size to be specified (in AVX version) -cvtpd2dq xmm1, xmm2 -cvtpd2dq xmm1, [rax] -cvtpd2dq xmm1, dqword [rax] -vcvtpd2dq xmm1, xmm2 -vcvtpd2dq xmm1, dqword [rax] -vcvtpd2dq xmm1, ymm2 -vcvtpd2dq xmm1, yword [rax] - -cvtpd2ps xmm1, xmm2 -cvtpd2ps xmm1, [rax] -cvtpd2ps xmm1, dqword [rax] -vcvtpd2ps xmm1, xmm2 -vcvtpd2ps xmm1, dqword [rax] -vcvtpd2ps xmm1, ymm2 -vcvtpd2ps xmm1, yword [rax] - -cvtps2dq xmm1, xmm2 -cvtps2dq xmm1, [rax] -cvtps2dq xmm1, dqword [rax] -vcvtps2dq xmm1, xmm2 -vcvtps2dq xmm1, [rax] -vcvtps2dq xmm1, dqword [rax] -vcvtps2dq ymm1, ymm2 -vcvtps2dq ymm1, [rax] -vcvtps2dq ymm1, yword [rax] - -cvtps2pd xmm1, xmm2 -cvtps2pd xmm1, [rax] -cvtps2pd xmm1, qword [rax] -vcvtps2pd xmm1, xmm2 -vcvtps2pd xmm1, [rax] -vcvtps2pd xmm1, qword [rax] -vcvtps2pd ymm1, xmm2 -vcvtps2pd ymm1, [rax] -vcvtps2pd ymm1, dqword [rax] - -cvtsd2si eax, xmm2 -cvtsd2si eax, [rax] -cvtsd2si eax, qword [rax] -vcvtsd2si eax, xmm2 -vcvtsd2si eax, [rax] -vcvtsd2si eax, qword [rax] -cvtsd2si rax, xmm2 -cvtsd2si rax, [rax] -cvtsd2si rax, qword [rax] -vcvtsd2si rax, xmm2 -vcvtsd2si rax, [rax] -vcvtsd2si rax, qword [rax] - -cvtsd2ss xmm1, xmm2 -cvtsd2ss xmm1, [rax] -cvtsd2ss xmm1, qword [rax] -vcvtsd2ss xmm1, xmm2 -vcvtsd2ss xmm1, [rax] -vcvtsd2ss xmm1, qword [rax] -vcvtsd2ss xmm1, xmm2, xmm3 -vcvtsd2ss xmm1, xmm2, [rax] -vcvtsd2ss xmm1, xmm2, qword [rax] - -; unsized not valid -cvtsi2sd xmm1, eax -cvtsi2sd xmm1, dword [rax] -vcvtsi2sd xmm1, eax -vcvtsi2sd xmm1, dword [rax] -vcvtsi2sd xmm1, xmm2, eax -vcvtsi2sd xmm1, xmm2, dword [rax] -cvtsi2sd xmm1, rax -cvtsi2sd xmm1, qword [rax] -vcvtsi2sd xmm1, rax -vcvtsi2sd xmm1, qword [rax] -vcvtsi2sd xmm1, xmm2, rax -vcvtsi2sd xmm1, xmm2, qword [rax] - -cvtsi2ss xmm1, eax -cvtsi2ss xmm1, dword [rax] -vcvtsi2ss xmm1, eax -vcvtsi2ss xmm1, dword [rax] -vcvtsi2ss xmm1, xmm2, eax -vcvtsi2ss xmm1, xmm2, dword [rax] -cvtsi2ss xmm1, rax -cvtsi2ss xmm1, qword [rax] -vcvtsi2ss xmm1, rax -vcvtsi2ss xmm1, qword [rax] -vcvtsi2ss xmm1, xmm2, rax -vcvtsi2ss xmm1, xmm2, qword [rax] - -cvtss2sd xmm1, xmm2 -cvtss2sd xmm1, [rax] -cvtss2sd xmm1, dword [rax] -vcvtss2sd xmm1, xmm2 -vcvtss2sd xmm1, [rax] -vcvtss2sd xmm1, dword [rax] -vcvtss2sd xmm1, xmm2, xmm3 -vcvtss2sd xmm1, xmm2, [rax] -vcvtss2sd xmm1, xmm2, dword [rax] - -cvtss2si eax, xmm2 -cvtss2si eax, [rax] -cvtss2si eax, dword [rax] -vcvtss2si eax, xmm2 -vcvtss2si eax, [rax] -vcvtss2si eax, dword [rax] -cvtss2si rax, xmm2 -cvtss2si rax, [rax] -cvtss2si rax, dword [rax] -vcvtss2si rax, xmm2 -vcvtss2si rax, [rax] -vcvtss2si rax, dword [rax] - -; These require memory operand size to be specified (in AVX version) -cvttpd2dq xmm1, xmm2 -cvttpd2dq xmm1, [rax] -cvttpd2dq xmm1, dqword [rax] -vcvttpd2dq xmm1, xmm2 -vcvttpd2dq xmm1, dqword [rax] -vcvttpd2dq xmm1, ymm2 -vcvttpd2dq xmm1, yword [rax] - -cvttps2dq xmm1, xmm2 -cvttps2dq xmm1, [rax] -cvttps2dq xmm1, dqword [rax] -vcvttps2dq xmm1, xmm2 -vcvttps2dq xmm1, [rax] -vcvttps2dq xmm1, dqword [rax] -vcvttps2dq ymm1, ymm2 -vcvttps2dq ymm1, [rax] -vcvttps2dq ymm1, yword [rax] - -cvttsd2si eax, xmm2 -cvttsd2si eax, [rax] -cvttsd2si eax, qword [rax] -vcvttsd2si eax, xmm2 -vcvttsd2si eax, [rax] -vcvttsd2si eax, qword [rax] -cvttsd2si rax, xmm2 -cvttsd2si rax, [rax] -cvttsd2si rax, qword [rax] -vcvttsd2si rax, xmm2 -vcvttsd2si rax, [rax] -vcvttsd2si rax, qword [rax] - -cvttss2si eax, xmm2 -cvttss2si eax, [rax] -cvttss2si eax, dword [rax] -vcvttss2si eax, xmm2 -vcvttss2si eax, [rax] -vcvttss2si eax, dword [rax] -cvttss2si rax, xmm2 -cvttss2si rax, [rax] -cvttss2si rax, dword [rax] -vcvttss2si rax, xmm2 -vcvttss2si rax, [rax] -vcvttss2si rax, dword [rax] - -divpd xmm1, xmm2 -divpd xmm1, [rax] -divpd xmm1, dqword [rax] -vdivpd xmm1, xmm2 -vdivpd xmm1, [rax] -vdivpd xmm1, dqword [rax] -vdivpd xmm1, xmm2, xmm3 -vdivpd xmm1, xmm2, [rax] -vdivpd xmm1, xmm2, dqword [rax] -vdivpd ymm1, ymm2, ymm3 -vdivpd ymm1, ymm2, [rax] -vdivpd ymm1, ymm2, yword [rax] - -divps xmm1, xmm2 -divps xmm1, [rax] -divps xmm1, dqword [rax] -vdivps xmm1, xmm2 -vdivps xmm1, [rax] -vdivps xmm1, dqword [rax] -vdivps xmm1, xmm2, xmm3 -vdivps xmm1, xmm2, [rax] -vdivps xmm1, xmm2, dqword [rax] -vdivps ymm1, ymm2, ymm3 -vdivps ymm1, ymm2, [rax] -vdivps ymm1, ymm2, yword [rax] - -divsd xmm1, xmm2 -divsd xmm1, [rax] -divsd xmm1, qword [rax] -vdivsd xmm1, xmm2 -vdivsd xmm1, [rax] -vdivsd xmm1, qword [rax] -vdivsd xmm1, xmm2, xmm3 -vdivsd xmm1, xmm2, [rax] -vdivsd xmm1, xmm2, qword [rax] - -divss xmm1, xmm2 -divss xmm1, [rax] -divss xmm1, dword [rax] -vdivss xmm1, xmm2 -vdivss xmm1, [rax] -vdivss xmm1, dword [rax] -vdivss xmm1, xmm2, xmm3 -vdivss xmm1, xmm2, [rax] -vdivss xmm1, xmm2, dword [rax] - -dppd xmm1, xmm2, 5 -dppd xmm1, [rax], byte 5 -dppd xmm1, dqword [rax], 5 -vdppd xmm1, xmm2, 5 -vdppd xmm1, [rax], byte 5 -vdppd xmm1, dqword [rax], 5 -vdppd xmm1, xmm2, xmm3, 5 -vdppd xmm1, xmm2, [rax], byte 5 -vdppd xmm1, xmm2, dqword [rax], 5 -; no ymm version - -dpps xmm1, xmm2, 5 -dpps xmm1, [rax], byte 5 -dpps xmm1, dqword [rax], 5 -vdpps xmm1, xmm2, 5 -vdpps xmm1, [rax], byte 5 -vdpps xmm1, dqword [rax], 5 -vdpps xmm1, xmm2, xmm3, 5 -vdpps xmm1, xmm2, [rax], byte 5 -vdpps xmm1, xmm2, dqword [rax], 5 -vdpps ymm1, ymm2, ymm3, 5 -vdpps ymm1, ymm2, [rax], byte 5 -vdpps ymm1, ymm2, yword [rax], 5 - -vextractf128 xmm1, ymm2, 5 -vextractf128 [rax], ymm2, byte 5 -vextractf128 dqword [rax], ymm2, 5 - -extractps eax, xmm1, 5 -extractps rax, xmm1, 5 -extractps [rax], xmm1, byte 5 -extractps dword [rax], xmm1, 5 -vextractps eax, xmm1, 5 -vextractps rax, xmm1, 5 -vextractps [rax], xmm1, byte 5 -vextractps dword [rax], xmm1, 5 - -haddpd xmm1, xmm2 -haddpd xmm1, [rax] -haddpd xmm1, dqword [rax] -vhaddpd xmm1, xmm2 -vhaddpd xmm1, [rax] -vhaddpd xmm1, dqword [rax] -vhaddpd xmm1, xmm2, xmm3 -vhaddpd xmm1, xmm2, [rax] -vhaddpd xmm1, xmm2, dqword [rax] -vhaddpd ymm1, ymm2, ymm3 -vhaddpd ymm1, ymm2, [rax] -vhaddpd ymm1, ymm2, yword [rax] - -haddps xmm1, xmm2 -haddps xmm1, [rax] -haddps xmm1, dqword [rax] -vhaddps xmm1, xmm2 -vhaddps xmm1, [rax] -vhaddps xmm1, dqword [rax] -vhaddps xmm1, xmm2, xmm3 -vhaddps xmm1, xmm2, [rax] -vhaddps xmm1, xmm2, dqword [rax] -vhaddps ymm1, ymm2, ymm3 -vhaddps ymm1, ymm2, [rax] -vhaddps ymm1, ymm2, yword [rax] - -hsubpd xmm1, xmm2 -hsubpd xmm1, [rax] -hsubpd xmm1, dqword [rax] -vhsubpd xmm1, xmm2 -vhsubpd xmm1, [rax] -vhsubpd xmm1, dqword [rax] -vhsubpd xmm1, xmm2, xmm3 -vhsubpd xmm1, xmm2, [rax] -vhsubpd xmm1, xmm2, dqword [rax] -vhsubpd ymm1, ymm2, ymm3 -vhsubpd ymm1, ymm2, [rax] -vhsubpd ymm1, ymm2, yword [rax] - -hsubps xmm1, xmm2 -hsubps xmm1, [rax] -hsubps xmm1, dqword [rax] -vhsubps xmm1, xmm2 -vhsubps xmm1, [rax] -vhsubps xmm1, dqword [rax] -vhsubps xmm1, xmm2, xmm3 -vhsubps xmm1, xmm2, [rax] -vhsubps xmm1, xmm2, dqword [rax] -vhsubps ymm1, ymm2, ymm3 -vhsubps ymm1, ymm2, [rax] -vhsubps ymm1, ymm2, yword [rax] - -vinsertf128 ymm1, ymm2, xmm3, 5 -vinsertf128 ymm1, ymm2, [rax], byte 5 -vinsertf128 ymm1, ymm2, dqword [rax], 5 - -insertps xmm1, xmm2, 5 -insertps xmm1, [rax], byte 5 -insertps xmm1, dword [rax], 5 -vinsertps xmm1, xmm2, 5 -vinsertps xmm1, [rax], byte 5 -vinsertps xmm1, dword [rax], 5 -vinsertps xmm1, xmm2, xmm3, 5 -vinsertps xmm1, xmm2, [rax], byte 5 -vinsertps xmm1, xmm2, dword [rax], 5 - -lddqu xmm1, [rax] -lddqu xmm1, dqword [rax] -vlddqu xmm1, [rax] -vlddqu xmm1, dqword [rax] -vlddqu ymm1, [rax] -vlddqu ymm1, yword [rax] - -ldmxcsr [rax] -ldmxcsr dword [rax] -vldmxcsr [rax] -vldmxcsr dword [rax] - -maskmovdqu xmm1, xmm2 -vmaskmovdqu xmm1, xmm2 - -vmaskmovps xmm1, xmm2, [rax] -vmaskmovps xmm1, xmm2, dqword [rax] -vmaskmovps ymm1, ymm2, [rax] -vmaskmovps ymm1, ymm2, yword [rax] -vmaskmovps [rax], xmm2, xmm3 -vmaskmovps dqword [rax], xmm2, xmm3 -vmaskmovps [rax], ymm2, ymm3 -vmaskmovps yword [rax], ymm2, ymm3 - -vmaskmovpd xmm1, xmm2, [rax] -vmaskmovpd xmm1, xmm2, dqword [rax] -vmaskmovpd ymm1, ymm2, [rax] -vmaskmovpd ymm1, ymm2, yword [rax] -vmaskmovpd [rax], xmm2, xmm3 -vmaskmovpd dqword [rax], xmm2, xmm3 -vmaskmovpd [rax], ymm2, ymm3 -vmaskmovpd yword [rax], ymm2, ymm3 - -maxpd xmm1, xmm2 -maxpd xmm1, [rax] -maxpd xmm1, dqword [rax] -vmaxpd xmm1, xmm2 -vmaxpd xmm1, [rax] -vmaxpd xmm1, dqword [rax] -vmaxpd xmm1, xmm2, xmm3 -vmaxpd xmm1, xmm2, [rax] -vmaxpd xmm1, xmm2, dqword [rax] -vmaxpd ymm1, ymm2, ymm3 -vmaxpd ymm1, ymm2, [rax] -vmaxpd ymm1, ymm2, yword [rax] - -maxps xmm1, xmm2 -maxps xmm1, [rax] -maxps xmm1, dqword [rax] -vmaxps xmm1, xmm2 -vmaxps xmm1, [rax] -vmaxps xmm1, dqword [rax] -vmaxps xmm1, xmm2, xmm3 -vmaxps xmm1, xmm2, [rax] -vmaxps xmm1, xmm2, dqword [rax] -vmaxps ymm1, ymm2, ymm3 -vmaxps ymm1, ymm2, [rax] -vmaxps ymm1, ymm2, yword [rax] - -maxsd xmm1, xmm2 -maxsd xmm1, [rax] -maxsd xmm1, qword [rax] -vmaxsd xmm1, xmm2 -vmaxsd xmm1, [rax] -vmaxsd xmm1, qword [rax] -vmaxsd xmm1, xmm2, xmm3 -vmaxsd xmm1, xmm2, [rax] -vmaxsd xmm1, xmm2, qword [rax] - -maxss xmm1, xmm2 -maxss xmm1, [rax] -maxss xmm1, dword [rax] -vmaxss xmm1, xmm2 -vmaxss xmm1, [rax] -vmaxss xmm1, dword [rax] -vmaxss xmm1, xmm2, xmm3 -vmaxss xmm1, xmm2, [rax] -vmaxss xmm1, xmm2, dword [rax] - -minpd xmm1, xmm2 -minpd xmm1, [rax] -minpd xmm1, dqword [rax] -vminpd xmm1, xmm2 -vminpd xmm1, [rax] -vminpd xmm1, dqword [rax] -vminpd xmm1, xmm2, xmm3 -vminpd xmm1, xmm2, [rax] -vminpd xmm1, xmm2, dqword [rax] -vminpd ymm1, ymm2, ymm3 -vminpd ymm1, ymm2, [rax] -vminpd ymm1, ymm2, yword [rax] - -minps xmm1, xmm2 -minps xmm1, [rax] -minps xmm1, dqword [rax] -vminps xmm1, xmm2 -vminps xmm1, [rax] -vminps xmm1, dqword [rax] -vminps xmm1, xmm2, xmm3 -vminps xmm1, xmm2, [rax] -vminps xmm1, xmm2, dqword [rax] -vminps ymm1, ymm2, ymm3 -vminps ymm1, ymm2, [rax] -vminps ymm1, ymm2, yword [rax] - -minsd xmm1, xmm2 -minsd xmm1, [rax] -minsd xmm1, qword [rax] -vminsd xmm1, xmm2 -vminsd xmm1, [rax] -vminsd xmm1, qword [rax] -vminsd xmm1, xmm2, xmm3 -vminsd xmm1, xmm2, [rax] -vminsd xmm1, xmm2, qword [rax] - -minss xmm1, xmm2 -minss xmm1, [rax] -minss xmm1, dword [rax] -vminss xmm1, xmm2 -vminss xmm1, [rax] -vminss xmm1, dword [rax] -vminss xmm1, xmm2, xmm3 -vminss xmm1, xmm2, [rax] -vminss xmm1, xmm2, dword [rax] - -movapd xmm1, xmm2 -movapd xmm1, [rax] -movapd xmm1, dqword [rax] -vmovapd xmm1, xmm2 -vmovapd xmm1, [rax] -vmovapd xmm1, dqword [rax] -movapd [rax], xmm2 -movapd dqword [rax], xmm2 -vmovapd [rax], xmm2 -vmovapd dqword [rax], xmm2 -vmovapd ymm1, ymm2 -vmovapd ymm1, [rax] -vmovapd ymm1, yword [rax] -vmovapd [rax], ymm2 -vmovapd yword [rax], ymm2 - -movaps xmm1, xmm2 -movaps xmm1, [rax] -movaps xmm1, dqword [rax] -vmovaps xmm1, xmm2 -vmovaps xmm1, [rax] -vmovaps xmm1, dqword [rax] -movaps [rax], xmm2 -movaps dqword [rax], xmm2 -vmovaps [rax], xmm2 -vmovaps dqword [rax], xmm2 -vmovaps ymm1, ymm2 -vmovaps ymm1, [rax] -vmovaps ymm1, yword [rax] -vmovaps [rax], ymm2 -vmovaps yword [rax], ymm2 - -movd xmm1, eax -movd xmm1, [rax] -movd xmm1, dword [rax] -vmovd xmm1, eax -vmovd xmm1, [rax] -vmovd xmm1, dword [rax] -movd eax, xmm2 -movd [rax], xmm2 -movd dword [rax], xmm2 -vmovd eax, xmm2 -vmovd [rax], xmm2 -vmovd dword [rax], xmm2 - -movq xmm1, rax -movq xmm1, [rax] -movq xmm1, qword [rax] -vmovq xmm1, rax -vmovq xmm1, [rax] -vmovq xmm1, qword [rax] -movq rax, xmm2 -movq [rax], xmm2 -movq qword [rax], xmm2 -vmovq rax, xmm2 -vmovq [rax], xmm2 -vmovq qword [rax], xmm2 - -movq xmm1, xmm2 -movq xmm1, [rax] -movq xmm1, qword [rax] -vmovq xmm1, xmm2 -vmovq xmm1, [rax] -vmovq xmm1, qword [rax] -movq [rax], xmm1 -movq qword [rax], xmm1 -vmovq [rax], xmm1 -vmovq qword [rax], xmm1 - -movddup xmm1, xmm2 -movddup xmm1, [rax] -movddup xmm1, qword [rax] -vmovddup xmm1, xmm2 -vmovddup xmm1, [rax] -vmovddup xmm1, qword [rax] -vmovddup ymm1, ymm2 -vmovddup ymm1, [rax] -vmovddup ymm1, yword [rax] - -movdqa xmm1, xmm2 -movdqa xmm1, [rax] -movdqa xmm1, dqword [rax] -movdqa [rax], xmm2 -movdqa dqword [rax], xmm2 -vmovdqa xmm1, xmm2 -vmovdqa xmm1, [rax] -vmovdqa xmm1, dqword [rax] -vmovdqa [rax], xmm2 -vmovdqa dqword [rax], xmm2 -vmovdqa ymm1, ymm2 -vmovdqa ymm1, [rax] -vmovdqa ymm1, yword [rax] -vmovdqa [rax], ymm2 -vmovdqa yword [rax], ymm2 - -movdqu xmm1, xmm2 -movdqu xmm1, [rax] -movdqu xmm1, dqword [rax] -movdqu [rax], xmm2 -movdqu dqword [rax], xmm2 -vmovdqu xmm1, xmm2 -vmovdqu xmm1, [rax] -vmovdqu xmm1, dqword [rax] -vmovdqu [rax], xmm2 -vmovdqu dqword [rax], xmm2 -vmovdqu ymm1, ymm2 -vmovdqu ymm1, [rax] -vmovdqu ymm1, yword [rax] -vmovdqu [rax], ymm2 -vmovdqu yword [rax], ymm2 - -movhlps xmm1, xmm2 -vmovhlps xmm1, xmm2 -vmovhlps xmm1, xmm2, xmm3 - -movhpd xmm1, [rax] -movhpd xmm1, qword [rax] -vmovhpd xmm1, [rax] -vmovhpd xmm1, qword [rax] -vmovhpd xmm1, xmm2, [rax] -vmovhpd xmm1, xmm2, qword [rax] -movhpd [rax], xmm2 -movhpd qword [rax], xmm2 -vmovhpd [rax], xmm2 -vmovhpd qword [rax], xmm2 - -movhps xmm1, [rax] -movhps xmm1, qword [rax] -vmovhps xmm1, [rax] -vmovhps xmm1, qword [rax] -vmovhps xmm1, xmm2, [rax] -vmovhps xmm1, xmm2, qword [rax] -movhps [rax], xmm2 -movhps qword [rax], xmm2 -vmovhps [rax], xmm2 -vmovhps qword [rax], xmm2 - -movhlps xmm1, xmm2 -vmovhlps xmm1, xmm2 -vmovhlps xmm1, xmm2, xmm3 - -movlpd xmm1, [rax] -movlpd xmm1, qword [rax] -vmovlpd xmm1, [rax] -vmovlpd xmm1, qword [rax] -vmovlpd xmm1, xmm2, [rax] -vmovlpd xmm1, xmm2, qword [rax] -movlpd [rax], xmm2 -movlpd qword [rax], xmm2 -vmovlpd [rax], xmm2 -vmovlpd qword [rax], xmm2 - -movlps xmm1, [rax] -movlps xmm1, qword [rax] -vmovlps xmm1, [rax] -vmovlps xmm1, qword [rax] -vmovlps xmm1, xmm2, [rax] -vmovlps xmm1, xmm2, qword [rax] -movlps [rax], xmm2 -movlps qword [rax], xmm2 -vmovlps [rax], xmm2 -vmovlps qword [rax], xmm2 - -movmskpd eax, xmm2 -movmskpd rax, xmm2 -vmovmskpd eax, xmm2 -vmovmskpd rax, xmm2 -vmovmskpd eax, ymm2 -vmovmskpd rax, ymm2 - -movmskps eax, xmm2 -movmskps rax, xmm2 -vmovmskps eax, xmm2 -vmovmskps rax, xmm2 -vmovmskps eax, ymm2 -vmovmskps rax, ymm2 - -movntdq [rax], xmm1 -movntdq dqword [rax], xmm1 -vmovntdq [rax], xmm1 -vmovntdq dqword [rax], xmm1 -vmovntdq [rax], ymm1 -vmovntdq yword [rax], ymm1 - -movntdqa xmm1, [rax] -movntdqa xmm1, dqword [rax] -vmovntdqa xmm1, [rax] -vmovntdqa xmm1, dqword [rax] - -movntpd [rax], xmm1 -movntpd dqword [rax], xmm1 -vmovntpd [rax], xmm1 -vmovntpd dqword [rax], xmm1 -vmovntpd [rax], ymm1 -vmovntpd yword [rax], ymm1 - -movntps [rax], xmm1 -movntps dqword [rax], xmm1 -vmovntps [rax], xmm1 -vmovntps dqword [rax], xmm1 -vmovntps [rax], ymm1 -vmovntps yword [rax], ymm1 - -movsd xmm1, xmm2 -vmovsd xmm1, xmm2 -vmovsd xmm1, xmm2, xmm3 -movsd xmm1, [rax] -movsd xmm1, qword [rax] -vmovsd xmm1, [rax] -vmovsd xmm1, qword [rax] -movsd [rax], xmm2 -movsd qword [rax], xmm2 -vmovsd [rax], xmm2 -vmovsd qword [rax], xmm2 - -movshdup xmm1, xmm2 -movshdup xmm1, [rax] -movshdup xmm1, dqword [rax] -vmovshdup xmm1, xmm2 -vmovshdup xmm1, [rax] -vmovshdup xmm1, dqword [rax] -vmovshdup ymm1, ymm2 -vmovshdup ymm1, [rax] -vmovshdup ymm1, yword [rax] - -movsldup xmm1, xmm2 -movsldup xmm1, [rax] -movsldup xmm1, dqword [rax] -vmovsldup xmm1, xmm2 -vmovsldup xmm1, [rax] -vmovsldup xmm1, dqword [rax] -vmovsldup ymm1, ymm2 -vmovsldup ymm1, [rax] -vmovsldup ymm1, yword [rax] - -movss xmm1, xmm2 -vmovss xmm1, xmm2 -vmovss xmm1, xmm2, xmm3 -movss xmm1, [rax] -movss xmm1, dword [rax] -vmovss xmm1, [rax] -vmovss xmm1, dword [rax] -movss [rax], xmm2 -movss dword [rax], xmm2 -vmovss [rax], xmm2 -vmovss dword [rax], xmm2 - -movupd xmm1, xmm2 -movupd xmm1, [rax] -movupd xmm1, dqword [rax] -vmovupd xmm1, xmm2 -vmovupd xmm1, [rax] -vmovupd xmm1, dqword [rax] -movupd [rax], xmm2 -movupd dqword [rax], xmm2 -vmovupd [rax], xmm2 -vmovupd dqword [rax], xmm2 -vmovupd ymm1, ymm2 -vmovupd ymm1, [rax] -vmovupd ymm1, yword [rax] -vmovupd [rax], ymm2 -vmovupd yword [rax], ymm2 - -movups xmm1, xmm2 -movups xmm1, [rax] -movups xmm1, dqword [rax] -vmovups xmm1, xmm2 -vmovups xmm1, [rax] -vmovups xmm1, dqword [rax] -movups [rax], xmm2 -movups dqword [rax], xmm2 -vmovups [rax], xmm2 -vmovups dqword [rax], xmm2 -vmovups ymm1, ymm2 -vmovups ymm1, [rax] -vmovups ymm1, yword [rax] -vmovups [rax], ymm2 -vmovups yword [rax], ymm2 - -mpsadbw xmm1, xmm2, 5 -mpsadbw xmm1, [rax], byte 5 -mpsadbw xmm1, dqword [rax], 5 -vmpsadbw xmm1, xmm2, 5 -vmpsadbw xmm1, [rax], byte 5 -vmpsadbw xmm1, dqword [rax], 5 -vmpsadbw xmm1, xmm2, xmm3, 5 -vmpsadbw xmm1, xmm2, [rax], byte 5 -vmpsadbw xmm1, xmm2, dqword [rax], 5 - -mulpd xmm1, xmm2 -mulpd xmm1, [rax] -mulpd xmm1, dqword [rax] -vmulpd xmm1, xmm2 -vmulpd xmm1, [rax] -vmulpd xmm1, dqword [rax] -vmulpd xmm1, xmm2, xmm3 -vmulpd xmm1, xmm2, [rax] -vmulpd xmm1, xmm2, dqword [rax] -vmulpd ymm1, ymm2, ymm3 -vmulpd ymm1, ymm2, [rax] -vmulpd ymm1, ymm2, yword [rax] - -mulps xmm1, xmm2 -mulps xmm1, [rax] -mulps xmm1, dqword [rax] -vmulps xmm1, xmm2 -vmulps xmm1, [rax] -vmulps xmm1, dqword [rax] -vmulps xmm1, xmm2, xmm3 -vmulps xmm1, xmm2, [rax] -vmulps xmm1, xmm2, dqword [rax] -vmulps ymm1, ymm2, ymm3 -vmulps ymm1, ymm2, [rax] -vmulps ymm1, ymm2, yword [rax] - -mulsd xmm1, xmm2 -mulsd xmm1, [rax] -mulsd xmm1, qword [rax] -vmulsd xmm1, xmm2 -vmulsd xmm1, [rax] -vmulsd xmm1, qword [rax] -vmulsd xmm1, xmm2, xmm3 -vmulsd xmm1, xmm2, [rax] -vmulsd xmm1, xmm2, qword [rax] - -mulss xmm1, xmm2 -mulss xmm1, [rax] -mulss xmm1, dword [rax] -vmulss xmm1, xmm2 -vmulss xmm1, [rax] -vmulss xmm1, dword [rax] -vmulss xmm1, xmm2, xmm3 -vmulss xmm1, xmm2, [rax] -vmulss xmm1, xmm2, dword [rax] - -orpd xmm1, xmm2 -orpd xmm1, [rax] -orpd xmm1, dqword [rax] -vorpd xmm1, xmm2 -vorpd xmm1, [rax] -vorpd xmm1, dqword [rax] -vorpd xmm1, xmm2, xmm3 -vorpd xmm1, xmm2, [rax] -vorpd xmm1, xmm2, dqword [rax] -vorpd ymm1, ymm2, ymm3 -vorpd ymm1, ymm2, [rax] -vorpd ymm1, ymm2, yword [rax] - -orps xmm1, xmm2 -orps xmm1, [rax] -orps xmm1, dqword [rax] -vorps xmm1, xmm2 -vorps xmm1, [rax] -vorps xmm1, dqword [rax] -vorps xmm1, xmm2, xmm3 -vorps xmm1, xmm2, [rax] -vorps xmm1, xmm2, dqword [rax] -vorps ymm1, ymm2, ymm3 -vorps ymm1, ymm2, [rax] -vorps ymm1, ymm2, yword [rax] - -pabsb xmm1, xmm2 -pabsb xmm1, [rax] -pabsb xmm1, dqword [rax] -vpabsb xmm1, xmm2 -vpabsb xmm1, [rax] -vpabsb xmm1, dqword [rax] - -pabsw xmm1, xmm2 -pabsw xmm1, [rax] -pabsw xmm1, dqword [rax] -vpabsw xmm1, xmm2 -vpabsw xmm1, [rax] -vpabsw xmm1, dqword [rax] - -pabsd xmm1, xmm2 -pabsd xmm1, [rax] -pabsd xmm1, dqword [rax] -vpabsd xmm1, xmm2 -vpabsd xmm1, [rax] -vpabsd xmm1, dqword [rax] - -packsswb xmm1, xmm2 -packsswb xmm1, [rax] -packsswb xmm1, dqword [rax] -vpacksswb xmm1, xmm2 -vpacksswb xmm1, [rax] -vpacksswb xmm1, dqword [rax] -vpacksswb xmm1, xmm2, xmm3 -vpacksswb xmm1, xmm2, [rax] -vpacksswb xmm1, xmm2, dqword [rax] - -packssdw xmm1, xmm2 -packssdw xmm1, [rax] -packssdw xmm1, dqword [rax] -vpackssdw xmm1, xmm2 -vpackssdw xmm1, [rax] -vpackssdw xmm1, dqword [rax] -vpackssdw xmm1, xmm2, xmm3 -vpackssdw xmm1, xmm2, [rax] -vpackssdw xmm1, xmm2, dqword [rax] - -packuswb xmm1, xmm2 -packuswb xmm1, [rax] -packuswb xmm1, dqword [rax] -vpackuswb xmm1, xmm2 -vpackuswb xmm1, [rax] -vpackuswb xmm1, dqword [rax] -vpackuswb xmm1, xmm2, xmm3 -vpackuswb xmm1, xmm2, [rax] -vpackuswb xmm1, xmm2, dqword [rax] - -packusdw xmm1, xmm2 -packusdw xmm1, [rax] -packusdw xmm1, dqword [rax] -vpackusdw xmm1, xmm2 -vpackusdw xmm1, [rax] -vpackusdw xmm1, dqword [rax] -vpackusdw xmm1, xmm2, xmm3 -vpackusdw xmm1, xmm2, [rax] -vpackusdw xmm1, xmm2, dqword [rax] - -paddb xmm1, xmm2 -paddb xmm1, [rax] -paddb xmm1, dqword [rax] -vpaddb xmm1, xmm2 -vpaddb xmm1, [rax] -vpaddb xmm1, dqword [rax] -vpaddb xmm1, xmm2, xmm3 -vpaddb xmm1, xmm2, [rax] -vpaddb xmm1, xmm2, dqword [rax] - -paddw xmm1, xmm2 -paddw xmm1, [rax] -paddw xmm1, dqword [rax] -vpaddw xmm1, xmm2 -vpaddw xmm1, [rax] -vpaddw xmm1, dqword [rax] -vpaddw xmm1, xmm2, xmm3 -vpaddw xmm1, xmm2, [rax] -vpaddw xmm1, xmm2, dqword [rax] - -paddd xmm1, xmm2 -paddd xmm1, [rax] -paddd xmm1, dqword [rax] -vpaddd xmm1, xmm2 -vpaddd xmm1, [rax] -vpaddd xmm1, dqword [rax] -vpaddd xmm1, xmm2, xmm3 -vpaddd xmm1, xmm2, [rax] -vpaddd xmm1, xmm2, dqword [rax] - -paddq xmm1, xmm2 -paddq xmm1, [rax] -paddq xmm1, dqword [rax] -vpaddq xmm1, xmm2 -vpaddq xmm1, [rax] -vpaddq xmm1, dqword [rax] -vpaddq xmm1, xmm2, xmm3 -vpaddq xmm1, xmm2, [rax] -vpaddq xmm1, xmm2, dqword [rax] - -paddsb xmm1, xmm2 -paddsb xmm1, [rax] -paddsb xmm1, dqword [rax] -vpaddsb xmm1, xmm2 -vpaddsb xmm1, [rax] -vpaddsb xmm1, dqword [rax] -vpaddsb xmm1, xmm2, xmm3 -vpaddsb xmm1, xmm2, [rax] -vpaddsb xmm1, xmm2, dqword [rax] - -paddsw xmm1, xmm2 -paddsw xmm1, [rax] -paddsw xmm1, dqword [rax] -vpaddsw xmm1, xmm2 -vpaddsw xmm1, [rax] -vpaddsw xmm1, dqword [rax] -vpaddsw xmm1, xmm2, xmm3 -vpaddsw xmm1, xmm2, [rax] -vpaddsw xmm1, xmm2, dqword [rax] - -paddusb xmm1, xmm2 -paddusb xmm1, [rax] -paddusb xmm1, dqword [rax] -vpaddusb xmm1, xmm2 -vpaddusb xmm1, [rax] -vpaddusb xmm1, dqword [rax] -vpaddusb xmm1, xmm2, xmm3 -vpaddusb xmm1, xmm2, [rax] -vpaddusb xmm1, xmm2, dqword [rax] - -paddusw xmm1, xmm2 -paddusw xmm1, [rax] -paddusw xmm1, dqword [rax] -vpaddusw xmm1, xmm2 -vpaddusw xmm1, [rax] -vpaddusw xmm1, dqword [rax] -vpaddusw xmm1, xmm2, xmm3 -vpaddusw xmm1, xmm2, [rax] -vpaddusw xmm1, xmm2, dqword [rax] - -palignr xmm1, xmm2, 5 -palignr xmm1, [rax], byte 5 -palignr xmm1, dqword [rax], 5 -vpalignr xmm1, xmm2, 5 -vpalignr xmm1, [rax], byte 5 -vpalignr xmm1, dqword [rax], 5 -vpalignr xmm1, xmm2, xmm3, 5 -vpalignr xmm1, xmm2, [rax], byte 5 -vpalignr xmm1, xmm2, dqword [rax], 5 - -pand xmm1, xmm2 -pand xmm1, [rax] -pand xmm1, dqword [rax] -vpand xmm1, xmm2 -vpand xmm1, [rax] -vpand xmm1, dqword [rax] -vpand xmm1, xmm2, xmm3 -vpand xmm1, xmm2, [rax] -vpand xmm1, xmm2, dqword [rax] - -pandn xmm1, xmm2 -pandn xmm1, [rax] -pandn xmm1, dqword [rax] -vpandn xmm1, xmm2 -vpandn xmm1, [rax] -vpandn xmm1, dqword [rax] -vpandn xmm1, xmm2, xmm3 -vpandn xmm1, xmm2, [rax] -vpandn xmm1, xmm2, dqword [rax] - -pavgb xmm1, xmm2 -pavgb xmm1, [rax] -pavgb xmm1, dqword [rax] -vpavgb xmm1, xmm2 -vpavgb xmm1, [rax] -vpavgb xmm1, dqword [rax] -vpavgb xmm1, xmm2, xmm3 -vpavgb xmm1, xmm2, [rax] -vpavgb xmm1, xmm2, dqword [rax] - -pavgw xmm1, xmm2 -pavgw xmm1, [rax] -pavgw xmm1, dqword [rax] -vpavgw xmm1, xmm2 -vpavgw xmm1, [rax] -vpavgw xmm1, dqword [rax] -vpavgw xmm1, xmm2, xmm3 -vpavgw xmm1, xmm2, [rax] -vpavgw xmm1, xmm2, dqword [rax] - -; implicit XMM0 cannot be VEX encoded -pblendvb xmm1, xmm2 -pblendvb xmm1, [rax] -pblendvb xmm1, dqword [rax] -pblendvb xmm1, xmm2, xmm0 -pblendvb xmm1, [rax], xmm0 -pblendvb xmm1, dqword [rax], xmm0 -vpblendvb xmm1, xmm2, xmm3, xmm4 -vpblendvb xmm1, xmm2, [rax], xmm4 -vpblendvb xmm1, xmm2, dqword [rax], xmm4 - -pblendw xmm1, xmm2, 5 -pblendw xmm1, [rax], byte 5 -pblendw xmm1, dqword [rax], 5 -vpblendw xmm1, xmm2, 5 -vpblendw xmm1, [rax], byte 5 -vpblendw xmm1, dqword [rax], 5 -vpblendw xmm1, xmm2, xmm3, 5 -vpblendw xmm1, xmm2, [rax], byte 5 -vpblendw xmm1, xmm2, dqword [rax], 5 - -pcmpestri xmm1, xmm2, 5 -pcmpestri xmm1, [rax], byte 5 -pcmpestri xmm1, dqword [rax], 5 -vpcmpestri xmm1, xmm2, 5 -vpcmpestri xmm1, [rax], byte 5 -vpcmpestri xmm1, dqword [rax], 5 - -pcmpestrm xmm1, xmm2, 5 -pcmpestrm xmm1, [rax], byte 5 -pcmpestrm xmm1, dqword [rax], 5 -vpcmpestrm xmm1, xmm2, 5 -vpcmpestrm xmm1, [rax], byte 5 -vpcmpestrm xmm1, dqword [rax], 5 - -pcmpistri xmm1, xmm2, 5 -pcmpistri xmm1, [rax], byte 5 -pcmpistri xmm1, dqword [rax], 5 -vpcmpistri xmm1, xmm2, 5 -vpcmpistri xmm1, [rax], byte 5 -vpcmpistri xmm1, dqword [rax], 5 - -pcmpistrm xmm1, xmm2, 5 -pcmpistrm xmm1, [rax], byte 5 -pcmpistrm xmm1, dqword [rax], 5 -vpcmpistrm xmm1, xmm2, 5 -vpcmpistrm xmm1, [rax], byte 5 -vpcmpistrm xmm1, dqword [rax], 5 - -pcmpeqb xmm1, xmm2 -pcmpeqb xmm1, [rax] -pcmpeqb xmm1, dqword [rax] -vpcmpeqb xmm1, xmm2 -vpcmpeqb xmm1, [rax] -vpcmpeqb xmm1, dqword [rax] -vpcmpeqb xmm1, xmm2, xmm3 -vpcmpeqb xmm1, xmm2, [rax] -vpcmpeqb xmm1, xmm2, dqword [rax] - -pcmpeqw xmm1, xmm2 -pcmpeqw xmm1, [rax] -pcmpeqw xmm1, dqword [rax] -vpcmpeqw xmm1, xmm2 -vpcmpeqw xmm1, [rax] -vpcmpeqw xmm1, dqword [rax] -vpcmpeqw xmm1, xmm2, xmm3 -vpcmpeqw xmm1, xmm2, [rax] -vpcmpeqw xmm1, xmm2, dqword [rax] - -pcmpeqd xmm1, xmm2 -pcmpeqd xmm1, [rax] -pcmpeqd xmm1, dqword [rax] -vpcmpeqd xmm1, xmm2 -vpcmpeqd xmm1, [rax] -vpcmpeqd xmm1, dqword [rax] -vpcmpeqd xmm1, xmm2, xmm3 -vpcmpeqd xmm1, xmm2, [rax] -vpcmpeqd xmm1, xmm2, dqword [rax] - -pcmpeqq xmm1, xmm2 -pcmpeqq xmm1, [rax] -pcmpeqq xmm1, dqword [rax] -vpcmpeqq xmm1, xmm2 -vpcmpeqq xmm1, [rax] -vpcmpeqq xmm1, dqword [rax] -vpcmpeqq xmm1, xmm2, xmm3 -vpcmpeqq xmm1, xmm2, [rax] -vpcmpeqq xmm1, xmm2, dqword [rax] - -pcmpgtb xmm1, xmm2 -pcmpgtb xmm1, [rax] -pcmpgtb xmm1, dqword [rax] -vpcmpgtb xmm1, xmm2 -vpcmpgtb xmm1, [rax] -vpcmpgtb xmm1, dqword [rax] -vpcmpgtb xmm1, xmm2, xmm3 -vpcmpgtb xmm1, xmm2, [rax] -vpcmpgtb xmm1, xmm2, dqword [rax] - -pcmpgtw xmm1, xmm2 -pcmpgtw xmm1, [rax] -pcmpgtw xmm1, dqword [rax] -vpcmpgtw xmm1, xmm2 -vpcmpgtw xmm1, [rax] -vpcmpgtw xmm1, dqword [rax] -vpcmpgtw xmm1, xmm2, xmm3 -vpcmpgtw xmm1, xmm2, [rax] -vpcmpgtw xmm1, xmm2, dqword [rax] - -pcmpgtd xmm1, xmm2 -pcmpgtd xmm1, [rax] -pcmpgtd xmm1, dqword [rax] -vpcmpgtd xmm1, xmm2 -vpcmpgtd xmm1, [rax] -vpcmpgtd xmm1, dqword [rax] -vpcmpgtd xmm1, xmm2, xmm3 -vpcmpgtd xmm1, xmm2, [rax] -vpcmpgtd xmm1, xmm2, dqword [rax] - -pcmpgtq xmm1, xmm2 -pcmpgtq xmm1, [rax] -pcmpgtq xmm1, dqword [rax] -vpcmpgtq xmm1, xmm2 -vpcmpgtq xmm1, [rax] -vpcmpgtq xmm1, dqword [rax] -vpcmpgtq xmm1, xmm2, xmm3 -vpcmpgtq xmm1, xmm2, [rax] -vpcmpgtq xmm1, xmm2, dqword [rax] - -vpermilpd xmm1, xmm2, xmm3 -vpermilpd xmm1, xmm2, [rax] -vpermilpd xmm1, xmm2, dqword [rax] -vpermilpd ymm1, ymm2, ymm3 -vpermilpd ymm1, ymm2, [rax] -vpermilpd ymm1, ymm2, yword [rax] -vpermilpd xmm1, [rax], byte 5 -vpermilpd xmm1, dqword [rax], 5 -vpermilpd ymm1, [rax], byte 5 -vpermilpd ymm1, yword [rax], 5 - -vpermilps xmm1, xmm2, xmm3 -vpermilps xmm1, xmm2, [rax] -vpermilps xmm1, xmm2, dqword [rax] -vpermilps ymm1, ymm2, ymm3 -vpermilps ymm1, ymm2, [rax] -vpermilps ymm1, ymm2, yword [rax] -vpermilps xmm1, [rax], byte 5 -vpermilps xmm1, dqword [rax], 5 -vpermilps ymm1, [rax], byte 5 -vpermilps ymm1, yword [rax], 5 - -vperm2f128 ymm1, ymm2, ymm3, 5 -vperm2f128 ymm1, ymm2, [rax], byte 5 -vperm2f128 ymm1, ymm2, yword [rax], 5 - -pextrb eax, xmm2, 5 -pextrb eax, xmm2, byte 5 -pextrb rax, xmm2, 5 -pextrb rax, xmm2, byte 5 -pextrb byte [rax], xmm2, 5 -pextrb [rax], xmm2, byte 5 -vpextrb eax, xmm2, 5 -vpextrb eax, xmm2, byte 5 -vpextrb rax, xmm2, 5 -vpextrb rax, xmm2, byte 5 -vpextrb byte [rax], xmm2, 5 -vpextrb [rax], xmm2, byte 5 - -pextrw eax, xmm2, 5 -pextrw eax, xmm2, byte 5 -pextrw rax, xmm2, 5 -pextrw rax, xmm2, byte 5 -pextrw word [rax], xmm2, 5 -pextrw [rax], xmm2, byte 5 -vpextrw eax, xmm2, 5 -vpextrw eax, xmm2, byte 5 -vpextrw rax, xmm2, 5 -vpextrw rax, xmm2, byte 5 -vpextrw word [rax], xmm2, 5 -vpextrw [rax], xmm2, byte 5 - -pextrd eax, xmm2, 5 -pextrd eax, xmm2, byte 5 -pextrd dword [rax], xmm2, 5 -pextrd [rax], xmm2, byte 5 -vpextrd eax, xmm2, 5 -vpextrd eax, xmm2, byte 5 -vpextrd dword [rax], xmm2, 5 -vpextrd [rax], xmm2, byte 5 - -pextrq rax, xmm2, 5 -pextrq rax, xmm2, byte 5 -pextrq qword [rax], xmm2, 5 -pextrq [rax], xmm2, byte 5 -vpextrq rax, xmm2, 5 -vpextrq rax, xmm2, byte 5 -vpextrq qword [rax], xmm2, 5 -vpextrq [rax], xmm2, byte 5 - -phaddw xmm1, xmm2 -phaddw xmm1, [rax] -phaddw xmm1, dqword [rax] -vphaddw xmm1, xmm2 -vphaddw xmm1, [rax] -vphaddw xmm1, dqword [rax] -vphaddw xmm1, xmm2, xmm3 -vphaddw xmm1, xmm2, [rax] -vphaddw xmm1, xmm2, dqword [rax] - -phaddd xmm1, xmm2 -phaddd xmm1, [rax] -phaddd xmm1, dqword [rax] -vphaddd xmm1, xmm2 -vphaddd xmm1, [rax] -vphaddd xmm1, dqword [rax] -vphaddd xmm1, xmm2, xmm3 -vphaddd xmm1, xmm2, [rax] -vphaddd xmm1, xmm2, dqword [rax] - -phaddsw xmm1, xmm2 -phaddsw xmm1, [rax] -phaddsw xmm1, dqword [rax] -vphaddsw xmm1, xmm2 -vphaddsw xmm1, [rax] -vphaddsw xmm1, dqword [rax] -vphaddsw xmm1, xmm2, xmm3 -vphaddsw xmm1, xmm2, [rax] -vphaddsw xmm1, xmm2, dqword [rax] - -phminposuw xmm1, xmm2 -phminposuw xmm1, [rax] -phminposuw xmm1, dqword [rax] -vphminposuw xmm1, xmm2 -vphminposuw xmm1, [rax] -vphminposuw xmm1, dqword [rax] - -phsubw xmm1, xmm2 -phsubw xmm1, [rax] -phsubw xmm1, dqword [rax] -vphsubw xmm1, xmm2 -vphsubw xmm1, [rax] -vphsubw xmm1, dqword [rax] -vphsubw xmm1, xmm2, xmm3 -vphsubw xmm1, xmm2, [rax] -vphsubw xmm1, xmm2, dqword [rax] - -phsubd xmm1, xmm2 -phsubd xmm1, [rax] -phsubd xmm1, dqword [rax] -vphsubd xmm1, xmm2 -vphsubd xmm1, [rax] -vphsubd xmm1, dqword [rax] -vphsubd xmm1, xmm2, xmm3 -vphsubd xmm1, xmm2, [rax] -vphsubd xmm1, xmm2, dqword [rax] - -phsubsw xmm1, xmm2 -phsubsw xmm1, [rax] -phsubsw xmm1, dqword [rax] -vphsubsw xmm1, xmm2 -vphsubsw xmm1, [rax] -vphsubsw xmm1, dqword [rax] -vphsubsw xmm1, xmm2, xmm3 -vphsubsw xmm1, xmm2, [rax] -vphsubsw xmm1, xmm2, dqword [rax] - -pinsrb xmm1, eax, 5 -pinsrb xmm1, byte [rax], 5 -pinsrb xmm1, [rax], byte 5 -vpinsrb xmm1, eax, 5 -vpinsrb xmm1, byte [rax], 5 -vpinsrb xmm1, [rax], byte 5 -vpinsrb xmm1, xmm2, eax, 5 -vpinsrb xmm1, xmm2, byte [rax], 5 -vpinsrb xmm1, xmm2, [rax], byte 5 - -pinsrw xmm1, eax, 5 -pinsrw xmm1, word [rax], 5 -pinsrw xmm1, [rax], byte 5 -vpinsrw xmm1, eax, 5 -vpinsrw xmm1, word [rax], 5 -vpinsrw xmm1, [rax], byte 5 -vpinsrw xmm1, xmm2, eax, 5 -vpinsrw xmm1, xmm2, word [rax], 5 -vpinsrw xmm1, xmm2, [rax], byte 5 - -pinsrd xmm1, eax, 5 -pinsrd xmm1, dword [rax], 5 -pinsrd xmm1, [rax], byte 5 -vpinsrd xmm1, eax, 5 -vpinsrd xmm1, dword [rax], 5 -vpinsrd xmm1, [rax], byte 5 -vpinsrd xmm1, xmm2, eax, 5 -vpinsrd xmm1, xmm2, dword [rax], 5 -vpinsrd xmm1, xmm2, [rax], byte 5 - -pinsrq xmm1, rax, 5 -pinsrq xmm1, qword [rax], 5 -pinsrq xmm1, [rax], byte 5 -vpinsrq xmm1, rax, 5 -vpinsrq xmm1, qword [rax], 5 -vpinsrq xmm1, [rax], byte 5 -vpinsrq xmm1, xmm2, rax, 5 -vpinsrq xmm1, xmm2, qword [rax], 5 -vpinsrq xmm1, xmm2, [rax], byte 5 - -pmaddwd xmm1, xmm2 -pmaddwd xmm1, [rax] -pmaddwd xmm1, dqword [rax] -vpmaddwd xmm1, xmm2 -vpmaddwd xmm1, [rax] -vpmaddwd xmm1, dqword [rax] -vpmaddwd xmm1, xmm2, xmm3 -vpmaddwd xmm1, xmm2, [rax] -vpmaddwd xmm1, xmm2, dqword [rax] - -pmaddubsw xmm1, xmm2 -pmaddubsw xmm1, [rax] -pmaddubsw xmm1, dqword [rax] -vpmaddubsw xmm1, xmm2 -vpmaddubsw xmm1, [rax] -vpmaddubsw xmm1, dqword [rax] -vpmaddubsw xmm1, xmm2, xmm3 -vpmaddubsw xmm1, xmm2, [rax] -vpmaddubsw xmm1, xmm2, dqword [rax] - -pmaxsb xmm1, xmm2 -pmaxsb xmm1, [rax] -pmaxsb xmm1, dqword [rax] -vpmaxsb xmm1, xmm2 -vpmaxsb xmm1, [rax] -vpmaxsb xmm1, dqword [rax] -vpmaxsb xmm1, xmm2, xmm3 -vpmaxsb xmm1, xmm2, [rax] -vpmaxsb xmm1, xmm2, dqword [rax] - -pmaxsw xmm1, xmm2 -pmaxsw xmm1, [rax] -pmaxsw xmm1, dqword [rax] -vpmaxsw xmm1, xmm2 -vpmaxsw xmm1, [rax] -vpmaxsw xmm1, dqword [rax] -vpmaxsw xmm1, xmm2, xmm3 -vpmaxsw xmm1, xmm2, [rax] -vpmaxsw xmm1, xmm2, dqword [rax] - -pmaxsd xmm1, xmm2 -pmaxsd xmm1, [rax] -pmaxsd xmm1, dqword [rax] -vpmaxsd xmm1, xmm2 -vpmaxsd xmm1, [rax] -vpmaxsd xmm1, dqword [rax] -vpmaxsd xmm1, xmm2, xmm3 -vpmaxsd xmm1, xmm2, [rax] -vpmaxsd xmm1, xmm2, dqword [rax] - -pmaxub xmm1, xmm2 -pmaxub xmm1, [rax] -pmaxub xmm1, dqword [rax] -vpmaxub xmm1, xmm2 -vpmaxub xmm1, [rax] -vpmaxub xmm1, dqword [rax] -vpmaxub xmm1, xmm2, xmm3 -vpmaxub xmm1, xmm2, [rax] -vpmaxub xmm1, xmm2, dqword [rax] - -pmaxuw xmm1, xmm2 -pmaxuw xmm1, [rax] -pmaxuw xmm1, dqword [rax] -vpmaxuw xmm1, xmm2 -vpmaxuw xmm1, [rax] -vpmaxuw xmm1, dqword [rax] -vpmaxuw xmm1, xmm2, xmm3 -vpmaxuw xmm1, xmm2, [rax] -vpmaxuw xmm1, xmm2, dqword [rax] - -pmaxud xmm1, xmm2 -pmaxud xmm1, [rax] -pmaxud xmm1, dqword [rax] -vpmaxud xmm1, xmm2 -vpmaxud xmm1, [rax] -vpmaxud xmm1, dqword [rax] -vpmaxud xmm1, xmm2, xmm3 -vpmaxud xmm1, xmm2, [rax] -vpmaxud xmm1, xmm2, dqword [rax] - -pminsb xmm1, xmm2 -pminsb xmm1, [rax] -pminsb xmm1, dqword [rax] -vpminsb xmm1, xmm2 -vpminsb xmm1, [rax] -vpminsb xmm1, dqword [rax] -vpminsb xmm1, xmm2, xmm3 -vpminsb xmm1, xmm2, [rax] -vpminsb xmm1, xmm2, dqword [rax] - -pminsw xmm1, xmm2 -pminsw xmm1, [rax] -pminsw xmm1, dqword [rax] -vpminsw xmm1, xmm2 -vpminsw xmm1, [rax] -vpminsw xmm1, dqword [rax] -vpminsw xmm1, xmm2, xmm3 -vpminsw xmm1, xmm2, [rax] -vpminsw xmm1, xmm2, dqword [rax] - -pminsd xmm1, xmm2 -pminsd xmm1, [rax] -pminsd xmm1, dqword [rax] -vpminsd xmm1, xmm2 -vpminsd xmm1, [rax] -vpminsd xmm1, dqword [rax] -vpminsd xmm1, xmm2, xmm3 -vpminsd xmm1, xmm2, [rax] -vpminsd xmm1, xmm2, dqword [rax] - -pminub xmm1, xmm2 -pminub xmm1, [rax] -pminub xmm1, dqword [rax] -vpminub xmm1, xmm2 -vpminub xmm1, [rax] -vpminub xmm1, dqword [rax] -vpminub xmm1, xmm2, xmm3 -vpminub xmm1, xmm2, [rax] -vpminub xmm1, xmm2, dqword [rax] - -pminuw xmm1, xmm2 -pminuw xmm1, [rax] -pminuw xmm1, dqword [rax] -vpminuw xmm1, xmm2 -vpminuw xmm1, [rax] -vpminuw xmm1, dqword [rax] -vpminuw xmm1, xmm2, xmm3 -vpminuw xmm1, xmm2, [rax] -vpminuw xmm1, xmm2, dqword [rax] - -pminud xmm1, xmm2 -pminud xmm1, [rax] -pminud xmm1, dqword [rax] -vpminud xmm1, xmm2 -vpminud xmm1, [rax] -vpminud xmm1, dqword [rax] -vpminud xmm1, xmm2, xmm3 -vpminud xmm1, xmm2, [rax] -vpminud xmm1, xmm2, dqword [rax] - -pmovmskb eax, xmm1 -pmovmskb rax, xmm1 -vpmovmskb eax, xmm1 -vpmovmskb rax, xmm1 - -pmovsxbw xmm1, xmm2 -pmovsxbw xmm1, [rax] -pmovsxbw xmm1, qword [rax] -vpmovsxbw xmm1, xmm2 -vpmovsxbw xmm1, [rax] -vpmovsxbw xmm1, qword [rax] - -pmovsxbd xmm1, xmm2 -pmovsxbd xmm1, [rax] -pmovsxbd xmm1, dword [rax] -vpmovsxbd xmm1, xmm2 -vpmovsxbd xmm1, [rax] -vpmovsxbd xmm1, dword [rax] - -pmovsxbq xmm1, xmm2 -pmovsxbq xmm1, [rax] -pmovsxbq xmm1, word [rax] -vpmovsxbq xmm1, xmm2 -vpmovsxbq xmm1, [rax] -vpmovsxbq xmm1, word [rax] - -pmovsxwd xmm1, xmm2 -pmovsxwd xmm1, [rax] -pmovsxwd xmm1, qword [rax] -vpmovsxwd xmm1, xmm2 -vpmovsxwd xmm1, [rax] -vpmovsxwd xmm1, qword [rax] - -pmovsxwq xmm1, xmm2 -pmovsxwq xmm1, [rax] -pmovsxwq xmm1, dword [rax] -vpmovsxwq xmm1, xmm2 -vpmovsxwq xmm1, [rax] -vpmovsxwq xmm1, dword [rax] - -pmovsxdq xmm1, xmm2 -pmovsxdq xmm1, [rax] -pmovsxdq xmm1, qword [rax] -vpmovsxdq xmm1, xmm2 -vpmovsxdq xmm1, [rax] -vpmovsxdq xmm1, qword [rax] - -pmovzxbw xmm1, xmm2 -pmovzxbw xmm1, [rax] -pmovzxbw xmm1, qword [rax] -vpmovzxbw xmm1, xmm2 -vpmovzxbw xmm1, [rax] -vpmovzxbw xmm1, qword [rax] - -pmovzxbd xmm1, xmm2 -pmovzxbd xmm1, [rax] -pmovzxbd xmm1, dword [rax] -vpmovzxbd xmm1, xmm2 -vpmovzxbd xmm1, [rax] -vpmovzxbd xmm1, dword [rax] - -pmovzxbq xmm1, xmm2 -pmovzxbq xmm1, [rax] -pmovzxbq xmm1, word [rax] -vpmovzxbq xmm1, xmm2 -vpmovzxbq xmm1, [rax] -vpmovzxbq xmm1, word [rax] - -pmovzxwd xmm1, xmm2 -pmovzxwd xmm1, [rax] -pmovzxwd xmm1, qword [rax] -vpmovzxwd xmm1, xmm2 -vpmovzxwd xmm1, [rax] -vpmovzxwd xmm1, qword [rax] - -pmovzxwq xmm1, xmm2 -pmovzxwq xmm1, [rax] -pmovzxwq xmm1, dword [rax] -vpmovzxwq xmm1, xmm2 -vpmovzxwq xmm1, [rax] -vpmovzxwq xmm1, dword [rax] - -pmovzxdq xmm1, xmm2 -pmovzxdq xmm1, [rax] -pmovzxdq xmm1, qword [rax] -vpmovzxdq xmm1, xmm2 -vpmovzxdq xmm1, [rax] -vpmovzxdq xmm1, qword [rax] - -pmulhuw xmm1, xmm2 -pmulhuw xmm1, [rax] -pmulhuw xmm1, dqword [rax] -vpmulhuw xmm1, xmm2 -vpmulhuw xmm1, [rax] -vpmulhuw xmm1, dqword [rax] -vpmulhuw xmm1, xmm2, xmm3 -vpmulhuw xmm1, xmm2, [rax] -vpmulhuw xmm1, xmm2, dqword [rax] - -pmulhrsw xmm1, xmm2 -pmulhrsw xmm1, [rax] -pmulhrsw xmm1, dqword [rax] -vpmulhrsw xmm1, xmm2 -vpmulhrsw xmm1, [rax] -vpmulhrsw xmm1, dqword [rax] -vpmulhrsw xmm1, xmm2, xmm3 -vpmulhrsw xmm1, xmm2, [rax] -vpmulhrsw xmm1, xmm2, dqword [rax] - -pmulhw xmm1, xmm2 -pmulhw xmm1, [rax] -pmulhw xmm1, dqword [rax] -vpmulhw xmm1, xmm2 -vpmulhw xmm1, [rax] -vpmulhw xmm1, dqword [rax] -vpmulhw xmm1, xmm2, xmm3 -vpmulhw xmm1, xmm2, [rax] -vpmulhw xmm1, xmm2, dqword [rax] - -pmullw xmm1, xmm2 -pmullw xmm1, [rax] -pmullw xmm1, dqword [rax] -vpmullw xmm1, xmm2 -vpmullw xmm1, [rax] -vpmullw xmm1, dqword [rax] -vpmullw xmm1, xmm2, xmm3 -vpmullw xmm1, xmm2, [rax] -vpmullw xmm1, xmm2, dqword [rax] - -pmulld xmm1, xmm2 -pmulld xmm1, [rax] -pmulld xmm1, dqword [rax] -vpmulld xmm1, xmm2 -vpmulld xmm1, [rax] -vpmulld xmm1, dqword [rax] -vpmulld xmm1, xmm2, xmm3 -vpmulld xmm1, xmm2, [rax] -vpmulld xmm1, xmm2, dqword [rax] - -pmuludq xmm1, xmm2 -pmuludq xmm1, [rax] -pmuludq xmm1, dqword [rax] -vpmuludq xmm1, xmm2 -vpmuludq xmm1, [rax] -vpmuludq xmm1, dqword [rax] -vpmuludq xmm1, xmm2, xmm3 -vpmuludq xmm1, xmm2, [rax] -vpmuludq xmm1, xmm2, dqword [rax] - -pmuldq xmm1, xmm2 -pmuldq xmm1, [rax] -pmuldq xmm1, dqword [rax] -vpmuldq xmm1, xmm2 -vpmuldq xmm1, [rax] -vpmuldq xmm1, dqword [rax] -vpmuldq xmm1, xmm2, xmm3 -vpmuldq xmm1, xmm2, [rax] -vpmuldq xmm1, xmm2, dqword [rax] - -por xmm1, xmm2 -por xmm1, [rax] -por xmm1, dqword [rax] -vpor xmm1, xmm2 -vpor xmm1, [rax] -vpor xmm1, dqword [rax] -vpor xmm1, xmm2, xmm3 -vpor xmm1, xmm2, [rax] -vpor xmm1, xmm2, dqword [rax] - -psadbw xmm1, xmm2 -psadbw xmm1, [rax] -psadbw xmm1, dqword [rax] -vpsadbw xmm1, xmm2 -vpsadbw xmm1, [rax] -vpsadbw xmm1, dqword [rax] -vpsadbw xmm1, xmm2, xmm3 -vpsadbw xmm1, xmm2, [rax] -vpsadbw xmm1, xmm2, dqword [rax] - -pshufb xmm1, xmm2 -pshufb xmm1, [rax] -pshufb xmm1, dqword [rax] -vpshufb xmm1, xmm2 -vpshufb xmm1, [rax] -vpshufb xmm1, dqword [rax] -vpshufb xmm1, xmm2, xmm3 -vpshufb xmm1, xmm2, [rax] -vpshufb xmm1, xmm2, dqword [rax] - -pshufd xmm1, xmm2, 5 -pshufd xmm1, [rax], byte 5 -pshufd xmm1, dqword [rax], 5 -vpshufd xmm1, xmm2, 5 -vpshufd xmm1, [rax], byte 5 -vpshufd xmm1, dqword [rax], 5 - -pshufhw xmm1, xmm2, 5 -pshufhw xmm1, [rax], byte 5 -pshufhw xmm1, dqword [rax], 5 -vpshufhw xmm1, xmm2, 5 -vpshufhw xmm1, [rax], byte 5 -vpshufhw xmm1, dqword [rax], 5 - -pshuflw xmm1, xmm2, 5 -pshuflw xmm1, [rax], byte 5 -pshuflw xmm1, dqword [rax], 5 -vpshuflw xmm1, xmm2, 5 -vpshuflw xmm1, [rax], byte 5 -vpshuflw xmm1, dqword [rax], 5 - -psignb xmm1, xmm2 -psignb xmm1, [rax] -psignb xmm1, dqword [rax] -vpsignb xmm1, xmm2 -vpsignb xmm1, [rax] -vpsignb xmm1, dqword [rax] -vpsignb xmm1, xmm2, xmm3 -vpsignb xmm1, xmm2, [rax] -vpsignb xmm1, xmm2, dqword [rax] - -psignw xmm1, xmm2 -psignw xmm1, [rax] -psignw xmm1, dqword [rax] -vpsignw xmm1, xmm2 -vpsignw xmm1, [rax] -vpsignw xmm1, dqword [rax] -vpsignw xmm1, xmm2, xmm3 -vpsignw xmm1, xmm2, [rax] -vpsignw xmm1, xmm2, dqword [rax] - -psignd xmm1, xmm2 -psignd xmm1, [rax] -psignd xmm1, dqword [rax] -vpsignd xmm1, xmm2 -vpsignd xmm1, [rax] -vpsignd xmm1, dqword [rax] -vpsignd xmm1, xmm2, xmm3 -vpsignd xmm1, xmm2, [rax] -vpsignd xmm1, xmm2, dqword [rax] - -; Test these with high regs as it goes into VEX.B (REX.B) -pslldq xmm11, 5 -pslldq xmm11, byte 5 -vpslldq xmm11, 5 -vpslldq xmm11, byte 5 -vpslldq xmm11, xmm12, 5 -vpslldq xmm11, xmm12, byte 5 - -pslldq xmm1, 5 -pslldq xmm1, byte 5 -vpslldq xmm1, 5 -vpslldq xmm1, byte 5 -vpslldq xmm1, xmm2, 5 -vpslldq xmm1, xmm2, byte 5 - -psrldq xmm1, 5 -psrldq xmm1, byte 5 -vpsrldq xmm1, 5 -vpsrldq xmm1, byte 5 -vpsrldq xmm1, xmm2, 5 -vpsrldq xmm1, xmm2, byte 5 - -psllw xmm1, xmm2 -psllw xmm1, [rax] -psllw xmm1, dqword [rax] -vpsllw xmm1, xmm2 -vpsllw xmm1, [rax] -vpsllw xmm1, dqword [rax] -vpsllw xmm1, xmm2, xmm3 -vpsllw xmm1, xmm2, [rax] -vpsllw xmm1, xmm2, dqword [rax] -psllw xmm1, 5 -psllw xmm1, byte 5 -vpsllw xmm1, 5 -vpsllw xmm1, byte 5 -vpsllw xmm1, xmm2, 5 -vpsllw xmm1, xmm2, byte 5 - -pslld xmm1, xmm2 -pslld xmm1, [rax] -pslld xmm1, dqword [rax] -vpslld xmm1, xmm2 -vpslld xmm1, [rax] -vpslld xmm1, dqword [rax] -vpslld xmm1, xmm2, xmm3 -vpslld xmm1, xmm2, [rax] -vpslld xmm1, xmm2, dqword [rax] -pslld xmm1, 5 -pslld xmm1, byte 5 -vpslld xmm1, 5 -vpslld xmm1, byte 5 -vpslld xmm1, xmm2, 5 -vpslld xmm1, xmm2, byte 5 - -psllq xmm1, xmm2 -psllq xmm1, [rax] -psllq xmm1, dqword [rax] -vpsllq xmm1, xmm2 -vpsllq xmm1, [rax] -vpsllq xmm1, dqword [rax] -vpsllq xmm1, xmm2, xmm3 -vpsllq xmm1, xmm2, [rax] -vpsllq xmm1, xmm2, dqword [rax] -psllq xmm1, 5 -psllq xmm1, byte 5 -vpsllq xmm1, 5 -vpsllq xmm1, byte 5 -vpsllq xmm1, xmm2, 5 -vpsllq xmm1, xmm2, byte 5 - -psraw xmm1, xmm2 -psraw xmm1, [rax] -psraw xmm1, dqword [rax] -vpsraw xmm1, xmm2 -vpsraw xmm1, [rax] -vpsraw xmm1, dqword [rax] -vpsraw xmm1, xmm2, xmm3 -vpsraw xmm1, xmm2, [rax] -vpsraw xmm1, xmm2, dqword [rax] -psraw xmm1, 5 -psraw xmm1, byte 5 -vpsraw xmm1, 5 -vpsraw xmm1, byte 5 -vpsraw xmm1, xmm2, 5 -vpsraw xmm1, xmm2, byte 5 - -psrad xmm1, xmm2 -psrad xmm1, [rax] -psrad xmm1, dqword [rax] -vpsrad xmm1, xmm2 -vpsrad xmm1, [rax] -vpsrad xmm1, dqword [rax] -vpsrad xmm1, xmm2, xmm3 -vpsrad xmm1, xmm2, [rax] -vpsrad xmm1, xmm2, dqword [rax] -psrad xmm1, 5 -psrad xmm1, byte 5 -vpsrad xmm1, 5 -vpsrad xmm1, byte 5 -vpsrad xmm1, xmm2, 5 -vpsrad xmm1, xmm2, byte 5 - -psrlw xmm1, xmm2 -psrlw xmm1, [rax] -psrlw xmm1, dqword [rax] -vpsrlw xmm1, xmm2 -vpsrlw xmm1, [rax] -vpsrlw xmm1, dqword [rax] -vpsrlw xmm1, xmm2, xmm3 -vpsrlw xmm1, xmm2, [rax] -vpsrlw xmm1, xmm2, dqword [rax] -psrlw xmm1, 5 -psrlw xmm1, byte 5 -vpsrlw xmm1, 5 -vpsrlw xmm1, byte 5 -vpsrlw xmm1, xmm2, 5 -vpsrlw xmm1, xmm2, byte 5 - -psrld xmm1, xmm2 -psrld xmm1, [rax] -psrld xmm1, dqword [rax] -vpsrld xmm1, xmm2 -vpsrld xmm1, [rax] -vpsrld xmm1, dqword [rax] -vpsrld xmm1, xmm2, xmm3 -vpsrld xmm1, xmm2, [rax] -vpsrld xmm1, xmm2, dqword [rax] -psrld xmm1, 5 -psrld xmm1, byte 5 -vpsrld xmm1, 5 -vpsrld xmm1, byte 5 -vpsrld xmm1, xmm2, 5 -vpsrld xmm1, xmm2, byte 5 - -psrlq xmm1, xmm2 -psrlq xmm1, [rax] -psrlq xmm1, dqword [rax] -vpsrlq xmm1, xmm2 -vpsrlq xmm1, [rax] -vpsrlq xmm1, dqword [rax] -vpsrlq xmm1, xmm2, xmm3 -vpsrlq xmm1, xmm2, [rax] -vpsrlq xmm1, xmm2, dqword [rax] -psrlq xmm1, 5 -psrlq xmm1, byte 5 -vpsrlq xmm1, 5 -vpsrlq xmm1, byte 5 -vpsrlq xmm1, xmm2, 5 -vpsrlq xmm1, xmm2, byte 5 - -ptest xmm1, xmm2 -ptest xmm1, [rax] -ptest xmm1, dqword [rax] -vptest xmm1, xmm2 -vptest xmm1, [rax] -vptest xmm1, dqword [rax] -vptest ymm1, ymm2 -vptest ymm1, [rax] -vptest ymm1, yword [rax] - -vtestps xmm1, xmm2 -vtestps xmm1, [rax] -vtestps xmm1, dqword [rax] -vtestps ymm1, ymm2 -vtestps ymm1, [rax] -vtestps ymm1, yword [rax] - -vtestpd xmm1, xmm2 -vtestpd xmm1, [rax] -vtestpd xmm1, dqword [rax] -vtestpd ymm1, ymm2 -vtestpd ymm1, [rax] -vtestpd ymm1, yword [rax] - -psubb xmm1, xmm2 -psubb xmm1, [rax] -psubb xmm1, dqword [rax] -vpsubb xmm1, xmm2 -vpsubb xmm1, [rax] -vpsubb xmm1, dqword [rax] -vpsubb xmm1, xmm2, xmm3 -vpsubb xmm1, xmm2, [rax] -vpsubb xmm1, xmm2, dqword [rax] - -psubw xmm1, xmm2 -psubw xmm1, [rax] -psubw xmm1, dqword [rax] -vpsubw xmm1, xmm2 -vpsubw xmm1, [rax] -vpsubw xmm1, dqword [rax] -vpsubw xmm1, xmm2, xmm3 -vpsubw xmm1, xmm2, [rax] -vpsubw xmm1, xmm2, dqword [rax] - -psubd xmm1, xmm2 -psubd xmm1, [rax] -psubd xmm1, dqword [rax] -vpsubd xmm1, xmm2 -vpsubd xmm1, [rax] -vpsubd xmm1, dqword [rax] -vpsubd xmm1, xmm2, xmm3 -vpsubd xmm1, xmm2, [rax] -vpsubd xmm1, xmm2, dqword [rax] - -psubq xmm1, xmm2 -psubq xmm1, [rax] -psubq xmm1, dqword [rax] -vpsubq xmm1, xmm2 -vpsubq xmm1, [rax] -vpsubq xmm1, dqword [rax] -vpsubq xmm1, xmm2, xmm3 -vpsubq xmm1, xmm2, [rax] -vpsubq xmm1, xmm2, dqword [rax] - -psubsb xmm1, xmm2 -psubsb xmm1, [rax] -psubsb xmm1, dqword [rax] -vpsubsb xmm1, xmm2 -vpsubsb xmm1, [rax] -vpsubsb xmm1, dqword [rax] -vpsubsb xmm1, xmm2, xmm3 -vpsubsb xmm1, xmm2, [rax] -vpsubsb xmm1, xmm2, dqword [rax] - -psubsw xmm1, xmm2 -psubsw xmm1, [rax] -psubsw xmm1, dqword [rax] -vpsubsw xmm1, xmm2 -vpsubsw xmm1, [rax] -vpsubsw xmm1, dqword [rax] -vpsubsw xmm1, xmm2, xmm3 -vpsubsw xmm1, xmm2, [rax] -vpsubsw xmm1, xmm2, dqword [rax] - -psubusb xmm1, xmm2 -psubusb xmm1, [rax] -psubusb xmm1, dqword [rax] -vpsubusb xmm1, xmm2 -vpsubusb xmm1, [rax] -vpsubusb xmm1, dqword [rax] -vpsubusb xmm1, xmm2, xmm3 -vpsubusb xmm1, xmm2, [rax] -vpsubusb xmm1, xmm2, dqword [rax] - -psubusw xmm1, xmm2 -psubusw xmm1, [rax] -psubusw xmm1, dqword [rax] -vpsubusw xmm1, xmm2 -vpsubusw xmm1, [rax] -vpsubusw xmm1, dqword [rax] -vpsubusw xmm1, xmm2, xmm3 -vpsubusw xmm1, xmm2, [rax] -vpsubusw xmm1, xmm2, dqword [rax] - -punpckhbw xmm1, xmm2 -punpckhbw xmm1, [rax] -punpckhbw xmm1, dqword [rax] -vpunpckhbw xmm1, xmm2 -vpunpckhbw xmm1, [rax] -vpunpckhbw xmm1, dqword [rax] -vpunpckhbw xmm1, xmm2, xmm3 -vpunpckhbw xmm1, xmm2, [rax] -vpunpckhbw xmm1, xmm2, dqword [rax] - -punpckhwd xmm1, xmm2 -punpckhwd xmm1, [rax] -punpckhwd xmm1, dqword [rax] -vpunpckhwd xmm1, xmm2 -vpunpckhwd xmm1, [rax] -vpunpckhwd xmm1, dqword [rax] -vpunpckhwd xmm1, xmm2, xmm3 -vpunpckhwd xmm1, xmm2, [rax] -vpunpckhwd xmm1, xmm2, dqword [rax] - -punpckhdq xmm1, xmm2 -punpckhdq xmm1, [rax] -punpckhdq xmm1, dqword [rax] -vpunpckhdq xmm1, xmm2 -vpunpckhdq xmm1, [rax] -vpunpckhdq xmm1, dqword [rax] -vpunpckhdq xmm1, xmm2, xmm3 -vpunpckhdq xmm1, xmm2, [rax] -vpunpckhdq xmm1, xmm2, dqword [rax] - -punpckhqdq xmm1, xmm2 -punpckhqdq xmm1, [rax] -punpckhqdq xmm1, dqword [rax] -vpunpckhqdq xmm1, xmm2 -vpunpckhqdq xmm1, [rax] -vpunpckhqdq xmm1, dqword [rax] -vpunpckhqdq xmm1, xmm2, xmm3 -vpunpckhqdq xmm1, xmm2, [rax] -vpunpckhqdq xmm1, xmm2, dqword [rax] - -punpcklbw xmm1, xmm2 -punpcklbw xmm1, [rax] -punpcklbw xmm1, dqword [rax] -vpunpcklbw xmm1, xmm2 -vpunpcklbw xmm1, [rax] -vpunpcklbw xmm1, dqword [rax] -vpunpcklbw xmm1, xmm2, xmm3 -vpunpcklbw xmm1, xmm2, [rax] -vpunpcklbw xmm1, xmm2, dqword [rax] - -punpcklwd xmm1, xmm2 -punpcklwd xmm1, [rax] -punpcklwd xmm1, dqword [rax] -vpunpcklwd xmm1, xmm2 -vpunpcklwd xmm1, [rax] -vpunpcklwd xmm1, dqword [rax] -vpunpcklwd xmm1, xmm2, xmm3 -vpunpcklwd xmm1, xmm2, [rax] -vpunpcklwd xmm1, xmm2, dqword [rax] - -punpckldq xmm1, xmm2 -punpckldq xmm1, [rax] -punpckldq xmm1, dqword [rax] -vpunpckldq xmm1, xmm2 -vpunpckldq xmm1, [rax] -vpunpckldq xmm1, dqword [rax] -vpunpckldq xmm1, xmm2, xmm3 -vpunpckldq xmm1, xmm2, [rax] -vpunpckldq xmm1, xmm2, dqword [rax] - -punpcklqdq xmm1, xmm2 -punpcklqdq xmm1, [rax] -punpcklqdq xmm1, dqword [rax] -vpunpcklqdq xmm1, xmm2 -vpunpcklqdq xmm1, [rax] -vpunpcklqdq xmm1, dqword [rax] -vpunpcklqdq xmm1, xmm2, xmm3 -vpunpcklqdq xmm1, xmm2, [rax] -vpunpcklqdq xmm1, xmm2, dqword [rax] - -pxor xmm1, xmm2 -pxor xmm1, [rax] -pxor xmm1, dqword [rax] -vpxor xmm1, xmm2 -vpxor xmm1, [rax] -vpxor xmm1, dqword [rax] -vpxor xmm1, xmm2, xmm3 -vpxor xmm1, xmm2, [rax] -vpxor xmm1, xmm2, dqword [rax] - -rcpps xmm1, xmm2 -rcpps xmm1, [rax] -rcpps xmm1, dqword [rax] -vrcpps xmm1, xmm2 -vrcpps xmm1, [rax] -vrcpps xmm1, dqword [rax] -vrcpps ymm1, ymm2 -vrcpps ymm1, [rax] -vrcpps ymm1, yword [rax] - -rcpss xmm1, xmm2 -rcpss xmm1, [rax] -rcpss xmm1, dword [rax] -vrcpss xmm1, xmm2 -vrcpss xmm1, [rax] -vrcpss xmm1, dword [rax] -vrcpss xmm1, xmm2, xmm3 -vrcpss xmm1, xmm2, [rax] -vrcpss xmm1, xmm2, dword [rax] - -rsqrtps xmm1, xmm2 -rsqrtps xmm1, [rax] -rsqrtps xmm1, dqword [rax] -vrsqrtps xmm1, xmm2 -vrsqrtps xmm1, [rax] -vrsqrtps xmm1, dqword [rax] -vrsqrtps ymm1, ymm2 -vrsqrtps ymm1, [rax] -vrsqrtps ymm1, yword [rax] - -rsqrtss xmm1, xmm2 -rsqrtss xmm1, [rax] -rsqrtss xmm1, dword [rax] -vrsqrtss xmm1, xmm2 -vrsqrtss xmm1, [rax] -vrsqrtss xmm1, dword [rax] -vrsqrtss xmm1, xmm2, xmm3 -vrsqrtss xmm1, xmm2, [rax] -vrsqrtss xmm1, xmm2, dword [rax] - -roundpd xmm1, xmm2, 5 -roundpd xmm1, [rax], byte 5 -roundpd xmm1, dqword [rax], 5 -vroundpd xmm1, xmm2, 5 -vroundpd xmm1, [rax], byte 5 -vroundpd xmm1, dqword [rax], 5 -vroundpd ymm1, ymm2, 5 -vroundpd ymm1, [rax], byte 5 -vroundpd ymm1, yword [rax], 5 - -roundps xmm1, xmm2, 5 -roundps xmm1, [rax], byte 5 -roundps xmm1, dqword [rax], 5 -vroundps xmm1, xmm2, 5 -vroundps xmm1, [rax], byte 5 -vroundps xmm1, dqword [rax], 5 -vroundps ymm1, ymm2, 5 -vroundps ymm1, [rax], byte 5 -vroundps ymm1, yword [rax], 5 - -roundsd xmm1, xmm2, 5 -roundsd xmm1, [rax], byte 5 -roundsd xmm1, qword [rax], 5 -vroundsd xmm1, xmm2, 5 -vroundsd xmm1, [rax], byte 5 -vroundsd xmm1, qword [rax], 5 -vroundsd xmm1, xmm2, xmm3, 5 -vroundsd xmm1, xmm2, [rax], byte 5 -vroundsd xmm1, xmm2, qword [rax], 5 - -roundss xmm1, xmm2, 5 -roundss xmm1, [rax], byte 5 -roundss xmm1, dword [rax], 5 -vroundss xmm1, xmm2, 5 -vroundss xmm1, [rax], byte 5 -vroundss xmm1, dword [rax], 5 -vroundss xmm1, xmm2, xmm3, 5 -vroundss xmm1, xmm2, [rax], byte 5 -vroundss xmm1, xmm2, dword [rax], 5 - -shufpd xmm1, xmm2, 5 -shufpd xmm1, [rax], byte 5 -shufpd xmm1, dqword [rax], 5 -vshufpd xmm1, xmm2, 5 -vshufpd xmm1, [rax], byte 5 -vshufpd xmm1, dqword [rax], 5 -vshufpd xmm1, xmm2, xmm3, 5 -vshufpd xmm1, xmm2, [rax], byte 5 -vshufpd xmm1, xmm2, dqword [rax], 5 -vshufpd ymm1, ymm2, ymm3, 5 -vshufpd ymm1, ymm2, [rax], byte 5 -vshufpd ymm1, ymm2, yword [rax], 5 - -shufps xmm1, xmm2, 5 -shufps xmm1, [rax], byte 5 -shufps xmm1, dqword [rax], 5 -vshufps xmm1, xmm2, 5 -vshufps xmm1, [rax], byte 5 -vshufps xmm1, dqword [rax], 5 -vshufps xmm1, xmm2, xmm3, 5 -vshufps xmm1, xmm2, [rax], byte 5 -vshufps xmm1, xmm2, dqword [rax], 5 -vshufps ymm1, ymm2, ymm3, 5 -vshufps ymm1, ymm2, [rax], byte 5 -vshufps ymm1, ymm2, yword [rax], 5 - -sqrtpd xmm1, xmm2 -sqrtpd xmm1, [rax] -sqrtpd xmm1, dqword [rax] -vsqrtpd xmm1, xmm2 -vsqrtpd xmm1, [rax] -vsqrtpd xmm1, dqword [rax] -vsqrtpd ymm1, ymm2 -vsqrtpd ymm1, [rax] -vsqrtpd ymm1, yword [rax] - -sqrtps xmm1, xmm2 -sqrtps xmm1, [rax] -sqrtps xmm1, dqword [rax] -vsqrtps xmm1, xmm2 -vsqrtps xmm1, [rax] -vsqrtps xmm1, dqword [rax] -vsqrtps ymm1, ymm2 -vsqrtps ymm1, [rax] -vsqrtps ymm1, yword [rax] - -sqrtsd xmm1, xmm2 -sqrtsd xmm1, [rax] -sqrtsd xmm1, qword [rax] -vsqrtsd xmm1, xmm2 -vsqrtsd xmm1, [rax] -vsqrtsd xmm1, qword [rax] -vsqrtsd xmm1, xmm2, xmm3 -vsqrtsd xmm1, xmm2, [rax] -vsqrtsd xmm1, xmm2, qword [rax] - -sqrtss xmm1, xmm2 -sqrtss xmm1, [rax] -sqrtss xmm1, dword [rax] -vsqrtss xmm1, xmm2 -vsqrtss xmm1, [rax] -vsqrtss xmm1, dword [rax] -vsqrtss xmm1, xmm2, xmm3 -vsqrtss xmm1, xmm2, [rax] -vsqrtss xmm1, xmm2, dword [rax] - -stmxcsr [rax] -stmxcsr dword [rax] -vstmxcsr [rax] -vstmxcsr dword [rax] - -subpd xmm1, xmm2 -subpd xmm1, [rax] -subpd xmm1, dqword [rax] -vsubpd xmm1, xmm2 -vsubpd xmm1, [rax] -vsubpd xmm1, dqword [rax] -vsubpd xmm1, xmm2, xmm3 -vsubpd xmm1, xmm2, [rax] -vsubpd xmm1, xmm2, dqword [rax] -vsubpd ymm1, ymm2, ymm3 -vsubpd ymm1, ymm2, [rax] -vsubpd ymm1, ymm2, yword [rax] - -subps xmm1, xmm2 -subps xmm1, [rax] -subps xmm1, dqword [rax] -vsubps xmm1, xmm2 -vsubps xmm1, [rax] -vsubps xmm1, dqword [rax] -vsubps xmm1, xmm2, xmm3 -vsubps xmm1, xmm2, [rax] -vsubps xmm1, xmm2, dqword [rax] -vsubps ymm1, ymm2, ymm3 -vsubps ymm1, ymm2, [rax] -vsubps ymm1, ymm2, yword [rax] - -subsd xmm1, xmm2 -subsd xmm1, [rax] -subsd xmm1, qword [rax] -vsubsd xmm1, xmm2 -vsubsd xmm1, [rax] -vsubsd xmm1, qword [rax] -vsubsd xmm1, xmm2, xmm3 -vsubsd xmm1, xmm2, [rax] -vsubsd xmm1, xmm2, qword [rax] - -subss xmm1, xmm2 -subss xmm1, [rax] -subss xmm1, dword [rax] -vsubss xmm1, xmm2 -vsubss xmm1, [rax] -vsubss xmm1, dword [rax] -vsubss xmm1, xmm2, xmm3 -vsubss xmm1, xmm2, [rax] -vsubss xmm1, xmm2, dword [rax] - -ucomisd xmm1, xmm2 -ucomisd xmm1, [rax] -ucomisd xmm1, qword [rax] -vucomisd xmm1, xmm2 -vucomisd xmm1, [rax] -vucomisd xmm1, qword [rax] - -ucomiss xmm1, xmm2 -ucomiss xmm1, [rax] -ucomiss xmm1, dword [rax] -vucomiss xmm1, xmm2 -vucomiss xmm1, [rax] -vucomiss xmm1, dword [rax] - -unpckhpd xmm1, xmm2 -unpckhpd xmm1, [rax] -unpckhpd xmm1, dqword [rax] -vunpckhpd xmm1, xmm2 -vunpckhpd xmm1, [rax] -vunpckhpd xmm1, dqword [rax] -vunpckhpd xmm1, xmm2, xmm3 -vunpckhpd xmm1, xmm2, [rax] -vunpckhpd xmm1, xmm2, dqword [rax] -vunpckhpd ymm1, ymm2, ymm3 -vunpckhpd ymm1, ymm2, [rax] -vunpckhpd ymm1, ymm2, yword [rax] - -unpckhps xmm1, xmm2 -unpckhps xmm1, [rax] -unpckhps xmm1, dqword [rax] -vunpckhps xmm1, xmm2 -vunpckhps xmm1, [rax] -vunpckhps xmm1, dqword [rax] -vunpckhps xmm1, xmm2, xmm3 -vunpckhps xmm1, xmm2, [rax] -vunpckhps xmm1, xmm2, dqword [rax] -vunpckhps ymm1, ymm2, ymm3 -vunpckhps ymm1, ymm2, [rax] -vunpckhps ymm1, ymm2, yword [rax] - -unpcklpd xmm1, xmm2 -unpcklpd xmm1, [rax] -unpcklpd xmm1, dqword [rax] -vunpcklpd xmm1, xmm2 -vunpcklpd xmm1, [rax] -vunpcklpd xmm1, dqword [rax] -vunpcklpd xmm1, xmm2, xmm3 -vunpcklpd xmm1, xmm2, [rax] -vunpcklpd xmm1, xmm2, dqword [rax] -vunpcklpd ymm1, ymm2, ymm3 -vunpcklpd ymm1, ymm2, [rax] -vunpcklpd ymm1, ymm2, yword [rax] - -unpcklps xmm1, xmm2 -unpcklps xmm1, [rax] -unpcklps xmm1, dqword [rax] -vunpcklps xmm1, xmm2 -vunpcklps xmm1, [rax] -vunpcklps xmm1, dqword [rax] -vunpcklps xmm1, xmm2, xmm3 -vunpcklps xmm1, xmm2, [rax] -vunpcklps xmm1, xmm2, dqword [rax] -vunpcklps ymm1, ymm2, ymm3 -vunpcklps ymm1, ymm2, [rax] -vunpcklps ymm1, ymm2, yword [rax] - -xorpd xmm1, xmm2 -xorpd xmm1, [rax] -xorpd xmm1, dqword [rax] -vxorpd xmm1, xmm2 -vxorpd xmm1, [rax] -vxorpd xmm1, dqword [rax] -vxorpd xmm1, xmm2, xmm3 -vxorpd xmm1, xmm2, [rax] -vxorpd xmm1, xmm2, dqword [rax] -vxorpd ymm1, ymm2, ymm3 -vxorpd ymm1, ymm2, [rax] -vxorpd ymm1, ymm2, yword [rax] - -xorps xmm1, xmm2 -xorps xmm1, [rax] -xorps xmm1, dqword [rax] -vxorps xmm1, xmm2 -vxorps xmm1, [rax] -vxorps xmm1, dqword [rax] -vxorps xmm1, xmm2, xmm3 -vxorps xmm1, xmm2, [rax] -vxorps xmm1, xmm2, dqword [rax] -vxorps ymm1, ymm2, ymm3 -vxorps ymm1, ymm2, [rax] -vxorps ymm1, ymm2, yword [rax] - -vzeroall - -vzeroupper - diff --git a/modules/arch/x86/tests/avx.hex b/modules/arch/x86/tests/avx.hex deleted file mode 100644 index 57eb96f5..00000000 --- a/modules/arch/x86/tests/avx.hex +++ /dev/null @@ -1,10332 +0,0 @@ -66 -0f -58 -ca -66 -0f -58 -08 -66 -0f -58 -08 -66 -45 -0f -58 -d4 -66 -46 -0f -58 -14 -b8 -66 -47 -0f -58 -14 -be -c5 -f1 -58 -ca -c5 -f1 -58 -08 -c5 -f1 -58 -08 -c4 -41 -29 -58 -d4 -c4 -21 -29 -58 -14 -b8 -c4 -01 -29 -58 -14 -be -c5 -e9 -58 -cb -c5 -e9 -58 -08 -c5 -e9 -58 -08 -c4 -41 -19 -58 -d5 -c4 -21 -19 -58 -14 -b8 -c4 -01 -19 -58 -14 -be -c5 -ed -58 -cb -c5 -ed -58 -08 -c5 -ed -58 -08 -c4 -41 -1d -58 -d5 -c4 -21 -1d -58 -14 -b8 -c4 -01 -1d -58 -14 -be -0f -58 -ca -0f -58 -08 -0f -58 -08 -c5 -f0 -58 -ca -c5 -f0 -58 -08 -c5 -f0 -58 -08 -c5 -e8 -58 -cb -c5 -e8 -58 -08 -c5 -e8 -58 -08 -c5 -ec -58 -cb -c5 -ec -58 -08 -c5 -ec -58 -08 -f2 -0f -58 -ca -f2 -0f -58 -08 -f2 -0f -58 -08 -c5 -f3 -58 -ca -c5 -f3 -58 -08 -c5 -f3 -58 -08 -c5 -eb -58 -cb -c5 -eb -58 -08 -c5 -eb -58 -08 -f3 -0f -58 -ca -f3 -0f -58 -08 -f3 -0f -58 -08 -c5 -f2 -58 -ca -c5 -f2 -58 -08 -c5 -f2 -58 -08 -c5 -ea -58 -cb -c5 -ea -58 -08 -c5 -ea -58 -08 -66 -0f -d0 -ca -66 -0f -d0 -08 -66 -0f -d0 -08 -c5 -f1 -d0 -ca -c5 -f1 -d0 -08 -c5 -f1 -d0 -08 -c5 -e9 -d0 -cb -c5 -e9 -d0 -08 -c5 -e9 -d0 -08 -c5 -ed -d0 -cb -c5 -ed -d0 -08 -c5 -ed -d0 -08 -f2 -0f -d0 -ca -f2 -0f -d0 -08 -f2 -0f -d0 -08 -c5 -f3 -d0 -ca -c5 -f3 -d0 -08 -c5 -f3 -d0 -08 -c5 -eb -d0 -cb -c5 -eb -d0 -08 -c5 -eb -d0 -08 -c5 -ef -d0 -cb -c5 -ef -d0 -08 -c5 -ef -d0 -08 -66 -0f -54 -ca -66 -0f -54 -08 -66 -0f -54 -08 -c5 -f1 -54 -ca -c5 -f1 -54 -08 -c5 -f1 -54 -08 -c5 -e9 -54 -cb -c5 -e9 -54 -08 -c5 -e9 -54 -08 -c5 -ed -54 -cb -c5 -ed -54 -08 -c5 -ed -54 -08 -0f -54 -ca -0f -54 -08 -0f -54 -08 -c5 -f0 -54 -ca -c5 -f0 -54 -08 -c5 -f0 -54 -08 -c5 -e8 -54 -cb -c5 -e8 -54 -08 -c5 -e8 -54 -08 -c5 -ec -54 -cb -c5 -ec -54 -08 -c5 -ec -54 -08 -66 -0f -55 -ca -66 -0f -55 -08 -66 -0f -55 -08 -c5 -f1 -55 -ca -c5 -f1 -55 -08 -c5 -f1 -55 -08 -c5 -e9 -55 -cb -c5 -e9 -55 -08 -c5 -e9 -55 -08 -c5 -ed -55 -cb -c5 -ed -55 -08 -c5 -ed -55 -08 -0f -55 -ca -0f -55 -08 -0f -55 -08 -c5 -f0 -55 -ca -c5 -f0 -55 -08 -c5 -f0 -55 -08 -c5 -e8 -55 -cb -c5 -e8 -55 -08 -c5 -e8 -55 -08 -c5 -ec -55 -cb -c5 -ec -55 -08 -c5 -ec -55 -08 -66 -0f -3a -0d -ca -05 -66 -0f -3a -0d -08 -05 -66 -0f -3a -0d -08 -05 -c4 -e3 -71 -0d -ca -05 -c4 -e3 -71 -0d -08 -05 -c4 -e3 -71 -0d -08 -05 -c4 -e3 -69 -0d -cb -05 -c4 -e3 -69 -0d -08 -05 -c4 -e3 -69 -0d -08 -05 -c4 -e3 -6d -0d -cb -05 -c4 -e3 -6d -0d -08 -05 -c4 -e3 -6d -0d -08 -05 -66 -0f -3a -0c -ca -05 -66 -0f -3a -0c -08 -05 -66 -0f -3a -0c -08 -05 -c4 -e3 -71 -0c -ca -05 -c4 -e3 -71 -0c -08 -05 -c4 -e3 -71 -0c -08 -05 -c4 -e3 -69 -0c -cb -05 -c4 -e3 -69 -0c -08 -05 -c4 -e3 -69 -0c -08 -05 -c4 -e3 -6d -0c -cb -05 -c4 -e3 -6d -0c -08 -05 -c4 -e3 -6d -0c -08 -05 -66 -0f -38 -15 -cb -66 -0f -38 -15 -08 -66 -0f -38 -15 -08 -66 -0f -38 -15 -cb -66 -0f -38 -15 -08 -66 -0f -38 -15 -08 -c4 -e3 -69 -4b -cb -40 -c4 -e3 -69 -4b -08 -40 -c4 -e3 -69 -4b -08 -40 -c4 -e3 -6d -4b -cb -40 -c4 -e3 -6d -4b -08 -40 -c4 -e3 -6d -4b -08 -40 -66 -0f -38 -14 -cb -66 -0f -38 -14 -08 -66 -0f -38 -14 -08 -66 -0f -38 -14 -cb -66 -0f -38 -14 -08 -66 -0f -38 -14 -08 -c4 -e3 -69 -4a -cb -40 -c4 -e3 -69 -4a -08 -40 -c4 -e3 -69 -4a -08 -40 -c4 -e3 -6d -4a -cb -40 -c4 -e3 -6d -4a -08 -40 -c4 -e3 -6d -4a -08 -40 -c4 -e2 -79 -18 -08 -c4 -e2 -79 -18 -08 -c4 -e2 -7d -18 -08 -c4 -e2 -7d -18 -08 -c4 -e2 -7d -19 -08 -c4 -e2 -7d -19 -08 -c4 -e2 -7d -1a -08 -c4 -e2 -7d -1a -08 -66 -0f -c2 -ca -05 -66 -0f -c2 -08 -05 -66 -0f -c2 -08 -05 -c5 -f1 -c2 -ca -05 -c5 -f1 -c2 -08 -05 -c5 -f1 -c2 -08 -05 -c5 -e9 -c2 -cb -05 -c5 -e9 -c2 -08 -05 -c5 -e9 -c2 -08 -05 -c5 -ed -c2 -cb -05 -c5 -ed -c2 -08 -05 -c5 -ed -c2 -08 -05 -0f -c2 -ca -05 -0f -c2 -08 -05 -0f -c2 -08 -05 -c5 -f0 -c2 -ca -05 -c5 -f0 -c2 -08 -05 -c5 -f0 -c2 -08 -05 -c5 -e8 -c2 -cb -05 -c5 -e8 -c2 -08 -05 -c5 -e8 -c2 -08 -05 -c5 -ec -c2 -cb -05 -c5 -ec -c2 -08 -05 -c5 -ec -c2 -08 -05 -f2 -0f -c2 -ca -05 -f2 -0f -c2 -08 -05 -f2 -0f -c2 -08 -05 -c5 -f3 -c2 -ca -05 -c5 -f3 -c2 -08 -05 -c5 -f3 -c2 -08 -05 -c5 -eb -c2 -cb -05 -c5 -eb -c2 -08 -05 -c5 -eb -c2 -08 -05 -f3 -0f -c2 -ca -05 -f3 -0f -c2 -08 -05 -f3 -0f -c2 -08 -05 -c5 -f2 -c2 -ca -05 -c5 -f2 -c2 -08 -05 -c5 -f2 -c2 -08 -05 -c5 -ea -c2 -cb -05 -c5 -ea -c2 -08 -05 -c5 -ea -c2 -08 -05 -66 -0f -2f -ca -66 -0f -2f -08 -66 -0f -2f -08 -c5 -f9 -2f -ca -c5 -f9 -2f -08 -c5 -f9 -2f -08 -0f -2f -ca -0f -2f -08 -0f -2f -08 -c5 -f8 -2f -ca -c5 -f8 -2f -08 -c5 -f8 -2f -08 -f3 -0f -e6 -ca -f3 -0f -e6 -08 -f3 -0f -e6 -08 -c5 -fa -e6 -ca -c5 -fa -e6 -08 -c5 -fa -e6 -08 -c5 -fe -e6 -ca -c5 -fe -e6 -08 -c5 -fe -e6 -08 -0f -5b -ca -0f -5b -08 -0f -5b -08 -c5 -f8 -5b -ca -c5 -f8 -5b -08 -c5 -f8 -5b -08 -c5 -fc -5b -ca -c5 -fc -5b -08 -c5 -fc -5b -08 -f2 -0f -e6 -ca -f2 -0f -e6 -08 -f2 -0f -e6 -08 -c5 -fb -e6 -ca -c5 -fb -e6 -08 -c5 -ff -e6 -ca -c5 -ff -e6 -08 -66 -0f -5a -ca -66 -0f -5a -08 -66 -0f -5a -08 -c5 -f9 -5a -ca -c5 -f9 -5a -08 -c5 -fd -5a -ca -c5 -fd -5a -08 -66 -0f -5b -ca -66 -0f -5b -08 -66 -0f -5b -08 -c5 -f9 -5b -ca -c5 -f9 -5b -08 -c5 -f9 -5b -08 -c5 -fd -5b -ca -c5 -fd -5b -08 -c5 -fd -5b -08 -0f -5a -ca -0f -5a -08 -0f -5a -08 -c5 -f8 -5a -ca -c5 -f8 -5a -08 -c5 -f8 -5a -08 -c5 -fc -5a -ca -c5 -fc -5a -08 -c5 -fc -5a -08 -f2 -0f -2d -c2 -f2 -0f -2d -00 -f2 -0f -2d -00 -c5 -fb -2d -c2 -c5 -fb -2d -00 -c5 -fb -2d -00 -f2 -48 -0f -2d -c2 -f2 -48 -0f -2d -00 -f2 -48 -0f -2d -00 -c4 -e1 -fb -2d -c2 -c4 -e1 -fb -2d -00 -c4 -e1 -fb -2d -00 -f2 -0f -5a -ca -f2 -0f -5a -08 -f2 -0f -5a -08 -c5 -f3 -5a -ca -c5 -f3 -5a -08 -c5 -f3 -5a -08 -c5 -eb -5a -cb -c5 -eb -5a -08 -c5 -eb -5a -08 -f2 -0f -2a -c8 -f2 -0f -2a -08 -c5 -f3 -2a -c8 -c5 -f3 -2a -08 -c5 -eb -2a -c8 -c5 -eb -2a -08 -f2 -48 -0f -2a -c8 -f2 -48 -0f -2a -08 -c4 -e1 -f3 -2a -c8 -c4 -e1 -f3 -2a -08 -c4 -e1 -eb -2a -c8 -c4 -e1 -eb -2a -08 -f3 -0f -2a -c8 -f3 -0f -2a -08 -c5 -f2 -2a -c8 -c5 -f2 -2a -08 -c5 -ea -2a -c8 -c5 -ea -2a -08 -f3 -48 -0f -2a -c8 -f3 -48 -0f -2a -08 -c4 -e1 -f2 -2a -c8 -c4 -e1 -f2 -2a -08 -c4 -e1 -ea -2a -c8 -c4 -e1 -ea -2a -08 -f3 -0f -5a -ca -f3 -0f -5a -08 -f3 -0f -5a -08 -c5 -f2 -5a -ca -c5 -f2 -5a -08 -c5 -f2 -5a -08 -c5 -ea -5a -cb -c5 -ea -5a -08 -c5 -ea -5a -08 -f3 -0f -2d -c2 -f3 -0f -2d -00 -f3 -0f -2d -00 -c5 -fa -2d -c2 -c5 -fa -2d -00 -c5 -fa -2d -00 -f3 -48 -0f -2d -c2 -f3 -48 -0f -2d -00 -f3 -48 -0f -2d -00 -c4 -e1 -fa -2d -c2 -c4 -e1 -fa -2d -00 -c4 -e1 -fa -2d -00 -66 -0f -e6 -ca -66 -0f -e6 -08 -66 -0f -e6 -08 -c5 -f9 -e6 -ca -c5 -f9 -e6 -08 -c5 -fd -e6 -ca -c5 -fd -e6 -08 -f3 -0f -5b -ca -f3 -0f -5b -08 -f3 -0f -5b -08 -c5 -fa -5b -ca -c5 -fa -5b -08 -c5 -fa -5b -08 -c5 -fe -5b -ca -c5 -fe -5b -08 -c5 -fe -5b -08 -f2 -0f -2c -c2 -f2 -0f -2c -00 -f2 -0f -2c -00 -c5 -fb -2c -c2 -c5 -fb -2c -00 -c5 -fb -2c -00 -f2 -48 -0f -2c -c2 -f2 -48 -0f -2c -00 -f2 -48 -0f -2c -00 -c4 -e1 -fb -2c -c2 -c4 -e1 -fb -2c -00 -c4 -e1 -fb -2c -00 -f3 -0f -2c -c2 -f3 -0f -2c -00 -f3 -0f -2c -00 -c5 -fa -2c -c2 -c5 -fa -2c -00 -c5 -fa -2c -00 -f3 -48 -0f -2c -c2 -f3 -48 -0f -2c -00 -f3 -48 -0f -2c -00 -c4 -e1 -fa -2c -c2 -c4 -e1 -fa -2c -00 -c4 -e1 -fa -2c -00 -66 -0f -5e -ca -66 -0f -5e -08 -66 -0f -5e -08 -c5 -f1 -5e -ca -c5 -f1 -5e -08 -c5 -f1 -5e -08 -c5 -e9 -5e -cb -c5 -e9 -5e -08 -c5 -e9 -5e -08 -c5 -ed -5e -cb -c5 -ed -5e -08 -c5 -ed -5e -08 -0f -5e -ca -0f -5e -08 -0f -5e -08 -c5 -f0 -5e -ca -c5 -f0 -5e -08 -c5 -f0 -5e -08 -c5 -e8 -5e -cb -c5 -e8 -5e -08 -c5 -e8 -5e -08 -c5 -ec -5e -cb -c5 -ec -5e -08 -c5 -ec -5e -08 -f2 -0f -5e -ca -f2 -0f -5e -08 -f2 -0f -5e -08 -c5 -f3 -5e -ca -c5 -f3 -5e -08 -c5 -f3 -5e -08 -c5 -eb -5e -cb -c5 -eb -5e -08 -c5 -eb -5e -08 -f3 -0f -5e -ca -f3 -0f -5e -08 -f3 -0f -5e -08 -c5 -f2 -5e -ca -c5 -f2 -5e -08 -c5 -f2 -5e -08 -c5 -ea -5e -cb -c5 -ea -5e -08 -c5 -ea -5e -08 -66 -0f -3a -41 -ca -05 -66 -0f -3a -41 -08 -05 -66 -0f -3a -41 -08 -05 -c4 -e3 -71 -41 -ca -05 -c4 -e3 -71 -41 -08 -05 -c4 -e3 -71 -41 -08 -05 -c4 -e3 -69 -41 -cb -05 -c4 -e3 -69 -41 -08 -05 -c4 -e3 -69 -41 -08 -05 -66 -0f -3a -40 -ca -05 -66 -0f -3a -40 -08 -05 -66 -0f -3a -40 -08 -05 -c4 -e3 -71 -40 -ca -05 -c4 -e3 -71 -40 -08 -05 -c4 -e3 -71 -40 -08 -05 -c4 -e3 -69 -40 -cb -05 -c4 -e3 -69 -40 -08 -05 -c4 -e3 -69 -40 -08 -05 -c4 -e3 -6d -40 -cb -05 -c4 -e3 -6d -40 -08 -05 -c4 -e3 -6d -40 -08 -05 -c4 -e3 -7d -19 -d1 -05 -c4 -e3 -7d -19 -10 -05 -c4 -e3 -7d -19 -10 -05 -66 -0f -3a -17 -c8 -05 -66 -48 -0f -3a -17 -c8 -05 -66 -0f -3a -17 -08 -05 -66 -0f -3a -17 -08 -05 -c4 -e3 -79 -17 -c8 -05 -c4 -e3 -f9 -17 -c8 -05 -c4 -e3 -79 -17 -08 -05 -c4 -e3 -79 -17 -08 -05 -66 -0f -7c -ca -66 -0f -7c -08 -66 -0f -7c -08 -c5 -f1 -7c -ca -c5 -f1 -7c -08 -c5 -f1 -7c -08 -c5 -e9 -7c -cb -c5 -e9 -7c -08 -c5 -e9 -7c -08 -c5 -ed -7c -cb -c5 -ed -7c -08 -c5 -ed -7c -08 -f2 -0f -7c -ca -f2 -0f -7c -08 -f2 -0f -7c -08 -c5 -f3 -7c -ca -c5 -f3 -7c -08 -c5 -f3 -7c -08 -c5 -eb -7c -cb -c5 -eb -7c -08 -c5 -eb -7c -08 -c5 -ef -7c -cb -c5 -ef -7c -08 -c5 -ef -7c -08 -66 -0f -7d -ca -66 -0f -7d -08 -66 -0f -7d -08 -c5 -f1 -7d -ca -c5 -f1 -7d -08 -c5 -f1 -7d -08 -c5 -e9 -7d -cb -c5 -e9 -7d -08 -c5 -e9 -7d -08 -c5 -ed -7d -cb -c5 -ed -7d -08 -c5 -ed -7d -08 -f2 -0f -7d -ca -f2 -0f -7d -08 -f2 -0f -7d -08 -c5 -f3 -7d -ca -c5 -f3 -7d -08 -c5 -f3 -7d -08 -c5 -eb -7d -cb -c5 -eb -7d -08 -c5 -eb -7d -08 -c5 -ef -7d -cb -c5 -ef -7d -08 -c5 -ef -7d -08 -c4 -e3 -6d -18 -cb -05 -c4 -e3 -6d -18 -08 -05 -c4 -e3 -6d -18 -08 -05 -66 -0f -3a -21 -ca -05 -66 -0f -3a -21 -08 -05 -66 -0f -3a -21 -08 -05 -c4 -e3 -71 -21 -ca -05 -c4 -e3 -71 -21 -08 -05 -c4 -e3 -71 -21 -08 -05 -c4 -e3 -69 -21 -cb -05 -c4 -e3 -69 -21 -08 -05 -c4 -e3 -69 -21 -08 -05 -f2 -0f -f0 -08 -f2 -0f -f0 -08 -c5 -fb -f0 -08 -c5 -fb -f0 -08 -c5 -ff -f0 -08 -c5 -ff -f0 -08 -0f -ae -10 -0f -ae -10 -c5 -f8 -ae -10 -c5 -f8 -ae -10 -66 -0f -f7 -ca -c5 -f9 -f7 -ca -c4 -e2 -69 -2c -08 -c4 -e2 -69 -2c -08 -c4 -e2 -6d -2c -08 -c4 -e2 -6d -2c -08 -c4 -e2 -69 -2e -18 -c4 -e2 -69 -2e -18 -c4 -e2 -6d -2e -18 -c4 -e2 -6d -2e -18 -c4 -e2 -69 -2d -08 -c4 -e2 -69 -2d -08 -c4 -e2 -6d -2d -08 -c4 -e2 -6d -2d -08 -c4 -e2 -69 -2f -18 -c4 -e2 -69 -2f -18 -c4 -e2 -6d -2f -18 -c4 -e2 -6d -2f -18 -66 -0f -5f -ca -66 -0f -5f -08 -66 -0f -5f -08 -c5 -f1 -5f -ca -c5 -f1 -5f -08 -c5 -f1 -5f -08 -c5 -e9 -5f -cb -c5 -e9 -5f -08 -c5 -e9 -5f -08 -c5 -ed -5f -cb -c5 -ed -5f -08 -c5 -ed -5f -08 -0f -5f -ca -0f -5f -08 -0f -5f -08 -c5 -f0 -5f -ca -c5 -f0 -5f -08 -c5 -f0 -5f -08 -c5 -e8 -5f -cb -c5 -e8 -5f -08 -c5 -e8 -5f -08 -c5 -ec -5f -cb -c5 -ec -5f -08 -c5 -ec -5f -08 -f2 -0f -5f -ca -f2 -0f -5f -08 -f2 -0f -5f -08 -c5 -f3 -5f -ca -c5 -f3 -5f -08 -c5 -f3 -5f -08 -c5 -eb -5f -cb -c5 -eb -5f -08 -c5 -eb -5f -08 -f3 -0f -5f -ca -f3 -0f -5f -08 -f3 -0f -5f -08 -c5 -f2 -5f -ca -c5 -f2 -5f -08 -c5 -f2 -5f -08 -c5 -ea -5f -cb -c5 -ea -5f -08 -c5 -ea -5f -08 -66 -0f -5d -ca -66 -0f -5d -08 -66 -0f -5d -08 -c5 -f1 -5d -ca -c5 -f1 -5d -08 -c5 -f1 -5d -08 -c5 -e9 -5d -cb -c5 -e9 -5d -08 -c5 -e9 -5d -08 -c5 -ed -5d -cb -c5 -ed -5d -08 -c5 -ed -5d -08 -0f -5d -ca -0f -5d -08 -0f -5d -08 -c5 -f0 -5d -ca -c5 -f0 -5d -08 -c5 -f0 -5d -08 -c5 -e8 -5d -cb -c5 -e8 -5d -08 -c5 -e8 -5d -08 -c5 -ec -5d -cb -c5 -ec -5d -08 -c5 -ec -5d -08 -f2 -0f -5d -ca -f2 -0f -5d -08 -f2 -0f -5d -08 -c5 -f3 -5d -ca -c5 -f3 -5d -08 -c5 -f3 -5d -08 -c5 -eb -5d -cb -c5 -eb -5d -08 -c5 -eb -5d -08 -f3 -0f -5d -ca -f3 -0f -5d -08 -f3 -0f -5d -08 -c5 -f2 -5d -ca -c5 -f2 -5d -08 -c5 -f2 -5d -08 -c5 -ea -5d -cb -c5 -ea -5d -08 -c5 -ea -5d -08 -66 -0f -28 -ca -66 -0f -28 -08 -66 -0f -28 -08 -c5 -f9 -28 -ca -c5 -f9 -28 -08 -c5 -f9 -28 -08 -66 -0f -29 -10 -66 -0f -29 -10 -c5 -f9 -29 -10 -c5 -f9 -29 -10 -c5 -fd -28 -ca -c5 -fd -28 -08 -c5 -fd -28 -08 -c5 -fd -29 -10 -c5 -fd -29 -10 -0f -28 -ca -0f -28 -08 -0f -28 -08 -c5 -f8 -28 -ca -c5 -f8 -28 -08 -c5 -f8 -28 -08 -0f -29 -10 -0f -29 -10 -c5 -f8 -29 -10 -c5 -f8 -29 -10 -c5 -fc -28 -ca -c5 -fc -28 -08 -c5 -fc -28 -08 -c5 -fc -29 -10 -c5 -fc -29 -10 -66 -0f -6e -c8 -66 -0f -6e -08 -66 -0f -6e -08 -c5 -f9 -6e -c8 -c5 -f9 -6e -08 -c5 -f9 -6e -08 -66 -0f -7e -d0 -66 -0f -7e -10 -66 -0f -7e -10 -c5 -f9 -7e -d0 -c5 -f9 -7e -10 -c5 -f9 -7e -10 -66 -48 -0f -6e -c8 -f3 -0f -7e -08 -f3 -0f -7e -08 -c4 -e1 -f9 -6e -c8 -c5 -fa -7e -08 -c5 -fa -7e -08 -66 -48 -0f -7e -d0 -66 -0f -d6 -10 -66 -0f -d6 -10 -c4 -e1 -f9 -7e -d0 -c5 -f9 -d6 -10 -c5 -f9 -d6 -10 -f3 -0f -7e -ca -f3 -0f -7e -08 -f3 -0f -7e -08 -c5 -fa -7e -ca -c5 -fa -7e -08 -c5 -fa -7e -08 -66 -0f -d6 -08 -66 -0f -d6 -08 -c5 -f9 -d6 -08 -c5 -f9 -d6 -08 -f2 -0f -12 -ca -f2 -0f -12 -08 -f2 -0f -12 -08 -c5 -fb -12 -ca -c5 -fb -12 -08 -c5 -fb -12 -08 -c5 -ff -12 -ca -c5 -ff -12 -08 -c5 -ff -12 -08 -66 -0f -6f -ca -66 -0f -6f -08 -66 -0f -6f -08 -66 -0f -7f -10 -66 -0f -7f -10 -c5 -f9 -6f -ca -c5 -f9 -6f -08 -c5 -f9 -6f -08 -c5 -f9 -7f -10 -c5 -f9 -7f -10 -c5 -fd -6f -ca -c5 -fd -6f -08 -c5 -fd -6f -08 -c5 -fd -7f -10 -c5 -fd -7f -10 -f3 -0f -6f -ca -f3 -0f -6f -08 -f3 -0f -6f -08 -f3 -0f -7f -10 -f3 -0f -7f -10 -c5 -fa -6f -ca -c5 -fa -6f -08 -c5 -fa -6f -08 -c5 -fa -7f -10 -c5 -fa -7f -10 -c5 -fe -6f -ca -c5 -fe -6f -08 -c5 -fe -6f -08 -c5 -fe -7f -10 -c5 -fe -7f -10 -0f -12 -ca -c5 -f0 -12 -ca -c5 -e8 -12 -cb -66 -0f -16 -08 -66 -0f -16 -08 -c5 -f1 -16 -08 -c5 -f1 -16 -08 -c5 -e9 -16 -08 -c5 -e9 -16 -08 -66 -0f -17 -10 -66 -0f -17 -10 -c5 -f9 -17 -10 -c5 -f9 -17 -10 -0f -16 -08 -0f -16 -08 -c5 -f0 -16 -08 -c5 -f0 -16 -08 -c5 -e8 -16 -08 -c5 -e8 -16 -08 -0f -17 -10 -0f -17 -10 -c5 -f8 -17 -10 -c5 -f8 -17 -10 -0f -12 -ca -c5 -f0 -12 -ca -c5 -e8 -12 -cb -66 -0f -12 -08 -66 -0f -12 -08 -c5 -f1 -12 -08 -c5 -f1 -12 -08 -c5 -e9 -12 -08 -c5 -e9 -12 -08 -66 -0f -13 -10 -66 -0f -13 -10 -c5 -f9 -13 -10 -c5 -f9 -13 -10 -0f -12 -08 -0f -12 -08 -c5 -f0 -12 -08 -c5 -f0 -12 -08 -c5 -e8 -12 -08 -c5 -e8 -12 -08 -0f -13 -10 -0f -13 -10 -c5 -f8 -13 -10 -c5 -f8 -13 -10 -66 -0f -50 -c2 -66 -48 -0f -50 -c2 -c5 -f9 -50 -c2 -c4 -e1 -f9 -50 -c2 -c5 -fd -50 -c2 -c4 -e1 -fd -50 -c2 -0f -50 -c2 -48 -0f -50 -c2 -c5 -f8 -50 -c2 -c4 -e1 -f8 -50 -c2 -c5 -fc -50 -c2 -c4 -e1 -fc -50 -c2 -66 -0f -e7 -08 -66 -0f -e7 -08 -c5 -f9 -e7 -08 -c5 -f9 -e7 -08 -c5 -fd -e7 -08 -c5 -fd -e7 -08 -66 -0f -38 -2a -08 -66 -0f -38 -2a -08 -c4 -e2 -79 -2a -08 -c4 -e2 -79 -2a -08 -66 -0f -2b -08 -66 -0f -2b -08 -c5 -f9 -2b -08 -c5 -f9 -2b -08 -c5 -fd -2b -08 -c5 -fd -2b -08 -0f -2b -08 -0f -2b -08 -c5 -f8 -2b -08 -c5 -f8 -2b -08 -c5 -fc -2b -08 -c5 -fc -2b -08 -f2 -0f -10 -ca -c5 -f3 -10 -ca -c5 -eb -10 -cb -f2 -0f -10 -08 -f2 -0f -10 -08 -c5 -fb -10 -08 -c5 -fb -10 -08 -f2 -0f -11 -10 -f2 -0f -11 -10 -c5 -fb -11 -10 -c5 -fb -11 -10 -f3 -0f -16 -ca -f3 -0f -16 -08 -f3 -0f -16 -08 -c5 -fa -16 -ca -c5 -fa -16 -08 -c5 -fa -16 -08 -c5 -fe -16 -ca -c5 -fe -16 -08 -c5 -fe -16 -08 -f3 -0f -12 -ca -f3 -0f -12 -08 -f3 -0f -12 -08 -c5 -fa -12 -ca -c5 -fa -12 -08 -c5 -fa -12 -08 -c5 -fe -12 -ca -c5 -fe -12 -08 -c5 -fe -12 -08 -f3 -0f -10 -ca -c5 -f2 -10 -ca -c5 -ea -10 -cb -f3 -0f -10 -08 -f3 -0f -10 -08 -c5 -fa -10 -08 -c5 -fa -10 -08 -f3 -0f -11 -10 -f3 -0f -11 -10 -c5 -fa -11 -10 -c5 -fa -11 -10 -66 -0f -10 -ca -66 -0f -10 -08 -66 -0f -10 -08 -c5 -f9 -10 -ca -c5 -f9 -10 -08 -c5 -f9 -10 -08 -66 -0f -11 -10 -66 -0f -11 -10 -c5 -f9 -11 -10 -c5 -f9 -11 -10 -c5 -fd -10 -ca -c5 -fd -10 -08 -c5 -fd -10 -08 -c5 -fd -11 -10 -c5 -fd -11 -10 -0f -10 -ca -0f -10 -08 -0f -10 -08 -c5 -f8 -10 -ca -c5 -f8 -10 -08 -c5 -f8 -10 -08 -0f -11 -10 -0f -11 -10 -c5 -f8 -11 -10 -c5 -f8 -11 -10 -c5 -fc -10 -ca -c5 -fc -10 -08 -c5 -fc -10 -08 -c5 -fc -11 -10 -c5 -fc -11 -10 -66 -0f -3a -42 -ca -05 -66 -0f -3a -42 -08 -05 -66 -0f -3a -42 -08 -05 -c4 -e3 -71 -42 -ca -05 -c4 -e3 -71 -42 -08 -05 -c4 -e3 -71 -42 -08 -05 -c4 -e3 -69 -42 -cb -05 -c4 -e3 -69 -42 -08 -05 -c4 -e3 -69 -42 -08 -05 -66 -0f -59 -ca -66 -0f -59 -08 -66 -0f -59 -08 -c5 -f1 -59 -ca -c5 -f1 -59 -08 -c5 -f1 -59 -08 -c5 -e9 -59 -cb -c5 -e9 -59 -08 -c5 -e9 -59 -08 -c5 -ed -59 -cb -c5 -ed -59 -08 -c5 -ed -59 -08 -0f -59 -ca -0f -59 -08 -0f -59 -08 -c5 -f0 -59 -ca -c5 -f0 -59 -08 -c5 -f0 -59 -08 -c5 -e8 -59 -cb -c5 -e8 -59 -08 -c5 -e8 -59 -08 -c5 -ec -59 -cb -c5 -ec -59 -08 -c5 -ec -59 -08 -f2 -0f -59 -ca -f2 -0f -59 -08 -f2 -0f -59 -08 -c5 -f3 -59 -ca -c5 -f3 -59 -08 -c5 -f3 -59 -08 -c5 -eb -59 -cb -c5 -eb -59 -08 -c5 -eb -59 -08 -f3 -0f -59 -ca -f3 -0f -59 -08 -f3 -0f -59 -08 -c5 -f2 -59 -ca -c5 -f2 -59 -08 -c5 -f2 -59 -08 -c5 -ea -59 -cb -c5 -ea -59 -08 -c5 -ea -59 -08 -66 -0f -56 -ca -66 -0f -56 -08 -66 -0f -56 -08 -c5 -f1 -56 -ca -c5 -f1 -56 -08 -c5 -f1 -56 -08 -c5 -e9 -56 -cb -c5 -e9 -56 -08 -c5 -e9 -56 -08 -c5 -ed -56 -cb -c5 -ed -56 -08 -c5 -ed -56 -08 -0f -56 -ca -0f -56 -08 -0f -56 -08 -c5 -f0 -56 -ca -c5 -f0 -56 -08 -c5 -f0 -56 -08 -c5 -e8 -56 -cb -c5 -e8 -56 -08 -c5 -e8 -56 -08 -c5 -ec -56 -cb -c5 -ec -56 -08 -c5 -ec -56 -08 -66 -0f -38 -1c -ca -66 -0f -38 -1c -08 -66 -0f -38 -1c -08 -c4 -e2 -79 -1c -ca -c4 -e2 -79 -1c -08 -c4 -e2 -79 -1c -08 -66 -0f -38 -1d -ca -66 -0f -38 -1d -08 -66 -0f -38 -1d -08 -c4 -e2 -79 -1d -ca -c4 -e2 -79 -1d -08 -c4 -e2 -79 -1d -08 -66 -0f -38 -1e -ca -66 -0f -38 -1e -08 -66 -0f -38 -1e -08 -c4 -e2 -79 -1e -ca -c4 -e2 -79 -1e -08 -c4 -e2 -79 -1e -08 -66 -0f -63 -ca -66 -0f -63 -08 -66 -0f -63 -08 -c5 -f1 -63 -ca -c5 -f1 -63 -08 -c5 -f1 -63 -08 -c5 -e9 -63 -cb -c5 -e9 -63 -08 -c5 -e9 -63 -08 -66 -0f -6b -ca -66 -0f -6b -08 -66 -0f -6b -08 -c5 -f1 -6b -ca -c5 -f1 -6b -08 -c5 -f1 -6b -08 -c5 -e9 -6b -cb -c5 -e9 -6b -08 -c5 -e9 -6b -08 -66 -0f -67 -ca -66 -0f -67 -08 -66 -0f -67 -08 -c5 -f1 -67 -ca -c5 -f1 -67 -08 -c5 -f1 -67 -08 -c5 -e9 -67 -cb -c5 -e9 -67 -08 -c5 -e9 -67 -08 -66 -0f -38 -2b -ca -66 -0f -38 -2b -08 -66 -0f -38 -2b -08 -c4 -e2 -71 -2b -ca -c4 -e2 -71 -2b -08 -c4 -e2 -71 -2b -08 -c4 -e2 -69 -2b -cb -c4 -e2 -69 -2b -08 -c4 -e2 -69 -2b -08 -66 -0f -fc -ca -66 -0f -fc -08 -66 -0f -fc -08 -c5 -f1 -fc -ca -c5 -f1 -fc -08 -c5 -f1 -fc -08 -c5 -e9 -fc -cb -c5 -e9 -fc -08 -c5 -e9 -fc -08 -66 -0f -fd -ca -66 -0f -fd -08 -66 -0f -fd -08 -c5 -f1 -fd -ca -c5 -f1 -fd -08 -c5 -f1 -fd -08 -c5 -e9 -fd -cb -c5 -e9 -fd -08 -c5 -e9 -fd -08 -66 -0f -fe -ca -66 -0f -fe -08 -66 -0f -fe -08 -c5 -f1 -fe -ca -c5 -f1 -fe -08 -c5 -f1 -fe -08 -c5 -e9 -fe -cb -c5 -e9 -fe -08 -c5 -e9 -fe -08 -66 -0f -d4 -ca -66 -0f -d4 -08 -66 -0f -d4 -08 -c5 -f1 -d4 -ca -c5 -f1 -d4 -08 -c5 -f1 -d4 -08 -c5 -e9 -d4 -cb -c5 -e9 -d4 -08 -c5 -e9 -d4 -08 -66 -0f -ec -ca -66 -0f -ec -08 -66 -0f -ec -08 -c5 -f1 -ec -ca -c5 -f1 -ec -08 -c5 -f1 -ec -08 -c5 -e9 -ec -cb -c5 -e9 -ec -08 -c5 -e9 -ec -08 -66 -0f -ed -ca -66 -0f -ed -08 -66 -0f -ed -08 -c5 -f1 -ed -ca -c5 -f1 -ed -08 -c5 -f1 -ed -08 -c5 -e9 -ed -cb -c5 -e9 -ed -08 -c5 -e9 -ed -08 -66 -0f -dc -ca -66 -0f -dc -08 -66 -0f -dc -08 -c5 -f1 -dc -ca -c5 -f1 -dc -08 -c5 -f1 -dc -08 -c5 -e9 -dc -cb -c5 -e9 -dc -08 -c5 -e9 -dc -08 -66 -0f -dd -ca -66 -0f -dd -08 -66 -0f -dd -08 -c5 -f1 -dd -ca -c5 -f1 -dd -08 -c5 -f1 -dd -08 -c5 -e9 -dd -cb -c5 -e9 -dd -08 -c5 -e9 -dd -08 -66 -0f -3a -0f -ca -05 -66 -0f -3a -0f -08 -05 -66 -0f -3a -0f -08 -05 -c4 -e3 -71 -0f -ca -05 -c4 -e3 -71 -0f -08 -05 -c4 -e3 -71 -0f -08 -05 -c4 -e3 -69 -0f -cb -05 -c4 -e3 -69 -0f -08 -05 -c4 -e3 -69 -0f -08 -05 -66 -0f -db -ca -66 -0f -db -08 -66 -0f -db -08 -c5 -f1 -db -ca -c5 -f1 -db -08 -c5 -f1 -db -08 -c5 -e9 -db -cb -c5 -e9 -db -08 -c5 -e9 -db -08 -66 -0f -df -ca -66 -0f -df -08 -66 -0f -df -08 -c5 -f1 -df -ca -c5 -f1 -df -08 -c5 -f1 -df -08 -c5 -e9 -df -cb -c5 -e9 -df -08 -c5 -e9 -df -08 -66 -0f -e0 -ca -66 -0f -e0 -08 -66 -0f -e0 -08 -c5 -f1 -e0 -ca -c5 -f1 -e0 -08 -c5 -f1 -e0 -08 -c5 -e9 -e0 -cb -c5 -e9 -e0 -08 -c5 -e9 -e0 -08 -66 -0f -e3 -ca -66 -0f -e3 -08 -66 -0f -e3 -08 -c5 -f1 -e3 -ca -c5 -f1 -e3 -08 -c5 -f1 -e3 -08 -c5 -e9 -e3 -cb -c5 -e9 -e3 -08 -c5 -e9 -e3 -08 -66 -0f -38 -10 -ca -66 -0f -38 -10 -08 -66 -0f -38 -10 -08 -66 -0f -38 -10 -ca -66 -0f -38 -10 -08 -66 -0f -38 -10 -08 -c4 -e3 -69 -4c -cb -40 -c4 -e3 -69 -4c -08 -40 -c4 -e3 -69 -4c -08 -40 -66 -0f -3a -0e -ca -05 -66 -0f -3a -0e -08 -05 -66 -0f -3a -0e -08 -05 -c4 -e3 -71 -0e -ca -05 -c4 -e3 -71 -0e -08 -05 -c4 -e3 -71 -0e -08 -05 -c4 -e3 -69 -0e -cb -05 -c4 -e3 -69 -0e -08 -05 -c4 -e3 -69 -0e -08 -05 -66 -0f -3a -61 -ca -05 -66 -0f -3a -61 -08 -05 -66 -0f -3a -61 -08 -05 -c4 -e3 -79 -61 -ca -05 -c4 -e3 -79 -61 -08 -05 -c4 -e3 -79 -61 -08 -05 -66 -0f -3a -60 -ca -05 -66 -0f -3a -60 -08 -05 -66 -0f -3a -60 -08 -05 -c4 -e3 -79 -60 -ca -05 -c4 -e3 -79 -60 -08 -05 -c4 -e3 -79 -60 -08 -05 -66 -0f -3a -63 -ca -05 -66 -0f -3a -63 -08 -05 -66 -0f -3a -63 -08 -05 -c4 -e3 -79 -63 -ca -05 -c4 -e3 -79 -63 -08 -05 -c4 -e3 -79 -63 -08 -05 -66 -0f -3a -62 -ca -05 -66 -0f -3a -62 -08 -05 -66 -0f -3a -62 -08 -05 -c4 -e3 -79 -62 -ca -05 -c4 -e3 -79 -62 -08 -05 -c4 -e3 -79 -62 -08 -05 -66 -0f -74 -ca -66 -0f -74 -08 -66 -0f -74 -08 -c5 -f1 -74 -ca -c5 -f1 -74 -08 -c5 -f1 -74 -08 -c5 -e9 -74 -cb -c5 -e9 -74 -08 -c5 -e9 -74 -08 -66 -0f -75 -ca -66 -0f -75 -08 -66 -0f -75 -08 -c5 -f1 -75 -ca -c5 -f1 -75 -08 -c5 -f1 -75 -08 -c5 -e9 -75 -cb -c5 -e9 -75 -08 -c5 -e9 -75 -08 -66 -0f -76 -ca -66 -0f -76 -08 -66 -0f -76 -08 -c5 -f1 -76 -ca -c5 -f1 -76 -08 -c5 -f1 -76 -08 -c5 -e9 -76 -cb -c5 -e9 -76 -08 -c5 -e9 -76 -08 -66 -0f -38 -29 -ca -66 -0f -38 -29 -08 -66 -0f -38 -29 -08 -c4 -e2 -71 -29 -ca -c4 -e2 -71 -29 -08 -c4 -e2 -71 -29 -08 -c4 -e2 -69 -29 -cb -c4 -e2 -69 -29 -08 -c4 -e2 -69 -29 -08 -66 -0f -64 -ca -66 -0f -64 -08 -66 -0f -64 -08 -c5 -f1 -64 -ca -c5 -f1 -64 -08 -c5 -f1 -64 -08 -c5 -e9 -64 -cb -c5 -e9 -64 -08 -c5 -e9 -64 -08 -66 -0f -65 -ca -66 -0f -65 -08 -66 -0f -65 -08 -c5 -f1 -65 -ca -c5 -f1 -65 -08 -c5 -f1 -65 -08 -c5 -e9 -65 -cb -c5 -e9 -65 -08 -c5 -e9 -65 -08 -66 -0f -66 -ca -66 -0f -66 -08 -66 -0f -66 -08 -c5 -f1 -66 -ca -c5 -f1 -66 -08 -c5 -f1 -66 -08 -c5 -e9 -66 -cb -c5 -e9 -66 -08 -c5 -e9 -66 -08 -66 -0f -38 -37 -ca -66 -0f -38 -37 -08 -66 -0f -38 -37 -08 -c4 -e2 -71 -37 -ca -c4 -e2 -71 -37 -08 -c4 -e2 -71 -37 -08 -c4 -e2 -69 -37 -cb -c4 -e2 -69 -37 -08 -c4 -e2 -69 -37 -08 -c4 -e2 -69 -0d -cb -c4 -e2 -69 -0d -08 -c4 -e2 -69 -0d -08 -c4 -e2 -6d -0d -cb -c4 -e2 -6d -0d -08 -c4 -e2 -6d -0d -08 -c4 -e3 -79 -05 -08 -05 -c4 -e3 -79 -05 -08 -05 -c4 -e3 -7d -05 -08 -05 -c4 -e3 -7d -05 -08 -05 -c4 -e2 -69 -0c -cb -c4 -e2 -69 -0c -08 -c4 -e2 -69 -0c -08 -c4 -e2 -6d -0c -cb -c4 -e2 -6d -0c -08 -c4 -e2 -6d -0c -08 -c4 -e3 -79 -04 -08 -05 -c4 -e3 -79 -04 -08 -05 -c4 -e3 -7d -04 -08 -05 -c4 -e3 -7d -04 -08 -05 -c4 -e3 -6d -06 -cb -05 -c4 -e3 -6d -06 -08 -05 -c4 -e3 -6d -06 -08 -05 -66 -0f -3a -14 -d0 -05 -66 -0f -3a -14 -d0 -05 -66 -48 -0f -3a -14 -d0 -05 -66 -48 -0f -3a -14 -d0 -05 -66 -0f -3a -14 -10 -05 -66 -0f -3a -14 -10 -05 -c4 -e3 -79 -14 -d0 -05 -c4 -e3 -79 -14 -d0 -05 -c4 -e3 -f9 -14 -d0 -05 -c4 -e3 -f9 -14 -d0 -05 -c4 -e3 -79 -14 -10 -05 -c4 -e3 -79 -14 -10 -05 -66 -0f -c5 -c2 -05 -66 -0f -c5 -c2 -05 -66 -48 -0f -c5 -c2 -05 -66 -48 -0f -c5 -c2 -05 -66 -0f -3a -15 -10 -05 -66 -0f -3a -15 -10 -05 -c5 -f9 -c5 -c2 -05 -c5 -f9 -c5 -c2 -05 -c4 -e1 -f9 -c5 -c2 -05 -c4 -e1 -f9 -c5 -c2 -05 -c4 -e3 -79 -15 -10 -05 -c4 -e3 -79 -15 -10 -05 -66 -0f -3a -16 -d0 -05 -66 -0f -3a -16 -d0 -05 -66 -0f -3a -16 -10 -05 -66 -0f -3a -16 -10 -05 -c4 -e3 -79 -16 -d0 -05 -c4 -e3 -79 -16 -d0 -05 -c4 -e3 -79 -16 -10 -05 -c4 -e3 -79 -16 -10 -05 -66 -48 -0f -3a -16 -d0 -05 -66 -48 -0f -3a -16 -d0 -05 -66 -48 -0f -3a -16 -10 -05 -66 -48 -0f -3a -16 -10 -05 -c4 -e3 -f9 -16 -d0 -05 -c4 -e3 -f9 -16 -d0 -05 -c4 -e3 -f9 -16 -10 -05 -c4 -e3 -f9 -16 -10 -05 -66 -0f -38 -01 -ca -66 -0f -38 -01 -08 -66 -0f -38 -01 -08 -c4 -e2 -71 -01 -ca -c4 -e2 -71 -01 -08 -c4 -e2 -71 -01 -08 -c4 -e2 -69 -01 -cb -c4 -e2 -69 -01 -08 -c4 -e2 -69 -01 -08 -66 -0f -38 -02 -ca -66 -0f -38 -02 -08 -66 -0f -38 -02 -08 -c4 -e2 -71 -02 -ca -c4 -e2 -71 -02 -08 -c4 -e2 -71 -02 -08 -c4 -e2 -69 -02 -cb -c4 -e2 -69 -02 -08 -c4 -e2 -69 -02 -08 -66 -0f -38 -03 -ca -66 -0f -38 -03 -08 -66 -0f -38 -03 -08 -c4 -e2 -71 -03 -ca -c4 -e2 -71 -03 -08 -c4 -e2 -71 -03 -08 -c4 -e2 -69 -03 -cb -c4 -e2 -69 -03 -08 -c4 -e2 -69 -03 -08 -66 -0f -38 -41 -ca -66 -0f -38 -41 -08 -66 -0f -38 -41 -08 -c4 -e2 -79 -41 -ca -c4 -e2 -79 -41 -08 -c4 -e2 -79 -41 -08 -66 -0f -38 -05 -ca -66 -0f -38 -05 -08 -66 -0f -38 -05 -08 -c4 -e2 -71 -05 -ca -c4 -e2 -71 -05 -08 -c4 -e2 -71 -05 -08 -c4 -e2 -69 -05 -cb -c4 -e2 -69 -05 -08 -c4 -e2 -69 -05 -08 -66 -0f -38 -06 -ca -66 -0f -38 -06 -08 -66 -0f -38 -06 -08 -c4 -e2 -71 -06 -ca -c4 -e2 -71 -06 -08 -c4 -e2 -71 -06 -08 -c4 -e2 -69 -06 -cb -c4 -e2 -69 -06 -08 -c4 -e2 -69 -06 -08 -66 -0f -38 -07 -ca -66 -0f -38 -07 -08 -66 -0f -38 -07 -08 -c4 -e2 -71 -07 -ca -c4 -e2 -71 -07 -08 -c4 -e2 -71 -07 -08 -c4 -e2 -69 -07 -cb -c4 -e2 -69 -07 -08 -c4 -e2 -69 -07 -08 -66 -0f -3a -20 -c8 -05 -66 -0f -3a -20 -08 -05 -66 -0f -3a -20 -08 -05 -c4 -e3 -71 -20 -c8 -05 -c4 -e3 -71 -20 -08 -05 -c4 -e3 -71 -20 -08 -05 -c4 -e3 -69 -20 -c8 -05 -c4 -e3 -69 -20 -08 -05 -c4 -e3 -69 -20 -08 -05 -66 -0f -c4 -c8 -05 -66 -0f -c4 -08 -05 -66 -0f -c4 -08 -05 -c5 -f1 -c4 -c8 -05 -c5 -f1 -c4 -08 -05 -c5 -f1 -c4 -08 -05 -c5 -e9 -c4 -c8 -05 -c5 -e9 -c4 -08 -05 -c5 -e9 -c4 -08 -05 -66 -0f -3a -22 -c8 -05 -66 -0f -3a -22 -08 -05 -66 -0f -3a -22 -08 -05 -c4 -e3 -71 -22 -c8 -05 -c4 -e3 -71 -22 -08 -05 -c4 -e3 -71 -22 -08 -05 -c4 -e3 -69 -22 -c8 -05 -c4 -e3 -69 -22 -08 -05 -c4 -e3 -69 -22 -08 -05 -66 -48 -0f -3a -22 -c8 -05 -66 -48 -0f -3a -22 -08 -05 -66 -48 -0f -3a -22 -08 -05 -c4 -e3 -f1 -22 -c8 -05 -c4 -e3 -f1 -22 -08 -05 -c4 -e3 -f1 -22 -08 -05 -c4 -e3 -e9 -22 -c8 -05 -c4 -e3 -e9 -22 -08 -05 -c4 -e3 -e9 -22 -08 -05 -66 -0f -f5 -ca -66 -0f -f5 -08 -66 -0f -f5 -08 -c5 -f1 -f5 -ca -c5 -f1 -f5 -08 -c5 -f1 -f5 -08 -c5 -e9 -f5 -cb -c5 -e9 -f5 -08 -c5 -e9 -f5 -08 -66 -0f -38 -04 -ca -66 -0f -38 -04 -08 -66 -0f -38 -04 -08 -c4 -e2 -71 -04 -ca -c4 -e2 -71 -04 -08 -c4 -e2 -71 -04 -08 -c4 -e2 -69 -04 -cb -c4 -e2 -69 -04 -08 -c4 -e2 -69 -04 -08 -66 -0f -38 -3c -ca -66 -0f -38 -3c -08 -66 -0f -38 -3c -08 -c4 -e2 -71 -3c -ca -c4 -e2 -71 -3c -08 -c4 -e2 -71 -3c -08 -c4 -e2 -69 -3c -cb -c4 -e2 -69 -3c -08 -c4 -e2 -69 -3c -08 -66 -0f -ee -ca -66 -0f -ee -08 -66 -0f -ee -08 -c5 -f1 -ee -ca -c5 -f1 -ee -08 -c5 -f1 -ee -08 -c5 -e9 -ee -cb -c5 -e9 -ee -08 -c5 -e9 -ee -08 -66 -0f -38 -3d -ca -66 -0f -38 -3d -08 -66 -0f -38 -3d -08 -c4 -e2 -71 -3d -ca -c4 -e2 -71 -3d -08 -c4 -e2 -71 -3d -08 -c4 -e2 -69 -3d -cb -c4 -e2 -69 -3d -08 -c4 -e2 -69 -3d -08 -66 -0f -de -ca -66 -0f -de -08 -66 -0f -de -08 -c5 -f1 -de -ca -c5 -f1 -de -08 -c5 -f1 -de -08 -c5 -e9 -de -cb -c5 -e9 -de -08 -c5 -e9 -de -08 -66 -0f -38 -3e -ca -66 -0f -38 -3e -08 -66 -0f -38 -3e -08 -c4 -e2 -71 -3e -ca -c4 -e2 -71 -3e -08 -c4 -e2 -71 -3e -08 -c4 -e2 -69 -3e -cb -c4 -e2 -69 -3e -08 -c4 -e2 -69 -3e -08 -66 -0f -38 -3f -ca -66 -0f -38 -3f -08 -66 -0f -38 -3f -08 -c4 -e2 -71 -3f -ca -c4 -e2 -71 -3f -08 -c4 -e2 -71 -3f -08 -c4 -e2 -69 -3f -cb -c4 -e2 -69 -3f -08 -c4 -e2 -69 -3f -08 -66 -0f -38 -38 -ca -66 -0f -38 -38 -08 -66 -0f -38 -38 -08 -c4 -e2 -71 -38 -ca -c4 -e2 -71 -38 -08 -c4 -e2 -71 -38 -08 -c4 -e2 -69 -38 -cb -c4 -e2 -69 -38 -08 -c4 -e2 -69 -38 -08 -66 -0f -ea -ca -66 -0f -ea -08 -66 -0f -ea -08 -c5 -f1 -ea -ca -c5 -f1 -ea -08 -c5 -f1 -ea -08 -c5 -e9 -ea -cb -c5 -e9 -ea -08 -c5 -e9 -ea -08 -66 -0f -38 -39 -ca -66 -0f -38 -39 -08 -66 -0f -38 -39 -08 -c4 -e2 -71 -39 -ca -c4 -e2 -71 -39 -08 -c4 -e2 -71 -39 -08 -c4 -e2 -69 -39 -cb -c4 -e2 -69 -39 -08 -c4 -e2 -69 -39 -08 -66 -0f -da -ca -66 -0f -da -08 -66 -0f -da -08 -c5 -f1 -da -ca -c5 -f1 -da -08 -c5 -f1 -da -08 -c5 -e9 -da -cb -c5 -e9 -da -08 -c5 -e9 -da -08 -66 -0f -38 -3a -ca -66 -0f -38 -3a -08 -66 -0f -38 -3a -08 -c4 -e2 -71 -3a -ca -c4 -e2 -71 -3a -08 -c4 -e2 -71 -3a -08 -c4 -e2 -69 -3a -cb -c4 -e2 -69 -3a -08 -c4 -e2 -69 -3a -08 -66 -0f -38 -3b -ca -66 -0f -38 -3b -08 -66 -0f -38 -3b -08 -c4 -e2 -71 -3b -ca -c4 -e2 -71 -3b -08 -c4 -e2 -71 -3b -08 -c4 -e2 -69 -3b -cb -c4 -e2 -69 -3b -08 -c4 -e2 -69 -3b -08 -66 -0f -d7 -c1 -66 -0f -d7 -c1 -c5 -f9 -d7 -c1 -c5 -f9 -d7 -c1 -66 -0f -38 -20 -ca -66 -0f -38 -20 -08 -66 -0f -38 -20 -08 -c4 -e2 -79 -20 -ca -c4 -e2 -79 -20 -08 -c4 -e2 -79 -20 -08 -66 -0f -38 -21 -ca -66 -0f -38 -21 -08 -66 -0f -38 -21 -08 -c4 -e2 -79 -21 -ca -c4 -e2 -79 -21 -08 -c4 -e2 -79 -21 -08 -66 -0f -38 -22 -ca -66 -0f -38 -22 -08 -66 -0f -38 -22 -08 -c4 -e2 -79 -22 -ca -c4 -e2 -79 -22 -08 -c4 -e2 -79 -22 -08 -66 -0f -38 -23 -ca -66 -0f -38 -23 -08 -66 -0f -38 -23 -08 -c4 -e2 -79 -23 -ca -c4 -e2 -79 -23 -08 -c4 -e2 -79 -23 -08 -66 -0f -38 -24 -ca -66 -0f -38 -24 -08 -66 -0f -38 -24 -08 -c4 -e2 -79 -24 -ca -c4 -e2 -79 -24 -08 -c4 -e2 -79 -24 -08 -66 -0f -38 -25 -ca -66 -0f -38 -25 -08 -66 -0f -38 -25 -08 -c4 -e2 -79 -25 -ca -c4 -e2 -79 -25 -08 -c4 -e2 -79 -25 -08 -66 -0f -38 -30 -ca -66 -0f -38 -30 -08 -66 -0f -38 -30 -08 -c4 -e2 -79 -30 -ca -c4 -e2 -79 -30 -08 -c4 -e2 -79 -30 -08 -66 -0f -38 -31 -ca -66 -0f -38 -31 -08 -66 -0f -38 -31 -08 -c4 -e2 -79 -31 -ca -c4 -e2 -79 -31 -08 -c4 -e2 -79 -31 -08 -66 -0f -38 -32 -ca -66 -0f -38 -32 -08 -66 -0f -38 -32 -08 -c4 -e2 -79 -32 -ca -c4 -e2 -79 -32 -08 -c4 -e2 -79 -32 -08 -66 -0f -38 -33 -ca -66 -0f -38 -33 -08 -66 -0f -38 -33 -08 -c4 -e2 -79 -33 -ca -c4 -e2 -79 -33 -08 -c4 -e2 -79 -33 -08 -66 -0f -38 -34 -ca -66 -0f -38 -34 -08 -66 -0f -38 -34 -08 -c4 -e2 -79 -34 -ca -c4 -e2 -79 -34 -08 -c4 -e2 -79 -34 -08 -66 -0f -38 -35 -ca -66 -0f -38 -35 -08 -66 -0f -38 -35 -08 -c4 -e2 -79 -35 -ca -c4 -e2 -79 -35 -08 -c4 -e2 -79 -35 -08 -66 -0f -e4 -ca -66 -0f -e4 -08 -66 -0f -e4 -08 -c5 -f1 -e4 -ca -c5 -f1 -e4 -08 -c5 -f1 -e4 -08 -c5 -e9 -e4 -cb -c5 -e9 -e4 -08 -c5 -e9 -e4 -08 -66 -0f -38 -0b -ca -66 -0f -38 -0b -08 -66 -0f -38 -0b -08 -c4 -e2 -71 -0b -ca -c4 -e2 -71 -0b -08 -c4 -e2 -71 -0b -08 -c4 -e2 -69 -0b -cb -c4 -e2 -69 -0b -08 -c4 -e2 -69 -0b -08 -66 -0f -e5 -ca -66 -0f -e5 -08 -66 -0f -e5 -08 -c5 -f1 -e5 -ca -c5 -f1 -e5 -08 -c5 -f1 -e5 -08 -c5 -e9 -e5 -cb -c5 -e9 -e5 -08 -c5 -e9 -e5 -08 -66 -0f -d5 -ca -66 -0f -d5 -08 -66 -0f -d5 -08 -c5 -f1 -d5 -ca -c5 -f1 -d5 -08 -c5 -f1 -d5 -08 -c5 -e9 -d5 -cb -c5 -e9 -d5 -08 -c5 -e9 -d5 -08 -66 -0f -38 -40 -ca -66 -0f -38 -40 -08 -66 -0f -38 -40 -08 -c4 -e2 -71 -40 -ca -c4 -e2 -71 -40 -08 -c4 -e2 -71 -40 -08 -c4 -e2 -69 -40 -cb -c4 -e2 -69 -40 -08 -c4 -e2 -69 -40 -08 -66 -0f -f4 -ca -66 -0f -f4 -08 -66 -0f -f4 -08 -c5 -f1 -f4 -ca -c5 -f1 -f4 -08 -c5 -f1 -f4 -08 -c5 -e9 -f4 -cb -c5 -e9 -f4 -08 -c5 -e9 -f4 -08 -66 -0f -38 -28 -ca -66 -0f -38 -28 -08 -66 -0f -38 -28 -08 -c4 -e2 -71 -28 -ca -c4 -e2 -71 -28 -08 -c4 -e2 -71 -28 -08 -c4 -e2 -69 -28 -cb -c4 -e2 -69 -28 -08 -c4 -e2 -69 -28 -08 -66 -0f -eb -ca -66 -0f -eb -08 -66 -0f -eb -08 -c5 -f1 -eb -ca -c5 -f1 -eb -08 -c5 -f1 -eb -08 -c5 -e9 -eb -cb -c5 -e9 -eb -08 -c5 -e9 -eb -08 -66 -0f -f6 -ca -66 -0f -f6 -08 -66 -0f -f6 -08 -c5 -f1 -f6 -ca -c5 -f1 -f6 -08 -c5 -f1 -f6 -08 -c5 -e9 -f6 -cb -c5 -e9 -f6 -08 -c5 -e9 -f6 -08 -66 -0f -38 -00 -ca -66 -0f -38 -00 -08 -66 -0f -38 -00 -08 -c4 -e2 -71 -00 -ca -c4 -e2 -71 -00 -08 -c4 -e2 -71 -00 -08 -c4 -e2 -69 -00 -cb -c4 -e2 -69 -00 -08 -c4 -e2 -69 -00 -08 -66 -0f -70 -ca -05 -66 -0f -70 -08 -05 -66 -0f -70 -08 -05 -c5 -f9 -70 -ca -05 -c5 -f9 -70 -08 -05 -c5 -f9 -70 -08 -05 -f3 -0f -70 -ca -05 -f3 -0f -70 -08 -05 -f3 -0f -70 -08 -05 -c5 -fa -70 -ca -05 -c5 -fa -70 -08 -05 -c5 -fa -70 -08 -05 -f2 -0f -70 -ca -05 -f2 -0f -70 -08 -05 -f2 -0f -70 -08 -05 -c5 -fb -70 -ca -05 -c5 -fb -70 -08 -05 -c5 -fb -70 -08 -05 -66 -0f -38 -08 -ca -66 -0f -38 -08 -08 -66 -0f -38 -08 -08 -c4 -e2 -71 -08 -ca -c4 -e2 -71 -08 -08 -c4 -e2 -71 -08 -08 -c4 -e2 -69 -08 -cb -c4 -e2 -69 -08 -08 -c4 -e2 -69 -08 -08 -66 -0f -38 -09 -ca -66 -0f -38 -09 -08 -66 -0f -38 -09 -08 -c4 -e2 -71 -09 -ca -c4 -e2 -71 -09 -08 -c4 -e2 -71 -09 -08 -c4 -e2 -69 -09 -cb -c4 -e2 -69 -09 -08 -c4 -e2 -69 -09 -08 -66 -0f -38 -0a -ca -66 -0f -38 -0a -08 -66 -0f -38 -0a -08 -c4 -e2 -71 -0a -ca -c4 -e2 -71 -0a -08 -c4 -e2 -71 -0a -08 -c4 -e2 -69 -0a -cb -c4 -e2 -69 -0a -08 -c4 -e2 -69 -0a -08 -66 -41 -0f -73 -fb -05 -66 -41 -0f -73 -fb -05 -c4 -c1 -21 -73 -fb -05 -c4 -c1 -21 -73 -fb -05 -c4 -c1 -21 -73 -fc -05 -c4 -c1 -21 -73 -fc -05 -66 -0f -73 -f9 -05 -66 -0f -73 -f9 -05 -c5 -f1 -73 -f9 -05 -c5 -f1 -73 -f9 -05 -c5 -f1 -73 -fa -05 -c5 -f1 -73 -fa -05 -66 -0f -73 -d9 -05 -66 -0f -73 -d9 -05 -c5 -f1 -73 -d9 -05 -c5 -f1 -73 -d9 -05 -c5 -f1 -73 -da -05 -c5 -f1 -73 -da -05 -66 -0f -f1 -ca -66 -0f -f1 -08 -66 -0f -f1 -08 -c5 -f1 -f1 -ca -c5 -f1 -f1 -08 -c5 -f1 -f1 -08 -c5 -e9 -f1 -cb -c5 -e9 -f1 -08 -c5 -e9 -f1 -08 -66 -0f -71 -f1 -05 -66 -0f -71 -f1 -05 -c5 -f1 -71 -f1 -05 -c5 -f1 -71 -f1 -05 -c5 -f1 -71 -f2 -05 -c5 -f1 -71 -f2 -05 -66 -0f -f2 -ca -66 -0f -f2 -08 -66 -0f -f2 -08 -c5 -f1 -f2 -ca -c5 -f1 -f2 -08 -c5 -f1 -f2 -08 -c5 -e9 -f2 -cb -c5 -e9 -f2 -08 -c5 -e9 -f2 -08 -66 -0f -72 -f1 -05 -66 -0f -72 -f1 -05 -c5 -f1 -72 -f1 -05 -c5 -f1 -72 -f1 -05 -c5 -f1 -72 -f2 -05 -c5 -f1 -72 -f2 -05 -66 -0f -f3 -ca -66 -0f -f3 -08 -66 -0f -f3 -08 -c5 -f1 -f3 -ca -c5 -f1 -f3 -08 -c5 -f1 -f3 -08 -c5 -e9 -f3 -cb -c5 -e9 -f3 -08 -c5 -e9 -f3 -08 -66 -0f -73 -f1 -05 -66 -0f -73 -f1 -05 -c5 -f1 -73 -f1 -05 -c5 -f1 -73 -f1 -05 -c5 -f1 -73 -f2 -05 -c5 -f1 -73 -f2 -05 -66 -0f -e1 -ca -66 -0f -e1 -08 -66 -0f -e1 -08 -c5 -f1 -e1 -ca -c5 -f1 -e1 -08 -c5 -f1 -e1 -08 -c5 -e9 -e1 -cb -c5 -e9 -e1 -08 -c5 -e9 -e1 -08 -66 -0f -71 -e1 -05 -66 -0f -71 -e1 -05 -c5 -f1 -71 -e1 -05 -c5 -f1 -71 -e1 -05 -c5 -f1 -71 -e2 -05 -c5 -f1 -71 -e2 -05 -66 -0f -e2 -ca -66 -0f -e2 -08 -66 -0f -e2 -08 -c5 -f1 -e2 -ca -c5 -f1 -e2 -08 -c5 -f1 -e2 -08 -c5 -e9 -e2 -cb -c5 -e9 -e2 -08 -c5 -e9 -e2 -08 -66 -0f -72 -e1 -05 -66 -0f -72 -e1 -05 -c5 -f1 -72 -e1 -05 -c5 -f1 -72 -e1 -05 -c5 -f1 -72 -e2 -05 -c5 -f1 -72 -e2 -05 -66 -0f -d1 -ca -66 -0f -d1 -08 -66 -0f -d1 -08 -c5 -f1 -d1 -ca -c5 -f1 -d1 -08 -c5 -f1 -d1 -08 -c5 -e9 -d1 -cb -c5 -e9 -d1 -08 -c5 -e9 -d1 -08 -66 -0f -71 -d1 -05 -66 -0f -71 -d1 -05 -c5 -f1 -71 -d1 -05 -c5 -f1 -71 -d1 -05 -c5 -f1 -71 -d2 -05 -c5 -f1 -71 -d2 -05 -66 -0f -d2 -ca -66 -0f -d2 -08 -66 -0f -d2 -08 -c5 -f1 -d2 -ca -c5 -f1 -d2 -08 -c5 -f1 -d2 -08 -c5 -e9 -d2 -cb -c5 -e9 -d2 -08 -c5 -e9 -d2 -08 -66 -0f -72 -d1 -05 -66 -0f -72 -d1 -05 -c5 -f1 -72 -d1 -05 -c5 -f1 -72 -d1 -05 -c5 -f1 -72 -d2 -05 -c5 -f1 -72 -d2 -05 -66 -0f -d3 -ca -66 -0f -d3 -08 -66 -0f -d3 -08 -c5 -f1 -d3 -ca -c5 -f1 -d3 -08 -c5 -f1 -d3 -08 -c5 -e9 -d3 -cb -c5 -e9 -d3 -08 -c5 -e9 -d3 -08 -66 -0f -73 -d1 -05 -66 -0f -73 -d1 -05 -c5 -f1 -73 -d1 -05 -c5 -f1 -73 -d1 -05 -c5 -f1 -73 -d2 -05 -c5 -f1 -73 -d2 -05 -66 -0f -38 -17 -ca -66 -0f -38 -17 -08 -66 -0f -38 -17 -08 -c4 -e2 -79 -17 -ca -c4 -e2 -79 -17 -08 -c4 -e2 -79 -17 -08 -c4 -e2 -7d -17 -ca -c4 -e2 -7d -17 -08 -c4 -e2 -7d -17 -08 -c4 -e2 -79 -0e -ca -c4 -e2 -79 -0e -08 -c4 -e2 -79 -0e -08 -c4 -e2 -7d -0e -ca -c4 -e2 -7d -0e -08 -c4 -e2 -7d -0e -08 -c4 -e2 -79 -0f -ca -c4 -e2 -79 -0f -08 -c4 -e2 -79 -0f -08 -c4 -e2 -7d -0f -ca -c4 -e2 -7d -0f -08 -c4 -e2 -7d -0f -08 -66 -0f -f8 -ca -66 -0f -f8 -08 -66 -0f -f8 -08 -c5 -f1 -f8 -ca -c5 -f1 -f8 -08 -c5 -f1 -f8 -08 -c5 -e9 -f8 -cb -c5 -e9 -f8 -08 -c5 -e9 -f8 -08 -66 -0f -f9 -ca -66 -0f -f9 -08 -66 -0f -f9 -08 -c5 -f1 -f9 -ca -c5 -f1 -f9 -08 -c5 -f1 -f9 -08 -c5 -e9 -f9 -cb -c5 -e9 -f9 -08 -c5 -e9 -f9 -08 -66 -0f -fa -ca -66 -0f -fa -08 -66 -0f -fa -08 -c5 -f1 -fa -ca -c5 -f1 -fa -08 -c5 -f1 -fa -08 -c5 -e9 -fa -cb -c5 -e9 -fa -08 -c5 -e9 -fa -08 -66 -0f -fb -ca -66 -0f -fb -08 -66 -0f -fb -08 -c5 -f1 -fb -ca -c5 -f1 -fb -08 -c5 -f1 -fb -08 -c5 -e9 -fb -cb -c5 -e9 -fb -08 -c5 -e9 -fb -08 -66 -0f -e8 -ca -66 -0f -e8 -08 -66 -0f -e8 -08 -c5 -f1 -e8 -ca -c5 -f1 -e8 -08 -c5 -f1 -e8 -08 -c5 -e9 -e8 -cb -c5 -e9 -e8 -08 -c5 -e9 -e8 -08 -66 -0f -e9 -ca -66 -0f -e9 -08 -66 -0f -e9 -08 -c5 -f1 -e9 -ca -c5 -f1 -e9 -08 -c5 -f1 -e9 -08 -c5 -e9 -e9 -cb -c5 -e9 -e9 -08 -c5 -e9 -e9 -08 -66 -0f -d8 -ca -66 -0f -d8 -08 -66 -0f -d8 -08 -c5 -f1 -d8 -ca -c5 -f1 -d8 -08 -c5 -f1 -d8 -08 -c5 -e9 -d8 -cb -c5 -e9 -d8 -08 -c5 -e9 -d8 -08 -66 -0f -d9 -ca -66 -0f -d9 -08 -66 -0f -d9 -08 -c5 -f1 -d9 -ca -c5 -f1 -d9 -08 -c5 -f1 -d9 -08 -c5 -e9 -d9 -cb -c5 -e9 -d9 -08 -c5 -e9 -d9 -08 -66 -0f -68 -ca -66 -0f -68 -08 -66 -0f -68 -08 -c5 -f1 -68 -ca -c5 -f1 -68 -08 -c5 -f1 -68 -08 -c5 -e9 -68 -cb -c5 -e9 -68 -08 -c5 -e9 -68 -08 -66 -0f -69 -ca -66 -0f -69 -08 -66 -0f -69 -08 -c5 -f1 -69 -ca -c5 -f1 -69 -08 -c5 -f1 -69 -08 -c5 -e9 -69 -cb -c5 -e9 -69 -08 -c5 -e9 -69 -08 -66 -0f -6a -ca -66 -0f -6a -08 -66 -0f -6a -08 -c5 -f1 -6a -ca -c5 -f1 -6a -08 -c5 -f1 -6a -08 -c5 -e9 -6a -cb -c5 -e9 -6a -08 -c5 -e9 -6a -08 -66 -0f -6d -ca -66 -0f -6d -08 -66 -0f -6d -08 -c5 -f1 -6d -ca -c5 -f1 -6d -08 -c5 -f1 -6d -08 -c5 -e9 -6d -cb -c5 -e9 -6d -08 -c5 -e9 -6d -08 -66 -0f -60 -ca -66 -0f -60 -08 -66 -0f -60 -08 -c5 -f1 -60 -ca -c5 -f1 -60 -08 -c5 -f1 -60 -08 -c5 -e9 -60 -cb -c5 -e9 -60 -08 -c5 -e9 -60 -08 -66 -0f -61 -ca -66 -0f -61 -08 -66 -0f -61 -08 -c5 -f1 -61 -ca -c5 -f1 -61 -08 -c5 -f1 -61 -08 -c5 -e9 -61 -cb -c5 -e9 -61 -08 -c5 -e9 -61 -08 -66 -0f -62 -ca -66 -0f -62 -08 -66 -0f -62 -08 -c5 -f1 -62 -ca -c5 -f1 -62 -08 -c5 -f1 -62 -08 -c5 -e9 -62 -cb -c5 -e9 -62 -08 -c5 -e9 -62 -08 -66 -0f -6c -ca -66 -0f -6c -08 -66 -0f -6c -08 -c5 -f1 -6c -ca -c5 -f1 -6c -08 -c5 -f1 -6c -08 -c5 -e9 -6c -cb -c5 -e9 -6c -08 -c5 -e9 -6c -08 -66 -0f -ef -ca -66 -0f -ef -08 -66 -0f -ef -08 -c5 -f1 -ef -ca -c5 -f1 -ef -08 -c5 -f1 -ef -08 -c5 -e9 -ef -cb -c5 -e9 -ef -08 -c5 -e9 -ef -08 -0f -53 -ca -0f -53 -08 -0f -53 -08 -c5 -f8 -53 -ca -c5 -f8 -53 -08 -c5 -f8 -53 -08 -c5 -fc -53 -ca -c5 -fc -53 -08 -c5 -fc -53 -08 -f3 -0f -53 -ca -f3 -0f -53 -08 -f3 -0f -53 -08 -c5 -f2 -53 -ca -c5 -f2 -53 -08 -c5 -f2 -53 -08 -c5 -ea -53 -cb -c5 -ea -53 -08 -c5 -ea -53 -08 -0f -52 -ca -0f -52 -08 -0f -52 -08 -c5 -f8 -52 -ca -c5 -f8 -52 -08 -c5 -f8 -52 -08 -c5 -fc -52 -ca -c5 -fc -52 -08 -c5 -fc -52 -08 -f3 -0f -52 -ca -f3 -0f -52 -08 -f3 -0f -52 -08 -c5 -f2 -52 -ca -c5 -f2 -52 -08 -c5 -f2 -52 -08 -c5 -ea -52 -cb -c5 -ea -52 -08 -c5 -ea -52 -08 -66 -0f -3a -09 -ca -05 -66 -0f -3a -09 -08 -05 -66 -0f -3a -09 -08 -05 -c4 -e3 -79 -09 -ca -05 -c4 -e3 -79 -09 -08 -05 -c4 -e3 -79 -09 -08 -05 -c4 -e3 -7d -09 -ca -05 -c4 -e3 -7d -09 -08 -05 -c4 -e3 -7d -09 -08 -05 -66 -0f -3a -08 -ca -05 -66 -0f -3a -08 -08 -05 -66 -0f -3a -08 -08 -05 -c4 -e3 -79 -08 -ca -05 -c4 -e3 -79 -08 -08 -05 -c4 -e3 -79 -08 -08 -05 -c4 -e3 -7d -08 -ca -05 -c4 -e3 -7d -08 -08 -05 -c4 -e3 -7d -08 -08 -05 -66 -0f -3a -0b -ca -05 -66 -0f -3a -0b -08 -05 -66 -0f -3a -0b -08 -05 -c4 -e3 -71 -0b -ca -05 -c4 -e3 -71 -0b -08 -05 -c4 -e3 -71 -0b -08 -05 -c4 -e3 -69 -0b -cb -05 -c4 -e3 -69 -0b -08 -05 -c4 -e3 -69 -0b -08 -05 -66 -0f -3a -0a -ca -05 -66 -0f -3a -0a -08 -05 -66 -0f -3a -0a -08 -05 -c4 -e3 -71 -0a -ca -05 -c4 -e3 -71 -0a -08 -05 -c4 -e3 -71 -0a -08 -05 -c4 -e3 -69 -0a -cb -05 -c4 -e3 -69 -0a -08 -05 -c4 -e3 -69 -0a -08 -05 -66 -0f -c6 -ca -05 -66 -0f -c6 -08 -05 -66 -0f -c6 -08 -05 -c5 -f1 -c6 -ca -05 -c5 -f1 -c6 -08 -05 -c5 -f1 -c6 -08 -05 -c5 -e9 -c6 -cb -05 -c5 -e9 -c6 -08 -05 -c5 -e9 -c6 -08 -05 -c5 -ed -c6 -cb -05 -c5 -ed -c6 -08 -05 -c5 -ed -c6 -08 -05 -0f -c6 -ca -05 -0f -c6 -08 -05 -0f -c6 -08 -05 -c5 -f0 -c6 -ca -05 -c5 -f0 -c6 -08 -05 -c5 -f0 -c6 -08 -05 -c5 -e8 -c6 -cb -05 -c5 -e8 -c6 -08 -05 -c5 -e8 -c6 -08 -05 -c5 -ec -c6 -cb -05 -c5 -ec -c6 -08 -05 -c5 -ec -c6 -08 -05 -66 -0f -51 -ca -66 -0f -51 -08 -66 -0f -51 -08 -c5 -f9 -51 -ca -c5 -f9 -51 -08 -c5 -f9 -51 -08 -c5 -fd -51 -ca -c5 -fd -51 -08 -c5 -fd -51 -08 -0f -51 -ca -0f -51 -08 -0f -51 -08 -c5 -f8 -51 -ca -c5 -f8 -51 -08 -c5 -f8 -51 -08 -c5 -fc -51 -ca -c5 -fc -51 -08 -c5 -fc -51 -08 -f2 -0f -51 -ca -f2 -0f -51 -08 -f2 -0f -51 -08 -c5 -f3 -51 -ca -c5 -f3 -51 -08 -c5 -f3 -51 -08 -c5 -eb -51 -cb -c5 -eb -51 -08 -c5 -eb -51 -08 -f3 -0f -51 -ca -f3 -0f -51 -08 -f3 -0f -51 -08 -c5 -f2 -51 -ca -c5 -f2 -51 -08 -c5 -f2 -51 -08 -c5 -ea -51 -cb -c5 -ea -51 -08 -c5 -ea -51 -08 -0f -ae -18 -0f -ae -18 -c5 -f8 -ae -18 -c5 -f8 -ae -18 -66 -0f -5c -ca -66 -0f -5c -08 -66 -0f -5c -08 -c5 -f1 -5c -ca -c5 -f1 -5c -08 -c5 -f1 -5c -08 -c5 -e9 -5c -cb -c5 -e9 -5c -08 -c5 -e9 -5c -08 -c5 -ed -5c -cb -c5 -ed -5c -08 -c5 -ed -5c -08 -0f -5c -ca -0f -5c -08 -0f -5c -08 -c5 -f0 -5c -ca -c5 -f0 -5c -08 -c5 -f0 -5c -08 -c5 -e8 -5c -cb -c5 -e8 -5c -08 -c5 -e8 -5c -08 -c5 -ec -5c -cb -c5 -ec -5c -08 -c5 -ec -5c -08 -f2 -0f -5c -ca -f2 -0f -5c -08 -f2 -0f -5c -08 -c5 -f3 -5c -ca -c5 -f3 -5c -08 -c5 -f3 -5c -08 -c5 -eb -5c -cb -c5 -eb -5c -08 -c5 -eb -5c -08 -f3 -0f -5c -ca -f3 -0f -5c -08 -f3 -0f -5c -08 -c5 -f2 -5c -ca -c5 -f2 -5c -08 -c5 -f2 -5c -08 -c5 -ea -5c -cb -c5 -ea -5c -08 -c5 -ea -5c -08 -66 -0f -2e -ca -66 -0f -2e -08 -66 -0f -2e -08 -c5 -f9 -2e -ca -c5 -f9 -2e -08 -c5 -f9 -2e -08 -0f -2e -ca -0f -2e -08 -0f -2e -08 -c5 -f8 -2e -ca -c5 -f8 -2e -08 -c5 -f8 -2e -08 -66 -0f -15 -ca -66 -0f -15 -08 -66 -0f -15 -08 -c5 -f1 -15 -ca -c5 -f1 -15 -08 -c5 -f1 -15 -08 -c5 -e9 -15 -cb -c5 -e9 -15 -08 -c5 -e9 -15 -08 -c5 -ed -15 -cb -c5 -ed -15 -08 -c5 -ed -15 -08 -0f -15 -ca -0f -15 -08 -0f -15 -08 -c5 -f0 -15 -ca -c5 -f0 -15 -08 -c5 -f0 -15 -08 -c5 -e8 -15 -cb -c5 -e8 -15 -08 -c5 -e8 -15 -08 -c5 -ec -15 -cb -c5 -ec -15 -08 -c5 -ec -15 -08 -66 -0f -14 -ca -66 -0f -14 -08 -66 -0f -14 -08 -c5 -f1 -14 -ca -c5 -f1 -14 -08 -c5 -f1 -14 -08 -c5 -e9 -14 -cb -c5 -e9 -14 -08 -c5 -e9 -14 -08 -c5 -ed -14 -cb -c5 -ed -14 -08 -c5 -ed -14 -08 -0f -14 -ca -0f -14 -08 -0f -14 -08 -c5 -f0 -14 -ca -c5 -f0 -14 -08 -c5 -f0 -14 -08 -c5 -e8 -14 -cb -c5 -e8 -14 -08 -c5 -e8 -14 -08 -c5 -ec -14 -cb -c5 -ec -14 -08 -c5 -ec -14 -08 -66 -0f -57 -ca -66 -0f -57 -08 -66 -0f -57 -08 -c5 -f1 -57 -ca -c5 -f1 -57 -08 -c5 -f1 -57 -08 -c5 -e9 -57 -cb -c5 -e9 -57 -08 -c5 -e9 -57 -08 -c5 -ed -57 -cb -c5 -ed -57 -08 -c5 -ed -57 -08 -0f -57 -ca -0f -57 -08 -0f -57 -08 -c5 -f0 -57 -ca -c5 -f0 -57 -08 -c5 -f0 -57 -08 -c5 -e8 -57 -cb -c5 -e8 -57 -08 -c5 -e8 -57 -08 -c5 -ec -57 -cb -c5 -ec -57 -08 -c5 -ec -57 -08 -c5 -fc -77 -c5 -f8 -77 diff --git a/modules/arch/x86/tests/avx16.asm b/modules/arch/x86/tests/avx16.asm deleted file mode 100644 index 72167589..00000000 --- a/modules/arch/x86/tests/avx16.asm +++ /dev/null @@ -1,10 +0,0 @@ -[bits 16] -extractps eax, xmm1, 5 -vextractps eax, xmm1, 5 -pextrb eax, xmm1, 5 -vpextrb eax, xmm1, 5 -pextrw eax, xmm1, 5 -vpextrw eax, xmm1, 5 -pextrd eax, xmm1, 5 -vpextrd eax, xmm1, 5 -vpinsrd xmm1, xmm2, eax, 5 diff --git a/modules/arch/x86/tests/avx16.hex b/modules/arch/x86/tests/avx16.hex deleted file mode 100644 index 6e3a538d..00000000 --- a/modules/arch/x86/tests/avx16.hex +++ /dev/null @@ -1,52 +0,0 @@ -66 -0f -3a -17 -c8 -05 -c4 -e3 -79 -17 -c8 -05 -66 -0f -3a -14 -c8 -05 -c4 -e3 -79 -14 -c8 -05 -66 -0f -c5 -c1 -05 -c5 -f9 -c5 -c1 -05 -66 -0f -3a -16 -c8 -05 -c4 -e3 -79 -16 -c8 -05 -c4 -e3 -69 -22 -c8 -05 diff --git a/modules/arch/x86/tests/avx2.asm b/modules/arch/x86/tests/avx2.asm deleted file mode 100644 index e76016ca..00000000 --- a/modules/arch/x86/tests/avx2.asm +++ /dev/null @@ -1,652 +0,0 @@ -; Exhaustive test of AVX2 instructions -; -; Copyright (C) 2011 Peter Johnson -; -; Redistribution and use in source and binary forms, with or without -; modification, are permitted provided that the following conditions -; are met: -; 1. Redistributions of source code must retain the above copyright -; notice, this list of conditions and the following disclaimer. -; 2. Redistributions in binary form must reproduce the above copyright -; notice, this list of conditions and the following disclaimer in the -; documentation and/or other materials provided with the distribution. -; -; THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND OTHER CONTRIBUTORS ``AS IS'' -; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -; ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR OTHER CONTRIBUTORS BE -; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -; POSSIBILITY OF SUCH DAMAGE. -; - -[bits 64] - -vmpsadbw ymm1, ymm3, 3 ; c4 e3 75 42 cb 03 -vmpsadbw ymm1, yword [rax], 3 ; c4 e3 75 42 08 03 -vmpsadbw ymm1, ymm2, ymm3, 3 ; c4 e3 6d 42 cb 03 -vmpsadbw ymm1, ymm2, yword [rax], 3 ; c4 e3 6d 42 08 03 - -vpabsb ymm1, ymm2 ; c4 e2 7d 1c ca -vpabsb ymm1, yword [rax] ; c4 e2 7d 1c 08 - -vpabsw ymm1, ymm2 ; c4 e2 7d 1d ca -vpabsw ymm1, yword [rax] ; c4 e2 7d 1d 08 - -vpabsd ymm1, ymm2 ; c4 e2 7d 1e ca -vpabsd ymm1, yword [rax] ; c4 e2 7d 1e 08 - -vpacksswb ymm1, ymm3 ; c5 f5 63 cb -vpacksswb ymm1, yword [rax] ; c5 f5 63 08 -vpacksswb ymm1, ymm2, ymm3 ; c5 ed 63 cb -vpacksswb ymm1, ymm2, yword [rax] ; c5 ed 63 08 - -vpackssdw ymm1, ymm3 ; c5 f5 6b cb -vpackssdw ymm1, yword [rax] ; c5 f5 6b 08 -vpackssdw ymm1, ymm2, ymm3 ; c5 ed 6b cb -vpackssdw ymm1, ymm2, yword [rax] ; c5 ed 6b 08 - -vpackusdw ymm1, ymm3 ; c4 e2 75 2b cb -vpackusdw ymm1, yword [rax] ; c4 e2 75 2b 08 -vpackusdw ymm1, ymm2, ymm3 ; c4 e2 6d 2b cb -vpackusdw ymm1, ymm2, yword [rax] ; c4 e2 6d 2b 08 - -vpackuswb ymm1, ymm3 ; c5 f5 67 cb -vpackuswb ymm1, yword [rax] ; c5 f5 67 08 -vpackuswb ymm1, ymm2, ymm3 ; c5 ed 67 cb -vpackuswb ymm1, ymm2, yword [rax] ; c5 ed 67 08 - -vpaddb ymm1, ymm3 ; c5 f5 fc cb -vpaddb ymm1, yword [rax] ; c5 f5 fc 08 -vpaddb ymm1, ymm2, ymm3 ; c5 ed fc cb -vpaddb ymm1, ymm2, yword [rax] ; c5 ed fc 08 - -vpaddw ymm1, ymm3 ; c5 f5 fd cb -vpaddw ymm1, yword [rax] ; c5 f5 fd 08 -vpaddw ymm1, ymm2, ymm3 ; c5 ed fd cb -vpaddw ymm1, ymm2, yword [rax] ; c5 ed fd 08 - -vpaddd ymm1, ymm3 ; c5 f5 fe cb -vpaddd ymm1, yword [rax] ; c5 f5 fe 08 -vpaddd ymm1, ymm2, ymm3 ; c5 ed fe cb -vpaddd ymm1, ymm2, yword [rax] ; c5 ed fe 08 - -vpaddq ymm1, ymm3 ; c5 f5 d4 cb -vpaddq ymm1, yword [rax] ; c5 f5 d4 08 -vpaddq ymm1, ymm2, ymm3 ; c5 ed d4 cb -vpaddq ymm1, ymm2, yword [rax] ; c5 ed d4 08 - -vpaddsb ymm1, ymm3 ; c5 f5 ec cb -vpaddsb ymm1, yword [rax] ; c5 f5 ec 08 -vpaddsb ymm1, ymm2, ymm3 ; c5 ed ec cb -vpaddsb ymm1, ymm2, yword [rax] ; c5 ed ec 08 - -vpaddsw ymm1, ymm3 ; c5 f5 ed cb -vpaddsw ymm1, yword [rax] ; c5 f5 ed 08 -vpaddsw ymm1, ymm2, ymm3 ; c5 ed ed cb -vpaddsw ymm1, ymm2, yword [rax] ; c5 ed ed 08 - -vpaddusb ymm1, ymm3 ; c5 f5 dc cb -vpaddusb ymm1, yword [rax] ; c5 f5 dc 08 -vpaddusb ymm1, ymm2, ymm3 ; c5 ed dc cb -vpaddusb ymm1, ymm2, yword [rax] ; c5 ed dc 08 - -vpaddusw ymm1, ymm3 ; c5 f5 dd cb -vpaddusw ymm1, yword [rax] ; c5 f5 dd 08 -vpaddusw ymm1, ymm2, ymm3 ; c5 ed dd cb -vpaddusw ymm1, ymm2, yword [rax] ; c5 ed dd 08 - -vpalignr ymm1, ymm2, ymm3, 3 ; c4 e3 6d 0f cb 03 -vpalignr ymm1, ymm2, yword [rax], 3 ; c4 e3 6d 0f 08 03 - -vpand ymm1, ymm3 ; c5 f5 db cb -vpand ymm1, yword [rax] ; c5 f5 db 08 -vpand ymm1, ymm2, ymm3 ; c5 ed db cb -vpand ymm1, ymm2, yword [rax] ; c5 ed db 08 - -vpandn ymm1, ymm3 ; c5 f5 df cb -vpandn ymm1, yword [rax] ; c5 f5 df 08 -vpandn ymm1, ymm2, ymm3 ; c5 ed df cb -vpandn ymm1, ymm2, yword [rax] ; c5 ed df 08 - -vpavgb ymm1, ymm3 ; c5 f5 e0 cb -vpavgb ymm1, yword [rax] ; c5 f5 e0 08 -vpavgb ymm1, ymm2, ymm3 ; c5 ed e0 cb -vpavgb ymm1, ymm2, yword [rax] ; c5 ed e0 08 - -vpavgw ymm1, ymm3 ; c5 f5 e3 cb -vpavgw ymm1, yword [rax] ; c5 f5 e3 08 -vpavgw ymm1, ymm2, ymm3 ; c5 ed e3 cb -vpavgw ymm1, ymm2, yword [rax] ; c5 ed e3 08 - -vpblendvb ymm1, ymm2, ymm3, ymm4 ; c4 e3 6d 4c cb 40 -vpblendvb ymm1, ymm2, yword [rax], ymm4 ; c4 e3 6d 4c 08 40 - -vpblendw ymm1, ymm3, 3 ; c4 e3 75 0e cb 03 -vpblendw ymm1, yword [rax], 3 ; c4 e3 75 0e 08 03 -vpblendw ymm1, ymm2, ymm3, 3 ; c4 e3 6d 0e cb 03 -vpblendw ymm1, ymm2, yword [rax], 3 ; c4 e3 6d 0e 08 03 - -vpcmpeqb ymm1, ymm3 ; c5 f5 74 cb -vpcmpeqb ymm1, yword [rax] ; c5 f5 74 08 -vpcmpeqb ymm1, ymm2, ymm3 ; c5 ed 74 cb -vpcmpeqb ymm1, ymm2, yword [rax] ; c5 ed 74 08 - -vpcmpeqw ymm1, ymm3 ; c5 f5 75 cb -vpcmpeqw ymm1, yword [rax] ; c5 f5 75 08 -vpcmpeqw ymm1, ymm2, ymm3 ; c5 ed 75 cb -vpcmpeqw ymm1, ymm2, yword [rax] ; c5 ed 75 08 - -vpcmpeqd ymm1, ymm3 ; c5 f5 76 cb -vpcmpeqd ymm1, yword [rax] ; c5 f5 76 08 -vpcmpeqd ymm1, ymm2, ymm3 ; c5 ed 76 cb -vpcmpeqd ymm1, ymm2, yword [rax] ; c5 ed 76 08 - -vpcmpeqq ymm1, ymm3 ; c4 e2 75 29 cb -vpcmpeqq ymm1, yword [rax] ; c4 e2 75 29 08 -vpcmpeqq ymm1, ymm2, ymm3 ; c4 e2 6d 29 cb -vpcmpeqq ymm1, ymm2, yword [rax] ; c4 e2 6d 29 08 - -vpcmpgtb ymm1, ymm3 ; c5 f5 64 cb -vpcmpgtb ymm1, yword [rax] ; c5 f5 64 08 -vpcmpgtb ymm1, ymm2, ymm3 ; c5 ed 64 cb -vpcmpgtb ymm1, ymm2, yword [rax] ; c5 ed 64 08 - -vpcmpgtw ymm1, ymm3 ; c5 f5 65 cb -vpcmpgtw ymm1, yword [rax] ; c5 f5 65 08 -vpcmpgtw ymm1, ymm2, ymm3 ; c5 ed 65 cb -vpcmpgtw ymm1, ymm2, yword [rax] ; c5 ed 65 08 - -vpcmpgtd ymm1, ymm3 ; c5 f5 66 cb -vpcmpgtd ymm1, yword [rax] ; c5 f5 66 08 -vpcmpgtd ymm1, ymm2, ymm3 ; c5 ed 66 cb -vpcmpgtd ymm1, ymm2, yword [rax] ; c5 ed 66 08 - -vpcmpgtq ymm1, ymm3 ; c4 e2 75 37 cb -vpcmpgtq ymm1, yword [rax] ; c4 e2 75 37 08 -vpcmpgtq ymm1, ymm2, ymm3 ; c4 e2 6d 37 cb -vpcmpgtq ymm1, ymm2, yword [rax] ; c4 e2 6d 37 08 - -vphaddw ymm1, ymm3 ; c4 e2 75 01 cb -vphaddw ymm1, yword [rax] ; c4 e2 75 01 08 -vphaddw ymm1, ymm2, ymm3 ; c4 e2 6d 01 cb -vphaddw ymm1, ymm2, yword [rax] ; c4 e2 6d 01 08 - -vphaddd ymm1, ymm3 ; c4 e2 75 02 cb -vphaddd ymm1, yword [rax] ; c4 e2 75 02 08 -vphaddd ymm1, ymm2, ymm3 ; c4 e2 6d 02 cb -vphaddd ymm1, ymm2, yword [rax] ; c4 e2 6d 02 08 - -vphaddsw ymm1, ymm3 ; c4 e2 75 03 cb -vphaddsw ymm1, yword [rax] ; c4 e2 75 03 08 -vphaddsw ymm1, ymm2, ymm3 ; c4 e2 6d 03 cb -vphaddsw ymm1, ymm2, yword [rax] ; c4 e2 6d 03 08 - -vphsubw ymm1, ymm3 ; c4 e2 75 05 cb -vphsubw ymm1, yword [rax] ; c4 e2 75 05 08 -vphsubw ymm1, ymm2, ymm3 ; c4 e2 6d 05 cb -vphsubw ymm1, ymm2, yword [rax] ; c4 e2 6d 05 08 - -vphsubd ymm1, ymm3 ; c4 e2 75 06 cb -vphsubd ymm1, yword [rax] ; c4 e2 75 06 08 -vphsubd ymm1, ymm2, ymm3 ; c4 e2 6d 06 cb -vphsubd ymm1, ymm2, yword [rax] ; c4 e2 6d 06 08 - -vphsubsw ymm1, ymm3 ; c4 e2 75 07 cb -vphsubsw ymm1, yword [rax] ; c4 e2 75 07 08 -vphsubsw ymm1, ymm2, ymm3 ; c4 e2 6d 07 cb -vphsubsw ymm1, ymm2, yword [rax] ; c4 e2 6d 07 08 - -vpmaddubsw ymm1, ymm3 ; c4 e2 75 04 cb -vpmaddubsw ymm1, yword [rax] ; c4 e2 75 04 08 -vpmaddubsw ymm1, ymm2, ymm3 ; c4 e2 6d 04 cb -vpmaddubsw ymm1, ymm2, yword [rax] ; c4 e2 6d 04 08 - -vpmaddwd ymm1, ymm3 ; c5 f5 f5 cb -vpmaddwd ymm1, yword [rax] ; c5 f5 f5 08 -vpmaddwd ymm1, ymm2, ymm3 ; c5 ed f5 cb -vpmaddwd ymm1, ymm2, yword [rax] ; c5 ed f5 08 - -vpmaxsb ymm1, ymm3 ; c4 e2 75 3c cb -vpmaxsb ymm1, yword [rax] ; c4 e2 75 3c 08 -vpmaxsb ymm1, ymm2, ymm3 ; c4 e2 6d 3c cb -vpmaxsb ymm1, ymm2, yword [rax] ; c4 e2 6d 3c 08 - -vpmaxsw ymm1, ymm3 ; c5 f5 ee cb -vpmaxsw ymm1, yword [rax] ; c5 f5 ee 08 -vpmaxsw ymm1, ymm2, ymm3 ; c5 ed ee cb -vpmaxsw ymm1, ymm2, yword [rax] ; c5 ed ee 08 - -vpmaxsd ymm1, ymm3 ; c4 e2 75 3d cb -vpmaxsd ymm1, yword [rax] ; c4 e2 75 3d 08 -vpmaxsd ymm1, ymm2, ymm3 ; c4 e2 6d 3d cb -vpmaxsd ymm1, ymm2, yword [rax] ; c4 e2 6d 3d 08 - -vpmaxub ymm1, ymm3 ; c5 f5 de cb -vpmaxub ymm1, yword [rax] ; c5 f5 de 08 -vpmaxub ymm1, ymm2, ymm3 ; c5 ed de cb -vpmaxub ymm1, ymm2, yword [rax] ; c5 ed de 08 - -vpmaxuw ymm1, ymm3 ; c4 e2 75 3e cb -vpmaxuw ymm1, yword [rax] ; c4 e2 75 3e 08 -vpmaxuw ymm1, ymm2, ymm3 ; c4 e2 6d 3e cb -vpmaxuw ymm1, ymm2, yword [rax] ; c4 e2 6d 3e 08 - -vpmaxud ymm1, ymm3 ; c4 e2 75 3f cb -vpmaxud ymm1, yword [rax] ; c4 e2 75 3f 08 -vpmaxud ymm1, ymm2, ymm3 ; c4 e2 6d 3f cb -vpmaxud ymm1, ymm2, yword [rax] ; c4 e2 6d 3f 08 - -vpminsb ymm1, ymm3 ; c4 e2 75 38 cb -vpminsb ymm1, yword [rax] ; c4 e2 75 38 08 -vpminsb ymm1, ymm2, ymm3 ; c4 e2 6d 38 cb -vpminsb ymm1, ymm2, yword [rax] ; c4 e2 6d 38 08 - -vpminsw ymm1, ymm3 ; c5 f5 ea cb -vpminsw ymm1, yword [rax] ; c5 f5 ea 08 -vpminsw ymm1, ymm2, ymm3 ; c5 ed ea cb -vpminsw ymm1, ymm2, yword [rax] ; c5 ed ea 08 - -vpminsd ymm1, ymm3 ; c4 e2 75 39 cb -vpminsd ymm1, yword [rax] ; c4 e2 75 39 08 -vpminsd ymm1, ymm2, ymm3 ; c4 e2 6d 39 cb -vpminsd ymm1, ymm2, yword [rax] ; c4 e2 6d 39 08 - -vpminub ymm1, ymm3 ; c5 f5 da cb -vpminub ymm1, yword [rax] ; c5 f5 da 08 -vpminub ymm1, ymm2, ymm3 ; c5 ed da cb -vpminub ymm1, ymm2, yword [rax] ; c5 ed da 08 - -vpminuw ymm1, ymm3 ; c4 e2 75 3a cb -vpminuw ymm1, yword [rax] ; c4 e2 75 3a 08 -vpminuw ymm1, ymm2, ymm3 ; c4 e2 6d 3a cb -vpminuw ymm1, ymm2, yword [rax] ; c4 e2 6d 3a 08 - -vpminud ymm1, ymm3 ; c4 e2 75 3b cb -vpminud ymm1, yword [rax] ; c4 e2 75 3b 08 -vpminud ymm1, ymm2, ymm3 ; c4 e2 6d 3b cb -vpminud ymm1, ymm2, yword [rax] ; c4 e2 6d 3b 08 - -vpmovmskb eax, ymm1 ; c5 fd d7 c1 -vpmovmskb rax, ymm1 ; c5 fd d7 c1 - -vpmovsxbw ymm1, xmm2 ; c4 e2 7d 20 ca -vpmovsxbw ymm1, [rax] ; c4 e2 7d 20 08 -vpmovsxbw ymm1, oword [rax] ; c4 e2 7d 20 08 - -vpmovsxbd ymm1, xmm2 ; c4 e2 7d 21 ca -vpmovsxbd ymm1, [rax] ; c4 e2 7d 21 08 -vpmovsxbd ymm1, qword [rax] ; c4 e2 7d 21 08 - -vpmovsxbq ymm1, xmm2 ; c4 e2 7d 22 ca -vpmovsxbq ymm1, [rax] ; c4 e2 7d 22 08 -vpmovsxbq ymm1, dword [rax] ; c4 e2 7d 22 08 - -vpmovsxwd ymm1, xmm2 ; c4 e2 7d 23 ca -vpmovsxwd ymm1, [rax] ; c4 e2 7d 23 08 -vpmovsxwd ymm1, oword [rax] ; c4 e2 7d 23 08 - -vpmovsxwq ymm1, xmm2 ; c4 e2 7d 24 ca -vpmovsxwq ymm1, [rax] ; c4 e2 7d 24 08 -vpmovsxwq ymm1, qword [rax] ; c4 e2 7d 24 08 - -vpmovsxdq ymm1, xmm2 ; c4 e2 7d 25 ca -vpmovsxdq ymm1, [rax] ; c4 e2 7d 25 08 -vpmovsxdq ymm1, oword [rax] ; c4 e2 7d 25 08 - -vpmovzxbw ymm1, xmm2 ; c4 e2 7d 30 ca -vpmovzxbw ymm1, [rax] ; c4 e2 7d 30 08 -vpmovzxbw ymm1, oword [rax] ; c4 e2 7d 30 08 - -vpmovzxbd ymm1, xmm2 ; c4 e2 7d 31 ca -vpmovzxbd ymm1, [rax] ; c4 e2 7d 31 08 -vpmovzxbd ymm1, qword [rax] ; c4 e2 7d 31 08 - -vpmovzxbq ymm1, xmm2 ; c4 e2 7d 32 ca -vpmovzxbq ymm1, [rax] ; c4 e2 7d 32 08 -vpmovzxbq ymm1, dword [rax] ; c4 e2 7d 32 08 - -vpmovzxwd ymm1, xmm2 ; c4 e2 7d 33 ca -vpmovzxwd ymm1, [rax] ; c4 e2 7d 33 08 -vpmovzxwd ymm1, oword [rax] ; c4 e2 7d 33 08 - -vpmovzxwq ymm1, xmm2 ; c4 e2 7d 34 ca -vpmovzxwq ymm1, [rax] ; c4 e2 7d 34 08 -vpmovzxwq ymm1, qword [rax] ; c4 e2 7d 34 08 - -vpmovzxdq ymm1, xmm2 ; c4 e2 7d 35 ca -vpmovzxdq ymm1, [rax] ; c4 e2 7d 35 08 -vpmovzxdq ymm1, oword [rax] ; c4 e2 7d 35 08 - -vpmuldq ymm1, ymm3 ; c4 e2 75 28 cb -vpmuldq ymm1, yword [rax] ; c4 e2 75 28 08 -vpmuldq ymm1, ymm2, ymm3 ; c4 e2 6d 28 cb -vpmuldq ymm1, ymm2, yword [rax] ; c4 e2 6d 28 08 - -vpmulhrsw ymm1, ymm3 ; c4 e2 75 0b cb -vpmulhrsw ymm1, yword [rax] ; c4 e2 75 0b 08 -vpmulhrsw ymm1, ymm2, ymm3 ; c4 e2 6d 0b cb -vpmulhrsw ymm1, ymm2, yword [rax] ; c4 e2 6d 0b 08 - -vpmulhuw ymm1, ymm3 ; c5 f5 e4 cb -vpmulhuw ymm1, yword [rax] ; c5 f5 e4 08 -vpmulhuw ymm1, ymm2, ymm3 ; c5 ed e4 cb -vpmulhuw ymm1, ymm2, yword [rax] ; c5 ed e4 08 - -vpmulhw ymm1, ymm3 ; c5 f5 e5 cb -vpmulhw ymm1, yword [rax] ; c5 f5 e5 08 -vpmulhw ymm1, ymm2, ymm3 ; c5 ed e5 cb -vpmulhw ymm1, ymm2, yword [rax] ; c5 ed e5 08 - -vpmullw ymm1, ymm3 ; c5 f5 d5 cb -vpmullw ymm1, yword [rax] ; c5 f5 d5 08 -vpmullw ymm1, ymm2, ymm3 ; c5 ed d5 cb -vpmullw ymm1, ymm2, yword [rax] ; c5 ed d5 08 - -vpmulld ymm1, ymm3 ; c4 e2 75 40 cb -vpmulld ymm1, yword [rax] ; c4 e2 75 40 08 -vpmulld ymm1, ymm2, ymm3 ; c4 e2 6d 40 cb -vpmulld ymm1, ymm2, yword [rax] ; c4 e2 6d 40 08 - -vpmuludq ymm1, ymm3 ; c5 f5 f4 cb -vpmuludq ymm1, yword [rax] ; c5 f5 f4 08 -vpmuludq ymm1, ymm2, ymm3 ; c5 ed f4 cb -vpmuludq ymm1, ymm2, yword [rax] ; c5 ed f4 08 - -vpor ymm1, ymm3 ; c5 f5 eb cb -vpor ymm1, yword [rax] ; c5 f5 eb 08 -vpor ymm1, ymm2, ymm3 ; c5 ed eb cb -vpor ymm1, ymm2, yword [rax] ; c5 ed eb 08 - -vpsadbw ymm1, ymm3 ; c5 f5 f6 cb -vpsadbw ymm1, yword [rax] ; c5 f5 f6 08 -vpsadbw ymm1, ymm2, ymm3 ; c5 ed f6 cb -vpsadbw ymm1, ymm2, yword [rax] ; c5 ed f6 08 - -vpshufb ymm1, ymm3 ; c4 e2 75 00 cb -vpshufb ymm1, yword [rax] ; c4 e2 75 00 08 -vpshufb ymm1, ymm2, ymm3 ; c4 e2 6d 00 cb -vpshufb ymm1, ymm2, yword [rax] ; c4 e2 6d 00 08 - -vpshufd ymm1, ymm3, 3 ; c5 fd 70 cb 03 -vpshufd ymm1, yword [rax], 3 ; c5 fd 70 08 03 - -vpshufhw ymm1, ymm3, 3 ; c5 fe 70 cb 03 -vpshufhw ymm1, yword [rax], 3 ; c5 fe 70 08 03 - -vpshuflw ymm1, ymm3, 3 ; c5 ff 70 cb 03 -vpshuflw ymm1, yword [rax], 3 ; c5 ff 70 08 03 - -vpsignb ymm1, ymm3 ; c4 e2 75 08 cb -vpsignb ymm1, yword [rax] ; c4 e2 75 08 08 -vpsignb ymm1, ymm2, ymm3 ; c4 e2 6d 08 cb -vpsignb ymm1, ymm2, yword [rax] ; c4 e2 6d 08 08 - -vpsignw ymm1, ymm3 ; c4 e2 75 09 cb -vpsignw ymm1, yword [rax] ; c4 e2 75 09 08 -vpsignw ymm1, ymm2, ymm3 ; c4 e2 6d 09 cb -vpsignw ymm1, ymm2, yword [rax] ; c4 e2 6d 09 08 - -vpsignd ymm1, ymm3 ; c4 e2 75 0a cb -vpsignd ymm1, yword [rax] ; c4 e2 75 0a 08 -vpsignd ymm1, ymm2, ymm3 ; c4 e2 6d 0a cb -vpsignd ymm1, ymm2, yword [rax] ; c4 e2 6d 0a 08 - -vpslldq ymm1, 3 ; c5 f5 73 f9 03 -vpslldq ymm1, ymm2, 3 ; c5 f5 73 fa 03 - -vpsllw ymm1, xmm3 ; c5 f5 f1 cb -vpsllw ymm1, oword [rax] ; c5 f5 f1 08 -vpsllw ymm1, 3 ; c5 f5 71 f1 03 -vpsllw ymm1, ymm2, xmm3 ; c5 ed f1 cb -vpsllw ymm1, ymm2, oword [rax] ; c5 ed f1 08 -vpsllw ymm1, ymm2, 3 ; c5 f5 71 f2 03 - -vpslld ymm1, xmm3 ; c5 f5 f2 cb -vpslld ymm1, oword [rax] ; c5 f5 f2 08 -vpslld ymm1, 3 ; c5 f5 72 f1 03 -vpslld ymm1, ymm2, xmm3 ; c5 ed f2 cb -vpslld ymm1, ymm2, oword [rax] ; c5 ed f2 08 -vpslld ymm1, ymm2, 3 ; c5 f5 72 f2 03 - -vpsllq ymm1, xmm3 ; c5 f5 f3 cb -vpsllq ymm1, oword [rax] ; c5 f5 f3 08 -vpsllq ymm1, 3 ; c5 f5 73 f1 03 -vpsllq ymm1, ymm2, xmm3 ; c5 ed f3 cb -vpsllq ymm1, ymm2, oword [rax] ; c5 ed f3 08 -vpsllq ymm1, ymm2, 3 ; c5 f5 73 f2 03 - -vpsraw ymm1, xmm3 ; c5 f5 e1 cb -vpsraw ymm1, oword [rax] ; c5 f5 e1 08 -vpsraw ymm1, 3 ; c5 f5 71 e1 03 -vpsraw ymm1, ymm2, xmm3 ; c5 ed e1 cb -vpsraw ymm1, ymm2, oword [rax] ; c5 ed e1 08 -vpsraw ymm1, ymm2, 3 ; c5 f5 71 e2 03 - -vpsrad ymm1, xmm3 ; c5 f5 e2 cb -vpsrad ymm1, oword [rax] ; c5 f5 e2 08 -vpsrad ymm1, 3 ; c5 f5 72 e1 03 -vpsrad ymm1, ymm2, xmm3 ; c5 ed e2 cb -vpsrad ymm1, ymm2, oword [rax] ; c5 ed e2 08 -vpsrad ymm1, ymm2, 3 ; c5 f5 72 e2 03 - -vpsrldq ymm1, 3 ; c5 f5 73 d9 03 -vpsrldq ymm1, ymm2, 3 ; c5 f5 73 da 03 - -vpsrlw ymm1, xmm3 ; c5 f5 d1 cb -vpsrlw ymm1, oword [rax] ; c5 f5 d1 08 -vpsrlw ymm1, 3 ; c5 f5 71 d1 03 -vpsrlw ymm1, ymm2, xmm3 ; c5 ed d1 cb -vpsrlw ymm1, ymm2, oword [rax] ; c5 ed d1 08 -vpsrlw ymm1, ymm2, 3 ; c5 f5 71 d2 03 - -vpsrld ymm1, xmm3 ; c5 f5 d2 cb -vpsrld ymm1, oword [rax] ; c5 f5 d2 08 -vpsrld ymm1, 3 ; c5 f5 72 d1 03 -vpsrld ymm1, ymm2, xmm3 ; c5 ed d2 cb -vpsrld ymm1, ymm2, oword [rax] ; c5 ed d2 08 -vpsrld ymm1, ymm2, 3 ; c5 f5 72 d2 03 - -vpsrld ymm1, xmm3 ; c5 f5 d2 cb -vpsrld ymm1, oword [rax] ; c5 f5 d2 08 -vpsrld ymm1, 3 ; c5 f5 72 d1 03 -vpsrld ymm1, ymm2, xmm3 ; c5 ed d2 cb -vpsrld ymm1, ymm2, oword [rax] ; c5 ed d2 08 -vpsrld ymm1, ymm2, 3 ; c5 f5 72 d2 03 - -vpsubsb ymm1, ymm3 ; c5 f5 e8 cb -vpsubsb ymm1, yword [rax] ; c5 f5 e8 08 -vpsubsb ymm1, ymm2, ymm3 ; c5 ed e8 cb -vpsubsb ymm1, ymm2, yword [rax] ; c5 ed e8 08 - -vpsubsw ymm1, ymm3 ; c5 f5 e9 cb -vpsubsw ymm1, yword [rax] ; c5 f5 e9 08 -vpsubsw ymm1, ymm2, ymm3 ; c5 ed e9 cb -vpsubsw ymm1, ymm2, yword [rax] ; c5 ed e9 08 - -vpsubusb ymm1, ymm3 ; c5 f5 d8 cb -vpsubusb ymm1, yword [rax] ; c5 f5 d8 08 -vpsubusb ymm1, ymm2, ymm3 ; c5 ed d8 cb -vpsubusb ymm1, ymm2, yword [rax] ; c5 ed d8 08 - -vpsubusw ymm1, ymm3 ; c5 f5 d9 cb -vpsubusw ymm1, yword [rax] ; c5 f5 d9 08 -vpsubusw ymm1, ymm2, ymm3 ; c5 ed d9 cb -vpsubusw ymm1, ymm2, yword [rax] ; c5 ed d9 08 - -vpunpckhbw ymm1, ymm3 ; c5 f5 68 cb -vpunpckhbw ymm1, yword [rax] ; c5 f5 68 08 -vpunpckhbw ymm1, ymm2, ymm3 ; c5 ed 68 cb -vpunpckhbw ymm1, ymm2, yword [rax] ; c5 ed 68 08 - -vpunpckhwd ymm1, ymm3 ; c5 f5 69 cb -vpunpckhwd ymm1, yword [rax] ; c5 f5 69 08 -vpunpckhwd ymm1, ymm2, ymm3 ; c5 ed 69 cb -vpunpckhwd ymm1, ymm2, yword [rax] ; c5 ed 69 08 - -vpunpckhdq ymm1, ymm3 ; c5 f5 6a cb -vpunpckhdq ymm1, yword [rax] ; c5 f5 6a 08 -vpunpckhdq ymm1, ymm2, ymm3 ; c5 ed 6a cb -vpunpckhdq ymm1, ymm2, yword [rax] ; c5 ed 6a 08 - -vpunpckhqdq ymm1, ymm3 ; c5 f5 6d cb -vpunpckhqdq ymm1, yword [rax] ; c5 f5 6d 08 -vpunpckhqdq ymm1, ymm2, ymm3 ; c5 ed 6d cb -vpunpckhqdq ymm1, ymm2, yword [rax] ; c5 ed 6d 08 - -vpunpcklbw ymm1, ymm3 ; c5 f5 60 cb -vpunpcklbw ymm1, yword [rax] ; c5 f5 60 08 -vpunpcklbw ymm1, ymm2, ymm3 ; c5 ed 60 cb -vpunpcklbw ymm1, ymm2, yword [rax] ; c5 ed 60 08 - -vpunpcklwd ymm1, ymm3 ; c5 f5 61 cb -vpunpcklwd ymm1, yword [rax] ; c5 f5 61 08 -vpunpcklwd ymm1, ymm2, ymm3 ; c5 ed 61 cb -vpunpcklwd ymm1, ymm2, yword [rax] ; c5 ed 61 08 - -vpunpckldq ymm1, ymm3 ; c5 f5 62 cb -vpunpckldq ymm1, yword [rax] ; c5 f5 62 08 -vpunpckldq ymm1, ymm2, ymm3 ; c5 ed 62 cb -vpunpckldq ymm1, ymm2, yword [rax] ; c5 ed 62 08 - -vpunpcklqdq ymm1, ymm3 ; c5 f5 6c cb -vpunpcklqdq ymm1, yword [rax] ; c5 f5 6c 08 -vpunpcklqdq ymm1, ymm2, ymm3 ; c5 ed 6c cb -vpunpcklqdq ymm1, ymm2, yword [rax] ; c5 ed 6c 08 - -vpxor ymm1, ymm3 ; c5 f5 ef cb -vpxor ymm1, yword [rax] ; c5 f5 ef 08 -vpxor ymm1, ymm2, ymm3 ; c5 ed ef cb -vpxor ymm1, ymm2, yword [rax] ; c5 ed ef 08 - -vmovntdqa ymm1, yword [rax] ; c4 e2 7d 2a 08 - -vbroadcastss xmm1, xmm2 ; c4 e2 79 18 ca -vbroadcastss ymm1, xmm2 ; c4 e2 7d 18 ca - -vbroadcastsd ymm1, xmm2 ; c4 e2 7d 19 ca - -vbroadcasti128 ymm1, oword [rax] ; c4 e2 7d 5a 08 - -vpblendd ymm1, ymm2, ymm3, 3 ; c4 e3 6d 02 cb 03 -vpblendd ymm1, ymm2, yword [rax], 3 ; c4 e3 6d 02 08 03 - -vpbroadcastb xmm1, xmm2 ; c4 e2 79 78 ca -vpbroadcastb xmm1, byte [rax] ; c4 e2 79 78 08 -vpbroadcastb ymm1, xmm2 ; c4 e2 7d 78 ca -vpbroadcastb ymm1, byte [rax] ; c4 e2 7d 78 08 - -vpbroadcastw xmm1, xmm2 ; c4 e2 79 79 ca -vpbroadcastw xmm1, word [rax] ; c4 e2 79 79 08 -vpbroadcastw ymm1, xmm2 ; c4 e2 7d 79 ca -vpbroadcastw ymm1, word [rax] ; c4 e2 7d 79 08 - -vpbroadcastd xmm1, xmm2 ; c4 e2 79 58 ca -vpbroadcastd xmm1, dword [rax] ; c4 e2 79 58 08 -vpbroadcastd ymm1, xmm2 ; c4 e2 7d 58 ca -vpbroadcastd ymm1, dword [rax] ; c4 e2 7d 58 08 - -vpbroadcastq xmm1, xmm2 ; c4 e2 79 59 ca -vpbroadcastq xmm1, qword [rax] ; c4 e2 79 59 08 -vpbroadcastq ymm1, xmm2 ; c4 e2 7d 59 ca -vpbroadcastq ymm1, qword [rax] ; c4 e2 7d 59 08 - -vpermd ymm1, ymm2, ymm3 ; c4 e2 6d 36 cb -vpermd ymm1, ymm2, yword [rax] ; c4 e2 6d 36 08 - -vpermpd ymm1, ymm2, 3 ; c4 e3 fd 01 ca 03 -vpermpd ymm1, yword [rax], 3 ; c4 e3 fd 01 08 03 - -vpermps ymm1, ymm2, ymm3 ; c4 e2 6d 16 cb -vpermps ymm1, ymm2, yword [rax] ; c4 e2 6d 16 08 - -vpermq ymm1, ymm2, 3 ; c4 e3 fd 00 ca 03 -vpermq ymm1, yword [rax], 3 ; c4 e3 fd 00 08 03 - -vperm2i128 ymm1, ymm2, ymm3, 3 ; c4 e3 6d 46 cb 03 -vperm2i128 ymm1, ymm2, yword [rax], 3 ; c4 e3 6d 46 08 03 - -vextracti128 xmm1, ymm2, 3 ; c4 e3 7d 39 d1 03 -vextracti128 oword [rax], ymm2, 3 ; c4 e3 7d 39 10 03 - -vinserti128 ymm1, ymm2, xmm3, 3 ; c4 e3 6d 38 cb 03 -vinserti128 ymm1, ymm2, oword [rax], 3 ; c4 e3 6d 38 08 03 - -vpmaskmovd xmm1, xmm2, oword [rax] ; c4 e2 69 8c 08 -vpmaskmovd ymm1, ymm2, yword [rax] ; c4 e2 6d 8c 08 -vpmaskmovd oword [rax], xmm1, xmm2 ; c4 e2 71 8e 10 -vpmaskmovd yword [rax], ymm1, ymm2 ; c4 e2 75 8e 10 - -vpmaskmovq xmm1, xmm2, oword [rax] ; c4 e2 e9 8c 08 -vpmaskmovq ymm1, ymm2, yword [rax] ; c4 e2 ed 8c 08 -vpmaskmovq oword [rax], xmm1, xmm2 ; c4 e2 f1 8e 10 -vpmaskmovq yword [rax], ymm1, ymm2 ; c4 e2 f5 8e 10 - -vpsllvd xmm1, xmm2, xmm3 ; c4 e2 69 47 cb -vpsllvd xmm1, xmm2, oword [rax] ; c4 e2 69 47 08 -vpsllvd ymm1, ymm2, ymm3 ; c4 e2 6d 47 cb -vpsllvd ymm1, ymm2, yword [rax] ; c4 e2 6d 47 08 - -vpsllvq xmm1, xmm2, xmm3 ; c4 e2 e9 47 cb -vpsllvq xmm1, xmm2, oword [rax] ; c4 e2 e9 47 08 -vpsllvq ymm1, ymm2, ymm3 ; c4 e2 ed 47 cb -vpsllvq ymm1, ymm2, yword [rax] ; c4 e2 ed 47 08 - -vpsravd xmm1, xmm2, xmm3 ; c4 e2 69 46 cb -vpsravd xmm1, xmm2, oword [rax] ; c4 e2 69 46 08 -vpsravd ymm1, ymm2, ymm3 ; c4 e2 6d 46 cb -vpsravd ymm1, ymm2, yword [rax] ; c4 e2 6d 46 08 - -vpsrlvd xmm1, xmm2, xmm3 ; c4 e2 69 45 cb -vpsrlvd xmm1, xmm2, oword [rax] ; c4 e2 69 45 08 -vpsrlvd ymm1, ymm2, ymm3 ; c4 e2 6d 45 cb -vpsrlvd ymm1, ymm2, yword [rax] ; c4 e2 6d 45 08 - -vpsrlvq xmm1, xmm2, xmm3 ; c4 e2 e9 45 cb -vpsrlvq xmm1, xmm2, oword [rax] ; c4 e2 e9 45 08 -vpsrlvq ymm1, ymm2, ymm3 ; c4 e2 ed 45 cb -vpsrlvq ymm1, ymm2, yword [rax] ; c4 e2 ed 45 08 - -vgatherdpd xmm1, [rax+xmm1], xmm2 ; c4 e2 e9 92 0c 08 -vgatherdpd xmm1, qword [rax+xmm1], xmm2 ; c4 e2 e9 92 0c 08 -vgatherdpd ymm1, [rax+xmm1], ymm2 ; c4 e2 ed 92 0c 08 -vgatherdpd ymm1, qword [rax+xmm1], ymm2 ; c4 e2 ed 92 0c 08 - -vgatherqpd xmm1, [rax+xmm1], xmm2 ; c4 e2 e9 93 0c 08 -vgatherqpd xmm1, qword [rax+xmm1], xmm2 ; c4 e2 e9 93 0c 08 -vgatherqpd ymm1, [rax+ymm1], ymm2 ; c4 e2 ed 93 0c 08 -vgatherqpd ymm1, qword [rax+ymm1], ymm2 ; c4 e2 ed 93 0c 08 - -vgatherdps xmm1, [rax+xmm1], xmm2 ; c4 e2 69 92 0c 08 -vgatherdps xmm1, dword [rax+xmm1], xmm2 ; c4 e2 69 92 0c 08 -vgatherdps ymm1, [rax+ymm1], ymm2 ; c4 e2 6d 92 0c 08 -vgatherdps ymm1, dword [rax+ymm1], ymm2 ; c4 e2 6d 92 0c 08 - -vgatherqps xmm1, [rax+xmm1], xmm2 ; c4 e2 69 93 0c 08 -vgatherqps xmm1, dword [rax+xmm1], xmm2 ; c4 e2 69 93 0c 08 -vgatherqps xmm1, [rax+ymm1], xmm2 ; c4 e2 6d 93 0c 08 -vgatherqps xmm1, dword [rax+ymm1], xmm2 ; c4 e2 6d 93 0c 08 - -vpgatherdd xmm1, [rax+xmm1], xmm2 ; c4 e2 69 90 0c 08 -vpgatherdd xmm1, dword [rax+xmm1], xmm2 ; c4 e2 69 90 0c 08 -vpgatherdd ymm1, [rax+ymm1], ymm2 ; c4 e2 6d 90 0c 08 -vpgatherdd ymm1, dword [rax+ymm1], ymm2 ; c4 e2 6d 90 0c 08 - -vpgatherqd xmm1, [rax+xmm1], xmm2 ; c4 e2 69 91 0c 08 -vpgatherqd xmm1, dword [rax+xmm1], xmm2 ; c4 e2 69 91 0c 08 -vpgatherqd xmm1, [rax+ymm1], xmm2 ; c4 e2 6d 91 0c 08 -vpgatherqd xmm1, dword [rax+ymm1], xmm2 ; c4 e2 6d 91 0c 08 - -vpgatherdq xmm1, [rax+xmm1], xmm2 ; c4 e2 e9 90 0c 08 -vpgatherdq xmm1, qword [rax+xmm1], xmm2 ; c4 e2 e9 90 0c 08 -vpgatherdq ymm1, [rax+xmm1], ymm2 ; c4 e2 ed 90 0c 08 -vpgatherdq ymm1, qword [rax+xmm1], ymm2 ; c4 e2 ed 90 0c 08 - -vpgatherqq xmm1, [rax+xmm1], xmm2 ; c4 e2 e9 91 0c 08 -vpgatherqq xmm1, qword [rax+xmm1], xmm2 ; c4 e2 e9 91 0c 08 -vpgatherqq ymm1, [rax+ymm1], ymm2 ; c4 e2 ed 91 0c 08 -vpgatherqq ymm1, qword [rax+ymm1], ymm2 ; c4 e2 ed 91 0c 08 diff --git a/modules/arch/x86/tests/avx2.hex b/modules/arch/x86/tests/avx2.hex deleted file mode 100644 index 17f84bd3..00000000 --- a/modules/arch/x86/tests/avx2.hex +++ /dev/null @@ -1,2297 +0,0 @@ -c4 -e3 -75 -42 -cb -03 -c4 -e3 -75 -42 -08 -03 -c4 -e3 -6d -42 -cb -03 -c4 -e3 -6d -42 -08 -03 -c4 -e2 -7d -1c -ca -c4 -e2 -7d -1c -08 -c4 -e2 -7d -1d -ca -c4 -e2 -7d -1d -08 -c4 -e2 -7d -1e -ca -c4 -e2 -7d -1e -08 -c5 -f5 -63 -cb -c5 -f5 -63 -08 -c5 -ed -63 -cb -c5 -ed -63 -08 -c5 -f5 -6b -cb -c5 -f5 -6b -08 -c5 -ed -6b -cb -c5 -ed -6b -08 -c4 -e2 -75 -2b -cb -c4 -e2 -75 -2b -08 -c4 -e2 -6d -2b -cb -c4 -e2 -6d -2b -08 -c5 -f5 -67 -cb -c5 -f5 -67 -08 -c5 -ed -67 -cb -c5 -ed -67 -08 -c5 -f5 -fc -cb -c5 -f5 -fc -08 -c5 -ed -fc -cb -c5 -ed -fc -08 -c5 -f5 -fd -cb -c5 -f5 -fd -08 -c5 -ed -fd -cb -c5 -ed -fd -08 -c5 -f5 -fe -cb -c5 -f5 -fe -08 -c5 -ed -fe -cb -c5 -ed -fe -08 -c5 -f5 -d4 -cb -c5 -f5 -d4 -08 -c5 -ed -d4 -cb -c5 -ed -d4 -08 -c5 -f5 -ec -cb -c5 -f5 -ec -08 -c5 -ed -ec -cb -c5 -ed -ec -08 -c5 -f5 -ed -cb -c5 -f5 -ed -08 -c5 -ed -ed -cb -c5 -ed -ed -08 -c5 -f5 -dc -cb -c5 -f5 -dc -08 -c5 -ed -dc -cb -c5 -ed -dc -08 -c5 -f5 -dd -cb -c5 -f5 -dd -08 -c5 -ed -dd -cb -c5 -ed -dd -08 -c4 -e3 -6d -0f -cb -03 -c4 -e3 -6d -0f -08 -03 -c5 -f5 -db -cb -c5 -f5 -db -08 -c5 -ed -db -cb -c5 -ed -db -08 -c5 -f5 -df -cb -c5 -f5 -df -08 -c5 -ed -df -cb -c5 -ed -df -08 -c5 -f5 -e0 -cb -c5 -f5 -e0 -08 -c5 -ed -e0 -cb -c5 -ed -e0 -08 -c5 -f5 -e3 -cb -c5 -f5 -e3 -08 -c5 -ed -e3 -cb -c5 -ed -e3 -08 -c4 -e3 -6d -4c -cb -40 -c4 -e3 -6d -4c -08 -40 -c4 -e3 -75 -0e -cb -03 -c4 -e3 -75 -0e -08 -03 -c4 -e3 -6d -0e -cb -03 -c4 -e3 -6d -0e -08 -03 -c5 -f5 -74 -cb -c5 -f5 -74 -08 -c5 -ed -74 -cb -c5 -ed -74 -08 -c5 -f5 -75 -cb -c5 -f5 -75 -08 -c5 -ed -75 -cb -c5 -ed -75 -08 -c5 -f5 -76 -cb -c5 -f5 -76 -08 -c5 -ed -76 -cb -c5 -ed -76 -08 -c4 -e2 -75 -29 -cb -c4 -e2 -75 -29 -08 -c4 -e2 -6d -29 -cb -c4 -e2 -6d -29 -08 -c5 -f5 -64 -cb -c5 -f5 -64 -08 -c5 -ed -64 -cb -c5 -ed -64 -08 -c5 -f5 -65 -cb -c5 -f5 -65 -08 -c5 -ed -65 -cb -c5 -ed -65 -08 -c5 -f5 -66 -cb -c5 -f5 -66 -08 -c5 -ed -66 -cb -c5 -ed -66 -08 -c4 -e2 -75 -37 -cb -c4 -e2 -75 -37 -08 -c4 -e2 -6d -37 -cb -c4 -e2 -6d -37 -08 -c4 -e2 -75 -01 -cb -c4 -e2 -75 -01 -08 -c4 -e2 -6d -01 -cb -c4 -e2 -6d -01 -08 -c4 -e2 -75 -02 -cb -c4 -e2 -75 -02 -08 -c4 -e2 -6d -02 -cb -c4 -e2 -6d -02 -08 -c4 -e2 -75 -03 -cb -c4 -e2 -75 -03 -08 -c4 -e2 -6d -03 -cb -c4 -e2 -6d -03 -08 -c4 -e2 -75 -05 -cb -c4 -e2 -75 -05 -08 -c4 -e2 -6d -05 -cb -c4 -e2 -6d -05 -08 -c4 -e2 -75 -06 -cb -c4 -e2 -75 -06 -08 -c4 -e2 -6d -06 -cb -c4 -e2 -6d -06 -08 -c4 -e2 -75 -07 -cb -c4 -e2 -75 -07 -08 -c4 -e2 -6d -07 -cb -c4 -e2 -6d -07 -08 -c4 -e2 -75 -04 -cb -c4 -e2 -75 -04 -08 -c4 -e2 -6d -04 -cb -c4 -e2 -6d -04 -08 -c5 -f5 -f5 -cb -c5 -f5 -f5 -08 -c5 -ed -f5 -cb -c5 -ed -f5 -08 -c4 -e2 -75 -3c -cb -c4 -e2 -75 -3c -08 -c4 -e2 -6d -3c -cb -c4 -e2 -6d -3c -08 -c5 -f5 -ee -cb -c5 -f5 -ee -08 -c5 -ed -ee -cb -c5 -ed -ee -08 -c4 -e2 -75 -3d -cb -c4 -e2 -75 -3d -08 -c4 -e2 -6d -3d -cb -c4 -e2 -6d -3d -08 -c5 -f5 -de -cb -c5 -f5 -de -08 -c5 -ed -de -cb -c5 -ed -de -08 -c4 -e2 -75 -3e -cb -c4 -e2 -75 -3e -08 -c4 -e2 -6d -3e -cb -c4 -e2 -6d -3e -08 -c4 -e2 -75 -3f -cb -c4 -e2 -75 -3f -08 -c4 -e2 -6d -3f -cb -c4 -e2 -6d -3f -08 -c4 -e2 -75 -38 -cb -c4 -e2 -75 -38 -08 -c4 -e2 -6d -38 -cb -c4 -e2 -6d -38 -08 -c5 -f5 -ea -cb -c5 -f5 -ea -08 -c5 -ed -ea -cb -c5 -ed -ea -08 -c4 -e2 -75 -39 -cb -c4 -e2 -75 -39 -08 -c4 -e2 -6d -39 -cb -c4 -e2 -6d -39 -08 -c5 -f5 -da -cb -c5 -f5 -da -08 -c5 -ed -da -cb -c5 -ed -da -08 -c4 -e2 -75 -3a -cb -c4 -e2 -75 -3a -08 -c4 -e2 -6d -3a -cb -c4 -e2 -6d -3a -08 -c4 -e2 -75 -3b -cb -c4 -e2 -75 -3b -08 -c4 -e2 -6d -3b -cb -c4 -e2 -6d -3b -08 -c5 -fd -d7 -c1 -c5 -fd -d7 -c1 -c4 -e2 -7d -20 -ca -c4 -e2 -7d -20 -08 -c4 -e2 -7d -20 -08 -c4 -e2 -7d -21 -ca -c4 -e2 -7d -21 -08 -c4 -e2 -7d -21 -08 -c4 -e2 -7d -22 -ca -c4 -e2 -7d -22 -08 -c4 -e2 -7d -22 -08 -c4 -e2 -7d -23 -ca -c4 -e2 -7d -23 -08 -c4 -e2 -7d -23 -08 -c4 -e2 -7d -24 -ca -c4 -e2 -7d -24 -08 -c4 -e2 -7d -24 -08 -c4 -e2 -7d -25 -ca -c4 -e2 -7d -25 -08 -c4 -e2 -7d -25 -08 -c4 -e2 -7d -30 -ca -c4 -e2 -7d -30 -08 -c4 -e2 -7d -30 -08 -c4 -e2 -7d -31 -ca -c4 -e2 -7d -31 -08 -c4 -e2 -7d -31 -08 -c4 -e2 -7d -32 -ca -c4 -e2 -7d -32 -08 -c4 -e2 -7d -32 -08 -c4 -e2 -7d -33 -ca -c4 -e2 -7d -33 -08 -c4 -e2 -7d -33 -08 -c4 -e2 -7d -34 -ca -c4 -e2 -7d -34 -08 -c4 -e2 -7d -34 -08 -c4 -e2 -7d -35 -ca -c4 -e2 -7d -35 -08 -c4 -e2 -7d -35 -08 -c4 -e2 -75 -28 -cb -c4 -e2 -75 -28 -08 -c4 -e2 -6d -28 -cb -c4 -e2 -6d -28 -08 -c4 -e2 -75 -0b -cb -c4 -e2 -75 -0b -08 -c4 -e2 -6d -0b -cb -c4 -e2 -6d -0b -08 -c5 -f5 -e4 -cb -c5 -f5 -e4 -08 -c5 -ed -e4 -cb -c5 -ed -e4 -08 -c5 -f5 -e5 -cb -c5 -f5 -e5 -08 -c5 -ed -e5 -cb -c5 -ed -e5 -08 -c5 -f5 -d5 -cb -c5 -f5 -d5 -08 -c5 -ed -d5 -cb -c5 -ed -d5 -08 -c4 -e2 -75 -40 -cb -c4 -e2 -75 -40 -08 -c4 -e2 -6d -40 -cb -c4 -e2 -6d -40 -08 -c5 -f5 -f4 -cb -c5 -f5 -f4 -08 -c5 -ed -f4 -cb -c5 -ed -f4 -08 -c5 -f5 -eb -cb -c5 -f5 -eb -08 -c5 -ed -eb -cb -c5 -ed -eb -08 -c5 -f5 -f6 -cb -c5 -f5 -f6 -08 -c5 -ed -f6 -cb -c5 -ed -f6 -08 -c4 -e2 -75 -00 -cb -c4 -e2 -75 -00 -08 -c4 -e2 -6d -00 -cb -c4 -e2 -6d -00 -08 -c5 -fd -70 -cb -03 -c5 -fd -70 -08 -03 -c5 -fe -70 -cb -03 -c5 -fe -70 -08 -03 -c5 -ff -70 -cb -03 -c5 -ff -70 -08 -03 -c4 -e2 -75 -08 -cb -c4 -e2 -75 -08 -08 -c4 -e2 -6d -08 -cb -c4 -e2 -6d -08 -08 -c4 -e2 -75 -09 -cb -c4 -e2 -75 -09 -08 -c4 -e2 -6d -09 -cb -c4 -e2 -6d -09 -08 -c4 -e2 -75 -0a -cb -c4 -e2 -75 -0a -08 -c4 -e2 -6d -0a -cb -c4 -e2 -6d -0a -08 -c5 -f5 -73 -f9 -03 -c5 -f5 -73 -fa -03 -c5 -f5 -f1 -cb -c5 -f5 -f1 -08 -c5 -f5 -71 -f1 -03 -c5 -ed -f1 -cb -c5 -ed -f1 -08 -c5 -f5 -71 -f2 -03 -c5 -f5 -f2 -cb -c5 -f5 -f2 -08 -c5 -f5 -72 -f1 -03 -c5 -ed -f2 -cb -c5 -ed -f2 -08 -c5 -f5 -72 -f2 -03 -c5 -f5 -f3 -cb -c5 -f5 -f3 -08 -c5 -f5 -73 -f1 -03 -c5 -ed -f3 -cb -c5 -ed -f3 -08 -c5 -f5 -73 -f2 -03 -c5 -f5 -e1 -cb -c5 -f5 -e1 -08 -c5 -f5 -71 -e1 -03 -c5 -ed -e1 -cb -c5 -ed -e1 -08 -c5 -f5 -71 -e2 -03 -c5 -f5 -e2 -cb -c5 -f5 -e2 -08 -c5 -f5 -72 -e1 -03 -c5 -ed -e2 -cb -c5 -ed -e2 -08 -c5 -f5 -72 -e2 -03 -c5 -f5 -73 -d9 -03 -c5 -f5 -73 -da -03 -c5 -f5 -d1 -cb -c5 -f5 -d1 -08 -c5 -f5 -71 -d1 -03 -c5 -ed -d1 -cb -c5 -ed -d1 -08 -c5 -f5 -71 -d2 -03 -c5 -f5 -d2 -cb -c5 -f5 -d2 -08 -c5 -f5 -72 -d1 -03 -c5 -ed -d2 -cb -c5 -ed -d2 -08 -c5 -f5 -72 -d2 -03 -c5 -f5 -d2 -cb -c5 -f5 -d2 -08 -c5 -f5 -72 -d1 -03 -c5 -ed -d2 -cb -c5 -ed -d2 -08 -c5 -f5 -72 -d2 -03 -c5 -f5 -e8 -cb -c5 -f5 -e8 -08 -c5 -ed -e8 -cb -c5 -ed -e8 -08 -c5 -f5 -e9 -cb -c5 -f5 -e9 -08 -c5 -ed -e9 -cb -c5 -ed -e9 -08 -c5 -f5 -d8 -cb -c5 -f5 -d8 -08 -c5 -ed -d8 -cb -c5 -ed -d8 -08 -c5 -f5 -d9 -cb -c5 -f5 -d9 -08 -c5 -ed -d9 -cb -c5 -ed -d9 -08 -c5 -f5 -68 -cb -c5 -f5 -68 -08 -c5 -ed -68 -cb -c5 -ed -68 -08 -c5 -f5 -69 -cb -c5 -f5 -69 -08 -c5 -ed -69 -cb -c5 -ed -69 -08 -c5 -f5 -6a -cb -c5 -f5 -6a -08 -c5 -ed -6a -cb -c5 -ed -6a -08 -c5 -f5 -6d -cb -c5 -f5 -6d -08 -c5 -ed -6d -cb -c5 -ed -6d -08 -c5 -f5 -60 -cb -c5 -f5 -60 -08 -c5 -ed -60 -cb -c5 -ed -60 -08 -c5 -f5 -61 -cb -c5 -f5 -61 -08 -c5 -ed -61 -cb -c5 -ed -61 -08 -c5 -f5 -62 -cb -c5 -f5 -62 -08 -c5 -ed -62 -cb -c5 -ed -62 -08 -c5 -f5 -6c -cb -c5 -f5 -6c -08 -c5 -ed -6c -cb -c5 -ed -6c -08 -c5 -f5 -ef -cb -c5 -f5 -ef -08 -c5 -ed -ef -cb -c5 -ed -ef -08 -c4 -e2 -7d -2a -08 -c4 -e2 -79 -18 -ca -c4 -e2 -7d -18 -ca -c4 -e2 -7d -19 -ca -c4 -e2 -7d -5a -08 -c4 -e3 -6d -02 -cb -03 -c4 -e3 -6d -02 -08 -03 -c4 -e2 -79 -78 -ca -c4 -e2 -79 -78 -08 -c4 -e2 -7d -78 -ca -c4 -e2 -7d -78 -08 -c4 -e2 -79 -79 -ca -c4 -e2 -79 -79 -08 -c4 -e2 -7d -79 -ca -c4 -e2 -7d -79 -08 -c4 -e2 -79 -58 -ca -c4 -e2 -79 -58 -08 -c4 -e2 -7d -58 -ca -c4 -e2 -7d -58 -08 -c4 -e2 -79 -59 -ca -c4 -e2 -79 -59 -08 -c4 -e2 -7d -59 -ca -c4 -e2 -7d -59 -08 -c4 -e2 -6d -36 -cb -c4 -e2 -6d -36 -08 -c4 -e3 -fd -01 -ca -03 -c4 -e3 -fd -01 -08 -03 -c4 -e2 -6d -16 -cb -c4 -e2 -6d -16 -08 -c4 -e3 -fd -00 -ca -03 -c4 -e3 -fd -00 -08 -03 -c4 -e3 -6d -46 -cb -03 -c4 -e3 -6d -46 -08 -03 -c4 -e3 -7d -39 -d1 -03 -c4 -e3 -7d -39 -10 -03 -c4 -e3 -6d -38 -cb -03 -c4 -e3 -6d -38 -08 -03 -c4 -e2 -69 -8c -08 -c4 -e2 -6d -8c -08 -c4 -e2 -71 -8e -10 -c4 -e2 -75 -8e -10 -c4 -e2 -e9 -8c -08 -c4 -e2 -ed -8c -08 -c4 -e2 -f1 -8e -10 -c4 -e2 -f5 -8e -10 -c4 -e2 -69 -47 -cb -c4 -e2 -69 -47 -08 -c4 -e2 -6d -47 -cb -c4 -e2 -6d -47 -08 -c4 -e2 -e9 -47 -cb -c4 -e2 -e9 -47 -08 -c4 -e2 -ed -47 -cb -c4 -e2 -ed -47 -08 -c4 -e2 -69 -46 -cb -c4 -e2 -69 -46 -08 -c4 -e2 -6d -46 -cb -c4 -e2 -6d -46 -08 -c4 -e2 -69 -45 -cb -c4 -e2 -69 -45 -08 -c4 -e2 -6d -45 -cb -c4 -e2 -6d -45 -08 -c4 -e2 -e9 -45 -cb -c4 -e2 -e9 -45 -08 -c4 -e2 -ed -45 -cb -c4 -e2 -ed -45 -08 -c4 -e2 -e9 -92 -0c -08 -c4 -e2 -e9 -92 -0c -08 -c4 -e2 -ed -92 -0c -08 -c4 -e2 -ed -92 -0c -08 -c4 -e2 -e9 -93 -0c -08 -c4 -e2 -e9 -93 -0c -08 -c4 -e2 -ed -93 -0c -08 -c4 -e2 -ed -93 -0c -08 -c4 -e2 -69 -92 -0c -08 -c4 -e2 -69 -92 -0c -08 -c4 -e2 -6d -92 -0c -08 -c4 -e2 -6d -92 -0c -08 -c4 -e2 -69 -93 -0c -08 -c4 -e2 -69 -93 -0c -08 -c4 -e2 -6d -93 -0c -08 -c4 -e2 -6d -93 -0c -08 -c4 -e2 -69 -90 -0c -08 -c4 -e2 -69 -90 -0c -08 -c4 -e2 -6d -90 -0c -08 -c4 -e2 -6d -90 -0c -08 -c4 -e2 -69 -91 -0c -08 -c4 -e2 -69 -91 -0c -08 -c4 -e2 -6d -91 -0c -08 -c4 -e2 -6d -91 -0c -08 -c4 -e2 -e9 -90 -0c -08 -c4 -e2 -e9 -90 -0c -08 -c4 -e2 -ed -90 -0c -08 -c4 -e2 -ed -90 -0c -08 -c4 -e2 -e9 -91 -0c -08 -c4 -e2 -e9 -91 -0c -08 -c4 -e2 -ed -91 -0c -08 -c4 -e2 -ed -91 -0c -08 diff --git a/modules/arch/x86/tests/avxcc.asm b/modules/arch/x86/tests/avxcc.asm deleted file mode 100644 index bcde2563..00000000 --- a/modules/arch/x86/tests/avxcc.asm +++ /dev/null @@ -1,899 +0,0 @@ -; Exhaustive test of AVX condition code aliases -; Also includes based-upon SSE instructions for comparison -; -; Copyright (C) 2008 Peter Johnson -; -; Redistribution and use in source and binary forms, with or without -; modification, are permitted provided that the following conditions -; are met: -; 1. Redistributions of source code must retain the above copyright -; notice, this list of conditions and the following disclaimer. -; 2. Redistributions in binary form must reproduce the above copyright -; notice, this list of conditions and the following disclaimer in the -; documentation and/or other materials provided with the distribution. -; -; THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND OTHER CONTRIBUTORS ``AS IS'' -; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -; ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR OTHER CONTRIBUTORS BE -; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -; POSSIBILITY OF SUCH DAMAGE. -; - -[bits 64] - -cmpeqpd xmm1, xmm2 ; 00h -cmpltpd xmm1, xmm2 ; 01h -cmplepd xmm1, xmm2 ; 02h -cmpunordpd xmm1, xmm2 ; 03h -cmpneqpd xmm1, xmm2 ; 04h -cmpnltpd xmm1, xmm2 ; 05h -cmpnlepd xmm1, xmm2 ; 06h -cmpordpd xmm1, xmm2 ; 07h - -vcmpeqpd xmm1, xmm2 ; 00h -vcmpltpd xmm1, xmm2 ; 01h -vcmplepd xmm1, xmm2 ; 02h -vcmpunordpd xmm1, xmm2 ; 03h -vcmpneqpd xmm1, xmm2 ; 04h -vcmpnltpd xmm1, xmm2 ; 05h -vcmpnlepd xmm1, xmm2 ; 06h -vcmpordpd xmm1, xmm2 ; 07h - -vcmpeqpd xmm1, xmm2, xmm3 ; 00h -vcmpltpd xmm1, xmm2, xmm3 ; 01h -vcmplepd xmm1, xmm2, xmm3 ; 02h -vcmpunordpd xmm1, xmm2, xmm3 ; 03h -vcmpneqpd xmm1, xmm2, xmm3 ; 04h -vcmpnltpd xmm1, xmm2, xmm3 ; 05h -vcmpnlepd xmm1, xmm2, xmm3 ; 06h -vcmpordpd xmm1, xmm2, xmm3 ; 07h - -vcmpeq_uqpd xmm1, xmm2, xmm3 ; 08h -vcmpngepd xmm1, xmm2, xmm3 ; 09h -vcmpngtpd xmm1, xmm2, xmm3 ; 0Ah -vcmpfalsepd xmm1, xmm2, xmm3 ; 0Bh -vcmpneq_oqpd xmm1, xmm2, xmm3 ; 0Ch -vcmpgepd xmm1, xmm2, xmm3 ; 0Dh -vcmpgtpd xmm1, xmm2, xmm3 ; 0Eh -vcmptruepd xmm1, xmm2, xmm3 ; 0Fh - -vcmpeq_ospd xmm1, xmm2, xmm3 ; 10h -vcmplt_oqpd xmm1, xmm2, xmm3 ; 11h -vcmple_oqpd xmm1, xmm2, xmm3 ; 12h -vcmpunord_spd xmm1, xmm2, xmm3 ; 13h -vcmpneq_uspd xmm1, xmm2, xmm3 ; 14h -vcmpnlt_uqpd xmm1, xmm2, xmm3 ; 15h -vcmpnle_uqpd xmm1, xmm2, xmm3 ; 16h -vcmpord_spd xmm1, xmm2, xmm3 ; 17h - -vcmpeq_uspd xmm1, xmm2, xmm3 ; 18h -vcmpnge_uqpd xmm1, xmm2, xmm3 ; 19h -vcmpngt_uqpd xmm1, xmm2, xmm3 ; 1Ah -vcmpfalse_ospd xmm1, xmm2, xmm3 ; 1Bh -vcmpneq_ospd xmm1, xmm2, xmm3 ; 1Ch -vcmpge_oqpd xmm1, xmm2, xmm3 ; 1Dh -vcmpgt_oqpd xmm1, xmm2, xmm3 ; 1Eh -vcmptrue_uspd xmm1, xmm2, xmm3 ; 1Fh - -cmpeqpd xmm1, [rax] ; 00h -cmpltpd xmm1, [rax] ; 01h -cmplepd xmm1, [rax] ; 02h -cmpunordpd xmm1, [rax] ; 03h -cmpneqpd xmm1, [rax] ; 04h -cmpnltpd xmm1, [rax] ; 05h -cmpnlepd xmm1, [rax] ; 06h -cmpordpd xmm1, [rax] ; 07h - -vcmpeqpd xmm1, [rax] ; 00h -vcmpltpd xmm1, [rax] ; 01h -vcmplepd xmm1, [rax] ; 02h -vcmpunordpd xmm1, [rax] ; 03h -vcmpneqpd xmm1, [rax] ; 04h -vcmpnltpd xmm1, [rax] ; 05h -vcmpnlepd xmm1, [rax] ; 06h -vcmpordpd xmm1, [rax] ; 07h - -vcmpeqpd xmm1, xmm2, [rax] ; 00h -vcmpltpd xmm1, xmm2, [rax] ; 01h -vcmplepd xmm1, xmm2, [rax] ; 02h -vcmpunordpd xmm1, xmm2, [rax] ; 03h -vcmpneqpd xmm1, xmm2, [rax] ; 04h -vcmpnltpd xmm1, xmm2, [rax] ; 05h -vcmpnlepd xmm1, xmm2, [rax] ; 06h -vcmpordpd xmm1, xmm2, [rax] ; 07h - -vcmpeq_uqpd xmm1, xmm2, [rax] ; 08h -vcmpngepd xmm1, xmm2, [rax] ; 09h -vcmpngtpd xmm1, xmm2, [rax] ; 0Ah -vcmpfalsepd xmm1, xmm2, [rax] ; 0Bh -vcmpneq_oqpd xmm1, xmm2, [rax] ; 0Ch -vcmpgepd xmm1, xmm2, [rax] ; 0Dh -vcmpgtpd xmm1, xmm2, [rax] ; 0Eh -vcmptruepd xmm1, xmm2, [rax] ; 0Fh - -vcmpeq_ospd xmm1, xmm2, [rax] ; 10h -vcmplt_oqpd xmm1, xmm2, [rax] ; 11h -vcmple_oqpd xmm1, xmm2, [rax] ; 12h -vcmpunord_spd xmm1, xmm2, [rax] ; 13h -vcmpneq_uspd xmm1, xmm2, [rax] ; 14h -vcmpnlt_uqpd xmm1, xmm2, [rax] ; 15h -vcmpnle_uqpd xmm1, xmm2, [rax] ; 16h -vcmpord_spd xmm1, xmm2, [rax] ; 17h - -vcmpeq_uspd xmm1, xmm2, [rax] ; 18h -vcmpnge_uqpd xmm1, xmm2, [rax] ; 19h -vcmpngt_uqpd xmm1, xmm2, [rax] ; 1Ah -vcmpfalse_ospd xmm1, xmm2, [rax] ; 1Bh -vcmpneq_ospd xmm1, xmm2, [rax] ; 1Ch -vcmpge_oqpd xmm1, xmm2, [rax] ; 1Dh -vcmpgt_oqpd xmm1, xmm2, [rax] ; 1Eh -vcmptrue_uspd xmm1, xmm2, [rax] ; 1Fh - -cmpeqpd xmm1, dqword [rax] ; 00h -cmpltpd xmm1, dqword [rax] ; 01h -cmplepd xmm1, dqword [rax] ; 02h -cmpunordpd xmm1, dqword [rax] ; 03h -cmpneqpd xmm1, dqword [rax] ; 04h -cmpnltpd xmm1, dqword [rax] ; 05h -cmpnlepd xmm1, dqword [rax] ; 06h -cmpordpd xmm1, dqword [rax] ; 07h - -vcmpeqpd xmm1, dqword [rax] ; 00h -vcmpltpd xmm1, dqword [rax] ; 01h -vcmplepd xmm1, dqword [rax] ; 02h -vcmpunordpd xmm1, dqword [rax] ; 03h -vcmpneqpd xmm1, dqword [rax] ; 04h -vcmpnltpd xmm1, dqword [rax] ; 05h -vcmpnlepd xmm1, dqword [rax] ; 06h -vcmpordpd xmm1, dqword [rax] ; 07h - -vcmpeqpd xmm1, xmm2, dqword [rax] ; 00h -vcmpltpd xmm1, xmm2, dqword [rax] ; 01h -vcmplepd xmm1, xmm2, dqword [rax] ; 02h -vcmpunordpd xmm1, xmm2, dqword [rax] ; 03h -vcmpneqpd xmm1, xmm2, dqword [rax] ; 04h -vcmpnltpd xmm1, xmm2, dqword [rax] ; 05h -vcmpnlepd xmm1, xmm2, dqword [rax] ; 06h -vcmpordpd xmm1, xmm2, dqword [rax] ; 07h - -vcmpeq_uqpd xmm1, xmm2, dqword [rax] ; 08h -vcmpngepd xmm1, xmm2, dqword [rax] ; 09h -vcmpngtpd xmm1, xmm2, dqword [rax] ; 0Ah -vcmpfalsepd xmm1, xmm2, dqword [rax] ; 0Bh -vcmpneq_oqpd xmm1, xmm2, dqword [rax] ; 0Ch -vcmpgepd xmm1, xmm2, dqword [rax] ; 0Dh -vcmpgtpd xmm1, xmm2, dqword [rax] ; 0Eh -vcmptruepd xmm1, xmm2, dqword [rax] ; 0Fh - -vcmpeq_ospd xmm1, xmm2, dqword [rax] ; 10h -vcmplt_oqpd xmm1, xmm2, dqword [rax] ; 11h -vcmple_oqpd xmm1, xmm2, dqword [rax] ; 12h -vcmpunord_spd xmm1, xmm2, dqword [rax] ; 13h -vcmpneq_uspd xmm1, xmm2, dqword [rax] ; 14h -vcmpnlt_uqpd xmm1, xmm2, dqword [rax] ; 15h -vcmpnle_uqpd xmm1, xmm2, dqword [rax] ; 16h -vcmpord_spd xmm1, xmm2, dqword [rax] ; 17h - -vcmpeq_uspd xmm1, xmm2, dqword [rax] ; 18h -vcmpnge_uqpd xmm1, xmm2, dqword [rax] ; 19h -vcmpngt_uqpd xmm1, xmm2, dqword [rax] ; 1Ah -vcmpfalse_ospd xmm1, xmm2, dqword [rax] ; 1Bh -vcmpneq_ospd xmm1, xmm2, dqword [rax] ; 1Ch -vcmpge_oqpd xmm1, xmm2, dqword [rax] ; 1Dh -vcmpgt_oqpd xmm1, xmm2, dqword [rax] ; 1Eh -vcmptrue_uspd xmm1, xmm2, dqword [rax] ; 1Fh - -vcmpeqpd ymm1, ymm2, ymm3 ; 00h -vcmpltpd ymm1, ymm2, ymm3 ; 01h -vcmplepd ymm1, ymm2, ymm3 ; 02h -vcmpunordpd ymm1, ymm2, ymm3 ; 03h -vcmpneqpd ymm1, ymm2, ymm3 ; 04h -vcmpnltpd ymm1, ymm2, ymm3 ; 05h -vcmpnlepd ymm1, ymm2, ymm3 ; 06h -vcmpordpd ymm1, ymm2, ymm3 ; 07h - -vcmpeq_uqpd ymm1, ymm2, ymm3 ; 08h -vcmpngepd ymm1, ymm2, ymm3 ; 09h -vcmpngtpd ymm1, ymm2, ymm3 ; 0Ah -vcmpfalsepd ymm1, ymm2, ymm3 ; 0Bh -vcmpneq_oqpd ymm1, ymm2, ymm3 ; 0Ch -vcmpgepd ymm1, ymm2, ymm3 ; 0Dh -vcmpgtpd ymm1, ymm2, ymm3 ; 0Eh -vcmptruepd ymm1, ymm2, ymm3 ; 0Fh - -vcmpeq_ospd ymm1, ymm2, ymm3 ; 10h -vcmplt_oqpd ymm1, ymm2, ymm3 ; 11h -vcmple_oqpd ymm1, ymm2, ymm3 ; 12h -vcmpunord_spd ymm1, ymm2, ymm3 ; 13h -vcmpneq_uspd ymm1, ymm2, ymm3 ; 14h -vcmpnlt_uqpd ymm1, ymm2, ymm3 ; 15h -vcmpnle_uqpd ymm1, ymm2, ymm3 ; 16h -vcmpord_spd ymm1, ymm2, ymm3 ; 17h - -vcmpeq_uspd ymm1, ymm2, ymm3 ; 18h -vcmpnge_uqpd ymm1, ymm2, ymm3 ; 19h -vcmpngt_uqpd ymm1, ymm2, ymm3 ; 1Ah -vcmpfalse_ospd ymm1, ymm2, ymm3 ; 1Bh -vcmpneq_ospd ymm1, ymm2, ymm3 ; 1Ch -vcmpge_oqpd ymm1, ymm2, ymm3 ; 1Dh -vcmpgt_oqpd ymm1, ymm2, ymm3 ; 1Eh -vcmptrue_uspd ymm1, ymm2, ymm3 ; 1Fh - -vcmpeqpd ymm1, ymm2, [rax] ; 00h -vcmpltpd ymm1, ymm2, [rax] ; 01h -vcmplepd ymm1, ymm2, [rax] ; 02h -vcmpunordpd ymm1, ymm2, [rax] ; 03h -vcmpneqpd ymm1, ymm2, [rax] ; 04h -vcmpnltpd ymm1, ymm2, [rax] ; 05h -vcmpnlepd ymm1, ymm2, [rax] ; 06h -vcmpordpd ymm1, ymm2, [rax] ; 07h - -vcmpeq_uqpd ymm1, ymm2, [rax] ; 08h -vcmpngepd ymm1, ymm2, [rax] ; 09h -vcmpngtpd ymm1, ymm2, [rax] ; 0Ah -vcmpfalsepd ymm1, ymm2, [rax] ; 0Bh -vcmpneq_oqpd ymm1, ymm2, [rax] ; 0Ch -vcmpgepd ymm1, ymm2, [rax] ; 0Dh -vcmpgtpd ymm1, ymm2, [rax] ; 0Eh -vcmptruepd ymm1, ymm2, [rax] ; 0Fh - -vcmpeq_ospd ymm1, ymm2, [rax] ; 10h -vcmplt_oqpd ymm1, ymm2, [rax] ; 11h -vcmple_oqpd ymm1, ymm2, [rax] ; 12h -vcmpunord_spd ymm1, ymm2, [rax] ; 13h -vcmpneq_uspd ymm1, ymm2, [rax] ; 14h -vcmpnlt_uqpd ymm1, ymm2, [rax] ; 15h -vcmpnle_uqpd ymm1, ymm2, [rax] ; 16h -vcmpord_spd ymm1, ymm2, [rax] ; 17h - -vcmpeq_uspd ymm1, ymm2, [rax] ; 18h -vcmpnge_uqpd ymm1, ymm2, [rax] ; 19h -vcmpngt_uqpd ymm1, ymm2, [rax] ; 1Ah -vcmpfalse_ospd ymm1, ymm2, [rax] ; 1Bh -vcmpneq_ospd ymm1, ymm2, [rax] ; 1Ch -vcmpge_oqpd ymm1, ymm2, [rax] ; 1Dh -vcmpgt_oqpd ymm1, ymm2, [rax] ; 1Eh -vcmptrue_uspd ymm1, ymm2, [rax] ; 1Fh - -vcmpeqpd ymm1, ymm2, yword [rax] ; 00h -vcmpltpd ymm1, ymm2, yword [rax] ; 01h -vcmplepd ymm1, ymm2, yword [rax] ; 02h -vcmpunordpd ymm1, ymm2, yword [rax] ; 03h -vcmpneqpd ymm1, ymm2, yword [rax] ; 04h -vcmpnltpd ymm1, ymm2, yword [rax] ; 05h -vcmpnlepd ymm1, ymm2, yword [rax] ; 06h -vcmpordpd ymm1, ymm2, yword [rax] ; 07h - -vcmpeq_uqpd ymm1, ymm2, yword [rax] ; 08h -vcmpngepd ymm1, ymm2, yword [rax] ; 09h -vcmpngtpd ymm1, ymm2, yword [rax] ; 0Ah -vcmpfalsepd ymm1, ymm2, yword [rax] ; 0Bh -vcmpneq_oqpd ymm1, ymm2, yword [rax] ; 0Ch -vcmpgepd ymm1, ymm2, yword [rax] ; 0Dh -vcmpgtpd ymm1, ymm2, yword [rax] ; 0Eh -vcmptruepd ymm1, ymm2, yword [rax] ; 0Fh - -vcmpeq_ospd ymm1, ymm2, yword [rax] ; 10h -vcmplt_oqpd ymm1, ymm2, yword [rax] ; 11h -vcmple_oqpd ymm1, ymm2, yword [rax] ; 12h -vcmpunord_spd ymm1, ymm2, yword [rax] ; 13h -vcmpneq_uspd ymm1, ymm2, yword [rax] ; 14h -vcmpnlt_uqpd ymm1, ymm2, yword [rax] ; 15h -vcmpnle_uqpd ymm1, ymm2, yword [rax] ; 16h -vcmpord_spd ymm1, ymm2, yword [rax] ; 17h - -vcmpeq_uspd ymm1, ymm2, yword [rax] ; 18h -vcmpnge_uqpd ymm1, ymm2, yword [rax] ; 19h -vcmpngt_uqpd ymm1, ymm2, yword [rax] ; 1Ah -vcmpfalse_ospd ymm1, ymm2, yword [rax] ; 1Bh -vcmpneq_ospd ymm1, ymm2, yword [rax] ; 1Ch -vcmpge_oqpd ymm1, ymm2, yword [rax] ; 1Dh -vcmpgt_oqpd ymm1, ymm2, yword [rax] ; 1Eh -vcmptrue_uspd ymm1, ymm2, yword [rax] ; 1Fh - -;----------------------------------------------------------------------------- - -cmpeqps xmm1, xmm2 ; 00h -cmpltps xmm1, xmm2 ; 01h -cmpleps xmm1, xmm2 ; 02h -cmpunordps xmm1, xmm2 ; 03h -cmpneqps xmm1, xmm2 ; 04h -cmpnltps xmm1, xmm2 ; 05h -cmpnleps xmm1, xmm2 ; 06h -cmpordps xmm1, xmm2 ; 07h - -vcmpeqps xmm1, xmm2 ; 00h -vcmpltps xmm1, xmm2 ; 01h -vcmpleps xmm1, xmm2 ; 02h -vcmpunordps xmm1, xmm2 ; 03h -vcmpneqps xmm1, xmm2 ; 04h -vcmpnltps xmm1, xmm2 ; 05h -vcmpnleps xmm1, xmm2 ; 06h -vcmpordps xmm1, xmm2 ; 07h - -vcmpeqps xmm1, xmm2, xmm3 ; 00h -vcmpltps xmm1, xmm2, xmm3 ; 01h -vcmpleps xmm1, xmm2, xmm3 ; 02h -vcmpunordps xmm1, xmm2, xmm3 ; 03h -vcmpneqps xmm1, xmm2, xmm3 ; 04h -vcmpnltps xmm1, xmm2, xmm3 ; 05h -vcmpnleps xmm1, xmm2, xmm3 ; 06h -vcmpordps xmm1, xmm2, xmm3 ; 07h - -vcmpeq_uqps xmm1, xmm2, xmm3 ; 08h -vcmpngeps xmm1, xmm2, xmm3 ; 09h -vcmpngtps xmm1, xmm2, xmm3 ; 0Ah -vcmpfalseps xmm1, xmm2, xmm3 ; 0Bh -vcmpneq_oqps xmm1, xmm2, xmm3 ; 0Ch -vcmpgeps xmm1, xmm2, xmm3 ; 0Dh -vcmpgtps xmm1, xmm2, xmm3 ; 0Eh -vcmptrueps xmm1, xmm2, xmm3 ; 0Fh - -vcmpeq_osps xmm1, xmm2, xmm3 ; 10h -vcmplt_oqps xmm1, xmm2, xmm3 ; 11h -vcmple_oqps xmm1, xmm2, xmm3 ; 12h -vcmpunord_sps xmm1, xmm2, xmm3 ; 13h -vcmpneq_usps xmm1, xmm2, xmm3 ; 14h -vcmpnlt_uqps xmm1, xmm2, xmm3 ; 15h -vcmpnle_uqps xmm1, xmm2, xmm3 ; 16h -vcmpord_sps xmm1, xmm2, xmm3 ; 17h - -vcmpeq_usps xmm1, xmm2, xmm3 ; 18h -vcmpnge_uqps xmm1, xmm2, xmm3 ; 19h -vcmpngt_uqps xmm1, xmm2, xmm3 ; 1Ah -vcmpfalse_osps xmm1, xmm2, xmm3 ; 1Bh -vcmpneq_osps xmm1, xmm2, xmm3 ; 1Ch -vcmpge_oqps xmm1, xmm2, xmm3 ; 1Dh -vcmpgt_oqps xmm1, xmm2, xmm3 ; 1Eh -vcmptrue_usps xmm1, xmm2, xmm3 ; 1Fh - -cmpeqps xmm1, [rax] ; 00h -cmpltps xmm1, [rax] ; 01h -cmpleps xmm1, [rax] ; 02h -cmpunordps xmm1, [rax] ; 03h -cmpneqps xmm1, [rax] ; 04h -cmpnltps xmm1, [rax] ; 05h -cmpnleps xmm1, [rax] ; 06h -cmpordps xmm1, [rax] ; 07h - -vcmpeqps xmm1, [rax] ; 00h -vcmpltps xmm1, [rax] ; 01h -vcmpleps xmm1, [rax] ; 02h -vcmpunordps xmm1, [rax] ; 03h -vcmpneqps xmm1, [rax] ; 04h -vcmpnltps xmm1, [rax] ; 05h -vcmpnleps xmm1, [rax] ; 06h -vcmpordps xmm1, [rax] ; 07h - -vcmpeqps xmm1, xmm2, [rax] ; 00h -vcmpltps xmm1, xmm2, [rax] ; 01h -vcmpleps xmm1, xmm2, [rax] ; 02h -vcmpunordps xmm1, xmm2, [rax] ; 03h -vcmpneqps xmm1, xmm2, [rax] ; 04h -vcmpnltps xmm1, xmm2, [rax] ; 05h -vcmpnleps xmm1, xmm2, [rax] ; 06h -vcmpordps xmm1, xmm2, [rax] ; 07h - -vcmpeq_uqps xmm1, xmm2, [rax] ; 08h -vcmpngeps xmm1, xmm2, [rax] ; 09h -vcmpngtps xmm1, xmm2, [rax] ; 0Ah -vcmpfalseps xmm1, xmm2, [rax] ; 0Bh -vcmpneq_oqps xmm1, xmm2, [rax] ; 0Ch -vcmpgeps xmm1, xmm2, [rax] ; 0Dh -vcmpgtps xmm1, xmm2, [rax] ; 0Eh -vcmptrueps xmm1, xmm2, [rax] ; 0Fh - -vcmpeq_osps xmm1, xmm2, [rax] ; 10h -vcmplt_oqps xmm1, xmm2, [rax] ; 11h -vcmple_oqps xmm1, xmm2, [rax] ; 12h -vcmpunord_sps xmm1, xmm2, [rax] ; 13h -vcmpneq_usps xmm1, xmm2, [rax] ; 14h -vcmpnlt_uqps xmm1, xmm2, [rax] ; 15h -vcmpnle_uqps xmm1, xmm2, [rax] ; 16h -vcmpord_sps xmm1, xmm2, [rax] ; 17h - -vcmpeq_usps xmm1, xmm2, [rax] ; 18h -vcmpnge_uqps xmm1, xmm2, [rax] ; 19h -vcmpngt_uqps xmm1, xmm2, [rax] ; 1Ah -vcmpfalse_osps xmm1, xmm2, [rax] ; 1Bh -vcmpneq_osps xmm1, xmm2, [rax] ; 1Ch -vcmpge_oqps xmm1, xmm2, [rax] ; 1Dh -vcmpgt_oqps xmm1, xmm2, [rax] ; 1Eh -vcmptrue_usps xmm1, xmm2, [rax] ; 1Fh - -cmpeqps xmm1, dqword [rax] ; 00h -cmpltps xmm1, dqword [rax] ; 01h -cmpleps xmm1, dqword [rax] ; 02h -cmpunordps xmm1, dqword [rax] ; 03h -cmpneqps xmm1, dqword [rax] ; 04h -cmpnltps xmm1, dqword [rax] ; 05h -cmpnleps xmm1, dqword [rax] ; 06h -cmpordps xmm1, dqword [rax] ; 07h - -vcmpeqps xmm1, dqword [rax] ; 00h -vcmpltps xmm1, dqword [rax] ; 01h -vcmpleps xmm1, dqword [rax] ; 02h -vcmpunordps xmm1, dqword [rax] ; 03h -vcmpneqps xmm1, dqword [rax] ; 04h -vcmpnltps xmm1, dqword [rax] ; 05h -vcmpnleps xmm1, dqword [rax] ; 06h -vcmpordps xmm1, dqword [rax] ; 07h - -vcmpeqps xmm1, xmm2, dqword [rax] ; 00h -vcmpltps xmm1, xmm2, dqword [rax] ; 01h -vcmpleps xmm1, xmm2, dqword [rax] ; 02h -vcmpunordps xmm1, xmm2, dqword [rax] ; 03h -vcmpneqps xmm1, xmm2, dqword [rax] ; 04h -vcmpnltps xmm1, xmm2, dqword [rax] ; 05h -vcmpnleps xmm1, xmm2, dqword [rax] ; 06h -vcmpordps xmm1, xmm2, dqword [rax] ; 07h - -vcmpeq_uqps xmm1, xmm2, dqword [rax] ; 08h -vcmpngeps xmm1, xmm2, dqword [rax] ; 09h -vcmpngtps xmm1, xmm2, dqword [rax] ; 0Ah -vcmpfalseps xmm1, xmm2, dqword [rax] ; 0Bh -vcmpneq_oqps xmm1, xmm2, dqword [rax] ; 0Ch -vcmpgeps xmm1, xmm2, dqword [rax] ; 0Dh -vcmpgtps xmm1, xmm2, dqword [rax] ; 0Eh -vcmptrueps xmm1, xmm2, dqword [rax] ; 0Fh - -vcmpeq_osps xmm1, xmm2, dqword [rax] ; 10h -vcmplt_oqps xmm1, xmm2, dqword [rax] ; 11h -vcmple_oqps xmm1, xmm2, dqword [rax] ; 12h -vcmpunord_sps xmm1, xmm2, dqword [rax] ; 13h -vcmpneq_usps xmm1, xmm2, dqword [rax] ; 14h -vcmpnlt_uqps xmm1, xmm2, dqword [rax] ; 15h -vcmpnle_uqps xmm1, xmm2, dqword [rax] ; 16h -vcmpord_sps xmm1, xmm2, dqword [rax] ; 17h - -vcmpeq_usps xmm1, xmm2, dqword [rax] ; 18h -vcmpnge_uqps xmm1, xmm2, dqword [rax] ; 19h -vcmpngt_uqps xmm1, xmm2, dqword [rax] ; 1Ah -vcmpfalse_osps xmm1, xmm2, dqword [rax] ; 1Bh -vcmpneq_osps xmm1, xmm2, dqword [rax] ; 1Ch -vcmpge_oqps xmm1, xmm2, dqword [rax] ; 1Dh -vcmpgt_oqps xmm1, xmm2, dqword [rax] ; 1Eh -vcmptrue_usps xmm1, xmm2, dqword [rax] ; 1Fh - -vcmpeqps ymm1, ymm2, ymm3 ; 00h -vcmpltps ymm1, ymm2, ymm3 ; 01h -vcmpleps ymm1, ymm2, ymm3 ; 02h -vcmpunordps ymm1, ymm2, ymm3 ; 03h -vcmpneqps ymm1, ymm2, ymm3 ; 04h -vcmpnltps ymm1, ymm2, ymm3 ; 05h -vcmpnleps ymm1, ymm2, ymm3 ; 06h -vcmpordps ymm1, ymm2, ymm3 ; 07h - -vcmpeq_uqps ymm1, ymm2, ymm3 ; 08h -vcmpngeps ymm1, ymm2, ymm3 ; 09h -vcmpngtps ymm1, ymm2, ymm3 ; 0Ah -vcmpfalseps ymm1, ymm2, ymm3 ; 0Bh -vcmpneq_oqps ymm1, ymm2, ymm3 ; 0Ch -vcmpgeps ymm1, ymm2, ymm3 ; 0Dh -vcmpgtps ymm1, ymm2, ymm3 ; 0Eh -vcmptrueps ymm1, ymm2, ymm3 ; 0Fh - -vcmpeq_osps ymm1, ymm2, ymm3 ; 10h -vcmplt_oqps ymm1, ymm2, ymm3 ; 11h -vcmple_oqps ymm1, ymm2, ymm3 ; 12h -vcmpunord_sps ymm1, ymm2, ymm3 ; 13h -vcmpneq_usps ymm1, ymm2, ymm3 ; 14h -vcmpnlt_uqps ymm1, ymm2, ymm3 ; 15h -vcmpnle_uqps ymm1, ymm2, ymm3 ; 16h -vcmpord_sps ymm1, ymm2, ymm3 ; 17h - -vcmpeq_usps ymm1, ymm2, ymm3 ; 18h -vcmpnge_uqps ymm1, ymm2, ymm3 ; 19h -vcmpngt_uqps ymm1, ymm2, ymm3 ; 1Ah -vcmpfalse_osps ymm1, ymm2, ymm3 ; 1Bh -vcmpneq_osps ymm1, ymm2, ymm3 ; 1Ch -vcmpge_oqps ymm1, ymm2, ymm3 ; 1Dh -vcmpgt_oqps ymm1, ymm2, ymm3 ; 1Eh -vcmptrue_usps ymm1, ymm2, ymm3 ; 1Fh - -vcmpeqps ymm1, ymm2, [rax] ; 00h -vcmpltps ymm1, ymm2, [rax] ; 01h -vcmpleps ymm1, ymm2, [rax] ; 02h -vcmpunordps ymm1, ymm2, [rax] ; 03h -vcmpneqps ymm1, ymm2, [rax] ; 04h -vcmpnltps ymm1, ymm2, [rax] ; 05h -vcmpnleps ymm1, ymm2, [rax] ; 06h -vcmpordps ymm1, ymm2, [rax] ; 07h - -vcmpeq_uqps ymm1, ymm2, [rax] ; 08h -vcmpngeps ymm1, ymm2, [rax] ; 09h -vcmpngtps ymm1, ymm2, [rax] ; 0Ah -vcmpfalseps ymm1, ymm2, [rax] ; 0Bh -vcmpneq_oqps ymm1, ymm2, [rax] ; 0Ch -vcmpgeps ymm1, ymm2, [rax] ; 0Dh -vcmpgtps ymm1, ymm2, [rax] ; 0Eh -vcmptrueps ymm1, ymm2, [rax] ; 0Fh - -vcmpeq_osps ymm1, ymm2, [rax] ; 10h -vcmplt_oqps ymm1, ymm2, [rax] ; 11h -vcmple_oqps ymm1, ymm2, [rax] ; 12h -vcmpunord_sps ymm1, ymm2, [rax] ; 13h -vcmpneq_usps ymm1, ymm2, [rax] ; 14h -vcmpnlt_uqps ymm1, ymm2, [rax] ; 15h -vcmpnle_uqps ymm1, ymm2, [rax] ; 16h -vcmpord_sps ymm1, ymm2, [rax] ; 17h - -vcmpeq_usps ymm1, ymm2, [rax] ; 18h -vcmpnge_uqps ymm1, ymm2, [rax] ; 19h -vcmpngt_uqps ymm1, ymm2, [rax] ; 1Ah -vcmpfalse_osps ymm1, ymm2, [rax] ; 1Bh -vcmpneq_osps ymm1, ymm2, [rax] ; 1Ch -vcmpge_oqps ymm1, ymm2, [rax] ; 1Dh -vcmpgt_oqps ymm1, ymm2, [rax] ; 1Eh -vcmptrue_usps ymm1, ymm2, [rax] ; 1Fh - -vcmpeqps ymm1, ymm2, yword [rax] ; 00h -vcmpltps ymm1, ymm2, yword [rax] ; 01h -vcmpleps ymm1, ymm2, yword [rax] ; 02h -vcmpunordps ymm1, ymm2, yword [rax] ; 03h -vcmpneqps ymm1, ymm2, yword [rax] ; 04h -vcmpnltps ymm1, ymm2, yword [rax] ; 05h -vcmpnleps ymm1, ymm2, yword [rax] ; 06h -vcmpordps ymm1, ymm2, yword [rax] ; 07h - -vcmpeq_uqps ymm1, ymm2, yword [rax] ; 08h -vcmpngeps ymm1, ymm2, yword [rax] ; 09h -vcmpngtps ymm1, ymm2, yword [rax] ; 0Ah -vcmpfalseps ymm1, ymm2, yword [rax] ; 0Bh -vcmpneq_oqps ymm1, ymm2, yword [rax] ; 0Ch -vcmpgeps ymm1, ymm2, yword [rax] ; 0Dh -vcmpgtps ymm1, ymm2, yword [rax] ; 0Eh -vcmptrueps ymm1, ymm2, yword [rax] ; 0Fh - -vcmpeq_osps ymm1, ymm2, yword [rax] ; 10h -vcmplt_oqps ymm1, ymm2, yword [rax] ; 11h -vcmple_oqps ymm1, ymm2, yword [rax] ; 12h -vcmpunord_sps ymm1, ymm2, yword [rax] ; 13h -vcmpneq_usps ymm1, ymm2, yword [rax] ; 14h -vcmpnlt_uqps ymm1, ymm2, yword [rax] ; 15h -vcmpnle_uqps ymm1, ymm2, yword [rax] ; 16h -vcmpord_sps ymm1, ymm2, yword [rax] ; 17h - -vcmpeq_usps ymm1, ymm2, yword [rax] ; 18h -vcmpnge_uqps ymm1, ymm2, yword [rax] ; 19h -vcmpngt_uqps ymm1, ymm2, yword [rax] ; 1Ah -vcmpfalse_osps ymm1, ymm2, yword [rax] ; 1Bh -vcmpneq_osps ymm1, ymm2, yword [rax] ; 1Ch -vcmpge_oqps ymm1, ymm2, yword [rax] ; 1Dh -vcmpgt_oqps ymm1, ymm2, yword [rax] ; 1Eh -vcmptrue_usps ymm1, ymm2, yword [rax] ; 1Fh - -;----------------------------------------------------------------------------- - -cmpeqsd xmm1, xmm2 ; 00h -cmpltsd xmm1, xmm2 ; 01h -cmplesd xmm1, xmm2 ; 02h -cmpunordsd xmm1, xmm2 ; 03h -cmpneqsd xmm1, xmm2 ; 04h -cmpnltsd xmm1, xmm2 ; 05h -cmpnlesd xmm1, xmm2 ; 06h -cmpordsd xmm1, xmm2 ; 07h - -vcmpeqsd xmm1, xmm2 ; 00h -vcmpltsd xmm1, xmm2 ; 01h -vcmplesd xmm1, xmm2 ; 02h -vcmpunordsd xmm1, xmm2 ; 03h -vcmpneqsd xmm1, xmm2 ; 04h -vcmpnltsd xmm1, xmm2 ; 05h -vcmpnlesd xmm1, xmm2 ; 06h -vcmpordsd xmm1, xmm2 ; 07h - -vcmpeqsd xmm1, xmm2, xmm3 ; 00h -vcmpltsd xmm1, xmm2, xmm3 ; 01h -vcmplesd xmm1, xmm2, xmm3 ; 02h -vcmpunordsd xmm1, xmm2, xmm3 ; 03h -vcmpneqsd xmm1, xmm2, xmm3 ; 04h -vcmpnltsd xmm1, xmm2, xmm3 ; 05h -vcmpnlesd xmm1, xmm2, xmm3 ; 06h -vcmpordsd xmm1, xmm2, xmm3 ; 07h - -vcmpeq_uqsd xmm1, xmm2, xmm3 ; 08h -vcmpngesd xmm1, xmm2, xmm3 ; 09h -vcmpngtsd xmm1, xmm2, xmm3 ; 0Ah -vcmpfalsesd xmm1, xmm2, xmm3 ; 0Bh -vcmpneq_oqsd xmm1, xmm2, xmm3 ; 0Ch -vcmpgesd xmm1, xmm2, xmm3 ; 0Dh -vcmpgtsd xmm1, xmm2, xmm3 ; 0Eh -vcmptruesd xmm1, xmm2, xmm3 ; 0Fh - -vcmpeq_ossd xmm1, xmm2, xmm3 ; 10h -vcmplt_oqsd xmm1, xmm2, xmm3 ; 11h -vcmple_oqsd xmm1, xmm2, xmm3 ; 12h -vcmpunord_ssd xmm1, xmm2, xmm3 ; 13h -vcmpneq_ussd xmm1, xmm2, xmm3 ; 14h -vcmpnlt_uqsd xmm1, xmm2, xmm3 ; 15h -vcmpnle_uqsd xmm1, xmm2, xmm3 ; 16h -vcmpord_ssd xmm1, xmm2, xmm3 ; 17h - -vcmpeq_ussd xmm1, xmm2, xmm3 ; 18h -vcmpnge_uqsd xmm1, xmm2, xmm3 ; 19h -vcmpngt_uqsd xmm1, xmm2, xmm3 ; 1Ah -vcmpfalse_ossd xmm1, xmm2, xmm3 ; 1Bh -vcmpneq_ossd xmm1, xmm2, xmm3 ; 1Ch -vcmpge_oqsd xmm1, xmm2, xmm3 ; 1Dh -vcmpgt_oqsd xmm1, xmm2, xmm3 ; 1Eh -vcmptrue_ussd xmm1, xmm2, xmm3 ; 1Fh - -cmpeqsd xmm1, [rax] ; 00h -cmpltsd xmm1, [rax] ; 01h -cmplesd xmm1, [rax] ; 02h -cmpunordsd xmm1, [rax] ; 03h -cmpneqsd xmm1, [rax] ; 04h -cmpnltsd xmm1, [rax] ; 05h -cmpnlesd xmm1, [rax] ; 06h -cmpordsd xmm1, [rax] ; 07h - -vcmpeqsd xmm1, [rax] ; 00h -vcmpltsd xmm1, [rax] ; 01h -vcmplesd xmm1, [rax] ; 02h -vcmpunordsd xmm1, [rax] ; 03h -vcmpneqsd xmm1, [rax] ; 04h -vcmpnltsd xmm1, [rax] ; 05h -vcmpnlesd xmm1, [rax] ; 06h -vcmpordsd xmm1, [rax] ; 07h - -vcmpeqsd xmm1, xmm2, [rax] ; 00h -vcmpltsd xmm1, xmm2, [rax] ; 01h -vcmplesd xmm1, xmm2, [rax] ; 02h -vcmpunordsd xmm1, xmm2, [rax] ; 03h -vcmpneqsd xmm1, xmm2, [rax] ; 04h -vcmpnltsd xmm1, xmm2, [rax] ; 05h -vcmpnlesd xmm1, xmm2, [rax] ; 06h -vcmpordsd xmm1, xmm2, [rax] ; 07h - -vcmpeq_uqsd xmm1, xmm2, [rax] ; 08h -vcmpngesd xmm1, xmm2, [rax] ; 09h -vcmpngtsd xmm1, xmm2, [rax] ; 0Ah -vcmpfalsesd xmm1, xmm2, [rax] ; 0Bh -vcmpneq_oqsd xmm1, xmm2, [rax] ; 0Ch -vcmpgesd xmm1, xmm2, [rax] ; 0Dh -vcmpgtsd xmm1, xmm2, [rax] ; 0Eh -vcmptruesd xmm1, xmm2, [rax] ; 0Fh - -vcmpeq_ossd xmm1, xmm2, [rax] ; 10h -vcmplt_oqsd xmm1, xmm2, [rax] ; 11h -vcmple_oqsd xmm1, xmm2, [rax] ; 12h -vcmpunord_ssd xmm1, xmm2, [rax] ; 13h -vcmpneq_ussd xmm1, xmm2, [rax] ; 14h -vcmpnlt_uqsd xmm1, xmm2, [rax] ; 15h -vcmpnle_uqsd xmm1, xmm2, [rax] ; 16h -vcmpord_ssd xmm1, xmm2, [rax] ; 17h - -vcmpeq_ussd xmm1, xmm2, [rax] ; 18h -vcmpnge_uqsd xmm1, xmm2, [rax] ; 19h -vcmpngt_uqsd xmm1, xmm2, [rax] ; 1Ah -vcmpfalse_ossd xmm1, xmm2, [rax] ; 1Bh -vcmpneq_ossd xmm1, xmm2, [rax] ; 1Ch -vcmpge_oqsd xmm1, xmm2, [rax] ; 1Dh -vcmpgt_oqsd xmm1, xmm2, [rax] ; 1Eh -vcmptrue_ussd xmm1, xmm2, [rax] ; 1Fh - -cmpeqsd xmm1, qword [rax] ; 00h -cmpltsd xmm1, qword [rax] ; 01h -cmplesd xmm1, qword [rax] ; 02h -cmpunordsd xmm1, qword [rax] ; 03h -cmpneqsd xmm1, qword [rax] ; 04h -cmpnltsd xmm1, qword [rax] ; 05h -cmpnlesd xmm1, qword [rax] ; 06h -cmpordsd xmm1, qword [rax] ; 07h - -vcmpeqsd xmm1, qword [rax] ; 00h -vcmpltsd xmm1, qword [rax] ; 01h -vcmplesd xmm1, qword [rax] ; 02h -vcmpunordsd xmm1, qword [rax] ; 03h -vcmpneqsd xmm1, qword [rax] ; 04h -vcmpnltsd xmm1, qword [rax] ; 05h -vcmpnlesd xmm1, qword [rax] ; 06h -vcmpordsd xmm1, qword [rax] ; 07h - -vcmpeqsd xmm1, xmm2, qword [rax] ; 00h -vcmpltsd xmm1, xmm2, qword [rax] ; 01h -vcmplesd xmm1, xmm2, qword [rax] ; 02h -vcmpunordsd xmm1, xmm2, qword [rax] ; 03h -vcmpneqsd xmm1, xmm2, qword [rax] ; 04h -vcmpnltsd xmm1, xmm2, qword [rax] ; 05h -vcmpnlesd xmm1, xmm2, qword [rax] ; 06h -vcmpordsd xmm1, xmm2, qword [rax] ; 07h - -vcmpeq_uqsd xmm1, xmm2, qword [rax] ; 08h -vcmpngesd xmm1, xmm2, qword [rax] ; 09h -vcmpngtsd xmm1, xmm2, qword [rax] ; 0Ah -vcmpfalsesd xmm1, xmm2, qword [rax] ; 0Bh -vcmpneq_oqsd xmm1, xmm2, qword [rax] ; 0Ch -vcmpgesd xmm1, xmm2, qword [rax] ; 0Dh -vcmpgtsd xmm1, xmm2, qword [rax] ; 0Eh -vcmptruesd xmm1, xmm2, qword [rax] ; 0Fh - -vcmpeq_ossd xmm1, xmm2, qword [rax] ; 10h -vcmplt_oqsd xmm1, xmm2, qword [rax] ; 11h -vcmple_oqsd xmm1, xmm2, qword [rax] ; 12h -vcmpunord_ssd xmm1, xmm2, qword [rax] ; 13h -vcmpneq_ussd xmm1, xmm2, qword [rax] ; 14h -vcmpnlt_uqsd xmm1, xmm2, qword [rax] ; 15h -vcmpnle_uqsd xmm1, xmm2, qword [rax] ; 16h -vcmpord_ssd xmm1, xmm2, qword [rax] ; 17h - -vcmpeq_ussd xmm1, xmm2, qword [rax] ; 18h -vcmpnge_uqsd xmm1, xmm2, qword [rax] ; 19h -vcmpngt_uqsd xmm1, xmm2, qword [rax] ; 1Ah -vcmpfalse_ossd xmm1, xmm2, qword [rax] ; 1Bh -vcmpneq_ossd xmm1, xmm2, qword [rax] ; 1Ch -vcmpge_oqsd xmm1, xmm2, qword [rax] ; 1Dh -vcmpgt_oqsd xmm1, xmm2, qword [rax] ; 1Eh -vcmptrue_ussd xmm1, xmm2, qword [rax] ; 1Fh - -;----------------------------------------------------------------------------- - -cmpeqss xmm1, xmm2 ; 00h -cmpltss xmm1, xmm2 ; 01h -cmpless xmm1, xmm2 ; 02h -cmpunordss xmm1, xmm2 ; 03h -cmpneqss xmm1, xmm2 ; 04h -cmpnltss xmm1, xmm2 ; 05h -cmpnless xmm1, xmm2 ; 06h -cmpordss xmm1, xmm2 ; 07h - -vcmpeqss xmm1, xmm2 ; 00h -vcmpltss xmm1, xmm2 ; 01h -vcmpless xmm1, xmm2 ; 02h -vcmpunordss xmm1, xmm2 ; 03h -vcmpneqss xmm1, xmm2 ; 04h -vcmpnltss xmm1, xmm2 ; 05h -vcmpnless xmm1, xmm2 ; 06h -vcmpordss xmm1, xmm2 ; 07h - -vcmpeqss xmm1, xmm2, xmm3 ; 00h -vcmpltss xmm1, xmm2, xmm3 ; 01h -vcmpless xmm1, xmm2, xmm3 ; 02h -vcmpunordss xmm1, xmm2, xmm3 ; 03h -vcmpneqss xmm1, xmm2, xmm3 ; 04h -vcmpnltss xmm1, xmm2, xmm3 ; 05h -vcmpnless xmm1, xmm2, xmm3 ; 06h -vcmpordss xmm1, xmm2, xmm3 ; 07h - -vcmpeq_uqss xmm1, xmm2, xmm3 ; 08h -vcmpngess xmm1, xmm2, xmm3 ; 09h -vcmpngtss xmm1, xmm2, xmm3 ; 0Ah -vcmpfalsess xmm1, xmm2, xmm3 ; 0Bh -vcmpneq_oqss xmm1, xmm2, xmm3 ; 0Ch -vcmpgess xmm1, xmm2, xmm3 ; 0Dh -vcmpgtss xmm1, xmm2, xmm3 ; 0Eh -vcmptruess xmm1, xmm2, xmm3 ; 0Fh - -vcmpeq_osss xmm1, xmm2, xmm3 ; 10h -vcmplt_oqss xmm1, xmm2, xmm3 ; 11h -vcmple_oqss xmm1, xmm2, xmm3 ; 12h -vcmpunord_sss xmm1, xmm2, xmm3 ; 13h -vcmpneq_usss xmm1, xmm2, xmm3 ; 14h -vcmpnlt_uqss xmm1, xmm2, xmm3 ; 15h -vcmpnle_uqss xmm1, xmm2, xmm3 ; 16h -vcmpord_sss xmm1, xmm2, xmm3 ; 17h - -vcmpeq_usss xmm1, xmm2, xmm3 ; 18h -vcmpnge_uqss xmm1, xmm2, xmm3 ; 19h -vcmpngt_uqss xmm1, xmm2, xmm3 ; 1Ah -vcmpfalse_osss xmm1, xmm2, xmm3 ; 1Bh -vcmpneq_osss xmm1, xmm2, xmm3 ; 1Ch -vcmpge_oqss xmm1, xmm2, xmm3 ; 1Dh -vcmpgt_oqss xmm1, xmm2, xmm3 ; 1Eh -vcmptrue_usss xmm1, xmm2, xmm3 ; 1Fh - -cmpeqss xmm1, [rax] ; 00h -cmpltss xmm1, [rax] ; 01h -cmpless xmm1, [rax] ; 02h -cmpunordss xmm1, [rax] ; 03h -cmpneqss xmm1, [rax] ; 04h -cmpnltss xmm1, [rax] ; 05h -cmpnless xmm1, [rax] ; 06h -cmpordss xmm1, [rax] ; 07h - -vcmpeqss xmm1, [rax] ; 00h -vcmpltss xmm1, [rax] ; 01h -vcmpless xmm1, [rax] ; 02h -vcmpunordss xmm1, [rax] ; 03h -vcmpneqss xmm1, [rax] ; 04h -vcmpnltss xmm1, [rax] ; 05h -vcmpnless xmm1, [rax] ; 06h -vcmpordss xmm1, [rax] ; 07h - -vcmpeqss xmm1, xmm2, [rax] ; 00h -vcmpltss xmm1, xmm2, [rax] ; 01h -vcmpless xmm1, xmm2, [rax] ; 02h -vcmpunordss xmm1, xmm2, [rax] ; 03h -vcmpneqss xmm1, xmm2, [rax] ; 04h -vcmpnltss xmm1, xmm2, [rax] ; 05h -vcmpnless xmm1, xmm2, [rax] ; 06h -vcmpordss xmm1, xmm2, [rax] ; 07h - -vcmpeq_uqss xmm1, xmm2, [rax] ; 08h -vcmpngess xmm1, xmm2, [rax] ; 09h -vcmpngtss xmm1, xmm2, [rax] ; 0Ah -vcmpfalsess xmm1, xmm2, [rax] ; 0Bh -vcmpneq_oqss xmm1, xmm2, [rax] ; 0Ch -vcmpgess xmm1, xmm2, [rax] ; 0Dh -vcmpgtss xmm1, xmm2, [rax] ; 0Eh -vcmptruess xmm1, xmm2, [rax] ; 0Fh - -vcmpeq_osss xmm1, xmm2, [rax] ; 10h -vcmplt_oqss xmm1, xmm2, [rax] ; 11h -vcmple_oqss xmm1, xmm2, [rax] ; 12h -vcmpunord_sss xmm1, xmm2, [rax] ; 13h -vcmpneq_usss xmm1, xmm2, [rax] ; 14h -vcmpnlt_uqss xmm1, xmm2, [rax] ; 15h -vcmpnle_uqss xmm1, xmm2, [rax] ; 16h -vcmpord_sss xmm1, xmm2, [rax] ; 17h - -vcmpeq_usss xmm1, xmm2, [rax] ; 18h -vcmpnge_uqss xmm1, xmm2, [rax] ; 19h -vcmpngt_uqss xmm1, xmm2, [rax] ; 1Ah -vcmpfalse_osss xmm1, xmm2, [rax] ; 1Bh -vcmpneq_osss xmm1, xmm2, [rax] ; 1Ch -vcmpge_oqss xmm1, xmm2, [rax] ; 1Dh -vcmpgt_oqss xmm1, xmm2, [rax] ; 1Eh -vcmptrue_usss xmm1, xmm2, [rax] ; 1Fh - -cmpeqss xmm1, dword [rax] ; 00h -cmpltss xmm1, dword [rax] ; 01h -cmpless xmm1, dword [rax] ; 02h -cmpunordss xmm1, dword [rax] ; 03h -cmpneqss xmm1, dword [rax] ; 04h -cmpnltss xmm1, dword [rax] ; 05h -cmpnless xmm1, dword [rax] ; 06h -cmpordss xmm1, dword [rax] ; 07h - -vcmpeqss xmm1, dword [rax] ; 00h -vcmpltss xmm1, dword [rax] ; 01h -vcmpless xmm1, dword [rax] ; 02h -vcmpunordss xmm1, dword [rax] ; 03h -vcmpneqss xmm1, dword [rax] ; 04h -vcmpnltss xmm1, dword [rax] ; 05h -vcmpnless xmm1, dword [rax] ; 06h -vcmpordss xmm1, dword [rax] ; 07h - -vcmpeqss xmm1, xmm2, dword [rax] ; 00h -vcmpltss xmm1, xmm2, dword [rax] ; 01h -vcmpless xmm1, xmm2, dword [rax] ; 02h -vcmpunordss xmm1, xmm2, dword [rax] ; 03h -vcmpneqss xmm1, xmm2, dword [rax] ; 04h -vcmpnltss xmm1, xmm2, dword [rax] ; 05h -vcmpnless xmm1, xmm2, dword [rax] ; 06h -vcmpordss xmm1, xmm2, dword [rax] ; 07h - -vcmpeq_uqss xmm1, xmm2, dword [rax] ; 08h -vcmpngess xmm1, xmm2, dword [rax] ; 09h -vcmpngtss xmm1, xmm2, dword [rax] ; 0Ah -vcmpfalsess xmm1, xmm2, dword [rax] ; 0Bh -vcmpneq_oqss xmm1, xmm2, dword [rax] ; 0Ch -vcmpgess xmm1, xmm2, dword [rax] ; 0Dh -vcmpgtss xmm1, xmm2, dword [rax] ; 0Eh -vcmptruess xmm1, xmm2, dword [rax] ; 0Fh - -vcmpeq_osss xmm1, xmm2, dword [rax] ; 10h -vcmplt_oqss xmm1, xmm2, dword [rax] ; 11h -vcmple_oqss xmm1, xmm2, dword [rax] ; 12h -vcmpunord_sss xmm1, xmm2, dword [rax] ; 13h -vcmpneq_usss xmm1, xmm2, dword [rax] ; 14h -vcmpnlt_uqss xmm1, xmm2, dword [rax] ; 15h -vcmpnle_uqss xmm1, xmm2, dword [rax] ; 16h -vcmpord_sss xmm1, xmm2, dword [rax] ; 17h - -vcmpeq_usss xmm1, xmm2, dword [rax] ; 18h -vcmpnge_uqss xmm1, xmm2, dword [rax] ; 19h -vcmpngt_uqss xmm1, xmm2, dword [rax] ; 1Ah -vcmpfalse_osss xmm1, xmm2, dword [rax] ; 1Bh -vcmpneq_osss xmm1, xmm2, dword [rax] ; 1Ch -vcmpge_oqss xmm1, xmm2, dword [rax] ; 1Dh -vcmpgt_oqss xmm1, xmm2, dword [rax] ; 1Eh -vcmptrue_usss xmm1, xmm2, dword [rax] ; 1Fh - diff --git a/modules/arch/x86/tests/avxcc.hex b/modules/arch/x86/tests/avxcc.hex deleted file mode 100644 index c6ed929a..00000000 --- a/modules/arch/x86/tests/avxcc.hex +++ /dev/null @@ -1,3816 +0,0 @@ -66 -0f -c2 -ca -00 -66 -0f -c2 -ca -01 -66 -0f -c2 -ca -02 -66 -0f -c2 -ca -03 -66 -0f -c2 -ca -04 -66 -0f -c2 -ca -05 -66 -0f -c2 -ca -06 -66 -0f -c2 -ca -07 -c5 -f1 -c2 -ca -00 -c5 -f1 -c2 -ca -01 -c5 -f1 -c2 -ca -02 -c5 -f1 -c2 -ca -03 -c5 -f1 -c2 -ca -04 -c5 -f1 -c2 -ca -05 -c5 -f1 -c2 -ca -06 -c5 -f1 -c2 -ca -07 -c5 -e9 -c2 -cb -00 -c5 -e9 -c2 -cb -01 -c5 -e9 -c2 -cb -02 -c5 -e9 -c2 -cb -03 -c5 -e9 -c2 -cb -04 -c5 -e9 -c2 -cb -05 -c5 -e9 -c2 -cb -06 -c5 -e9 -c2 -cb -07 -c5 -e9 -c2 -cb -08 -c5 -e9 -c2 -cb -09 -c5 -e9 -c2 -cb -0a -c5 -e9 -c2 -cb -0b -c5 -e9 -c2 -cb -0c -c5 -e9 -c2 -cb -0d -c5 -e9 -c2 -cb -0e -c5 -e9 -c2 -cb -0f -c5 -e9 -c2 -cb -10 -c5 -e9 -c2 -cb -11 -c5 -e9 -c2 -cb -12 -c5 -e9 -c2 -cb -13 -c5 -e9 -c2 -cb -14 -c5 -e9 -c2 -cb -15 -c5 -e9 -c2 -cb -16 -c5 -e9 -c2 -cb -17 -c5 -e9 -c2 -cb -18 -c5 -e9 -c2 -cb -19 -c5 -e9 -c2 -cb -1a -c5 -e9 -c2 -cb -1b -c5 -e9 -c2 -cb -1c -c5 -e9 -c2 -cb -1d -c5 -e9 -c2 -cb -1e -c5 -e9 -c2 -cb -1f -66 -0f -c2 -08 -00 -66 -0f -c2 -08 -01 -66 -0f -c2 -08 -02 -66 -0f -c2 -08 -03 -66 -0f -c2 -08 -04 -66 -0f -c2 -08 -05 -66 -0f -c2 -08 -06 -66 -0f -c2 -08 -07 -c5 -f1 -c2 -08 -00 -c5 -f1 -c2 -08 -01 -c5 -f1 -c2 -08 -02 -c5 -f1 -c2 -08 -03 -c5 -f1 -c2 -08 -04 -c5 -f1 -c2 -08 -05 -c5 -f1 -c2 -08 -06 -c5 -f1 -c2 -08 -07 -c5 -e9 -c2 -08 -00 -c5 -e9 -c2 -08 -01 -c5 -e9 -c2 -08 -02 -c5 -e9 -c2 -08 -03 -c5 -e9 -c2 -08 -04 -c5 -e9 -c2 -08 -05 -c5 -e9 -c2 -08 -06 -c5 -e9 -c2 -08 -07 -c5 -e9 -c2 -08 -08 -c5 -e9 -c2 -08 -09 -c5 -e9 -c2 -08 -0a -c5 -e9 -c2 -08 -0b -c5 -e9 -c2 -08 -0c -c5 -e9 -c2 -08 -0d -c5 -e9 -c2 -08 -0e -c5 -e9 -c2 -08 -0f -c5 -e9 -c2 -08 -10 -c5 -e9 -c2 -08 -11 -c5 -e9 -c2 -08 -12 -c5 -e9 -c2 -08 -13 -c5 -e9 -c2 -08 -14 -c5 -e9 -c2 -08 -15 -c5 -e9 -c2 -08 -16 -c5 -e9 -c2 -08 -17 -c5 -e9 -c2 -08 -18 -c5 -e9 -c2 -08 -19 -c5 -e9 -c2 -08 -1a -c5 -e9 -c2 -08 -1b -c5 -e9 -c2 -08 -1c -c5 -e9 -c2 -08 -1d -c5 -e9 -c2 -08 -1e -c5 -e9 -c2 -08 -1f -66 -0f -c2 -08 -00 -66 -0f -c2 -08 -01 -66 -0f -c2 -08 -02 -66 -0f -c2 -08 -03 -66 -0f -c2 -08 -04 -66 -0f -c2 -08 -05 -66 -0f -c2 -08 -06 -66 -0f -c2 -08 -07 -c5 -f1 -c2 -08 -00 -c5 -f1 -c2 -08 -01 -c5 -f1 -c2 -08 -02 -c5 -f1 -c2 -08 -03 -c5 -f1 -c2 -08 -04 -c5 -f1 -c2 -08 -05 -c5 -f1 -c2 -08 -06 -c5 -f1 -c2 -08 -07 -c5 -e9 -c2 -08 -00 -c5 -e9 -c2 -08 -01 -c5 -e9 -c2 -08 -02 -c5 -e9 -c2 -08 -03 -c5 -e9 -c2 -08 -04 -c5 -e9 -c2 -08 -05 -c5 -e9 -c2 -08 -06 -c5 -e9 -c2 -08 -07 -c5 -e9 -c2 -08 -08 -c5 -e9 -c2 -08 -09 -c5 -e9 -c2 -08 -0a -c5 -e9 -c2 -08 -0b -c5 -e9 -c2 -08 -0c -c5 -e9 -c2 -08 -0d -c5 -e9 -c2 -08 -0e -c5 -e9 -c2 -08 -0f -c5 -e9 -c2 -08 -10 -c5 -e9 -c2 -08 -11 -c5 -e9 -c2 -08 -12 -c5 -e9 -c2 -08 -13 -c5 -e9 -c2 -08 -14 -c5 -e9 -c2 -08 -15 -c5 -e9 -c2 -08 -16 -c5 -e9 -c2 -08 -17 -c5 -e9 -c2 -08 -18 -c5 -e9 -c2 -08 -19 -c5 -e9 -c2 -08 -1a -c5 -e9 -c2 -08 -1b -c5 -e9 -c2 -08 -1c -c5 -e9 -c2 -08 -1d -c5 -e9 -c2 -08 -1e -c5 -e9 -c2 -08 -1f -c5 -ed -c2 -cb -00 -c5 -ed -c2 -cb -01 -c5 -ed -c2 -cb -02 -c5 -ed -c2 -cb -03 -c5 -ed -c2 -cb -04 -c5 -ed -c2 -cb -05 -c5 -ed -c2 -cb -06 -c5 -ed -c2 -cb -07 -c5 -ed -c2 -cb -08 -c5 -ed -c2 -cb -09 -c5 -ed -c2 -cb -0a -c5 -ed -c2 -cb -0b -c5 -ed -c2 -cb -0c -c5 -ed -c2 -cb -0d -c5 -ed -c2 -cb -0e -c5 -ed -c2 -cb -0f -c5 -ed -c2 -cb -10 -c5 -ed -c2 -cb -11 -c5 -ed -c2 -cb -12 -c5 -ed -c2 -cb -13 -c5 -ed -c2 -cb -14 -c5 -ed -c2 -cb -15 -c5 -ed -c2 -cb -16 -c5 -ed -c2 -cb -17 -c5 -ed -c2 -cb -18 -c5 -ed -c2 -cb -19 -c5 -ed -c2 -cb -1a -c5 -ed -c2 -cb -1b -c5 -ed -c2 -cb -1c -c5 -ed -c2 -cb -1d -c5 -ed -c2 -cb -1e -c5 -ed -c2 -cb -1f -c5 -ed -c2 -08 -00 -c5 -ed -c2 -08 -01 -c5 -ed -c2 -08 -02 -c5 -ed -c2 -08 -03 -c5 -ed -c2 -08 -04 -c5 -ed -c2 -08 -05 -c5 -ed -c2 -08 -06 -c5 -ed -c2 -08 -07 -c5 -ed -c2 -08 -08 -c5 -ed -c2 -08 -09 -c5 -ed -c2 -08 -0a -c5 -ed -c2 -08 -0b -c5 -ed -c2 -08 -0c -c5 -ed -c2 -08 -0d -c5 -ed -c2 -08 -0e -c5 -ed -c2 -08 -0f -c5 -ed -c2 -08 -10 -c5 -ed -c2 -08 -11 -c5 -ed -c2 -08 -12 -c5 -ed -c2 -08 -13 -c5 -ed -c2 -08 -14 -c5 -ed -c2 -08 -15 -c5 -ed -c2 -08 -16 -c5 -ed -c2 -08 -17 -c5 -ed -c2 -08 -18 -c5 -ed -c2 -08 -19 -c5 -ed -c2 -08 -1a -c5 -ed -c2 -08 -1b -c5 -ed -c2 -08 -1c -c5 -ed -c2 -08 -1d -c5 -ed -c2 -08 -1e -c5 -ed -c2 -08 -1f -c5 -ed -c2 -08 -00 -c5 -ed -c2 -08 -01 -c5 -ed -c2 -08 -02 -c5 -ed -c2 -08 -03 -c5 -ed -c2 -08 -04 -c5 -ed -c2 -08 -05 -c5 -ed -c2 -08 -06 -c5 -ed -c2 -08 -07 -c5 -ed -c2 -08 -08 -c5 -ed -c2 -08 -09 -c5 -ed -c2 -08 -0a -c5 -ed -c2 -08 -0b -c5 -ed -c2 -08 -0c -c5 -ed -c2 -08 -0d -c5 -ed -c2 -08 -0e -c5 -ed -c2 -08 -0f -c5 -ed -c2 -08 -10 -c5 -ed -c2 -08 -11 -c5 -ed -c2 -08 -12 -c5 -ed -c2 -08 -13 -c5 -ed -c2 -08 -14 -c5 -ed -c2 -08 -15 -c5 -ed -c2 -08 -16 -c5 -ed -c2 -08 -17 -c5 -ed -c2 -08 -18 -c5 -ed -c2 -08 -19 -c5 -ed -c2 -08 -1a -c5 -ed -c2 -08 -1b -c5 -ed -c2 -08 -1c -c5 -ed -c2 -08 -1d -c5 -ed -c2 -08 -1e -c5 -ed -c2 -08 -1f -0f -c2 -ca -00 -0f -c2 -ca -01 -0f -c2 -ca -02 -0f -c2 -ca -03 -0f -c2 -ca -04 -0f -c2 -ca -05 -0f -c2 -ca -06 -0f -c2 -ca -07 -c5 -f0 -c2 -ca -00 -c5 -f0 -c2 -ca -01 -c5 -f0 -c2 -ca -02 -c5 -f0 -c2 -ca -03 -c5 -f0 -c2 -ca -04 -c5 -f0 -c2 -ca -05 -c5 -f0 -c2 -ca -06 -c5 -f0 -c2 -ca -07 -c5 -e8 -c2 -cb -00 -c5 -e8 -c2 -cb -01 -c5 -e8 -c2 -cb -02 -c5 -e8 -c2 -cb -03 -c5 -e8 -c2 -cb -04 -c5 -e8 -c2 -cb -05 -c5 -e8 -c2 -cb -06 -c5 -e8 -c2 -cb -07 -c5 -e8 -c2 -cb -08 -c5 -e8 -c2 -cb -09 -c5 -e8 -c2 -cb -0a -c5 -e8 -c2 -cb -0b -c5 -e8 -c2 -cb -0c -c5 -e8 -c2 -cb -0d -c5 -e8 -c2 -cb -0e -c5 -e8 -c2 -cb -0f -c5 -e8 -c2 -cb -10 -c5 -e8 -c2 -cb -11 -c5 -e8 -c2 -cb -12 -c5 -e8 -c2 -cb -13 -c5 -e8 -c2 -cb -14 -c5 -e8 -c2 -cb -15 -c5 -e8 -c2 -cb -16 -c5 -e8 -c2 -cb -17 -c5 -e8 -c2 -cb -18 -c5 -e8 -c2 -cb -19 -c5 -e8 -c2 -cb -1a -c5 -e8 -c2 -cb -1b -c5 -e8 -c2 -cb -1c -c5 -e8 -c2 -cb -1d -c5 -e8 -c2 -cb -1e -c5 -e8 -c2 -cb -1f -0f -c2 -08 -00 -0f -c2 -08 -01 -0f -c2 -08 -02 -0f -c2 -08 -03 -0f -c2 -08 -04 -0f -c2 -08 -05 -0f -c2 -08 -06 -0f -c2 -08 -07 -c5 -f0 -c2 -08 -00 -c5 -f0 -c2 -08 -01 -c5 -f0 -c2 -08 -02 -c5 -f0 -c2 -08 -03 -c5 -f0 -c2 -08 -04 -c5 -f0 -c2 -08 -05 -c5 -f0 -c2 -08 -06 -c5 -f0 -c2 -08 -07 -c5 -e8 -c2 -08 -00 -c5 -e8 -c2 -08 -01 -c5 -e8 -c2 -08 -02 -c5 -e8 -c2 -08 -03 -c5 -e8 -c2 -08 -04 -c5 -e8 -c2 -08 -05 -c5 -e8 -c2 -08 -06 -c5 -e8 -c2 -08 -07 -c5 -e8 -c2 -08 -08 -c5 -e8 -c2 -08 -09 -c5 -e8 -c2 -08 -0a -c5 -e8 -c2 -08 -0b -c5 -e8 -c2 -08 -0c -c5 -e8 -c2 -08 -0d -c5 -e8 -c2 -08 -0e -c5 -e8 -c2 -08 -0f -c5 -e8 -c2 -08 -10 -c5 -e8 -c2 -08 -11 -c5 -e8 -c2 -08 -12 -c5 -e8 -c2 -08 -13 -c5 -e8 -c2 -08 -14 -c5 -e8 -c2 -08 -15 -c5 -e8 -c2 -08 -16 -c5 -e8 -c2 -08 -17 -c5 -e8 -c2 -08 -18 -c5 -e8 -c2 -08 -19 -c5 -e8 -c2 -08 -1a -c5 -e8 -c2 -08 -1b -c5 -e8 -c2 -08 -1c -c5 -e8 -c2 -08 -1d -c5 -e8 -c2 -08 -1e -c5 -e8 -c2 -08 -1f -0f -c2 -08 -00 -0f -c2 -08 -01 -0f -c2 -08 -02 -0f -c2 -08 -03 -0f -c2 -08 -04 -0f -c2 -08 -05 -0f -c2 -08 -06 -0f -c2 -08 -07 -c5 -f0 -c2 -08 -00 -c5 -f0 -c2 -08 -01 -c5 -f0 -c2 -08 -02 -c5 -f0 -c2 -08 -03 -c5 -f0 -c2 -08 -04 -c5 -f0 -c2 -08 -05 -c5 -f0 -c2 -08 -06 -c5 -f0 -c2 -08 -07 -c5 -e8 -c2 -08 -00 -c5 -e8 -c2 -08 -01 -c5 -e8 -c2 -08 -02 -c5 -e8 -c2 -08 -03 -c5 -e8 -c2 -08 -04 -c5 -e8 -c2 -08 -05 -c5 -e8 -c2 -08 -06 -c5 -e8 -c2 -08 -07 -c5 -e8 -c2 -08 -08 -c5 -e8 -c2 -08 -09 -c5 -e8 -c2 -08 -0a -c5 -e8 -c2 -08 -0b -c5 -e8 -c2 -08 -0c -c5 -e8 -c2 -08 -0d -c5 -e8 -c2 -08 -0e -c5 -e8 -c2 -08 -0f -c5 -e8 -c2 -08 -10 -c5 -e8 -c2 -08 -11 -c5 -e8 -c2 -08 -12 -c5 -e8 -c2 -08 -13 -c5 -e8 -c2 -08 -14 -c5 -e8 -c2 -08 -15 -c5 -e8 -c2 -08 -16 -c5 -e8 -c2 -08 -17 -c5 -e8 -c2 -08 -18 -c5 -e8 -c2 -08 -19 -c5 -e8 -c2 -08 -1a -c5 -e8 -c2 -08 -1b -c5 -e8 -c2 -08 -1c -c5 -e8 -c2 -08 -1d -c5 -e8 -c2 -08 -1e -c5 -e8 -c2 -08 -1f -c5 -ec -c2 -cb -00 -c5 -ec -c2 -cb -01 -c5 -ec -c2 -cb -02 -c5 -ec -c2 -cb -03 -c5 -ec -c2 -cb -04 -c5 -ec -c2 -cb -05 -c5 -ec -c2 -cb -06 -c5 -ec -c2 -cb -07 -c5 -ec -c2 -cb -08 -c5 -ec -c2 -cb -09 -c5 -ec -c2 -cb -0a -c5 -ec -c2 -cb -0b -c5 -ec -c2 -cb -0c -c5 -ec -c2 -cb -0d -c5 -ec -c2 -cb -0e -c5 -ec -c2 -cb -0f -c5 -ec -c2 -cb -10 -c5 -ec -c2 -cb -11 -c5 -ec -c2 -cb -12 -c5 -ec -c2 -cb -13 -c5 -ec -c2 -cb -14 -c5 -ec -c2 -cb -15 -c5 -ec -c2 -cb -16 -c5 -ec -c2 -cb -17 -c5 -ec -c2 -cb -18 -c5 -ec -c2 -cb -19 -c5 -ec -c2 -cb -1a -c5 -ec -c2 -cb -1b -c5 -ec -c2 -cb -1c -c5 -ec -c2 -cb -1d -c5 -ec -c2 -cb -1e -c5 -ec -c2 -cb -1f -c5 -ec -c2 -08 -00 -c5 -ec -c2 -08 -01 -c5 -ec -c2 -08 -02 -c5 -ec -c2 -08 -03 -c5 -ec -c2 -08 -04 -c5 -ec -c2 -08 -05 -c5 -ec -c2 -08 -06 -c5 -ec -c2 -08 -07 -c5 -ec -c2 -08 -08 -c5 -ec -c2 -08 -09 -c5 -ec -c2 -08 -0a -c5 -ec -c2 -08 -0b -c5 -ec -c2 -08 -0c -c5 -ec -c2 -08 -0d -c5 -ec -c2 -08 -0e -c5 -ec -c2 -08 -0f -c5 -ec -c2 -08 -10 -c5 -ec -c2 -08 -11 -c5 -ec -c2 -08 -12 -c5 -ec -c2 -08 -13 -c5 -ec -c2 -08 -14 -c5 -ec -c2 -08 -15 -c5 -ec -c2 -08 -16 -c5 -ec -c2 -08 -17 -c5 -ec -c2 -08 -18 -c5 -ec -c2 -08 -19 -c5 -ec -c2 -08 -1a -c5 -ec -c2 -08 -1b -c5 -ec -c2 -08 -1c -c5 -ec -c2 -08 -1d -c5 -ec -c2 -08 -1e -c5 -ec -c2 -08 -1f -c5 -ec -c2 -08 -00 -c5 -ec -c2 -08 -01 -c5 -ec -c2 -08 -02 -c5 -ec -c2 -08 -03 -c5 -ec -c2 -08 -04 -c5 -ec -c2 -08 -05 -c5 -ec -c2 -08 -06 -c5 -ec -c2 -08 -07 -c5 -ec -c2 -08 -08 -c5 -ec -c2 -08 -09 -c5 -ec -c2 -08 -0a -c5 -ec -c2 -08 -0b -c5 -ec -c2 -08 -0c -c5 -ec -c2 -08 -0d -c5 -ec -c2 -08 -0e -c5 -ec -c2 -08 -0f -c5 -ec -c2 -08 -10 -c5 -ec -c2 -08 -11 -c5 -ec -c2 -08 -12 -c5 -ec -c2 -08 -13 -c5 -ec -c2 -08 -14 -c5 -ec -c2 -08 -15 -c5 -ec -c2 -08 -16 -c5 -ec -c2 -08 -17 -c5 -ec -c2 -08 -18 -c5 -ec -c2 -08 -19 -c5 -ec -c2 -08 -1a -c5 -ec -c2 -08 -1b -c5 -ec -c2 -08 -1c -c5 -ec -c2 -08 -1d -c5 -ec -c2 -08 -1e -c5 -ec -c2 -08 -1f -f2 -0f -c2 -ca -00 -f2 -0f -c2 -ca -01 -f2 -0f -c2 -ca -02 -f2 -0f -c2 -ca -03 -f2 -0f -c2 -ca -04 -f2 -0f -c2 -ca -05 -f2 -0f -c2 -ca -06 -f2 -0f -c2 -ca -07 -c5 -f3 -c2 -ca -00 -c5 -f3 -c2 -ca -01 -c5 -f3 -c2 -ca -02 -c5 -f3 -c2 -ca -03 -c5 -f3 -c2 -ca -04 -c5 -f3 -c2 -ca -05 -c5 -f3 -c2 -ca -06 -c5 -f3 -c2 -ca -07 -c5 -eb -c2 -cb -00 -c5 -eb -c2 -cb -01 -c5 -eb -c2 -cb -02 -c5 -eb -c2 -cb -03 -c5 -eb -c2 -cb -04 -c5 -eb -c2 -cb -05 -c5 -eb -c2 -cb -06 -c5 -eb -c2 -cb -07 -c5 -eb -c2 -cb -08 -c5 -eb -c2 -cb -09 -c5 -eb -c2 -cb -0a -c5 -eb -c2 -cb -0b -c5 -eb -c2 -cb -0c -c5 -eb -c2 -cb -0d -c5 -eb -c2 -cb -0e -c5 -eb -c2 -cb -0f -c5 -eb -c2 -cb -10 -c5 -eb -c2 -cb -11 -c5 -eb -c2 -cb -12 -c5 -eb -c2 -cb -13 -c5 -eb -c2 -cb -14 -c5 -eb -c2 -cb -15 -c5 -eb -c2 -cb -16 -c5 -eb -c2 -cb -17 -c5 -eb -c2 -cb -18 -c5 -eb -c2 -cb -19 -c5 -eb -c2 -cb -1a -c5 -eb -c2 -cb -1b -c5 -eb -c2 -cb -1c -c5 -eb -c2 -cb -1d -c5 -eb -c2 -cb -1e -c5 -eb -c2 -cb -1f -f2 -0f -c2 -08 -00 -f2 -0f -c2 -08 -01 -f2 -0f -c2 -08 -02 -f2 -0f -c2 -08 -03 -f2 -0f -c2 -08 -04 -f2 -0f -c2 -08 -05 -f2 -0f -c2 -08 -06 -f2 -0f -c2 -08 -07 -c5 -f3 -c2 -08 -00 -c5 -f3 -c2 -08 -01 -c5 -f3 -c2 -08 -02 -c5 -f3 -c2 -08 -03 -c5 -f3 -c2 -08 -04 -c5 -f3 -c2 -08 -05 -c5 -f3 -c2 -08 -06 -c5 -f3 -c2 -08 -07 -c5 -eb -c2 -08 -00 -c5 -eb -c2 -08 -01 -c5 -eb -c2 -08 -02 -c5 -eb -c2 -08 -03 -c5 -eb -c2 -08 -04 -c5 -eb -c2 -08 -05 -c5 -eb -c2 -08 -06 -c5 -eb -c2 -08 -07 -c5 -eb -c2 -08 -08 -c5 -eb -c2 -08 -09 -c5 -eb -c2 -08 -0a -c5 -eb -c2 -08 -0b -c5 -eb -c2 -08 -0c -c5 -eb -c2 -08 -0d -c5 -eb -c2 -08 -0e -c5 -eb -c2 -08 -0f -c5 -eb -c2 -08 -10 -c5 -eb -c2 -08 -11 -c5 -eb -c2 -08 -12 -c5 -eb -c2 -08 -13 -c5 -eb -c2 -08 -14 -c5 -eb -c2 -08 -15 -c5 -eb -c2 -08 -16 -c5 -eb -c2 -08 -17 -c5 -eb -c2 -08 -18 -c5 -eb -c2 -08 -19 -c5 -eb -c2 -08 -1a -c5 -eb -c2 -08 -1b -c5 -eb -c2 -08 -1c -c5 -eb -c2 -08 -1d -c5 -eb -c2 -08 -1e -c5 -eb -c2 -08 -1f -f2 -0f -c2 -08 -00 -f2 -0f -c2 -08 -01 -f2 -0f -c2 -08 -02 -f2 -0f -c2 -08 -03 -f2 -0f -c2 -08 -04 -f2 -0f -c2 -08 -05 -f2 -0f -c2 -08 -06 -f2 -0f -c2 -08 -07 -c5 -f3 -c2 -08 -00 -c5 -f3 -c2 -08 -01 -c5 -f3 -c2 -08 -02 -c5 -f3 -c2 -08 -03 -c5 -f3 -c2 -08 -04 -c5 -f3 -c2 -08 -05 -c5 -f3 -c2 -08 -06 -c5 -f3 -c2 -08 -07 -c5 -eb -c2 -08 -00 -c5 -eb -c2 -08 -01 -c5 -eb -c2 -08 -02 -c5 -eb -c2 -08 -03 -c5 -eb -c2 -08 -04 -c5 -eb -c2 -08 -05 -c5 -eb -c2 -08 -06 -c5 -eb -c2 -08 -07 -c5 -eb -c2 -08 -08 -c5 -eb -c2 -08 -09 -c5 -eb -c2 -08 -0a -c5 -eb -c2 -08 -0b -c5 -eb -c2 -08 -0c -c5 -eb -c2 -08 -0d -c5 -eb -c2 -08 -0e -c5 -eb -c2 -08 -0f -c5 -eb -c2 -08 -10 -c5 -eb -c2 -08 -11 -c5 -eb -c2 -08 -12 -c5 -eb -c2 -08 -13 -c5 -eb -c2 -08 -14 -c5 -eb -c2 -08 -15 -c5 -eb -c2 -08 -16 -c5 -eb -c2 -08 -17 -c5 -eb -c2 -08 -18 -c5 -eb -c2 -08 -19 -c5 -eb -c2 -08 -1a -c5 -eb -c2 -08 -1b -c5 -eb -c2 -08 -1c -c5 -eb -c2 -08 -1d -c5 -eb -c2 -08 -1e -c5 -eb -c2 -08 -1f -f3 -0f -c2 -ca -00 -f3 -0f -c2 -ca -01 -f3 -0f -c2 -ca -02 -f3 -0f -c2 -ca -03 -f3 -0f -c2 -ca -04 -f3 -0f -c2 -ca -05 -f3 -0f -c2 -ca -06 -f3 -0f -c2 -ca -07 -c5 -f2 -c2 -ca -00 -c5 -f2 -c2 -ca -01 -c5 -f2 -c2 -ca -02 -c5 -f2 -c2 -ca -03 -c5 -f2 -c2 -ca -04 -c5 -f2 -c2 -ca -05 -c5 -f2 -c2 -ca -06 -c5 -f2 -c2 -ca -07 -c5 -ea -c2 -cb -00 -c5 -ea -c2 -cb -01 -c5 -ea -c2 -cb -02 -c5 -ea -c2 -cb -03 -c5 -ea -c2 -cb -04 -c5 -ea -c2 -cb -05 -c5 -ea -c2 -cb -06 -c5 -ea -c2 -cb -07 -c5 -ea -c2 -cb -08 -c5 -ea -c2 -cb -09 -c5 -ea -c2 -cb -0a -c5 -ea -c2 -cb -0b -c5 -ea -c2 -cb -0c -c5 -ea -c2 -cb -0d -c5 -ea -c2 -cb -0e -c5 -ea -c2 -cb -0f -c5 -ea -c2 -cb -10 -c5 -ea -c2 -cb -11 -c5 -ea -c2 -cb -12 -c5 -ea -c2 -cb -13 -c5 -ea -c2 -cb -14 -c5 -ea -c2 -cb -15 -c5 -ea -c2 -cb -16 -c5 -ea -c2 -cb -17 -c5 -ea -c2 -cb -18 -c5 -ea -c2 -cb -19 -c5 -ea -c2 -cb -1a -c5 -ea -c2 -cb -1b -c5 -ea -c2 -cb -1c -c5 -ea -c2 -cb -1d -c5 -ea -c2 -cb -1e -c5 -ea -c2 -cb -1f -f3 -0f -c2 -08 -00 -f3 -0f -c2 -08 -01 -f3 -0f -c2 -08 -02 -f3 -0f -c2 -08 -03 -f3 -0f -c2 -08 -04 -f3 -0f -c2 -08 -05 -f3 -0f -c2 -08 -06 -f3 -0f -c2 -08 -07 -c5 -f2 -c2 -08 -00 -c5 -f2 -c2 -08 -01 -c5 -f2 -c2 -08 -02 -c5 -f2 -c2 -08 -03 -c5 -f2 -c2 -08 -04 -c5 -f2 -c2 -08 -05 -c5 -f2 -c2 -08 -06 -c5 -f2 -c2 -08 -07 -c5 -ea -c2 -08 -00 -c5 -ea -c2 -08 -01 -c5 -ea -c2 -08 -02 -c5 -ea -c2 -08 -03 -c5 -ea -c2 -08 -04 -c5 -ea -c2 -08 -05 -c5 -ea -c2 -08 -06 -c5 -ea -c2 -08 -07 -c5 -ea -c2 -08 -08 -c5 -ea -c2 -08 -09 -c5 -ea -c2 -08 -0a -c5 -ea -c2 -08 -0b -c5 -ea -c2 -08 -0c -c5 -ea -c2 -08 -0d -c5 -ea -c2 -08 -0e -c5 -ea -c2 -08 -0f -c5 -ea -c2 -08 -10 -c5 -ea -c2 -08 -11 -c5 -ea -c2 -08 -12 -c5 -ea -c2 -08 -13 -c5 -ea -c2 -08 -14 -c5 -ea -c2 -08 -15 -c5 -ea -c2 -08 -16 -c5 -ea -c2 -08 -17 -c5 -ea -c2 -08 -18 -c5 -ea -c2 -08 -19 -c5 -ea -c2 -08 -1a -c5 -ea -c2 -08 -1b -c5 -ea -c2 -08 -1c -c5 -ea -c2 -08 -1d -c5 -ea -c2 -08 -1e -c5 -ea -c2 -08 -1f -f3 -0f -c2 -08 -00 -f3 -0f -c2 -08 -01 -f3 -0f -c2 -08 -02 -f3 -0f -c2 -08 -03 -f3 -0f -c2 -08 -04 -f3 -0f -c2 -08 -05 -f3 -0f -c2 -08 -06 -f3 -0f -c2 -08 -07 -c5 -f2 -c2 -08 -00 -c5 -f2 -c2 -08 -01 -c5 -f2 -c2 -08 -02 -c5 -f2 -c2 -08 -03 -c5 -f2 -c2 -08 -04 -c5 -f2 -c2 -08 -05 -c5 -f2 -c2 -08 -06 -c5 -f2 -c2 -08 -07 -c5 -ea -c2 -08 -00 -c5 -ea -c2 -08 -01 -c5 -ea -c2 -08 -02 -c5 -ea -c2 -08 -03 -c5 -ea -c2 -08 -04 -c5 -ea -c2 -08 -05 -c5 -ea -c2 -08 -06 -c5 -ea -c2 -08 -07 -c5 -ea -c2 -08 -08 -c5 -ea -c2 -08 -09 -c5 -ea -c2 -08 -0a -c5 -ea -c2 -08 -0b -c5 -ea -c2 -08 -0c -c5 -ea -c2 -08 -0d -c5 -ea -c2 -08 -0e -c5 -ea -c2 -08 -0f -c5 -ea -c2 -08 -10 -c5 -ea -c2 -08 -11 -c5 -ea -c2 -08 -12 -c5 -ea -c2 -08 -13 -c5 -ea -c2 -08 -14 -c5 -ea -c2 -08 -15 -c5 -ea -c2 -08 -16 -c5 -ea -c2 -08 -17 -c5 -ea -c2 -08 -18 -c5 -ea -c2 -08 -19 -c5 -ea -c2 -08 -1a -c5 -ea -c2 -08 -1b -c5 -ea -c2 -08 -1c -c5 -ea -c2 -08 -1d -c5 -ea -c2 -08 -1e -c5 -ea -c2 -08 -1f diff --git a/modules/arch/x86/tests/bmi1.asm b/modules/arch/x86/tests/bmi1.asm deleted file mode 100644 index 4913a4f8..00000000 --- a/modules/arch/x86/tests/bmi1.asm +++ /dev/null @@ -1,32 +0,0 @@ -[bits 64] -andn eax, ebx, ecx ; c4 e2 60 f2 c1 -andn eax, ebx, [0] ; c4 e2 60 f2 04 25 00 00 00 00 -andn rax, rbx, rcx ; c4 e2 e0 f2 c1 -andn rax, rbx, [0] ; c4 e2 e0 f2 04 25 00 00 00 00 - -bextr eax, ebx, ecx ; c4 e2 70 f7 c3 -bextr eax, [0], ecx ; c4 e2 70 f7 04 25 00 00 00 00 -bextr rax, rbx, rcx ; c4 e2 f0 f7 c3 -bextr rax, [0], rcx ; c4 e2 f0 f7 04 25 00 00 00 00 - -blsi eax, ecx ; c4 e2 78 f3 d9 -blsi eax, [0] ; c4 e2 78 f3 1c 25 00 00 00 00 -blsi rax, rcx ; c4 e2 f8 f3 d9 -blsi rax, [0] ; c4 e2 f8 f3 1c 25 00 00 00 00 - -blsmsk eax, ecx ; c4 e2 78 f3 d1 -blsmsk eax, [0] ; c4 e2 78 f3 14 25 00 00 00 00 -blsmsk rax, rcx ; c4 e2 f8 f3 d1 -blsmsk rax, [0] ; c4 e2 f8 f3 14 25 00 00 00 00 - -blsr eax, ecx ; c4 e2 78 f3 c9 -blsr eax, [0] ; c4 e2 78 f3 0c 25 00 00 00 00 -blsr rax, rcx ; c4 e2 f8 f3 c9 -blsr rax, [0] ; c4 e2 f8 f3 0c 25 00 00 00 00 - -tzcnt ax, bx ; 66 f3 0f bc c3 -tzcnt ax, [0] ; 66 f3 0f bc 04 25 00 00 00 00 -tzcnt eax, ebx ; f3 0f bc c3 -tzcnt eax, [0] ; f3 0f bc 04 25 00 00 00 00 -tzcnt rax, rbx ; f3 48 0f bc c3 -tzcnt rax, [0] ; f3 48 0f bc 04 25 00 00 00 00 diff --git a/modules/arch/x86/tests/bmi1.hex b/modules/arch/x86/tests/bmi1.hex deleted file mode 100644 index fc692cde..00000000 --- a/modules/arch/x86/tests/bmi1.hex +++ /dev/null @@ -1,193 +0,0 @@ -c4 -e2 -60 -f2 -c1 -c4 -e2 -60 -f2 -04 -25 -00 -00 -00 -00 -c4 -e2 -e0 -f2 -c1 -c4 -e2 -e0 -f2 -04 -25 -00 -00 -00 -00 -c4 -e2 -70 -f7 -c3 -c4 -e2 -70 -f7 -04 -25 -00 -00 -00 -00 -c4 -e2 -f0 -f7 -c3 -c4 -e2 -f0 -f7 -04 -25 -00 -00 -00 -00 -c4 -e2 -78 -f3 -d9 -c4 -e2 -78 -f3 -1c -25 -00 -00 -00 -00 -c4 -e2 -f8 -f3 -d9 -c4 -e2 -f8 -f3 -1c -25 -00 -00 -00 -00 -c4 -e2 -78 -f3 -d1 -c4 -e2 -78 -f3 -14 -25 -00 -00 -00 -00 -c4 -e2 -f8 -f3 -d1 -c4 -e2 -f8 -f3 -14 -25 -00 -00 -00 -00 -c4 -e2 -78 -f3 -c9 -c4 -e2 -78 -f3 -0c -25 -00 -00 -00 -00 -c4 -e2 -f8 -f3 -c9 -c4 -e2 -f8 -f3 -0c -25 -00 -00 -00 -00 -66 -f3 -0f -bc -c3 -66 -f3 -0f -bc -04 -25 -00 -00 -00 -00 -f3 -0f -bc -c3 -f3 -0f -bc -04 -25 -00 -00 -00 -00 -f3 -48 -0f -bc -c3 -f3 -48 -0f -bc -04 -25 -00 -00 -00 -00 diff --git a/modules/arch/x86/tests/bmi2.asm b/modules/arch/x86/tests/bmi2.asm deleted file mode 100644 index d19d7f3a..00000000 --- a/modules/arch/x86/tests/bmi2.asm +++ /dev/null @@ -1,40 +0,0 @@ -[bits 64] -bzhi eax, ebx, ecx ; c4 e2 70 f5 c3 -bzhi eax, [0], ecx ; c4 e2 70 f5 04 25 00 00 00 00 -bzhi rax, rbx, rcx ; c4 e2 f0 f5 c3 -bzhi rax, [0], rcx ; c4 e2 f0 f5 04 25 00 00 00 00 - -mulx eax, ebx, ecx ; c4 e2 63 f6 c1 -mulx eax, ebx, [0] ; c4 e2 63 f6 04 25 00 00 00 00 -mulx rax, rbx, rcx ; c4 e2 e3 f6 c1 -mulx rax, rbx, [0] ; c4 e2 e3 f6 04 25 00 00 00 00 - -pdep eax, ebx, ecx ; c4 e2 63 f5 c1 -pdep eax, ebx, [0] ; c4 e2 63 f5 04 25 00 00 00 00 -pdep rax, rbx, rcx ; c4 e2 e3 f5 c1 -pdep rax, rbx, [0] ; c4 e2 e3 f5 04 25 00 00 00 00 - -pext eax, ebx, ecx ; c4 e2 62 f5 c1 -pext eax, ebx, [0] ; c4 e2 62 f5 04 25 00 00 00 00 -pext rax, rbx, rcx ; c4 e2 e2 f5 c1 -pext rax, rbx, [0] ; c4 e2 e2 f5 04 25 00 00 00 00 - -rorx eax, ebx, 3 ; c4 e3 7b f0 c3 03 -rorx eax, [0], 3 ; c4 e3 7b f0 04 25 00 00 00 00 03 -rorx rax, rbx, 3 ; c4 e3 fb f0 c3 03 -rorx rax, [0], 3 ; c4 e3 fb f0 04 25 00 00 00 00 03 - -sarx eax, ebx, ecx ; c4 e2 72 f7 c3 -sarx eax, [0], ecx ; c4 e2 72 f7 04 25 00 00 00 00 -sarx rax, rbx, rcx ; c4 e2 f2 f7 c3 -sarx rax, [0], rcx ; c4 e2 f2 f7 04 25 00 00 00 00 - -shlx eax, ebx, ecx ; c4 e2 71 f7 c3 -shlx eax, [0], ecx ; c4 e2 71 f7 04 25 00 00 00 00 -shlx rax, rbx, rcx ; c4 e2 f1 f7 c3 -shlx rax, [0], rcx ; c4 e2 f1 f7 04 25 00 00 00 00 - -shrx eax, ebx, ecx ; c4 e2 73 f7 c3 -shrx eax, [0], ecx ; c4 e2 73 f7 04 25 00 00 00 00 -shrx rax, rbx, rcx ; c4 e2 f3 f7 c3 -shrx rax, [0], rcx ; c4 e2 f3 f7 04 25 00 00 00 00 diff --git a/modules/arch/x86/tests/bmi2.hex b/modules/arch/x86/tests/bmi2.hex deleted file mode 100644 index c1529729..00000000 --- a/modules/arch/x86/tests/bmi2.hex +++ /dev/null @@ -1,244 +0,0 @@ -c4 -e2 -70 -f5 -c3 -c4 -e2 -70 -f5 -04 -25 -00 -00 -00 -00 -c4 -e2 -f0 -f5 -c3 -c4 -e2 -f0 -f5 -04 -25 -00 -00 -00 -00 -c4 -e2 -63 -f6 -c1 -c4 -e2 -63 -f6 -04 -25 -00 -00 -00 -00 -c4 -e2 -e3 -f6 -c1 -c4 -e2 -e3 -f6 -04 -25 -00 -00 -00 -00 -c4 -e2 -63 -f5 -c1 -c4 -e2 -63 -f5 -04 -25 -00 -00 -00 -00 -c4 -e2 -e3 -f5 -c1 -c4 -e2 -e3 -f5 -04 -25 -00 -00 -00 -00 -c4 -e2 -62 -f5 -c1 -c4 -e2 -62 -f5 -04 -25 -00 -00 -00 -00 -c4 -e2 -e2 -f5 -c1 -c4 -e2 -e2 -f5 -04 -25 -00 -00 -00 -00 -c4 -e3 -7b -f0 -c3 -03 -c4 -e3 -7b -f0 -04 -25 -00 -00 -00 -00 -03 -c4 -e3 -fb -f0 -c3 -03 -c4 -e3 -fb -f0 -04 -25 -00 -00 -00 -00 -03 -c4 -e2 -72 -f7 -c3 -c4 -e2 -72 -f7 -04 -25 -00 -00 -00 -00 -c4 -e2 -f2 -f7 -c3 -c4 -e2 -f2 -f7 -04 -25 -00 -00 -00 -00 -c4 -e2 -71 -f7 -c3 -c4 -e2 -71 -f7 -04 -25 -00 -00 -00 -00 -c4 -e2 -f1 -f7 -c3 -c4 -e2 -f1 -f7 -04 -25 -00 -00 -00 -00 -c4 -e2 -73 -f7 -c3 -c4 -e2 -73 -f7 -04 -25 -00 -00 -00 -00 -c4 -e2 -f3 -f7 -c3 -c4 -e2 -f3 -f7 -04 -25 -00 -00 -00 -00 diff --git a/modules/arch/x86/tests/clmul.asm b/modules/arch/x86/tests/clmul.asm deleted file mode 100644 index 92e168ef..00000000 --- a/modules/arch/x86/tests/clmul.asm +++ /dev/null @@ -1,42 +0,0 @@ -[bits 64] - -pclmulqdq xmm1, xmm2, 5 -pclmulqdq xmm1, [rax], byte 5 -pclmulqdq xmm1, dqword [rax], 5 -vpclmulqdq xmm1, xmm2, 0x10 -vpclmulqdq xmm1, dqword [rbx], 0x10 -vpclmulqdq xmm0, xmm1, xmm2, 0x10 -vpclmulqdq xmm0, xmm1, dqword [rbx], 0x10 - -pclmullqlqdq xmm1, xmm2 -pclmullqlqdq xmm1, [rax] -pclmullqlqdq xmm1, dqword [rax] -vpclmullqlqdq xmm1, xmm2 -vpclmullqlqdq xmm1, dqword[rbx] -vpclmullqlqdq xmm0, xmm1, xmm2 -vpclmullqlqdq xmm0, xmm1, dqword[rbx] - -pclmulhqlqdq xmm1, xmm2 -pclmulhqlqdq xmm1, [rax] -pclmulhqlqdq xmm1, dqword [rax] -vpclmulhqlqdq xmm1, xmm2 -vpclmulhqlqdq xmm1, dqword[rbx] -vpclmulhqlqdq xmm0, xmm1, xmm2 -vpclmulhqlqdq xmm0, xmm1, dqword[rbx] - -pclmullqhqdq xmm1, xmm2 -pclmullqhqdq xmm1, [rax] -pclmullqhqdq xmm1, dqword [rax] -vpclmullqhqdq xmm1, xmm2 -vpclmullqhqdq xmm1, dqword[rbx] -vpclmullqhqdq xmm0, xmm1, xmm2 -vpclmullqhqdq xmm0, xmm1, dqword[rbx] - -pclmulhqhqdq xmm1, xmm2 -pclmulhqhqdq xmm1, [rax] -pclmulhqhqdq xmm1, dqword [rax] -vpclmulhqhqdq xmm1, xmm2 -vpclmulhqhqdq xmm1, dqword[rbx] -vpclmulhqhqdq xmm0, xmm1, xmm2 -vpclmulhqhqdq xmm0, xmm1, dqword[rbx] - diff --git a/modules/arch/x86/tests/clmul.hex b/modules/arch/x86/tests/clmul.hex deleted file mode 100644 index 6aad748a..00000000 --- a/modules/arch/x86/tests/clmul.hex +++ /dev/null @@ -1,210 +0,0 @@ -66 -0f -3a -44 -ca -05 -66 -0f -3a -44 -08 -05 -66 -0f -3a -44 -08 -05 -c4 -e3 -71 -44 -ca -10 -c4 -e3 -71 -44 -0b -10 -c4 -e3 -71 -44 -c2 -10 -c4 -e3 -71 -44 -03 -10 -66 -0f -3a -44 -ca -00 -66 -0f -3a -44 -08 -00 -66 -0f -3a -44 -08 -00 -c4 -e3 -71 -44 -ca -00 -c4 -e3 -71 -44 -0b -00 -c4 -e3 -71 -44 -c2 -00 -c4 -e3 -71 -44 -03 -00 -66 -0f -3a -44 -ca -01 -66 -0f -3a -44 -08 -01 -66 -0f -3a -44 -08 -01 -c4 -e3 -71 -44 -ca -01 -c4 -e3 -71 -44 -0b -01 -c4 -e3 -71 -44 -c2 -01 -c4 -e3 -71 -44 -03 -01 -66 -0f -3a -44 -ca -10 -66 -0f -3a -44 -08 -10 -66 -0f -3a -44 -08 -10 -c4 -e3 -71 -44 -ca -10 -c4 -e3 -71 -44 -0b -10 -c4 -e3 -71 -44 -c2 -10 -c4 -e3 -71 -44 -03 -10 -66 -0f -3a -44 -ca -11 -66 -0f -3a -44 -08 -11 -66 -0f -3a -44 -08 -11 -c4 -e3 -71 -44 -ca -11 -c4 -e3 -71 -44 -0b -11 -c4 -e3 -71 -44 -c2 -11 -c4 -e3 -71 -44 -03 -11 diff --git a/modules/arch/x86/tests/cpubasic-err.errwarn b/modules/arch/x86/tests/cpubasic-err.errwarn index 3c2b876c..917843e5 100644 --- a/modules/arch/x86/tests/cpubasic-err.errwarn +++ b/modules/arch/x86/tests/cpubasic-err.errwarn @@ -1,6 +1,6 @@ -:2: warning: `pause' is an instruction in CPU P4 --:4: error: requires CPU 186 +-:4: requires CPU 186 -:7: warning: `fninit' is an instruction in CPU FPU --:15: error: requires CPU 186 +-:15: requires CPU 186 -:16: warning: `movsd' is an instruction in CPU 386 --:17: error: requires CPU 186 +-:17: requires CPU 186 diff --git a/modules/arch/x86/tests/div-err.errwarn b/modules/arch/x86/tests/div-err.errwarn index af466252..4b6340e7 100644 --- a/modules/arch/x86/tests/div-err.errwarn +++ b/modules/arch/x86/tests/div-err.errwarn @@ -1,4 +1,4 @@ --:1: error: cannot override register size --:3: error: cannot override register size --:4: error: cannot override register size --:5: error: cannot override register size +-:1: cannot override register size +-:3: cannot override register size +-:4: cannot override register size +-:5: cannot override register size diff --git a/modules/arch/x86/tests/effaddr.asm b/modules/arch/x86/tests/effaddr.asm index 1a22a158..5a165c9a 100644 --- a/modules/arch/x86/tests/effaddr.asm +++ b/modules/arch/x86/tests/effaddr.asm @@ -15,4 +15,3 @@ label dd 5 label2 ;mov ax,[eax+ebx*(label2-label)] ; not supported -mov ax,[eax*2+ebx*2-ebx] diff --git a/modules/arch/x86/tests/effaddr.hex b/modules/arch/x86/tests/effaddr.hex index 225a2152..b3628f0d 100644 --- a/modules/arch/x86/tests/effaddr.hex +++ b/modules/arch/x86/tests/effaddr.hex @@ -57,7 +57,3 @@ f8 00 00 00 -66 -8b -04 -43 diff --git a/modules/arch/x86/tests/eptvpid.asm b/modules/arch/x86/tests/eptvpid.asm deleted file mode 100644 index 8c4881f4..00000000 --- a/modules/arch/x86/tests/eptvpid.asm +++ /dev/null @@ -1,8 +0,0 @@ -[bits 32] -invept eax, [eax] -invvpid eax, [eax] - -[bits 64] -invept rax, [rax] -invvpid rax, [rax] - diff --git a/modules/arch/x86/tests/eptvpid.hex b/modules/arch/x86/tests/eptvpid.hex deleted file mode 100644 index 1e2c2420..00000000 --- a/modules/arch/x86/tests/eptvpid.hex +++ /dev/null @@ -1,22 +0,0 @@ -66 -0f -38 -80 -00 -66 -0f -38 -81 -00 -66 -48 -0f -38 -80 -00 -66 -48 -0f -38 -81 -00 diff --git a/modules/arch/x86/tests/f16c.asm b/modules/arch/x86/tests/f16c.asm deleted file mode 100644 index 06fa5f1d..00000000 --- a/modules/arch/x86/tests/f16c.asm +++ /dev/null @@ -1,10 +0,0 @@ -[bits 64] -vcvtph2ps ymm1, xmm2 -vcvtph2ps ymm1, oword [0] -vcvtph2ps xmm1, xmm2 -vcvtph2ps xmm1, qword [0] - -vcvtps2ph xmm1, ymm2, 4 -vcvtps2ph oword [0], ymm2, 8 -vcvtps2ph xmm1, xmm2, 3 -vcvtps2ph qword [0], xmm2, 5 diff --git a/modules/arch/x86/tests/f16c.hex b/modules/arch/x86/tests/f16c.hex deleted file mode 100644 index 8ba06fc7..00000000 --- a/modules/arch/x86/tests/f16c.hex +++ /dev/null @@ -1,64 +0,0 @@ -c4 -e2 -7d -13 -ca -c4 -e2 -7d -13 -0c -25 -00 -00 -00 -00 -c4 -e2 -79 -13 -ca -c4 -e2 -79 -13 -0c -25 -00 -00 -00 -00 -c4 -e3 -7d -1d -d1 -04 -c4 -e3 -7d -1d -14 -25 -00 -00 -00 -00 -08 -c4 -e3 -79 -1d -d1 -03 -c4 -e3 -79 -1d -14 -25 -00 -00 -00 -00 -05 diff --git a/modules/arch/x86/tests/farbasic.asm b/modules/arch/x86/tests/farbasic.asm index fa1ced0f..0c2648dc 100644 --- a/modules/arch/x86/tests/farbasic.asm +++ b/modules/arch/x86/tests/farbasic.asm @@ -1,10 +1,10 @@ -equval equ 6:7 - [bits 32] jmp 5:4 -jmp far equval +jmp equval + +equval equ 6:7 [bits 16] diff --git a/modules/arch/x86/tests/fma.asm b/modules/arch/x86/tests/fma.asm deleted file mode 100644 index 9bfb512b..00000000 --- a/modules/arch/x86/tests/fma.asm +++ /dev/null @@ -1,289 +0,0 @@ -[bits 64] -vfmadd132ss xmm1, xmm2, xmm3 -vfmadd132ss xmm1, xmm2, dword [rax] -vfmadd132ss xmm1, xmm2, [rax] -vfmadd231ss xmm1, xmm2, xmm3 -vfmadd231ss xmm1, xmm2, dword [rax] -vfmadd231ss xmm1, xmm2, [rax] -vfmadd213ss xmm1, xmm2, xmm3 -vfmadd213ss xmm1, xmm2, dword [rax] -vfmadd213ss xmm1, xmm2, [rax] -vfmadd132sd xmm1, xmm2, xmm3 -vfmadd132sd xmm1, xmm2, qword [rax] -vfmadd132sd xmm1, xmm2, [rax] -vfmadd231sd xmm1, xmm2, xmm3 -vfmadd231sd xmm1, xmm2, qword [rax] -vfmadd231sd xmm1, xmm2, [rax] -vfmadd213sd xmm1, xmm2, xmm3 -vfmadd213sd xmm1, xmm2, qword [rax] -vfmadd213sd xmm1, xmm2, [rax] -vfmadd132ps xmm1, xmm2, xmm3 -vfmadd132ps xmm1, xmm2, xmm3 -vfmadd132ps xmm1, xmm2, [rax] -vfmadd231ps xmm1, xmm2, xmm3 -vfmadd231ps xmm1, xmm2, xmm3 -vfmadd231ps xmm1, xmm2, [rax] -vfmadd213ps xmm1, xmm2, xmm3 -vfmadd213ps xmm1, xmm2, xmm3 -vfmadd213ps xmm1, xmm2, [rax] -vfmadd132ps ymm1, ymm2, ymm3 -vfmadd132ps ymm1, ymm2, yword [rax] -vfmadd132ps ymm1, ymm2, [rax] -vfmadd231ps ymm1, ymm2, ymm3 -vfmadd231ps ymm1, ymm2, yword [rax] -vfmadd231ps ymm1, ymm2, [rax] -vfmadd213ps ymm1, ymm2, ymm3 -vfmadd213ps ymm1, ymm2, yword [rax] -vfmadd213ps ymm1, ymm2, [rax] -vfmadd132pd xmm1, xmm2, xmm3 -vfmadd132pd xmm1, xmm2, dqword [rax] -vfmadd132pd xmm1, xmm2, [rax] -vfmadd231pd xmm1, xmm2, xmm3 -vfmadd231pd xmm1, xmm2, dqword [rax] -vfmadd231pd xmm1, xmm2, [rax] -vfmadd213pd xmm1, xmm2, xmm3 -vfmadd213pd xmm1, xmm2, dqword [rax] -vfmadd213pd xmm1, xmm2, [rax] -vfmadd132pd ymm1, ymm2, ymm3 -vfmadd132pd ymm1, ymm2, yword [rax] -vfmadd132pd ymm1, ymm2, [rax] -vfmadd231pd ymm1, ymm2, ymm3 -vfmadd231pd ymm1, ymm2, yword [rax] -vfmadd231pd ymm1, ymm2, [rax] -vfmadd213pd ymm1, ymm2, ymm3 -vfmadd213pd ymm1, ymm2, yword [rax] -vfmadd213pd ymm1, ymm2, [rax] -vfmsub132ss xmm1, xmm2, xmm3 -vfmsub132ss xmm1, xmm2, dword [rax] -vfmsub132ss xmm1, xmm2, [rax] -vfmsub231ss xmm1, xmm2, xmm3 -vfmsub231ss xmm1, xmm2, dword [rax] -vfmsub231ss xmm1, xmm2, [rax] -vfmsub213ss xmm1, xmm2, xmm3 -vfmsub213ss xmm1, xmm2, dword [rax] -vfmsub213ss xmm1, xmm2, [rax] -vfmsub132sd xmm1, xmm2, xmm3 -vfmsub132sd xmm1, xmm2, qword [rax] -vfmsub132sd xmm1, xmm2, [rax] -vfmsub231sd xmm1, xmm2, xmm3 -vfmsub231sd xmm1, xmm2, qword [rax] -vfmsub231sd xmm1, xmm2, [rax] -vfmsub213sd xmm1, xmm2, xmm3 -vfmsub213sd xmm1, xmm2, qword [rax] -vfmsub213sd xmm1, xmm2, [rax] -vfmsub132ps xmm1, xmm2, xmm3 -vfmsub132ps xmm1, xmm2, xmm3 -vfmsub132ps xmm1, xmm2, [rax] -vfmsub231ps xmm1, xmm2, xmm3 -vfmsub231ps xmm1, xmm2, xmm3 -vfmsub231ps xmm1, xmm2, [rax] -vfmsub213ps xmm1, xmm2, xmm3 -vfmsub213ps xmm1, xmm2, xmm3 -vfmsub213ps xmm1, xmm2, [rax] -vfmsub132ps ymm1, ymm2, ymm3 -vfmsub132ps ymm1, ymm2, yword [rax] -vfmsub132ps ymm1, ymm2, [rax] -vfmsub231ps ymm1, ymm2, ymm3 -vfmsub231ps ymm1, ymm2, yword [rax] -vfmsub231ps ymm1, ymm2, [rax] -vfmsub213ps ymm1, ymm2, ymm3 -vfmsub213ps ymm1, ymm2, yword [rax] -vfmsub213ps ymm1, ymm2, [rax] -vfmsub132pd xmm1, xmm2, xmm3 -vfmsub132pd xmm1, xmm2, dqword [rax] -vfmsub132pd xmm1, xmm2, [rax] -vfmsub231pd xmm1, xmm2, xmm3 -vfmsub231pd xmm1, xmm2, dqword [rax] -vfmsub231pd xmm1, xmm2, [rax] -vfmsub213pd xmm1, xmm2, xmm3 -vfmsub213pd xmm1, xmm2, dqword [rax] -vfmsub213pd xmm1, xmm2, [rax] -vfmsub132pd ymm1, ymm2, ymm3 -vfmsub132pd ymm1, ymm2, yword [rax] -vfmsub132pd ymm1, ymm2, [rax] -vfmsub231pd ymm1, ymm2, ymm3 -vfmsub231pd ymm1, ymm2, yword [rax] -vfmsub231pd ymm1, ymm2, [rax] -vfmsub213pd ymm1, ymm2, ymm3 -vfmsub213pd ymm1, ymm2, yword [rax] -vfmsub213pd ymm1, ymm2, [rax] -vfnmadd132ss xmm1, xmm2, xmm3 -vfnmadd132ss xmm1, xmm2, dword [rax] -vfnmadd132ss xmm1, xmm2, [rax] -vfnmadd231ss xmm1, xmm2, xmm3 -vfnmadd231ss xmm1, xmm2, dword [rax] -vfnmadd231ss xmm1, xmm2, [rax] -vfnmadd213ss xmm1, xmm2, xmm3 -vfnmadd213ss xmm1, xmm2, dword [rax] -vfnmadd213ss xmm1, xmm2, [rax] -vfnmadd132sd xmm1, xmm2, xmm3 -vfnmadd132sd xmm1, xmm2, qword [rax] -vfnmadd132sd xmm1, xmm2, [rax] -vfnmadd231sd xmm1, xmm2, xmm3 -vfnmadd231sd xmm1, xmm2, qword [rax] -vfnmadd231sd xmm1, xmm2, [rax] -vfnmadd213sd xmm1, xmm2, xmm3 -vfnmadd213sd xmm1, xmm2, qword [rax] -vfnmadd213sd xmm1, xmm2, [rax] -vfnmadd132ps xmm1, xmm2, xmm3 -vfnmadd132ps xmm1, xmm2, xmm3 -vfnmadd132ps xmm1, xmm2, [rax] -vfnmadd231ps xmm1, xmm2, xmm3 -vfnmadd231ps xmm1, xmm2, xmm3 -vfnmadd231ps xmm1, xmm2, [rax] -vfnmadd213ps xmm1, xmm2, xmm3 -vfnmadd213ps xmm1, xmm2, xmm3 -vfnmadd213ps xmm1, xmm2, [rax] -vfnmadd132ps ymm1, ymm2, ymm3 -vfnmadd132ps ymm1, ymm2, yword [rax] -vfnmadd132ps ymm1, ymm2, [rax] -vfnmadd231ps ymm1, ymm2, ymm3 -vfnmadd231ps ymm1, ymm2, yword [rax] -vfnmadd231ps ymm1, ymm2, [rax] -vfnmadd213ps ymm1, ymm2, ymm3 -vfnmadd213ps ymm1, ymm2, yword [rax] -vfnmadd213ps ymm1, ymm2, [rax] -vfnmadd132pd xmm1, xmm2, xmm3 -vfnmadd132pd xmm1, xmm2, dqword [rax] -vfnmadd132pd xmm1, xmm2, [rax] -vfnmadd231pd xmm1, xmm2, xmm3 -vfnmadd231pd xmm1, xmm2, dqword [rax] -vfnmadd231pd xmm1, xmm2, [rax] -vfnmadd213pd xmm1, xmm2, xmm3 -vfnmadd213pd xmm1, xmm2, dqword [rax] -vfnmadd213pd xmm1, xmm2, [rax] -vfnmadd132pd ymm1, ymm2, ymm3 -vfnmadd132pd ymm1, ymm2, yword [rax] -vfnmadd132pd ymm1, ymm2, [rax] -vfnmadd231pd ymm1, ymm2, ymm3 -vfnmadd231pd ymm1, ymm2, yword [rax] -vfnmadd231pd ymm1, ymm2, [rax] -vfnmadd213pd ymm1, ymm2, ymm3 -vfnmadd213pd ymm1, ymm2, yword [rax] -vfnmadd213pd ymm1, ymm2, [rax] -vfnmsub132ss xmm1, xmm2, xmm3 -vfnmsub132ss xmm1, xmm2, dword [rax] -vfnmsub132ss xmm1, xmm2, [rax] -vfnmsub231ss xmm1, xmm2, xmm3 -vfnmsub231ss xmm1, xmm2, dword [rax] -vfnmsub231ss xmm1, xmm2, [rax] -vfnmsub213ss xmm1, xmm2, xmm3 -vfnmsub213ss xmm1, xmm2, dword [rax] -vfnmsub213ss xmm1, xmm2, [rax] -vfnmsub132sd xmm1, xmm2, xmm3 -vfnmsub132sd xmm1, xmm2, qword [rax] -vfnmsub132sd xmm1, xmm2, [rax] -vfnmsub231sd xmm1, xmm2, xmm3 -vfnmsub231sd xmm1, xmm2, qword [rax] -vfnmsub231sd xmm1, xmm2, [rax] -vfnmsub213sd xmm1, xmm2, xmm3 -vfnmsub213sd xmm1, xmm2, qword [rax] -vfnmsub213sd xmm1, xmm2, [rax] -vfnmsub132ps xmm1, xmm2, xmm3 -vfnmsub132ps xmm1, xmm2, xmm3 -vfnmsub132ps xmm1, xmm2, [rax] -vfnmsub231ps xmm1, xmm2, xmm3 -vfnmsub231ps xmm1, xmm2, xmm3 -vfnmsub231ps xmm1, xmm2, [rax] -vfnmsub213ps xmm1, xmm2, xmm3 -vfnmsub213ps xmm1, xmm2, xmm3 -vfnmsub213ps xmm1, xmm2, [rax] -vfnmsub132ps ymm1, ymm2, ymm3 -vfnmsub132ps ymm1, ymm2, yword [rax] -vfnmsub132ps ymm1, ymm2, [rax] -vfnmsub231ps ymm1, ymm2, ymm3 -vfnmsub231ps ymm1, ymm2, yword [rax] -vfnmsub231ps ymm1, ymm2, [rax] -vfnmsub213ps ymm1, ymm2, ymm3 -vfnmsub213ps ymm1, ymm2, yword [rax] -vfnmsub213ps ymm1, ymm2, [rax] -vfnmsub132pd xmm1, xmm2, xmm3 -vfnmsub132pd xmm1, xmm2, dqword [rax] -vfnmsub132pd xmm1, xmm2, [rax] -vfnmsub231pd xmm1, xmm2, xmm3 -vfnmsub231pd xmm1, xmm2, dqword [rax] -vfnmsub231pd xmm1, xmm2, [rax] -vfnmsub213pd xmm1, xmm2, xmm3 -vfnmsub213pd xmm1, xmm2, dqword [rax] -vfnmsub213pd xmm1, xmm2, [rax] -vfnmsub132pd ymm1, ymm2, ymm3 -vfnmsub132pd ymm1, ymm2, yword [rax] -vfnmsub132pd ymm1, ymm2, [rax] -vfnmsub231pd ymm1, ymm2, ymm3 -vfnmsub231pd ymm1, ymm2, yword [rax] -vfnmsub231pd ymm1, ymm2, [rax] -vfnmsub213pd ymm1, ymm2, ymm3 -vfnmsub213pd ymm1, ymm2, yword [rax] -vfnmsub213pd ymm1, ymm2, [rax] -vfmaddsub132ps xmm1, xmm2, xmm3 -vfmaddsub132ps xmm1, xmm2, xmm3 -vfmaddsub132ps xmm1, xmm2, [rax] -vfmaddsub231ps xmm1, xmm2, xmm3 -vfmaddsub231ps xmm1, xmm2, xmm3 -vfmaddsub231ps xmm1, xmm2, [rax] -vfmaddsub213ps xmm1, xmm2, xmm3 -vfmaddsub213ps xmm1, xmm2, xmm3 -vfmaddsub213ps xmm1, xmm2, [rax] -vfmaddsub132ps ymm1, ymm2, ymm3 -vfmaddsub132ps ymm1, ymm2, yword [rax] -vfmaddsub132ps ymm1, ymm2, [rax] -vfmaddsub231ps ymm1, ymm2, ymm3 -vfmaddsub231ps ymm1, ymm2, yword [rax] -vfmaddsub231ps ymm1, ymm2, [rax] -vfmaddsub213ps ymm1, ymm2, ymm3 -vfmaddsub213ps ymm1, ymm2, yword [rax] -vfmaddsub213ps ymm1, ymm2, [rax] -vfmaddsub132pd xmm1, xmm2, xmm3 -vfmaddsub132pd xmm1, xmm2, dqword [rax] -vfmaddsub132pd xmm1, xmm2, [rax] -vfmaddsub231pd xmm1, xmm2, xmm3 -vfmaddsub231pd xmm1, xmm2, dqword [rax] -vfmaddsub231pd xmm1, xmm2, [rax] -vfmaddsub213pd xmm1, xmm2, xmm3 -vfmaddsub213pd xmm1, xmm2, dqword [rax] -vfmaddsub213pd xmm1, xmm2, [rax] -vfmaddsub132pd ymm1, ymm2, ymm3 -vfmaddsub132pd ymm1, ymm2, yword [rax] -vfmaddsub132pd ymm1, ymm2, [rax] -vfmaddsub231pd ymm1, ymm2, ymm3 -vfmaddsub231pd ymm1, ymm2, yword [rax] -vfmaddsub231pd ymm1, ymm2, [rax] -vfmaddsub213pd ymm1, ymm2, ymm3 -vfmaddsub213pd ymm1, ymm2, yword [rax] -vfmaddsub213pd ymm1, ymm2, [rax] -vfmsubadd132ps xmm1, xmm2, xmm3 -vfmsubadd132ps xmm1, xmm2, xmm3 -vfmsubadd132ps xmm1, xmm2, [rax] -vfmsubadd231ps xmm1, xmm2, xmm3 -vfmsubadd231ps xmm1, xmm2, xmm3 -vfmsubadd231ps xmm1, xmm2, [rax] -vfmsubadd213ps xmm1, xmm2, xmm3 -vfmsubadd213ps xmm1, xmm2, xmm3 -vfmsubadd213ps xmm1, xmm2, [rax] -vfmsubadd132ps ymm1, ymm2, ymm3 -vfmsubadd132ps ymm1, ymm2, yword [rax] -vfmsubadd132ps ymm1, ymm2, [rax] -vfmsubadd231ps ymm1, ymm2, ymm3 -vfmsubadd231ps ymm1, ymm2, yword [rax] -vfmsubadd231ps ymm1, ymm2, [rax] -vfmsubadd213ps ymm1, ymm2, ymm3 -vfmsubadd213ps ymm1, ymm2, yword [rax] -vfmsubadd213ps ymm1, ymm2, [rax] -vfmsubadd132pd xmm1, xmm2, xmm3 -vfmsubadd132pd xmm1, xmm2, dqword [rax] -vfmsubadd132pd xmm1, xmm2, [rax] -vfmsubadd231pd xmm1, xmm2, xmm3 -vfmsubadd231pd xmm1, xmm2, dqword [rax] -vfmsubadd231pd xmm1, xmm2, [rax] -vfmsubadd213pd xmm1, xmm2, xmm3 -vfmsubadd213pd xmm1, xmm2, dqword [rax] -vfmsubadd213pd xmm1, xmm2, [rax] -vfmsubadd132pd ymm1, ymm2, ymm3 -vfmsubadd132pd ymm1, ymm2, yword [rax] -vfmsubadd132pd ymm1, ymm2, [rax] -vfmsubadd231pd ymm1, ymm2, ymm3 -vfmsubadd231pd ymm1, ymm2, yword [rax] -vfmsubadd231pd ymm1, ymm2, [rax] -vfmsubadd213pd ymm1, ymm2, ymm3 -vfmsubadd213pd ymm1, ymm2, yword [rax] -vfmsubadd213pd ymm1, ymm2, [rax] diff --git a/modules/arch/x86/tests/fma.hex b/modules/arch/x86/tests/fma.hex deleted file mode 100644 index 161933f9..00000000 --- a/modules/arch/x86/tests/fma.hex +++ /dev/null @@ -1,1440 +0,0 @@ -c4 -e2 -69 -99 -cb -c4 -e2 -69 -99 -08 -c4 -e2 -69 -99 -08 -c4 -e2 -69 -b9 -cb -c4 -e2 -69 -b9 -08 -c4 -e2 -69 -b9 -08 -c4 -e2 -69 -a9 -cb -c4 -e2 -69 -a9 -08 -c4 -e2 -69 -a9 -08 -c4 -e2 -e9 -99 -cb -c4 -e2 -e9 -99 -08 -c4 -e2 -e9 -99 -08 -c4 -e2 -e9 -b9 -cb -c4 -e2 -e9 -b9 -08 -c4 -e2 -e9 -b9 -08 -c4 -e2 -e9 -a9 -cb -c4 -e2 -e9 -a9 -08 -c4 -e2 -e9 -a9 -08 -c4 -e2 -69 -98 -cb -c4 -e2 -69 -98 -cb -c4 -e2 -69 -98 -08 -c4 -e2 -69 -b8 -cb -c4 -e2 -69 -b8 -cb -c4 -e2 -69 -b8 -08 -c4 -e2 -69 -a8 -cb -c4 -e2 -69 -a8 -cb -c4 -e2 -69 -a8 -08 -c4 -e2 -6d -98 -cb -c4 -e2 -6d -98 -08 -c4 -e2 -6d -98 -08 -c4 -e2 -6d -b8 -cb -c4 -e2 -6d -b8 -08 -c4 -e2 -6d -b8 -08 -c4 -e2 -6d -a8 -cb -c4 -e2 -6d -a8 -08 -c4 -e2 -6d -a8 -08 -c4 -e2 -e9 -98 -cb -c4 -e2 -e9 -98 -08 -c4 -e2 -e9 -98 -08 -c4 -e2 -e9 -b8 -cb -c4 -e2 -e9 -b8 -08 -c4 -e2 -e9 -b8 -08 -c4 -e2 -e9 -a8 -cb -c4 -e2 -e9 -a8 -08 -c4 -e2 -e9 -a8 -08 -c4 -e2 -ed -98 -cb -c4 -e2 -ed -98 -08 -c4 -e2 -ed -98 -08 -c4 -e2 -ed -b8 -cb -c4 -e2 -ed -b8 -08 -c4 -e2 -ed -b8 -08 -c4 -e2 -ed -a8 -cb -c4 -e2 -ed -a8 -08 -c4 -e2 -ed -a8 -08 -c4 -e2 -69 -9b -cb -c4 -e2 -69 -9b -08 -c4 -e2 -69 -9b -08 -c4 -e2 -69 -bb -cb -c4 -e2 -69 -bb -08 -c4 -e2 -69 -bb -08 -c4 -e2 -69 -ab -cb -c4 -e2 -69 -ab -08 -c4 -e2 -69 -ab -08 -c4 -e2 -e9 -9b -cb -c4 -e2 -e9 -9b -08 -c4 -e2 -e9 -9b -08 -c4 -e2 -e9 -bb -cb -c4 -e2 -e9 -bb -08 -c4 -e2 -e9 -bb -08 -c4 -e2 -e9 -ab -cb -c4 -e2 -e9 -ab -08 -c4 -e2 -e9 -ab -08 -c4 -e2 -69 -9a -cb -c4 -e2 -69 -9a -cb -c4 -e2 -69 -9a -08 -c4 -e2 -69 -ba -cb -c4 -e2 -69 -ba -cb -c4 -e2 -69 -ba -08 -c4 -e2 -69 -aa -cb -c4 -e2 -69 -aa -cb -c4 -e2 -69 -aa -08 -c4 -e2 -6d -9a -cb -c4 -e2 -6d -9a -08 -c4 -e2 -6d -9a -08 -c4 -e2 -6d -ba -cb -c4 -e2 -6d -ba -08 -c4 -e2 -6d -ba -08 -c4 -e2 -6d -aa -cb -c4 -e2 -6d -aa -08 -c4 -e2 -6d -aa -08 -c4 -e2 -e9 -9a -cb -c4 -e2 -e9 -9a -08 -c4 -e2 -e9 -9a -08 -c4 -e2 -e9 -ba -cb -c4 -e2 -e9 -ba -08 -c4 -e2 -e9 -ba -08 -c4 -e2 -e9 -aa -cb -c4 -e2 -e9 -aa -08 -c4 -e2 -e9 -aa -08 -c4 -e2 -ed -9a -cb -c4 -e2 -ed -9a -08 -c4 -e2 -ed -9a -08 -c4 -e2 -ed -ba -cb -c4 -e2 -ed -ba -08 -c4 -e2 -ed -ba -08 -c4 -e2 -ed -aa -cb -c4 -e2 -ed -aa -08 -c4 -e2 -ed -aa -08 -c4 -e2 -69 -9d -cb -c4 -e2 -69 -9d -08 -c4 -e2 -69 -9d -08 -c4 -e2 -69 -bd -cb -c4 -e2 -69 -bd -08 -c4 -e2 -69 -bd -08 -c4 -e2 -69 -ad -cb -c4 -e2 -69 -ad -08 -c4 -e2 -69 -ad -08 -c4 -e2 -e9 -9d -cb -c4 -e2 -e9 -9d -08 -c4 -e2 -e9 -9d -08 -c4 -e2 -e9 -bd -cb -c4 -e2 -e9 -bd -08 -c4 -e2 -e9 -bd -08 -c4 -e2 -e9 -ad -cb -c4 -e2 -e9 -ad -08 -c4 -e2 -e9 -ad -08 -c4 -e2 -69 -9c -cb -c4 -e2 -69 -9c -cb -c4 -e2 -69 -9c -08 -c4 -e2 -69 -bc -cb -c4 -e2 -69 -bc -cb -c4 -e2 -69 -bc -08 -c4 -e2 -69 -ac -cb -c4 -e2 -69 -ac -cb -c4 -e2 -69 -ac -08 -c4 -e2 -6d -9c -cb -c4 -e2 -6d -9c -08 -c4 -e2 -6d -9c -08 -c4 -e2 -6d -bc -cb -c4 -e2 -6d -bc -08 -c4 -e2 -6d -bc -08 -c4 -e2 -6d -ac -cb -c4 -e2 -6d -ac -08 -c4 -e2 -6d -ac -08 -c4 -e2 -e9 -9c -cb -c4 -e2 -e9 -9c -08 -c4 -e2 -e9 -9c -08 -c4 -e2 -e9 -bc -cb -c4 -e2 -e9 -bc -08 -c4 -e2 -e9 -bc -08 -c4 -e2 -e9 -ac -cb -c4 -e2 -e9 -ac -08 -c4 -e2 -e9 -ac -08 -c4 -e2 -ed -9c -cb -c4 -e2 -ed -9c -08 -c4 -e2 -ed -9c -08 -c4 -e2 -ed -bc -cb -c4 -e2 -ed -bc -08 -c4 -e2 -ed -bc -08 -c4 -e2 -ed -ac -cb -c4 -e2 -ed -ac -08 -c4 -e2 -ed -ac -08 -c4 -e2 -69 -9f -cb -c4 -e2 -69 -9f -08 -c4 -e2 -69 -9f -08 -c4 -e2 -69 -bf -cb -c4 -e2 -69 -bf -08 -c4 -e2 -69 -bf -08 -c4 -e2 -69 -af -cb -c4 -e2 -69 -af -08 -c4 -e2 -69 -af -08 -c4 -e2 -e9 -9f -cb -c4 -e2 -e9 -9f -08 -c4 -e2 -e9 -9f -08 -c4 -e2 -e9 -bf -cb -c4 -e2 -e9 -bf -08 -c4 -e2 -e9 -bf -08 -c4 -e2 -e9 -af -cb -c4 -e2 -e9 -af -08 -c4 -e2 -e9 -af -08 -c4 -e2 -69 -9e -cb -c4 -e2 -69 -9e -cb -c4 -e2 -69 -9e -08 -c4 -e2 -69 -be -cb -c4 -e2 -69 -be -cb -c4 -e2 -69 -be -08 -c4 -e2 -69 -ae -cb -c4 -e2 -69 -ae -cb -c4 -e2 -69 -ae -08 -c4 -e2 -6d -9e -cb -c4 -e2 -6d -9e -08 -c4 -e2 -6d -9e -08 -c4 -e2 -6d -be -cb -c4 -e2 -6d -be -08 -c4 -e2 -6d -be -08 -c4 -e2 -6d -ae -cb -c4 -e2 -6d -ae -08 -c4 -e2 -6d -ae -08 -c4 -e2 -e9 -9e -cb -c4 -e2 -e9 -9e -08 -c4 -e2 -e9 -9e -08 -c4 -e2 -e9 -be -cb -c4 -e2 -e9 -be -08 -c4 -e2 -e9 -be -08 -c4 -e2 -e9 -ae -cb -c4 -e2 -e9 -ae -08 -c4 -e2 -e9 -ae -08 -c4 -e2 -ed -9e -cb -c4 -e2 -ed -9e -08 -c4 -e2 -ed -9e -08 -c4 -e2 -ed -be -cb -c4 -e2 -ed -be -08 -c4 -e2 -ed -be -08 -c4 -e2 -ed -ae -cb -c4 -e2 -ed -ae -08 -c4 -e2 -ed -ae -08 -c4 -e2 -69 -96 -cb -c4 -e2 -69 -96 -cb -c4 -e2 -69 -96 -08 -c4 -e2 -69 -b6 -cb -c4 -e2 -69 -b6 -cb -c4 -e2 -69 -b6 -08 -c4 -e2 -69 -a6 -cb -c4 -e2 -69 -a6 -cb -c4 -e2 -69 -a6 -08 -c4 -e2 -6d -96 -cb -c4 -e2 -6d -96 -08 -c4 -e2 -6d -96 -08 -c4 -e2 -6d -b6 -cb -c4 -e2 -6d -b6 -08 -c4 -e2 -6d -b6 -08 -c4 -e2 -6d -a6 -cb -c4 -e2 -6d -a6 -08 -c4 -e2 -6d -a6 -08 -c4 -e2 -e9 -96 -cb -c4 -e2 -e9 -96 -08 -c4 -e2 -e9 -96 -08 -c4 -e2 -e9 -b6 -cb -c4 -e2 -e9 -b6 -08 -c4 -e2 -e9 -b6 -08 -c4 -e2 -e9 -a6 -cb -c4 -e2 -e9 -a6 -08 -c4 -e2 -e9 -a6 -08 -c4 -e2 -ed -96 -cb -c4 -e2 -ed -96 -08 -c4 -e2 -ed -96 -08 -c4 -e2 -ed -b6 -cb -c4 -e2 -ed -b6 -08 -c4 -e2 -ed -b6 -08 -c4 -e2 -ed -a6 -cb -c4 -e2 -ed -a6 -08 -c4 -e2 -ed -a6 -08 -c4 -e2 -69 -97 -cb -c4 -e2 -69 -97 -cb -c4 -e2 -69 -97 -08 -c4 -e2 -69 -b7 -cb -c4 -e2 -69 -b7 -cb -c4 -e2 -69 -b7 -08 -c4 -e2 -69 -a7 -cb -c4 -e2 -69 -a7 -cb -c4 -e2 -69 -a7 -08 -c4 -e2 -6d -97 -cb -c4 -e2 -6d -97 -08 -c4 -e2 -6d -97 -08 -c4 -e2 -6d -b7 -cb -c4 -e2 -6d -b7 -08 -c4 -e2 -6d -b7 -08 -c4 -e2 -6d -a7 -cb -c4 -e2 -6d -a7 -08 -c4 -e2 -6d -a7 -08 -c4 -e2 -e9 -97 -cb -c4 -e2 -e9 -97 -08 -c4 -e2 -e9 -97 -08 -c4 -e2 -e9 -b7 -cb -c4 -e2 -e9 -b7 -08 -c4 -e2 -e9 -b7 -08 -c4 -e2 -e9 -a7 -cb -c4 -e2 -e9 -a7 -08 -c4 -e2 -e9 -a7 -08 -c4 -e2 -ed -97 -cb -c4 -e2 -ed -97 -08 -c4 -e2 -ed -97 -08 -c4 -e2 -ed -b7 -cb -c4 -e2 -ed -b7 -08 -c4 -e2 -ed -b7 -08 -c4 -e2 -ed -a7 -cb -c4 -e2 -ed -a7 -08 -c4 -e2 -ed -a7 -08 diff --git a/modules/arch/x86/tests/fsgsbase.asm b/modules/arch/x86/tests/fsgsbase.asm deleted file mode 100644 index bae73013..00000000 --- a/modules/arch/x86/tests/fsgsbase.asm +++ /dev/null @@ -1,10 +0,0 @@ -[bits 64] -rdfsbase ebx -rdfsbase rbx -rdgsbase ecx -rdgsbase rcx - -wrfsbase ebx -wrfsbase rbx -wrgsbase ecx -wrgsbase rcx diff --git a/modules/arch/x86/tests/fsgsbase.hex b/modules/arch/x86/tests/fsgsbase.hex deleted file mode 100644 index 27b5eee0..00000000 --- a/modules/arch/x86/tests/fsgsbase.hex +++ /dev/null @@ -1,36 +0,0 @@ -f3 -0f -ae -c3 -f3 -48 -0f -ae -c3 -f3 -0f -ae -c9 -f3 -48 -0f -ae -c9 -f3 -0f -ae -d3 -f3 -48 -0f -ae -d3 -f3 -0f -ae -d9 -f3 -48 -0f -ae -d9 diff --git a/modules/arch/x86/tests/gas32/Makefile.inc b/modules/arch/x86/tests/gas32/Makefile.inc index 2f58c668..fbb8ccf4 100644 --- a/modules/arch/x86/tests/gas32/Makefile.inc +++ b/modules/arch/x86/tests/gas32/Makefile.inc @@ -1,3 +1,5 @@ +# $Id$ + TESTS += modules/arch/x86/tests/gas32/x86_gas32_test.sh EXTRA_DIST += modules/arch/x86/tests/gas32/x86_gas32_test.sh @@ -5,20 +7,8 @@ EXTRA_DIST += modules/arch/x86/tests/gas32/align32.asm EXTRA_DIST += modules/arch/x86/tests/gas32/align32.hex EXTRA_DIST += modules/arch/x86/tests/gas32/gas-farithr.asm EXTRA_DIST += modules/arch/x86/tests/gas32/gas-farithr.hex -EXTRA_DIST += modules/arch/x86/tests/gas32/gas-farjump.asm -EXTRA_DIST += modules/arch/x86/tests/gas32/gas-farjump.hex -EXTRA_DIST += modules/arch/x86/tests/gas32/gas-fpmem.asm -EXTRA_DIST += modules/arch/x86/tests/gas32/gas-fpmem.hex -EXTRA_DIST += modules/arch/x86/tests/gas32/gas-invlpg.asm -EXTRA_DIST += modules/arch/x86/tests/gas32/gas-invlpg.hex -EXTRA_DIST += modules/arch/x86/tests/gas32/gas-loop32.asm -EXTRA_DIST += modules/arch/x86/tests/gas32/gas-loop32.hex EXTRA_DIST += modules/arch/x86/tests/gas32/gas-movdq32.asm EXTRA_DIST += modules/arch/x86/tests/gas32/gas-movdq32.hex -EXTRA_DIST += modules/arch/x86/tests/gas32/gas-movsd.asm -EXTRA_DIST += modules/arch/x86/tests/gas32/gas-movsd.hex -EXTRA_DIST += modules/arch/x86/tests/gas32/gas-pop.asm -EXTRA_DIST += modules/arch/x86/tests/gas32/gas-pop.hex EXTRA_DIST += modules/arch/x86/tests/gas32/gas32-jmpcall.asm EXTRA_DIST += modules/arch/x86/tests/gas32/gas32-jmpcall.hex diff --git a/modules/arch/x86/tests/gas32/align32.hex b/modules/arch/x86/tests/gas32/align32.hex index 8fb42419..77181969 100644 --- a/modules/arch/x86/tests/gas32/align32.hex +++ b/modules/arch/x86/tests/gas32/align32.hex @@ -228,8 +228,8 @@ ff 00 ff ff -66 -90 +89 +f6 ff 90 00 diff --git a/modules/arch/x86/tests/gas32/gas-farjump.asm b/modules/arch/x86/tests/gas32/gas-farjump.asm deleted file mode 100644 index 6d890da2..00000000 --- a/modules/arch/x86/tests/gas32/gas-farjump.asm +++ /dev/null @@ -1,13 +0,0 @@ -call $0x1234, $0x567890ab -lcall $0x1234, $0x567890ab -jmp $0x1234, $0x567890ab -ljmp $0x1234, $0x567890ab -ljmp *(%eax) -lcall *(%eax) -jmp *(%eax) -call *(%eax) -jmp *%eax -call *%eax -ret -lret -lret $0x100 diff --git a/modules/arch/x86/tests/gas32/gas-farjump.hex b/modules/arch/x86/tests/gas32/gas-farjump.hex deleted file mode 100644 index 839492d4..00000000 --- a/modules/arch/x86/tests/gas32/gas-farjump.hex +++ /dev/null @@ -1,408 +0,0 @@ -7f -45 -4c -46 -01 -01 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -01 -00 -03 -00 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -d0 -00 -00 -00 -00 -00 -00 -00 -34 -00 -00 -00 -00 -00 -28 -00 -05 -00 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -9a -ab -90 -78 -56 -34 -12 -9a -ab -90 -78 -56 -34 -12 -ea -ab -90 -78 -56 -34 -12 -ea -ab -90 -78 -56 -34 -12 -ff -28 -ff -18 -ff -20 -ff -10 -ff -e0 -ff -d0 -c3 -cb -ca -00 -01 -00 -00 -00 -00 -2e -74 -65 -78 -74 -00 -2e -73 -74 -72 -74 -61 -62 -00 -2e -73 -79 -6d -74 -61 -62 -00 -2e -73 -68 -73 -74 -72 -74 -61 -62 -00 -00 -00 -00 -00 -2d -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -04 -00 -f1 -ff -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -03 -00 -04 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -17 -00 -00 -00 -03 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -70 -00 -00 -00 -21 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -07 -00 -00 -00 -03 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -94 -00 -00 -00 -03 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -0f -00 -00 -00 -02 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -98 -00 -00 -00 -30 -00 -00 -00 -02 -00 -00 -00 -03 -00 -00 -00 -04 -00 -00 -00 -10 -00 -00 -00 -01 -00 -00 -00 -01 -00 -00 -00 -06 -00 -00 -00 -00 -00 -00 -00 -40 -00 -00 -00 -2d -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -10 -00 -00 -00 -00 -00 -00 -00 diff --git a/modules/arch/x86/tests/gas32/gas-fpmem.asm b/modules/arch/x86/tests/gas32/gas-fpmem.asm deleted file mode 100644 index ca905308..00000000 --- a/modules/arch/x86/tests/gas32/gas-fpmem.asm +++ /dev/null @@ -1,11 +0,0 @@ -.text -fcomp -fcomp %st(1) -fcomp 0(%eax) -fcomps 0(%eax) -fcompl 0(%eax) - -fistp 0(%eax) -fistps 0(%eax) -fistpl 0(%eax) - diff --git a/modules/arch/x86/tests/gas32/gas-fpmem.hex b/modules/arch/x86/tests/gas32/gas-fpmem.hex deleted file mode 100644 index 81d6a3a0..00000000 --- a/modules/arch/x86/tests/gas32/gas-fpmem.hex +++ /dev/null @@ -1,376 +0,0 @@ -7f -45 -4c -46 -01 -01 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -01 -00 -03 -00 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -b0 -00 -00 -00 -00 -00 -00 -00 -34 -00 -00 -00 -00 -00 -28 -00 -05 -00 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -d8 -d9 -d8 -d9 -d8 -18 -d8 -18 -dc -18 -df -18 -df -18 -db -18 -00 -2e -74 -65 -78 -74 -00 -2e -73 -74 -72 -74 -61 -62 -00 -2e -73 -79 -6d -74 -61 -62 -00 -2e -73 -68 -73 -74 -72 -74 -61 -62 -00 -00 -00 -00 -00 -2d -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -04 -00 -f1 -ff -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -03 -00 -04 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -17 -00 -00 -00 -03 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -50 -00 -00 -00 -21 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -07 -00 -00 -00 -03 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -74 -00 -00 -00 -03 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -0f -00 -00 -00 -02 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -78 -00 -00 -00 -30 -00 -00 -00 -02 -00 -00 -00 -03 -00 -00 -00 -04 -00 -00 -00 -10 -00 -00 -00 -01 -00 -00 -00 -01 -00 -00 -00 -06 -00 -00 -00 -00 -00 -00 -00 -40 -00 -00 -00 -10 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -10 -00 -00 -00 -00 -00 -00 -00 diff --git a/modules/arch/x86/tests/gas32/gas-invlpg.asm b/modules/arch/x86/tests/gas32/gas-invlpg.asm deleted file mode 100644 index f7d6faa9..00000000 --- a/modules/arch/x86/tests/gas32/gas-invlpg.asm +++ /dev/null @@ -1,2 +0,0 @@ -invlpg (%eax) - diff --git a/modules/arch/x86/tests/gas32/gas-invlpg.hex b/modules/arch/x86/tests/gas32/gas-invlpg.hex deleted file mode 100644 index c40e0506..00000000 --- a/modules/arch/x86/tests/gas32/gas-invlpg.hex +++ /dev/null @@ -1,360 +0,0 @@ -7f -45 -4c -46 -01 -01 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -01 -00 -03 -00 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -a0 -00 -00 -00 -00 -00 -00 -00 -34 -00 -00 -00 -00 -00 -28 -00 -05 -00 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -0f -01 -38 -00 -00 -2e -74 -65 -78 -74 -00 -2e -73 -74 -72 -74 -61 -62 -00 -2e -73 -79 -6d -74 -61 -62 -00 -2e -73 -68 -73 -74 -72 -74 -61 -62 -00 -00 -00 -00 -00 -2d -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -04 -00 -f1 -ff -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -03 -00 -04 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -17 -00 -00 -00 -03 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -44 -00 -00 -00 -21 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -07 -00 -00 -00 -03 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -68 -00 -00 -00 -03 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -0f -00 -00 -00 -02 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -6c -00 -00 -00 -30 -00 -00 -00 -02 -00 -00 -00 -03 -00 -00 -00 -04 -00 -00 -00 -10 -00 -00 -00 -01 -00 -00 -00 -01 -00 -00 -00 -06 -00 -00 -00 -00 -00 -00 -00 -40 -00 -00 -00 -03 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -10 -00 -00 -00 -00 -00 -00 -00 diff --git a/modules/arch/x86/tests/gas32/gas-loop32.asm b/modules/arch/x86/tests/gas32/gas-loop32.asm deleted file mode 100644 index 3b5777de..00000000 --- a/modules/arch/x86/tests/gas32/gas-loop32.asm +++ /dev/null @@ -1,5 +0,0 @@ -loop label -loopw label -loopl label -#loopq label -label: diff --git a/modules/arch/x86/tests/gas32/gas-loop32.hex b/modules/arch/x86/tests/gas32/gas-loop32.hex deleted file mode 100644 index 5bf161bc..00000000 --- a/modules/arch/x86/tests/gas32/gas-loop32.hex +++ /dev/null @@ -1,376 +0,0 @@ -7f -45 -4c -46 -01 -01 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -01 -00 -03 -00 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -b0 -00 -00 -00 -00 -00 -00 -00 -34 -00 -00 -00 -00 -00 -28 -00 -05 -00 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -e2 -05 -67 -e2 -02 -e2 -00 -00 -00 -2e -74 -65 -78 -74 -00 -2e -73 -74 -72 -74 -61 -62 -00 -2e -73 -79 -6d -74 -61 -62 -00 -2e -73 -68 -73 -74 -72 -74 -61 -62 -00 -00 -00 -00 -00 -2d -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -04 -00 -f1 -ff -00 -00 -00 -00 -07 -00 -00 -00 -00 -00 -00 -00 -00 -00 -04 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -03 -00 -04 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -17 -00 -00 -00 -03 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -48 -00 -00 -00 -21 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -07 -00 -00 -00 -03 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -6c -00 -00 -00 -03 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -0f -00 -00 -00 -02 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -70 -00 -00 -00 -40 -00 -00 -00 -02 -00 -00 -00 -04 -00 -00 -00 -04 -00 -00 -00 -10 -00 -00 -00 -01 -00 -00 -00 -01 -00 -00 -00 -06 -00 -00 -00 -00 -00 -00 -00 -40 -00 -00 -00 -07 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -10 -00 -00 -00 -00 -00 -00 -00 diff --git a/modules/arch/x86/tests/gas32/gas-movsd.asm b/modules/arch/x86/tests/gas32/gas-movsd.asm deleted file mode 100644 index 3d3c0c73..00000000 --- a/modules/arch/x86/tests/gas32/gas-movsd.asm +++ /dev/null @@ -1,3 +0,0 @@ -.text -movsd -movsl diff --git a/modules/arch/x86/tests/gas32/gas-movsd.hex b/modules/arch/x86/tests/gas32/gas-movsd.hex deleted file mode 100644 index 70701e6d..00000000 --- a/modules/arch/x86/tests/gas32/gas-movsd.hex +++ /dev/null @@ -1,360 +0,0 @@ -7f -45 -4c -46 -01 -01 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -01 -00 -03 -00 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -a0 -00 -00 -00 -00 -00 -00 -00 -34 -00 -00 -00 -00 -00 -28 -00 -05 -00 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -a5 -a5 -00 -00 -00 -2e -74 -65 -78 -74 -00 -2e -73 -74 -72 -74 -61 -62 -00 -2e -73 -79 -6d -74 -61 -62 -00 -2e -73 -68 -73 -74 -72 -74 -61 -62 -00 -00 -00 -00 -00 -2d -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -04 -00 -f1 -ff -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -03 -00 -04 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -17 -00 -00 -00 -03 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -44 -00 -00 -00 -21 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -07 -00 -00 -00 -03 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -68 -00 -00 -00 -03 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -0f -00 -00 -00 -02 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -6c -00 -00 -00 -30 -00 -00 -00 -02 -00 -00 -00 -03 -00 -00 -00 -04 -00 -00 -00 -10 -00 -00 -00 -01 -00 -00 -00 -01 -00 -00 -00 -06 -00 -00 -00 -00 -00 -00 -00 -40 -00 -00 -00 -02 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -10 -00 -00 -00 -00 -00 -00 -00 diff --git a/modules/arch/x86/tests/gas32/gas-pop.asm b/modules/arch/x86/tests/gas32/gas-pop.asm deleted file mode 100644 index 7c47ebef..00000000 --- a/modules/arch/x86/tests/gas32/gas-pop.asm +++ /dev/null @@ -1,50 +0,0 @@ -.code64 -push %cx # out: 66 51 -pop %cx # out: 66 59 -push %rcx # out: 51 -pop %rcx # out: 59 -pushw %cx # out: 66 51 -popw %cx # out: 66 59 -pushq %rcx # out: 51 -popq %rcx # out: 59 - -push -24(%rcx) # out: ff 71 e8 -pop -24(%rcx) # out: 8f 41 e8 -pushw -24(%rcx) # out: 66 ff 71 e8 -popw -24(%rcx) # out: 66 8f 41 e8 -pushq -24(%rcx) # out: ff 71 e8 -popq -24(%rcx) # out: 8f 41 e8 - -.code32 -push %cx # out: 66 51 -pop %cx # out: 66 59 -push %ecx # out: 51 -pop %ecx # out: 59 -pushw %cx # out: 66 51 -popw %cx # out: 66 59 -pushl %ecx # out: 51 -popl %ecx # out: 59 - -push -24(%ecx) # out: ff 71 e8 -pop -24(%ecx) # out: 8f 41 e8 -pushw -24(%ecx) # out: 66 ff 71 e8 -popw -24(%ecx) # out: 66 8f 41 e8 -pushl -24(%ecx) # out: ff 71 e8 -popl -24(%ecx) # out: 8f 41 e8 - -.code16 -push %cx # out: 51 -pop %cx # out: 59 -push %ecx # out: 66 51 -pop %ecx # out: 66 59 -pushw %cx # out: 51 -popw %cx # out: 59 -pushl %ecx # out: 66 51 -popl %ecx # out: 66 59 - -push -24(%bp) # out: ff 76 e8 -pop -24(%bp) # out: 8f 46 e8 -pushw -24(%bp) # out: ff 76 e8 -popw -24(%bp) # out: 8f 46 e8 -pushl -24(%bp) # out: 66 ff 76 e8 -popl -24(%bp) # out: 66 8f 46 e8 diff --git a/modules/arch/x86/tests/gas32/gas-pop.hex b/modules/arch/x86/tests/gas32/gas-pop.hex deleted file mode 100644 index 30744378..00000000 --- a/modules/arch/x86/tests/gas32/gas-pop.hex +++ /dev/null @@ -1,456 +0,0 @@ -7f -45 -4c -46 -01 -01 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -01 -00 -03 -00 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -01 -00 -00 -00 -00 -00 -00 -34 -00 -00 -00 -00 -00 -28 -00 -05 -00 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -66 -51 -66 -59 -51 -59 -66 -51 -66 -59 -51 -59 -ff -71 -e8 -8f -41 -e8 -66 -ff -71 -e8 -66 -8f -41 -e8 -ff -71 -e8 -8f -41 -e8 -66 -51 -66 -59 -51 -59 -66 -51 -66 -59 -51 -59 -ff -71 -e8 -8f -41 -e8 -66 -ff -71 -e8 -66 -8f -41 -e8 -ff -71 -e8 -8f -41 -e8 -51 -59 -66 -51 -66 -59 -51 -59 -66 -51 -66 -59 -ff -76 -e8 -8f -46 -e8 -ff -76 -e8 -8f -46 -e8 -66 -ff -76 -e8 -66 -8f -46 -e8 -00 -2e -74 -65 -78 -74 -00 -2e -73 -74 -72 -74 -61 -62 -00 -2e -73 -79 -6d -74 -61 -62 -00 -2e -73 -68 -73 -74 -72 -74 -61 -62 -00 -00 -00 -00 -00 -2d -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -04 -00 -f1 -ff -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -03 -00 -04 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -17 -00 -00 -00 -03 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -a0 -00 -00 -00 -21 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -07 -00 -00 -00 -03 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -c4 -00 -00 -00 -03 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -0f -00 -00 -00 -02 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -c8 -00 -00 -00 -30 -00 -00 -00 -02 -00 -00 -00 -03 -00 -00 -00 -04 -00 -00 -00 -10 -00 -00 -00 -01 -00 -00 -00 -01 -00 -00 -00 -06 -00 -00 -00 -00 -00 -00 -00 -40 -00 -00 -00 -60 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -10 -00 -00 -00 -00 -00 -00 -00 diff --git a/modules/arch/x86/tests/gas32/x86_gas32_test.sh b/modules/arch/x86/tests/gas32/x86_gas32_test.sh index b1d6c03c..af84899e 100755 --- a/modules/arch/x86/tests/gas32/x86_gas32_test.sh +++ b/modules/arch/x86/tests/gas32/x86_gas32_test.sh @@ -1,3 +1,4 @@ #! /bin/sh +# $Id$ ${srcdir}/out_test.sh x86_gas32_test modules/arch/x86/tests/gas32 "x86 gas format" "-f elf32 -p gas" ".o" exit $? diff --git a/modules/arch/x86/tests/gas64/Makefile.inc b/modules/arch/x86/tests/gas64/Makefile.inc index 00baf626..ab6589aa 100644 --- a/modules/arch/x86/tests/gas64/Makefile.inc +++ b/modules/arch/x86/tests/gas64/Makefile.inc @@ -1,3 +1,5 @@ +# $Id$ + TESTS += modules/arch/x86/tests/gas64/x86_gas64_test.sh EXTRA_DIST += modules/arch/x86/tests/gas64/x86_gas64_test.sh @@ -9,8 +11,6 @@ EXTRA_DIST += modules/arch/x86/tests/gas64/gas-fp.asm EXTRA_DIST += modules/arch/x86/tests/gas64/gas-fp.hex EXTRA_DIST += modules/arch/x86/tests/gas64/gas-inout.asm EXTRA_DIST += modules/arch/x86/tests/gas64/gas-inout.hex -EXTRA_DIST += modules/arch/x86/tests/gas64/gas-loop64.asm -EXTRA_DIST += modules/arch/x86/tests/gas64/gas-loop64.hex EXTRA_DIST += modules/arch/x86/tests/gas64/gas-moreinsn.asm EXTRA_DIST += modules/arch/x86/tests/gas64/gas-moreinsn.hex EXTRA_DIST += modules/arch/x86/tests/gas64/gas-movabs.asm diff --git a/modules/arch/x86/tests/gas64/align64.hex b/modules/arch/x86/tests/gas64/align64.hex index ecfbf7ab..3e9c5c1d 100644 --- a/modules/arch/x86/tests/gas64/align64.hex +++ b/modules/arch/x86/tests/gas64/align64.hex @@ -66,50 +66,50 @@ ff 66 66 66 +90 66 66 66 -2e -0f -1f -84 -00 -00 -00 -00 -00 +90 +66 +66 +66 +90 +66 +66 +90 ff ff 66 66 66 +90 66 66 -2e -0f -1f -84 -00 -00 -00 -00 -00 +66 +90 +66 +66 +90 +66 +66 +90 ff ff ff 66 66 66 +90 66 -2e -0f -1f -84 -00 -00 -00 -00 -00 +66 +90 +66 +66 +90 +66 +66 +90 ff ff ff @@ -117,15 +117,15 @@ ff 66 66 66 -2e -0f -1f -84 -00 -00 -00 -00 -00 +90 +66 +66 +66 +90 +66 +66 +66 +90 ff ff ff @@ -133,15 +133,15 @@ ff ff 66 66 -2e -0f -1f -84 -00 -00 -00 -00 -00 +66 +90 +66 +66 +66 +90 +66 +66 +90 ff ff ff @@ -149,15 +149,15 @@ ff ff ff 66 -2e -0f -1f -84 -00 -00 -00 -00 -00 +66 +66 +90 +66 +66 +90 +66 +66 +90 ff ff ff @@ -166,14 +166,14 @@ ff ff ff 66 -0f -1f -84 -00 -00 -00 -00 -00 +66 +90 +66 +66 +90 +66 +66 +90 ff ff ff @@ -182,50 +182,50 @@ ff ff ff ff -0f -1f -84 -00 -00 -00 -00 -00 -ff -0f -1f -80 -00 -00 -00 -00 -ff -ff 66 -0f -1f -44 -00 -00 +66 +66 +90 +66 +66 +66 +90 +ff +66 +66 +66 +90 +66 +66 +90 +ff +ff +66 +66 +90 +66 +66 +90 ff ff ff -0f -1f -44 -00 -00 +66 +66 +90 +66 +90 ff ff ff ff -0f -1f -40 -00 +66 +66 +66 +90 ff -0f -1f -00 +66 +66 +90 ff ff 66 diff --git a/modules/arch/x86/tests/gas64/gas-loop64.asm b/modules/arch/x86/tests/gas64/gas-loop64.asm deleted file mode 100644 index d441ad69..00000000 --- a/modules/arch/x86/tests/gas64/gas-loop64.asm +++ /dev/null @@ -1,5 +0,0 @@ -loop label -#loopw label -loopl label -loopq label -label: diff --git a/modules/arch/x86/tests/gas64/gas-loop64.hex b/modules/arch/x86/tests/gas64/gas-loop64.hex deleted file mode 100644 index 7c1e9246..00000000 --- a/modules/arch/x86/tests/gas64/gas-loop64.hex +++ /dev/null @@ -1,528 +0,0 @@ -7f -45 -4c -46 -02 -01 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -01 -00 -3e -00 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -d0 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -40 -00 -00 -00 -00 -00 -40 -00 -05 -00 -01 -00 -e2 -05 -67 -e2 -02 -e2 -00 -00 -00 -2e -74 -65 -78 -74 -00 -2e -73 -74 -72 -74 -61 -62 -00 -2e -73 -79 -6d -74 -61 -62 -00 -2e -73 -68 -73 -74 -72 -74 -61 -62 -00 -00 -00 -00 -00 -2d -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -01 -00 -00 -00 -04 -00 -f1 -ff -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -04 -00 -07 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -03 -00 -04 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -17 -00 -00 -00 -03 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -48 -00 -00 -00 -00 -00 -00 -00 -21 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -07 -00 -00 -00 -03 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -6c -00 -00 -00 -00 -00 -00 -00 -03 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -0f -00 -00 -00 -02 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -70 -00 -00 -00 -00 -00 -00 -00 -60 -00 -00 -00 -00 -00 -00 -00 -02 -00 -00 -00 -04 -00 -00 -00 -08 -00 -00 -00 -00 -00 -00 -00 -18 -00 -00 -00 -00 -00 -00 -00 -01 -00 -00 -00 -01 -00 -00 -00 -06 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -40 -00 -00 -00 -00 -00 -00 -00 -07 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -10 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 diff --git a/modules/arch/x86/tests/gas64/gas-moreinsn.hex b/modules/arch/x86/tests/gas64/gas-moreinsn.hex index fa76e393..399c179a 100644 --- a/modules/arch/x86/tests/gas64/gas-moreinsn.hex +++ b/modules/arch/x86/tests/gas64/gas-moreinsn.hex @@ -208,6 +208,7 @@ c1 c4 c0 05 +48 0f c4 c8 @@ -218,6 +219,7 @@ c4 c0 05 66 +48 0f c4 c8 @@ -225,6 +227,7 @@ c8 0f d7 c0 +48 0f d7 c0 @@ -233,6 +236,7 @@ c0 d7 c0 66 +48 0f d7 c0 @@ -458,10 +462,6 @@ ff 00 00 00 -00 -00 -00 -00 17 00 00 @@ -486,7 +486,7 @@ ff 00 00 00 -1c +20 01 00 00 @@ -550,7 +550,7 @@ ff 00 00 00 -40 +44 01 00 00 @@ -614,7 +614,7 @@ ff 00 00 00 -44 +48 01 00 00 @@ -686,7 +686,7 @@ ff 00 00 00 -dc +e0 00 00 00 diff --git a/modules/arch/x86/tests/gas64/gas-movsxs.asm b/modules/arch/x86/tests/gas64/gas-movsxs.asm index 7216a8ca..1aa1e97e 100644 --- a/modules/arch/x86/tests/gas64/gas-movsxs.asm +++ b/modules/arch/x86/tests/gas64/gas-movsxs.asm @@ -16,17 +16,3 @@ movzbw %al, %ax movzwl %ax, %eax movzbq %al, %rax movzwq %ax, %rax - -movsbw 5,%ax -movsbl 5,%eax -movswl 5,%eax -movsbq 5,%rax -movswq 5,%rax -movsx 5,%eax -movzbw 5,%ax -movzbl 5,%eax -movzwl 5,%eax -movzbq 5,%rax -movzwq 5,%rax -movzx 5,%eax - diff --git a/modules/arch/x86/tests/gas64/gas-movsxs.hex b/modules/arch/x86/tests/gas64/gas-movsxs.hex index 50abeba2..dc1dfd30 100644 --- a/modules/arch/x86/tests/gas64/gas-movsxs.hex +++ b/modules/arch/x86/tests/gas64/gas-movsxs.hex @@ -38,8 +38,8 @@ 00 00 00 -40 -01 +e0 +00 00 00 00 @@ -101,110 +101,6 @@ c0 0f b7 c0 -66 -0f -be -04 -25 -05 -00 -00 -00 -0f -be -04 -25 -05 -00 -00 -00 -0f -bf -04 -25 -05 -00 -00 -00 -48 -0f -be -04 -25 -05 -00 -00 -00 -48 -0f -bf -04 -25 -05 -00 -00 -00 -0f -be -04 -25 -05 -00 -00 -00 -66 -0f -b6 -04 -25 -05 -00 -00 -00 -0f -b6 -04 -25 -05 -00 -00 -00 -0f -b7 -04 -25 -05 -00 -00 -00 -48 -0f -b6 -04 -25 -05 -00 -00 -00 -48 -0f -b7 -04 -25 -05 -00 -00 -00 -0f -b6 -04 -25 -05 -00 -00 -00 -00 -00 00 00 2e @@ -382,6 +278,14 @@ ff 00 00 00 +00 +00 +00 +00 +00 +00 +00 +00 17 00 00 @@ -406,7 +310,7 @@ ff 00 00 00 -d0 +68 00 00 00 @@ -470,7 +374,7 @@ d0 00 00 00 -f4 +8c 00 00 00 @@ -534,7 +438,7 @@ f4 00 00 00 -f8 +90 00 00 00 @@ -606,7 +510,7 @@ f8 00 00 00 -8d +27 00 00 00 diff --git a/modules/arch/x86/tests/gas64/x86_gas64_test.sh b/modules/arch/x86/tests/gas64/x86_gas64_test.sh index b5b2cdf3..3379775c 100755 --- a/modules/arch/x86/tests/gas64/x86_gas64_test.sh +++ b/modules/arch/x86/tests/gas64/x86_gas64_test.sh @@ -1,3 +1,4 @@ #! /bin/sh +# $Id$ ${srcdir}/out_test.sh x86_gas64_test modules/arch/x86/tests/gas64 "amd64 gas format" "-f elf -m amd64 -p gas" ".o" exit $? diff --git a/modules/arch/x86/tests/gen-fma-test.py b/modules/arch/x86/tests/gen-fma-test.py deleted file mode 100755 index a8f4e025..00000000 --- a/modules/arch/x86/tests/gen-fma-test.py +++ /dev/null @@ -1,63 +0,0 @@ -#!/usr/bin/env python - -def emit(opcode,suffix,width,order,optype): - d = {} - d['opcode']=opcode - d['suffix']=suffix - d['order']=order - if width == 128: - d['op1']= 'xmm1' - d['op2']= 'xmm2' - d['op3']= 'xmm3' - if optype == 'rrr': - d['op3']= 'xmm3' - elif suffix == 'pd': - d['op3']= 'dqword [rax]' - elif suffix == 'sd': - d['op3']= 'qword [rax]' - elif suffix == 'ss': - d['op3']= 'dword [rax]' - else: - d['op1']= 'ymm1' - d['op2']= 'ymm2' - if optype == 'rrr': - d['op3']= 'ymm3' - else: - d['op3']= 'yword [rax]' - - - print "v%(opcode)s%(order)s%(suffix)s %(op1)s, %(op2)s, %(op3)s" % (d) - if optype == 'rrm': - d['op3']= '[rax]' - print "v%(opcode)s%(order)s%(suffix)s %(op1)s, %(op2)s, %(op3)s" % (d) - -def gen(opcodes, combos, optypes, orders): - for opcode in opcodes: - for (suffix,width) in combos: - for order in orders: - for optype in optypes: - emit(opcode,suffix,width,order,optype) - - -if __name__ == '__main__': - orders = ['132', '231', '213'] - - all_combos = [('ss',128), - ('sd',128), - ('ps',128), - ('ps',256), - ('pd',128), - ('pd',256) ] - packed_combos = [ ('ps',128), - ('ps',256), - ('pd',128), - ('pd',256) ] - - opcodes1 = ['fmadd', 'fmsub', 'fnmadd', 'fnmsub'] - opcodes2 = ['fmaddsub', 'fmsubadd'] - - optypes = ['rrr','rrm'] - - print "[bits 64]" - gen(opcodes1, all_combos,optypes, orders) - gen(opcodes2, packed_combos,optypes, orders) diff --git a/modules/arch/x86/tests/genopcode.asm b/modules/arch/x86/tests/genopcode.asm index 357c010e..f37695d3 100644 --- a/modules/arch/x86/tests/genopcode.asm +++ b/modules/arch/x86/tests/genopcode.asm @@ -168,9 +168,6 @@ jmp near label jmp far [label] jmp far dword [label] call far word [label] -loop short label -jcxz short label -jecxz short label [bits 16] push si push esi diff --git a/modules/arch/x86/tests/genopcode.hex b/modules/arch/x86/tests/genopcode.hex index 37b3cf94..d6a562d2 100644 --- a/modules/arch/x86/tests/genopcode.hex +++ b/modules/arch/x86/tests/genopcode.hex @@ -482,13 +482,6 @@ ff 1e b9 01 -e2 -d3 -e3 -d1 -67 -e3 -ce 56 66 56 diff --git a/modules/arch/x86/tests/imm64.asm b/modules/arch/x86/tests/imm64.asm deleted file mode 100644 index 5b41bfae..00000000 --- a/modules/arch/x86/tests/imm64.asm +++ /dev/null @@ -1,35 +0,0 @@ -bits 64 -default abs -;extern label1 -label1: -label2: - -mov rax, 0x1000 ; 32-bit imm -mov rax, 0x1122334455667788 ; 64-bit imm (larger than signed 32-bit) -;mov rax, 0x80000000 ; 64-bit imm (larger than signed 32-bit) -mov rax, label1 ; 32-bit imm <--- not 64-bit! -mov rax, label2 ; 32-bit imm <--- not 64-bit! -mov rax, qword 0x1000 ; 64-bit imm -mov rax, qword label1 ; 64-bit imm -mov rax, qword label2 ; 64-bit imm - -mov qword [rax], 0x1000 ; 32-bit imm -mov qword [rax], 0x1122334455667788 ; 32-bit imm, overflow warning -;mov qword [rax], 0x80000000 ; 32-bit imm, overflow warning -mov qword [rax], label1 ; 32-bit imm (matches default above) -mov qword [rax], label2 ; 32-bit imm (matches default above) - -add rax, 0x1000 ; 32-bit imm -add rax, 0x1122334455667788 ; 32-bit imm, overflow warning -;add rax, 0x80000000 ; 32-bit imm, overflow warning -add rax, label1 ; 32-bit imm (matches default above) -add rax, label2 ; 32-bit imm (matches default above) - -mov [0x1000], rax ; 32-bit disp -mov [abs 0x1122334455667788], rax ; 64-bit disp -mov [label1], rax ; 32-bit disp -mov [label2], rax ; 32-bit disp -mov [qword 0x1000], rax ; 64-bit disp -mov [qword label1], rax ; 64-bit disp -mov [qword label2], rax ; 64-bit disp - diff --git a/modules/arch/x86/tests/imm64.errwarn b/modules/arch/x86/tests/imm64.errwarn deleted file mode 100644 index a0487353..00000000 --- a/modules/arch/x86/tests/imm64.errwarn +++ /dev/null @@ -1,3 +0,0 @@ --:17: warning: value does not fit in 32 bit field --:23: warning: value does not fit in 32 bit field --:29: warning: value does not fit in 32 bit field diff --git a/modules/arch/x86/tests/imm64.hex b/modules/arch/x86/tests/imm64.hex deleted file mode 100644 index af46a719..00000000 --- a/modules/arch/x86/tests/imm64.hex +++ /dev/null @@ -1,175 +0,0 @@ -48 -c7 -c0 -00 -10 -00 -00 -48 -b8 -88 -77 -66 -55 -44 -33 -22 -11 -48 -c7 -c0 -00 -00 -00 -00 -48 -c7 -c0 -00 -00 -00 -00 -48 -b8 -00 -10 -00 -00 -00 -00 -00 -00 -48 -b8 -00 -00 -00 -00 -00 -00 -00 -00 -48 -b8 -00 -00 -00 -00 -00 -00 -00 -00 -48 -c7 -00 -00 -10 -00 -00 -48 -c7 -00 -88 -77 -66 -55 -48 -c7 -00 -00 -00 -00 -00 -48 -c7 -00 -00 -00 -00 -00 -48 -05 -00 -10 -00 -00 -48 -05 -88 -77 -66 -55 -48 -05 -00 -00 -00 -00 -48 -05 -00 -00 -00 -00 -48 -89 -04 -25 -00 -10 -00 -00 -48 -89 -04 -25 -88 -77 -66 -55 -48 -89 -04 -25 -00 -00 -00 -00 -48 -89 -04 -25 -00 -00 -00 -00 -48 -a3 -00 -10 -00 -00 -00 -00 -00 -00 -48 -a3 -00 -00 -00 -00 -00 -00 -00 -00 -48 -a3 -00 -00 -00 -00 -00 -00 -00 -00 diff --git a/modules/arch/x86/tests/invpcid.asm b/modules/arch/x86/tests/invpcid.asm deleted file mode 100644 index 90f517aa..00000000 --- a/modules/arch/x86/tests/invpcid.asm +++ /dev/null @@ -1,6 +0,0 @@ -[bits 32] -invpcid eax, oword [0] ; 66 0f 38 82 05 00 00 00 00 - -[bits 64] -invpcid rax, oword [0] ; 66 0f 38 82 04 25 00 00 00 00 - diff --git a/modules/arch/x86/tests/invpcid.hex b/modules/arch/x86/tests/invpcid.hex deleted file mode 100644 index cfc8726b..00000000 --- a/modules/arch/x86/tests/invpcid.hex +++ /dev/null @@ -1,19 +0,0 @@ -66 -0f -38 -82 -05 -00 -00 -00 -00 -66 -0f -38 -82 -04 -25 -00 -00 -00 -00 diff --git a/modules/arch/x86/tests/jmpfar.asm b/modules/arch/x86/tests/jmpfar.asm deleted file mode 100644 index 92ef261b..00000000 --- a/modules/arch/x86/tests/jmpfar.asm +++ /dev/null @@ -1,16 +0,0 @@ -jmp 1234:5678 ; YASM: far jump -jmp near 1234:5678 ; YASM: near jump; NASM: mismatch in operand sizes -jmp far 1234:5678 ; YASM: far jump; NASM: mismatch in operand sizes -;dw seg (1234:5678) -far1 equ 1234:5678 -jmp far1 ; both: near jump -jmp near far1 ; both: near jump -jmp far far1 ; YASM: far jump; NASM: value referenced by FAR is not relocatable -dw seg far1 -jmp far2 ; both: near jump -jmp near far2 ; both: near jump -jmp far far2 ; YASM: far jump; NASM: value referenced by FAR is not relocatable -dw seg far2 -far2 equ 1234:5678 -;mov ax, [1234:5678] ; YASM: invalid segment in effective address; NASM: invalid segment override -;mov ax, 1234:5678 ; YASM: immediate does not support segment; NASM: invalid combination of opcode and operands diff --git a/modules/arch/x86/tests/jmpfar.hex b/modules/arch/x86/tests/jmpfar.hex deleted file mode 100644 index f9d3ea42..00000000 --- a/modules/arch/x86/tests/jmpfar.hex +++ /dev/null @@ -1,39 +0,0 @@ -ea -2e -16 -d2 -04 -e9 -26 -16 -ea -2e -16 -d2 -04 -e9 -1e -16 -e9 -1b -16 -ea -2e -16 -d2 -04 -d2 -04 -e9 -11 -16 -e9 -0e -16 -ea -2e -16 -d2 -04 -d2 -04 diff --git a/modules/arch/x86/tests/larlsl.asm b/modules/arch/x86/tests/larlsl.asm deleted file mode 100644 index 51c3feca..00000000 --- a/modules/arch/x86/tests/larlsl.asm +++ /dev/null @@ -1,59 +0,0 @@ -[bits 16] -lar ax, bx -lar ax, [bx] -lar ax, word [bx] -lar eax, bx -lar eax, ebx -lar eax, [bx] -lar eax, word [bx] - -lsl ax, bx -lsl ax, [bx] -lsl ax, word [bx] -lsl eax, bx -lsl eax, ebx -lsl eax, [bx] -lsl eax, word [bx] - -[bits 32] -lar ax, bx -lar ax, [ebx] -lar ax, word [ebx] -lar eax, bx -lar eax, ebx -lar eax, [ebx] -lar eax, word [ebx] - -lsl ax, bx -lsl ax, [ebx] -lsl ax, word [ebx] -lsl eax, bx -lsl eax, ebx -lsl eax, [ebx] -lsl eax, word [ebx] - -[bits 64] -lar ax, bx -lar ax, [rbx] -lar ax, word [rbx] -lar eax, bx -lar eax, ebx -lar eax, [rbx] -lar eax, word [rbx] -lar rax, bx -lar rax, ebx -lar rax, [rbx] -lar rax, word [rbx] - -lsl ax, bx -lsl ax, [rbx] -lsl ax, word [rbx] -lsl eax, bx -lsl eax, ebx -lsl eax, [rbx] -lsl eax, word [rbx] -lsl rax, bx -lsl rax, ebx -lsl rax, [rbx] -lsl rax, word [rbx] - diff --git a/modules/arch/x86/tests/larlsl.hex b/modules/arch/x86/tests/larlsl.hex deleted file mode 100644 index 38c8b973..00000000 --- a/modules/arch/x86/tests/larlsl.hex +++ /dev/null @@ -1,178 +0,0 @@ -0f -02 -c3 -0f -02 -07 -0f -02 -07 -66 -0f -02 -c3 -66 -0f -02 -c3 -66 -0f -02 -07 -66 -0f -02 -07 -0f -03 -c3 -0f -03 -07 -0f -03 -07 -66 -0f -03 -c3 -66 -0f -03 -c3 -66 -0f -03 -07 -66 -0f -03 -07 -66 -0f -02 -c3 -66 -0f -02 -03 -66 -0f -02 -03 -0f -02 -c3 -0f -02 -c3 -0f -02 -03 -0f -02 -03 -66 -0f -03 -c3 -66 -0f -03 -03 -66 -0f -03 -03 -0f -03 -c3 -0f -03 -c3 -0f -03 -03 -0f -03 -03 -66 -0f -02 -c3 -66 -0f -02 -03 -66 -0f -02 -03 -0f -02 -c3 -0f -02 -c3 -0f -02 -03 -0f -02 -03 -48 -0f -02 -c3 -48 -0f -02 -c3 -48 -0f -02 -03 -48 -0f -02 -03 -66 -0f -03 -c3 -66 -0f -03 -03 -66 -0f -03 -03 -0f -03 -c3 -0f -03 -c3 -0f -03 -03 -0f -03 -03 -48 -0f -03 -c3 -48 -0f -03 -c3 -48 -0f -03 -03 -48 -0f -03 -03 diff --git a/modules/arch/x86/tests/lds.asm b/modules/arch/x86/tests/lds-err.asm similarity index 100% rename from modules/arch/x86/tests/lds.asm rename to modules/arch/x86/tests/lds-err.asm diff --git a/modules/arch/x86/tests/lds-err.errwarn b/modules/arch/x86/tests/lds-err.errwarn new file mode 100644 index 00000000..cd07464a --- /dev/null +++ b/modules/arch/x86/tests/lds-err.errwarn @@ -0,0 +1,4 @@ +-:2: invalid size for operand 2 +-:3: invalid size for operand 2 +-:5: invalid size for operand 2 +-:6: invalid size for operand 2 diff --git a/modules/arch/x86/tests/lds.hex b/modules/arch/x86/tests/lds.hex deleted file mode 100644 index c3909546..00000000 --- a/modules/arch/x86/tests/lds.hex +++ /dev/null @@ -1,27 +0,0 @@ -c5 -06 -01 -00 -c5 -06 -01 -00 -c5 -06 -01 -00 -66 -c5 -06 -01 -00 -66 -c5 -06 -01 -00 -66 -c5 -06 -01 -00 diff --git a/modules/arch/x86/tests/lfs64.asm b/modules/arch/x86/tests/lfs64.asm deleted file mode 100644 index 5ee04760..00000000 --- a/modules/arch/x86/tests/lfs64.asm +++ /dev/null @@ -1,10 +0,0 @@ -[bits 64] -lfs ax, [rbx] -lfs eax, [rbx] -lfs rax, [rbx] -lgs ax, [rbx] -lgs eax, [rbx] -lgs rax, [rbx] -lss ax, [rbx] -lss eax, [rbx] -lss rax, [rbx] diff --git a/modules/arch/x86/tests/lfs64.hex b/modules/arch/x86/tests/lfs64.hex deleted file mode 100644 index 8eb71864..00000000 --- a/modules/arch/x86/tests/lfs64.hex +++ /dev/null @@ -1,33 +0,0 @@ -66 -0f -b4 -03 -0f -b4 -03 -48 -0f -b4 -03 -66 -0f -b5 -03 -0f -b5 -03 -48 -0f -b5 -03 -66 -0f -b2 -03 -0f -b2 -03 -48 -0f -b2 -03 diff --git a/modules/arch/x86/tests/lzcnt.asm b/modules/arch/x86/tests/lzcnt.asm deleted file mode 100644 index 4e545dfa..00000000 --- a/modules/arch/x86/tests/lzcnt.asm +++ /dev/null @@ -1,8 +0,0 @@ -[bits 64] - -lzcnt ax, bx ; 66 f3 0f bd c3 -lzcnt ax, [0] ; 66 f3 0f bd 04 25 00 00 00 00 -lzcnt eax, ebx ; f3 0f bd c3 -lzcnt eax, [0] ; f3 0f bd 04 25 00 00 00 00 -lzcnt rax, rbx ; f3 48 0f bd c3 -lzcnt rax, [0] ; f3 48 0f bd 04 25 00 00 00 00 diff --git a/modules/arch/x86/tests/lzcnt.hex b/modules/arch/x86/tests/lzcnt.hex deleted file mode 100644 index ed14eb0e..00000000 --- a/modules/arch/x86/tests/lzcnt.hex +++ /dev/null @@ -1,43 +0,0 @@ -66 -f3 -0f -bd -c3 -66 -f3 -0f -bd -04 -25 -00 -00 -00 -00 -f3 -0f -bd -c3 -f3 -0f -bd -04 -25 -00 -00 -00 -00 -f3 -48 -0f -bd -c3 -f3 -48 -0f -bd -04 -25 -00 -00 -00 -00 diff --git a/modules/arch/x86/tests/mem64-err.errwarn b/modules/arch/x86/tests/mem64-err.errwarn index 6f37650d..c9b1943d 100644 --- a/modules/arch/x86/tests/mem64-err.errwarn +++ b/modules/arch/x86/tests/mem64-err.errwarn @@ -1,5 +1,5 @@ --:2: error: 16-bit addresses not supported in 64-bit mode --:4: error: 16-bit addresses not supported in 64-bit mode --:5: error: invalid effective address --:6: error: invalid effective address --:7: error: cannot use A/B/C/DH with instruction needing REX +-:2: 16-bit addresses not supported in 64-bit mode +-:4: 16-bit addresses not supported in 64-bit mode +-:5: invalid effective address +-:6: invalid effective address +-:7: cannot use A/B/C/DH with instruction needing REX diff --git a/modules/arch/x86/tests/mixcase.asm b/modules/arch/x86/tests/mixcase.asm deleted file mode 100644 index 66a96865..00000000 --- a/modules/arch/x86/tests/mixcase.asm +++ /dev/null @@ -1,3 +0,0 @@ -CPU SSSE3 -MOV AX,5 - diff --git a/modules/arch/x86/tests/mixcase.hex b/modules/arch/x86/tests/mixcase.hex deleted file mode 100644 index 76dc00b9..00000000 --- a/modules/arch/x86/tests/mixcase.hex +++ /dev/null @@ -1,3 +0,0 @@ -b8 -05 -00 diff --git a/modules/arch/x86/tests/movbe.asm b/modules/arch/x86/tests/movbe.asm deleted file mode 100644 index 637524ae..00000000 --- a/modules/arch/x86/tests/movbe.asm +++ /dev/null @@ -1,20 +0,0 @@ -[bits 64] -movbe cx, [5] -movbe cx, word [5] -movbe ecx, [5] -movbe ecx, dword [5] -movbe rcx, [5] -movbe rcx, qword [5] -movbe r9, [5] -movbe r9, qword [5] -movbe [5], bx -movbe word [5], bx -movbe [5], ebx -movbe dword [5], ebx -movbe [5], r10d -movbe dword [5], r10d -movbe [5], rbx -movbe qword [5], rbx -movbe [5], r10 -movbe qword [5], r10 - diff --git a/modules/arch/x86/tests/movbe.hex b/modules/arch/x86/tests/movbe.hex deleted file mode 100644 index 108bedf7..00000000 --- a/modules/arch/x86/tests/movbe.hex +++ /dev/null @@ -1,176 +0,0 @@ -66 -0f -38 -f0 -0c -25 -05 -00 -00 -00 -66 -0f -38 -f0 -0c -25 -05 -00 -00 -00 -0f -38 -f0 -0c -25 -05 -00 -00 -00 -0f -38 -f0 -0c -25 -05 -00 -00 -00 -48 -0f -38 -f0 -0c -25 -05 -00 -00 -00 -48 -0f -38 -f0 -0c -25 -05 -00 -00 -00 -4c -0f -38 -f0 -0c -25 -05 -00 -00 -00 -4c -0f -38 -f0 -0c -25 -05 -00 -00 -00 -66 -0f -38 -f1 -1c -25 -05 -00 -00 -00 -66 -0f -38 -f1 -1c -25 -05 -00 -00 -00 -0f -38 -f1 -1c -25 -05 -00 -00 -00 -0f -38 -f1 -1c -25 -05 -00 -00 -00 -44 -0f -38 -f1 -14 -25 -05 -00 -00 -00 -44 -0f -38 -f1 -14 -25 -05 -00 -00 -00 -48 -0f -38 -f1 -1c -25 -05 -00 -00 -00 -48 -0f -38 -f1 -1c -25 -05 -00 -00 -00 -4c -0f -38 -f1 -14 -25 -05 -00 -00 -00 -4c -0f -38 -f1 -14 -25 -05 -00 -00 -00 diff --git a/modules/arch/x86/tests/nomem64-err.errwarn b/modules/arch/x86/tests/nomem64-err.errwarn index 73bfcf97..2694d2fb 100644 --- a/modules/arch/x86/tests/nomem64-err.errwarn +++ b/modules/arch/x86/tests/nomem64-err.errwarn @@ -1,12 +1,12 @@ -:2: warning: `es' segment register ignored in 64-bit mode --:4: error: `pushaw' invalid in 64-bit mode --:5: error: `popa' invalid in 64-bit mode --:6: error: `lds' invalid in 64-bit mode --:7: error: `aas' invalid in 64-bit mode --:8: error: `das' invalid in 64-bit mode --:9: error: `aad' invalid in 64-bit mode --:10: error: `into' invalid in 64-bit mode --:11: error: `salc' invalid in 64-bit mode +-:4: `pushaw' invalid in 64-bit mode +-:5: `popa' invalid in 64-bit mode +-:6: `lds' invalid in 64-bit mode +-:7: `aas' invalid in 64-bit mode +-:8: `das' invalid in 64-bit mode +-:9: `aad' invalid in 64-bit mode +-:10: `into' invalid in 64-bit mode +-:11: `salc' invalid in 64-bit mode -:13: warning: `xmm9' is a register in 64-bit mode -:14: warning: `rax' is a register in 64-bit mode -:15: warning: `rdx' is a register in 64-bit mode diff --git a/modules/arch/x86/tests/nomem64-err2.errwarn b/modules/arch/x86/tests/nomem64-err2.errwarn index 8a785392..b26a14d1 100644 --- a/modules/arch/x86/tests/nomem64-err2.errwarn +++ b/modules/arch/x86/tests/nomem64-err2.errwarn @@ -1,2 +1,2 @@ --:2: error: cannot use A/B/C/DH with instruction needing REX --:3: error: cannot use A/B/C/DH with instruction needing REX +-:2: cannot use A/B/C/DH with instruction needing REX +-:3: cannot use A/B/C/DH with instruction needing REX diff --git a/modules/arch/x86/tests/o64loop.asm b/modules/arch/x86/tests/o64loop.asm deleted file mode 100644 index 14f7951b..00000000 --- a/modules/arch/x86/tests/o64loop.asm +++ /dev/null @@ -1,3 +0,0 @@ -[bits 64] -o64 loop next -next: diff --git a/modules/arch/x86/tests/o64loop.errwarn b/modules/arch/x86/tests/o64loop.errwarn deleted file mode 100644 index 55f8201b..00000000 --- a/modules/arch/x86/tests/o64loop.errwarn +++ /dev/null @@ -1 +0,0 @@ --:2: warning: ignoring REX prefix on jump diff --git a/modules/arch/x86/tests/o64loop.hex b/modules/arch/x86/tests/o64loop.hex deleted file mode 100644 index 55e2c214..00000000 --- a/modules/arch/x86/tests/o64loop.hex +++ /dev/null @@ -1,2 +0,0 @@ -e2 -00 diff --git a/modules/arch/x86/tests/opsize-err.errwarn b/modules/arch/x86/tests/opsize-err.errwarn index f515f51e..da7bf083 100644 --- a/modules/arch/x86/tests/opsize-err.errwarn +++ b/modules/arch/x86/tests/opsize-err.errwarn @@ -1 +1 @@ --:3: error: invalid size for operand 2 +-:3: invalid size for operand 2 diff --git a/modules/arch/x86/tests/pinsrb.asm b/modules/arch/x86/tests/pinsrb.asm deleted file mode 100644 index 7ee059d7..00000000 --- a/modules/arch/x86/tests/pinsrb.asm +++ /dev/null @@ -1,6 +0,0 @@ -[bits 16] -pinsrb xmm4, eax, 0x55 -[bits 32] -pinsrb xmm4, eax, 0x55 -[bits 64] -pinsrb xmm4, eax, 0x55 diff --git a/modules/arch/x86/tests/pinsrb.hex b/modules/arch/x86/tests/pinsrb.hex deleted file mode 100644 index 27e71a9e..00000000 --- a/modules/arch/x86/tests/pinsrb.hex +++ /dev/null @@ -1,18 +0,0 @@ -66 -0f -3a -20 -e0 -55 -66 -0f -3a -20 -e0 -55 -66 -0f -3a -20 -e0 -55 diff --git a/modules/arch/x86/tests/pushf-err.errwarn b/modules/arch/x86/tests/pushf-err.errwarn index 498610ba..79f3177a 100644 --- a/modules/arch/x86/tests/pushf-err.errwarn +++ b/modules/arch/x86/tests/pushf-err.errwarn @@ -1,10 +1,10 @@ -:5: warning: `pushfq' is an instruction in 64-bit mode -:9: warning: `popfq' is an instruction in 64-bit mode -:15: warning: `pushfq' is an instruction in 64-bit mode --:15: error: redefinition of `pushfq' --:5: error: `pushfq' previously defined here +-:15: redefinition of `pushfq' +-:5: `pushfq' previously defined here -:19: warning: `popfq' is an instruction in 64-bit mode --:19: error: redefinition of `popfq' --:9: error: `popfq' previously defined here --:24: error: `pushfd' invalid in 64-bit mode --:28: error: `popfd' invalid in 64-bit mode +-:19: redefinition of `popfq' +-:9: `popfq' previously defined here +-:24: `pushfd' invalid in 64-bit mode +-:28: `popfd' invalid in 64-bit mode diff --git a/modules/arch/x86/tests/pushnosize.asm b/modules/arch/x86/tests/pushnosize.asm index ada9be17..3d999774 100644 --- a/modules/arch/x86/tests/pushnosize.asm +++ b/modules/arch/x86/tests/pushnosize.asm @@ -2,7 +2,7 @@ push 0 ; 6A 00 - equivalent to push byte 0 push byte 0 ; 6A 00 push word 0 ; 6A 00 - optimized -push dword 0 ; 66 6A 00 - optimized +push dword 0 ; 66 68 00000000 push strict byte 0 ; 6A 00 push strict word 0 ; 68 0000 push strict dword 0 ; 66 68 00000000 @@ -17,7 +17,7 @@ push strict dword 128 ; 66 68 80000000 [bits 32] push 0 ; 6A 00 - equivalent to push byte 0 push byte 0 ; 6A 00 -push word 0 ; 66 6A 00 - optimized +push word 0 ; 66 68 0000 push dword 0 ; 6A 00 - optimized push strict byte 0 ; 6A 00 push strict word 0 ; 66 68 0000 @@ -32,12 +32,12 @@ push strict dword 128 ; 6A 80000000 [bits 64] push 0 ; same as bits 32 output -push byte 0 ; 6A 00; 64 bits pushed onto stack -push word 0 ; 66 6A 00 - 66h prefix, optimized to byte -push dword 0 ; 6A 00 - optimized to byte; note 64 bits pushed onto stack -push strict byte 0 ; 6A 00; 64 bits pushed onto stack -push strict word 0 ; 66 68 0000 -push strict dword 0 ; 68 00000000; note 64 bits pushed onto stack +push byte 0 +push word 0 +push dword 0 ; optimized to byte +push strict byte 0 +push strict word 0 +push strict dword 0 push 128 push byte 128 ; warning push word 128 diff --git a/modules/arch/x86/tests/pushnosize.hex b/modules/arch/x86/tests/pushnosize.hex index 08960202..de28febf 100644 --- a/modules/arch/x86/tests/pushnosize.hex +++ b/modules/arch/x86/tests/pushnosize.hex @@ -5,7 +5,10 @@ 6a 00 66 -6a +68 +00 +00 +00 00 6a 00 @@ -48,7 +51,8 @@ 6a 00 66 -6a +68 +00 00 6a 00 @@ -95,7 +99,8 @@ 6a 00 66 -6a +68 +00 00 6a 00 diff --git a/modules/arch/x86/tests/rdrand.asm b/modules/arch/x86/tests/rdrand.asm deleted file mode 100644 index 20ade23f..00000000 --- a/modules/arch/x86/tests/rdrand.asm +++ /dev/null @@ -1,4 +0,0 @@ -[bits 64] -rdrand bx -rdrand ebx -rdrand rbx diff --git a/modules/arch/x86/tests/rdrand.hex b/modules/arch/x86/tests/rdrand.hex deleted file mode 100644 index 25ac57c4..00000000 --- a/modules/arch/x86/tests/rdrand.hex +++ /dev/null @@ -1,11 +0,0 @@ -66 -0f -c7 -f3 -0f -c7 -f3 -48 -0f -c7 -f3 diff --git a/modules/arch/x86/tests/rdrnd.asm b/modules/arch/x86/tests/rdrnd.asm deleted file mode 100644 index 234451df..00000000 --- a/modules/arch/x86/tests/rdrnd.asm +++ /dev/null @@ -1,4 +0,0 @@ -[bits 64] -rdrand cx -rdrand ecx -rdrand rcx diff --git a/modules/arch/x86/tests/rdrnd.hex b/modules/arch/x86/tests/rdrnd.hex deleted file mode 100644 index be4bb809..00000000 --- a/modules/arch/x86/tests/rdrnd.hex +++ /dev/null @@ -1,11 +0,0 @@ -66 -0f -c7 -f1 -0f -c7 -f1 -48 -0f -c7 -f1 diff --git a/modules/arch/x86/tests/rdseed.asm b/modules/arch/x86/tests/rdseed.asm deleted file mode 100644 index 42fff846..00000000 --- a/modules/arch/x86/tests/rdseed.asm +++ /dev/null @@ -1,4 +0,0 @@ -[bits 64] -rdseed bx -rdseed ebx -rdseed rbx diff --git a/modules/arch/x86/tests/rdseed.hex b/modules/arch/x86/tests/rdseed.hex deleted file mode 100644 index 03f4fbd3..00000000 --- a/modules/arch/x86/tests/rdseed.hex +++ /dev/null @@ -1,11 +0,0 @@ -66 -0f -c7 -fb -0f -c7 -fb -48 -0f -c7 -fb diff --git a/modules/arch/x86/tests/riprel1.asm b/modules/arch/x86/tests/riprel1.asm deleted file mode 100644 index b1fdbecb..00000000 --- a/modules/arch/x86/tests/riprel1.asm +++ /dev/null @@ -1,66 +0,0 @@ -bits 64 -val: -default abs - -mov rax, val ; 32-bit imm -mov rax, dword val ; 32-bit imm -mov rax, qword val ; 64-bit imm - -mov rbx, val ; 32-bit imm -mov rbx, dword val ; 32-bit imm -mov rbx, qword val ; 64-bit imm - -mov rax, [val] ; 48 8b ... (32-bit disp) -mov rax, [dword val] ; 48 8b ... (32-bit disp) -mov rax, [qword val] ; 48 a1 ... (64-bit disp) -a32 mov rax, [val] ; 67 48 a1 ... (32-bit disp) -a32 mov rax, [dword val] ; 67 48 a1 ... (32-bit disp) -a32 mov rax, [qword val] ; 67 48 a1 ... (32-bit disp) - ; [this one is debatable on correctness, - ; I chose in yasm to make a32 override] -a64 mov rax, [val] ; 48 8b ... (32-bit disp) -a64 mov rax, [dword val] ; 48 8b ... (32-bit disp) -a64 mov rax, [qword val] ; 48 a1 ... (64-bit disp) - -mov rbx, [val] ; 48 8b ... (32-bit disp) -mov rbx, [dword val] ; 48 8b ... (32-bit disp) -;mov rbx, [qword val] ; illegal (can't have 64-bit disp) -a32 mov rbx, [val] ; 67 48 8b ... (32-bit disp) -a32 mov rbx, [dword val] ; 67 48 8b ... (32-bit disp) -;a32 mov rbx, [qword val] ; illegal (can't have 64-bit disp) -a64 mov rbx, [val] ; 48 8b ... (32-bit disp) -a64 mov rbx, [dword val] ; 48 8b ... (32-bit disp) -;a64 mov rbx, [qword val] ; illegal (can't have 64-bit disp) - -default rel - -mov rax, val ; 32-bit imm -mov rax, dword val ; 32-bit imm -mov rax, qword val ; 64-bit imm - -mov rbx, val ; 32-bit imm -mov rbx, dword val ; 32-bit imm -mov rbx, qword val ; 64-bit imm - -mov rax, [val] ; 48 8b ... (32-bit disp, RIP-rel) -mov rax, [dword val] ; 48 8b ... (32-bit disp, RIP-rel) -mov rax, [qword val] ; 48 a1 ... (64-bit disp, ABS) -a32 mov rax, [val] ; 67 48 8b ... (32-bit disp, RIP-rel) -a32 mov rax, [dword val] ; 67 48 8b ... (32-bit disp, RIP-rel) -a32 mov rax, [qword val] ; 67 48 a1 ... (32-bit disp, ABS) - ; [this one is debatable on correctness, - ; I chose in yasm to make a32 override] -a64 mov rax, [val] ; 48 8b ... (32-bit disp, RIP-rel) -a64 mov rax, [dword val] ; 48 8b ... (32-bit disp, RIP-rel) -a64 mov rax, [qword val] ; 48 a1 ... (64-bit disp, ABS) - -mov rbx, [val] ; 48 8b ... (32-bit disp, RIP-rel) -mov rbx, [dword val] ; 48 8b ... (32-bit disp, RIP-rel) -;mov rbx, [qword val] ; illegal (can't have 64-bit disp) -a32 mov rbx, [val] ; 67 48 8b ... (32-bit disp, RIP-rel) -a32 mov rbx, [dword val] ; 67 48 8b ... (32-bit disp, RIP-rel) -;a32 mov rbx, [qword val] ; illegal (can't have 64-bit disp) -a64 mov rbx, [val] ; 48 8b ... (32-bit disp, RIP-rel) -a64 mov rbx, [dword val] ; 48 8b ... (32-bit disp, RIP-rel) -;a64 mov rbx, [qword val] ; illegal (can't have 64-bit disp) - diff --git a/modules/arch/x86/tests/riprel1.hex b/modules/arch/x86/tests/riprel1.hex deleted file mode 100644 index 78f28bff..00000000 --- a/modules/arch/x86/tests/riprel1.hex +++ /dev/null @@ -1,334 +0,0 @@ -48 -c7 -c0 -00 -00 -00 -00 -48 -c7 -c0 -00 -00 -00 -00 -48 -b8 -00 -00 -00 -00 -00 -00 -00 -00 -48 -c7 -c3 -00 -00 -00 -00 -48 -c7 -c3 -00 -00 -00 -00 -48 -bb -00 -00 -00 -00 -00 -00 -00 -00 -48 -8b -04 -25 -00 -00 -00 -00 -48 -8b -04 -25 -00 -00 -00 -00 -48 -a1 -00 -00 -00 -00 -00 -00 -00 -00 -67 -48 -a1 -00 -00 -00 -00 -67 -48 -a1 -00 -00 -00 -00 -67 -48 -a1 -00 -00 -00 -00 -48 -8b -04 -25 -00 -00 -00 -00 -48 -8b -04 -25 -00 -00 -00 -00 -48 -a1 -00 -00 -00 -00 -00 -00 -00 -00 -48 -8b -1c -25 -00 -00 -00 -00 -48 -8b -1c -25 -00 -00 -00 -00 -67 -48 -8b -1c -25 -00 -00 -00 -00 -67 -48 -8b -1c -25 -00 -00 -00 -00 -48 -8b -1c -25 -00 -00 -00 -00 -48 -8b -1c -25 -00 -00 -00 -00 -48 -c7 -c0 -00 -00 -00 -00 -48 -c7 -c0 -00 -00 -00 -00 -48 -b8 -00 -00 -00 -00 -00 -00 -00 -00 -48 -c7 -c3 -00 -00 -00 -00 -48 -c7 -c3 -00 -00 -00 -00 -48 -bb -00 -00 -00 -00 -00 -00 -00 -00 -48 -8b -05 -1e -ff -ff -ff -48 -8b -05 -17 -ff -ff -ff -48 -a1 -00 -00 -00 -00 -00 -00 -00 -00 -67 -48 -8b -05 -05 -ff -ff -ff -67 -48 -8b -05 -fd -fe -ff -ff -67 -48 -a1 -00 -00 -00 -00 -48 -8b -05 -ef -fe -ff -ff -48 -8b -05 -e8 -fe -ff -ff -48 -a1 -00 -00 -00 -00 -00 -00 -00 -00 -48 -8b -1d -d7 -fe -ff -ff -48 -8b -1d -d0 -fe -ff -ff -67 -48 -8b -1d -c8 -fe -ff -ff -67 -48 -8b -1d -c0 -fe -ff -ff -48 -8b -1d -b9 -fe -ff -ff -48 -8b -1d -b2 -fe -ff -ff diff --git a/modules/arch/x86/tests/riprel2.asm b/modules/arch/x86/tests/riprel2.asm deleted file mode 100644 index 7f3be69a..00000000 --- a/modules/arch/x86/tests/riprel2.asm +++ /dev/null @@ -1,110 +0,0 @@ - bits 64 - - default abs ; default abs, except for explicit rel - - mov rax,[foo] - mov rax,[qword 123456789abcdef0h] - mov rbx,[foo] - mov rax,[dword foo] - mov rbx,[dword foo] - mov rax,[qword foo] - mov rax,[rel foo] ; rel - mov rbx,[rel foo] ; rel - mov rax,[rel dword foo] ; rel - ;mov rax,[rel qword foo] ; illegal - mov rax,[abs foo] - mov rbx,[abs foo] - mov rax,[abs dword foo] - mov rax,[abs qword foo] - - mov rax,[es:foo] - mov rax,[qword es:123456789abcdef0h] - mov rbx,[es:foo] - mov rax,[dword es:foo] - mov rbx,[dword es:foo] - mov rax,[qword es:foo] - mov rax,[rel es:foo] ; rel - mov rbx,[rel es:foo] ; rel - mov rax,[rel dword es:foo] ; rel - ;mov rax,[rel qword es:foo] ; illegal - mov rax,[abs es:foo] - mov rbx,[abs es:foo] - mov rax,[abs dword es:foo] - mov rax,[abs qword es:foo] - - mov rax,[fs:foo] - mov rax,[qword fs:123456789abcdef0h] - mov rbx,[fs:foo] - mov rax,[dword fs:foo] - mov rbx,[dword fs:foo] - mov rax,[qword fs:foo] - mov rax,[rel fs:foo] ; rel - mov rbx,[rel fs:foo] ; rel - mov rax,[rel dword fs:foo] ; rel - ;mov rax,[rel qword fs:foo] ; illegal - mov rax,[abs fs:foo] - mov rbx,[abs fs:foo] - mov rax,[abs dword fs:foo] - mov rax,[abs qword fs:foo] - - mov rax,[rbx] - mov rax,[rel rbx] - mov rax,[abs rbx] - - default rel - - ; all of these are default rel, except for 64-bit displacements - mov rax,[foo] - mov rax,[qword 123456789abcdef0h] ; abs - mov rbx,[foo] - mov rax,[dword foo] - mov rbx,[dword foo] - mov rax,[qword foo] ; abs - mov rax,[rel foo] - mov rbx,[rel foo] - mov rax,[rel dword foo] - ;mov rax,[rel qword foo] ; illegal - mov rax,[abs foo] - mov rbx,[abs foo] - mov rax,[abs dword foo] - mov rax,[abs qword foo] - - ; all of these are default rel, except for 64-bit displacements - mov rax,[es:foo] - mov rax,[qword es:123456789abcdef0h] - mov rbx,[es:foo] - mov rax,[dword es:foo] - mov rbx,[dword es:foo] - mov rax,[qword es:foo] - mov rax,[rel es:foo] ; rel - mov rbx,[rel es:foo] ; rel - mov rax,[rel dword es:foo] ; rel - ;mov rax,[rel qword es:foo] ; illegal - mov rax,[abs es:foo] - mov rbx,[abs es:foo] - mov rax,[abs dword es:foo] - mov rax,[abs qword es:foo] - - ; all of these are abs due to fs:, except for explicit rel - mov rax,[fs:foo] - mov rax,[qword fs:123456789abcdef0h] - mov rbx,[fs:foo] - mov rax,[dword fs:foo] - mov rbx,[dword fs:foo] - mov rax,[qword fs:foo] - mov rax,[rel fs:foo] ; rel - mov rbx,[rel fs:foo] ; rel - mov rax,[rel dword fs:foo] ; rel - ;mov rax,[rel qword fs:foo] ; illegal - mov rax,[abs fs:foo] - mov rbx,[abs fs:foo] - mov rax,[abs dword fs:foo] - mov rax,[abs qword fs:foo] - - mov rax,[rbx] - mov rax,[rel rbx] - mov rax,[abs rbx] - - section .data -foo equ $ - diff --git a/modules/arch/x86/tests/riprel2.errwarn b/modules/arch/x86/tests/riprel2.errwarn deleted file mode 100644 index b219dc7e..00000000 --- a/modules/arch/x86/tests/riprel2.errwarn +++ /dev/null @@ -1,26 +0,0 @@ --:20: warning: `es' segment register ignored in 64-bit mode --:21: warning: `es' segment register ignored in 64-bit mode --:22: warning: `es' segment register ignored in 64-bit mode --:23: warning: `es' segment register ignored in 64-bit mode --:24: warning: `es' segment register ignored in 64-bit mode --:25: warning: `es' segment register ignored in 64-bit mode --:26: warning: `es' segment register ignored in 64-bit mode --:27: warning: `es' segment register ignored in 64-bit mode --:28: warning: `es' segment register ignored in 64-bit mode --:30: warning: `es' segment register ignored in 64-bit mode --:31: warning: `es' segment register ignored in 64-bit mode --:32: warning: `es' segment register ignored in 64-bit mode --:33: warning: `es' segment register ignored in 64-bit mode --:73: warning: `es' segment register ignored in 64-bit mode --:74: warning: `es' segment register ignored in 64-bit mode --:75: warning: `es' segment register ignored in 64-bit mode --:76: warning: `es' segment register ignored in 64-bit mode --:77: warning: `es' segment register ignored in 64-bit mode --:78: warning: `es' segment register ignored in 64-bit mode --:79: warning: `es' segment register ignored in 64-bit mode --:80: warning: `es' segment register ignored in 64-bit mode --:81: warning: `es' segment register ignored in 64-bit mode --:83: warning: `es' segment register ignored in 64-bit mode --:84: warning: `es' segment register ignored in 64-bit mode --:85: warning: `es' segment register ignored in 64-bit mode --:86: warning: `es' segment register ignored in 64-bit mode diff --git a/modules/arch/x86/tests/riprel2.hex b/modules/arch/x86/tests/riprel2.hex deleted file mode 100644 index a7b6f112..00000000 --- a/modules/arch/x86/tests/riprel2.hex +++ /dev/null @@ -1,704 +0,0 @@ -48 -8b -04 -25 -c0 -02 -00 -00 -48 -a1 -f0 -de -bc -9a -78 -56 -34 -12 -48 -8b -1c -25 -c0 -02 -00 -00 -48 -8b -04 -25 -c0 -02 -00 -00 -48 -8b -1c -25 -c0 -02 -00 -00 -48 -a1 -c0 -02 -00 -00 -00 -00 -00 -00 -48 -8b -05 -85 -02 -00 -00 -48 -8b -1d -7e -02 -00 -00 -48 -8b -05 -77 -02 -00 -00 -48 -8b -04 -25 -c0 -02 -00 -00 -48 -8b -1c -25 -c0 -02 -00 -00 -48 -8b -04 -25 -c0 -02 -00 -00 -48 -a1 -c0 -02 -00 -00 -00 -00 -00 -00 -26 -48 -8b -04 -25 -c0 -02 -00 -00 -26 -48 -a1 -f0 -de -bc -9a -78 -56 -34 -12 -26 -48 -8b -1c -25 -c0 -02 -00 -00 -26 -48 -8b -04 -25 -c0 -02 -00 -00 -26 -48 -8b -1c -25 -c0 -02 -00 -00 -26 -48 -a1 -c0 -02 -00 -00 -00 -00 -00 -00 -26 -48 -8b -05 -13 -02 -00 -00 -26 -48 -8b -1d -0b -02 -00 -00 -26 -48 -8b -05 -03 -02 -00 -00 -26 -48 -8b -04 -25 -c0 -02 -00 -00 -26 -48 -8b -1c -25 -c0 -02 -00 -00 -26 -48 -8b -04 -25 -c0 -02 -00 -00 -26 -48 -a1 -c0 -02 -00 -00 -00 -00 -00 -00 -64 -48 -8b -04 -25 -c0 -02 -00 -00 -64 -48 -a1 -f0 -de -bc -9a -78 -56 -34 -12 -64 -48 -8b -1c -25 -c0 -02 -00 -00 -64 -48 -8b -04 -25 -c0 -02 -00 -00 -64 -48 -8b -1c -25 -c0 -02 -00 -00 -64 -48 -a1 -c0 -02 -00 -00 -00 -00 -00 -00 -64 -48 -8b -05 -9b -01 -00 -00 -64 -48 -8b -1d -93 -01 -00 -00 -64 -48 -8b -05 -8b -01 -00 -00 -64 -48 -8b -04 -25 -c0 -02 -00 -00 -64 -48 -8b -1c -25 -c0 -02 -00 -00 -64 -48 -8b -04 -25 -c0 -02 -00 -00 -64 -48 -a1 -c0 -02 -00 -00 -00 -00 -00 -00 -48 -8b -03 -48 -8b -03 -48 -8b -03 -48 -8b -05 -55 -01 -00 -00 -48 -a1 -f0 -de -bc -9a -78 -56 -34 -12 -48 -8b -1d -44 -01 -00 -00 -48 -8b -05 -3d -01 -00 -00 -48 -8b -1d -36 -01 -00 -00 -48 -a1 -c0 -02 -00 -00 -00 -00 -00 -00 -48 -8b -05 -25 -01 -00 -00 -48 -8b -1d -1e -01 -00 -00 -48 -8b -05 -17 -01 -00 -00 -48 -8b -04 -25 -c0 -02 -00 -00 -48 -8b -1c -25 -c0 -02 -00 -00 -48 -8b -04 -25 -c0 -02 -00 -00 -48 -a1 -c0 -02 -00 -00 -00 -00 -00 -00 -26 -48 -8b -05 -ed -00 -00 -00 -26 -48 -a1 -f0 -de -bc -9a -78 -56 -34 -12 -26 -48 -8b -1d -da -00 -00 -00 -26 -48 -8b -05 -d2 -00 -00 -00 -26 -48 -8b -1d -ca -00 -00 -00 -26 -48 -a1 -c0 -02 -00 -00 -00 -00 -00 -00 -26 -48 -8b -05 -b7 -00 -00 -00 -26 -48 -8b -1d -af -00 -00 -00 -26 -48 -8b -05 -a7 -00 -00 -00 -26 -48 -8b -04 -25 -c0 -02 -00 -00 -26 -48 -8b -1c -25 -c0 -02 -00 -00 -26 -48 -8b -04 -25 -c0 -02 -00 -00 -26 -48 -a1 -c0 -02 -00 -00 -00 -00 -00 -00 -64 -48 -8b -04 -25 -c0 -02 -00 -00 -64 -48 -a1 -f0 -de -bc -9a -78 -56 -34 -12 -64 -48 -8b -1c -25 -c0 -02 -00 -00 -64 -48 -8b -04 -25 -c0 -02 -00 -00 -64 -48 -8b -1c -25 -c0 -02 -00 -00 -64 -48 -a1 -c0 -02 -00 -00 -00 -00 -00 -00 -64 -48 -8b -05 -3f -00 -00 -00 -64 -48 -8b -1d -37 -00 -00 -00 -64 -48 -8b -05 -2f -00 -00 -00 -64 -48 -8b -04 -25 -c0 -02 -00 -00 -64 -48 -8b -1c -25 -c0 -02 -00 -00 -64 -48 -8b -04 -25 -c0 -02 -00 -00 -64 -48 -a1 -c0 -02 -00 -00 -00 -00 -00 -00 -48 -8b -03 -48 -8b -03 -48 -8b -03 diff --git a/modules/arch/x86/tests/ripseg.asm b/modules/arch/x86/tests/ripseg.asm deleted file mode 100644 index 1779a1c9..00000000 --- a/modules/arch/x86/tests/ripseg.asm +++ /dev/null @@ -1,35 +0,0 @@ -bits 64 -foo: - -default abs -mov rbx, [foo] -mov rbx, [es:foo] -mov rbx, [fs:foo] -mov rbx, [gs:foo] -mov rbx, [rel es:foo] -mov rbx, [rel fs:foo] -mov rbx, [rel gs:foo] -mov rbx, [abs es:foo] -mov rbx, [abs fs:foo] -mov rbx, [abs gs:foo] -;mov rbx, [es:rel foo] -;mov rbx, [fs:rel foo] -;mov rbx, [es:abs foo] -;mov rbx, [fs:abs foo] - -default rel -mov rbx, [foo] -mov rbx, [es:foo] -mov rbx, [fs:foo] -mov rbx, [gs:foo] -mov rbx, [rel es:foo] -mov rbx, [rel fs:foo] -mov rbx, [rel gs:foo] -mov rbx, [abs es:foo] -mov rbx, [abs fs:foo] -mov rbx, [abs gs:foo] -;mov rbx, [es:rel foo] -;mov rbx, [fs:rel foo] -;mov rbx, [es:abs foo] -;mov rbx, [fs:abs foo] - diff --git a/modules/arch/x86/tests/ripseg.errwarn b/modules/arch/x86/tests/ripseg.errwarn deleted file mode 100644 index 19782ddd..00000000 --- a/modules/arch/x86/tests/ripseg.errwarn +++ /dev/null @@ -1,6 +0,0 @@ --:6: warning: `es' segment register ignored in 64-bit mode --:9: warning: `es' segment register ignored in 64-bit mode --:12: warning: `es' segment register ignored in 64-bit mode --:22: warning: `es' segment register ignored in 64-bit mode --:25: warning: `es' segment register ignored in 64-bit mode --:28: warning: `es' segment register ignored in 64-bit mode diff --git a/modules/arch/x86/tests/ripseg.hex b/modules/arch/x86/tests/ripseg.hex deleted file mode 100644 index 5303fe94..00000000 --- a/modules/arch/x86/tests/ripseg.hex +++ /dev/null @@ -1,170 +0,0 @@ -48 -8b -1c -25 -00 -00 -00 -00 -26 -48 -8b -1c -25 -00 -00 -00 -00 -64 -48 -8b -1c -25 -00 -00 -00 -00 -65 -48 -8b -1c -25 -00 -00 -00 -00 -26 -48 -8b -1d -d5 -ff -ff -ff -64 -48 -8b -1d -cd -ff -ff -ff -65 -48 -8b -1d -c5 -ff -ff -ff -26 -48 -8b -1c -25 -00 -00 -00 -00 -64 -48 -8b -1c -25 -00 -00 -00 -00 -65 -48 -8b -1c -25 -00 -00 -00 -00 -48 -8b -1d -a3 -ff -ff -ff -26 -48 -8b -1d -9b -ff -ff -ff -64 -48 -8b -1c -25 -00 -00 -00 -00 -65 -48 -8b -1c -25 -00 -00 -00 -00 -26 -48 -8b -1d -81 -ff -ff -ff -64 -48 -8b -1d -79 -ff -ff -ff -65 -48 -8b -1d -71 -ff -ff -ff -26 -48 -8b -1c -25 -00 -00 -00 -00 -64 -48 -8b -1c -25 -00 -00 -00 -00 -65 -48 -8b -1c -25 -00 -00 -00 -00 diff --git a/modules/arch/x86/tests/segoff-err.asm b/modules/arch/x86/tests/segoff-err.asm deleted file mode 100644 index ac76927d..00000000 --- a/modules/arch/x86/tests/segoff-err.asm +++ /dev/null @@ -1,6 +0,0 @@ -; all of these should be illegal - -jmp far[1:2] -mov ax,[1:2] -push dword [1:2] -mov ax,1:2 diff --git a/modules/arch/x86/tests/segoff-err.errwarn b/modules/arch/x86/tests/segoff-err.errwarn deleted file mode 100644 index 98a96c7b..00000000 --- a/modules/arch/x86/tests/segoff-err.errwarn +++ /dev/null @@ -1,4 +0,0 @@ --:3: error: invalid segment in effective address --:4: error: invalid segment in effective address --:5: error: invalid segment in effective address --:6: error: immediate does not support segment diff --git a/modules/arch/x86/tests/segoff.asm b/modules/arch/x86/tests/segoff.asm deleted file mode 100644 index 7a2091fe..00000000 --- a/modules/arch/x86/tests/segoff.asm +++ /dev/null @@ -1,7 +0,0 @@ -; all of these should be legal and should just result in the offset portion - -foo equ 1:2 -jmp far[foo] -mov ax,[foo] -push dword [foo] -mov ax,foo diff --git a/modules/arch/x86/tests/segoff.hex b/modules/arch/x86/tests/segoff.hex deleted file mode 100644 index 7520242a..00000000 --- a/modules/arch/x86/tests/segoff.hex +++ /dev/null @@ -1,15 +0,0 @@ -ff -2e -02 -00 -a1 -02 -00 -66 -ff -36 -02 -00 -b8 -02 -00 diff --git a/modules/arch/x86/tests/shift64.asm b/modules/arch/x86/tests/shift64.asm deleted file mode 100644 index c1ce6b1c..00000000 --- a/modules/arch/x86/tests/shift64.asm +++ /dev/null @@ -1,5 +0,0 @@ -[bits 64] -shl rax, 5 -shl rax, 32 -shr rax, 5 -shr rax, 32 diff --git a/modules/arch/x86/tests/shift64.hex b/modules/arch/x86/tests/shift64.hex deleted file mode 100644 index ad28eb24..00000000 --- a/modules/arch/x86/tests/shift64.hex +++ /dev/null @@ -1,16 +0,0 @@ -48 -c1 -e0 -05 -48 -c1 -e0 -20 -48 -c1 -e8 -05 -48 -c1 -e8 -20 diff --git a/modules/arch/x86/tests/smap.asm b/modules/arch/x86/tests/smap.asm deleted file mode 100644 index 702bc810..00000000 --- a/modules/arch/x86/tests/smap.asm +++ /dev/null @@ -1,2 +0,0 @@ -clac -stac diff --git a/modules/arch/x86/tests/smap.hex b/modules/arch/x86/tests/smap.hex deleted file mode 100644 index a1034059..00000000 --- a/modules/arch/x86/tests/smap.hex +++ /dev/null @@ -1,6 +0,0 @@ -0f -01 -ca -0f -01 -cb diff --git a/modules/arch/x86/tests/smx.asm b/modules/arch/x86/tests/smx.asm deleted file mode 100644 index e5ca5b5a..00000000 --- a/modules/arch/x86/tests/smx.asm +++ /dev/null @@ -1,3 +0,0 @@ -[bits 32] -getsec - diff --git a/modules/arch/x86/tests/smx.hex b/modules/arch/x86/tests/smx.hex deleted file mode 100644 index 7e6dae1f..00000000 --- a/modules/arch/x86/tests/smx.hex +++ /dev/null @@ -1,2 +0,0 @@ -0f -37 diff --git a/modules/arch/x86/tests/sse4-err.errwarn b/modules/arch/x86/tests/sse4-err.errwarn index 8a785392..b26a14d1 100644 --- a/modules/arch/x86/tests/sse4-err.errwarn +++ b/modules/arch/x86/tests/sse4-err.errwarn @@ -1,2 +1,2 @@ --:2: error: cannot use A/B/C/DH with instruction needing REX --:3: error: cannot use A/B/C/DH with instruction needing REX +-:2: cannot use A/B/C/DH with instruction needing REX +-:3: cannot use A/B/C/DH with instruction needing REX diff --git a/modules/arch/x86/tests/ssewidth.asm b/modules/arch/x86/tests/ssewidth.asm deleted file mode 100644 index 0824b769..00000000 --- a/modules/arch/x86/tests/ssewidth.asm +++ /dev/null @@ -1,566 +0,0 @@ -[bits 64] -addpd xmm1, xmm2 -addpd xmm1, dqword [rbx] - -addps xmm1, xmm2 -addps xmm1, dqword [rbx] - -addsd xmm1, xmm2 -addsd xmm1, qword [rbx] - -addss xmm1, xmm2 -addss xmm1, dword [rbx] - -addsubpd xmm1, xmm2 -addsubpd xmm1, dqword [rbx] - -addsubps xmm1, xmm2 -addsubps xmm1, dqword [rbx] - -andnpd xmm1, xmm2 -andnpd xmm1, dqword [rbx] - -andnps xmm1, xmm2 -andnps xmm1, dqword [rbx] - -andpd xmm1, xmm2 -andpd xmm1, dqword [rbx] - -andps xmm1, xmm2 -andps xmm1, dqword [rbx] - -cmppd xmm1, xmm2, 0 -cmppd xmm1, dqword [rbx], 0 -cmpeqpd xmm1, xmm2 -cmpeqpd xmm1, dqword [rbx] - -cmpps xmm1, xmm2, 0 -cmpps xmm1, dqword [rbx], 0 -cmpeqps xmm1, xmm2 -cmpeqps xmm1, dqword [rbx] - -cmpsd xmm1, xmm2, 0 -cmpsd xmm1, qword [rbx], 0 -cmpeqsd xmm1, xmm2 -cmpeqsd xmm1, qword [rbx] - -cmpss xmm1, xmm2, 0 -cmpss xmm1, dword [rbx], 0 -cmpeqss xmm1, xmm2 -cmpeqss xmm1, dword [rbx] - -comisd xmm1, xmm2 -comisd xmm1, qword [rbx] - -comiss xmm1, xmm2 -comiss xmm1, dword [rbx] - -cvtdq2pd xmm1, xmm2 -cvtdq2pd xmm1, qword [rbx] - -cvtdq2ps xmm1, xmm2 -cvtdq2ps xmm1, dqword [rbx] - -cvtpd2dq xmm1, xmm2 -cvtpd2dq xmm1, dqword [rbx] - -cvtpd2pi mm1, xmm2 ; mmx -cvtpd2pi mm1, dqword [rbx] - -cvtpd2ps xmm1, xmm2 -cvtpd2ps xmm1, dqword [rbx] - -cvtpi2pd xmm1, mm2 ; mmx -cvtpi2pd xmm1, qword [rbx] - -cvtpi2ps xmm1, mm2 ; mmx -cvtpi2ps xmm1, qword [rbx] - -cvtps2dq xmm1, xmm2 -cvtps2dq xmm1, dqword [rbx] - -cvtps2pd xmm1, xmm2 -cvtps2pd xmm1, qword [rbx] - -cvtps2pi mm1, xmm2 -cvtps2pi mm1, qword [rbx] - -cvtsd2si rbx, xmm2 -cvtsd2si rbx, qword [rbx] - -cvtsd2ss xmm1, xmm2 -cvtsd2ss xmm1, qword [rbx] - -cvtsi2sd xmm1, ebx -cvtsi2sd xmm1, dword [rbx] -cvtsi2sd xmm1, rbx -cvtsi2sd xmm1, qword [rbx] - -cvtsi2ss xmm1, ebx -cvtsi2ss xmm1, dword [rbx] -cvtsi2ss xmm1, rbx -cvtsi2ss xmm1, qword [rbx] - -cvtss2sd xmm1, xmm2 -cvtss2sd xmm1, dword [rbx] - -cvtss2si ebx, xmm2 -cvtss2si ebx, dword [rbx] -cvtss2si rbx, xmm2 -cvtss2si rbx, dword [rbx] - -cvttpd2dq xmm1, xmm2 -cvttpd2dq xmm1, dqword [rbx] - -cvttpd2pi mm1, xmm2 -cvttpd2pi mm1, dqword [rbx] - -cvttps2dq xmm1, xmm2 -cvttps2dq xmm1, dqword [rbx] - -cvttps2pi mm1, xmm2 -cvttps2pi mm1, qword [rbx] - -cvttsd2si eax, xmm1 -cvttsd2si eax, qword [rbx] -cvttsd2si rax, xmm1 -cvttsd2si rax, qword [rbx] - -cvttss2si eax, xmm1 -cvttss2si eax, dword [rbx] -cvttss2si rax, xmm1 -cvttss2si rax, dword [rbx] - -divpd xmm1, xmm2 -divpd xmm1, dqword [rbx] - -divps xmm1, xmm2 -divps xmm1, dqword [rbx] - -divsd xmm1, xmm2 -divsd xmm1, qword [rbx] - -divss xmm1, xmm2 -divss xmm1, dword [rbx] - -extrq xmm1, 0, 1 -extrq xmm1, byte 0, byte 1 -extrq xmm1, xmm2 - -haddpd xmm1, xmm2 -haddpd xmm1, dqword [rbx] - -haddps xmm1, xmm2 -haddps xmm1, dqword [rbx] - -hsubpd xmm1, xmm2 -hsubpd xmm1, dqword [rbx] - -hsubps xmm1, xmm2 -hsubps xmm1, dqword [rbx] - -insertq xmm1, xmm2, 0, 1 -insertq xmm1, xmm2, byte 0, byte 1 -insertq xmm1, xmm2 - -lddqu xmm1, dqword [rbx] - -ldmxcsr dword [rbx] - -maskmovdqu xmm1, xmm2 - -maxpd xmm1, xmm2 -maxpd xmm1, dqword [rbx] - -maxps xmm1, xmm2 -maxps xmm1, dqword [rbx] - -maxsd xmm1, xmm2 -maxsd xmm1, qword [rbx] - -maxss xmm1, xmm2 -maxss xmm1, dword [rbx] - -minpd xmm1, xmm2 -minpd xmm1, dqword [rbx] - -minps xmm1, xmm2 -minps xmm1, dqword [rbx] - -minsd xmm1, xmm2 -minsd xmm1, qword [rbx] - -minss xmm1, xmm2 -minss xmm1, dword [rbx] - -movapd xmm1, xmm2 -movapd xmm1, dqword [rbx] -movapd dqword [rbx], xmm2 - -movaps xmm1, xmm2 -movaps xmm1, dqword [rbx] -movaps dqword [rbx], xmm2 - -movd xmm1, ebx -movd xmm1, dword [rbx] -movd xmm1, rbx -movd xmm1, qword [rbx] -movd dword [rbx], xmm2 -movd qword [rbx], xmm2 - -movddup xmm1, xmm2 -movddup xmm1, qword [rbx] - -movdq2q mm1, xmm2 - -movdqa xmm1, xmm2 -movdqa xmm1, dqword [rbx] -movdqa dqword [rbx], xmm2 - -movdqu xmm1, xmm2 -movdqu xmm1, dqword [rbx] -movdqu dqword [rbx], xmm2 - -movhlps xmm1, xmm2 - -movhpd xmm1, qword [rbx] -movhpd qword [rbx], xmm2 - -movhps xmm1, qword [rbx] -movhps qword [rbx], xmm2 - -movlhps xmm1, xmm2 - -movlpd xmm1, qword [rbx] -movlpd qword [rbx], xmm2 - -movlps xmm1, qword [rbx] -movlps qword [rbx], xmm2 - -movmskpd ebx, xmm2 - -movmskps ebx, xmm2 - -movntdq dqword [rbx], xmm2 - -movntpd dqword [rbx], xmm2 - -movntps dqword [rbx], xmm2 - -movntsd qword [rbx], xmm2 - -movntss dword [rbx], xmm2 - -movq xmm1, xmm2 -movq xmm1, qword [rbx] -movq qword [rbx], xmm2 - -movq2dq xmm1, mm2 - -movsd xmm1, xmm2 -movsd xmm1, qword [rbx] -movsd qword [rbx], xmm2 - -movshdup xmm1, xmm2 -movshdup xmm1, dqword [rbx] - -movsldup xmm1, xmm2 -movsldup xmm1, dqword [rbx] - -movss xmm1, xmm2 -movss xmm1, dword [rbx] -movss dword [rbx], xmm2 - -movupd xmm1, xmm2 -movupd xmm1, dqword [rbx] -movupd dqword [rbx], xmm2 - -movups xmm1, xmm2 -movups xmm1, dqword [rbx] -movups dqword [rbx], xmm2 - -mulpd xmm1, xmm2 -mulpd xmm1, dqword [rbx] - -mulps xmm1, xmm2 -mulps xmm1, dqword [rbx] - -mulsd xmm1, xmm2 -mulsd xmm1, qword [rbx] - -mulss xmm1, xmm2 -mulss xmm1, dword [rbx] - -orpd xmm1, xmm2 -orpd xmm1, dqword [rbx] - -orps xmm1, xmm2 -orps xmm1, dqword [rbx] - -packssdw xmm1, xmm2 -packssdw xmm1, dqword [rbx] - -packsswb xmm1, xmm2 -packsswb xmm1, dqword [rbx] - -packuswb xmm1, xmm2 -packuswb xmm1, dqword [rbx] - -paddb xmm1, xmm2 -paddb xmm1, dqword [rbx] - -paddd xmm1, xmm2 -paddd xmm1, dqword [rbx] - -paddq xmm1, xmm2 -paddq xmm1, dqword [rbx] - -paddsb xmm1, xmm2 -paddsb xmm1, dqword [rbx] - -paddsw xmm1, xmm2 -paddsw xmm1, dqword [rbx] - -paddusb xmm1, xmm2 -paddusb xmm1, dqword [rbx] - -paddusw xmm1, xmm2 -paddusw xmm1, dqword [rbx] - -paddw xmm1, xmm2 -paddw xmm1, dqword [rbx] - -pand xmm1, xmm2 -pand xmm1, dqword [rbx] - -pandn xmm1, xmm2 -pandn xmm1, dqword [rbx] - -pavgb xmm1, xmm2 -pavgb xmm1, dqword [rbx] - -pavgw xmm1, xmm2 -pavgw xmm1, dqword [rbx] - -pcmpeqb xmm1, xmm2 -pcmpeqb xmm1, dqword [rbx] - -pcmpeqd xmm1, xmm2 -pcmpeqd xmm1, dqword [rbx] - -pcmpeqw xmm1, xmm2 -pcmpeqw xmm1, dqword [rbx] - -pcmpgtb xmm1, xmm2 -pcmpgtb xmm1, dqword [rbx] - -pcmpgtd xmm1, xmm2 -pcmpgtd xmm1, dqword [rbx] - -pcmpgtw xmm1, xmm2 -pcmpgtw xmm1, dqword [rbx] - -pextrw ebx, xmm2, byte 0 - -pinsrw xmm1, ebx, byte 0 -pinsrw xmm1, word [rbx], byte 0 - -pmaddwd xmm1, xmm2 -pmaddwd xmm1, dqword [rbx] - -pmaxsw xmm1, xmm2 -pmaxsw xmm1, dqword [rbx] - -pmaxub xmm1, xmm2 -pmaxub xmm1, dqword [rbx] - -pminsw xmm1, xmm2 -pminsw xmm1, dqword [rbx] - -pminub xmm1, xmm2 -pminub xmm1, dqword [rbx] - -pmovmskb eax, xmm2 - -pmulhuw xmm1, xmm2 -pmulhuw xmm1, dqword [rbx] - -pmulhw xmm1, xmm2 -pmulhw xmm1, dqword [rbx] - -pmullw xmm1, xmm2 -pmullw xmm1, dqword [rbx] - -pmuludq xmm1, xmm2 -pmuludq xmm1, dqword [rbx] - -por xmm1, xmm2 -por xmm1, dqword [rbx] - -psadbw xmm1, xmm2 -psadbw xmm1, dqword [rbx] - -pshufd xmm1, xmm2, byte 0 -pshufd xmm1, dqword [rbx], byte 0 - -pshufhw xmm1, xmm2, byte 0 -pshufhw xmm1, dqword [rbx], byte 0 - -pshuflw xmm1, xmm2, byte 0 -pshuflw xmm1, dqword [rbx], byte 0 - -pslld xmm1, xmm2 -pslld xmm1, dqword [rbx] -pslld xmm1, byte 5 - -pslldq xmm1, byte 5 - -psllq xmm1, xmm2 -psllq xmm1, dqword [rbx] -psllq xmm1, byte 5 - -psllw xmm1, xmm2 -psllw xmm1, dqword [rbx] -psllw xmm1, byte 5 - -psrad xmm1, xmm2 -psrad xmm1, dqword [rbx] -psrad xmm1, byte 5 - -psraw xmm1, xmm2 -psraw xmm1, dqword [rbx] -psraw xmm1, byte 5 - -psrld xmm1, xmm2 -psrld xmm1, dqword [rbx] -psrld xmm1, byte 5 - -psrldq xmm1, byte 5 - -psrlq xmm1, xmm2 -psrlq xmm1, dqword [rbx] -psrlq xmm1, byte 5 - -psrlw xmm1, xmm2 -psrlw xmm1, dqword [rbx] -psrlw xmm1, byte 5 - -psubb xmm1, xmm2 -psubb xmm1, dqword [rbx] - -psubd xmm1, xmm2 -psubd xmm1, dqword [rbx] - -psubq xmm1, xmm2 -psubq xmm1, dqword [rbx] - -psubsb xmm1, xmm2 -psubsb xmm1, dqword [rbx] - -psubsw xmm1, xmm2 -psubsw xmm1, dqword [rbx] - -psubusb xmm1, xmm2 -psubusb xmm1, dqword [rbx] - -psubusw xmm1, xmm2 -psubusw xmm1, dqword [rbx] - -psubw xmm1, xmm2 -psubw xmm1, dqword [rbx] - -punpckhbw xmm1, xmm2 -punpckhbw xmm1, dqword [rbx] - -punpckhdq xmm1, xmm2 -punpckhdq xmm1, dqword [rbx] - -punpckhqdq xmm1, xmm2 -punpckhqdq xmm1, dqword [rbx] - -punpckhwd xmm1, xmm2 -punpckhwd xmm1, dqword [rbx] - -punpcklbw xmm1, xmm2 -punpcklbw xmm1, dqword [rbx] - -punpckldq xmm1, xmm2 -punpckldq xmm1, dqword [rbx] - -punpcklqdq xmm1, xmm2 -punpcklqdq xmm1, dqword [rbx] - -punpcklwd xmm1, xmm2 -punpcklwd xmm1, dqword [rbx] - -pxor xmm1, xmm2 -pxor xmm1, dqword [rbx] - -rcpps xmm1, xmm2 -rcpps xmm1, dqword [rbx] - -rcpss xmm1, xmm2 -rcpss xmm1, dword [rbx] - -rsqrtps xmm1, xmm2 -rsqrtps xmm1, dqword [rbx] - -rsqrtss xmm1, xmm2 -rsqrtss xmm1, dword [rbx] - -shufpd xmm1, xmm2, 0 -shufpd xmm1, dqword [rbx], byte 0 - -shufps xmm1, xmm2, 0 -shufps xmm1, dqword [rbx], byte 0 - -sqrtpd xmm1, xmm2 -sqrtpd xmm1, dqword [rbx] - -sqrtps xmm1, xmm2 -sqrtps xmm1, dqword [rbx] - -sqrtsd xmm1, xmm2 -sqrtsd xmm1, qword [rbx] - -sqrtss xmm1, xmm2 -sqrtss xmm1, dword [rbx] - -stmxcsr dword [rbx] - -subpd xmm1, xmm2 -subpd xmm1, dqword [rbx] - -subps xmm1, xmm2 -subps xmm1, dqword [rbx] - -subsd xmm1, xmm2 -subsd xmm1, qword [rbx] - -subss xmm1, xmm2 -subss xmm1, dword [rbx] - -ucomisd xmm1, xmm2 -ucomisd xmm1, qword [rbx] - -ucomiss xmm1, xmm2 -ucomiss xmm1, dword [rbx] - -unpckhpd xmm1, xmm2 -unpckhpd xmm1, dqword [rbx] - -unpckhps xmm1, xmm2 -unpckhps xmm1, dqword [rbx] - -unpcklpd xmm1, xmm2 -unpcklpd xmm1, dqword [rbx] - -unpcklps xmm1, xmm2 -unpcklps xmm1, dqword [rbx] - -xorpd xmm1, xmm2 -xorpd xmm1, dqword [rbx] - -xorps xmm1, xmm2 -xorps xmm1, dqword [rbx] - diff --git a/modules/arch/x86/tests/ssewidth.hex b/modules/arch/x86/tests/ssewidth.hex deleted file mode 100644 index fc24e8da..00000000 --- a/modules/arch/x86/tests/ssewidth.hex +++ /dev/null @@ -1,1532 +0,0 @@ -66 -0f -58 -ca -66 -0f -58 -0b -0f -58 -ca -0f -58 -0b -f2 -0f -58 -ca -f2 -0f -58 -0b -f3 -0f -58 -ca -f3 -0f -58 -0b -66 -0f -d0 -ca -66 -0f -d0 -0b -f2 -0f -d0 -ca -f2 -0f -d0 -0b -66 -0f -55 -ca -66 -0f -55 -0b -0f -55 -ca -0f -55 -0b -66 -0f -54 -ca -66 -0f -54 -0b -0f -54 -ca -0f -54 -0b -66 -0f -c2 -ca -00 -66 -0f -c2 -0b -00 -66 -0f -c2 -ca -00 -66 -0f -c2 -0b -00 -0f -c2 -ca -00 -0f -c2 -0b -00 -0f -c2 -ca -00 -0f -c2 -0b -00 -f2 -0f -c2 -ca -00 -f2 -0f -c2 -0b -00 -f2 -0f -c2 -ca -00 -f2 -0f -c2 -0b -00 -f3 -0f -c2 -ca -00 -f3 -0f -c2 -0b -00 -f3 -0f -c2 -ca -00 -f3 -0f -c2 -0b -00 -66 -0f -2f -ca -66 -0f -2f -0b -0f -2f -ca -0f -2f -0b -f3 -0f -e6 -ca -f3 -0f -e6 -0b -0f -5b -ca -0f -5b -0b -f2 -0f -e6 -ca -f2 -0f -e6 -0b -66 -0f -2d -ca -66 -0f -2d -0b -66 -0f -5a -ca -66 -0f -5a -0b -66 -0f -2a -ca -66 -0f -2a -0b -0f -2a -ca -0f -2a -0b -66 -0f -5b -ca -66 -0f -5b -0b -0f -5a -ca -0f -5a -0b -0f -2d -ca -0f -2d -0b -f2 -48 -0f -2d -da -f2 -48 -0f -2d -1b -f2 -0f -5a -ca -f2 -0f -5a -0b -f2 -0f -2a -cb -f2 -0f -2a -0b -f2 -48 -0f -2a -cb -f2 -48 -0f -2a -0b -f3 -0f -2a -cb -f3 -0f -2a -0b -f3 -48 -0f -2a -cb -f3 -48 -0f -2a -0b -f3 -0f -5a -ca -f3 -0f -5a -0b -f3 -0f -2d -da -f3 -0f -2d -1b -f3 -48 -0f -2d -da -f3 -48 -0f -2d -1b -66 -0f -e6 -ca -66 -0f -e6 -0b -66 -0f -2c -ca -66 -0f -2c -0b -f3 -0f -5b -ca -f3 -0f -5b -0b -0f -2c -ca -0f -2c -0b -f2 -0f -2c -c1 -f2 -0f -2c -03 -f2 -48 -0f -2c -c1 -f2 -48 -0f -2c -03 -f3 -0f -2c -c1 -f3 -0f -2c -03 -f3 -48 -0f -2c -c1 -f3 -48 -0f -2c -03 -66 -0f -5e -ca -66 -0f -5e -0b -0f -5e -ca -0f -5e -0b -f2 -0f -5e -ca -f2 -0f -5e -0b -f3 -0f -5e -ca -f3 -0f -5e -0b -66 -0f -78 -c1 -00 -01 -66 -0f -78 -c1 -00 -01 -66 -0f -79 -ca -66 -0f -7c -ca -66 -0f -7c -0b -f2 -0f -7c -ca -f2 -0f -7c -0b -66 -0f -7d -ca -66 -0f -7d -0b -f2 -0f -7d -ca -f2 -0f -7d -0b -f2 -0f -78 -ca -00 -01 -f2 -0f -78 -ca -00 -01 -f2 -0f -79 -ca -f2 -0f -f0 -0b -0f -ae -13 -66 -0f -f7 -ca -66 -0f -5f -ca -66 -0f -5f -0b -0f -5f -ca -0f -5f -0b -f2 -0f -5f -ca -f2 -0f -5f -0b -f3 -0f -5f -ca -f3 -0f -5f -0b -66 -0f -5d -ca -66 -0f -5d -0b -0f -5d -ca -0f -5d -0b -f2 -0f -5d -ca -f2 -0f -5d -0b -f3 -0f -5d -ca -f3 -0f -5d -0b -66 -0f -28 -ca -66 -0f -28 -0b -66 -0f -29 -13 -0f -28 -ca -0f -28 -0b -0f -29 -13 -66 -0f -6e -cb -66 -0f -6e -0b -66 -48 -0f -6e -cb -66 -48 -0f -6e -0b -66 -0f -7e -13 -66 -48 -0f -7e -13 -f2 -0f -12 -ca -f2 -0f -12 -0b -f2 -0f -d6 -ca -66 -0f -6f -ca -66 -0f -6f -0b -66 -0f -7f -13 -f3 -0f -6f -ca -f3 -0f -6f -0b -f3 -0f -7f -13 -0f -12 -ca -66 -0f -16 -0b -66 -0f -17 -13 -0f -16 -0b -0f -17 -13 -0f -16 -ca -66 -0f -12 -0b -66 -0f -13 -13 -0f -12 -0b -0f -13 -13 -66 -0f -50 -da -0f -50 -da -66 -0f -e7 -13 -66 -0f -2b -13 -0f -2b -13 -f2 -0f -2b -13 -f3 -0f -2b -13 -f3 -0f -7e -ca -f3 -0f -7e -0b -66 -0f -d6 -13 -f3 -0f -d6 -ca -f2 -0f -10 -ca -f2 -0f -10 -0b -f2 -0f -11 -13 -f3 -0f -16 -ca -f3 -0f -16 -0b -f3 -0f -12 -ca -f3 -0f -12 -0b -f3 -0f -10 -ca -f3 -0f -10 -0b -f3 -0f -11 -13 -66 -0f -10 -ca -66 -0f -10 -0b -66 -0f -11 -13 -0f -10 -ca -0f -10 -0b -0f -11 -13 -66 -0f -59 -ca -66 -0f -59 -0b -0f -59 -ca -0f -59 -0b -f2 -0f -59 -ca -f2 -0f -59 -0b -f3 -0f -59 -ca -f3 -0f -59 -0b -66 -0f -56 -ca -66 -0f -56 -0b -0f -56 -ca -0f -56 -0b -66 -0f -6b -ca -66 -0f -6b -0b -66 -0f -63 -ca -66 -0f -63 -0b -66 -0f -67 -ca -66 -0f -67 -0b -66 -0f -fc -ca -66 -0f -fc -0b -66 -0f -fe -ca -66 -0f -fe -0b -66 -0f -d4 -ca -66 -0f -d4 -0b -66 -0f -ec -ca -66 -0f -ec -0b -66 -0f -ed -ca -66 -0f -ed -0b -66 -0f -dc -ca -66 -0f -dc -0b -66 -0f -dd -ca -66 -0f -dd -0b -66 -0f -fd -ca -66 -0f -fd -0b -66 -0f -db -ca -66 -0f -db -0b -66 -0f -df -ca -66 -0f -df -0b -66 -0f -e0 -ca -66 -0f -e0 -0b -66 -0f -e3 -ca -66 -0f -e3 -0b -66 -0f -74 -ca -66 -0f -74 -0b -66 -0f -76 -ca -66 -0f -76 -0b -66 -0f -75 -ca -66 -0f -75 -0b -66 -0f -64 -ca -66 -0f -64 -0b -66 -0f -66 -ca -66 -0f -66 -0b -66 -0f -65 -ca -66 -0f -65 -0b -66 -0f -c5 -da -00 -66 -0f -c4 -cb -00 -66 -0f -c4 -0b -00 -66 -0f -f5 -ca -66 -0f -f5 -0b -66 -0f -ee -ca -66 -0f -ee -0b -66 -0f -de -ca -66 -0f -de -0b -66 -0f -ea -ca -66 -0f -ea -0b -66 -0f -da -ca -66 -0f -da -0b -66 -0f -d7 -c2 -66 -0f -e4 -ca -66 -0f -e4 -0b -66 -0f -e5 -ca -66 -0f -e5 -0b -66 -0f -d5 -ca -66 -0f -d5 -0b -66 -0f -f4 -ca -66 -0f -f4 -0b -66 -0f -eb -ca -66 -0f -eb -0b -66 -0f -f6 -ca -66 -0f -f6 -0b -66 -0f -70 -ca -00 -66 -0f -70 -0b -00 -f3 -0f -70 -ca -00 -f3 -0f -70 -0b -00 -f2 -0f -70 -ca -00 -f2 -0f -70 -0b -00 -66 -0f -f2 -ca -66 -0f -f2 -0b -66 -0f -72 -f1 -05 -66 -0f -73 -f9 -05 -66 -0f -f3 -ca -66 -0f -f3 -0b -66 -0f -73 -f1 -05 -66 -0f -f1 -ca -66 -0f -f1 -0b -66 -0f -71 -f1 -05 -66 -0f -e2 -ca -66 -0f -e2 -0b -66 -0f -72 -e1 -05 -66 -0f -e1 -ca -66 -0f -e1 -0b -66 -0f -71 -e1 -05 -66 -0f -d2 -ca -66 -0f -d2 -0b -66 -0f -72 -d1 -05 -66 -0f -73 -d9 -05 -66 -0f -d3 -ca -66 -0f -d3 -0b -66 -0f -73 -d1 -05 -66 -0f -d1 -ca -66 -0f -d1 -0b -66 -0f -71 -d1 -05 -66 -0f -f8 -ca -66 -0f -f8 -0b -66 -0f -fa -ca -66 -0f -fa -0b -66 -0f -fb -ca -66 -0f -fb -0b -66 -0f -e8 -ca -66 -0f -e8 -0b -66 -0f -e9 -ca -66 -0f -e9 -0b -66 -0f -d8 -ca -66 -0f -d8 -0b -66 -0f -d9 -ca -66 -0f -d9 -0b -66 -0f -f9 -ca -66 -0f -f9 -0b -66 -0f -68 -ca -66 -0f -68 -0b -66 -0f -6a -ca -66 -0f -6a -0b -66 -0f -6d -ca -66 -0f -6d -0b -66 -0f -69 -ca -66 -0f -69 -0b -66 -0f -60 -ca -66 -0f -60 -0b -66 -0f -62 -ca -66 -0f -62 -0b -66 -0f -6c -ca -66 -0f -6c -0b -66 -0f -61 -ca -66 -0f -61 -0b -66 -0f -ef -ca -66 -0f -ef -0b -0f -53 -ca -0f -53 -0b -f3 -0f -53 -ca -f3 -0f -53 -0b -0f -52 -ca -0f -52 -0b -f3 -0f -52 -ca -f3 -0f -52 -0b -66 -0f -c6 -ca -00 -66 -0f -c6 -0b -00 -0f -c6 -ca -00 -0f -c6 -0b -00 -66 -0f -51 -ca -66 -0f -51 -0b -0f -51 -ca -0f -51 -0b -f2 -0f -51 -ca -f2 -0f -51 -0b -f3 -0f -51 -ca -f3 -0f -51 -0b -0f -ae -1b -66 -0f -5c -ca -66 -0f -5c -0b -0f -5c -ca -0f -5c -0b -f2 -0f -5c -ca -f2 -0f -5c -0b -f3 -0f -5c -ca -f3 -0f -5c -0b -66 -0f -2e -ca -66 -0f -2e -0b -0f -2e -ca -0f -2e -0b -66 -0f -15 -ca -66 -0f -15 -0b -0f -15 -ca -0f -15 -0b -66 -0f -14 -ca -66 -0f -14 -0b -0f -14 -ca -0f -14 -0b -66 -0f -57 -ca -66 -0f -57 -0b -0f -57 -ca -0f -57 -0b diff --git a/modules/arch/x86/tests/strict-err.errwarn b/modules/arch/x86/tests/strict-err.errwarn index ac3b21b8..62ebb456 100644 --- a/modules/arch/x86/tests/strict-err.errwarn +++ b/modules/arch/x86/tests/strict-err.errwarn @@ -1,4 +1,4 @@ --:2: error: invalid size for operand 1 --:3: error: invalid size for operand 1 --:4: error: invalid size for operand 2 --:5: error: invalid size for operand 2 +-:2: invalid size for operand 1 +-:3: invalid size for operand 1 +-:4: invalid size for operand 2 +-:5: invalid size for operand 2 diff --git a/modules/arch/x86/tests/vmx-err.errwarn b/modules/arch/x86/tests/vmx-err.errwarn index 7db4b3cb..6faab0a7 100644 --- a/modules/arch/x86/tests/vmx-err.errwarn +++ b/modules/arch/x86/tests/vmx-err.errwarn @@ -1,2 +1,2 @@ --:6: error: invalid size for operand 2 --:7: error: invalid size for operand 1 +-:6: invalid size for operand 2 +-:7: invalid size for operand 1 diff --git a/modules/arch/x86/tests/vsib-err.asm b/modules/arch/x86/tests/vsib-err.asm deleted file mode 100644 index ee306038..00000000 --- a/modules/arch/x86/tests/vsib-err.asm +++ /dev/null @@ -1,14 +0,0 @@ -; Errors caught during instruction matching - -[bits 64] - -vpgatherdq xmm0,xmm0,xmm0 ; no reg EA template - -vpgatherdq xmm0,[ymm0],xmm0 ; not a VSIB256 template -vpgatherqq ymm0,[xmm0],ymm0 ; not a VSIB128 template - -vpgatherdq xmm0,[rel 0],xmm0 -vpgatherdq xmm0,[0],xmm0 -vpgatherdq xmm0,[rax],xmm0 -vpgatherdq xmm0,[rax+rbx],xmm0 - diff --git a/modules/arch/x86/tests/vsib-err.errwarn b/modules/arch/x86/tests/vsib-err.errwarn deleted file mode 100644 index 8d2d084f..00000000 --- a/modules/arch/x86/tests/vsib-err.errwarn +++ /dev/null @@ -1,7 +0,0 @@ --:5: error: invalid combination of opcode and operands --:7: error: invalid combination of opcode and operands --:8: error: invalid combination of opcode and operands --:10: error: invalid combination of opcode and operands --:11: error: invalid combination of opcode and operands --:12: error: invalid combination of opcode and operands --:13: error: invalid combination of opcode and operands diff --git a/modules/arch/x86/tests/vsib.asm b/modules/arch/x86/tests/vsib.asm deleted file mode 100644 index fc2a705b..00000000 --- a/modules/arch/x86/tests/vsib.asm +++ /dev/null @@ -1,114 +0,0 @@ -[bits 16] -; test promotion to 32-bit address size -vpgatherdq xmm0,[xmm0],xmm0 ; 67 c4 e2 f9 90 04 05 00 00 00 00 -vpgatherqq ymm0,[ymm0],ymm0 ; 67 c4 e2 fd 91 04 05 00 00 00 00 - -[bits 32] -; test promotion from base to index -vpgatherdq xmm0,[xmm0],xmm0 ; c4 e2 f9 90 04 05 00 00 00 00 -vpgatherqq ymm0,[ymm0],ymm0 ; c4 e2 fd 91 04 05 00 00 00 00 - -; various combinations -vpgatherdq xmm0,[ecx+xmm5],xmm0 ; c4 e2 f9 90 04 29 -vpgatherqq ymm0,[ecx+ymm5],ymm0 ; c4 e2 fd 91 04 29 -vpgatherdq xmm0,[ebp+xmm5],xmm0 ; c4 e2 f9 90 44 2d 00 -vpgatherqq ymm0,[ebp+ymm5],ymm0 ; c4 e2 fd 91 44 2d 00 - -vpgatherdq xmm0,[xmm5+ecx],xmm0 ; c4 e2 f9 90 04 29 -vpgatherqq ymm0,[ymm5+ecx],ymm0 ; c4 e2 fd 91 04 29 -vpgatherdq xmm0,[xmm5+ebp],xmm0 ; c4 e2 f9 90 44 2d 00 -vpgatherqq ymm0,[ymm5+ebp],ymm0 ; c4 e2 fd 91 44 2d 00 - -vpgatherdq xmm0,[ecx+xmm5*1],xmm0 ; c4 e2 f9 90 04 29 -vpgatherqq ymm0,[ecx+ymm5*1],ymm0 ; c4 e2 fd 91 04 29 -vpgatherdq xmm0,[ebp+xmm5*1],xmm0 ; c4 e2 f9 90 44 2d 00 -vpgatherqq ymm0,[ebp+ymm5*1],ymm0 ; c4 e2 fd 91 44 2d 00 - -vpgatherdq xmm0,[xmm5+ecx*1],xmm0 ; c4 e2 f9 90 04 29 -vpgatherqq ymm0,[ymm5+ecx*1],ymm0 ; c4 e2 fd 91 04 29 -vpgatherdq xmm0,[xmm5+ebp*1],xmm0 ; c4 e2 f9 90 44 2d 00 -vpgatherqq ymm0,[ymm5+ebp*1],ymm0 ; c4 e2 fd 91 44 2d 00 - -vpgatherdq xmm0,[nosplit 12345678h + xmm5*1],xmm0; c4 e2 f9 90 04 2d 78 56 34 12 -vpgatherqq ymm0,[nosplit 12345678h + ymm5*1],ymm0; c4 e2 fd 91 04 2d 78 56 34 12 - -vpgatherdq xmm0,[byte ecx + 12 + xmm5*2],xmm0 ; c4 e2 f9 90 44 69 0c -vpgatherqq ymm0,[byte ecx + 12 + ymm5*2],ymm0 ; c4 e2 fd 91 44 69 0c -vpgatherdq xmm0,[byte ebp + 12 + xmm5*2],xmm0 ; c4 e2 f9 90 44 6d 0c -vpgatherqq ymm0,[byte ebp + 12 + ymm5*2],ymm0 ; c4 e2 fd 91 44 6d 0c - -vpgatherdq xmm0,[dword ecx + 12 + xmm5*4],xmm0 ; c4 e2 f9 90 84 a9 0c 00 00 00 -vpgatherqq ymm0,[dword ecx + 12 + ymm5*4],ymm0 ; c4 e2 fd 91 84 a9 0c 00 00 00 -vpgatherdq xmm0,[dword ebp + 12 + xmm5*4],xmm0 ; c4 e2 f9 90 84 ad 0c 00 00 00 -vpgatherqq ymm0,[dword ebp + 12 + ymm5*4],ymm0 ; c4 e2 fd 91 84 ad 0c 00 00 00 - -vpgatherdq xmm0,[ecx + 12345678h + xmm5*4],xmm0 ; c4 e2 f9 90 84 a9 78 56 34 12 -vpgatherqq ymm0,[ecx + 12345678h + ymm5*4],ymm0 ; c4 e2 fd 91 84 a9 78 56 34 12 -vpgatherdq xmm0,[ebp + 12345678h + xmm5*4],xmm0 ; c4 e2 f9 90 84 ad 78 56 34 12 -vpgatherqq ymm0,[ebp + 12345678h + ymm5*4],ymm0 ; c4 e2 fd 91 84 ad 78 56 34 12 - -vpgatherdq xmm0,[ecx + 12 + xmm5*4],xmm0 ; c4 e2 f9 90 44 a9 0c -vpgatherqq ymm0,[ecx + 12 + ymm5*4],ymm0 ; c4 e2 fd 91 44 a9 0c -vpgatherdq xmm0,[ebp + 12 + xmm5*4],xmm0 ; c4 e2 f9 90 44 ad 0c -vpgatherqq ymm0,[ebp + 12 + ymm5*4],ymm0 ; c4 e2 fd 91 44 ad 0c - -vpgatherdq xmm0,[dword 12 + xmm5*8],xmm0 ; c4 e2 f9 90 04 ed 0c 00 00 00 -vpgatherqq ymm0,[dword 12 + ymm5*8],ymm0 ; c4 e2 fd 91 04 ed 0c 00 00 00 -vpgatherdq xmm0,[12 + xmm5*8],xmm0 ; c4 e2 f9 90 04 ed 0c 00 00 00 -vpgatherqq ymm0,[12 + ymm5*8],ymm0 ; c4 e2 fd 91 04 ed 0c 00 00 00 - -[bits 64] -; test promotion from base to index -vpgatherdq xmm0,[xmm0],xmm0 ; c4 e2 f9 90 04 05 00 00 00 00 -vpgatherqq ymm0,[ymm0],ymm0 ; c4 e2 fd 91 04 05 00 00 00 00 - -; various combinations -vpgatherdq xmm0,[rcx+xmm5],xmm0 ; c4 e2 f9 90 04 29 -vpgatherqq ymm0,[rcx+ymm13],ymm0 ; c4 a2 fd 91 04 29 -vpgatherdq xmm0,[r13+xmm13],xmm0 ; c4 82 f9 90 44 2d 00 -vpgatherqq ymm0,[r13+ymm5],ymm0 ; c4 c2 fd 91 44 2d 00 - -vpgatherdq xmm0,[xmm5+rcx],xmm0 ; c4 e2 f9 90 04 29 -vpgatherqq ymm0,[ymm13+rcx],ymm0 ; c4 a2 fd 91 04 29 -vpgatherdq xmm0,[xmm13+r13],xmm0 ; c4 82 f9 90 44 2d 00 -vpgatherqq ymm0,[ymm5+r13],ymm0 ; c4 c2 fd 91 44 2d 00 - -vpgatherdq xmm0,[rcx+xmm5*1],xmm0 ; c4 e2 f9 90 04 29 -vpgatherqq ymm0,[rcx+ymm13*1],ymm0 ; c4 a2 fd 91 04 29 -vpgatherdq xmm0,[r13+xmm13*1],xmm0 ; c4 82 f9 90 44 2d 00 -vpgatherqq ymm0,[r13+ymm5*1],ymm0 ; c4 c2 fd 91 44 2d 00 - -vpgatherdq xmm0,[xmm5+rcx*1],xmm0 ; c4 e2 f9 90 04 29 -vpgatherqq ymm0,[ymm13+rcx*1],ymm0 ; c4 a2 fd 91 04 29 -vpgatherdq xmm0,[xmm13+r13*1],xmm0 ; c4 82 f9 90 44 2d 00 -vpgatherqq ymm0,[ymm5+r13*1],ymm0 ; c4 c2 fd 91 44 2d 00 - -vpgatherdq xmm0,[nosplit 12345678h + xmm5*1],xmm0; c4 e2 f9 90 04 2d 78 56 34 12 -vpgatherqq ymm0,[nosplit 12345678h + ymm5*1],ymm0; c4 e2 fd 91 04 2d 78 56 34 12 - -vpgatherdq xmm0,[byte rcx + 12 + xmm5*2],xmm0 ; c4 e2 f9 90 44 69 0c -vpgatherqq ymm0,[byte rcx + 12 + ymm13*2],ymm0 ; c4 a2 fd 91 44 69 0c -vpgatherdq xmm0,[byte r13 + 12 + xmm13*2],xmm0 ; c4 82 f9 90 44 6d 0c -vpgatherqq ymm0,[byte r13 + 12 + ymm5*2],ymm0 ; c4 c2 fd 91 44 6d 0c - -vpgatherdq xmm0,[dword rcx + 12 + xmm5*4],xmm0 ; c4 e2 f9 90 84 a9 0c 00 00 00 -vpgatherqq ymm0,[dword rcx + 12 + ymm13*4],ymm0 ; c4 a2 fd 91 84 a9 0c 00 00 00 -vpgatherdq xmm0,[dword r13 + 12 + xmm13*4],xmm0 ; c4 82 f9 90 84 ad 0c 00 00 00 -vpgatherqq ymm0,[dword r13 + 12 + ymm5*4],ymm0 ; c4 c2 fd 91 84 ad 0c 00 00 00 - -vpgatherdq xmm0,[rcx + 12345678h + xmm5*4],xmm0 ; c4 e2 f9 90 84 a9 78 56 34 12 -vpgatherqq ymm0,[rcx + 12345678h + ymm13*4],ymm0; c4 a2 fd 91 84 a9 78 56 34 12 -vpgatherdq xmm0,[r13 + 12345678h + xmm13*4],xmm0; c4 82 f9 90 84 ad 78 56 34 12 -vpgatherqq ymm0,[r13 + 12345678h + ymm5*4],ymm0 ; c4 c2 fd 91 84 ad 78 56 34 12 - -vpgatherdq xmm0,[rcx + 12 + xmm5*4],xmm0 ; c4 e2 f9 90 44 a9 0c -vpgatherqq ymm0,[rcx + 12 + ymm13*4],ymm0 ; c4 a2 fd 91 44 a9 0c -vpgatherdq xmm0,[r13 + 12 + xmm13*4],xmm0 ; c4 82 f9 90 44 ad 0c -vpgatherqq ymm0,[r13 + 12 + ymm5*4],ymm0 ; c4 c2 fd 91 44 ad 0c - -vpgatherdq xmm0,[dword 12 + xmm5*8],xmm0 ; c4 e2 f9 90 04 ed 0c 00 00 00 -vpgatherqq ymm0,[dword 12 + ymm13*8],ymm0 ; c4 a2 fd 91 04 ed 0c 00 00 00 -vpgatherdq xmm0,[12 + xmm13*8],xmm0 ; c4 a2 f9 90 04 ed 0c 00 00 00 -vpgatherqq ymm0,[12 + ymm5*8],ymm0 ; c4 e2 fd 91 04 ed 0c 00 00 00 - - diff --git a/modules/arch/x86/tests/vsib.hex b/modules/arch/x86/tests/vsib.hex deleted file mode 100644 index 7dfde886..00000000 --- a/modules/arch/x86/tests/vsib.hex +++ /dev/null @@ -1,662 +0,0 @@ -67 -c4 -e2 -f9 -90 -04 -05 -00 -00 -00 -00 -67 -c4 -e2 -fd -91 -04 -05 -00 -00 -00 -00 -c4 -e2 -f9 -90 -04 -05 -00 -00 -00 -00 -c4 -e2 -fd -91 -04 -05 -00 -00 -00 -00 -c4 -e2 -f9 -90 -04 -29 -c4 -e2 -fd -91 -04 -29 -c4 -e2 -f9 -90 -44 -2d -00 -c4 -e2 -fd -91 -44 -2d -00 -c4 -e2 -f9 -90 -04 -29 -c4 -e2 -fd -91 -04 -29 -c4 -e2 -f9 -90 -44 -2d -00 -c4 -e2 -fd -91 -44 -2d -00 -c4 -e2 -f9 -90 -04 -29 -c4 -e2 -fd -91 -04 -29 -c4 -e2 -f9 -90 -44 -2d -00 -c4 -e2 -fd -91 -44 -2d -00 -c4 -e2 -f9 -90 -04 -29 -c4 -e2 -fd -91 -04 -29 -c4 -e2 -f9 -90 -44 -2d -00 -c4 -e2 -fd -91 -44 -2d -00 -c4 -e2 -f9 -90 -04 -2d -78 -56 -34 -12 -c4 -e2 -fd -91 -04 -2d -78 -56 -34 -12 -c4 -e2 -f9 -90 -44 -69 -0c -c4 -e2 -fd -91 -44 -69 -0c -c4 -e2 -f9 -90 -44 -6d -0c -c4 -e2 -fd -91 -44 -6d -0c -c4 -e2 -f9 -90 -84 -a9 -0c -00 -00 -00 -c4 -e2 -fd -91 -84 -a9 -0c -00 -00 -00 -c4 -e2 -f9 -90 -84 -ad -0c -00 -00 -00 -c4 -e2 -fd -91 -84 -ad -0c -00 -00 -00 -c4 -e2 -f9 -90 -84 -a9 -78 -56 -34 -12 -c4 -e2 -fd -91 -84 -a9 -78 -56 -34 -12 -c4 -e2 -f9 -90 -84 -ad -78 -56 -34 -12 -c4 -e2 -fd -91 -84 -ad -78 -56 -34 -12 -c4 -e2 -f9 -90 -44 -a9 -0c -c4 -e2 -fd -91 -44 -a9 -0c -c4 -e2 -f9 -90 -44 -ad -0c -c4 -e2 -fd -91 -44 -ad -0c -c4 -e2 -f9 -90 -04 -ed -0c -00 -00 -00 -c4 -e2 -fd -91 -04 -ed -0c -00 -00 -00 -c4 -e2 -f9 -90 -04 -ed -0c -00 -00 -00 -c4 -e2 -fd -91 -04 -ed -0c -00 -00 -00 -c4 -e2 -f9 -90 -04 -05 -00 -00 -00 -00 -c4 -e2 -fd -91 -04 -05 -00 -00 -00 -00 -c4 -e2 -f9 -90 -04 -29 -c4 -a2 -fd -91 -04 -29 -c4 -82 -f9 -90 -44 -2d -00 -c4 -c2 -fd -91 -44 -2d -00 -c4 -e2 -f9 -90 -04 -29 -c4 -a2 -fd -91 -04 -29 -c4 -82 -f9 -90 -44 -2d -00 -c4 -c2 -fd -91 -44 -2d -00 -c4 -e2 -f9 -90 -04 -29 -c4 -a2 -fd -91 -04 -29 -c4 -82 -f9 -90 -44 -2d -00 -c4 -c2 -fd -91 -44 -2d -00 -c4 -e2 -f9 -90 -04 -29 -c4 -a2 -fd -91 -04 -29 -c4 -82 -f9 -90 -44 -2d -00 -c4 -c2 -fd -91 -44 -2d -00 -c4 -e2 -f9 -90 -04 -2d -78 -56 -34 -12 -c4 -e2 -fd -91 -04 -2d -78 -56 -34 -12 -c4 -e2 -f9 -90 -44 -69 -0c -c4 -a2 -fd -91 -44 -69 -0c -c4 -82 -f9 -90 -44 -6d -0c -c4 -c2 -fd -91 -44 -6d -0c -c4 -e2 -f9 -90 -84 -a9 -0c -00 -00 -00 -c4 -a2 -fd -91 -84 -a9 -0c -00 -00 -00 -c4 -82 -f9 -90 -84 -ad -0c -00 -00 -00 -c4 -c2 -fd -91 -84 -ad -0c -00 -00 -00 -c4 -e2 -f9 -90 -84 -a9 -78 -56 -34 -12 -c4 -a2 -fd -91 -84 -a9 -78 -56 -34 -12 -c4 -82 -f9 -90 -84 -ad -78 -56 -34 -12 -c4 -c2 -fd -91 -84 -ad -78 -56 -34 -12 -c4 -e2 -f9 -90 -44 -a9 -0c -c4 -a2 -fd -91 -44 -a9 -0c -c4 -82 -f9 -90 -44 -ad -0c -c4 -c2 -fd -91 -44 -ad -0c -c4 -e2 -f9 -90 -04 -ed -0c -00 -00 -00 -c4 -a2 -fd -91 -04 -ed -0c -00 -00 -00 -c4 -a2 -f9 -90 -04 -ed -0c -00 -00 -00 -c4 -e2 -fd -91 -04 -ed -0c -00 -00 -00 diff --git a/modules/arch/x86/tests/vsib2-err.asm b/modules/arch/x86/tests/vsib2-err.asm deleted file mode 100644 index 7e3ac55e..00000000 --- a/modules/arch/x86/tests/vsib2-err.asm +++ /dev/null @@ -1,19 +0,0 @@ -; Errors caught during EA checking - -[bits 32] -vpgatherqq ymm0,[ymm0+ecx*2],ymm0 - -[bits 64] -addpd xmm0,[xmm0] ; not a VSIB128 template -addpd xmm0,[ymm0] ; not a VSIB256 template - -[bits 32] -vpgatherdq xmm0,[bp+xmm0],xmm0 - -vpgatherdq xmm0,[xmm0+ymm0],xmm0 - -vpgatherqq ymm0,[word ymm0],ymm0 - -vpgatherqq ymm0,[byte ymm0],ymm0 - - diff --git a/modules/arch/x86/tests/vsib2-err.errwarn b/modules/arch/x86/tests/vsib2-err.errwarn deleted file mode 100644 index 877ce62e..00000000 --- a/modules/arch/x86/tests/vsib2-err.errwarn +++ /dev/null @@ -1,7 +0,0 @@ --:4: error: invalid effective address --:7: error: invalid effective address --:8: error: invalid effective address --:11: error: invalid effective address --:13: error: invalid effective address --:15: error: invalid effective address --:17: warning: invalid displacement size; fixed diff --git a/modules/arch/x86/tests/x86_test.sh b/modules/arch/x86/tests/x86_test.sh index 56aa2154..d2e6e373 100755 --- a/modules/arch/x86/tests/x86_test.sh +++ b/modules/arch/x86/tests/x86_test.sh @@ -1,3 +1,4 @@ #! /bin/sh -${srcdir}/out_test.sh x86_test modules/arch/x86/tests "x86 arch" "-f bin -Wsegreg-in-64bit" "" +# $Id$ +${srcdir}/out_test.sh x86_test modules/arch/x86/tests "x86 arch" "-f bin" "" exit $? diff --git a/modules/arch/x86/tests/xchg64.asm b/modules/arch/x86/tests/xchg64.asm index 794d4f1c..d6a13949 100644 --- a/modules/arch/x86/tests/xchg64.asm +++ b/modules/arch/x86/tests/xchg64.asm @@ -8,25 +8,3 @@ xchg ebx, eax xchg rax, rax xchg rax, rbx xchg rbx, rax - -xchg al, al -xchg al, r8b -xchg r8b, al - -xchg ax, ax -xchg ax, r8w -xchg r8w, ax -xchg ax, r9w -xchg r9w, ax - -xchg eax, eax -xchg eax, r8d -xchg r8d, eax -xchg eax, r9d -xchg r9d, eax - -xchg rax, rax -xchg rax, r8 -xchg r8, rax -xchg rax, r9 -xchg r9, rax diff --git a/modules/arch/x86/tests/xchg64.hex b/modules/arch/x86/tests/xchg64.hex index 44adfca8..f7149e3d 100644 --- a/modules/arch/x86/tests/xchg64.hex +++ b/modules/arch/x86/tests/xchg64.hex @@ -13,44 +13,3 @@ c0 93 48 93 -86 -c0 -44 -86 -c0 -41 -86 -c0 -66 -90 -66 -41 -90 -66 -41 -90 -66 -41 -91 -66 -41 -91 -87 -c0 -41 -90 -41 -90 -41 -91 -41 -91 -90 -49 -90 -49 -90 -49 -91 -49 -91 diff --git a/modules/arch/x86/tests/xop-all.asm b/modules/arch/x86/tests/xop-all.asm deleted file mode 100644 index db5dabf0..00000000 --- a/modules/arch/x86/tests/xop-all.asm +++ /dev/null @@ -1,266 +0,0 @@ -; Instructions are ordered in XOP databook order -; BITS=16 to minimize output length -[bits 16] -vfrczpd xmm1, xmm2 ; 8F E9 78 81 312 -vfrczpd xmm1, [0] ; 8F E9 78 81 016 00 00 -vfrczpd xmm1, dqword [0] ; 8F E9 78 81 016 00 00 -vfrczpd ymm1, ymm2 ; 8F E9 7C 81 312 -vfrczpd ymm1, [0] ; 8F E9 7C 81 016 00 00 -vfrczpd ymm1, yword [0] ; 8F E9 7C 81 016 00 00 - -vfrczps xmm1, xmm2 ; 8F E9 78 80 312 -vfrczps xmm1, [0] ; 8F E9 78 80 016 00 00 -vfrczps xmm1, dqword [0] ; 8F E9 78 80 016 00 00 -vfrczps ymm1, ymm2 ; 8F E9 7C 80 312 -vfrczps ymm1, [0] ; 8F E9 7C 80 016 00 00 -vfrczps ymm1, yword [0] ; 8F E9 7C 80 016 00 00 - -vfrczsd xmm1, xmm2 ; 8F E9 78 83 312 -vfrczsd xmm1, [0] ; 8F E9 78 83 016 00 00 -vfrczsd xmm1, qword [0] ; 8F E9 78 83 016 00 00 - -vfrczss xmm1, xmm2 ; 8F E9 78 82 312 -vfrczss xmm1, [0] ; 8F E9 78 82 016 00 00 -vfrczss xmm1, dword [0] ; 8F E9 78 82 016 00 00 - -vpcmov xmm1, xmm2, xmm3, xmm4 ; 8F E8 68 A2 313 40 /or/ 8F E8 E8 A2 314 30 -vpcmov xmm1, xmm2, xmm3, [0] ; 8F E8 E8 A2 016 00 00 30 -vpcmov xmm1, xmm2, xmm3, dqword [0] ; 8F E8 E8 A2 016 00 00 30 -vpcmov xmm1, xmm2, [0], xmm4 ; 8F E8 68 A2 016 00 00 40 -vpcmov xmm1, xmm2, dqword [0], xmm4 ; 8F E8 68 A2 016 00 00 40 -vpcmov ymm1, ymm2, ymm3, ymm4 ; 8F E8 6C A2 313 40 /or/ 8F E8 EC A2 314 30 -vpcmov ymm1, ymm2, ymm3, [0] ; 8F E8 EC A2 016 00 00 30 -vpcmov ymm1, ymm2, ymm3, yword [0] ; 8F E8 EC A2 016 00 00 30 -vpcmov ymm1, ymm2, [0], ymm4 ; 8F E8 6C A2 016 00 00 40 -vpcmov ymm1, ymm2, yword [0], ymm4 ; 8F E8 6C A2 016 00 00 40 - -vpcomb xmm1, xmm4, xmm7, 5 ; 8F E8 58 CC 317 05 -vpcomb xmm2, xmm5, [0], byte 5 ; 8F E8 50 CC 026 00 00 05 -vpcomb xmm3, xmm6, dqword [0], 5 ; 8F E8 48 CC 036 00 00 05 - -vpcomd xmm1, xmm4, xmm7, 5 ; 8F E8 58 CE 317 05 -vpcomd xmm2, xmm5, [0], byte 5 ; 8F E8 50 CE 026 00 00 05 -vpcomd xmm3, xmm6, dqword [0], 5 ; 8F E8 48 CE 036 00 00 05 - -vpcomq xmm1, xmm4, xmm7, 5 ; 8F E8 58 CF 317 05 -vpcomq xmm2, xmm5, [0], byte 5 ; 8F E8 50 CF 026 00 00 05 -vpcomq xmm3, xmm6, dqword [0], 5 ; 8F E8 48 CF 036 00 00 05 - -vpcomub xmm1, xmm4, xmm7, 5 ; 8F E8 58 EC 317 05 -vpcomub xmm2, xmm5, [0], byte 5 ; 8F E8 50 EC 026 00 00 05 -vpcomub xmm3, xmm6, dqword [0], 5 ; 8F E8 48 EC 036 00 00 05 - -vpcomud xmm1, xmm4, xmm7, 5 ; 8F E8 58 EE 317 05 -vpcomud xmm2, xmm5, [0], byte 5 ; 8F E8 50 EE 026 00 00 05 -vpcomud xmm3, xmm6, dqword [0], 5 ; 8F E8 48 EE 036 00 00 05 - -vpcomuq xmm1, xmm4, xmm7, 5 ; 8F E8 58 EF 317 05 -vpcomuq xmm2, xmm5, [0], byte 5 ; 8F E8 50 EF 026 00 00 05 -vpcomuq xmm3, xmm6, dqword [0], 5 ; 8F E8 48 EF 036 00 00 05 - -vpcomuw xmm1, xmm4, xmm7, 5 ; 8F E8 58 ED 317 05 -vpcomuw xmm2, xmm5, [0], byte 5 ; 8F E8 50 ED 026 00 00 05 -vpcomuw xmm3, xmm6, dqword [0], 5 ; 8F E8 48 ED 036 00 00 05 - -vpcomw xmm1, xmm4, xmm7, 5 ; 8F E8 58 CD 317 05 -vpcomw xmm2, xmm5, [0], byte 5 ; 8F E8 50 CD 026 00 00 05 -vpcomw xmm3, xmm6, dqword [0], 5 ; 8F E8 48 CD 036 00 00 05 - -vphaddbd xmm1, xmm2 ; 8F E9 78 C2 312 -vphaddbd xmm1, [0] ; 8F E9 78 C2 016 00 00 -vphaddbd xmm1, dqword [0] ; 8F E9 78 C2 016 00 00 - -vphaddbq xmm1, xmm2 ; 8F E9 78 C3 312 -vphaddbq xmm1, [0] ; 8F E9 78 C3 016 00 00 -vphaddbq xmm1, dqword [0] ; 8F E9 78 C3 016 00 00 - -vphaddbw xmm1, xmm2 ; 8F E9 78 C1 312 -vphaddbw xmm1, [0] ; 8F E9 78 C1 016 00 00 -vphaddbw xmm1, dqword [0] ; 8F E9 78 C1 016 00 00 - -vphadddq xmm1, xmm2 ; 8F E9 78 CB 312 -vphadddq xmm1, [0] ; 8F E9 78 CB 016 00 00 -vphadddq xmm1, dqword [0] ; 8F E9 78 CB 016 00 00 - -vphaddubd xmm1, xmm2 ; 8F E9 78 D2 312 -vphaddubd xmm1, [0] ; 8F E9 78 D2 016 00 00 -vphaddubd xmm1, dqword [0] ; 8F E9 78 D2 016 00 00 - -vphaddubq xmm1, xmm2 ; 8F E9 78 D3 312 -vphaddubq xmm1, [0] ; 8F E9 78 D3 016 00 00 -vphaddubq xmm1, dqword [0] ; 8F E9 78 D3 016 00 00 - -vphaddubw xmm1, xmm2 ; 8F E9 78 D1 312 -vphaddubw xmm1, [0] ; 8F E9 78 D1 016 00 00 -vphaddubw xmm1, dqword [0] ; 8F E9 78 D1 016 00 00 - -vphaddudq xmm1, xmm2 ; 8F E9 78 DB 312 -vphaddudq xmm1, [0] ; 8F E9 78 DB 016 00 00 -vphaddudq xmm1, dqword [0] ; 8F E9 78 DB 016 00 00 - -vphadduwd xmm1, xmm2 ; 8F E9 78 D6 312 -vphadduwd xmm1, [0] ; 8F E9 78 D6 016 00 00 -vphadduwd xmm1, dqword [0] ; 8F E9 78 D6 016 00 00 - -vphadduwq xmm1, xmm2 ; 8F E9 78 D7 312 -vphadduwq xmm1, [0] ; 8F E9 78 D7 016 00 00 -vphadduwq xmm1, dqword [0] ; 8F E9 78 D7 016 00 00 - -vphaddwd xmm1, xmm2 ; 8F E9 78 C6 312 -vphaddwd xmm1, [0] ; 8F E9 78 C6 016 00 00 -vphaddwd xmm1, dqword [0] ; 8F E9 78 C6 016 00 00 - -vphaddwq xmm1, xmm2 ; 8F E9 78 C7 312 -vphaddwq xmm1, [0] ; 8F E9 78 C7 016 00 00 -vphaddwq xmm1, dqword [0] ; 8F E9 78 C7 016 00 00 - -vphsubbw xmm1, xmm2 ; 8F E9 78 E1 312 -vphsubbw xmm1, [0] ; 8F E9 78 E1 016 00 00 -vphsubbw xmm1, dqword [0] ; 8F E9 78 E1 016 00 00 - -vphsubdq xmm1, xmm2 ; 8F E9 78 E3 312 -vphsubdq xmm1, [0] ; 8F E9 78 E3 016 00 00 -vphsubdq xmm1, dqword [0] ; 8F E9 78 E3 016 00 00 - -vphsubwd xmm1, xmm2 ; 8F E9 78 E2 312 -vphsubwd xmm1, [0] ; 8F E9 78 E2 016 00 00 -vphsubwd xmm1, dqword [0] ; 8F E9 78 E2 016 00 00 - -vpmacsdd xmm1, xmm4, xmm7, xmm3 ; 8F E8 58 9E 317 30 -vpmacsdd xmm2, xmm5, [0], xmm0 ; 8F E8 50 9E 026 00 00 00 -vpmacsdd xmm3, xmm6, dqword [0], xmm2 ; 8F E8 48 9E 036 00 00 20 - -vpmacsdqh xmm1, xmm4, xmm7, xmm3 ; 8F E8 58 9F 317 30 -vpmacsdqh xmm2, xmm5, [0], xmm0 ; 8F E8 50 9F 026 00 00 00 -vpmacsdqh xmm3, xmm6, dqword [0], xmm2 ; 8F E8 48 9F 036 00 00 20 - -vpmacsdql xmm1, xmm4, xmm7, xmm3 ; 8F E8 58 97 317 30 -vpmacsdql xmm2, xmm5, [0], xmm0 ; 8F E8 50 97 026 00 00 00 -vpmacsdql xmm3, xmm6, dqword [0], xmm2 ; 8F E8 48 97 036 00 00 20 - -vpmacssdd xmm1, xmm4, xmm7, xmm3 ; 8F E8 58 8E 317 30 -vpmacssdd xmm2, xmm5, [0], xmm0 ; 8F E8 50 8E 026 00 00 00 -vpmacssdd xmm3, xmm6, dqword [0], xmm2 ; 8F E8 48 8E 036 00 00 20 - -vpmacssdqh xmm1, xmm4, xmm7, xmm3 ; 8F E8 58 8F 317 30 -vpmacssdqh xmm2, xmm5, [0], xmm0 ; 8F E8 50 8F 026 00 00 00 -vpmacssdqh xmm3, xmm6, dqword [0], xmm2 ; 8F E8 48 8F 036 00 00 20 - -vpmacssdql xmm1, xmm4, xmm7, xmm3 ; 8F E8 58 87 317 30 -vpmacssdql xmm2, xmm5, [0], xmm0 ; 8F E8 50 87 026 00 00 00 -vpmacssdql xmm3, xmm6, dqword [0], xmm2 ; 8F E8 48 87 036 00 00 20 - -vpmacsswd xmm1, xmm4, xmm7, xmm3 ; 8F E8 58 86 317 30 -vpmacsswd xmm2, xmm5, [0], xmm0 ; 8F E8 50 86 026 00 00 00 -vpmacsswd xmm3, xmm6, dqword [0], xmm2 ; 8F E8 48 86 036 00 00 20 - -vpmacssww xmm1, xmm4, xmm7, xmm3 ; 8F E8 58 85 317 30 -vpmacssww xmm2, xmm5, [0], xmm0 ; 8F E8 50 85 026 00 00 00 -vpmacssww xmm3, xmm6, dqword [0], xmm2 ; 8F E8 48 85 036 00 00 20 - -vpmacswd xmm1, xmm4, xmm7, xmm3 ; 8F E8 58 96 317 30 -vpmacswd xmm2, xmm5, [0], xmm0 ; 8F E8 50 96 026 00 00 00 -vpmacswd xmm3, xmm6, dqword [0], xmm2 ; 8F E8 48 96 036 00 00 20 - -vpmacsww xmm1, xmm4, xmm7, xmm3 ; 8F E8 58 95 317 30 -vpmacsww xmm2, xmm5, [0], xmm0 ; 8F E8 50 95 026 00 00 00 -vpmacsww xmm3, xmm6, dqword [0], xmm2 ; 8F E8 48 95 036 00 00 20 - -vpmadcsswd xmm1, xmm4, xmm7, xmm3 ; 8F E8 58 A6 317 30 -vpmadcsswd xmm2, xmm5, [0], xmm0 ; 8F E8 50 A6 026 00 00 00 -vpmadcsswd xmm3, xmm6, dqword [0], xmm2 ; 8F E8 48 A6 036 00 00 20 - -vpmadcswd xmm1, xmm4, xmm7, xmm3 ; 8F E8 58 B6 317 30 -vpmadcswd xmm2, xmm5, [0], xmm0 ; 8F E8 50 B6 026 00 00 00 -vpmadcswd xmm3, xmm6, dqword [0], xmm2 ; 8F E8 48 B6 036 00 00 20 - -vpperm xmm1, xmm2, xmm3, xmm4 ; 8F E8 68 A3 313 40 /or/ 8F E8 E8 A3 314 30 -vpperm xmm1, xmm2, xmm3, [0] ; 8F E8 E8 A3 016 00 00 30 -vpperm xmm1, xmm2, xmm3, dqword [0] ; 8F E8 E8 A3 016 00 00 30 -vpperm xmm1, xmm2, [0], xmm4 ; 8F E8 68 A3 016 00 00 40 -vpperm xmm1, xmm2, dqword [0], xmm4 ; 8F E8 68 A3 016 00 00 40 - -vprotb xmm1, xmm2, xmm3 ; 8F E9 60 90 312 /or/ 8F E9 E8 90 313 -vprotb xmm1, xmm2, [0] ; 8F E9 E8 90 016 00 00 -vprotb xmm1, xmm2, dqword [0] ; 8F E9 E8 90 016 00 00 -vprotb xmm1, [0], xmm3 ; 8F E9 60 90 016 00 00 -vprotb xmm1, dqword [0], xmm3 ; 8F E9 60 90 016 00 00 -vprotb xmm1, xmm2, byte 5 ; 8F E8 78 C0 312 05 -vprotb xmm1, [0], byte 5 ; 8F E8 78 C0 016 00 00 05 -vprotb xmm1, dqword [0], 5 ; 8F E8 78 C0 016 00 00 05 - -vprotd xmm1, xmm2, xmm3 ; 8F E9 60 92 312 /or/ 8F E9 E8 92 313 -vprotd xmm1, xmm2, [0] ; 8F E9 E8 92 016 00 00 -vprotd xmm1, xmm2, dqword [0] ; 8F E9 E8 92 016 00 00 -vprotd xmm1, [0], xmm3 ; 8F E9 60 92 016 00 00 -vprotd xmm1, dqword [0], xmm3 ; 8F E9 60 92 016 00 00 -vprotd xmm1, xmm2, byte 5 ; 8F E8 78 C2 312 05 -vprotd xmm1, [0], byte 5 ; 8F E8 78 C2 016 00 00 05 -vprotd xmm1, dqword [0], 5 ; 8F E8 78 C2 016 00 00 05 - -vprotq xmm1, xmm2, xmm3 ; 8F E9 60 93 312 /or/ 8F E9 E8 93 313 -vprotq xmm1, xmm2, [0] ; 8F E9 E8 93 016 00 00 -vprotq xmm1, xmm2, dqword [0] ; 8F E9 E8 93 016 00 00 -vprotq xmm1, [0], xmm3 ; 8F E9 60 93 016 00 00 -vprotq xmm1, dqword [0], xmm3 ; 8F E9 60 93 016 00 00 -vprotq xmm1, xmm2, byte 5 ; 8F E8 78 C3 312 05 -vprotq xmm1, [0], byte 5 ; 8F E8 78 C3 016 00 00 05 -vprotq xmm1, dqword [0], 5 ; 8F E8 78 C3 016 00 00 05 - -vprotw xmm1, xmm2, xmm3 ; 8F E9 60 91 312 /or/ 8F E9 E8 91 313 -vprotw xmm1, xmm2, [0] ; 8F E9 E8 91 016 00 00 -vprotw xmm1, xmm2, dqword [0] ; 8F E9 E8 91 016 00 00 -vprotw xmm1, [0], xmm3 ; 8F E9 60 91 016 00 00 -vprotw xmm1, dqword [0], xmm3 ; 8F E9 60 91 016 00 00 -vprotw xmm1, xmm2, byte 5 ; 8F E8 78 C1 312 05 -vprotw xmm1, [0], byte 5 ; 8F E8 78 C1 016 00 00 05 -vprotw xmm1, dqword [0], 5 ; 8F E8 78 C1 016 00 00 05 - -vpshab xmm1, xmm2, xmm3 ; 8F E9 60 98 312 /or/ 8F E9 E8 98 313 -vpshab xmm1, xmm2, [0] ; 8F E9 E8 98 016 00 00 -vpshab xmm1, xmm2, dqword [0] ; 8F E9 E8 98 016 00 00 -vpshab xmm1, [0], xmm3 ; 8F E9 60 98 016 00 00 -vpshab xmm1, dqword [0], xmm3 ; 8F E9 60 98 016 00 00 - -vpshad xmm1, xmm2, xmm3 ; 8F E9 60 9A 312 /or/ 8F E9 E8 9A 313 -vpshad xmm1, xmm2, [0] ; 8F E9 E8 9A 016 00 00 -vpshad xmm1, xmm2, dqword [0] ; 8F E9 E8 9A 016 00 00 -vpshad xmm1, [0], xmm3 ; 8F E9 60 9A 016 00 00 -vpshad xmm1, dqword [0], xmm3 ; 8F E9 60 9A 016 00 00 - -vpshaq xmm1, xmm2, xmm3 ; 8F E9 60 9B 312 /or/ 8F E9 E8 9B 313 -vpshaq xmm1, xmm2, [0] ; 8F E9 E8 9B 016 00 00 -vpshaq xmm1, xmm2, dqword [0] ; 8F E9 E8 9B 016 00 00 -vpshaq xmm1, [0], xmm3 ; 8F E9 60 9B 016 00 00 -vpshaq xmm1, dqword [0], xmm3 ; 8F E9 60 9B 016 00 00 - -vpshaw xmm1, xmm2, xmm3 ; 8F E9 60 99 312 /or/ 8F E9 E8 99 313 -vpshaw xmm1, xmm2, [0] ; 8F E9 E8 99 016 00 00 -vpshaw xmm1, xmm2, dqword [0] ; 8F E9 E8 99 016 00 00 -vpshaw xmm1, [0], xmm3 ; 8F E9 60 99 016 00 00 -vpshaw xmm1, dqword [0], xmm3 ; 8F E9 60 99 016 00 00 - -vpshlb xmm1, xmm2, xmm3 ; 8F E9 60 94 312 /or/ 8F E9 E8 94 313 -vpshlb xmm1, xmm2, [0] ; 8F E9 E8 94 016 00 00 -vpshlb xmm1, xmm2, dqword [0] ; 8F E9 E8 94 016 00 00 -vpshlb xmm1, [0], xmm3 ; 8F E9 60 94 016 00 00 -vpshlb xmm1, dqword [0], xmm3 ; 8F E9 60 94 016 00 00 - -vpshld xmm1, xmm2, xmm3 ; 8F E9 60 96 312 /or/ 8F E9 E8 96 313 -vpshld xmm1, xmm2, [0] ; 8F E9 E8 96 016 00 00 -vpshld xmm1, xmm2, dqword [0] ; 8F E9 E8 96 016 00 00 -vpshld xmm1, [0], xmm3 ; 8F E9 60 96 016 00 00 -vpshld xmm1, dqword [0], xmm3 ; 8F E9 60 96 016 00 00 - -vpshlq xmm1, xmm2, xmm3 ; 8F E9 60 97 312 /or/ 8F E9 E8 97 313 -vpshlq xmm1, xmm2, [0] ; 8F E9 E8 97 016 00 00 -vpshlq xmm1, xmm2, dqword [0] ; 8F E9 E8 97 016 00 00 -vpshlq xmm1, [0], xmm3 ; 8F E9 60 97 016 00 00 -vpshlq xmm1, dqword [0], xmm3 ; 8F E9 60 97 016 00 00 - -vpshlw xmm1, xmm2, xmm3 ; 8F E9 60 95 312 /or/ 8F E9 E8 95 313 -vpshlw xmm1, xmm2, [0] ; 8F E9 E8 95 016 00 00 -vpshlw xmm1, xmm2, dqword [0] ; 8F E9 E8 95 016 00 00 -vpshlw xmm1, [0], xmm3 ; 8F E9 60 95 016 00 00 -vpshlw xmm1, dqword [0], xmm3 ; 8F E9 60 95 016 00 00 - diff --git a/modules/arch/x86/tests/xop-all.hex b/modules/arch/x86/tests/xop-all.hex deleted file mode 100644 index ee9fd7fb..00000000 --- a/modules/arch/x86/tests/xop-all.hex +++ /dev/null @@ -1,1437 +0,0 @@ -8f -e9 -78 -81 -ca -8f -e9 -78 -81 -0e -00 -00 -8f -e9 -78 -81 -0e -00 -00 -8f -e9 -7c -81 -ca -8f -e9 -7c -81 -0e -00 -00 -8f -e9 -7c -81 -0e -00 -00 -8f -e9 -78 -80 -ca -8f -e9 -78 -80 -0e -00 -00 -8f -e9 -78 -80 -0e -00 -00 -8f -e9 -7c -80 -ca -8f -e9 -7c -80 -0e -00 -00 -8f -e9 -7c -80 -0e -00 -00 -8f -e9 -78 -83 -ca -8f -e9 -78 -83 -0e -00 -00 -8f -e9 -78 -83 -0e -00 -00 -8f -e9 -78 -82 -ca -8f -e9 -78 -82 -0e -00 -00 -8f -e9 -78 -82 -0e -00 -00 -8f -e8 -68 -a2 -cb -40 -8f -e8 -e8 -a2 -0e -00 -00 -30 -8f -e8 -e8 -a2 -0e -00 -00 -30 -8f -e8 -68 -a2 -0e -00 -00 -40 -8f -e8 -68 -a2 -0e -00 -00 -40 -8f -e8 -6c -a2 -cb -40 -8f -e8 -ec -a2 -0e -00 -00 -30 -8f -e8 -ec -a2 -0e -00 -00 -30 -8f -e8 -6c -a2 -0e -00 -00 -40 -8f -e8 -6c -a2 -0e -00 -00 -40 -8f -e8 -58 -cc -cf -05 -8f -e8 -50 -cc -16 -00 -00 -05 -8f -e8 -48 -cc -1e -00 -00 -05 -8f -e8 -58 -ce -cf -05 -8f -e8 -50 -ce -16 -00 -00 -05 -8f -e8 -48 -ce -1e -00 -00 -05 -8f -e8 -58 -cf -cf -05 -8f -e8 -50 -cf -16 -00 -00 -05 -8f -e8 -48 -cf -1e -00 -00 -05 -8f -e8 -58 -ec -cf -05 -8f -e8 -50 -ec -16 -00 -00 -05 -8f -e8 -48 -ec -1e -00 -00 -05 -8f -e8 -58 -ee -cf -05 -8f -e8 -50 -ee -16 -00 -00 -05 -8f -e8 -48 -ee -1e -00 -00 -05 -8f -e8 -58 -ef -cf -05 -8f -e8 -50 -ef -16 -00 -00 -05 -8f -e8 -48 -ef -1e -00 -00 -05 -8f -e8 -58 -ed -cf -05 -8f -e8 -50 -ed -16 -00 -00 -05 -8f -e8 -48 -ed -1e -00 -00 -05 -8f -e8 -58 -cd -cf -05 -8f -e8 -50 -cd -16 -00 -00 -05 -8f -e8 -48 -cd -1e -00 -00 -05 -8f -e9 -78 -c2 -ca -8f -e9 -78 -c2 -0e -00 -00 -8f -e9 -78 -c2 -0e -00 -00 -8f -e9 -78 -c3 -ca -8f -e9 -78 -c3 -0e -00 -00 -8f -e9 -78 -c3 -0e -00 -00 -8f -e9 -78 -c1 -ca -8f -e9 -78 -c1 -0e -00 -00 -8f -e9 -78 -c1 -0e -00 -00 -8f -e9 -78 -cb -ca -8f -e9 -78 -cb -0e -00 -00 -8f -e9 -78 -cb -0e -00 -00 -8f -e9 -78 -d2 -ca -8f -e9 -78 -d2 -0e -00 -00 -8f -e9 -78 -d2 -0e -00 -00 -8f -e9 -78 -d3 -ca -8f -e9 -78 -d3 -0e -00 -00 -8f -e9 -78 -d3 -0e -00 -00 -8f -e9 -78 -d1 -ca -8f -e9 -78 -d1 -0e -00 -00 -8f -e9 -78 -d1 -0e -00 -00 -8f -e9 -78 -db -ca -8f -e9 -78 -db -0e -00 -00 -8f -e9 -78 -db -0e -00 -00 -8f -e9 -78 -d6 -ca -8f -e9 -78 -d6 -0e -00 -00 -8f -e9 -78 -d6 -0e -00 -00 -8f -e9 -78 -d7 -ca -8f -e9 -78 -d7 -0e -00 -00 -8f -e9 -78 -d7 -0e -00 -00 -8f -e9 -78 -c6 -ca -8f -e9 -78 -c6 -0e -00 -00 -8f -e9 -78 -c6 -0e -00 -00 -8f -e9 -78 -c7 -ca -8f -e9 -78 -c7 -0e -00 -00 -8f -e9 -78 -c7 -0e -00 -00 -8f -e9 -78 -e1 -ca -8f -e9 -78 -e1 -0e -00 -00 -8f -e9 -78 -e1 -0e -00 -00 -8f -e9 -78 -e3 -ca -8f -e9 -78 -e3 -0e -00 -00 -8f -e9 -78 -e3 -0e -00 -00 -8f -e9 -78 -e2 -ca -8f -e9 -78 -e2 -0e -00 -00 -8f -e9 -78 -e2 -0e -00 -00 -8f -e8 -58 -9e -cf -30 -8f -e8 -50 -9e -16 -00 -00 -00 -8f -e8 -48 -9e -1e -00 -00 -20 -8f -e8 -58 -9f -cf -30 -8f -e8 -50 -9f -16 -00 -00 -00 -8f -e8 -48 -9f -1e -00 -00 -20 -8f -e8 -58 -97 -cf -30 -8f -e8 -50 -97 -16 -00 -00 -00 -8f -e8 -48 -97 -1e -00 -00 -20 -8f -e8 -58 -8e -cf -30 -8f -e8 -50 -8e -16 -00 -00 -00 -8f -e8 -48 -8e -1e -00 -00 -20 -8f -e8 -58 -8f -cf -30 -8f -e8 -50 -8f -16 -00 -00 -00 -8f -e8 -48 -8f -1e -00 -00 -20 -8f -e8 -58 -87 -cf -30 -8f -e8 -50 -87 -16 -00 -00 -00 -8f -e8 -48 -87 -1e -00 -00 -20 -8f -e8 -58 -86 -cf -30 -8f -e8 -50 -86 -16 -00 -00 -00 -8f -e8 -48 -86 -1e -00 -00 -20 -8f -e8 -58 -85 -cf -30 -8f -e8 -50 -85 -16 -00 -00 -00 -8f -e8 -48 -85 -1e -00 -00 -20 -8f -e8 -58 -96 -cf -30 -8f -e8 -50 -96 -16 -00 -00 -00 -8f -e8 -48 -96 -1e -00 -00 -20 -8f -e8 -58 -95 -cf -30 -8f -e8 -50 -95 -16 -00 -00 -00 -8f -e8 -48 -95 -1e -00 -00 -20 -8f -e8 -58 -a6 -cf -30 -8f -e8 -50 -a6 -16 -00 -00 -00 -8f -e8 -48 -a6 -1e -00 -00 -20 -8f -e8 -58 -b6 -cf -30 -8f -e8 -50 -b6 -16 -00 -00 -00 -8f -e8 -48 -b6 -1e -00 -00 -20 -8f -e8 -68 -a3 -cb -40 -8f -e8 -e8 -a3 -0e -00 -00 -30 -8f -e8 -e8 -a3 -0e -00 -00 -30 -8f -e8 -68 -a3 -0e -00 -00 -40 -8f -e8 -68 -a3 -0e -00 -00 -40 -8f -e9 -60 -90 -ca -8f -e9 -e8 -90 -0e -00 -00 -8f -e9 -e8 -90 -0e -00 -00 -8f -e9 -60 -90 -0e -00 -00 -8f -e9 -60 -90 -0e -00 -00 -8f -e8 -78 -c0 -ca -05 -8f -e8 -78 -c0 -0e -00 -00 -05 -8f -e8 -78 -c0 -0e -00 -00 -05 -8f -e9 -60 -92 -ca -8f -e9 -e8 -92 -0e -00 -00 -8f -e9 -e8 -92 -0e -00 -00 -8f -e9 -60 -92 -0e -00 -00 -8f -e9 -60 -92 -0e -00 -00 -8f -e8 -78 -c2 -ca -05 -8f -e8 -78 -c2 -0e -00 -00 -05 -8f -e8 -78 -c2 -0e -00 -00 -05 -8f -e9 -60 -93 -ca -8f -e9 -e8 -93 -0e -00 -00 -8f -e9 -e8 -93 -0e -00 -00 -8f -e9 -60 -93 -0e -00 -00 -8f -e9 -60 -93 -0e -00 -00 -8f -e8 -78 -c3 -ca -05 -8f -e8 -78 -c3 -0e -00 -00 -05 -8f -e8 -78 -c3 -0e -00 -00 -05 -8f -e9 -60 -91 -ca -8f -e9 -e8 -91 -0e -00 -00 -8f -e9 -e8 -91 -0e -00 -00 -8f -e9 -60 -91 -0e -00 -00 -8f -e9 -60 -91 -0e -00 -00 -8f -e8 -78 -c1 -ca -05 -8f -e8 -78 -c1 -0e -00 -00 -05 -8f -e8 -78 -c1 -0e -00 -00 -05 -8f -e9 -60 -98 -ca -8f -e9 -e8 -98 -0e -00 -00 -8f -e9 -e8 -98 -0e -00 -00 -8f -e9 -60 -98 -0e -00 -00 -8f -e9 -60 -98 -0e -00 -00 -8f -e9 -60 -9a -ca -8f -e9 -e8 -9a -0e -00 -00 -8f -e9 -e8 -9a -0e -00 -00 -8f -e9 -60 -9a -0e -00 -00 -8f -e9 -60 -9a -0e -00 -00 -8f -e9 -60 -9b -ca -8f -e9 -e8 -9b -0e -00 -00 -8f -e9 -e8 -9b -0e -00 -00 -8f -e9 -60 -9b -0e -00 -00 -8f -e9 -60 -9b -0e -00 -00 -8f -e9 -60 -99 -ca -8f -e9 -e8 -99 -0e -00 -00 -8f -e9 -e8 -99 -0e -00 -00 -8f -e9 -60 -99 -0e -00 -00 -8f -e9 -60 -99 -0e -00 -00 -8f -e9 -60 -94 -ca -8f -e9 -e8 -94 -0e -00 -00 -8f -e9 -e8 -94 -0e -00 -00 -8f -e9 -60 -94 -0e -00 -00 -8f -e9 -60 -94 -0e -00 -00 -8f -e9 -60 -96 -ca -8f -e9 -e8 -96 -0e -00 -00 -8f -e9 -e8 -96 -0e -00 -00 -8f -e9 -60 -96 -0e -00 -00 -8f -e9 -60 -96 -0e -00 -00 -8f -e9 -60 -97 -ca -8f -e9 -e8 -97 -0e -00 -00 -8f -e9 -e8 -97 -0e -00 -00 -8f -e9 -60 -97 -0e -00 -00 -8f -e9 -60 -97 -0e -00 -00 -8f -e9 -60 -95 -ca -8f -e9 -e8 -95 -0e -00 -00 -8f -e9 -e8 -95 -0e -00 -00 -8f -e9 -60 -95 -0e -00 -00 -8f -e9 -60 -95 -0e -00 -00 diff --git a/modules/arch/x86/tests/xop-basic.asm b/modules/arch/x86/tests/xop-basic.asm deleted file mode 100644 index 516b4bd2..00000000 --- a/modules/arch/x86/tests/xop-basic.asm +++ /dev/null @@ -1,8 +0,0 @@ -[bits 64] -vfrczpd ymm9, ymm10 ; 8F 49 7C 81 312 -vfrczpd ymm9, [0] ; 8F 69 7C 81 0C 25 00 00 00 00 -vfrczpd ymm9, yword [0] ; 8F 69 7C 81 0C 25 00 00 00 00 -vfrczpd ymm9, [r8*4] ; 8F 29 7C 81 0C 85 00 00 00 00 -vfrczpd ymm9, [r8*4+r9] ; 8F 09 7C 81 0C 81 - -vpcmov ymm10, ymm11, ymm12, ymm13 ; 8F 48 24 A2 324 D0 diff --git a/modules/arch/x86/tests/xop-basic.hex b/modules/arch/x86/tests/xop-basic.hex deleted file mode 100644 index 6be478a1..00000000 --- a/modules/arch/x86/tests/xop-basic.hex +++ /dev/null @@ -1,47 +0,0 @@ -8f -49 -7c -81 -ca -8f -69 -7c -81 -0c -25 -00 -00 -00 -00 -8f -69 -7c -81 -0c -25 -00 -00 -00 -00 -8f -29 -7c -81 -0c -85 -00 -00 -00 -00 -8f -09 -7c -81 -0c -81 -8f -48 -24 -a2 -d4 -d0 diff --git a/modules/arch/x86/tests/xop-cc.asm b/modules/arch/x86/tests/xop-cc.asm deleted file mode 100644 index 8b8bbe39..00000000 --- a/modules/arch/x86/tests/xop-cc.asm +++ /dev/null @@ -1,22 +0,0 @@ -[bits 16] -vpcomltb xmm1, xmm2, xmm3 ; 8F E8 68 CC 313 00 -vpcomleb xmm1, xmm2, xmm3 ; 8F E8 68 CC 313 01 -vpcomgtb xmm1, xmm2, xmm3 ; 8F E8 68 CC 313 02 -vpcomgeb xmm1, xmm2, xmm3 ; 8F E8 68 CC 313 03 -vpcomeqb xmm1, xmm2, xmm3 ; 8F E8 68 CC 313 04 -vpcomneqb xmm1, xmm2, xmm3 ; 8F E8 68 CC 313 05 -vpcomneb xmm1, xmm2, xmm3 ; 8F E8 68 CC 313 05 -vpcomfalseb xmm1, xmm2, xmm3 ; 8F E8 68 CC 313 06 -vpcomtrueb xmm1, xmm2, xmm3 ; 8F E8 68 CC 313 07 - -vpcomltuw xmm1, xmm2, xmm3 ; 8F E8 68 ED 313 00 -vpcomleuw xmm1, xmm2, xmm3 ; 8F E8 68 ED 313 01 -vpcomgtuw xmm1, xmm2, xmm3 ; 8F E8 68 ED 313 02 -vpcomgeuw xmm1, xmm2, xmm3 ; 8F E8 68 ED 313 03 -vpcomequw xmm1, xmm2, xmm3 ; 8F E8 68 ED 313 04 -vpcomnequw xmm1, xmm2, xmm3 ; 8F E8 68 ED 313 05 -vpcomneuw xmm1, xmm2, xmm3 ; 8F E8 68 ED 313 05 -vpcomfalseuw xmm1, xmm2, xmm3 ; 8F E8 68 ED 313 06 -vpcomtrueuw xmm1, xmm2, xmm3 ; 8F E8 68 ED 313 07 - - diff --git a/modules/arch/x86/tests/xop-cc.hex b/modules/arch/x86/tests/xop-cc.hex deleted file mode 100644 index 24300585..00000000 --- a/modules/arch/x86/tests/xop-cc.hex +++ /dev/null @@ -1,108 +0,0 @@ -8f -e8 -68 -cc -cb -00 -8f -e8 -68 -cc -cb -01 -8f -e8 -68 -cc -cb -02 -8f -e8 -68 -cc -cb -03 -8f -e8 -68 -cc -cb -04 -8f -e8 -68 -cc -cb -05 -8f -e8 -68 -cc -cb -05 -8f -e8 -68 -cc -cb -06 -8f -e8 -68 -cc -cb -07 -8f -e8 -68 -ed -cb -00 -8f -e8 -68 -ed -cb -01 -8f -e8 -68 -ed -cb -02 -8f -e8 -68 -ed -cb -03 -8f -e8 -68 -ed -cb -04 -8f -e8 -68 -ed -cb -05 -8f -e8 -68 -ed -cb -05 -8f -e8 -68 -ed -cb -06 -8f -e8 -68 -ed -cb -07 diff --git a/modules/arch/x86/tests/xsave.asm b/modules/arch/x86/tests/xsave.asm deleted file mode 100644 index 43f5f28d..00000000 --- a/modules/arch/x86/tests/xsave.asm +++ /dev/null @@ -1,8 +0,0 @@ -xsave [0] -xrstor [0] -xgetbv -xsetbv - -xsaveopt [0] -[bits 64] -xsaveopt64 [0] diff --git a/modules/arch/x86/tests/xsave.hex b/modules/arch/x86/tests/xsave.hex deleted file mode 100644 index 21e3a193..00000000 --- a/modules/arch/x86/tests/xsave.hex +++ /dev/null @@ -1,30 +0,0 @@ -0f -ae -26 -00 -00 -0f -ae -2e -00 -00 -0f -01 -d0 -0f -01 -d1 -0f -ae -36 -00 -00 -48 -0f -ae -34 -25 -00 -00 -00 -00 diff --git a/modules/arch/x86/x86arch.c b/modules/arch/x86/x86arch.c index bac11774..1f41503c 100644 --- a/modules/arch/x86/x86arch.c +++ b/modules/arch/x86/x86arch.c @@ -25,7 +25,9 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include +/*@unused@*/ RCSID("$Id$"); +#define YASM_LIB_INTERNAL #include #include "x86arch.h" @@ -36,58 +38,40 @@ yasm_arch_module yasm_x86_LTX_arch; static /*@only@*/ yasm_arch * x86_create(const char *machine, const char *parser, - /*@out@*/ yasm_arch_create_error *error) + /*@out@*/ yasm_arch_create_error *error) { yasm_arch_x86 *arch_x86; - unsigned int amd64_machine, address_size; + unsigned int amd64_machine; *error = YASM_ARCH_CREATE_OK; - if (yasm__strcasecmp(machine, "x86") == 0) { - amd64_machine = 0; - address_size = 32; - } else if (yasm__strcasecmp(machine, "amd64") == 0) { - amd64_machine = 1; - address_size = 64; - } else if (yasm__strcasecmp(machine, "x32") == 0) { - amd64_machine = 1; - address_size = 32; - } + if (yasm__strcasecmp(machine, "x86") == 0) + amd64_machine = 0; + else if (yasm__strcasecmp(machine, "amd64") == 0) + amd64_machine = 1; else { - *error = YASM_ARCH_CREATE_BAD_MACHINE; - return NULL; + *error = YASM_ARCH_CREATE_BAD_MACHINE; + return NULL; } arch_x86 = yasm_xmalloc(sizeof(yasm_arch_x86)); arch_x86->arch.module = &yasm_x86_LTX_arch; - /* default to all instructions/features enabled */ - arch_x86->active_cpu = 0; - arch_x86->cpu_enables_size = 1; - arch_x86->cpu_enables = yasm_xmalloc(sizeof(wordptr)); - arch_x86->cpu_enables[0] = BitVector_Create(64, FALSE); - BitVector_Fill(arch_x86->cpu_enables[0]); - + arch_x86->cpu_enabled = ~CPU_Any; arch_x86->amd64_machine = amd64_machine; arch_x86->mode_bits = 0; - arch_x86->address_size = address_size; arch_x86->force_strict = 0; - arch_x86->default_rel = 0; - arch_x86->gas_intel_mode = 0; - arch_x86->nop = X86_NOP_BASIC; if (yasm__strcasecmp(parser, "nasm") == 0) - arch_x86->parser = X86_PARSER_NASM; - else if (yasm__strcasecmp(parser, "tasm") == 0) - arch_x86->parser = X86_PARSER_TASM; + arch_x86->parser = X86_PARSER_NASM; else if (yasm__strcasecmp(parser, "gas") == 0 - || yasm__strcasecmp(parser, "gnu") == 0) - arch_x86->parser = X86_PARSER_GAS; + || yasm__strcasecmp(parser, "gnu") == 0) + arch_x86->parser = X86_PARSER_GAS; else { - yasm_xfree(arch_x86); - *error = YASM_ARCH_CREATE_BAD_PARSER; - return NULL; + yasm_xfree(arch_x86); + *error = YASM_ARCH_CREATE_BAD_PARSER; + return NULL; } return (yasm_arch *)arch_x86; @@ -96,11 +80,6 @@ x86_create(const char *machine, const char *parser, static void x86_destroy(/*@only@*/ yasm_arch *arch) { - yasm_arch_x86 *arch_x86 = (yasm_arch_x86 *)arch; - unsigned int i; - for (i=0; icpu_enables_size; i++) - BitVector_Destroy(arch_x86->cpu_enables[i]); - yasm_xfree(arch_x86->cpu_enables); yasm_xfree(arch); } @@ -108,13 +87,10 @@ static const char * x86_get_machine(const yasm_arch *arch) { const yasm_arch_x86 *arch_x86 = (const yasm_arch_x86 *)arch; - if (arch_x86->amd64_machine) { - if (arch_x86->address_size == 32) - return "x32"; - else - return "amd64"; - } else - return "x86"; + if (arch_x86->amd64_machine) + return "amd64"; + else + return "x86"; } static unsigned int @@ -122,8 +98,11 @@ x86_get_address_size(const yasm_arch *arch) { const yasm_arch_x86 *arch_x86 = (const yasm_arch_x86 *)arch; if (arch_x86->mode_bits != 0) - return arch_x86->mode_bits; - return arch_x86->address_size; + return arch_x86->mode_bits; + if (arch_x86->amd64_machine) + return 64; + else + return 32; } static int @@ -131,25 +110,17 @@ x86_set_var(yasm_arch *arch, const char *var, unsigned long val) { yasm_arch_x86 *arch_x86 = (yasm_arch_x86 *)arch; if (yasm__strcasecmp(var, "mode_bits") == 0) - arch_x86->mode_bits = (unsigned int)val; + arch_x86->mode_bits = (unsigned char)val; else if (yasm__strcasecmp(var, "force_strict") == 0) - arch_x86->force_strict = (unsigned int)val; - else if (yasm__strcasecmp(var, "default_rel") == 0) { - if (arch_x86->mode_bits != 64) - yasm_warn_set(YASM_WARN_GENERAL, - N_("ignoring default rel in non-64-bit mode")); - else - arch_x86->default_rel = (unsigned int)val; - } else if (yasm__strcasecmp(var, "gas_intel_mode") == 0) { - arch_x86->gas_intel_mode = (unsigned int)val; - } else - return 1; + arch_x86->force_strict = (unsigned char)val; + else + return 1; return 0; } static void x86_dir_cpu(yasm_object *object, yasm_valparamhead *valparams, - yasm_valparamhead *objext_valparams, unsigned long line) + yasm_valparamhead *objext_valparams, unsigned long line) { yasm_arch_x86 *arch_x86 = (yasm_arch_x86 *)object->arch; @@ -159,25 +130,25 @@ x86_dir_cpu(yasm_object *object, yasm_valparamhead *valparams, if (s) yasm_x86__parse_cpu(arch_x86, s, strlen(s)); else if (vp->type == YASM_PARAM_EXPR) { - const yasm_intnum *intcpu; + const yasm_intnum *intcpu; intcpu = yasm_expr_get_intnum(&vp->param.e, 0); - if (!intcpu) - yasm_error_set(YASM_ERROR_SYNTAX, - N_("invalid argument to [%s]"), "CPU"); - else { - char strcpu[16]; - sprintf(strcpu, "%lu", yasm_intnum_get_uint(intcpu)); - yasm_x86__parse_cpu(arch_x86, strcpu, strlen(strcpu)); - } + if (!intcpu) + yasm_error_set(YASM_ERROR_SYNTAX, + N_("invalid argument to [%s]"), "CPU"); + else { + char strcpu[16]; + sprintf(strcpu, "%lu", yasm_intnum_get_uint(intcpu)); + yasm_x86__parse_cpu(arch_x86, strcpu, strlen(strcpu)); + } } else yasm_error_set(YASM_ERROR_SYNTAX, N_("invalid argument to [%s]"), "CPU"); - } + } } static void x86_dir_bits(yasm_object *object, yasm_valparamhead *valparams, - yasm_valparamhead *objext_valparams, unsigned long line) + yasm_valparamhead *objext_valparams, unsigned long line) { yasm_arch_x86 *arch_x86 = (yasm_arch_x86 *)object->arch; yasm_valparam *vp; @@ -188,19 +159,19 @@ x86_dir_bits(yasm_object *object, yasm_valparamhead *valparams, if ((vp = yasm_vps_first(valparams)) && !vp->val && (e = yasm_vp_expr(vp, object->symtab, line)) != NULL && (intn = yasm_expr_get_intnum(&e, 0)) != NULL && - (lval = yasm_intnum_get_int(intn)) && - (lval == 16 || lval == 32 || lval == 64)) - arch_x86->mode_bits = (unsigned char)lval; + (lval = yasm_intnum_get_int(intn)) && + (lval == 16 || lval == 32 || lval == 64)) + arch_x86->mode_bits = (unsigned char)lval; else - yasm_error_set(YASM_ERROR_VALUE, N_("invalid argument to [%s]"), - "BITS"); + yasm_error_set(YASM_ERROR_VALUE, N_("invalid argument to [%s]"), + "BITS"); if (e) yasm_expr_destroy(e); } static void x86_dir_code16(yasm_object *object, yasm_valparamhead *valparams, - yasm_valparamhead *objext_valparams, unsigned long line) + yasm_valparamhead *objext_valparams, unsigned long line) { yasm_arch_x86 *arch_x86 = (yasm_arch_x86 *)object->arch; arch_x86->mode_bits = 16; @@ -208,7 +179,7 @@ x86_dir_code16(yasm_object *object, yasm_valparamhead *valparams, static void x86_dir_code32(yasm_object *object, yasm_valparamhead *valparams, - yasm_valparamhead *objext_valparams, unsigned long line) + yasm_valparamhead *objext_valparams, unsigned long line) { yasm_arch_x86 *arch_x86 = (yasm_arch_x86 *)object->arch; arch_x86->mode_bits = 32; @@ -216,7 +187,7 @@ x86_dir_code32(yasm_object *object, yasm_valparamhead *valparams, static void x86_dir_code64(yasm_object *object, yasm_valparamhead *valparams, - yasm_valparamhead *objext_valparams, unsigned long line) + yasm_valparamhead *objext_valparams, unsigned long line) { yasm_arch_x86 *arch_x86 = (yasm_arch_x86 *)object->arch; arch_x86->mode_bits = 64; @@ -228,290 +199,217 @@ x86_get_fill(const yasm_arch *arch) const yasm_arch_x86 *arch_x86 = (const yasm_arch_x86 *)arch; /* Fill patterns that GAS uses. */ - static const unsigned char fill16_1[1] = - {0x90}; /* 1 - nop */ - static const unsigned char fill16_2[2] = - {0x89, 0xf6}; /* 2 - mov si, si */ - static const unsigned char fill16_3[3] = - {0x8d, 0x74, 0x00}; /* 3 - lea si, [si+byte 0] */ - static const unsigned char fill16_4[4] = - {0x8d, 0xb4, 0x00, 0x00}; /* 4 - lea si, [si+word 0] */ - static const unsigned char fill16_5[5] = - {0x90, /* 5 - nop */ - 0x8d, 0xb4, 0x00, 0x00}; /* lea si, [si+word 0] */ - static const unsigned char fill16_6[6] = - {0x89, 0xf6, /* 6 - mov si, si */ - 0x8d, 0xbd, 0x00, 0x00}; /* lea di, [di+word 0] */ - static const unsigned char fill16_7[7] = - {0x8d, 0x74, 0x00, /* 7 - lea si, [si+byte 0] */ - 0x8d, 0xbd, 0x00, 0x00}; /* lea di, [di+word 0] */ - static const unsigned char fill16_8[8] = - {0x8d, 0xb4, 0x00, 0x00, /* 8 - lea si, [si+word 0] */ - 0x8d, 0xbd, 0x00, 0x00}; /* lea di, [di+word 0] */ - static const unsigned char fill16_9[9] = - {0xeb, 0x07, 0x90, 0x90, 0x90, 0x90, /* 9 - jmp $+9; nop fill */ - 0x90, 0x90, 0x90}; - static const unsigned char fill16_10[10] = - {0xeb, 0x08, 0x90, 0x90, 0x90, 0x90, /* 10 - jmp $+10; nop fill */ - 0x90, 0x90, 0x90, 0x90}; - static const unsigned char fill16_11[11] = - {0xeb, 0x09, 0x90, 0x90, 0x90, 0x90, /* 11 - jmp $+11; nop fill */ - 0x90, 0x90, 0x90, 0x90, 0x90}; - static const unsigned char fill16_12[12] = - {0xeb, 0x0a, 0x90, 0x90, 0x90, 0x90, /* 12 - jmp $+12; nop fill */ - 0x90, 0x90, 0x90, 0x90, 0x90, 0x90}; - static const unsigned char fill16_13[13] = - {0xeb, 0x0b, 0x90, 0x90, 0x90, 0x90, /* 13 - jmp $+13; nop fill */ - 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90}; - static const unsigned char fill16_14[14] = - {0xeb, 0x0c, 0x90, 0x90, 0x90, 0x90, /* 14 - jmp $+14; nop fill */ - 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90}; - static const unsigned char fill16_15[15] = - {0xeb, 0x0d, 0x90, 0x90, 0x90, 0x90, /* 15 - jmp $+15; nop fill */ - 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90}; - static const unsigned char *fill16[16] = - { - NULL, fill16_1, fill16_2, fill16_3, - fill16_4, fill16_5, fill16_6, fill16_7, - fill16_8, fill16_9, fill16_10, fill16_11, - fill16_12, fill16_13, fill16_14, fill16_15 + static const unsigned char *fill16[16] = { + NULL, /* unused */ + (const unsigned char *) + "\x90", /* 1 - nop */ + (const unsigned char *) + "\x89\xf6", /* 2 - mov si, si */ + (const unsigned char *) + "\x8d\x74\x00", /* 3 - lea si, [si+byte 0] */ + (const unsigned char *) + "\x8d\xb4\x00\x00", /* 4 - lea si, [si+word 0] */ + (const unsigned char *) + "\x90" /* 5 - nop */ + "\x8d\xb4\x00\x00", /* lea si, [si+word 0] */ + (const unsigned char *) + "\x89\xf6" /* 6 - mov si, si */ + "\x8d\xbd\x00\x00", /* lea di, [di+word 0] */ + (const unsigned char *) + "\x8d\x74\x00" /* 7 - lea si, [si+byte 0] */ + "\x8d\xbd\x00\x00", /* lea di, [di+word 0] */ + (const unsigned char *) + "\x8d\xb4\x00\x00" /* 8 - lea si, [si+word 0] */ + "\x8d\xbd\x00\x00", /* lea di, [di+word 0] */ + (const unsigned char *) + "\xeb\x07\x90\x90\x90\x90\x90" /* 9 - jmp $+9; nop fill */ + "\x90\x90", + (const unsigned char *) + "\xeb\x08\x90\x90\x90\x90\x90" /* 10 - jmp $+10; nop fill */ + "\x90\x90\x90", + (const unsigned char *) + "\xeb\x09\x90\x90\x90\x90\x90" /* 11 - jmp $+11; nop fill */ + "\x90\x90\x90\x90", + (const unsigned char *) + "\xeb\x0a\x90\x90\x90\x90\x90" /* 12 - jmp $+12; nop fill */ + "\x90\x90\x90\x90\x90", + (const unsigned char *) + "\xeb\x0b\x90\x90\x90\x90\x90" /* 13 - jmp $+13; nop fill */ + "\x90\x90\x90\x90\x90\x90", + (const unsigned char *) + "\xeb\x0c\x90\x90\x90\x90\x90" /* 14 - jmp $+14; nop fill */ + "\x90\x90\x90\x90\x90\x90\x90", + (const unsigned char *) + "\xeb\x0d\x90\x90\x90\x90\x90" /* 15 - jmp $+15; nop fill */ + "\x90\x90\x90\x90\x90\x90\x90\x90" }; - - static const unsigned char fill32_1[1] = - {0x90}; /* 1 - nop */ - static const unsigned char fill32_2[2] = - {0x66, 0x90}; /* 2 - xchg ax, ax (o16 nop) */ - static const unsigned char fill32_3[3] = - {0x8d, 0x76, 0x00}; /* 3 - lea esi, [esi+byte 0] */ - static const unsigned char fill32_4[4] = - {0x8d, 0x74, 0x26, 0x00}; /* 4 - lea esi, [esi*1+byte 0] */ - static const unsigned char fill32_5[5] = - {0x90, /* 5 - nop */ - 0x8d, 0x74, 0x26, 0x00}; /* lea esi, [esi*1+byte 0] */ - static const unsigned char fill32_6[6] = - {0x8d, 0xb6, 0x00, 0x00, 0x00, 0x00};/* 6 - lea esi, [esi+dword 0] */ - static const unsigned char fill32_7[7] = - {0x8d, 0xb4, 0x26, 0x00, 0x00, 0x00, /* 7 - lea esi, [esi*1+dword 0] */ - 0x00}; - static const unsigned char fill32_8[8] = - {0x90, /* 8 - nop */ - 0x8d, 0xb4, 0x26, 0x00, 0x00, 0x00, /* lea esi, [esi*1+dword 0] */ - 0x00}; + static const unsigned char *fill32[16] = { + NULL, /* unused */ + (const unsigned char *) + "\x90", /* 1 - nop */ + (const unsigned char *) + "\x89\xf6", /* 2 - mov esi, esi */ + (const unsigned char *) + "\x8d\x76\x00", /* 3 - lea esi, [esi+byte 0] */ + (const unsigned char *) + "\x8d\x74\x26\x00", /* 4 - lea esi, [esi*1+byte 0] */ + (const unsigned char *) + "\x90" /* 5 - nop */ + "\x8d\x74\x26\x00", /* lea esi, [esi*1+byte 0] */ + (const unsigned char *) + "\x8d\xb6\x00\x00\x00\x00", /* 6 - lea esi, [esi+dword 0] */ + (const unsigned char *) + "\x8d\xb4\x26\x00\x00\x00\x00", /* 7 - lea esi, [esi*1+dword 0] */ + (const unsigned char *) + "\x90" /* 8 - nop */ + "\x8d\xb4\x26\x00\x00\x00\x00", /* lea esi, [esi*1+dword 0] */ #if 0 - /* GAS uses these */ - static const unsigned char fill32_9[9] = - {0x89, 0xf6, /* 9 - mov esi, esi */ - 0x8d, 0xbc, 0x27, 0x00, 0x00, 0x00, /* lea edi, [edi*1+dword 0] */ - 0x00}; - static const unsigned char fill32_10[10] = - {0x8d, 0x76, 0x00, /* 10 - lea esi, [esi+byte 0] */ - 0x8d, 0xbc, 0x27, 0x00, 0x00, 0x00, /* lea edi, [edi+dword 0] */ - 0x00}; - static const unsigned char fill32_11[11] = - {0x8d, 0x74, 0x26, 0x00, /* 11 - lea esi, [esi*1+byte 0] */ - 0x8d, 0xbc, 0x27, 0x00, 0x00, 0x00, /* lea edi, [edi*1+dword 0] */ - 0x00}; - static const unsigned char fill32_12[12] = - {0x8d, 0xb6, 0x00, 0x00, 0x00, 0x00, /* 12 - lea esi, [esi+dword 0] */ - 0x8d, 0xbf, 0x00, 0x00, 0x00, 0x00};/* lea edi, [edi+dword 0] */ - static const unsigned char fill32_13[13] = - {0x8d, 0xb6, 0x00, 0x00, 0x00, 0x00, /* 13 - lea esi, [esi+dword 0] */ - 0x8d, 0xbc, 0x27, 0x00, 0x00, 0x00, /* lea edi, [edi*1+dword 0] */ - 0x00}; - static const unsigned char fill32_14[14] = - {0x8d, 0xb4, 0x26, 0x00, 0x00, 0x00, /* 14 - lea esi, [esi*1+dword 0] */ - 0x00, - 0x8d, 0xbc, 0x27, 0x00, 0x00, 0x00, /* lea edi, [edi*1+dword 0] */ - 0x00}; + /* GAS uses these */ + (const unsigned char *) + "\x89\xf6" /* 9 - mov esi, esi */ + "\x8d\xbc\x27\x00\x00\x00\x00", /* lea edi, [edi*1+dword 0] */ + (const unsigned char *) + "\x8d\x76\x00" /* 10 - lea esi, [esi+byte 0] */ + "\x8d\xbc\x27\x00\x00\x00\x00", /* lea edi, [edi+dword 0] */ + (const unsigned char *) + "\x8d\x74\x26\x00" /* 11 - lea esi, [esi*1+byte 0] */ + "\x8d\xbc\x27\x00\x00\x00\x00", /* lea edi, [edi*1+dword 0]*/ + (const unsigned char *) + "\x8d\xb6\x00\x00\x00\x00" /* 12 - lea esi, [esi+dword 0] */ + "\x8d\xbf\x00\x00\x00\x00", /* lea edi, [edi+dword 0] */ + (const unsigned char *) + "\x8d\xb6\x00\x00\x00\x00" /* 13 - lea esi, [esi+dword 0] */ + "\x8d\xbc\x27\x00\x00\x00\x00", /* lea edi, [edi*1+dword 0]*/ + (const unsigned char *) + "\x8d\xb4\x26\x00\x00\x00\x00" /* 14 - lea esi, [esi*1+dword 0]*/ + "\x8d\xbc\x27\x00\x00\x00\x00", /* lea edi, [edi*1+dword 0]*/ #else - /* But on newer processors, these are recommended */ - static const unsigned char fill32_9[9] = - {0xeb, 0x07, 0x90, 0x90, 0x90, 0x90, /* 9 - jmp $+9; nop fill */ - 0x90, 0x90, 0x90}; - static const unsigned char fill32_10[10] = - {0xeb, 0x08, 0x90, 0x90, 0x90, 0x90, /* 10 - jmp $+10; nop fill */ - 0x90, 0x90, 0x90, 0x90}; - static const unsigned char fill32_11[11] = - {0xeb, 0x09, 0x90, 0x90, 0x90, 0x90, /* 11 - jmp $+11; nop fill */ - 0x90, 0x90, 0x90, 0x90, 0x90}; - static const unsigned char fill32_12[12] = - {0xeb, 0x0a, 0x90, 0x90, 0x90, 0x90, /* 12 - jmp $+12; nop fill */ - 0x90, 0x90, 0x90, 0x90, 0x90, 0x90}; - static const unsigned char fill32_13[13] = - {0xeb, 0x0b, 0x90, 0x90, 0x90, 0x90, /* 13 - jmp $+13; nop fill */ - 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90}; - static const unsigned char fill32_14[14] = - {0xeb, 0x0c, 0x90, 0x90, 0x90, 0x90, /* 14 - jmp $+14; nop fill */ - 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90}; + /* But on newer processors, these are recommended */ + (const unsigned char *) + "\xeb\x07\x90\x90\x90\x90\x90" /* 9 - jmp $+9; nop fill */ + "\x90\x90", + (const unsigned char *) + "\xeb\x08\x90\x90\x90\x90\x90" /* 10 - jmp $+10; nop fill */ + "\x90\x90\x90", + (const unsigned char *) + "\xeb\x09\x90\x90\x90\x90\x90" /* 11 - jmp $+11; nop fill */ + "\x90\x90\x90\x90", + (const unsigned char *) + "\xeb\x0a\x90\x90\x90\x90\x90" /* 12 - jmp $+12; nop fill */ + "\x90\x90\x90\x90\x90", + (const unsigned char *) + "\xeb\x0b\x90\x90\x90\x90\x90" /* 13 - jmp $+13; nop fill */ + "\x90\x90\x90\x90\x90\x90", + (const unsigned char *) + "\xeb\x0c\x90\x90\x90\x90\x90" /* 14 - jmp $+14; nop fill */ + "\x90\x90\x90\x90\x90\x90\x90", #endif - static const unsigned char fill32_15[15] = - {0xeb, 0x0d, 0x90, 0x90, 0x90, 0x90, /* 15 - jmp $+15; nop fill */ - 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90}; - static const unsigned char *fill32[16] = - { - NULL, fill32_1, fill32_2, fill32_3, - fill32_4, fill32_5, fill32_6, fill32_7, - fill32_8, fill32_9, fill32_10, fill32_11, - fill32_12, fill32_13, fill32_14, fill32_15 + (const unsigned char *) + "\xeb\x0d\x90\x90\x90\x90\x90" /* 15 - jmp $+15; nop fill */ + "\x90\x90\x90\x90\x90\x90\x90\x90" }; - - /* Long form nops available on more recent Intel and AMD processors */ - static const unsigned char fill32new_3[3] = - {0x0f, 0x1f, 0x00}; /* 3 - nop(3) */ - static const unsigned char fill32new_4[4] = - {0x0f, 0x1f, 0x40, 0x00}; /* 4 - nop(4) */ - static const unsigned char fill32new_5[5] = - {0x0f, 0x1f, 0x44, 0x00, 0x00}; /* 5 - nop(5) */ - static const unsigned char fill32new_6[6] = - {0x66, 0x0f, 0x1f, 0x44, 0x00, 0x00}; /* 6 - nop(6) */ - static const unsigned char fill32new_7[7] = - {0x0f, 0x1f, 0x80, 0x00, 0x00, 0x00, 0x00}; /* 7 - nop(7) */ - static const unsigned char fill32new_8[8] = - {0x0f, 0x1f, 0x84, 0x00, 0x00, 0x00, 0x00, /* 8 - nop(8) */ - 0x00}; - static const unsigned char fill32new_9[9] = - {0x66, 0x0f, 0x1f, 0x84, 0x00, 0x00, 0x00, /* 9 - nop(9) */ - 0x00, 0x00}; - - /* Longer forms preferred by Intel use repeated o16 prefixes */ - static const unsigned char fill32intel_10[10] = - {0x66, 0x2e, 0x0f, 0x1f, 0x84, 0x00, 0x00, /* 10 - o16; cs; nop */ - 0x00, 0x00, 0x00}; - static const unsigned char fill32intel_11[11] = - {0x66, 0x66, 0x2e, 0x0f, 0x1f, 0x84, 0x00, /* 11 - 2x o16; cs; nop */ - 0x00, 0x00, 0x00, 0x00}; - static const unsigned char fill32intel_12[12] = - {0x66, 0x66, 0x66, 0x2e, 0x0f, 0x1f, 0x84, /* 12 - 3x o16; cs; nop */ - 0x00, 0x00, 0x00, 0x00, 0x00}; - static const unsigned char fill32intel_13[13] = - {0x66, 0x66, 0x66, 0x66, 0x2e, 0x0f, 0x1f, /* 13 - 4x o16; cs; nop */ - 0x84, 0x00, 0x00, 0x00, 0x00, 0x00}; - static const unsigned char fill32intel_14[14] = - {0x66, 0x66, 0x66, 0x66, 0x66, 0x2e, 0x0f, /* 14 - 5x o16; cs; nop */ - 0x1f, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00}; - static const unsigned char fill32intel_15[15] = - {0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x2e, /* 15 - 6x o16; cs; nop */ - 0x0f, 0x1f, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00}; - - /* Longer forms preferred by AMD use fewer o16 prefixes and no CS prefix; - * Source: Software Optimisation Guide for AMD Family 10h - * Processors 40546 revision 3.10 February 2009 - */ - static const unsigned char fill32amd_10[10] = - {0x66, 0x66, 0x0f, 0x1f, 0x84, 0x00, 0x00, /* 10 - nop(10) */ - 0x00, 0x00, 0x00}; - static const unsigned char fill32amd_11[11] = - {0x0f, 0x1f, 0x44, 0x00, 0x00, /* 11 - nop(5) */ - 0x66, 0x0f, 0x1f, 0x44, 0x00, 0x00}; /* nop(6) */ - static const unsigned char fill32amd_12[12] = - {0x66, 0x0f, 0x1f, 0x44, 0x00, 0x00, /* 12 - nop(6) */ - 0x66, 0x0f, 0x1f, 0x44, 0x00, 0x00}; /* nop(6) */ - static const unsigned char fill32amd_13[13] = - {0x66, 0x0f, 0x1f, 0x44, 0x00, 0x00, /* 13 - nop(6) */ - 0x0f, 0x1f, 0x80, 0x00, 0x00, 0x00, 0x00}; /* nop(7) */ - static const unsigned char fill32amd_14[14] = - {0x0f, 0x1f, 0x80, 0x00, 0x00, 0x00, 0x00, /* 14 - nop(7) */ - 0x0f, 0x1f, 0x80, 0x00, 0x00, 0x00, 0x00}; /* nop(7) */ - static const unsigned char fill32amd_15[15] = - {0x0f, 0x1f, 0x80, 0x00, 0x00, 0x00, 0x00, /* 15 - nop(7) */ - 0x0f, 0x1f, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00}; /* nop(8) */ - - static const unsigned char *fill32_intel[16] = - { - NULL, fill32_1, fill32_2, fill32new_3, - fill32new_4, fill32new_5, fill32new_6, fill32new_7, - fill32new_8, fill32new_9, fill32intel_10, fill32intel_11, - fill32intel_12, fill32intel_13, fill32intel_14, fill32intel_15 + static const unsigned char *fill64[16] = { + NULL, /* unused */ + (const unsigned char *) + "\x90", /* 1 - nop */ + (const unsigned char *) + "\x66\x90", /* 2 - o16; nop */ + (const unsigned char *) + "\x66\x66\x90", /* 3 - o16; o16; nop */ + (const unsigned char *) + "\x66\x66\x66\x90", /* 4 - o16; o16; o16; nop */ + (const unsigned char *) + "\x66\x66\x90\x66\x90", /* 5 */ + (const unsigned char *) + "\x66\x66\x90\x66\x66\x90", /* 6 */ + (const unsigned char *) + "\x66\x66\x66\x90\x66\x66\x90", /* 7 */ + (const unsigned char *) + "\x66\x66\x66\x90\x66\x66\x66" /* 8 */ + "\x90", + (const unsigned char *) + "\x66\x66\x90\x66\x66\x90\x66" /* 9 */ + "\x66\x90", + (const unsigned char *) + "\x66\x66\x66\x90\x66\x66\x90" /* 10 */ + "\x66\x66\x90", + (const unsigned char *) + "\x66\x66\x66\x90\x66\x66\x66" /* 11 */ + "\x90\x66\x66\x90", + (const unsigned char *) + "\x66\x66\x66\x90\x66\x66\x66" /* 12 */ + "\x90\x66\x66\x66\x90", + (const unsigned char *) + "\x66\x66\x66\x90\x66\x66\x90" /* 13 */ + "\x66\x66\x90\x66\x66\x90", + (const unsigned char *) + "\x66\x66\x66\x90\x66\x66\x66" /* 14 */ + "\x90\x66\x66\x90\x66\x66\x90", + (const unsigned char *) + "\x66\x66\x66\x90\x66\x66\x66" /* 15 */ + "\x90\x66\x66\x66\x90\x66\x66\x90" }; - static const unsigned char *fill32_amd[16] = - { - NULL, fill32_1, fill32_2, fill32new_3, - fill32new_4, fill32new_5, fill32new_6, fill32new_7, - fill32new_8, fill32new_9, fill32amd_10, fill32amd_11, - fill32amd_12, fill32amd_13, fill32amd_14, fill32amd_15 - }; - switch (arch_x86->mode_bits) { - case 16: - return fill16; - case 32: - if (arch_x86->nop == X86_NOP_INTEL) - return fill32_intel; - else if (arch_x86->nop == X86_NOP_AMD) - return fill32_amd; - else - return fill32; - case 64: - /* We know long nops are available in 64-bit mode; default to Intel - * ones if unspecified (to match GAS behavior). - */ - if (arch_x86->nop == X86_NOP_AMD) - return fill32_amd; - else - return fill32_intel; - default: - yasm_error_set(YASM_ERROR_VALUE, - N_("Invalid mode_bits in x86_get_fill")); - return NULL; + case 16: + return fill16; + case 32: + return fill32; + case 64: + return fill64; + default: + yasm_error_set(YASM_ERROR_VALUE, + N_("Invalid mode_bits in x86_get_fill")); + return NULL; } } unsigned int -yasm_x86__get_reg_size(uintptr_t reg) +yasm_x86__get_reg_size(yasm_arch *arch, uintptr_t reg) { switch ((x86_expritem_reg_size)(reg & ~0xFUL)) { - case X86_REG8: - case X86_REG8X: - return 8; - case X86_REG16: - return 16; - case X86_REG32: - case X86_CRREG: - case X86_DRREG: - case X86_TRREG: - return 32; - case X86_REG64: - case X86_MMXREG: - return 64; - case X86_XMMREG: - return 128; - case X86_YMMREG: - return 256; - case X86_FPUREG: - return 80; - default: - yasm_error_set(YASM_ERROR_VALUE, N_("unknown register size")); + case X86_REG8: + case X86_REG8X: + return 8; + case X86_REG16: + return 16; + case X86_REG32: + case X86_CRREG: + case X86_DRREG: + case X86_TRREG: + return 32; + case X86_REG64: + case X86_MMXREG: + return 64; + case X86_XMMREG: + return 128; + case X86_FPUREG: + return 80; + default: + yasm_error_set(YASM_ERROR_VALUE, N_("unknown register size")); } return 0; } -static unsigned int -x86_get_reg_size(yasm_arch *arch, uintptr_t reg) -{ - return yasm_x86__get_reg_size(reg); -} - static uintptr_t x86_reggroup_get_reg(yasm_arch *arch, uintptr_t reggroup, - unsigned long regindex) + unsigned long regindex) { yasm_arch_x86 *arch_x86 = (yasm_arch_x86 *)arch; switch ((x86_expritem_reg_size)(reggroup & ~0xFUL)) { - case X86_XMMREG: - case X86_YMMREG: - if (arch_x86->mode_bits == 64) { - if (regindex > 15) - return 0; - return reggroup | (regindex & 15); - } - /*@fallthrough@*/ - case X86_MMXREG: - case X86_FPUREG: - if (regindex > 7) - return 0; - return reggroup | (regindex & 7); - default: - yasm_error_set(YASM_ERROR_VALUE, N_("bad register group")); + case X86_XMMREG: + if (arch_x86->mode_bits == 64) { + if (regindex > 15) + return 0; + return reggroup | (regindex & 15); + } + /*@fallthrough@*/ + case X86_MMXREG: + case X86_FPUREG: + if (regindex > 7) + return 0; + return reggroup | (regindex & 7); + default: + yasm_error_set(YASM_ERROR_VALUE, N_("bad register group")); } return 0; } @@ -521,61 +419,58 @@ x86_reg_print(yasm_arch *arch, uintptr_t reg, FILE *f) { static const char *name8[] = {"al","cl","dl","bl","ah","ch","dh","bh"}; static const char *name8x[] = { - "al", "cl", "dl", "bl", "spl", "bpl", "sil", "dil", - "r8b", "r9b", "r10b", "r11b", "r12b", "r13b", "r14b", "r15b" + "al", "cl", "dl", "bl", "spl", "bpl", "sil", "dil", + "r8b", "r9b", "r10b", "r11b", "r12b", "r13b", "r14b", "r15b" }; static const char *name16[] = { - "ax", "cx", "dx", "bx", "sp", "bp", "si", "di", - "r8w", "r9w", "r10w", "r11w", "r12w", "r13w", "r14w", "r15w" + "ax", "cx", "dx", "bx", "sp", "bp", "si", "di" + "r8w", "r9w", "r10w", "r11w", "r12w", "r13w", "r14w", "r15w" }; static const char *name32[] = { - "eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi", - "r8d", "r9d", "r10d", "r11d", "r12d", "r13d", "r14d", "r15d" + "eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi" + "r8d", "r9d", "r10d", "r11d", "r12d", "r13d", "r14d", "r15d" }; static const char *name64[] = { - "rax", "rcx", "rdx", "rbx", "rsp", "rbp", "rsi", "rdi", - "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15" + "rax", "rcx", "rdx", "rbx", "rsp", "rbp", "rsi", "rdi" + "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15" }; switch ((x86_expritem_reg_size)(reg & ~0xFUL)) { - case X86_REG8: - fprintf(f, "%s", name8[reg&0xF]); - break; - case X86_REG8X: - fprintf(f, "%s", name8x[reg&0xF]); - break; - case X86_REG16: - fprintf(f, "%s", name16[reg&0xF]); - break; - case X86_REG32: - fprintf(f, "%s", name32[reg&0xF]); - break; - case X86_REG64: - fprintf(f, "%s", name64[reg&0xF]); - break; - case X86_MMXREG: - fprintf(f, "mm%d", (int)(reg&0xF)); - break; - case X86_XMMREG: - fprintf(f, "xmm%d", (int)(reg&0xF)); - break; - case X86_YMMREG: - fprintf(f, "ymm%d", (int)(reg&0xF)); - break; - case X86_CRREG: - fprintf(f, "cr%d", (int)(reg&0xF)); - break; - case X86_DRREG: - fprintf(f, "dr%d", (int)(reg&0xF)); - break; - case X86_TRREG: - fprintf(f, "tr%d", (int)(reg&0xF)); - break; - case X86_FPUREG: - fprintf(f, "st%d", (int)(reg&0xF)); - break; - default: - yasm_error_set(YASM_ERROR_VALUE, N_("unknown register size")); + case X86_REG8: + fprintf(f, "%s", name8[reg&0xF]); + break; + case X86_REG8X: + fprintf(f, "%s", name8x[reg&0xF]); + break; + case X86_REG16: + fprintf(f, "%s", name16[reg&0xF]); + break; + case X86_REG32: + fprintf(f, "%s", name32[reg&0xF]); + break; + case X86_REG64: + fprintf(f, "%s", name64[reg&0xF]); + break; + case X86_MMXREG: + fprintf(f, "mm%d", (int)(reg&0xF)); + break; + case X86_XMMREG: + fprintf(f, "xmm%d", (int)(reg&0xF)); + break; + case X86_CRREG: + fprintf(f, "cr%d", (int)(reg&0xF)); + break; + case X86_DRREG: + fprintf(f, "dr%d", (int)(reg&0xF)); + break; + case X86_TRREG: + fprintf(f, "tr%d", (int)(reg&0xF)); + break; + case X86_FPUREG: + fprintf(f, "st%d", (int)(reg&0xF)); + break; + default: + yasm_error_set(YASM_ERROR_VALUE, N_("unknown register size")); } } @@ -590,16 +485,15 @@ x86_segreg_print(yasm_arch *arch, uintptr_t segreg, FILE *f) static const yasm_arch_machine x86_machines[] = { { "IA-32 and derivatives", "x86" }, { "AMD64", "amd64" }, - { "X32", "x32" }, { NULL, NULL } }; static const yasm_directive x86_directives[] = { - { "cpu", "nasm", x86_dir_cpu, YASM_DIR_ARG_REQUIRED }, - { "bits", "nasm", x86_dir_bits, YASM_DIR_ARG_REQUIRED }, - { ".code16", "gas", x86_dir_code16, YASM_DIR_ANY }, - { ".code32", "gas", x86_dir_code32, YASM_DIR_ANY }, - { ".code64", "gas", x86_dir_code64, YASM_DIR_ANY }, + { "cpu", "nasm", x86_dir_cpu, YASM_DIR_ARG_REQUIRED }, + { "bits", "nasm", x86_dir_bits, YASM_DIR_ARG_REQUIRED }, + { ".code16", "gas", x86_dir_code16, YASM_DIR_ANY }, + { ".code32", "gas", x86_dir_code32, YASM_DIR_ANY }, + { ".code64", "gas", x86_dir_code64, YASM_DIR_ANY }, { NULL, NULL, NULL, 0 } }; @@ -616,16 +510,14 @@ yasm_arch_module yasm_x86_LTX_arch = { yasm_x86__parse_check_insnprefix, yasm_x86__parse_check_regtmod, x86_get_fill, + yasm_x86__finalize_insn, yasm_x86__floatnum_tobytes, yasm_x86__intnum_tobytes, - x86_get_reg_size, + yasm_x86__get_reg_size, x86_reggroup_get_reg, x86_reg_print, x86_segreg_print, yasm_x86__ea_create_expr, - yasm_x86__ea_destroy, - yasm_x86__ea_print, - yasm_x86__create_empty_insn, x86_machines, "x86", 16, diff --git a/modules/arch/x86/x86arch.h b/modules/arch/x86/x86arch.h index 911482ee..52f9f7b0 100644 --- a/modules/arch/x86/x86arch.h +++ b/modules/arch/x86/x86arch.h @@ -1,4 +1,4 @@ -/* +/* $Id$ * x86 Architecture header file * * Copyright (C) 2001-2007 Peter Johnson @@ -27,99 +27,60 @@ #ifndef YASM_X86ARCH_H #define YASM_X86ARCH_H -#include - /* Available CPU feature flags */ -#define CPU_Any 0 /* Any old cpu will do */ -#define CPU_086 CPU_Any -#define CPU_186 1 /* i186 or better required */ -#define CPU_286 2 /* i286 or better required */ -#define CPU_386 3 /* i386 or better required */ -#define CPU_486 4 /* i486 or better required */ -#define CPU_586 5 /* i585 or better required */ -#define CPU_686 6 /* i686 or better required */ -#define CPU_P3 7 /* Pentium3 or better required */ -#define CPU_P4 8 /* Pentium4 or better required */ -#define CPU_IA64 9 /* IA-64 or better required */ -#define CPU_K6 10 /* AMD K6 or better required */ -#define CPU_Athlon 11 /* AMD Athlon or better required */ -#define CPU_Hammer 12 /* AMD Sledgehammer or better required */ -#define CPU_FPU 13 /* FPU support required */ -#define CPU_MMX 14 /* MMX support required */ -#define CPU_SSE 15 /* Streaming SIMD extensions required */ -#define CPU_SSE2 16 /* Streaming SIMD extensions 2 required */ -#define CPU_SSE3 17 /* Streaming SIMD extensions 3 required */ -#define CPU_3DNow 18 /* 3DNow! support required */ -#define CPU_Cyrix 19 /* Cyrix-specific instruction */ -#define CPU_AMD 20 /* AMD-specific inst. (older than K6) */ -#define CPU_SMM 21 /* System Management Mode instruction */ -#define CPU_Prot 22 /* Protected mode only instruction */ -#define CPU_Undoc 23 /* Undocumented instruction */ -#define CPU_Obs 24 /* Obsolete instruction */ -#define CPU_Priv 25 /* Priveleged instruction */ -#define CPU_SVM 26 /* Secure Virtual Machine instruction */ -#define CPU_PadLock 27 /* VIA PadLock instruction */ -#define CPU_EM64T 28 /* Intel EM64T or better */ -#define CPU_SSSE3 29 /* Streaming SIMD extensions 3 required */ -#define CPU_SSE41 30 /* Streaming SIMD extensions 4.1 required */ -#define CPU_SSE42 31 /* Streaming SIMD extensions 4.2 required */ -#define CPU_SSE4a 32 /* AMD Streaming SIMD extensions 4a required */ -#define CPU_XSAVE 33 /* Intel XSAVE instructions */ -#define CPU_AVX 34 /* Intel Advanced Vector Extensions */ -#define CPU_FMA 35 /* Intel Fused-Multiply-Add Extensions */ -#define CPU_AES 36 /* AES instruction */ -#define CPU_CLMUL 37 /* PCLMULQDQ instruction */ -#define CPU_MOVBE 38 /* MOVBE instruction */ -#define CPU_XOP 39 /* AMD XOP extensions */ -#define CPU_FMA4 40 /* AMD Fused-Multiply-Add extensions */ -#define CPU_F16C 41 /* Intel float-16 instructions */ -#define CPU_FSGSBASE 42 /* Intel FSGSBASE instructions */ -#define CPU_RDRAND 43 /* Intel RDRAND instruction */ -#define CPU_XSAVEOPT 44 /* Intel XSAVEOPT instruction */ -#define CPU_EPTVPID 45 /* Intel INVEPT, INVVPID instructions */ -#define CPU_SMX 46 /* Intel SMX instruction (GETSEC) */ -#define CPU_AVX2 47 /* Intel AVX2 instructions */ -#define CPU_BMI1 48 /* Intel BMI1 instructions */ -#define CPU_BMI2 49 /* Intel BMI2 instructions */ -#define CPU_INVPCID 50 /* Intel INVPCID instruction */ -#define CPU_LZCNT 51 /* Intel LZCNT instruction */ -#define CPU_TBM 52 /* AMD TBM instruction */ -#define CPU_TSX 53 /* Intel TSX instructions */ -#define CPU_SHA 54 /* Intel SHA instructions */ -#define CPU_SMAP 55 /* Intel SMAP instructions */ -#define CPU_RDSEED 56 /* Intel RDSEED instruction */ -#define CPU_ADX 57 /* Intel ADCX and ADOX instructions */ -#define CPU_PRFCHW 58 /* Intel/AMD PREFETCHW instruction */ +#define CPU_Any (0UL) /* Any old cpu will do */ +#define CPU_086 CPU_Any +#define CPU_186 (1UL<<0) /* i186 or better required */ +#define CPU_286 (1UL<<1) /* i286 or better required */ +#define CPU_386 (1UL<<2) /* i386 or better required */ +#define CPU_486 (1UL<<3) /* i486 or better required */ +#define CPU_586 (1UL<<4) /* i585 or better required */ +#define CPU_686 (1UL<<5) /* i686 or better required */ +#define CPU_P3 (1UL<<6) /* Pentium3 or better required */ +#define CPU_P4 (1UL<<7) /* Pentium4 or better required */ +#define CPU_IA64 (1UL<<8) /* IA-64 or better required */ +#define CPU_K6 (1UL<<9) /* AMD K6 or better required */ +#define CPU_Athlon (1UL<<10) /* AMD Athlon or better required */ +#define CPU_Hammer (1UL<<11) /* AMD Sledgehammer or better required */ +#define CPU_FPU (1UL<<12) /* FPU support required */ +#define CPU_MMX (1UL<<13) /* MMX support required */ +#define CPU_SSE (1UL<<14) /* Streaming SIMD extensions required */ +#define CPU_SSE2 (1UL<<15) /* Streaming SIMD extensions 2 required */ +#define CPU_SSE3 (1UL<<16) /* Streaming SIMD extensions 3 required */ +#define CPU_3DNow (1UL<<17) /* 3DNow! support required */ +#define CPU_Cyrix (1UL<<18) /* Cyrix-specific instruction */ +#define CPU_AMD (1UL<<19) /* AMD-specific inst. (older than K6) */ +#define CPU_SMM (1UL<<20) /* System Management Mode instruction */ +#define CPU_Prot (1UL<<21) /* Protected mode only instruction */ +#define CPU_Undoc (1UL<<22) /* Undocumented instruction */ +#define CPU_Obs (1UL<<23) /* Obsolete instruction */ +#define CPU_Priv (1UL<<24) /* Priveleged instruction */ +#define CPU_SVM (1UL<<25) /* Secure Virtual Machine instruction */ +#define CPU_PadLock (1UL<<25) /* VIA PadLock instruction */ +#define CPU_EM64T (1UL<<26) /* Intel EM64T or better */ +#define CPU_SSSE3 (1UL<<27) /* Streaming SIMD extensions 3 required */ +#define CPU_SSE41 (1UL<<28) /* Streaming SIMD extensions 4.1 required */ +#define CPU_SSE42 (1UL<<29) /* Streaming SIMD extensions 4.2 required */ +#define CPU_SSE4 (CPU_SSE41|CPU_SSE42) -enum x86_parser_type { - X86_PARSER_NASM = 0, - X86_PARSER_TASM = 1, - X86_PARSER_GAS = 2 -}; - -#define PARSER(arch) (((arch)->parser == X86_PARSER_GAS && (arch)->gas_intel_mode) ? X86_PARSER_NASM : (arch)->parser) +/* Technically not CPU capabilities, they do affect what instructions are + * available. These are tested against BITS==64. + */ +#define CPU_64 (1UL<<30) /* Only available in 64-bit mode */ +#define CPU_Not64 (1UL<<31) /* Not available (invalid) in 64-bit mode */ typedef struct yasm_arch_x86 { - yasm_arch_base arch; /* base structure */ + yasm_arch_base arch; /* base structure */ /* What instructions/features are enabled? */ - unsigned int active_cpu; /* active index into cpu_enables table */ - unsigned int cpu_enables_size; /* size of cpu_enables table */ - wordptr *cpu_enables; - + unsigned long cpu_enabled; unsigned int amd64_machine; - enum x86_parser_type parser; - unsigned int mode_bits; - unsigned int address_size; - unsigned int force_strict; - unsigned int default_rel; - unsigned int gas_intel_mode; - enum { - X86_NOP_BASIC = 0, - X86_NOP_INTEL = 1, - X86_NOP_AMD = 2 - } nop; + X86_PARSER_NASM, + X86_PARSER_GAS + } parser; + unsigned char mode_bits; + unsigned char force_strict; } yasm_arch_x86; /* 0-15 (low 4 bits) used for register number, stored in same data area. @@ -127,28 +88,25 @@ typedef struct yasm_arch_x86 { */ typedef enum { X86_REG8 = 0x1<<4, - X86_REG8X = 0x2<<4, /* 64-bit mode only, REX prefix version of REG8 */ + X86_REG8X = 0x2<<4, /* 64-bit mode only, REX prefix version of REG8 */ X86_REG16 = 0x3<<4, X86_REG32 = 0x4<<4, - X86_REG64 = 0x5<<4, /* 64-bit mode only */ + X86_REG64 = 0x5<<4, /* 64-bit mode only */ X86_FPUREG = 0x6<<4, X86_MMXREG = 0x7<<4, X86_XMMREG = 0x8<<4, - X86_YMMREG = 0x9<<4, - X86_CRREG = 0xA<<4, - X86_DRREG = 0xB<<4, - X86_TRREG = 0xC<<4, - X86_RIP = 0xD<<4 /* 64-bit mode only, always RIP (regnum ignored) */ + X86_CRREG = 0x9<<4, + X86_DRREG = 0xA<<4, + X86_TRREG = 0xB<<4, + X86_RIP = 0xC<<4 /* 64-bit mode only, always RIP (regnum ignored) */ } x86_expritem_reg_size; -/* Low 8 bits are used for the prefix value, stored in same data area. */ typedef enum { - X86_LOCKREP = 1<<8, - X86_ADDRSIZE = 2<<8, - X86_OPERSIZE = 3<<8, - X86_SEGREG = 4<<8, - X86_REX = 5<<8, - X86_ACQREL = 6<<8 /*TSX hint prefixes*/ + X86_LOCKREP = 1, + X86_ADDRSIZE, + X86_OPERSIZE, + X86_SEGREG, + X86_REX } x86_parse_insn_prefix; typedef enum { @@ -179,105 +137,98 @@ typedef enum { * in 64-bit mode or if it wasn't needed to express reg. */ int yasm_x86__set_rex_from_reg(unsigned char *rex, unsigned char *low3, - uintptr_t reg, unsigned int bits, - x86_rex_bit_pos rexbit); + uintptr_t reg, unsigned int bits, + x86_rex_bit_pos rexbit); /* Effective address type */ typedef struct x86_effaddr { - yasm_effaddr ea; /* base structure */ - - /* VSIB uses the normal SIB byte, but this flag enables it. */ - unsigned char vsib_mode; /* 0 if not, 1 if XMM, 2 if YMM */ + yasm_effaddr ea; /* base structure */ /* How the spare (register) bits in Mod/RM are handled: * Even if valid_modrm=0, the spare bits are still valid (don't overwrite!) * They're set in bytecode_create_insn(). */ unsigned char modrm; - unsigned char valid_modrm; /* 1 if Mod/RM byte currently valid, 0 if not */ - unsigned char need_modrm; /* 1 if Mod/RM byte needed, 0 if not */ + unsigned char valid_modrm; /* 1 if Mod/RM byte currently valid, 0 if not */ + unsigned char need_modrm; /* 1 if Mod/RM byte needed, 0 if not */ unsigned char sib; - unsigned char valid_sib; /* 1 if SIB byte currently valid, 0 if not */ - unsigned char need_sib; /* 1 if SIB byte needed, 0 if not, - 0xff if unknown */ + unsigned char valid_sib; /* 1 if SIB byte currently valid, 0 if not */ + unsigned char need_sib; /* 1 if SIB byte needed, 0 if not, + 0xff if unknown */ } x86_effaddr; void yasm_x86__ea_init(x86_effaddr *x86_ea, unsigned int spare, - yasm_bytecode *precbc); + yasm_bytecode *precbc); void yasm_x86__ea_set_disponly(x86_effaddr *x86_ea); -x86_effaddr *yasm_x86__ea_create_reg(x86_effaddr *x86_ea, unsigned long reg, - unsigned char *rex, unsigned int bits); +x86_effaddr *yasm_x86__ea_create_reg(unsigned long reg, unsigned char *rex, + unsigned int bits); x86_effaddr *yasm_x86__ea_create_imm - (x86_effaddr *x86_ea, /*@keep@*/ yasm_expr *imm, unsigned int im_len); + (/*@keep@*/ yasm_expr *imm, unsigned int im_len); yasm_effaddr *yasm_x86__ea_create_expr(yasm_arch *arch, - /*@keep@*/ yasm_expr *e); -void yasm_x86__ea_destroy(yasm_effaddr *ea); -void yasm_x86__ea_print(const yasm_effaddr *ea, FILE *f, int indent_level); + /*@keep@*/ yasm_expr *e); void yasm_x86__bc_insn_opersize_override(yasm_bytecode *bc, - unsigned int opersize); + unsigned int opersize); void yasm_x86__bc_insn_addrsize_override(yasm_bytecode *bc, - unsigned int addrsize); + unsigned int addrsize); void yasm_x86__bc_insn_set_lockrep_prefix(yasm_bytecode *bc, - unsigned int prefix); + unsigned int prefix); /* Bytecode types */ typedef struct x86_common { - unsigned char addrsize; /* 0 or =mode_bits => no override */ - unsigned char opersize; /* 0 or =mode_bits => no override */ - unsigned char lockrep_pre; /* 0 indicates no prefix */ - unsigned char acqrel_pre; /* 0 indicates no prefix. We need this because - xqcuire/xrelease might require F0 prefix */ + unsigned char addrsize; /* 0 or =mode_bits => no override */ + unsigned char opersize; /* 0 or =mode_bits => no override */ + unsigned char lockrep_pre; /* 0 indicates no prefix */ unsigned char mode_bits; } x86_common; typedef struct x86_opcode { - unsigned char opcode[4]; /* opcode */ + unsigned char opcode[3]; /* opcode */ unsigned char len; } x86_opcode; typedef struct x86_insn { - x86_common common; /* common x86 information */ + x86_common common; /* common x86 information */ x86_opcode opcode; /*@null@*/ x86_effaddr *x86_ea; /* effective address */ - /*@null@*/ yasm_value *imm; /* immediate or relative value */ + /*@null@*/ yasm_value *imm; /* immediate or relative value */ unsigned char def_opersize_64; /* default operand size in 64-bit mode */ unsigned char special_prefix; /* "special" prefix (0=none) */ - unsigned char rex; /* REX AMD64 extension, 0 if none, - 0xff if not allowed (high 8 bit reg used) */ + unsigned char rex; /* REX AMD64 extension, 0 if none, + 0xff if not allowed (high 8 bit reg used) */ /* Postponed (from parsing to later binding) action options. */ enum { - /* None */ - X86_POSTOP_NONE = 0, + /* None */ + X86_POSTOP_NONE = 0, - /* Instructions that take a sign-extended imm8 as well as imm values - * (eg, the arith instructions and a subset of the imul instructions) - * should set this and put the imm8 form as the "normal" opcode (in - * the first one or two bytes) and non-imm8 form in the second or - * third byte of the opcode. - */ - X86_POSTOP_SIGNEXT_IMM8, + /* Instructions that take a sign-extended imm8 as well as imm values + * (eg, the arith instructions and a subset of the imul instructions) + * should set this and put the imm8 form as the "normal" opcode (in + * the first one or two bytes) and non-imm8 form in the second or + * third byte of the opcode. + */ + X86_POSTOP_SIGNEXT_IMM8, - /* Override any attempt at address-size override to 16 bits, and never - * generate a prefix. This is used for the ENTER opcode. - */ - X86_POSTOP_ADDRESS16 + /* Override any attempt at address-size override to 16 bits, and never + * generate a prefix. This is used for the ENTER opcode. + */ + X86_POSTOP_ADDRESS16 } postop; } x86_insn; typedef struct x86_jmp { - x86_common common; /* common x86 information */ + x86_common common; /* common x86 information */ x86_opcode shortop, nearop; - yasm_value target; /* jump target */ + yasm_value target; /* jump target */ /* which opcode are we using? */ /* The *FORCED forms are specified in the source as such */ @@ -289,11 +240,11 @@ typedef struct x86_jmp { * This bytecode is not legal in 64-bit mode. */ typedef struct x86_jmpfar { - x86_common common; /* common x86 information */ + x86_common common; /* common x86 information */ x86_opcode opcode; - yasm_value segment; /* target segment */ - yasm_value offset; /* target offset */ + yasm_value segment; /* target segment */ + yasm_value offset; /* target offset */ } x86_jmpfar; void yasm_x86__bc_transform_insn(yasm_bytecode *bc, x86_insn *insn); @@ -302,7 +253,7 @@ void yasm_x86__bc_transform_jmpfar(yasm_bytecode *bc, x86_jmpfar *jmpfar); void yasm_x86__bc_apply_prefixes (x86_common *common, unsigned char *rex, unsigned int def_opersize_64, - unsigned int num_prefixes, uintptr_t *prefixes); + int num_prefixes, uintptr_t **prefixes); /* Check an effective address. Returns 0 if EA was successfully determined, * 1 if invalid EA, or 2 if indeterminate EA. @@ -312,14 +263,20 @@ int yasm_x86__expr_checkea int address16_op, unsigned char *rex, yasm_bytecode *bc); void yasm_x86__parse_cpu(yasm_arch_x86 *arch_x86, const char *cpuid, - size_t cpuid_len); + size_t cpuid_len); yasm_arch_insnprefix yasm_x86__parse_check_insnprefix - (yasm_arch *arch, const char *id, size_t id_len, unsigned long line, - /*@out@*/ yasm_bytecode **bc, /*@out@*/ uintptr_t *prefix); + (yasm_arch *arch, /*@out@*/ uintptr_t data[4], const char *id, + size_t id_len); yasm_arch_regtmod yasm_x86__parse_check_regtmod - (yasm_arch *arch, const char *id, size_t id_len, - /*@out@*/ uintptr_t *data); + (yasm_arch *arch, /*@out@*/ uintptr_t *data, const char *id, + size_t id_len); + +void yasm_x86__finalize_insn + (yasm_arch *arch, yasm_bytecode *bc, yasm_bytecode *prev_bc, + const uintptr_t data[4], int num_operands, + /*@null@*/ yasm_insn_operands *operands, int num_prefixes, + uintptr_t **prefixes, int num_segregs, const uintptr_t *segregs); int yasm_x86__floatnum_tobytes (yasm_arch *arch, const yasm_floatnum *flt, unsigned char *buf, @@ -329,8 +286,5 @@ int yasm_x86__intnum_tobytes size_t destsize, size_t valsize, int shift, const yasm_bytecode *bc, int warn); -unsigned int yasm_x86__get_reg_size(uintptr_t reg); - -/*@only@*/ yasm_bytecode *yasm_x86__create_empty_insn(yasm_arch *arch, - unsigned long line); +unsigned int yasm_x86__get_reg_size(yasm_arch *arch, uintptr_t reg); #endif diff --git a/modules/arch/x86/x86bc.c b/modules/arch/x86/x86bc.c index 7f1eccea..b41b356b 100644 --- a/modules/arch/x86/x86bc.c +++ b/modules/arch/x86/x86bc.c @@ -25,59 +25,72 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include +/*@unused@*/ RCSID("$Id$"); +#define YASM_LIB_INTERNAL +#define YASM_BC_INTERNAL +#define YASM_EXPR_INTERNAL #include #include "x86arch.h" +/* Effective address callback function prototypes */ + +static void x86_ea_destroy(yasm_effaddr *ea); +static void x86_ea_print(const yasm_effaddr *ea, FILE *f, int indent_level); + /* Bytecode callback function prototypes */ static void x86_bc_insn_destroy(void *contents); static void x86_bc_insn_print(const void *contents, FILE *f, - int indent_level); + int indent_level); static int x86_bc_insn_calc_len(yasm_bytecode *bc, - yasm_bc_add_span_func add_span, - void *add_span_data); + yasm_bc_add_span_func add_span, + void *add_span_data); static int x86_bc_insn_expand(yasm_bytecode *bc, int span, long old_val, - long new_val, /*@out@*/ long *neg_thres, - /*@out@*/ long *pos_thres); + long new_val, /*@out@*/ long *neg_thres, + /*@out@*/ long *pos_thres); static int x86_bc_insn_tobytes(yasm_bytecode *bc, unsigned char **bufp, - unsigned char *bufstart, - void *d, yasm_output_value_func output_value, - /*@null@*/ yasm_output_reloc_func output_reloc); + void *d, yasm_output_value_func output_value, + /*@null@*/ yasm_output_reloc_func output_reloc); static void x86_bc_jmp_destroy(void *contents); static void x86_bc_jmp_print(const void *contents, FILE *f, int indent_level); static int x86_bc_jmp_calc_len(yasm_bytecode *bc, - yasm_bc_add_span_func add_span, - void *add_span_data); + yasm_bc_add_span_func add_span, + void *add_span_data); static int x86_bc_jmp_expand(yasm_bytecode *bc, int span, long old_val, - long new_val, /*@out@*/ long *neg_thres, - /*@out@*/ long *pos_thres); + long new_val, /*@out@*/ long *neg_thres, + /*@out@*/ long *pos_thres); static int x86_bc_jmp_tobytes(yasm_bytecode *bc, unsigned char **bufp, - unsigned char *bufstart, - void *d, yasm_output_value_func output_value, - /*@null@*/ yasm_output_reloc_func output_reloc); + void *d, yasm_output_value_func output_value, + /*@null@*/ yasm_output_reloc_func output_reloc); static void x86_bc_jmpfar_destroy(void *contents); static void x86_bc_jmpfar_print(const void *contents, FILE *f, - int indent_level); + int indent_level); static int x86_bc_jmpfar_calc_len(yasm_bytecode *bc, - yasm_bc_add_span_func add_span, - void *add_span_data); + yasm_bc_add_span_func add_span, + void *add_span_data); static int x86_bc_jmpfar_tobytes - (yasm_bytecode *bc, unsigned char **bufp, unsigned char *bufstart, void *d, + (yasm_bytecode *bc, unsigned char **bufp, void *d, yasm_output_value_func output_value, /*@null@*/ yasm_output_reloc_func output_reloc); +/* Effective address callback structures */ + +static const yasm_effaddr_callback x86_ea_callback = { + x86_ea_destroy, + x86_ea_print +}; + /* Bytecode callback structures */ static const yasm_bytecode_callback x86_bc_callback_insn = { x86_bc_insn_destroy, x86_bc_insn_print, yasm_bc_finalize_common, - NULL, x86_bc_insn_calc_len, x86_bc_insn_expand, x86_bc_insn_tobytes, @@ -88,7 +101,6 @@ static const yasm_bytecode_callback x86_bc_callback_jmp = { x86_bc_jmp_destroy, x86_bc_jmp_print, yasm_bc_finalize_common, - NULL, x86_bc_jmp_calc_len, x86_bc_jmp_expand, x86_bc_jmp_tobytes, @@ -99,7 +111,6 @@ static const yasm_bytecode_callback x86_bc_callback_jmpfar = { x86_bc_jmpfar_destroy, x86_bc_jmpfar_print, yasm_bc_finalize_common, - NULL, x86_bc_jmpfar_calc_len, yasm_bc_expand_common, x86_bc_jmpfar_tobytes, @@ -108,31 +119,31 @@ static const yasm_bytecode_callback x86_bc_callback_jmpfar = { int yasm_x86__set_rex_from_reg(unsigned char *rex, unsigned char *low3, - uintptr_t reg, unsigned int bits, - x86_rex_bit_pos rexbit) + uintptr_t reg, unsigned int bits, + x86_rex_bit_pos rexbit) { *low3 = (unsigned char)(reg&7); if (bits == 64) { - x86_expritem_reg_size size = (x86_expritem_reg_size)(reg & ~0xFUL); + x86_expritem_reg_size size = (x86_expritem_reg_size)(reg & ~0xFUL); - if (size == X86_REG8X || (reg & 0xF) >= 8) { - /* Check to make sure we can set it */ - if (*rex == 0xff) { - yasm_error_set(YASM_ERROR_TYPE, - N_("cannot use A/B/C/DH with instruction needing REX")); - return 1; - } - *rex |= 0x40 | (((reg & 8) >> 3) << rexbit); - } else if (size == X86_REG8 && (reg & 7) >= 4) { - /* AH/BH/CH/DH, so no REX allowed */ - if (*rex != 0 && *rex != 0xff) { - yasm_error_set(YASM_ERROR_TYPE, - N_("cannot use A/B/C/DH with instruction needing REX")); - return 1; - } - *rex = 0xff; /* Flag so we can NEVER set it (see above) */ - } + if (size == X86_REG8X || (reg & 0xF) >= 8) { + /* Check to make sure we can set it */ + if (*rex == 0xff) { + yasm_error_set(YASM_ERROR_TYPE, + N_("cannot use A/B/C/DH with instruction needing REX")); + return 1; + } + *rex |= 0x40 | (((reg & 8) >> 3) << rexbit); + } else if (size == X86_REG8 && (reg & 7) >= 4) { + /* AH/BH/CH/DH, so no REX allowed */ + if (*rex != 0 && *rex != 0xff) { + yasm_error_set(YASM_ERROR_TYPE, + N_("cannot use A/B/C/DH with instruction needing REX")); + return 1; + } + *rex = 0xff; /* Flag so we can NEVER set it (see above) */ + } } return 0; @@ -158,12 +169,12 @@ yasm_x86__bc_transform_jmpfar(yasm_bytecode *bc, x86_jmpfar *jmpfar) void yasm_x86__ea_init(x86_effaddr *x86_ea, unsigned int spare, - yasm_bytecode *precbc) + yasm_bytecode *precbc) { if (yasm_value_finalize(&x86_ea->ea.disp, precbc)) - yasm_error_set(YASM_ERROR_TOO_COMPLEX, - N_("effective address too complex")); - x86_ea->modrm &= 0xC7; /* zero spare/reg bits */ + yasm_error_set(YASM_ERROR_TOO_COMPLEX, + N_("effective address too complex")); + x86_ea->modrm &= 0xC7; /* zero spare/reg bits */ x86_ea->modrm |= (spare << 3) & 0x38; /* plug in provided bits */ } @@ -176,24 +187,28 @@ yasm_x86__ea_set_disponly(x86_effaddr *x86_ea) x86_ea->need_sib = 0; } -static x86_effaddr * -ea_create(void) +x86_effaddr * +yasm_x86__ea_create_reg(unsigned long reg, unsigned char *rex, + unsigned int bits) { - x86_effaddr *x86_ea = yasm_xmalloc(sizeof(x86_effaddr)); + x86_effaddr *x86_ea; + unsigned char rm; + if (yasm_x86__set_rex_from_reg(rex, &rm, reg, bits, X86_REX_B)) + return NULL; + + x86_ea = yasm_xmalloc(sizeof(x86_effaddr)); + + x86_ea->ea.callback = &x86_ea_callback; yasm_value_initialize(&x86_ea->ea.disp, NULL, 0); x86_ea->ea.need_nonzero_len = 0; x86_ea->ea.need_disp = 0; x86_ea->ea.nosplit = 0; x86_ea->ea.strong = 0; x86_ea->ea.segreg = 0; - x86_ea->ea.pc_rel = 0; - x86_ea->ea.not_pc_rel = 0; - x86_ea->ea.data_len = 0; - x86_ea->vsib_mode = 0; - x86_ea->modrm = 0; - x86_ea->valid_modrm = 0; - x86_ea->need_modrm = 0; + x86_ea->modrm = 0xC0 | rm; /* Mod=11, R/M=Reg, Reg=0 */ + x86_ea->valid_modrm = 1; + x86_ea->need_modrm = 1; x86_ea->sib = 0; x86_ea->valid_sib = 0; x86_ea->need_sib = 0; @@ -201,69 +216,69 @@ ea_create(void) return x86_ea; } -x86_effaddr * -yasm_x86__ea_create_reg(x86_effaddr *x86_ea, unsigned long reg, - unsigned char *rex, unsigned int bits) -{ - unsigned char rm; - - if (yasm_x86__set_rex_from_reg(rex, &rm, reg, bits, X86_REX_B)) - return NULL; - - if (!x86_ea) - x86_ea = ea_create(); - x86_ea->modrm = 0xC0 | rm; /* Mod=11, R/M=Reg, Reg=0 */ - x86_ea->valid_modrm = 1; - x86_ea->need_modrm = 1; - - return x86_ea; -} - yasm_effaddr * yasm_x86__ea_create_expr(yasm_arch *arch, yasm_expr *e) { yasm_arch_x86 *arch_x86 = (yasm_arch_x86 *)arch; x86_effaddr *x86_ea; - x86_ea = ea_create(); + x86_ea = yasm_xmalloc(sizeof(x86_effaddr)); + x86_ea->ea.callback = &x86_ea_callback; if (arch_x86->parser == X86_PARSER_GAS) { - /* Need to change foo+rip into foo wrt rip (even in .intel_syntax mode). - * Note this assumes a particular ordering coming from the parser - * to work (it's not very smart)! - */ - if (e->op == YASM_EXPR_ADD && e->terms[0].type == YASM_EXPR_REG - && e->terms[0].data.reg == X86_RIP) { - /* replace register with 0 */ - e->terms[0].type = YASM_EXPR_INT; - e->terms[0].data.intn = yasm_intnum_create_uint(0); - /* build new wrt expression */ - e = yasm_expr_create(YASM_EXPR_WRT, yasm_expr_expr(e), - yasm_expr_reg(X86_RIP), e->line); - } + /* Need to change foo+rip into foo wrt rip. + * Note this assumes a particular ordering coming from the parser + * to work (it's not very smart)! + */ + if (e->op == YASM_EXPR_ADD && e->terms[0].type == YASM_EXPR_REG + && e->terms[0].data.reg == X86_RIP) { + /* replace register with 0 */ + e->terms[0].type = YASM_EXPR_INT; + e->terms[0].data.intn = yasm_intnum_create_uint(0); + /* build new wrt expression */ + e = yasm_expr_create(YASM_EXPR_WRT, yasm_expr_expr(e), + yasm_expr_reg(X86_RIP), e->line); + } } yasm_value_initialize(&x86_ea->ea.disp, e, 0); + x86_ea->ea.need_nonzero_len = 0; x86_ea->ea.need_disp = 1; + x86_ea->ea.nosplit = 0; + x86_ea->ea.strong = 0; + x86_ea->ea.segreg = 0; + x86_ea->modrm = 0; + x86_ea->valid_modrm = 0; x86_ea->need_modrm = 1; + x86_ea->sib = 0; + x86_ea->valid_sib = 0; /* We won't know whether we need an SIB until we know more about expr and * the BITS/address override setting. */ x86_ea->need_sib = 0xff; - x86_ea->ea.data_len = 0; - return (yasm_effaddr *)x86_ea; } /*@-compmempass@*/ x86_effaddr * -yasm_x86__ea_create_imm(x86_effaddr *x86_ea, yasm_expr *imm, - unsigned int im_len) +yasm_x86__ea_create_imm(yasm_expr *imm, unsigned int im_len) { - if (!x86_ea) - x86_ea = ea_create(); + x86_effaddr *x86_ea; + + x86_ea = yasm_xmalloc(sizeof(x86_effaddr)); + + x86_ea->ea.callback = &x86_ea_callback; yasm_value_initialize(&x86_ea->ea.disp, imm, im_len); x86_ea->ea.need_disp = 1; + x86_ea->ea.nosplit = 0; + x86_ea->ea.strong = 0; + x86_ea->ea.segreg = 0; + x86_ea->modrm = 0; + x86_ea->valid_modrm = 0; + x86_ea->need_modrm = 0; + x86_ea->sib = 0; + x86_ea->valid_sib = 0; + x86_ea->need_sib = 0; return x86_ea; } @@ -271,86 +286,65 @@ yasm_x86__ea_create_imm(x86_effaddr *x86_ea, yasm_expr *imm, void yasm_x86__bc_apply_prefixes(x86_common *common, unsigned char *rex, - unsigned int def_opersize_64, - unsigned int num_prefixes, uintptr_t *prefixes) + unsigned int def_opersize_64, int num_prefixes, + uintptr_t **prefixes) { - unsigned int i; + int i; int first = 1; for (i=0; iacqrel_pre != 0) - yasm_warn_set(YASM_WARN_GENERAL, - N_("multiple XACQUIRE/XRELEASE prefixes, " - "using leftmost")); - common->acqrel_pre = (unsigned char)prefixes[i] & 0xff; - break; - case X86_LOCKREP: - if (common->lockrep_pre != 0) - yasm_warn_set(YASM_WARN_GENERAL, - N_("multiple LOCK or REP prefixes, using leftmost")); - common->lockrep_pre = (unsigned char)prefixes[i] & 0xff; - break; - case X86_ADDRSIZE: - common->addrsize = (unsigned char)prefixes[i] & 0xff; - break; - case X86_OPERSIZE: - common->opersize = (unsigned char)prefixes[i] & 0xff; - if (common->mode_bits == 64 && common->opersize == 64 && - def_opersize_64 != 64) { - if (!rex) - yasm_warn_set(YASM_WARN_GENERAL, - N_("ignoring REX prefix on jump")); - else if (*rex == 0xff) - yasm_warn_set(YASM_WARN_GENERAL, - N_("REX prefix not allowed on this instruction, ignoring")); - else - *rex = 0x48; - } - break; - case X86_SEGREG: - /* This is a hack.. we should really be putting this in the - * the effective address! - */ - common->lockrep_pre = (unsigned char)prefixes[i] & 0xff; - break; - case X86_REX: - if (!rex) - yasm_warn_set(YASM_WARN_GENERAL, - N_("ignoring REX prefix on jump")); - else if (*rex == 0xff) - yasm_warn_set(YASM_WARN_GENERAL, - N_("REX prefix not allowed on this instruction, ignoring")); - else { - if (*rex != 0) { - if (first) - yasm_warn_set(YASM_WARN_GENERAL, - N_("overriding generated REX prefix")); - else - yasm_warn_set(YASM_WARN_GENERAL, - N_("multiple REX prefixes, using leftmost")); - } - /* Here we assume that we can't get this prefix in non - * 64 bit mode due to checks in parse_check_prefix(). - */ - common->mode_bits = 64; - *rex = (unsigned char)prefixes[i] & 0xff; - } - first = 0; - break; - } + switch ((x86_parse_insn_prefix)prefixes[i][0]) { + case X86_LOCKREP: + if (common->lockrep_pre != 0) + yasm_warn_set(YASM_WARN_GENERAL, + N_("multiple LOCK or REP prefixes, using leftmost")); + common->lockrep_pre = (unsigned char)prefixes[i][1]; + break; + case X86_ADDRSIZE: + common->addrsize = (unsigned char)prefixes[i][1]; + break; + case X86_OPERSIZE: + common->opersize = (unsigned char)prefixes[i][1]; + if (common->mode_bits == 64 && common->opersize == 64 && + def_opersize_64 != 64) { + if (*rex == 0xff) + yasm_warn_set(YASM_WARN_GENERAL, + N_("REX prefix not allowed on this instruction, ignoring")); + else + *rex = 0x48; + } + break; + case X86_SEGREG: + /* This is a hack.. we should really be putting this in the + * the effective address! + */ + common->lockrep_pre = (unsigned char)prefixes[i][1]; + break; + case X86_REX: + if (!rex) + yasm_warn_set(YASM_WARN_GENERAL, + N_("ignoring REX prefix on jump")); + else if (*rex == 0xff) + yasm_warn_set(YASM_WARN_GENERAL, + N_("REX prefix not allowed on this instruction, ignoring")); + else { + if (*rex != 0) { + if (first) + yasm_warn_set(YASM_WARN_GENERAL, + N_("overriding generated REX prefix")); + else + yasm_warn_set(YASM_WARN_GENERAL, + N_("multiple REX prefixes, using leftmost")); + } + /* Here we assume that we can't get this prefix in non + * 64 bit mode due to checks in parse_check_prefix(). + */ + common->mode_bits = 64; + *rex = (unsigned char)prefixes[i][1]; + } + first = 0; + break; + } } } @@ -359,10 +353,10 @@ x86_bc_insn_destroy(void *contents) { x86_insn *insn = (x86_insn *)contents; if (insn->x86_ea) - yasm_x86__ea_destroy((yasm_effaddr *)insn->x86_ea); + yasm_ea_destroy((yasm_effaddr *)insn->x86_ea); if (insn->imm) { - yasm_value_delete(insn->imm); - yasm_xfree(insn->imm); + yasm_value_delete(insn->imm); + yasm_xfree(insn->imm); } yasm_xfree(contents); } @@ -384,54 +378,44 @@ x86_bc_jmpfar_destroy(void *contents) yasm_xfree(contents); } -void -yasm_x86__ea_destroy(yasm_effaddr *ea) +static void +x86_ea_destroy(yasm_effaddr *ea) { - yasm_value_delete(&ea->disp); - yasm_xfree(ea); } -void -yasm_x86__ea_print(const yasm_effaddr *ea, FILE *f, int indent_level) +static void +x86_ea_print(const yasm_effaddr *ea, FILE *f, int indent_level) { const x86_effaddr *x86_ea = (const x86_effaddr *)ea; - fprintf(f, "%*sDisp:\n", indent_level, ""); - yasm_value_print(&ea->disp, f, indent_level+1); - fprintf(f, "%*sNoSplit=%u\n", indent_level, "", (unsigned int)ea->nosplit); fprintf(f, "%*sSegmentOv=%02x\n", indent_level, "", - (unsigned int)x86_ea->ea.segreg); - fprintf(f, "%*sVSIBMode=%u\n", indent_level, "", - (unsigned int)x86_ea->vsib_mode); + (unsigned int)x86_ea->ea.segreg); fprintf(f, "%*sModRM=%03o ValidRM=%u NeedRM=%u\n", indent_level, "", - (unsigned int)x86_ea->modrm, (unsigned int)x86_ea->valid_modrm, - (unsigned int)x86_ea->need_modrm); + (unsigned int)x86_ea->modrm, (unsigned int)x86_ea->valid_modrm, + (unsigned int)x86_ea->need_modrm); fprintf(f, "%*sSIB=%03o ValidSIB=%u NeedSIB=%u\n", indent_level, "", - (unsigned int)x86_ea->sib, (unsigned int)x86_ea->valid_sib, - (unsigned int)x86_ea->need_sib); + (unsigned int)x86_ea->sib, (unsigned int)x86_ea->valid_sib, + (unsigned int)x86_ea->need_sib); } static void x86_common_print(const x86_common *common, FILE *f, int indent_level) { - fprintf(f, "%*sAddrSize=%u OperSize=%u LockRepPre=%02x " - "ACQREL_Pre=%02x BITS=%u\n", - indent_level, "", - (unsigned int)common->addrsize, - (unsigned int)common->opersize, - (unsigned int)common->lockrep_pre, - (unsigned int)common->acqrel_pre, - (unsigned int)common->mode_bits); + fprintf(f, "%*sAddrSize=%u OperSize=%u LockRepPre=%02x BITS=%u\n", + indent_level, "", + (unsigned int)common->addrsize, + (unsigned int)common->opersize, + (unsigned int)common->lockrep_pre, + (unsigned int)common->mode_bits); } static void x86_opcode_print(const x86_opcode *opcode, FILE *f, int indent_level) { - fprintf(f, "%*sOpcode: %02x %02x %02x %02x OpLen=%u\n", indent_level, "", - (unsigned int)opcode->opcode[0], - (unsigned int)opcode->opcode[1], - (unsigned int)opcode->opcode[2], - (unsigned int)opcode->opcode[3], - (unsigned int)opcode->len); + fprintf(f, "%*sOpcode: %02x %02x %02x OpLen=%u\n", indent_level, "", + (unsigned int)opcode->opcode[0], + (unsigned int)opcode->opcode[1], + (unsigned int)opcode->opcode[2], + (unsigned int)opcode->len); } static void @@ -442,25 +426,25 @@ x86_bc_insn_print(const void *contents, FILE *f, int indent_level) fprintf(f, "%*s_Instruction_\n", indent_level, ""); fprintf(f, "%*sEffective Address:", indent_level, ""); if (insn->x86_ea) { - fprintf(f, "\n"); - yasm_x86__ea_print((yasm_effaddr *)insn->x86_ea, f, indent_level+1); + fprintf(f, "\n"); + yasm_ea_print((yasm_effaddr *)insn->x86_ea, f, indent_level+1); } else - fprintf(f, " (nil)\n"); + fprintf(f, " (nil)\n"); fprintf(f, "%*sImmediate Value:", indent_level, ""); if (!insn->imm) - fprintf(f, " (nil)\n"); + fprintf(f, " (nil)\n"); else { - indent_level++; - fprintf(f, "\n"); - yasm_value_print(insn->imm, f, indent_level); - indent_level--; + indent_level++; + fprintf(f, "\n"); + yasm_value_print(insn->imm, f, indent_level); + indent_level--; } x86_opcode_print(&insn->opcode, f, indent_level); x86_common_print(&insn->common, f, indent_level); fprintf(f, "%*sSpPre=%02x REX=%03o PostOp=%u\n", indent_level, "", - (unsigned int)insn->special_prefix, - (unsigned int)insn->rex, - (unsigned int)insn->postop); + (unsigned int)insn->special_prefix, + (unsigned int)insn->rex, + (unsigned int)insn->postop); } static void @@ -477,34 +461,34 @@ x86_bc_jmp_print(const void *contents, FILE *f, int indent_level) */ fprintf(f, "\n%*sShort Form:\n", indent_level, ""); if (jmp->shortop.len == 0) - fprintf(f, "%*sNone\n", indent_level+1, ""); + fprintf(f, "%*sNone\n", indent_level+1, ""); else - x86_opcode_print(&jmp->shortop, f, indent_level+1); + x86_opcode_print(&jmp->shortop, f, indent_level+1); fprintf(f, "%*sNear Form:\n", indent_level, ""); if (jmp->nearop.len == 0) - fprintf(f, "%*sNone\n", indent_level+1, ""); + fprintf(f, "%*sNone\n", indent_level+1, ""); else - x86_opcode_print(&jmp->nearop, f, indent_level+1); + x86_opcode_print(&jmp->nearop, f, indent_level+1); fprintf(f, "%*sOpSel=", indent_level, ""); switch (jmp->op_sel) { - case JMP_NONE: - fprintf(f, "None"); - break; - case JMP_SHORT: - fprintf(f, "Short"); - break; - case JMP_NEAR: - fprintf(f, "Near"); - break; - case JMP_SHORT_FORCED: - fprintf(f, "Forced Short"); - break; - case JMP_NEAR_FORCED: - fprintf(f, "Forced Near"); - break; - default: - fprintf(f, "UNKNOWN!!"); - break; + case JMP_NONE: + fprintf(f, "None"); + break; + case JMP_SHORT: + fprintf(f, "Short"); + break; + case JMP_NEAR: + fprintf(f, "Near"); + break; + case JMP_SHORT_FORCED: + fprintf(f, "Forced Short"); + break; + case JMP_NEAR_FORCED: + fprintf(f, "Forced Near"); + break; + default: + fprintf(f, "UNKNOWN!!"); + break; } x86_common_print(&jmp->common, f, indent_level); } @@ -529,160 +513,133 @@ x86_common_calc_len(const x86_common *common) unsigned int len = 0; if (common->addrsize != 0 && common->addrsize != common->mode_bits) - len++; + len++; if (common->opersize != 0 && - ((common->mode_bits != 64 && common->opersize != common->mode_bits) || - (common->mode_bits == 64 && common->opersize == 16))) - len++; + ((common->mode_bits != 64 && common->opersize != common->mode_bits) || + (common->mode_bits == 64 && common->opersize == 16))) + len++; if (common->lockrep_pre != 0) - len++; - if (common->acqrel_pre != 0) - len++; - + len++; return len; } static int x86_bc_insn_calc_len(yasm_bytecode *bc, yasm_bc_add_span_func add_span, - void *add_span_data) + void *add_span_data) { x86_insn *insn = (x86_insn *)bc->contents; x86_effaddr *x86_ea = insn->x86_ea; yasm_value *imm = insn->imm; if (x86_ea) { - /* Check validity of effective address and calc R/M bits of - * Mod/RM byte and SIB byte. We won't know the Mod field - * of the Mod/RM byte until we know more about the - * displacement. - */ - if (yasm_x86__expr_checkea(x86_ea, &insn->common.addrsize, - insn->common.mode_bits, insn->postop == X86_POSTOP_ADDRESS16, - &insn->rex, bc)) - /* failed, don't bother checking rest of insn */ - return -1; + /* Check validity of effective address and calc R/M bits of + * Mod/RM byte and SIB byte. We won't know the Mod field + * of the Mod/RM byte until we know more about the + * displacement. + */ + if (yasm_x86__expr_checkea(x86_ea, &insn->common.addrsize, + insn->common.mode_bits, insn->postop == X86_POSTOP_ADDRESS16, + &insn->rex, bc)) + /* failed, don't bother checking rest of insn */ + return -1; - if (x86_ea->ea.disp.size == 0 && x86_ea->ea.need_nonzero_len) { - /* Handle unknown case, default to byte-sized and set as - * critical expression. - */ - x86_ea->ea.disp.size = 8; - add_span(add_span_data, bc, 1, &x86_ea->ea.disp, -128, 127); - } - bc->len += x86_ea->ea.disp.size/8; + if (x86_ea->ea.disp.size == 0 && x86_ea->ea.need_nonzero_len) { + /* Handle unknown case, default to byte-sized and set as + * critical expression. + */ + x86_ea->ea.disp.size = 8; + add_span(add_span_data, bc, 1, &x86_ea->ea.disp, -128, 127); + } + bc->len += x86_ea->ea.disp.size/8; - /* Handle address16 postop case */ - if (insn->postop == X86_POSTOP_ADDRESS16) - insn->common.addrsize = 0; + /* Handle address16 postop case */ + if (insn->postop == X86_POSTOP_ADDRESS16) + insn->common.addrsize = 0; - /* Compute length of ea and add to total */ - bc->len += x86_ea->need_modrm + (x86_ea->need_sib ? 1:0); - bc->len += (x86_ea->ea.segreg != 0) ? 1 : 0; + /* Compute length of ea and add to total */ + bc->len += x86_ea->need_modrm + (x86_ea->need_sib ? 1:0); + bc->len += (x86_ea->ea.segreg != 0) ? 1 : 0; } if (imm) { - unsigned int immlen = imm->size; + unsigned int immlen = imm->size; - /* TODO: check imm->len vs. sized len from expr? */ + /* TODO: check imm->len vs. sized len from expr? */ - /* Handle signext_imm8 postop special-casing */ - if (insn->postop == X86_POSTOP_SIGNEXT_IMM8) { - /*@null@*/ /*@only@*/ yasm_intnum *num; - num = yasm_value_get_intnum(imm, NULL, 0); + /* Handle signext_imm8 postop special-casing */ + if (insn->postop == X86_POSTOP_SIGNEXT_IMM8) { + /*@null@*/ /*@only@*/ yasm_intnum *num; + num = yasm_value_get_intnum(imm, NULL, 0); - if (!num) { - /* Unknown; default to byte form and set as critical - * expression. - */ - immlen = 8; - add_span(add_span_data, bc, 2, imm, -128, 127); - } else { - if (yasm_intnum_in_range(num, -128, 127)) { - /* We can use the sign-extended byte form: shorten - * the immediate length to 1 and make the byte form - * permanent. - */ - imm->size = 8; - imm->sign = 1; - immlen = 8; - } else { - /* We can't. Copy over the word-sized opcode. */ - insn->opcode.opcode[0] = - insn->opcode.opcode[insn->opcode.len]; - insn->opcode.len = 1; - } - insn->postop = X86_POSTOP_NONE; - yasm_intnum_destroy(num); - } - } + if (!num) { + /* Unknown; default to byte form and set as critical + * expression. + */ + immlen = 8; + add_span(add_span_data, bc, 2, imm, -128, 127); + } else { + if (yasm_intnum_in_range(num, -128, 127)) { + /* We can use the sign-extended byte form: shorten + * the immediate length to 1 and make the byte form + * permanent. + */ + imm->size = 8; + imm->sign = 1; + immlen = 8; + } else { + /* We can't. Copy over the word-sized opcode. */ + insn->opcode.opcode[0] = + insn->opcode.opcode[insn->opcode.len]; + insn->opcode.len = 1; + } + insn->postop = X86_POSTOP_NONE; + yasm_intnum_destroy(num); + } + } - bc->len += immlen/8; + bc->len += immlen/8; } - /* VEX and XOP prefixes never have REX (it's embedded in the opcode). - * For VEX, we can come into this function with the three byte form, - * so we need to see if we can optimize to the two byte form. - * We can't do it earlier, as we don't know all of the REX byte until now. - */ - if (insn->special_prefix == 0xC4) { - /* See if we can shorten the VEX prefix to its two byte form. - * In order to do this, REX.X, REX.B, and REX.W/VEX.W must all be 0, - * and the VEX mmmmm field must be 1. - */ - if ((insn->opcode.opcode[0] & 0x1F) == 1 && - (insn->opcode.opcode[1] & 0x80) == 0 && - (insn->rex == 0xff || (insn->rex & 0x0B) == 0)) { - insn->opcode.opcode[0] = insn->opcode.opcode[1]; - insn->opcode.opcode[1] = insn->opcode.opcode[2]; - insn->opcode.opcode[2] = 0; /* sanity */ - insn->opcode.len = 2; - insn->special_prefix = 0xC5; /* mark as two-byte VEX */ - } - } else if (insn->rex != 0xff && insn->rex != 0 && - insn->special_prefix != 0xC5 && insn->special_prefix != 0x8F) - bc->len++; - bc->len += insn->opcode.len; bc->len += x86_common_calc_len(&insn->common); bc->len += (insn->special_prefix != 0) ? 1:0; + if (insn->rex != 0xff && insn->rex != 0) + bc->len++; return 0; } static int x86_bc_insn_expand(yasm_bytecode *bc, int span, long old_val, long new_val, - /*@out@*/ long *neg_thres, /*@out@*/ long *pos_thres) + /*@out@*/ long *neg_thres, /*@out@*/ long *pos_thres) { x86_insn *insn = (x86_insn *)bc->contents; x86_effaddr *x86_ea = insn->x86_ea; - yasm_effaddr *ea = NULL; - yasm_value *imm; - if (x86_ea != NULL) - ea = &x86_ea->ea; - imm = insn->imm; + yasm_effaddr *ea = &x86_ea->ea; + yasm_value *imm = insn->imm; if (ea && span == 1) { - /* Change displacement length into word-sized */ - if (ea->disp.size == 8) { - ea->disp.size = (insn->common.addrsize == 16) ? 16 : 32; - x86_ea->modrm &= ~0300; - x86_ea->modrm |= 0200; - bc->len--; - bc->len += ea->disp.size/8; - } + /* Change displacement length into word-sized */ + if (ea->disp.size == 8) { + ea->disp.size = (insn->common.addrsize == 16) ? 16 : 32; + x86_ea->modrm &= ~0300; + x86_ea->modrm |= 0200; + bc->len--; + bc->len += ea->disp.size/8; + } } if (imm && span == 2) { - if (insn->postop == X86_POSTOP_SIGNEXT_IMM8) { - /* Update bc->len for new opcode and immediate size */ - bc->len -= insn->opcode.len; - bc->len += imm->size/8; + if (insn->postop == X86_POSTOP_SIGNEXT_IMM8) { + /* Update bc->len for new opcode and immediate size */ + bc->len -= insn->opcode.len; + bc->len += imm->size/8; - /* Change to the word-sized opcode */ - insn->opcode.opcode[0] = insn->opcode.opcode[insn->opcode.len]; - insn->opcode.len = 1; - insn->postop = X86_POSTOP_NONE; - } + /* Change to the word-sized opcode */ + insn->opcode.opcode[0] = insn->opcode.opcode[insn->opcode.len]; + insn->opcode.len = 1; + insn->postop = X86_POSTOP_NONE; + } } return 0; @@ -690,7 +647,7 @@ x86_bc_insn_expand(yasm_bytecode *bc, int span, long old_val, long new_val, static int x86_bc_jmp_calc_len(yasm_bytecode *bc, yasm_bc_add_span_func add_span, - void *add_span_data) + void *add_span_data) { x86_jmp *jmp = (x86_jmp *)bc->contents; yasm_bytecode *target_prevbc; @@ -698,86 +655,86 @@ x86_bc_jmp_calc_len(yasm_bytecode *bc, yasm_bc_add_span_func add_span, /* As opersize may be 0, figure out its "real" value. */ opersize = (jmp->common.opersize == 0) ? - jmp->common.mode_bits : jmp->common.opersize; + jmp->common.mode_bits : jmp->common.opersize; bc->len += x86_common_calc_len(&jmp->common); if (jmp->op_sel == JMP_NEAR_FORCED || jmp->shortop.len == 0) { - if (jmp->nearop.len == 0) { - yasm_error_set(YASM_ERROR_TYPE, N_("near jump does not exist")); - return -1; - } + if (jmp->nearop.len == 0) { + yasm_error_set(YASM_ERROR_TYPE, N_("near jump does not exist")); + return -1; + } - /* Near jump, no spans needed */ - if (jmp->shortop.len == 0) - jmp->op_sel = JMP_NEAR; - bc->len += jmp->nearop.len; - bc->len += (opersize == 16) ? 2 : 4; - return 0; + /* Near jump, no spans needed */ + if (jmp->shortop.len == 0) + jmp->op_sel = JMP_NEAR; + bc->len += jmp->nearop.len; + bc->len += (opersize == 16) ? 2 : 4; + return 0; } if (jmp->op_sel == JMP_SHORT_FORCED || jmp->nearop.len == 0) { - if (jmp->shortop.len == 0) { - yasm_error_set(YASM_ERROR_TYPE, N_("short jump does not exist")); - return -1; - } + if (jmp->shortop.len == 0) { + yasm_error_set(YASM_ERROR_TYPE, N_("short jump does not exist")); + return -1; + } - /* We want to be sure to error if we exceed short length, so - * put it in as a dependent expression (falling through). - */ + /* We want to be sure to error if we exceed short length, so + * put it in as a dependent expression (falling through). + */ } if (jmp->target.rel - && (!yasm_symrec_get_label(jmp->target.rel, &target_prevbc) - || target_prevbc->section != bc->section)) { - /* External or out of segment, so we can't check distance. - * Allowing short jumps depends on the objfmt supporting - * 8-bit relocs. While most don't, some might, so allow it here. - * Otherwise default to word-sized. - * The objfmt will error if not supported. - */ - if (jmp->op_sel == JMP_SHORT_FORCED || jmp->nearop.len == 0) { - if (jmp->op_sel == JMP_NONE) - jmp->op_sel = JMP_SHORT; - bc->len += jmp->shortop.len + 1; - } else { - jmp->op_sel = JMP_NEAR; - bc->len += jmp->nearop.len; - bc->len += (opersize == 16) ? 2 : 4; - } - return 0; + && (!yasm_symrec_get_label(jmp->target.rel, &target_prevbc) + || target_prevbc->section != bc->section)) { + /* External or out of segment, so we can't check distance. + * Allowing short jumps depends on the objfmt supporting + * 8-bit relocs. While most don't, some might, so allow it here. + * Otherwise default to word-sized. + * The objfmt will error if not supported. + */ + if (jmp->op_sel == JMP_SHORT_FORCED || jmp->nearop.len == 0) { + if (jmp->op_sel == JMP_NONE) + jmp->op_sel = JMP_SHORT; + bc->len += jmp->shortop.len + 1; + } else { + jmp->op_sel = JMP_NEAR; + bc->len += jmp->nearop.len; + bc->len += (opersize == 16) ? 2 : 4; + } + return 0; } /* Default to short jump and generate span */ if (jmp->op_sel == JMP_NONE) - jmp->op_sel = JMP_SHORT; + jmp->op_sel = JMP_SHORT; bc->len += jmp->shortop.len + 1; add_span(add_span_data, bc, 1, &jmp->target, -128+(long)bc->len, - 127+(long)bc->len); + 127+(long)bc->len); return 0; } static int x86_bc_jmp_expand(yasm_bytecode *bc, int span, long old_val, long new_val, - /*@out@*/ long *neg_thres, /*@out@*/ long *pos_thres) + /*@out@*/ long *neg_thres, /*@out@*/ long *pos_thres) { x86_jmp *jmp = (x86_jmp *)bc->contents; unsigned char opersize; if (span != 1) - yasm_internal_error(N_("unrecognized span id")); + yasm_internal_error(N_("unrecognized span id")); /* As opersize may be 0, figure out its "real" value. */ opersize = (jmp->common.opersize == 0) ? - jmp->common.mode_bits : jmp->common.opersize; + jmp->common.mode_bits : jmp->common.opersize; if (jmp->op_sel == JMP_SHORT_FORCED || jmp->nearop.len == 0) { - yasm_error_set(YASM_ERROR_VALUE, N_("short jump out of range")); - return -1; + yasm_error_set(YASM_ERROR_VALUE, N_("short jump out of range")); + return -1; } if (jmp->op_sel == JMP_NEAR) - yasm_internal_error(N_("trying to expand an already-near jump")); + yasm_internal_error(N_("trying to expand an already-near jump")); /* Upgrade to a near jump */ jmp->op_sel = JMP_NEAR; @@ -790,16 +747,16 @@ x86_bc_jmp_expand(yasm_bytecode *bc, int span, long old_val, long new_val, static int x86_bc_jmpfar_calc_len(yasm_bytecode *bc, yasm_bc_add_span_func add_span, - void *add_span_data) + void *add_span_data) { x86_jmpfar *jmpfar = (x86_jmpfar *)bc->contents; unsigned char opersize; opersize = (jmpfar->common.opersize == 0) ? - jmpfar->common.mode_bits : jmpfar->common.opersize; + jmpfar->common.mode_bits : jmpfar->common.opersize; bc->len += jmpfar->opcode.len; - bc->len += 2; /* segment */ + bc->len += 2; /* segment */ bc->len += (opersize == 16) ? 2 : 4; bc->len += x86_common_calc_len(&jmpfar->common); @@ -808,21 +765,18 @@ x86_bc_jmpfar_calc_len(yasm_bytecode *bc, yasm_bc_add_span_func add_span, static void x86_common_tobytes(const x86_common *common, unsigned char **bufp, - unsigned int segreg) + unsigned int segreg) { if (segreg != 0) - YASM_WRITE_8(*bufp, (unsigned char)segreg); + YASM_WRITE_8(*bufp, (unsigned char)segreg); if (common->addrsize != 0 && common->addrsize != common->mode_bits) - YASM_WRITE_8(*bufp, 0x67); + YASM_WRITE_8(*bufp, 0x67); if (common->opersize != 0 && - ((common->mode_bits != 64 && common->opersize != common->mode_bits) || - (common->mode_bits == 64 && common->opersize == 16))) - YASM_WRITE_8(*bufp, 0x66); - /*TSX hints come before lock prefix*/ - if (common->acqrel_pre != 0) - YASM_WRITE_8(*bufp, common->acqrel_pre); + ((common->mode_bits != 64 && common->opersize != common->mode_bits) || + (common->mode_bits == 64 && common->opersize == 16))) + YASM_WRITE_8(*bufp, 0x66); if (common->lockrep_pre != 0) - YASM_WRITE_8(*bufp, common->lockrep_pre); + YASM_WRITE_8(*bufp, common->lockrep_pre); } static void @@ -830,46 +784,28 @@ x86_opcode_tobytes(const x86_opcode *opcode, unsigned char **bufp) { unsigned int i; for (i=0; ilen; i++) - YASM_WRITE_8(*bufp, opcode->opcode[i]); + YASM_WRITE_8(*bufp, opcode->opcode[i]); } static int -x86_bc_insn_tobytes(yasm_bytecode *bc, unsigned char **bufp, - unsigned char *bufstart, void *d, - yasm_output_value_func output_value, - /*@unused@*/ yasm_output_reloc_func output_reloc) +x86_bc_insn_tobytes(yasm_bytecode *bc, unsigned char **bufp, void *d, + yasm_output_value_func output_value, + /*@unused@*/ yasm_output_reloc_func output_reloc) { x86_insn *insn = (x86_insn *)bc->contents; /*@null@*/ x86_effaddr *x86_ea = (x86_effaddr *)insn->x86_ea; yasm_value *imm = insn->imm; + unsigned char *bufp_orig = *bufp; /* Prefixes */ x86_common_tobytes(&insn->common, bufp, - x86_ea ? (unsigned int)(x86_ea->ea.segreg>>8) : 0); + x86_ea ? (unsigned int)(x86_ea->ea.segreg>>8) : 0); if (insn->special_prefix != 0) - YASM_WRITE_8(*bufp, insn->special_prefix); - if (insn->special_prefix == 0xC4 || insn->special_prefix == 0x8F) { - /* 3-byte VEX/XOP; merge in 1s complement of REX.R, REX.X, REX.B */ - insn->opcode.opcode[0] &= 0x1F; - if (insn->rex != 0xff) - insn->opcode.opcode[0] |= ((~insn->rex) & 0x07) << 5; - /* merge REX.W via ORing; there should never be a case in which REX.W - * is important when VEX.W is already set by the instruction. - */ - if (insn->rex != 0xff && (insn->rex & 0x8) != 0) - insn->opcode.opcode[1] |= 0x80; - } else if (insn->special_prefix == 0xC5) { - /* 2-byte VEX; merge in 1s complement of REX.R */ - insn->opcode.opcode[0] &= 0x7F; - if (insn->rex != 0xff && (insn->rex & 0x4) == 0) - insn->opcode.opcode[0] |= 0x80; - /* No other REX bits should be set */ - if (insn->rex != 0xff && (insn->rex & 0xB) != 0) - yasm_internal_error(N_("x86: REX.WXB set, but 2-byte VEX")); - } else if (insn->rex != 0xff && insn->rex != 0) { - if (insn->common.mode_bits != 64) - yasm_internal_error(N_("x86: got a REX prefix in non-64-bit mode")); - YASM_WRITE_8(*bufp, insn->rex); + YASM_WRITE_8(*bufp, insn->special_prefix); + if (insn->rex != 0xff && insn->rex != 0) { + if (insn->common.mode_bits != 64) + yasm_internal_error(N_("x86: got a REX prefix in non-64-bit mode")); + YASM_WRITE_8(*bufp, insn->rex); } /* Opcode */ @@ -879,71 +815,71 @@ x86_bc_insn_tobytes(yasm_bytecode *bc, unsigned char **bufp, * displacement (if required). */ if (x86_ea) { - if (x86_ea->need_modrm) { - if (!x86_ea->valid_modrm) - yasm_internal_error(N_("invalid Mod/RM in x86 tobytes_insn")); - YASM_WRITE_8(*bufp, x86_ea->modrm); - } + if (x86_ea->need_modrm) { + if (!x86_ea->valid_modrm) + yasm_internal_error(N_("invalid Mod/RM in x86 tobytes_insn")); + YASM_WRITE_8(*bufp, x86_ea->modrm); + } - if (x86_ea->need_sib) { - if (!x86_ea->valid_sib) - yasm_internal_error(N_("invalid SIB in x86 tobytes_insn")); - YASM_WRITE_8(*bufp, x86_ea->sib); - } + if (x86_ea->need_sib) { + if (!x86_ea->valid_sib) + yasm_internal_error(N_("invalid SIB in x86 tobytes_insn")); + YASM_WRITE_8(*bufp, x86_ea->sib); + } - if (x86_ea->ea.need_disp) { - unsigned int disp_len = x86_ea->ea.disp.size/8; + if (x86_ea->ea.need_disp) { + unsigned int disp_len = x86_ea->ea.disp.size/8; - if (x86_ea->ea.disp.ip_rel) { - /* Adjust relative displacement to end of bytecode */ - /*@only@*/ yasm_intnum *delta; - delta = yasm_intnum_create_int(-(long)bc->len); - if (!x86_ea->ea.disp.abs) - x86_ea->ea.disp.abs = - yasm_expr_create_ident(yasm_expr_int(delta), bc->line); - else - x86_ea->ea.disp.abs = - yasm_expr_create(YASM_EXPR_ADD, - yasm_expr_expr(x86_ea->ea.disp.abs), - yasm_expr_int(delta), bc->line); - } - if (output_value(&x86_ea->ea.disp, *bufp, disp_len, - (unsigned long)(*bufp-bufstart), bc, 1, d)) - return 1; - *bufp += disp_len; - } + if (x86_ea->ea.disp.ip_rel) { + /* Adjust relative displacement to end of bytecode */ + /*@only@*/ yasm_intnum *delta; + delta = yasm_intnum_create_int(-(long)bc->len); + if (!x86_ea->ea.disp.abs) + x86_ea->ea.disp.abs = + yasm_expr_create_ident(yasm_expr_int(delta), bc->line); + else + x86_ea->ea.disp.abs = + yasm_expr_create(YASM_EXPR_ADD, + yasm_expr_expr(x86_ea->ea.disp.abs), + yasm_expr_int(delta), bc->line); + } + if (output_value(&x86_ea->ea.disp, *bufp, disp_len, + (unsigned long)(*bufp-bufp_orig), bc, 1, d)) + return 1; + *bufp += disp_len; + } } /* Immediate (if required) */ if (imm) { - unsigned int imm_len; - if (insn->postop == X86_POSTOP_SIGNEXT_IMM8) { - /* If we got here with this postop still set, we need to force - * imm size to 8 here. - */ - imm->size = 8; - imm->sign = 1; - imm_len = 1; - } else - imm_len = imm->size/8; - if (output_value(imm, *bufp, imm_len, (unsigned long)(*bufp-bufstart), - bc, 1, d)) - return 1; - *bufp += imm_len; + unsigned int imm_len; + if (insn->postop == X86_POSTOP_SIGNEXT_IMM8) { + /* If we got here with this postop still set, we need to force + * imm size to 8 here. + */ + imm->size = 8; + imm->sign = 1; + imm_len = 1; + } else + imm_len = imm->size/8; + if (output_value(imm, *bufp, imm_len, (unsigned long)(*bufp-bufp_orig), + bc, 1, d)) + return 1; + *bufp += imm_len; } return 0; } static int -x86_bc_jmp_tobytes(yasm_bytecode *bc, unsigned char **bufp, - unsigned char *bufstart, void *d, - yasm_output_value_func output_value, - /*@unused@*/ yasm_output_reloc_func output_reloc) +x86_bc_jmp_tobytes(yasm_bytecode *bc, unsigned char **bufp, void *d, + yasm_output_value_func output_value, + /*@unused@*/ yasm_output_reloc_func output_reloc) { x86_jmp *jmp = (x86_jmp *)bc->contents; unsigned char opersize; unsigned int i; + unsigned char *bufp_orig = *bufp; /*@only@*/ yasm_intnum *delta; /* Prefixes */ @@ -951,85 +887,83 @@ x86_bc_jmp_tobytes(yasm_bytecode *bc, unsigned char **bufp, /* As opersize may be 0, figure out its "real" value. */ opersize = (jmp->common.opersize == 0) ? - jmp->common.mode_bits : jmp->common.opersize; + jmp->common.mode_bits : jmp->common.opersize; /* Check here again to see if forms are actually legal. */ switch (jmp->op_sel) { - case JMP_SHORT_FORCED: - case JMP_SHORT: - /* 1 byte relative displacement */ - if (jmp->shortop.len == 0) - yasm_internal_error(N_("short jump does not exist")); + case JMP_SHORT_FORCED: + case JMP_SHORT: + /* 1 byte relative displacement */ + if (jmp->shortop.len == 0) + yasm_internal_error(N_("short jump does not exist")); - /* Opcode */ - x86_opcode_tobytes(&jmp->shortop, bufp); + /* Opcode */ + x86_opcode_tobytes(&jmp->shortop, bufp); - /* Adjust relative displacement to end of bytecode */ - delta = yasm_intnum_create_int(-(long)bc->len); - if (!jmp->target.abs) - jmp->target.abs = yasm_expr_create_ident(yasm_expr_int(delta), - bc->line); - else - jmp->target.abs = - yasm_expr_create(YASM_EXPR_ADD, - yasm_expr_expr(jmp->target.abs), - yasm_expr_int(delta), bc->line); + /* Adjust relative displacement to end of bytecode */ + delta = yasm_intnum_create_int(-(long)bc->len); + if (!jmp->target.abs) + jmp->target.abs = yasm_expr_create_ident(yasm_expr_int(delta), + bc->line); + else + jmp->target.abs = + yasm_expr_create(YASM_EXPR_ADD, + yasm_expr_expr(jmp->target.abs), + yasm_expr_int(delta), bc->line); - jmp->target.size = 8; - jmp->target.sign = 1; - if (output_value(&jmp->target, *bufp, 1, - (unsigned long)(*bufp-bufstart), bc, 1, d)) - return 1; - *bufp += 1; - break; - case JMP_NEAR_FORCED: - case JMP_NEAR: - /* 2/4 byte relative displacement (depending on operand size) */ - if (jmp->nearop.len == 0) { - yasm_error_set(YASM_ERROR_TYPE, - N_("near jump does not exist")); - return 1; - } + jmp->target.size = 8; + if (output_value(&jmp->target, *bufp, 1, + (unsigned long)(*bufp-bufp_orig), bc, -1, d)) + return 1; + *bufp += 1; + break; + case JMP_NEAR_FORCED: + case JMP_NEAR: + /* 2/4 byte relative displacement (depending on operand size) */ + if (jmp->nearop.len == 0) { + yasm_error_set(YASM_ERROR_TYPE, + N_("near jump does not exist")); + return 1; + } - /* Opcode */ - x86_opcode_tobytes(&jmp->nearop, bufp); + /* Opcode */ + x86_opcode_tobytes(&jmp->nearop, bufp); - i = (opersize == 16) ? 2 : 4; + i = (opersize == 16) ? 2 : 4; - /* Adjust relative displacement to end of bytecode */ - delta = yasm_intnum_create_int(-(long)bc->len); - if (!jmp->target.abs) - jmp->target.abs = yasm_expr_create_ident(yasm_expr_int(delta), - bc->line); - else - jmp->target.abs = - yasm_expr_create(YASM_EXPR_ADD, - yasm_expr_expr(jmp->target.abs), - yasm_expr_int(delta), bc->line); + /* Adjust relative displacement to end of bytecode */ + delta = yasm_intnum_create_int(-(long)bc->len); + if (!jmp->target.abs) + jmp->target.abs = yasm_expr_create_ident(yasm_expr_int(delta), + bc->line); + else + jmp->target.abs = + yasm_expr_create(YASM_EXPR_ADD, + yasm_expr_expr(jmp->target.abs), + yasm_expr_int(delta), bc->line); - jmp->target.size = i*8; - jmp->target.sign = 1; - if (output_value(&jmp->target, *bufp, i, - (unsigned long)(*bufp-bufstart), bc, 1, d)) - return 1; - *bufp += i; - break; - case JMP_NONE: - yasm_internal_error(N_("jump op_sel cannot be JMP_NONE in tobytes")); - default: - yasm_internal_error(N_("unrecognized relative jump op_sel")); + jmp->target.size = i*8; + if (output_value(&jmp->target, *bufp, i, + (unsigned long)(*bufp-bufp_orig), bc, -1, d)) + return 1; + *bufp += i; + break; + case JMP_NONE: + yasm_internal_error(N_("jump op_sel cannot be JMP_NONE in tobytes")); + default: + yasm_internal_error(N_("unrecognized relative jump op_sel")); } return 0; } static int -x86_bc_jmpfar_tobytes(yasm_bytecode *bc, unsigned char **bufp, - unsigned char *bufstart, void *d, - yasm_output_value_func output_value, - /*@unused@*/ yasm_output_reloc_func output_reloc) +x86_bc_jmpfar_tobytes(yasm_bytecode *bc, unsigned char **bufp, void *d, + yasm_output_value_func output_value, + /*@unused@*/ yasm_output_reloc_func output_reloc) { x86_jmpfar *jmpfar = (x86_jmpfar *)bc->contents; unsigned int i; + unsigned char *bufp_orig = *bufp; unsigned char opersize; x86_common_tobytes(&jmpfar->common, bufp, 0); @@ -1037,19 +971,19 @@ x86_bc_jmpfar_tobytes(yasm_bytecode *bc, unsigned char **bufp, /* As opersize may be 0, figure out its "real" value. */ opersize = (jmpfar->common.opersize == 0) ? - jmpfar->common.mode_bits : jmpfar->common.opersize; + jmpfar->common.mode_bits : jmpfar->common.opersize; /* Absolute displacement: segment and offset */ i = (opersize == 16) ? 2 : 4; jmpfar->offset.size = i*8; if (output_value(&jmpfar->offset, *bufp, i, - (unsigned long)(*bufp-bufstart), bc, 1, d)) - return 1; + (unsigned long)(*bufp-bufp_orig), bc, 1, d)) + return 1; *bufp += i; jmpfar->segment.size = 16; if (output_value(&jmpfar->segment, *bufp, 2, - (unsigned long)(*bufp-bufstart), bc, 1, d)) - return 1; + (unsigned long)(*bufp-bufp_orig), bc, 1, d)) + return 1; *bufp += 2; return 0; @@ -1057,8 +991,8 @@ x86_bc_jmpfar_tobytes(yasm_bytecode *bc, unsigned char **bufp, int yasm_x86__intnum_tobytes(yasm_arch *arch, const yasm_intnum *intn, - unsigned char *buf, size_t destsize, size_t valsize, - int shift, const yasm_bytecode *bc, int warn) + unsigned char *buf, size_t destsize, size_t valsize, + int shift, const yasm_bytecode *bc, int warn) { /* Write value out. */ yasm_intnum_get_sized(intn, buf, destsize, valsize, shift, 0, warn); diff --git a/modules/arch/x86/x86cpu.gperf b/modules/arch/x86/x86cpu.gperf deleted file mode 100644 index 334ea1c8..00000000 --- a/modules/arch/x86/x86cpu.gperf +++ /dev/null @@ -1,496 +0,0 @@ -# -# x86 CPU recognition -# -# Copyright (C) 2002-2007 Peter Johnson -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND OTHER CONTRIBUTORS ``AS IS'' -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR OTHER CONTRIBUTORS BE -# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -%{ -#include - -#include -#include -#include - -#include "modules/arch/x86/x86arch.h" - -#define PROC_8086 0 -#define PROC_186 1 -#define PROC_286 2 -#define PROC_386 3 -#define PROC_486 4 -#define PROC_586 5 -#define PROC_686 6 -#define PROC_p2 7 -#define PROC_p3 8 -#define PROC_p4 9 -#define PROC_prescott 10 -#define PROC_conroe 11 -#define PROC_penryn 12 -#define PROC_nehalem 13 -#define PROC_westmere 14 -#define PROC_sandybridge 15 -#define PROC_ivybridge 16 -#define PROC_haswell 17 -#define PROC_broadwell 18 -#define PROC_skylake 19 - -static void -x86_cpu_intel(wordptr cpu, yasm_arch_x86 *arch_x86, unsigned int data) -{ - BitVector_Empty(cpu); - - BitVector_Bit_On(cpu, CPU_Priv); - if (data >= PROC_286) - BitVector_Bit_On(cpu, CPU_Prot); - if (data >= PROC_386) - BitVector_Bit_On(cpu, CPU_SMM); - if (data >= PROC_skylake) { - BitVector_Bit_On(cpu, CPU_SHA); - } - if (data >= PROC_broadwell) { - BitVector_Bit_On(cpu, CPU_RDSEED); - BitVector_Bit_On(cpu, CPU_ADX); - BitVector_Bit_On(cpu, CPU_PRFCHW); - } - if (data >= PROC_haswell) { - BitVector_Bit_On(cpu, CPU_FMA); - BitVector_Bit_On(cpu, CPU_AVX2); - BitVector_Bit_On(cpu, CPU_BMI1); - BitVector_Bit_On(cpu, CPU_BMI2); - BitVector_Bit_On(cpu, CPU_INVPCID); - BitVector_Bit_On(cpu, CPU_LZCNT); - BitVector_Bit_On(cpu, CPU_TSX); - BitVector_Bit_On(cpu, CPU_SMAP); - } - if (data >= PROC_ivybridge) { - BitVector_Bit_On(cpu, CPU_F16C); - BitVector_Bit_On(cpu, CPU_FSGSBASE); - BitVector_Bit_On(cpu, CPU_RDRAND); - } - if (data >= PROC_sandybridge) { - BitVector_Bit_On(cpu, CPU_AVX); - BitVector_Bit_On(cpu, CPU_XSAVEOPT); - BitVector_Bit_On(cpu, CPU_EPTVPID); - BitVector_Bit_On(cpu, CPU_SMX); - } - if (data >= PROC_westmere) { - BitVector_Bit_On(cpu, CPU_AES); - BitVector_Bit_On(cpu, CPU_CLMUL); - } - if (data >= PROC_nehalem) { - BitVector_Bit_On(cpu, CPU_SSE42); - BitVector_Bit_On(cpu, CPU_XSAVE); - } - if (data >= PROC_penryn) - BitVector_Bit_On(cpu, CPU_SSE41); - if (data >= PROC_conroe) - BitVector_Bit_On(cpu, CPU_SSSE3); - if (data >= PROC_prescott) - BitVector_Bit_On(cpu, CPU_SSE3); - if (data >= PROC_p4) - BitVector_Bit_On(cpu, CPU_SSE2); - if (data >= PROC_p3) - BitVector_Bit_On(cpu, CPU_SSE); - if (data >= PROC_p2) - BitVector_Bit_On(cpu, CPU_MMX); - if (data >= PROC_486) - BitVector_Bit_On(cpu, CPU_FPU); - if (data >= PROC_prescott) - BitVector_Bit_On(cpu, CPU_EM64T); - - if (data >= PROC_p4) - BitVector_Bit_On(cpu, CPU_P4); - if (data >= PROC_p3) - BitVector_Bit_On(cpu, CPU_P3); - if (data >= PROC_686) - BitVector_Bit_On(cpu, CPU_686); - if (data >= PROC_586) - BitVector_Bit_On(cpu, CPU_586); - if (data >= PROC_486) - BitVector_Bit_On(cpu, CPU_486); - if (data >= PROC_386) - BitVector_Bit_On(cpu, CPU_386); - if (data >= PROC_286) - BitVector_Bit_On(cpu, CPU_286); - if (data >= PROC_186) - BitVector_Bit_On(cpu, CPU_186); - BitVector_Bit_On(cpu, CPU_086); - - /* Use Intel long NOPs if 686 or better */ - if (data >= PROC_686) - arch_x86->nop = X86_NOP_INTEL; - else - arch_x86->nop = X86_NOP_BASIC; -} - -static void -x86_cpu_ia64(wordptr cpu, yasm_arch_x86 *arch_x86, unsigned int data) -{ - BitVector_Empty(cpu); - BitVector_Bit_On(cpu, CPU_Priv); - BitVector_Bit_On(cpu, CPU_Prot); - BitVector_Bit_On(cpu, CPU_SMM); - BitVector_Bit_On(cpu, CPU_SSE2); - BitVector_Bit_On(cpu, CPU_SSE); - BitVector_Bit_On(cpu, CPU_MMX); - BitVector_Bit_On(cpu, CPU_FPU); - BitVector_Bit_On(cpu, CPU_IA64); - BitVector_Bit_On(cpu, CPU_P4); - BitVector_Bit_On(cpu, CPU_P3); - BitVector_Bit_On(cpu, CPU_686); - BitVector_Bit_On(cpu, CPU_586); - BitVector_Bit_On(cpu, CPU_486); - BitVector_Bit_On(cpu, CPU_386); - BitVector_Bit_On(cpu, CPU_286); - BitVector_Bit_On(cpu, CPU_186); - BitVector_Bit_On(cpu, CPU_086); -} - -#define PROC_bulldozer 11 -#define PROC_k10 10 -#define PROC_venice 9 -#define PROC_hammer 8 -#define PROC_k7 7 -#define PROC_k6 6 - -static void -x86_cpu_amd(wordptr cpu, yasm_arch_x86 *arch_x86, unsigned int data) -{ - BitVector_Empty(cpu); - - BitVector_Bit_On(cpu, CPU_Priv); - BitVector_Bit_On(cpu, CPU_Prot); - BitVector_Bit_On(cpu, CPU_SMM); - BitVector_Bit_On(cpu, CPU_3DNow); - if (data >= PROC_bulldozer) { - BitVector_Bit_On(cpu, CPU_XOP); - BitVector_Bit_On(cpu, CPU_FMA4); - } - if (data >= PROC_k10) - BitVector_Bit_On(cpu, CPU_SSE4a); - if (data >= PROC_venice) - BitVector_Bit_On(cpu, CPU_SSE3); - if (data >= PROC_hammer) - BitVector_Bit_On(cpu, CPU_SSE2); - if (data >= PROC_k7) - BitVector_Bit_On(cpu, CPU_SSE); - if (data >= PROC_k6) - BitVector_Bit_On(cpu, CPU_MMX); - BitVector_Bit_On(cpu, CPU_FPU); - - if (data >= PROC_hammer) - BitVector_Bit_On(cpu, CPU_Hammer); - if (data >= PROC_k7) - BitVector_Bit_On(cpu, CPU_Athlon); - if (data >= PROC_k6) - BitVector_Bit_On(cpu, CPU_K6); - BitVector_Bit_On(cpu, CPU_686); - BitVector_Bit_On(cpu, CPU_586); - BitVector_Bit_On(cpu, CPU_486); - BitVector_Bit_On(cpu, CPU_386); - BitVector_Bit_On(cpu, CPU_286); - BitVector_Bit_On(cpu, CPU_186); - BitVector_Bit_On(cpu, CPU_086); - - /* Use AMD long NOPs if k6 or better */ - if (data >= PROC_k6) - arch_x86->nop = X86_NOP_AMD; - else - arch_x86->nop = X86_NOP_BASIC; -} - -static void -x86_cpu_set(wordptr cpu, yasm_arch_x86 *arch_x86, unsigned int data) -{ - BitVector_Bit_On(cpu, data); -} - -static void -x86_cpu_clear(wordptr cpu, yasm_arch_x86 *arch_x86, unsigned int data) -{ - BitVector_Bit_Off(cpu, data); -} - -static void -x86_cpu_set_sse4(wordptr cpu, yasm_arch_x86 *arch_x86, unsigned int data) -{ - BitVector_Bit_On(cpu, CPU_SSE41); - BitVector_Bit_On(cpu, CPU_SSE42); -} - -static void -x86_cpu_clear_sse4(wordptr cpu, yasm_arch_x86 *arch_x86, unsigned int data) -{ - BitVector_Bit_Off(cpu, CPU_SSE41); - BitVector_Bit_Off(cpu, CPU_SSE42); -} - -static void -x86_nop(wordptr cpu, yasm_arch_x86 *arch_x86, unsigned int data) -{ - arch_x86->nop = data; -} - -%} -%ignore-case -%language=ANSI-C -%compare-strncmp -%readonly-tables -%enum -%struct-type -%define hash-function-name cpu_hash -%define lookup-function-name cpu_find -struct cpu_parse_data { - const char *name; - void (*handler) (wordptr cpu, yasm_arch_x86 *arch_x86, unsigned int data); - unsigned int data; -}; -%% -8086, x86_cpu_intel, PROC_8086 -186, x86_cpu_intel, PROC_186 -80186, x86_cpu_intel, PROC_186 -i186, x86_cpu_intel, PROC_186 -286, x86_cpu_intel, PROC_286 -80286, x86_cpu_intel, PROC_286 -i286, x86_cpu_intel, PROC_286 -386, x86_cpu_intel, PROC_386 -80386, x86_cpu_intel, PROC_386 -i386, x86_cpu_intel, PROC_386 -486, x86_cpu_intel, PROC_486 -80486, x86_cpu_intel, PROC_486 -i486, x86_cpu_intel, PROC_486 -586, x86_cpu_intel, PROC_586 -i586, x86_cpu_intel, PROC_586 -pentium, x86_cpu_intel, PROC_586 -p5, x86_cpu_intel, PROC_586 -686, x86_cpu_intel, PROC_686 -i686, x86_cpu_intel, PROC_686 -p6, x86_cpu_intel, PROC_686 -ppro, x86_cpu_intel, PROC_686 -pentiumpro, x86_cpu_intel, PROC_686 -p2, x86_cpu_intel, PROC_p2 -pentium2, x86_cpu_intel, PROC_p2 -pentium-2, x86_cpu_intel, PROC_p2 -pentiumii, x86_cpu_intel, PROC_p2 -pentium-ii, x86_cpu_intel, PROC_p2 -p3, x86_cpu_intel, PROC_p3 -pentium3, x86_cpu_intel, PROC_p3 -pentium-3, x86_cpu_intel, PROC_p3 -pentiumiii, x86_cpu_intel, PROC_p3 -pentium-iii, x86_cpu_intel, PROC_p3 -katmai, x86_cpu_intel, PROC_p3 -p4, x86_cpu_intel, PROC_p4 -pentium4, x86_cpu_intel, PROC_p4 -pentium-4, x86_cpu_intel, PROC_p4 -pentiumiv, x86_cpu_intel, PROC_p4 -pentium-iv, x86_cpu_intel, PROC_p4 -williamette, x86_cpu_intel, PROC_p4 -ia64, x86_cpu_ia64, 0 -ia-64, x86_cpu_ia64, 0 -itanium, x86_cpu_ia64, 0 -k6, x86_cpu_amd, PROC_k6 -k7, x86_cpu_amd, PROC_k7 -athlon, x86_cpu_amd, PROC_k7 -k8, x86_cpu_amd, PROC_hammer -hammer, x86_cpu_amd, PROC_hammer -clawhammer, x86_cpu_amd, PROC_hammer -opteron, x86_cpu_amd, PROC_hammer -athlon64, x86_cpu_amd, PROC_hammer -athlon-64, x86_cpu_amd, PROC_hammer -venice, x86_cpu_amd, PROC_venice -k10, x86_cpu_amd, PROC_k10 -phenom, x86_cpu_amd, PROC_k10 -family10h, x86_cpu_amd, PROC_k10 -bulldozer, x86_cpu_amd, PROC_bulldozer -prescott, x86_cpu_intel, PROC_prescott -conroe, x86_cpu_intel, PROC_conroe -core2, x86_cpu_intel, PROC_conroe -penryn, x86_cpu_intel, PROC_penryn -nehalem, x86_cpu_intel, PROC_nehalem -corei7, x86_cpu_intel, PROC_nehalem -westmere, x86_cpu_intel, PROC_westmere -sandybridge, x86_cpu_intel, PROC_sandybridge -ivybridge, x86_cpu_intel, PROC_ivybridge -haswell, x86_cpu_intel, PROC_haswell -broadwell, x86_cpu_intel, PROC_broadwell -skylake, x86_cpu_intel, PROC_skylake -# -# Features have "no" versions to disable them, and only set/reset the -# specific feature being changed. All other bits are left alone. -# -fpu, x86_cpu_set, CPU_FPU -nofpu, x86_cpu_clear, CPU_FPU -mmx, x86_cpu_set, CPU_MMX -nommx, x86_cpu_clear, CPU_MMX -sse, x86_cpu_set, CPU_SSE -nosse, x86_cpu_clear, CPU_SSE -sse2, x86_cpu_set, CPU_SSE2 -nosse2, x86_cpu_clear, CPU_SSE2 -sse3, x86_cpu_set, CPU_SSE3 -nosse3, x86_cpu_clear, CPU_SSE3 -#pni, x86_cpu_set, CPU_PNI -#nopni, x86_cpu_clear, CPU_PNI -3dnow, x86_cpu_set, CPU_3DNow -no3dnow, x86_cpu_clear, CPU_3DNow -cyrix, x86_cpu_set, CPU_Cyrix -nocyrix, x86_cpu_clear, CPU_Cyrix -amd, x86_cpu_set, CPU_AMD -noamd, x86_cpu_clear, CPU_AMD -smm, x86_cpu_set, CPU_SMM -nosmm, x86_cpu_clear, CPU_SMM -prot, x86_cpu_set, CPU_Prot -noprot, x86_cpu_clear, CPU_Prot -protected, x86_cpu_set, CPU_Prot -noprotected, x86_cpu_clear, CPU_Prot -undoc, x86_cpu_set, CPU_Undoc -noundoc, x86_cpu_clear, CPU_Undoc -undocumented, x86_cpu_set, CPU_Undoc -noundocumented, x86_cpu_clear, CPU_Undoc -obs, x86_cpu_set, CPU_Obs -noobs, x86_cpu_clear, CPU_Obs -obsolete, x86_cpu_set, CPU_Obs -noobsolete, x86_cpu_clear, CPU_Obs -priv, x86_cpu_set, CPU_Priv -nopriv, x86_cpu_clear, CPU_Priv -privileged, x86_cpu_set, CPU_Priv -noprivileged, x86_cpu_clear, CPU_Priv -svm, x86_cpu_set, CPU_SVM -nosvm, x86_cpu_clear, CPU_SVM -padlock, x86_cpu_set, CPU_PadLock -nopadlock, x86_cpu_clear, CPU_PadLock -em64t, x86_cpu_set, CPU_EM64T -noem64t, x86_cpu_clear, CPU_EM64T -ssse3, x86_cpu_set, CPU_SSSE3 -nossse3, x86_cpu_clear, CPU_SSSE3 -sse4.1, x86_cpu_set, CPU_SSE41 -nosse4.1, x86_cpu_clear, CPU_SSE41 -sse41, x86_cpu_set, CPU_SSE41 -nosse41, x86_cpu_clear, CPU_SSE41 -sse4.2, x86_cpu_set, CPU_SSE42 -nosse4.2, x86_cpu_clear, CPU_SSE42 -sse42, x86_cpu_set, CPU_SSE42 -nosse42, x86_cpu_clear, CPU_SSE42 -sse4a, x86_cpu_set, CPU_SSE4a -nosse4a, x86_cpu_clear, CPU_SSE4a -sse4, x86_cpu_set_sse4, 0 -nosse4, x86_cpu_clear_sse4, 0 -xsave, x86_cpu_set, CPU_XSAVE -noxsave, x86_cpu_clear, CPU_XSAVE -avx, x86_cpu_set, CPU_AVX -noavx, x86_cpu_clear, CPU_AVX -fma, x86_cpu_set, CPU_FMA -nofma, x86_cpu_clear, CPU_FMA -aes, x86_cpu_set, CPU_AES -noaes, x86_cpu_clear, CPU_AES -clmul, x86_cpu_set, CPU_CLMUL -noclmul, x86_cpu_clear, CPU_CLMUL -pclmulqdq, x86_cpu_set, CPU_CLMUL -nopclmulqdq, x86_cpu_clear, CPU_CLMUL -movbe, x86_cpu_set, CPU_MOVBE -nomovbe, x86_cpu_clear, CPU_MOVBE -xop, x86_cpu_set, CPU_XOP -noxop, x86_cpu_clear, CPU_XOP -fma4, x86_cpu_set, CPU_FMA4 -nofma4, x86_cpu_clear, CPU_FMA4 -f16c, x86_cpu_set, CPU_F16C -nof16c, x86_cpu_clear, CPU_F16C -fsgsbase, x86_cpu_set, CPU_FSGSBASE -nofsgsbase, x86_cpu_clear, CPU_FSGSBASE -rdrand, x86_cpu_set, CPU_RDRAND -nordrand, x86_cpu_clear, CPU_RDRAND -xsaveopt, x86_cpu_set, CPU_XSAVEOPT -noxsaveopt, x86_cpu_clear, CPU_XSAVEOPT -eptvpid, x86_cpu_set, CPU_EPTVPID -noeptvpid, x86_cpu_clear, CPU_EPTVPID -smx, x86_cpu_set, CPU_SMX -nosmx, x86_cpu_clear, CPU_SMX -avx2, x86_cpu_set, CPU_AVX2 -noavx2, x86_cpu_clear, CPU_AVX2 -tsx, x86_cpu_set, CPU_TSX -notsx, x86_cpu_clear, CPU_TSX -bmi1, x86_cpu_set, CPU_BMI1 -nobmi1, x86_cpu_clear, CPU_BMI1 -bmi2, x86_cpu_set, CPU_BMI2 -nobmi2, x86_cpu_clear, CPU_BMI2 -invpcid, x86_cpu_set, CPU_INVPCID -noinvpcid, x86_cpu_clear, CPU_INVPCID -lzcnt, x86_cpu_set, CPU_LZCNT -nolzcnt, x86_cpu_clear, CPU_LZCNT -tbm, x86_cpu_set, CPU_TBM -notbm, x86_cpu_clear, CPU_TBM -sha, x86_cpu_set, CPU_SHA -nosha, x86_cpu_clear, CPU_SHA -smap, x86_cpu_set, CPU_SMAP -nosmap, x86_cpu_clear, CPU_SMAP -rdseed, x86_cpu_set, CPU_RDSEED -nordseed, x86_cpu_clear, CPU_RDSEED -adx, x86_cpu_set, CPU_ADX -noadx, x86_cpu_clear, CPU_ADX -prfchw, x86_cpu_set, CPU_PRFCHW -noprfchw, x86_cpu_clear, CPU_PRFCHW -# Change NOP patterns -basicnop, x86_nop, X86_NOP_BASIC -intelnop, x86_nop, X86_NOP_INTEL -amdnop, x86_nop, X86_NOP_AMD -%% - -void -yasm_x86__parse_cpu(yasm_arch_x86 *arch_x86, const char *cpuid, - size_t cpuid_len) -{ - /*@null@*/ const struct cpu_parse_data *pdata; - wordptr new_cpu; - size_t i; - static char lcaseid[16]; - - if (cpuid_len > 15) - return; - for (i=0; icpu_enables[arch_x86->active_cpu]); - pdata->handler(new_cpu, arch_x86, pdata->data); - - /* try to find an existing match in the CPU table first */ - for (i=0; icpu_enables_size; i++) { - if (BitVector_equal(arch_x86->cpu_enables[i], new_cpu)) { - arch_x86->active_cpu = i; - BitVector_Destroy(new_cpu); - return; - } - } - - /* not found, need to add a new entry */ - arch_x86->active_cpu = arch_x86->cpu_enables_size++; - arch_x86->cpu_enables = - yasm_xrealloc(arch_x86->cpu_enables, - arch_x86->cpu_enables_size*sizeof(wordptr)); - arch_x86->cpu_enables[arch_x86->active_cpu] = new_cpu; -} diff --git a/modules/arch/x86/x86expr.c b/modules/arch/x86/x86expr.c index e9ddcce5..de73b204 100644 --- a/modules/arch/x86/x86expr.c +++ b/modules/arch/x86/x86expr.c @@ -25,15 +25,17 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include +/*@unused@*/ RCSID("$Id$"); +#define YASM_LIB_INTERNAL +#define YASM_EXPR_INTERNAL #include #include "x86arch.h" typedef struct x86_checkea_reg3264_data { - int *regs; /* total multiplier for each reg */ - unsigned char vsib_mode; + int *regs; /* total multiplier for each reg */ unsigned char bits; unsigned char addrsize; } x86_checkea_reg3264_data; @@ -43,42 +45,28 @@ typedef struct x86_checkea_reg3264_data { */ static /*@null@*/ /*@dependent@*/ int * x86_expr_checkea_get_reg3264(yasm_expr__item *ei, int *regnum, - /*returned*/ void *d) + /*returned*/ void *d) { x86_checkea_reg3264_data *data = d; switch ((x86_expritem_reg_size)(ei->data.reg & ~0xFUL)) { - case X86_REG32: - if (data->addrsize != 32) - return 0; - *regnum = (unsigned int)(ei->data.reg & 0xF); - break; - case X86_REG64: - if (data->addrsize != 64) - return 0; - *regnum = (unsigned int)(ei->data.reg & 0xF); - break; - case X86_XMMREG: - if (data->vsib_mode != 1) - return 0; - if (data->bits != 64 && (ei->data.reg & 0x8) == 0x8) - return 0; - *regnum = 17+(unsigned int)(ei->data.reg & 0xF); - break; - case X86_YMMREG: - if (data->vsib_mode != 2) - return 0; - if (data->bits != 64 && (ei->data.reg & 0x8) == 0x8) - return 0; - *regnum = 17+(unsigned int)(ei->data.reg & 0xF); - break; - case X86_RIP: - if (data->bits != 64) - return 0; - *regnum = 16; - break; - default: - return 0; + case X86_REG32: + if (data->addrsize != 32) + return 0; + *regnum = (unsigned int)(ei->data.reg & 0xF); + break; + case X86_REG64: + if (data->addrsize != 64) + return 0; + *regnum = (unsigned int)(ei->data.reg & 0xF); + break; + case X86_RIP: + if (data->bits != 64) + return 0; + *regnum = 16; + break; + default: + return 0; } /* overwrite with 0 to eliminate register from displacement expr */ @@ -90,7 +78,7 @@ x86_expr_checkea_get_reg3264(yasm_expr__item *ei, int *regnum, } typedef struct x86_checkea_reg16_data { - int bx, si, di, bp; /* total multiplier for each reg */ + int bx, si, di, bp; /* total multiplier for each reg */ } x86_checkea_reg16_data; /* Only works if ei->type == EXPR_REG (doesn't check). @@ -112,14 +100,14 @@ x86_expr_checkea_get_reg16(yasm_expr__item *ei, int *regnum, void *d) /* don't allow 32-bit registers */ if ((ei->data.reg & ~0xFUL) != X86_REG16) - return 0; + return 0; /* & 7 for sanity check */ *regnum = (unsigned int)(ei->data.reg & 0x7); /* only allow BX, SI, DI, BP */ if (!reg16[*regnum]) - return 0; + return 0; /* overwrite with 0 to eliminate register from displacement expr */ ei->type = YASM_EXPR_INT; @@ -154,95 +142,95 @@ x86_expr_checkea_distcheck_reg(yasm_expr **ep, unsigned int bits) yasm_expr *e = *ep; int i; int havereg = -1, havereg_expr = -1; - int retval = 1; /* default to legal, no changes */ + int retval = 1; /* default to legal, no changes */ for (i=0; inumterms; i++) { - switch (e->terms[i].type) { - case YASM_EXPR_REG: - /* Check op to make sure it's valid to use w/register. */ - switch (e->op) { - case YASM_EXPR_MUL: - /* Check for reg*reg */ - if (havereg != -1) - return 0; - break; - case YASM_EXPR_ADD: - case YASM_EXPR_IDENT: - break; - default: - return 0; - } - havereg = i; - break; - case YASM_EXPR_FLOAT: - /* Floats not allowed. */ - return 0; - case YASM_EXPR_EXPR: - if (yasm_expr__contains(e->terms[i].data.expn, - YASM_EXPR_REG)) { - int ret2; + switch (e->terms[i].type) { + case YASM_EXPR_REG: + /* Check op to make sure it's valid to use w/register. */ + switch (e->op) { + case YASM_EXPR_MUL: + /* Check for reg*reg */ + if (havereg != -1) + return 0; + break; + case YASM_EXPR_ADD: + case YASM_EXPR_IDENT: + break; + default: + return 0; + } + havereg = i; + break; + case YASM_EXPR_FLOAT: + /* Floats not allowed. */ + return 0; + case YASM_EXPR_EXPR: + if (yasm_expr__contains(e->terms[i].data.expn, + YASM_EXPR_REG)) { + int ret2; - /* Check op to make sure it's valid to use w/register. */ - if (e->op != YASM_EXPR_ADD && e->op != YASM_EXPR_MUL) - return 0; - /* Check for reg*reg */ - if (e->op == YASM_EXPR_MUL && havereg != -1) - return 0; - havereg = i; - havereg_expr = i; - /* Recurse to check lower levels */ - ret2 = - x86_expr_checkea_distcheck_reg(&e->terms[i].data.expn, - bits); - if (ret2 == 0) - return 0; - if (ret2 == 2) - retval = 2; - } else if (yasm_expr__contains(e->terms[i].data.expn, - YASM_EXPR_FLOAT)) - return 0; /* Disallow floats */ - break; - default: - break; - } + /* Check op to make sure it's valid to use w/register. */ + if (e->op != YASM_EXPR_ADD && e->op != YASM_EXPR_MUL) + return 0; + /* Check for reg*reg */ + if (e->op == YASM_EXPR_MUL && havereg != -1) + return 0; + havereg = i; + havereg_expr = i; + /* Recurse to check lower levels */ + ret2 = + x86_expr_checkea_distcheck_reg(&e->terms[i].data.expn, + bits); + if (ret2 == 0) + return 0; + if (ret2 == 2) + retval = 2; + } else if (yasm_expr__contains(e->terms[i].data.expn, + YASM_EXPR_FLOAT)) + return 0; /* Disallow floats */ + break; + default: + break; + } } /* just exit if no registers were used */ if (havereg == -1) - return retval; + return retval; /* Distribute */ if (e->op == YASM_EXPR_MUL && havereg_expr != -1) { - yasm_expr *ne; + yasm_expr *ne; - retval = 2; /* we're going to change it */ + retval = 2; /* we're going to change it */ - /* The reg expn *must* be EXPR_ADD at this point. Sanity check. */ - if (e->terms[havereg_expr].type != YASM_EXPR_EXPR || - e->terms[havereg_expr].data.expn->op != YASM_EXPR_ADD) - yasm_internal_error(N_("Register expression not ADD or EXPN")); + /* The reg expn *must* be EXPR_ADD at this point. Sanity check. */ + if (e->terms[havereg_expr].type != YASM_EXPR_EXPR || + e->terms[havereg_expr].data.expn->op != YASM_EXPR_ADD) + yasm_internal_error(N_("Register expression not ADD or EXPN")); - /* Iterate over each term in reg expn */ - for (i=0; iterms[havereg_expr].data.expn->numterms; i++) { - /* Copy everything EXCEPT havereg_expr term into new expression */ - ne = yasm_expr__copy_except(e, havereg_expr); - assert(ne != NULL); - /* Copy reg expr term into uncopied (empty) term in new expn */ - ne->terms[havereg_expr] = - e->terms[havereg_expr].data.expn->terms[i]; /* struct copy */ - /* Overwrite old reg expr term with new expn */ - e->terms[havereg_expr].data.expn->terms[i].type = YASM_EXPR_EXPR; - e->terms[havereg_expr].data.expn->terms[i].data.expn = ne; - } + /* Iterate over each term in reg expn */ + for (i=0; iterms[havereg_expr].data.expn->numterms; i++) { + /* Copy everything EXCEPT havereg_expr term into new expression */ + ne = yasm_expr__copy_except(e, havereg_expr); + assert(ne != NULL); + /* Copy reg expr term into uncopied (empty) term in new expn */ + ne->terms[havereg_expr] = + e->terms[havereg_expr].data.expn->terms[i]; /* struct copy */ + /* Overwrite old reg expr term with new expn */ + e->terms[havereg_expr].data.expn->terms[i].type = YASM_EXPR_EXPR; + e->terms[havereg_expr].data.expn->terms[i].data.expn = ne; + } - /* Replace e with expanded reg expn */ - ne = e->terms[havereg_expr].data.expn; - e->terms[havereg_expr].type = YASM_EXPR_NONE; /* don't delete it! */ - yasm_expr_destroy(e); /* but everything else */ - e = ne; - /*@-onlytrans@*/ - *ep = ne; - /*@=onlytrans@*/ + /* Replace e with expanded reg expn */ + ne = e->terms[havereg_expr].data.expn; + e->terms[havereg_expr].type = YASM_EXPR_NONE; /* don't delete it! */ + yasm_expr_destroy(e); /* but everything else */ + e = ne; + /*@-onlytrans@*/ + *ep = ne; + /*@=onlytrans@*/ } return retval; @@ -276,145 +264,122 @@ x86_expr_checkea_getregusage(yasm_expr **ep, /*@null@*/ int *indexreg, /* Check for WRT rip first */ wrt = yasm_expr_extract_wrt(ep); if (wrt && wrt->op == YASM_EXPR_IDENT && - wrt->terms[0].type == YASM_EXPR_REG) { - if (bits != 64) { /* only valid in 64-bit mode */ - yasm_expr_destroy(wrt); - return 1; - } - reg = get_reg(&wrt->terms[0], ®num, data); - if (!reg || regnum != 16) { /* only accept rip */ - yasm_expr_destroy(wrt); - return 1; - } - (*reg)++; + wrt->terms[0].type == YASM_EXPR_REG) { + if (bits != 64) { /* only valid in 64-bit mode */ + yasm_expr_destroy(wrt); + return 1; + } + reg = get_reg(&wrt->terms[0], ®num, data); + if (!reg || regnum != 16) { /* only accept rip */ + yasm_expr_destroy(wrt); + return 1; + } + (*reg)++; - /* Delete WRT. Set pcrel to 1 to indicate to x86 - * bytecode code to do PC-relative displacement transform. - */ - *pcrel = 1; - yasm_expr_destroy(wrt); + /* Delete WRT. Set pcrel to 1 to indicate to x86 + * bytecode code to do PC-relative displacement transform. + */ + *pcrel = 1; + yasm_expr_destroy(wrt); } else if (wrt) { - yasm_expr_destroy(wrt); - return 1; + yasm_expr_destroy(wrt); + return 1; } /*@=unqualifiedtrans@*/ assert(*ep != NULL); e = *ep; switch (x86_expr_checkea_distcheck_reg(ep, bits)) { - case 0: - return 1; - case 2: - /* Need to simplify again */ - *ep = yasm_expr__level_tree(*ep, 1, 1, indexreg == 0, 0, NULL, - NULL); - e = *ep; - break; - default: - break; + case 0: + return 1; + case 2: + /* Need to simplify again */ + *ep = yasm_expr__level_tree(*ep, 1, 1, indexreg == 0, 0, NULL, + NULL); + e = *ep; + break; + default: + break; } switch (e->op) { - case YASM_EXPR_ADD: - /* Prescan for non-int multipliers against a reg. - * This is invalid due to the optimizer structure. - */ - for (i=0; inumterms; i++) - if (e->terms[i].type == YASM_EXPR_EXPR) { - yasm_expr__order_terms(e->terms[i].data.expn); - if (e->terms[i].data.expn->terms[0].type == - YASM_EXPR_REG) { - if (e->terms[i].data.expn->numterms > 2) - return 1; - if (e->terms[i].data.expn->terms[1].type != - YASM_EXPR_INT) - return 1; - } - } + case YASM_EXPR_ADD: + /* Prescan for non-int multipliers against a reg. + * This is invalid due to the optimizer structure. + */ + for (i=0; inumterms; i++) + if (e->terms[i].type == YASM_EXPR_EXPR) { + yasm_expr__order_terms(e->terms[i].data.expn); + if (e->terms[i].data.expn->terms[0].type == + YASM_EXPR_REG) { + if (e->terms[i].data.expn->numterms > 2) + return 1; + if (e->terms[i].data.expn->terms[1].type != + YASM_EXPR_INT) + return 1; + } + } - /*@fallthrough@*/ - case YASM_EXPR_IDENT: - /* Check each term for register (and possible multiplier). */ - for (i=0; inumterms; i++) { - if (e->terms[i].type == YASM_EXPR_REG) { - reg = get_reg(&e->terms[i], ®num, data); - if (!reg) - return 1; - (*reg)++; - /* Let last, largest multipler win indexreg */ - if (indexreg && *reg > 0 && indexval <= *reg && - !indexmult) { - *indexreg = regnum; - indexval = *reg; - } - } else if (e->terms[i].type == YASM_EXPR_EXPR) { - /* Already ordered from ADD above, just grab the value. - * Sanity check for EXPR_INT. - */ - if (e->terms[i].data.expn->terms[0].type == - YASM_EXPR_REG) { - long delta; - if (e->terms[i].data.expn->terms[1].type != - YASM_EXPR_INT) - yasm_internal_error( - N_("Non-integer value in reg expn")); - reg = get_reg(&e->terms[i].data.expn->terms[0], - ®num, data); - if (!reg) - return 1; - delta = yasm_intnum_get_int( - e->terms[i].data.expn->terms[1].data.intn); - (*reg) += delta; - /* Let last, largest multipler win indexreg */ - if (indexreg && delta > 0 && indexval <= *reg) { - *indexreg = regnum; - indexval = *reg; - indexmult = 1; - } else if (indexreg && *indexreg == regnum && - delta < 0 && *reg <= 1) { - *indexreg = -1; - indexval = 0; - indexmult = 0; - } - } - } - } - break; - case YASM_EXPR_MUL: - /* Here, too, check for non-int multipliers against a reg. */ - yasm_expr__order_terms(e); - if (e->terms[0].type == YASM_EXPR_REG) { - long delta; - if (e->numterms > 2) - return 1; - if (e->terms[1].type != YASM_EXPR_INT) - return 1; - reg = get_reg(&e->terms[0], ®num, data); - if (!reg) - return 1; - delta = yasm_intnum_get_int(e->terms[1].data.intn); - (*reg) += delta; - if (indexreg) - { - if (delta < 0 && *reg <= 1) - { - *indexreg = -1; - indexval = 0; - indexmult = 0; - } - else - *indexreg = regnum; - } - } - break; - case YASM_EXPR_SEGOFF: - /* No registers are allowed on either side. */ - if (yasm_expr__contains(e, YASM_EXPR_REG)) - return 1; - break; - default: - /* Should never get here! */ - yasm_internal_error(N_("unexpected expr op")); + /*@fallthrough@*/ + case YASM_EXPR_IDENT: + /* Check each term for register (and possible multiplier). */ + for (i=0; inumterms; i++) { + if (e->terms[i].type == YASM_EXPR_REG) { + reg = get_reg(&e->terms[i], ®num, data); + if (!reg) + return 1; + (*reg)++; + /* Let last, largest multipler win indexreg */ + if (indexreg && *reg > 0 && indexval <= *reg && + !indexmult) { + *indexreg = regnum; + indexval = *reg; + } + } else if (e->terms[i].type == YASM_EXPR_EXPR) { + /* Already ordered from ADD above, just grab the value. + * Sanity check for EXPR_INT. + */ + if (e->terms[i].data.expn->terms[0].type == + YASM_EXPR_REG) { + if (e->terms[i].data.expn->terms[1].type != + YASM_EXPR_INT) + yasm_internal_error( + N_("Non-integer value in reg expn")); + reg = get_reg(&e->terms[i].data.expn->terms[0], + ®num, data); + if (!reg) + return 1; + (*reg) += yasm_intnum_get_int( + e->terms[i].data.expn->terms[1].data.intn); + /* Let last, largest multipler win indexreg */ + if (indexreg && *reg > 0 && indexval <= *reg) { + *indexreg = regnum; + indexval = *reg; + indexmult = 1; + } + } + } + } + break; + case YASM_EXPR_MUL: + /* Here, too, check for non-int multipliers against a reg. */ + yasm_expr__order_terms(e); + if (e->terms[0].type == YASM_EXPR_REG) { + if (e->numterms > 2) + return 1; + if (e->terms[1].type != YASM_EXPR_INT) + return 1; + reg = get_reg(&e->terms[0], ®num, data); + if (!reg) + return 1; + (*reg) += yasm_intnum_get_int(e->terms[1].data.intn); + if (indexreg) + *indexreg = regnum; + } + break; + default: + /* Should never get here! */ + yasm_internal_error(N_("unexpected expr op")); } /* Simplify expr, which is now really just the displacement. This @@ -437,78 +402,78 @@ x86_expr_checkea_getregusage(yasm_expr **ep, /*@null@*/ int *indexreg, /*@-nullstate@*/ static int x86_checkea_calc_displen(x86_effaddr *x86_ea, unsigned int wordsize, int noreg, - int dispreq) + int dispreq) { /*@null@*/ /*@only@*/ yasm_intnum *num; - x86_ea->valid_modrm = 0; /* default to not yet valid */ + x86_ea->valid_modrm = 0; /* default to not yet valid */ switch (x86_ea->ea.disp.size) { - case 0: - break; - /* If not 0, the displacement length was forced; set the Mod bits - * appropriately and we're done with the ModRM byte. - */ - case 8: - /* Byte is only a valid override if there are registers in the - * EA. With no registers, we must have a 16/32 value. - */ - if (noreg) { - yasm_warn_set(YASM_WARN_IMPLICIT_SIZE_OVERRIDE, - N_("invalid displacement size; fixed")); - x86_ea->ea.disp.size = wordsize; - } else - x86_ea->modrm |= 0100; - x86_ea->valid_modrm = 1; - return 0; - case 16: - case 32: - /* Don't allow changing displacement different from BITS setting - * directly; require an address-size override to change it. - */ - if (wordsize != x86_ea->ea.disp.size) { - yasm_error_set(YASM_ERROR_VALUE, - N_("invalid effective address (displacement size)")); - return 1; - } - if (!noreg) - x86_ea->modrm |= 0200; - x86_ea->valid_modrm = 1; - return 0; - default: - /* we shouldn't ever get any other size! */ - yasm_internal_error(N_("strange EA displacement size")); + case 0: + break; + /* If not 0, the displacement length was forced; set the Mod bits + * appropriately and we're done with the ModRM byte. + */ + case 8: + /* Byte is only a valid override if there are registers in the + * EA. With no registers, we must have a 16/32 value. + */ + if (noreg) { + yasm_warn_set(YASM_WARN_GENERAL, + N_("invalid displacement size; fixed")); + x86_ea->ea.disp.size = wordsize; + } else + x86_ea->modrm |= 0100; + x86_ea->valid_modrm = 1; + return 0; + case 16: + case 32: + /* Don't allow changing displacement different from BITS setting + * directly; require an address-size override to change it. + */ + if (wordsize != x86_ea->ea.disp.size) { + yasm_error_set(YASM_ERROR_VALUE, + N_("invalid effective address (displacement size)")); + return 1; + } + if (!noreg) + x86_ea->modrm |= 0200; + x86_ea->valid_modrm = 1; + return 0; + default: + /* we shouldn't ever get any other size! */ + yasm_internal_error(N_("strange EA displacement size")); } /* The displacement length hasn't been forced (or the forcing wasn't * valid), try to determine what it is. */ if (noreg) { - /* No register in ModRM expression, so it must be disp16/32, - * and as the Mod bits are set to 0 by the caller, we're done - * with the ModRM byte. - */ - x86_ea->ea.disp.size = wordsize; - x86_ea->valid_modrm = 1; - return 0; + /* No register in ModRM expression, so it must be disp16/32, + * and as the Mod bits are set to 0 by the caller, we're done + * with the ModRM byte. + */ + x86_ea->ea.disp.size = wordsize; + x86_ea->valid_modrm = 1; + return 0; } if (dispreq) { - /* for BP/EBP, there *must* be a displacement value, but we - * may not know the size (8 or 16/32) for sure right now. - */ - x86_ea->ea.need_nonzero_len = 1; + /* for BP/EBP, there *must* be a displacement value, but we + * may not know the size (8 or 16/32) for sure right now. + */ + x86_ea->ea.need_nonzero_len = 1; } if (x86_ea->ea.disp.rel) { - /* Relative displacement; basically all object formats need non-byte - * for relocation here, so just do that. (TODO: handle this - * differently?) - */ - x86_ea->ea.disp.size = wordsize; - x86_ea->modrm |= 0200; - x86_ea->valid_modrm = 1; - return 0; + /* Relative displacement; basically all object formats need non-byte + * for relocation here, so just do that. (TODO: handle this + * differently?) + */ + x86_ea->ea.disp.size = wordsize; + x86_ea->modrm |= 0200; + x86_ea->valid_modrm = 1; + return 0; } /* At this point there's 3 possibilities for the displacement: @@ -522,33 +487,33 @@ x86_checkea_calc_displen(x86_effaddr *x86_ea, unsigned int wordsize, int noreg, */ num = yasm_value_get_intnum(&x86_ea->ea.disp, NULL, 0); if (!num) { - /* Still has unknown values. */ - x86_ea->ea.need_nonzero_len = 1; - x86_ea->modrm |= 0100; - x86_ea->valid_modrm = 1; - return 0; + /* Still has unknown values. */ + x86_ea->ea.need_nonzero_len = 1; + x86_ea->modrm |= 0100; + x86_ea->valid_modrm = 1; + return 0; } /* Figure out what size displacement we will have. */ if (yasm_intnum_is_zero(num) && !x86_ea->ea.need_nonzero_len) { - /* If we know that the displacement is 0 right now, - * go ahead and delete the expr and make it so no - * displacement value is included in the output. - * The Mod bits of ModRM are set to 0 above, and - * we're done with the ModRM byte! - */ - yasm_value_delete(&x86_ea->ea.disp); - x86_ea->ea.need_disp = 0; + /* If we know that the displacement is 0 right now, + * go ahead and delete the expr and make it so no + * displacement value is included in the output. + * The Mod bits of ModRM are set to 0 above, and + * we're done with the ModRM byte! + */ + yasm_value_delete(&x86_ea->ea.disp); + x86_ea->ea.need_disp = 0; } else if (yasm_intnum_in_range(num, -128, 127)) { - /* It fits into a signed byte */ - x86_ea->ea.disp.size = 8; - x86_ea->modrm |= 0100; + /* It fits into a signed byte */ + x86_ea->ea.disp.size = 8; + x86_ea->modrm |= 0100; } else { - /* It's a 16/32-bit displacement */ - x86_ea->ea.disp.size = wordsize; - x86_ea->modrm |= 0200; + /* It's a 16/32-bit displacement */ + x86_ea->ea.disp.size = wordsize; + x86_ea->modrm |= 0200; } - x86_ea->valid_modrm = 1; /* We're done with ModRM */ + x86_ea->valid_modrm = 1; /* We're done with ModRM */ yasm_intnum_destroy(num); return 0; @@ -561,499 +526,449 @@ x86_expr_checkea_getregsize_callback(yasm_expr__item *ei, void *d) unsigned char *addrsize = (unsigned char *)d; if (ei->type == YASM_EXPR_REG) { - switch ((x86_expritem_reg_size)(ei->data.reg & ~0xFUL)) { - case X86_REG16: - *addrsize = 16; - break; - case X86_REG32: - *addrsize = 32; - break; - case X86_REG64: - case X86_RIP: - *addrsize = 64; - break; - default: - return 0; - } - return 1; + switch ((x86_expritem_reg_size)(ei->data.reg & ~0xFUL)) { + case X86_REG16: + *addrsize = 16; + break; + case X86_REG32: + *addrsize = 32; + break; + case X86_REG64: + case X86_RIP: + *addrsize = 64; + break; + default: + return 0; + } + return 1; } else - return 0; + return 0; } int yasm_x86__expr_checkea(x86_effaddr *x86_ea, unsigned char *addrsize, - unsigned int bits, int address16_op, unsigned char *rex, - yasm_bytecode *bc) + unsigned int bits, int address16_op, unsigned char *rex, + yasm_bytecode *bc) { int retval; if (*addrsize == 0) { - /* we need to figure out the address size from what we know about: - * - the displacement length - * - what registers are used in the expression - * - the bits setting - */ - switch (x86_ea->ea.disp.size) { - case 16: - /* must be 16-bit */ - *addrsize = 16; - break; - case 64: - /* We have to support this for the MemOffs case, but it's - * otherwise illegal. It's also illegal in non-64-bit mode. - */ - if (x86_ea->need_modrm || x86_ea->need_sib) { - yasm_error_set(YASM_ERROR_VALUE, - N_("invalid effective address (displacement size)")); - return 1; - } - *addrsize = 64; - break; - case 32: - /* Must be 32-bit in 16-bit or 32-bit modes. In 64-bit mode, - * we don't know unless we look at the registers, except in the - * MemOffs case (see the end of this function). - */ - if (bits != 64 || (!x86_ea->need_modrm && !x86_ea->need_sib)) { - *addrsize = 32; - break; - } - /*@fallthrough@*/ - default: - /* If SIB is required, but we're in 16-bit mode, set to 32. */ - if (bits == 16 && x86_ea->need_sib == 1) { - *addrsize = 32; - break; - } - /* check for use of 16 or 32-bit registers; if none are used - * default to bits setting. - */ - if (!x86_ea->ea.disp.abs || - !yasm_expr__traverse_leaves_in(x86_ea->ea.disp.abs, - addrsize, x86_expr_checkea_getregsize_callback)) - *addrsize = bits; - /* TODO: Add optional warning here if switched address size - * from bits setting just by register use.. eg [ax] in - * 32-bit mode would generate a warning. - */ - } + /* we need to figure out the address size from what we know about: + * - the displacement length + * - what registers are used in the expression + * - the bits setting + */ + switch (x86_ea->ea.disp.size) { + case 16: + /* must be 16-bit */ + *addrsize = 16; + break; + case 64: + /* We have to support this for the MemOffs case, but it's + * otherwise illegal. It's also illegal in non-64-bit mode. + */ + if (x86_ea->need_modrm || x86_ea->need_sib) { + yasm_error_set(YASM_ERROR_VALUE, + N_("invalid effective address (displacement size)")); + return 1; + } + *addrsize = 64; + break; + case 32: + /* Must be 32-bit in 16-bit or 32-bit modes. In 64-bit mode, + * we don't know unless we look at the registers, except in the + * MemOffs case (see the end of this function). + */ + if (bits != 64 || (!x86_ea->need_modrm && !x86_ea->need_sib)) { + *addrsize = 32; + break; + } + /*@fallthrough@*/ + default: + /* check for use of 16 or 32-bit registers; if none are used + * default to bits setting. + */ + if (!x86_ea->ea.disp.abs || + !yasm_expr__traverse_leaves_in(x86_ea->ea.disp.abs, + addrsize, x86_expr_checkea_getregsize_callback)) + *addrsize = bits; + /* TODO: Add optional warning here if switched address size + * from bits setting just by register use.. eg [ax] in + * 32-bit mode would generate a warning. + */ + } } if ((*addrsize == 32 || *addrsize == 64) && - ((x86_ea->need_modrm && !x86_ea->valid_modrm) || - (x86_ea->need_sib && !x86_ea->valid_sib))) { - int i; - unsigned char low3; - enum { - REG3264_NONE = -1, - REG3264_EAX = 0, - REG3264_ECX, - REG3264_EDX, - REG3264_EBX, - REG3264_ESP, - REG3264_EBP, - REG3264_ESI, - REG3264_EDI, - REG64_R8, - REG64_R9, - REG64_R10, - REG64_R11, - REG64_R12, - REG64_R13, - REG64_R14, - REG64_R15, - REG64_RIP, - SIMDREGS - }; - int reg3264mult[33] = - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; - x86_checkea_reg3264_data reg3264_data; - int basereg = REG3264_NONE; /* "base" register (for SIB) */ - int indexreg = REG3264_NONE; /* "index" register (for SIB) */ - int regcount = 17; /* normally don't check SIMD regs */ + ((x86_ea->need_modrm && !x86_ea->valid_modrm) || + (x86_ea->need_sib && !x86_ea->valid_sib))) { + int i; + unsigned char low3; + typedef enum { + REG3264_NONE = -1, + REG3264_EAX = 0, + REG3264_ECX, + REG3264_EDX, + REG3264_EBX, + REG3264_ESP, + REG3264_EBP, + REG3264_ESI, + REG3264_EDI, + REG64_R8, + REG64_R9, + REG64_R10, + REG64_R11, + REG64_R12, + REG64_R13, + REG64_R14, + REG64_R15, + REG64_RIP + } reg3264type; + int reg3264mult[17] = {0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0}; + x86_checkea_reg3264_data reg3264_data; + int basereg = REG3264_NONE; /* "base" register (for SIB) */ + int indexreg = REG3264_NONE; /* "index" register (for SIB) */ - if (x86_ea->vsib_mode != 0) - regcount = 33; + /* We can only do 64-bit addresses in 64-bit mode. */ + if (*addrsize == 64 && bits != 64) { + yasm_error_set(YASM_ERROR_TYPE, + N_("invalid effective address (64-bit in non-64-bit mode)")); + return 1; + } - /* We can only do 64-bit addresses in 64-bit mode. */ - if (*addrsize == 64 && bits != 64) { - yasm_error_set(YASM_ERROR_TYPE, - N_("invalid effective address (64-bit in non-64-bit mode)")); - return 1; - } + reg3264_data.regs = reg3264mult; + reg3264_data.bits = bits; + reg3264_data.addrsize = *addrsize; + if (x86_ea->ea.disp.abs) { + int pcrel = 0; + switch (x86_expr_checkea_getregusage + (&x86_ea->ea.disp.abs, &indexreg, &pcrel, bits, + ®3264_data, x86_expr_checkea_get_reg3264)) { + case 1: + yasm_error_set(YASM_ERROR_VALUE, + N_("invalid effective address")); + return 1; + case 2: + if (pcrel) + yasm_value_set_curpos_rel(&x86_ea->ea.disp, bc, 1); + return 2; + default: + if (pcrel) + yasm_value_set_curpos_rel(&x86_ea->ea.disp, bc, 1); + break; + } + } - if (x86_ea->ea.pc_rel && bits != 64) { - yasm_warn_set(YASM_WARN_GENERAL, - N_("RIP-relative directive ignored in non-64-bit mode")); - x86_ea->ea.pc_rel = 0; - } + /* If indexreg mult is 0, discard it. + * This is possible because of the way indexreg is found in + * expr_checkea_getregusage(). + */ + if (indexreg != REG3264_NONE && reg3264mult[indexreg] == 0) + indexreg = REG3264_NONE; - reg3264_data.regs = reg3264mult; - reg3264_data.vsib_mode = x86_ea->vsib_mode; - reg3264_data.bits = bits; - reg3264_data.addrsize = *addrsize; - if (x86_ea->ea.disp.abs) { - int pcrel = 0; - switch (x86_expr_checkea_getregusage - (&x86_ea->ea.disp.abs, &indexreg, &pcrel, bits, - ®3264_data, x86_expr_checkea_get_reg3264)) { - case 1: - yasm_error_set(YASM_ERROR_VALUE, - N_("invalid effective address")); - return 1; - case 2: - if (pcrel) - yasm_value_set_curpos_rel(&x86_ea->ea.disp, bc, 1); - return 2; - default: - if (pcrel) - yasm_value_set_curpos_rel(&x86_ea->ea.disp, bc, 1); - break; - } - } + /* Find a basereg (*1, but not indexreg), if there is one. + * Also, if an indexreg hasn't been assigned, try to find one. + * Meanwhile, check to make sure there's no negative register mults. + */ + for (i=0; i<17; i++) { + if (reg3264mult[i] < 0) { + yasm_error_set(YASM_ERROR_VALUE, + N_("invalid effective address")); + return 1; + } + if (i != indexreg && reg3264mult[i] == 1 && + basereg == REG3264_NONE) + basereg = i; + else if (indexreg == REG3264_NONE && reg3264mult[i] > 0) + indexreg = i; + } - /* If indexreg mult is 0, discard it. - * This is possible because of the way indexreg is found in - * expr_checkea_getregusage(). - */ - if (indexreg != REG3264_NONE && reg3264mult[indexreg] == 0) - indexreg = REG3264_NONE; + /* Handle certain special cases of indexreg mults when basereg is + * empty. + */ + if (indexreg != REG3264_NONE && basereg == REG3264_NONE) + switch (reg3264mult[indexreg]) { + case 1: + /* Only optimize this way if nosplit wasn't specified */ + if (!x86_ea->ea.nosplit) { + basereg = indexreg; + indexreg = -1; + } + break; + case 2: + /* Only split if nosplit wasn't specified */ + if (!x86_ea->ea.nosplit) { + basereg = indexreg; + reg3264mult[indexreg] = 1; + } + break; + case 3: + case 5: + case 9: + basereg = indexreg; + reg3264mult[indexreg]--; + break; + } - /* Find a basereg (*1, but not indexreg), if there is one. - * Also, if an indexreg hasn't been assigned, try to find one. - * Meanwhile, check to make sure there's no negative register mults. - */ - for (i=0; i 0) - indexreg = i; - } + /* Make sure there's no other registers than the basereg and indexreg + * we just found. + */ + for (i=0; i<17; i++) + if (i != basereg && i != indexreg && reg3264mult[i] != 0) { + yasm_error_set(YASM_ERROR_VALUE, + N_("invalid effective address")); + return 1; + } - if (x86_ea->vsib_mode != 0) { - /* For VSIB, the SIMD register needs to go into the indexreg. - * Also check basereg (must be a GPR if present) and indexreg - * (must be a SIMD register). - */ - if (basereg >= SIMDREGS && - (indexreg == REG3264_NONE || reg3264mult[indexreg] == 1)) { - int temp = basereg; - basereg = indexreg; - indexreg = temp; - } - if (basereg >= REG64_RIP || indexreg < SIMDREGS) { - yasm_error_set(YASM_ERROR_VALUE, - N_("invalid effective address")); - return 1; - } - } else if (indexreg != REG3264_NONE && basereg == REG3264_NONE) - /* Handle certain special cases of indexreg mults when basereg is - * empty. - */ - switch (reg3264mult[indexreg]) { - case 1: - /* Only optimize this way if nosplit wasn't specified */ - if (!x86_ea->ea.nosplit) { - basereg = indexreg; - indexreg = -1; - } - break; - case 2: - /* Only split if nosplit wasn't specified */ - if (!x86_ea->ea.nosplit) { - basereg = indexreg; - reg3264mult[indexreg] = 1; - } - break; - case 3: - case 5: - case 9: - basereg = indexreg; - reg3264mult[indexreg]--; - break; - } + /* Check the index multiplier value for validity if present. */ + if (indexreg != REG3264_NONE && reg3264mult[indexreg] != 1 && + reg3264mult[indexreg] != 2 && reg3264mult[indexreg] != 4 && + reg3264mult[indexreg] != 8) { + yasm_error_set(YASM_ERROR_VALUE, N_("invalid effective address")); + return 1; + } - /* Make sure there's no other registers than the basereg and indexreg - * we just found. - */ - for (i=0; i1 or basereg is ESP also, there's no way to make it + * legal. + */ + if (reg3264mult[REG3264_ESP] > 1 || basereg == REG3264_ESP) { + yasm_error_set(YASM_ERROR_VALUE, + N_("invalid effective address")); + return 1; + } + /* If mult==1 and basereg is not ESP, swap indexreg w/basereg. */ + indexreg = basereg; + basereg = REG3264_ESP; + } - /* Check the index multiplier value for validity if present. */ - if (indexreg != REG3264_NONE && reg3264mult[indexreg] != 1 && - reg3264mult[indexreg] != 2 && reg3264mult[indexreg] != 4 && - reg3264mult[indexreg] != 8) { - yasm_error_set(YASM_ERROR_VALUE, N_("invalid effective address")); - return 1; - } + /* RIP is only legal if it's the ONLY register used. */ + if (indexreg == REG64_RIP || + (basereg == REG64_RIP && indexreg != REG3264_NONE)) { + yasm_error_set(YASM_ERROR_VALUE, N_("invalid effective address")); + return 1; + } - /* ESP is not a legal indexreg. */ - if (indexreg == REG3264_ESP) { - /* If mult>1 or basereg is ESP also, there's no way to make it - * legal. - */ - if (reg3264mult[REG3264_ESP] > 1 || basereg == REG3264_ESP) { - yasm_error_set(YASM_ERROR_VALUE, - N_("invalid effective address")); - return 1; - } - /* If mult==1 and basereg is not ESP, swap indexreg w/basereg. */ - indexreg = basereg; - basereg = REG3264_ESP; - } + /* At this point, we know the base and index registers and that the + * memory expression is (essentially) valid. Now build the ModRM and + * (optional) SIB bytes. + */ - /* RIP is only legal if it's the ONLY register used. */ - if (indexreg == REG64_RIP || - (basereg == REG64_RIP && indexreg != REG3264_NONE)) { - yasm_error_set(YASM_ERROR_VALUE, N_("invalid effective address")); - return 1; - } + /* First determine R/M (Mod is later determined from disp size) */ + x86_ea->need_modrm = 1; /* we always need ModRM */ + if (basereg == REG3264_NONE && indexreg == REG3264_NONE) { + /* Just a disp32: in 64-bit mode the RM encoding is used for RIP + * offset addressing, so we need to use the SIB form instead. + */ + if (bits == 64) { + x86_ea->modrm |= 4; + x86_ea->need_sib = 1; + } else { + x86_ea->modrm |= 5; + x86_ea->sib = 0; + x86_ea->valid_sib = 0; + x86_ea->need_sib = 0; + } + } else if (basereg == REG64_RIP) { + x86_ea->modrm |= 5; + x86_ea->sib = 0; + x86_ea->valid_sib = 0; + x86_ea->need_sib = 0; + /* RIP always requires a 32-bit displacement */ + x86_ea->valid_modrm = 1; + x86_ea->ea.disp.size = 32; + return 0; + } else if (indexreg == REG3264_NONE) { + /* basereg only */ + /* Don't need to go to the full effort of determining what type + * of register basereg is, as x86_set_rex_from_reg doesn't pay + * much attention. + */ + if (yasm_x86__set_rex_from_reg(rex, &low3, + (unsigned int)(X86_REG64 | basereg), + bits, X86_REX_B)) + return 1; + x86_ea->modrm |= low3; + /* we don't need an SIB *unless* basereg is ESP or R12 */ + if (basereg == REG3264_ESP || basereg == REG64_R12) + x86_ea->need_sib = 1; + else { + x86_ea->sib = 0; + x86_ea->valid_sib = 0; + x86_ea->need_sib = 0; + } + } else { + /* index or both base and index */ + x86_ea->modrm |= 4; + x86_ea->need_sib = 1; + } - /* At this point, we know the base and index registers and that the - * memory expression is (essentially) valid. Now build the ModRM and - * (optional) SIB bytes. - */ + /* Determine SIB if needed */ + if (x86_ea->need_sib == 1) { + x86_ea->sib = 0; /* start with 0 */ - /* If we're supposed to be RIP-relative and there's no register - * usage, change to RIP-relative. - */ - if (basereg == REG3264_NONE && indexreg == REG3264_NONE && - x86_ea->ea.pc_rel) { - basereg = REG64_RIP; - yasm_value_set_curpos_rel(&x86_ea->ea.disp, bc, 1); - } + /* Special case: no basereg */ + if (basereg == REG3264_NONE) + x86_ea->sib |= 5; + else { + if (yasm_x86__set_rex_from_reg(rex, &low3, (unsigned int) + (X86_REG64 | basereg), bits, + X86_REX_B)) + return 1; + x86_ea->sib |= low3; + } + + /* Put in indexreg, checking for none case */ + if (indexreg == REG3264_NONE) + x86_ea->sib |= 040; + /* Any scale field is valid, just leave at 0. */ + else { + if (yasm_x86__set_rex_from_reg(rex, &low3, (unsigned int) + (X86_REG64 | indexreg), bits, + X86_REX_X)) + return 1; + x86_ea->sib |= low3 << 3; + /* Set scale field, 1 case -> 0, so don't bother. */ + switch (reg3264mult[indexreg]) { + case 2: + x86_ea->sib |= 0100; + break; + case 4: + x86_ea->sib |= 0200; + break; + case 8: + x86_ea->sib |= 0300; + break; + } + } - /* First determine R/M (Mod is later determined from disp size) */ - x86_ea->need_modrm = 1; /* we always need ModRM */ - if (basereg == REG3264_NONE && indexreg == REG3264_NONE) { - /* Just a disp32: in 64-bit mode the RM encoding is used for RIP - * offset addressing, so we need to use the SIB form instead. - */ - if (bits == 64) { - x86_ea->modrm |= 4; - x86_ea->need_sib = 1; - } else { - x86_ea->modrm |= 5; - x86_ea->sib = 0; - x86_ea->valid_sib = 0; - x86_ea->need_sib = 0; - } - } else if (basereg == REG64_RIP) { - x86_ea->modrm |= 5; - x86_ea->sib = 0; - x86_ea->valid_sib = 0; - x86_ea->need_sib = 0; - /* RIP always requires a 32-bit displacement */ - x86_ea->valid_modrm = 1; - x86_ea->ea.disp.size = 32; - return 0; - } else if (indexreg == REG3264_NONE) { - /* basereg only */ - /* Don't need to go to the full effort of determining what type - * of register basereg is, as x86_set_rex_from_reg doesn't pay - * much attention. - */ - if (yasm_x86__set_rex_from_reg(rex, &low3, - (unsigned int)(X86_REG64 | basereg), - bits, X86_REX_B)) - return 1; - x86_ea->modrm |= low3; - /* we don't need an SIB *unless* basereg is ESP or R12 */ - if (basereg == REG3264_ESP || basereg == REG64_R12) - x86_ea->need_sib = 1; - else { - x86_ea->sib = 0; - x86_ea->valid_sib = 0; - x86_ea->need_sib = 0; - } - } else { - /* index or both base and index */ - x86_ea->modrm |= 4; - x86_ea->need_sib = 1; - } + x86_ea->valid_sib = 1; /* Done with SIB */ + } - /* Determine SIB if needed */ - if (x86_ea->need_sib == 1) { - x86_ea->sib = 0; /* start with 0 */ - - /* Special case: no basereg */ - if (basereg == REG3264_NONE) - x86_ea->sib |= 5; - else { - if (yasm_x86__set_rex_from_reg(rex, &low3, (unsigned int) - (X86_REG64 | basereg), bits, - X86_REX_B)) - return 1; - x86_ea->sib |= low3; - } - - /* Put in indexreg, checking for none case */ - if (indexreg == REG3264_NONE) - x86_ea->sib |= 040; - /* Any scale field is valid, just leave at 0. */ - else { - if (indexreg >= SIMDREGS) { - if (yasm_x86__set_rex_from_reg(rex, &low3, - (unsigned int)(X86_XMMREG | (indexreg-SIMDREGS)), - bits, X86_REX_X)) - return 1; - } else { - if (yasm_x86__set_rex_from_reg(rex, &low3, - (unsigned int)(X86_REG64 | indexreg), - bits, X86_REX_X)) - return 1; - } - x86_ea->sib |= low3 << 3; - /* Set scale field, 1 case -> 0, so don't bother. */ - switch (reg3264mult[indexreg]) { - case 2: - x86_ea->sib |= 0100; - break; - case 4: - x86_ea->sib |= 0200; - break; - case 8: - x86_ea->sib |= 0300; - break; - } - } - - x86_ea->valid_sib = 1; /* Done with SIB */ - } - - /* Calculate displacement length (if possible) */ - retval = x86_checkea_calc_displen - (x86_ea, 32, basereg == REG3264_NONE, - basereg == REG3264_EBP || basereg == REG64_R13); - return retval; + /* Calculate displacement length (if possible) */ + retval = x86_checkea_calc_displen + (x86_ea, 32, basereg == REG3264_NONE, + basereg == REG3264_EBP || basereg == REG64_R13); + return retval; } else if (*addrsize == 16 && x86_ea->need_modrm && !x86_ea->valid_modrm) { - static const unsigned char modrm16[16] = { - 0006 /* disp16 */, 0007 /* [BX] */, 0004 /* [SI] */, - 0000 /* [BX+SI] */, 0005 /* [DI] */, 0001 /* [BX+DI] */, - 0377 /* invalid */, 0377 /* invalid */, 0006 /* [BP]+d */, - 0377 /* invalid */, 0002 /* [BP+SI] */, 0377 /* invalid */, - 0003 /* [BP+DI] */, 0377 /* invalid */, 0377 /* invalid */, - 0377 /* invalid */ - }; - x86_checkea_reg16_data reg16mult = {0, 0, 0, 0}; - enum { - HAVE_NONE = 0, - HAVE_BX = 1<<0, - HAVE_SI = 1<<1, - HAVE_DI = 1<<2, - HAVE_BP = 1<<3 - } havereg = HAVE_NONE; + static const unsigned char modrm16[16] = { + 0006 /* disp16 */, 0007 /* [BX] */, 0004 /* [SI] */, + 0000 /* [BX+SI] */, 0005 /* [DI] */, 0001 /* [BX+DI] */, + 0377 /* invalid */, 0377 /* invalid */, 0006 /* [BP]+d */, + 0377 /* invalid */, 0002 /* [BP+SI] */, 0377 /* invalid */, + 0003 /* [BP+DI] */, 0377 /* invalid */, 0377 /* invalid */, + 0377 /* invalid */ + }; + x86_checkea_reg16_data reg16mult = {0, 0, 0, 0}; + enum { + HAVE_NONE = 0, + HAVE_BX = 1<<0, + HAVE_SI = 1<<1, + HAVE_DI = 1<<2, + HAVE_BP = 1<<3 + } havereg = HAVE_NONE; - /* 64-bit mode does not allow 16-bit addresses */ - if (bits == 64 && !address16_op) { - yasm_error_set(YASM_ERROR_TYPE, - N_("16-bit addresses not supported in 64-bit mode")); - return 1; - } + /* 64-bit mode does not allow 16-bit addresses */ + if (bits == 64 && !address16_op) { + yasm_error_set(YASM_ERROR_TYPE, + N_("16-bit addresses not supported in 64-bit mode")); + return 1; + } - /* 16-bit cannot have SIB */ - x86_ea->sib = 0; - x86_ea->valid_sib = 0; - x86_ea->need_sib = 0; + /* 16-bit cannot have SIB */ + x86_ea->sib = 0; + x86_ea->valid_sib = 0; + x86_ea->need_sib = 0; - if (x86_ea->ea.disp.abs) { - int pcrel = 0; - switch (x86_expr_checkea_getregusage - (&x86_ea->ea.disp.abs, (int *)NULL, &pcrel, bits, - ®16mult, x86_expr_checkea_get_reg16)) { - case 1: - yasm_error_set(YASM_ERROR_VALUE, - N_("invalid effective address")); - return 1; - case 2: - if (pcrel) - yasm_value_set_curpos_rel(&x86_ea->ea.disp, bc, 1); - return 2; - default: - if (pcrel) - yasm_value_set_curpos_rel(&x86_ea->ea.disp, bc, 1); - break; - } - } + if (x86_ea->ea.disp.abs) { + int pcrel = 0; + switch (x86_expr_checkea_getregusage + (&x86_ea->ea.disp.abs, (int *)NULL, &pcrel, bits, + ®16mult, x86_expr_checkea_get_reg16)) { + case 1: + yasm_error_set(YASM_ERROR_VALUE, + N_("invalid effective address")); + return 1; + case 2: + if (pcrel) + yasm_value_set_curpos_rel(&x86_ea->ea.disp, bc, 1); + return 2; + default: + if (pcrel) + yasm_value_set_curpos_rel(&x86_ea->ea.disp, bc, 1); + break; + } + } - /* reg multipliers not 0 or 1 are illegal. */ - if (reg16mult.bx & ~1 || reg16mult.si & ~1 || reg16mult.di & ~1 || - reg16mult.bp & ~1) { - yasm_error_set(YASM_ERROR_VALUE, N_("invalid effective address")); - return 1; - } + /* reg multipliers not 0 or 1 are illegal. */ + if (reg16mult.bx & ~1 || reg16mult.si & ~1 || reg16mult.di & ~1 || + reg16mult.bp & ~1) { + yasm_error_set(YASM_ERROR_VALUE, N_("invalid effective address")); + return 1; + } - /* Set havereg appropriately */ - if (reg16mult.bx > 0) - havereg |= HAVE_BX; - if (reg16mult.si > 0) - havereg |= HAVE_SI; - if (reg16mult.di > 0) - havereg |= HAVE_DI; - if (reg16mult.bp > 0) - havereg |= HAVE_BP; + /* Set havereg appropriately */ + if (reg16mult.bx > 0) + havereg |= HAVE_BX; + if (reg16mult.si > 0) + havereg |= HAVE_SI; + if (reg16mult.di > 0) + havereg |= HAVE_DI; + if (reg16mult.bp > 0) + havereg |= HAVE_BP; - /* Check the modrm value for invalid combinations. */ - if (modrm16[havereg] & 0070) { - yasm_error_set(YASM_ERROR_VALUE, N_("invalid effective address")); - return 1; - } + /* Check the modrm value for invalid combinations. */ + if (modrm16[havereg] & 0070) { + yasm_error_set(YASM_ERROR_VALUE, N_("invalid effective address")); + return 1; + } - /* Set ModRM byte for registers */ - x86_ea->modrm |= modrm16[havereg]; + /* Set ModRM byte for registers */ + x86_ea->modrm |= modrm16[havereg]; - /* Calculate displacement length (if possible) */ - retval = x86_checkea_calc_displen - (x86_ea, 16, havereg == HAVE_NONE, havereg == HAVE_BP); - return retval; + /* Calculate displacement length (if possible) */ + retval = x86_checkea_calc_displen + (x86_ea, 16, havereg == HAVE_NONE, havereg == HAVE_BP); + return retval; } else if (!x86_ea->need_modrm && !x86_ea->need_sib) { - /* Special case for MOV MemOffs opcode: displacement but no modrm. */ - switch (*addrsize) { - case 64: - if (bits != 64) { - yasm_error_set(YASM_ERROR_TYPE, - N_("invalid effective address (64-bit in non-64-bit mode)")); - return 1; - } - x86_ea->ea.disp.size = 64; - break; - case 32: - x86_ea->ea.disp.size = 32; - break; - case 16: - /* 64-bit mode does not allow 16-bit addresses */ - if (bits == 64 && !address16_op) { - yasm_error_set(YASM_ERROR_TYPE, - N_("16-bit addresses not supported in 64-bit mode")); - return 1; - } - x86_ea->ea.disp.size = 16; - break; - } + /* Special case for MOV MemOffs opcode: displacement but no modrm. */ + switch (*addrsize) { + case 64: + if (bits != 64) { + yasm_error_set(YASM_ERROR_TYPE, + N_("invalid effective address (64-bit in non-64-bit mode)")); + return 1; + } + x86_ea->ea.disp.size = 64; + break; + case 32: + x86_ea->ea.disp.size = 32; + break; + case 16: + /* 64-bit mode does not allow 16-bit addresses */ + if (bits == 64 && !address16_op) { + yasm_error_set(YASM_ERROR_TYPE, + N_("16-bit addresses not supported in 64-bit mode")); + return 1; + } + x86_ea->ea.disp.size = 16; + break; + } } return 0; } int yasm_x86__floatnum_tobytes(yasm_arch *arch, const yasm_floatnum *flt, - unsigned char *buf, size_t destsize, size_t valsize, - size_t shift, int warn) + unsigned char *buf, size_t destsize, size_t valsize, + size_t shift, int warn) { if (!yasm_floatnum_check_size(flt, valsize)) { - yasm_error_set(YASM_ERROR_FLOATING_POINT, - N_("invalid floating point constant size")); - return 1; + yasm_error_set(YASM_ERROR_FLOATING_POINT, + N_("invalid floating point constant size")); + return 1; } yasm_floatnum_get_sized(flt, buf, destsize, valsize, shift, 0, warn); diff --git a/modules/arch/x86/x86id.c b/modules/arch/x86/x86id.c index 6a766dc9..a121e1d3 100644 --- a/modules/arch/x86/x86id.c +++ b/modules/arch/x86/x86id.c @@ -26,235 +26,226 @@ */ #include #include +RCSID("$Id$"); +#define YASM_LIB_INTERNAL +#define YASM_BC_INTERNAL +#define YASM_EXPR_INTERNAL #include #include #include "modules/arch/x86/x86arch.h" -static const char *cpu_find_reverse(unsigned int cpu0, unsigned int cpu1, - unsigned int cpu2); +static const char *cpu_find_reverse(unsigned long cpu); -/* Opcode modifiers. */ -#define MOD_Gap 0 /* Eats a parameter / does nothing */ -#define MOD_PreAdd 1 /* Parameter adds to "special" prefix */ -#define MOD_Op0Add 2 /* Parameter adds to opcode byte 0 */ -#define MOD_Op1Add 3 /* Parameter adds to opcode byte 1 */ -#define MOD_Op2Add 4 /* Parameter adds to opcode byte 2 */ -#define MOD_Op3Add 5 /* Parameter adds to opcode byte 3 */ -#define MOD_SpAdd 6 /* Parameter adds to "spare" value */ -#define MOD_OpSizeR 7 /* Parameter replaces opersize */ -#define MOD_Imm8 8 /* Parameter is included as immediate byte */ -#define MOD_AdSizeR 9 /* Parameter replaces addrsize (jmp only) */ -#define MOD_DOpS64R 10 /* Parameter replaces default 64-bit opersize */ -#define MOD_Op1AddSp 11 /* Parameter is added as "spare" to opcode byte 2 */ -#define MOD_SetVEX 12 /* Parameter replaces internal VEX prefix value */ +/* Opcode modifiers. The opcode bytes are in "reverse" order because the + * parameters are read from the arch-specific data in LSB->MSB order. + * (only for asthetic reasons in the lexer code below, no practical reason). + */ +#define MOD_Gap0 (1UL<<0) /* Eats a parameter */ +#define MOD_Op2Add (1UL<<1) /* Parameter adds to opcode byte 2 */ +#define MOD_Gap1 (1UL<<2) /* Eats a parameter */ +#define MOD_Op1Add (1UL<<3) /* Parameter adds to opcode byte 1 */ +#define MOD_Gap2 (1UL<<4) /* Eats a parameter */ +#define MOD_Op0Add (1UL<<5) /* Parameter adds to opcode byte 0 */ +#define MOD_PreAdd (1UL<<6) /* Parameter adds to "special" prefix */ +#define MOD_SpAdd (1UL<<7) /* Parameter adds to "spare" value */ +#define MOD_OpSizeR (1UL<<8) /* Parameter replaces opersize */ +#define MOD_Imm8 (1UL<<9) /* Parameter is included as immediate byte */ +#define MOD_AdSizeR (1UL<<10) /* Parameter replaces addrsize (jmp only) */ +#define MOD_DOpS64R (1UL<<11) /* Parameter replaces default 64-bit opersize */ +#define MOD_Op1AddSp (1UL<<12) /* Parameter is added as "spare" to opcode byte 2 */ -/* GAS suffix flags for instructions */ -enum x86_gas_suffix_flags { - SUF_Z = 1<<0, /* no suffix */ - SUF_B = 1<<1, - SUF_W = 1<<2, - SUF_L = 1<<3, - SUF_Q = 1<<4, - SUF_S = 1<<5, - SUF_MASK = SUF_Z|SUF_B|SUF_W|SUF_L|SUF_Q|SUF_S, +/* Modifiers that aren't: these are used with the GAS parser to indicate + * special cases. + */ +#define MOD_GasOnly (1UL<<13) /* Only available in GAS mode */ +#define MOD_GasIllegal (1UL<<14) /* Illegal in GAS mode */ +#define MOD_GasNoRev (1UL<<15) /* Don't reverse operands */ +#define MOD_GasSufB (1UL<<16) /* GAS B suffix ok */ +#define MOD_GasSufW (1UL<<17) /* GAS W suffix ok */ +#define MOD_GasSufL (1UL<<18) /* GAS L suffix ok */ +#define MOD_GasSufQ (1UL<<19) /* GAS Q suffix ok */ +#define MOD_GasSufS (1UL<<20) /* GAS S suffix ok */ +#define MOD_GasSuf_SHIFT 16 +#define MOD_GasSuf_MASK (0x1FUL<<16) - /* Flags only used in x86_insn_info */ - GAS_ONLY = 1<<6, /* Only available in GAS mode */ - GAS_ILLEGAL = 1<<7, /* Illegal in GAS mode */ - GAS_NO_REV = 1<<8 /* Don't reverse operands in GAS mode */ -}; +/* Operand types. These are more detailed than the "general" types for all + * architectures, as they include the size, for instance. + * Bit Breakdown (from LSB to MSB): + * - 5 bits = general type (must be exact match, except for =3): + * 0 = immediate + * 1 = any general purpose or FPU register + * 2 = memory + * 3 = any general purpose or FPU register OR memory + * 4 = any MMX or XMM register + * 5 = any MMX or XMM register OR memory + * 6 = any segment register + * 7 = any CR register + * 8 = any DR register + * 9 = any TR register + * A = ST0 + * B = AL/AX/EAX/RAX (depending on size) + * C = CL/CX/ECX/RCX (depending on size) + * D = DL/DX/EDX/RDX (depending on size) + * E = CS + * F = DS + * 10 = ES + * 11 = FS + * 12 = GS + * 13 = SS + * 14 = CR4 + * 15 = memory offset (an EA, but with no registers allowed) + * [special case for MOV opcode] + * 16 = immediate, value=1 (for special-case shift) + * 17 = immediate, does not contain SEG:OFF (for jmp/call), + * 18 = XMM0 + * 19 = AX/EAX/RAX memory operand only (EA) + * [special case for SVM opcodes] + * 20 = EAX memory operand only (EA) + * [special case for SVM skinit opcode] + * - 3 bits = size (user-specified, or from register size): + * 0 = any size acceptable/no size spec acceptable (dep. on strict) + * 1/2/3/4 = 8/16/32/64 bits (from user or reg size) + * 5/6 = 80/128 bits (from user) + * 7 = current BITS setting; when this is used the size matched + * gets stored into the opersize as well. + * - 1 bit = size implicit or explicit ("strictness" of size matching on + * non-registers -- registers are always strictly matched): + * 0 = user size must exactly match size above. + * 1 = user size either unspecified or exactly match size above. + * - 3 bits = target modification. + * 0 = no target mod acceptable + * 1 = NEAR + * 2 = SHORT + * 3 = FAR (or SEG:OFF immediate) + * 4 = TO + * - 1 bit = effective address size + * 0 = any address size allowed except for 64-bit + * 1 = only 64-bit address size allowed + * + * MSBs than the above are actions: what to do with the operand if the + * instruction matches. Essentially describes what part of the output bytecode + * gets the operand. This may require conversion (e.g. a register going into + * an ea field). Naturally, only one of each of these may be contained in the + * operands of a single insn_info structure. + * - 4 bits = action: + * 0 = does nothing (operand data is discarded) + * 1 = operand data goes into ea field + * 2 = operand data goes into imm field + * 3 = operand data goes into sign-extended imm field + * 4 = operand data goes into "spare" field + * 5 = operand data is added to opcode byte 0 + * 6 = operand data is added to opcode byte 1 + * 7 = operand data goes into BOTH ea and spare + * [special case for imul opcode] + * 8 = relative jump (outputs a jmp instead of normal insn) + * 9 = operand size goes into address size (jmp only) + * A = far jump (outputs a farjmp instead of normal insn) + * B = ea operand only sets address size (no actual ea field) + * The below describes postponed actions: actions which can't be completed at + * parse-time due to possibly dependent expressions. For these, some + * additional data (stored in the second byte of the opcode with a one-byte + * opcode) is passed to later stages of the assembler with flags set to + * indicate postponed actions. + * - 3 bits = postponed action: + * 0 = none + * 1 = sign-extended imm8 that could expand to a large imm16/32 + * 2 = could become a short opcode mov with bits=64 and a32 prefix + * 3 = forced 16-bit address size (override ignored, no prefix) + * 4 = large imm64 that can become a sign-extended imm32. + */ +#define OPT_Imm 0x0 +#define OPT_Reg 0x1 +#define OPT_Mem 0x2 +#define OPT_RM 0x3 +#define OPT_SIMDReg 0x4 +#define OPT_SIMDRM 0x5 +#define OPT_SegReg 0x6 +#define OPT_CRReg 0x7 +#define OPT_DRReg 0x8 +#define OPT_TRReg 0x9 +#define OPT_ST0 0xA +#define OPT_Areg 0xB +#define OPT_Creg 0xC +#define OPT_Dreg 0xD +#define OPT_CS 0xE +#define OPT_DS 0xF +#define OPT_ES 0x10 +#define OPT_FS 0x11 +#define OPT_GS 0x12 +#define OPT_SS 0x13 +#define OPT_CR4 0x14 +#define OPT_MemOffs 0x15 +#define OPT_Imm1 0x16 +#define OPT_ImmNotSegOff 0x17 +#define OPT_XMM0 0x18 +#define OPT_MemrAX 0x19 +#define OPT_MemEAX 0x1A +#define OPT_MASK 0x1F -/* Miscellaneous flag tests for instructions */ -enum x86_misc_flags { - /* These are tested against BITS==64. */ - ONLY_64 = 1<<0, /* Only available in 64-bit mode */ - NOT_64 = 1<<1, /* Not available (invalid) in 64-bit mode */ - /* These are tested against whether the base instruction is an AVX one. */ - ONLY_AVX = 1<<2, /* Only available in AVX instruction */ - NOT_AVX = 1<<3 /* Not available (invalid) in AVX instruction */ -}; +#define OPS_Any (0UL<<5) +#define OPS_8 (1UL<<5) +#define OPS_16 (2UL<<5) +#define OPS_32 (3UL<<5) +#define OPS_64 (4UL<<5) +#define OPS_80 (5UL<<5) +#define OPS_128 (6UL<<5) +#define OPS_BITS (7UL<<5) +#define OPS_MASK (7UL<<5) +#define OPS_SHIFT 5 -enum x86_operand_type { - OPT_Imm = 0, /* immediate */ - OPT_Reg = 1, /* any general purpose or FPU register */ - OPT_Mem = 2, /* memory */ - OPT_RM = 3, /* any general purpose or FPU register OR memory */ - OPT_SIMDReg = 4, /* any MMX or XMM register */ - OPT_SIMDRM = 5, /* any MMX or XMM register OR memory */ - OPT_SegReg = 6, /* any segment register */ - OPT_CRReg = 7, /* any CR register */ - OPT_DRReg = 8, /* any DR register */ - OPT_TRReg = 9, /* any TR register */ - OPT_ST0 = 10, /* ST0 */ - OPT_Areg = 11, /* AL/AX/EAX/RAX (depending on size) */ - OPT_Creg = 12, /* CL/CX/ECX/RCX (depending on size) */ - OPT_Dreg = 13, /* DL/DX/EDX/RDX (depending on size) */ - OPT_CS = 14, /* CS */ - OPT_DS = 15, /* DS */ - OPT_ES = 16, /* ES */ - OPT_FS = 17, /* FS */ - OPT_GS = 18, /* GS */ - OPT_SS = 19, /* SS */ - OPT_CR4 = 20, /* CR4 */ - /* memory offset (an EA, but with no registers allowed) - * [special case for MOV opcode] - */ - OPT_MemOffs = 21, - OPT_Imm1 = 22, /* immediate, value=1 (for special-case shift) */ - /* immediate, does not contain SEG:OFF (for jmp/call) */ - OPT_ImmNotSegOff = 23, - OPT_XMM0 = 24, /* XMM0 */ - /* AX/EAX/RAX memory operand only (EA) [special case for SVM opcodes] - */ - OPT_MemrAX = 25, - /* EAX memory operand only (EA) [special case for SVM skinit opcode] */ - OPT_MemEAX = 26, - /* XMM VSIB memory operand */ - OPT_MemXMMIndex = 27, - /* YMM VSIB memory operand */ - OPT_MemYMMIndex = 28 -}; +#define OPS_Relaxed (1UL<<8) +#define OPS_RMASK (1UL<<8) -enum x86_operand_size { - /* any size acceptable/no size spec acceptable (dep. on strict) */ - OPS_Any = 0, - /* 8/16/32/64/80/128/256 bits (from user or reg size) */ - OPS_8 = 1, - OPS_16 = 2, - OPS_32 = 3, - OPS_64 = 4, - OPS_80 = 5, - OPS_128 = 6, - OPS_256 = 7, - /* current BITS setting; when this is used the size matched - * gets stored into the opersize as well. - */ - OPS_BITS = 8 -}; +#define OPEAS_Not64 (0UL<<9) +#define OPEAS_64 (1UL<<9) +#define OPEAS_MASK (1UL<<9) -enum x86_operand_targetmod { - OPTM_None = 0, /* no target mod acceptable */ - OPTM_Near = 1, /* NEAR */ - OPTM_Short = 2, /* SHORT */ - OPTM_Far = 3, /* FAR (or SEG:OFF immediate) */ - OPTM_To = 4 /* TO */ -}; +#define OPTM_None (0UL<<10) +#define OPTM_Near (1UL<<10) +#define OPTM_Short (2UL<<10) +#define OPTM_Far (3UL<<10) +#define OPTM_To (4UL<<10) +#define OPTM_MASK (7UL<<10) -enum x86_operand_action { - OPA_None = 0, /* does nothing (operand data is discarded) */ - OPA_EA = 1, /* operand data goes into ea field */ - OPA_Imm = 2, /* operand data goes into imm field */ - OPA_SImm = 3, /* operand data goes into sign-extended imm field */ - OPA_Spare = 4, /* operand data goes into "spare" field */ - OPA_Op0Add = 5, /* operand data is added to opcode byte 0 */ - OPA_Op1Add = 6, /* operand data is added to opcode byte 1 */ - /* operand data goes into BOTH ea and spare - * (special case for imul opcode) - */ - OPA_SpareEA = 7, - /* relative jump (outputs a jmp instead of normal insn) */ - OPA_JmpRel = 8, - /* operand size goes into address size (jmp only) */ - OPA_AdSizeR = 9, - /* far jump (outputs a farjmp instead of normal insn) */ - OPA_JmpFar = 10, - /* ea operand only sets address size (no actual ea field) */ - OPA_AdSizeEA = 11, - OPA_VEX = 12, /* operand data goes into VEX/XOP "vvvv" field */ - /* operand data goes into BOTH VEX/XOP "vvvv" field and ea field */ - OPA_EAVEX = 13, - /* operand data goes into BOTH VEX/XOP "vvvv" field and spare field */ - OPA_SpareVEX = 14, - /* operand data goes into upper 4 bits of immediate byte (VEX is4 field) */ - OPA_VEXImmSrc = 15, - /* operand data goes into bottom 4 bits of immediate byte - * (currently only VEX imz2 field) - */ - OPA_VEXImm = 16 -}; +#define OPA_None (0UL<<13) +#define OPA_EA (1UL<<13) +#define OPA_Imm (2UL<<13) +#define OPA_SImm (3UL<<13) +#define OPA_Spare (4UL<<13) +#define OPA_Op0Add (5UL<<13) +#define OPA_Op1Add (6UL<<13) +#define OPA_SpareEA (7UL<<13) +#define OPA_JmpRel (8UL<<13) +#define OPA_AdSizeR (9UL<<13) +#define OPA_JmpFar (0xAUL<<13) +#define OPA_AdSizeEA (0xBUL<<13) +#define OPA_MASK (0xFUL<<13) -enum x86_operand_post_action { - OPAP_None = 0, - /* sign-extended imm8 that could expand to a large imm16/32 */ - OPAP_SImm8 = 1, - /* could become a short opcode mov with bits=64 and a32 prefix */ - OPAP_ShortMov = 2, - /* forced 16-bit address size (override ignored, no prefix) */ - OPAP_A16 = 3, - /* large imm64 that can become a sign-extended imm32 */ - OPAP_SImm32Avail = 4 -}; - -typedef struct x86_info_operand { - /* Operand types. These are more detailed than the "general" types for all - * architectures, as they include the size, for instance. - */ - - /* general type (must be exact match, except for RM types): */ - unsigned int type:5; - - /* size (user-specified, or from register size) */ - unsigned int size:4; - - /* size implicit or explicit ("strictness" of size matching on - * non-registers -- registers are always strictly matched): - * 0 = user size must exactly match size above. - * 1 = user size either unspecified or exactly match size above. - */ - unsigned int relaxed:1; - - /* effective address size - * 0 = any address size allowed except for 64-bit - * 1 = only 64-bit address size allowed - */ - unsigned int eas64:1; - - /* target modification */ - unsigned int targetmod:3; - - /* Actions: what to do with the operand if the instruction matches. - * Essentially describes what part of the output bytecode gets the - * operand. This may require conversion (e.g. a register going into - * an ea field). Naturally, only one of each of these may be contained - * in the operands of a single insn_info structure. - */ - unsigned int action:5; - - /* Postponed actions: actions which can't be completed at - * parse-time due to possibly dependent expressions. For these, some - * additional data (stored in the second byte of the opcode with a - * one-byte opcode) is passed to later stages of the assembler with - * flags set to indicate postponed actions. - */ - unsigned int post_action:3; -} x86_info_operand; +#define OPAP_None (0UL<<17) +#define OPAP_SImm8 (1UL<<17) +#define OPAP_ShortMov (2UL<<17) +#define OPAP_A16 (3UL<<17) +#define OPAP_SImm32Avail (4UL<<17) +#define OPAP_MASK (7UL<<17) typedef struct x86_insn_info { - /* GAS suffix flags */ - unsigned int gas_flags:9; /* Enabled for these GAS suffixes */ - - /* Tests against BITS==64, AVX, and XOP */ - unsigned int misc_flags:5; - /* The CPU feature flags needed to execute this instruction. This is OR'ed * with arch-specific data[2]. This combined value is compared with * cpu_enabled to see if all bits set here are set in cpu_enabled--if so, * the instruction is available on this CPU. */ - unsigned int cpu0:6; - unsigned int cpu1:6; - unsigned int cpu2:6; + unsigned long cpu; /* Opcode modifiers for variations of instruction. As each modifier reads * its parameter in LSB->MSB order from the arch-specific data[1] from the * lexer data, and the LSB of the arch-specific data[1] is reserved for the * count of insn_info structures in the instruction grouping, there can - * only be a maximum of 4 modifiers. + * only be a maximum of 3 modifiers. */ - unsigned char modifiers[4]; + unsigned long modifiers; /* Operand Size */ unsigned char opersize; @@ -267,129 +258,2028 @@ typedef struct x86_insn_info { * mode, they're treated like normal prefixes (e.g. the REX prefix needs * to be *after* the F2/F3/66 "prefix"). * (0=no special prefix) - * 0xC0 - 0xCF indicate a VEX prefix, with the four LSBs holding "WLpp": - * W: VEX.W field (meaning depends on opcode) - * L: 0=128-bit, 1=256-bit - * pp: SIMD prefix designation: - * 00: None - * 01: 66 - * 10: F3 - * 11: F2 - * 0x80 - 0x8F indicate a XOP prefix, with the four LSBs holding "WLpp": - * same meanings as VEX prefix. */ unsigned char special_prefix; /* The length of the basic opcode */ unsigned char opcode_len; - /* The basic 1-4 byte opcode (not including the special instruction + /* The basic 1-3 byte opcode (not including the special instruction * prefix). */ - unsigned char opcode[4]; + unsigned char opcode[3]; /* The 3-bit "spare" value (extended opcode) for the R/M byte field */ unsigned char spare; /* The number of operands this form of the instruction takes */ - unsigned int num_operands:4; + unsigned char num_operands; - /* The index into the insn_operands array which contains the type of each - * operand, see above - */ - unsigned int operands_index:12; + /* The types of each operand, see above */ + unsigned long operands[3]; } x86_insn_info; -typedef struct x86_id_insn { - yasm_insn insn; /* base structure */ +/* + * General instruction groupings + */ - /* instruction parse group - NULL if empty instruction (just prefixes) */ - /*@null@*/ const x86_insn_info *group; - - /* CPU feature flags enabled at the time of parsing the instruction */ - wordptr cpu_enabled; - - /* Modifier data */ - unsigned char mod_data[4]; - - /* Number of elements in the instruction parse group */ - unsigned int num_info:8; - - /* BITS setting active at the time of parsing the instruction */ - unsigned int mode_bits:8; - - /* Suffix flags */ - unsigned int suffix:9; - - /* Tests against BITS==64 and AVX */ - unsigned int misc_flags:5; - - /* Parser enabled at the time of parsing the instruction */ - unsigned int parser:2; - - /* Strict forced setting at the time of parsing the instruction */ - unsigned int force_strict:1; - - /* Default rel setting at the time of parsing the instruction */ - unsigned int default_rel:1; -} x86_id_insn; - -static void x86_id_insn_destroy(void *contents); -static void x86_id_insn_print(const void *contents, FILE *f, int indent_level); -static void x86_id_insn_finalize(yasm_bytecode *bc, yasm_bytecode *prev_bc); - -static const yasm_bytecode_callback x86_id_insn_callback = { - x86_id_insn_destroy, - x86_id_insn_print, - x86_id_insn_finalize, - NULL, - yasm_bc_calc_len_common, - yasm_bc_expand_common, - yasm_bc_tobytes_common, - YASM_BC_SPECIAL_INSN +/* Empty instruction */ +static const x86_insn_info empty_insn[] = { + { CPU_Any, 0, 0, 0, 0, 0, {0, 0, 0}, 0, 0, {0, 0, 0} } }; -#include "x86insns.c" +/* Placeholder for instructions invalid in 64-bit mode */ +static const x86_insn_info not64_insn[] = { + { CPU_Not64, 0, 0, 0, 0, 0, {0, 0, 0}, 0, 0, {0, 0, 0} } +}; -/* Looks for the first SIMD register match for the purposes of VSIB matching. - * Full legality checking is performed in EA code. +/* One byte opcode instructions with no operands */ +static const x86_insn_info onebyte_insn[] = { + { CPU_Any, MOD_Op0Add|MOD_OpSizeR|MOD_DOpS64R, 0, 0, 0, 1, {0, 0, 0}, 0, 0, + {0, 0, 0} } +}; + +/* One byte opcode instructions with "special" prefix with no operands */ +static const x86_insn_info onebyte_prefix_insn[] = { + { CPU_Any, MOD_Op0Add|MOD_PreAdd, 0, 0, 0x00, 1, {0x00, 0, 0}, 0, 0, + {0, 0, 0} } +}; + +/* Two byte opcode instructions with no operands */ +static const x86_insn_info twobyte_insn[] = { + { CPU_Any, MOD_Op1Add|MOD_Op0Add|MOD_GasSufL|MOD_GasSufQ, 0, 0, 0, 2, + {0, 0, 0}, 0, 0, {0, 0, 0} } +}; + +/* Three byte opcode instructions with no operands */ +static const x86_insn_info threebyte_insn[] = { + { CPU_Any, MOD_Op2Add|MOD_Op1Add|MOD_Op0Add, 0, 0, 0, 3, {0, 0, 0}, 0, 0, + {0, 0, 0} } +}; + +/* One byte opcode instructions with general memory operand */ +static const x86_insn_info onebytemem_insn[] = { + { CPU_Any, MOD_Op0Add|MOD_SpAdd|MOD_GasSufL|MOD_GasSufQ|MOD_GasSufS, + 0, 0, 0, 1, {0, 0, 0}, 0, 1, {OPT_Mem|OPS_Any|OPA_EA, 0, 0} } +}; + +/* Two byte opcode instructions with general memory operand */ +static const x86_insn_info twobytemem_insn[] = { + { CPU_Any, + MOD_Op1Add|MOD_Op0Add|MOD_SpAdd|MOD_GasSufL|MOD_GasSufQ|MOD_GasSufS, + 0, 0, 0, 2, {0, 0, 0}, 0, 1, {OPT_Mem|OPS_Any|OPA_EA, 0, 0} } +}; + +/* P4 VMX Instructions */ +static const x86_insn_info vmxmemrd_insn[] = { + { CPU_Not64, MOD_Op1Add|MOD_Op0Add|MOD_GasSufL, 32, 0, 0, 2, {0, 0, 0}, 0, + 2, {OPT_RM|OPS_32|OPS_Relaxed|OPA_EA, OPT_Reg|OPS_32|OPA_Spare, 0} }, + { CPU_64, MOD_Op1Add|MOD_Op0Add|MOD_GasSufQ, 64, 64, 0, 2, {0, 0, 0}, 0, + 2, {OPT_RM|OPS_64|OPS_Relaxed|OPA_EA, OPT_Reg|OPS_64|OPA_Spare, 0} } +}; +static const x86_insn_info vmxmemwr_insn[] = { + { CPU_Not64, MOD_Op1Add|MOD_Op0Add|MOD_GasSufL, 32, 0, 0, 2, {0, 0, 0}, 0, + 2, {OPT_Reg|OPS_32|OPA_Spare, OPT_RM|OPS_32|OPS_Relaxed|OPA_EA, 0} }, + { CPU_64, MOD_Op1Add|MOD_Op0Add|MOD_GasSufQ, 64, 64, 0, 2, {0, 0, 0}, 0, + 2, {OPT_Reg|OPS_64|OPA_Spare, OPT_RM|OPS_64|OPS_Relaxed|OPA_EA, 0} } +}; +static const x86_insn_info vmxtwobytemem_insn[] = { + { CPU_Any, MOD_SpAdd|MOD_Op1Add, 0, 0, 0, 2, {0x0F, 0, 0}, 0, 1, + {OPT_Mem|OPS_64|OPS_Relaxed|OPA_EA, 0, 0} } +}; +static const x86_insn_info vmxthreebytemem_insn[] = { + { CPU_Any, MOD_SpAdd|MOD_PreAdd|MOD_Op1Add, 0, 0, 0, 2, {0x0F, 0, 0}, 0, 1, + {OPT_Mem|OPS_64|OPS_Relaxed|OPA_EA, 0, 0} } +}; + +/* Move instructions */ +static const x86_insn_info mov_insn[] = { + /* Absolute forms for non-64-bit mode */ + { CPU_Not64, MOD_GasSufB, 0, 0, 0, 1, {0xA0, 0, 0}, 0, 2, + {OPT_Areg|OPS_8|OPA_None, OPT_MemOffs|OPS_8|OPS_Relaxed|OPA_EA, 0} }, + { CPU_Not64, MOD_GasSufW, 16, 0, 0, 1, {0xA1, 0, 0}, 0, 2, + {OPT_Areg|OPS_16|OPA_None, OPT_MemOffs|OPS_16|OPS_Relaxed|OPA_EA, 0} }, + { CPU_386|CPU_Not64, MOD_GasSufL, 32, 0, 0, 1, {0xA1, 0, 0}, 0, 2, + {OPT_Areg|OPS_32|OPA_None, OPT_MemOffs|OPS_32|OPS_Relaxed|OPA_EA, 0} }, + + { CPU_Not64, MOD_GasSufB, 0, 0, 0, 1, {0xA2, 0, 0}, 0, 2, + {OPT_MemOffs|OPS_8|OPS_Relaxed|OPA_EA, OPT_Areg|OPS_8|OPA_None, 0} }, + { CPU_Not64, MOD_GasSufW, 16, 0, 0, 1, {0xA3, 0, 0}, 0, 2, + {OPT_MemOffs|OPS_16|OPS_Relaxed|OPA_EA, OPT_Areg|OPS_16|OPA_None, 0} }, + { CPU_386|CPU_Not64, MOD_GasSufL, 32, 0, 0, 1, {0xA3, 0, 0}, 0, 2, + {OPT_MemOffs|OPS_32|OPS_Relaxed|OPA_EA, OPT_Areg|OPS_32|OPA_None, 0} }, + + /* 64-bit absolute forms for 64-bit mode. Disabled for GAS, see movabs */ + { CPU_Hammer|CPU_64, 0, 0, 0, 0, 1, {0xA0, 0, 0}, 0, 2, + {OPT_Areg|OPS_8|OPA_None, + OPT_MemOffs|OPS_8|OPS_Relaxed|OPEAS_64|OPA_EA, 0} }, + { CPU_Hammer|CPU_64, 0, 16, 0, 0, 1, {0xA1, 0, 0}, 0, 2, + {OPT_Areg|OPS_16|OPA_None, + OPT_MemOffs|OPS_16|OPS_Relaxed|OPEAS_64|OPA_EA, 0} }, + { CPU_Hammer|CPU_64, 0, 32, 0, 0, 1, {0xA1, 0, 0}, 0, 2, + {OPT_Areg|OPS_32|OPA_None, + OPT_MemOffs|OPS_32|OPS_Relaxed|OPEAS_64|OPA_EA, 0} }, + { CPU_Hammer|CPU_64, 0, 64, 0, 0, 1, {0xA1, 0, 0}, 0, 2, + {OPT_Areg|OPS_64|OPA_None, + OPT_MemOffs|OPS_64|OPS_Relaxed|OPEAS_64|OPA_EA, 0} }, + + { CPU_Hammer|CPU_64, 0, 0, 0, 0, 1, {0xA2, 0, 0}, 0, 2, + {OPT_MemOffs|OPS_8|OPS_Relaxed|OPEAS_64|OPA_EA, + OPT_Areg|OPS_8|OPA_None, 0} }, + { CPU_Hammer|CPU_64, 0, 16, 0, 0, 1, {0xA3, 0, 0}, 0, 2, + {OPT_MemOffs|OPS_16|OPS_Relaxed|OPEAS_64|OPA_EA, + OPT_Areg|OPS_16|OPA_None, 0} }, + { CPU_Hammer|CPU_64, 0, 32, 0, 0, 1, {0xA3, 0, 0}, 0, 2, + {OPT_MemOffs|OPS_32|OPS_Relaxed|OPEAS_64|OPA_EA, + OPT_Areg|OPS_32|OPA_None, 0} }, + { CPU_Hammer|CPU_64, 0, 64, 0, 0, 1, {0xA3, 0, 0}, 0, 2, + {OPT_MemOffs|OPS_64|OPS_Relaxed|OPEAS_64|OPA_EA, + OPT_Areg|OPS_64|OPA_None, 0} }, + + /* General 32-bit forms using Areg / short absolute option */ + { CPU_Any, MOD_GasSufB, 0, 0, 0, 1, {0x88, 0xA2, 0}, 0, 2, + {OPT_RM|OPS_8|OPS_Relaxed|OPA_EA|OPAP_ShortMov, OPT_Areg|OPS_8|OPA_Spare, + 0} }, + { CPU_Any, MOD_GasSufW, 16, 0, 0, 1, {0x89, 0xA3, 0}, 0, 2, + {OPT_RM|OPS_16|OPS_Relaxed|OPA_EA|OPAP_ShortMov, + OPT_Areg|OPS_16|OPA_Spare, 0} }, + { CPU_386, MOD_GasSufL, 32, 0, 0, 1, {0x89, 0xA3, 0}, 0, 2, + {OPT_RM|OPS_32|OPS_Relaxed|OPA_EA|OPAP_ShortMov, + OPT_Areg|OPS_32|OPA_Spare, 0} }, + { CPU_Hammer|CPU_64, MOD_GasSufQ, 64, 0, 0, 1, {0x89, 0xA3, 0}, 0, 2, + {OPT_RM|OPS_64|OPS_Relaxed|OPA_EA|OPAP_ShortMov, + OPT_Areg|OPS_64|OPA_Spare, 0} }, + + /* General 32-bit forms */ + { CPU_Any, MOD_GasSufB, 0, 0, 0, 1, {0x88, 0, 0}, 0, 2, + {OPT_RM|OPS_8|OPS_Relaxed|OPA_EA, OPT_Reg|OPS_8|OPA_Spare, 0} }, + { CPU_Any, MOD_GasSufW, 16, 0, 0, 1, {0x89, 0, 0}, 0, 2, + {OPT_RM|OPS_16|OPS_Relaxed|OPA_EA, OPT_Reg|OPS_16|OPA_Spare, 0} }, + { CPU_386, MOD_GasSufL, 32, 0, 0, 1, {0x89, 0, 0}, 0, 2, + {OPT_RM|OPS_32|OPS_Relaxed|OPA_EA, OPT_Reg|OPS_32|OPA_Spare, 0} }, + { CPU_Hammer|CPU_64, MOD_GasSufQ, 64, 0, 0, 1, {0x89, 0, 0}, 0, 2, + {OPT_RM|OPS_64|OPS_Relaxed|OPA_EA, OPT_Reg|OPS_64|OPA_Spare, 0} }, + + /* General 32-bit forms using Areg / short absolute option */ + { CPU_Any, MOD_GasSufB, 0, 0, 0, 1, {0x8A, 0xA0, 0}, 0, 2, + {OPT_Areg|OPS_8|OPA_Spare, OPT_RM|OPS_8|OPS_Relaxed|OPA_EA|OPAP_ShortMov, + 0} }, + { CPU_Any, MOD_GasSufW, 16, 0, 0, 1, {0x8B, 0xA1, 0}, 0, 2, + {OPT_Areg|OPS_16|OPA_Spare, + OPT_RM|OPS_16|OPS_Relaxed|OPA_EA|OPAP_ShortMov, 0} }, + { CPU_386, MOD_GasSufL, 32, 0, 0, 1, {0x8B, 0xA1, 0}, 0, 2, + {OPT_Areg|OPS_32|OPA_Spare, + OPT_RM|OPS_32|OPS_Relaxed|OPA_EA|OPAP_ShortMov, 0} }, + { CPU_Hammer|CPU_64, MOD_GasSufQ, 64, 0, 0, 1, {0x8B, 0xA1, 0}, 0, 2, + {OPT_Areg|OPS_64|OPA_Spare, + OPT_RM|OPS_64|OPS_Relaxed|OPA_EA|OPAP_ShortMov, 0} }, + + /* General 32-bit forms */ + { CPU_Any, MOD_GasSufB, 0, 0, 0, 1, {0x8A, 0, 0}, 0, 2, + {OPT_Reg|OPS_8|OPA_Spare, OPT_RM|OPS_8|OPS_Relaxed|OPA_EA, 0} }, + { CPU_Any, MOD_GasSufW, 16, 0, 0, 1, {0x8B, 0, 0}, 0, 2, + {OPT_Reg|OPS_16|OPA_Spare, OPT_RM|OPS_16|OPS_Relaxed|OPA_EA, 0} }, + { CPU_386, MOD_GasSufL, 32, 0, 0, 1, {0x8B, 0, 0}, 0, 2, + {OPT_Reg|OPS_32|OPA_Spare, OPT_RM|OPS_32|OPS_Relaxed|OPA_EA, 0} }, + { CPU_Hammer|CPU_64, MOD_GasSufQ, 64, 0, 0, 1, {0x8B, 0, 0}, 0, 2, + {OPT_Reg|OPS_64|OPA_Spare, OPT_RM|OPS_64|OPS_Relaxed|OPA_EA, 0} }, + + /* Segment register forms */ + { CPU_Any, MOD_GasSufW, 0, 0, 0, 1, {0x8C, 0, 0}, 0, 2, + {OPT_Mem|OPS_16|OPS_Relaxed|OPA_EA, + OPT_SegReg|OPS_16|OPS_Relaxed|OPA_Spare, 0} }, + { CPU_Any, MOD_GasSufW, 16, 0, 0, 1, {0x8C, 0, 0}, 0, 2, + {OPT_Reg|OPS_16|OPA_EA, OPT_SegReg|OPS_16|OPS_Relaxed|OPA_Spare, 0} }, + { CPU_386, MOD_GasSufL, 32, 0, 0, 1, {0x8C, 0, 0}, 0, 2, + {OPT_Reg|OPS_32|OPA_EA, OPT_SegReg|OPS_16|OPS_Relaxed|OPA_Spare, 0} }, + { CPU_Hammer|CPU_64, MOD_GasSufQ, 64, 0, 0, 1, {0x8C, 0, 0}, 0, 2, + {OPT_Reg|OPS_64|OPA_EA, OPT_SegReg|OPS_16|OPS_Relaxed|OPA_Spare, 0} }, + + { CPU_Any, MOD_GasSufW, 0, 0, 0, 1, {0x8E, 0, 0}, 0, 2, + {OPT_SegReg|OPS_16|OPS_Relaxed|OPA_Spare, + OPT_RM|OPS_16|OPS_Relaxed|OPA_EA, 0} }, + { CPU_386, MOD_GasSufL, 0, 0, 0, 1, {0x8E, 0, 0}, 0, 2, + {OPT_SegReg|OPS_16|OPS_Relaxed|OPA_Spare, OPT_Reg|OPS_32|OPA_EA, 0} }, + { CPU_Hammer|CPU_64, MOD_GasSufQ, 0, 0, 0, 1, {0x8E, 0, 0}, 0, 2, + {OPT_SegReg|OPS_16|OPS_Relaxed|OPA_Spare, OPT_Reg|OPS_64|OPA_EA, 0} }, + + /* Immediate forms */ + { CPU_Any, MOD_GasSufB, 0, 0, 0, 1, {0xB0, 0, 0}, 0, 2, + {OPT_Reg|OPS_8|OPA_Op0Add, OPT_Imm|OPS_8|OPS_Relaxed|OPA_Imm, 0} }, + { CPU_Any, MOD_GasSufW, 16, 0, 0, 1, {0xB8, 0, 0}, 0, 2, + {OPT_Reg|OPS_16|OPA_Op0Add, OPT_Imm|OPS_16|OPS_Relaxed|OPA_Imm, 0} }, + { CPU_386, MOD_GasSufL, 32, 0, 0, 1, {0xB8, 0, 0}, 0, 2, + {OPT_Reg|OPS_32|OPA_Op0Add, OPT_Imm|OPS_32|OPS_Relaxed|OPA_Imm, 0} }, + /* 64-bit forced size form */ + { CPU_Hammer|CPU_64, MOD_GasIllegal, 64, 0, 0, 1, {0xB8, 0, 0}, 0, 2, + {OPT_Reg|OPS_64|OPA_Op0Add, OPT_Imm|OPS_64|OPA_Imm, 0} }, + { CPU_Hammer|CPU_64, MOD_GasSufQ, 64, 0, 0, 1, {0xB8, 0xC7, 0}, 0, 2, + {OPT_Reg|OPS_64|OPA_Op0Add, + OPT_Imm|OPS_64|OPS_Relaxed|OPA_Imm|OPAP_SImm32Avail, 0} }, + /* Need two sets here, one for strictness on left side, one for right. */ + { CPU_Any, MOD_GasSufB, 0, 0, 0, 1, {0xC6, 0, 0}, 0, 2, + {OPT_RM|OPS_8|OPS_Relaxed|OPA_EA, OPT_Imm|OPS_8|OPA_Imm, 0} }, + { CPU_Any, MOD_GasSufW, 16, 0, 0, 1, {0xC7, 0, 0}, 0, 2, + {OPT_RM|OPS_16|OPS_Relaxed|OPA_EA, OPT_Imm|OPS_16|OPA_Imm, 0} }, + { CPU_386, MOD_GasSufL, 32, 0, 0, 1, {0xC7, 0, 0}, 0, 2, + {OPT_RM|OPS_32|OPS_Relaxed|OPA_EA, OPT_Imm|OPS_32|OPA_Imm, 0} }, + { CPU_Hammer|CPU_64, MOD_GasSufQ, 64, 0, 0, 1, {0xC7, 0, 0}, 0, 2, + {OPT_RM|OPS_64|OPS_Relaxed|OPA_EA, OPT_Imm|OPS_32|OPA_Imm, 0} }, + { CPU_Any, MOD_GasSufB, 0, 0, 0, 1, {0xC6, 0, 0}, 0, 2, + {OPT_RM|OPS_8|OPA_EA, OPT_Imm|OPS_8|OPS_Relaxed|OPA_Imm, 0} }, + { CPU_Any, MOD_GasSufW, 16, 0, 0, 1, {0xC7, 0, 0}, 0, 2, + {OPT_RM|OPS_16|OPA_EA, OPT_Imm|OPS_16|OPS_Relaxed|OPA_Imm, 0} }, + { CPU_386, MOD_GasSufL, 32, 0, 0, 1, {0xC7, 0, 0}, 0, 2, + {OPT_RM|OPS_32|OPA_EA, OPT_Imm|OPS_32|OPS_Relaxed|OPA_Imm, 0} }, + { CPU_Hammer|CPU_64, MOD_GasSufQ, 64, 0, 0, 1, {0xC7, 0, 0}, 0, 2, + {OPT_RM|OPS_64|OPA_EA, OPT_Imm|OPS_32|OPS_Relaxed|OPA_Imm, 0} }, + + /* CR/DR forms */ + { CPU_586|CPU_Priv|CPU_Not64, MOD_GasSufL, 0, 0, 0, 2, {0x0F, 0x22, 0}, 0, + 2, {OPT_CR4|OPS_32|OPA_Spare, OPT_Reg|OPS_32|OPA_EA, 0} }, + { CPU_386|CPU_Priv|CPU_Not64, MOD_GasSufL, 0, 0, 0, 2, {0x0F, 0x22, 0}, 0, + 2, {OPT_CRReg|OPS_32|OPA_Spare, OPT_Reg|OPS_32|OPA_EA, 0} }, + { CPU_Hammer|CPU_Priv|CPU_64, MOD_GasSufL, 0, 0, 0, 2, {0x0F, 0x22, 0}, 0, + 2, {OPT_CRReg|OPS_32|OPA_Spare, OPT_Reg|OPS_64|OPA_EA, 0} }, + { CPU_586|CPU_Priv|CPU_Not64, MOD_GasSufL, 0, 0, 0, 2, {0x0F, 0x20, 0}, 0, + 2, {OPT_Reg|OPS_32|OPA_EA, OPT_CR4|OPS_32|OPA_Spare, 0} }, + { CPU_386|CPU_Priv|CPU_Not64, MOD_GasSufL, 0, 0, 0, 2, {0x0F, 0x20, 0}, 0, + 2, {OPT_Reg|OPS_32|OPA_EA, OPT_CRReg|OPS_32|OPA_Spare, 0} }, + { CPU_Hammer|CPU_Priv|CPU_64, MOD_GasSufQ, 0, 0, 0, 2, {0x0F, 0x20, 0}, 0, + 2, {OPT_Reg|OPS_64|OPA_EA, OPT_CRReg|OPS_32|OPA_Spare, 0} }, + + { CPU_386|CPU_Priv|CPU_Not64, MOD_GasSufL, 0, 0, 0, 2, {0x0F, 0x23, 0}, 0, + 2, {OPT_DRReg|OPS_32|OPA_Spare, OPT_Reg|OPS_32|OPA_EA, 0} }, + { CPU_Hammer|CPU_Priv|CPU_64, MOD_GasSufL, 0, 0, 0, 2, {0x0F, 0x23, 0}, 0, + 2, {OPT_DRReg|OPS_32|OPA_Spare, OPT_Reg|OPS_64|OPA_EA, 0} }, + { CPU_386|CPU_Priv|CPU_Not64, MOD_GasSufL, 0, 0, 0, 2, {0x0F, 0x21, 0}, 0, + 2, {OPT_Reg|OPS_32|OPA_EA, OPT_DRReg|OPS_32|OPA_Spare, 0} }, + { CPU_Hammer|CPU_Priv|CPU_64, MOD_GasSufQ, 0, 0, 0, 2, {0x0F, 0x21, 0}, 0, + 2, {OPT_Reg|OPS_64|OPA_EA, OPT_DRReg|OPS_32|OPA_Spare, 0} }, + + /* MMX/SSE2 forms for GAS parser (copied from movq_insn) */ + { CPU_MMX, MOD_GasOnly|MOD_GasSufQ, 0, 0, 0, 2, {0x0F, 0x6F, 0}, 0, 2, + {OPT_SIMDReg|OPS_64|OPA_Spare, OPT_SIMDRM|OPS_64|OPS_Relaxed|OPA_EA, 0} + }, + { CPU_MMX|CPU_Hammer|CPU_64, MOD_GasOnly|MOD_GasSufQ, 64, 0, 0, 2, + {0x0F, 0x6E, 0}, 0, 2, + {OPT_SIMDReg|OPS_64|OPA_Spare, OPT_RM|OPS_64|OPS_Relaxed|OPA_EA, 0} }, + { CPU_MMX, MOD_GasOnly|MOD_GasSufQ, 0, 0, 0, 2, {0x0F, 0x7F, 0}, 0, 2, + {OPT_SIMDRM|OPS_64|OPS_Relaxed|OPA_EA, OPT_SIMDReg|OPS_64|OPA_Spare, 0} + }, + { CPU_MMX|CPU_Hammer|CPU_64, MOD_GasOnly|MOD_GasSufQ, 64, 0, 0, 2, + {0x0F, 0x7E, 0}, 0, 2, + {OPT_RM|OPS_64|OPS_Relaxed|OPA_EA, OPT_SIMDReg|OPS_64|OPA_Spare, 0} }, + { CPU_SSE2, MOD_GasOnly|MOD_GasSufQ, 0, 0, 0xF3, 2, {0x0F, 0x7E, 0}, 0, 2, + {OPT_SIMDReg|OPS_128|OPA_Spare, OPT_SIMDReg|OPS_128|OPA_EA, 0} }, + { CPU_SSE2, MOD_GasOnly|MOD_GasSufQ, 0, 0, 0xF3, 2, {0x0F, 0x7E, 0}, 0, 2, + {OPT_SIMDReg|OPS_128|OPA_Spare, OPT_SIMDRM|OPS_64|OPS_Relaxed|OPA_EA, 0} + }, + { CPU_SSE2|CPU_Hammer|CPU_64, MOD_GasOnly|MOD_GasSufQ, 64, 0, 0x66, 2, + {0x0F, 0x6E, 0}, 0, 2, + {OPT_SIMDReg|OPS_128|OPA_Spare, OPT_RM|OPS_64|OPS_Relaxed|OPA_EA, 0} }, + { CPU_SSE2, MOD_GasOnly|MOD_GasSufQ, 0, 0, 0x66, 2, {0x0F, 0xD6, 0}, 0, 2, + {OPT_SIMDRM|OPS_64|OPS_Relaxed|OPA_EA, OPT_SIMDReg|OPS_128|OPA_Spare, 0} + }, + { CPU_SSE2|CPU_Hammer|CPU_64, MOD_GasOnly|MOD_GasSufQ, 64, 0, 0x66, 2, + {0x0F, 0x7E, 0}, 0, 2, + {OPT_RM|OPS_64|OPS_Relaxed|OPA_EA, OPT_SIMDReg|OPS_128|OPA_Spare, 0} } +}; + +/* 64-bit absolute move (for GAS). + * These are disabled for GAS for normal mov above. */ -static int -x86_expr_contains_simd_cb(const yasm_expr__item *ei, void *d) -{ - int ymm = *((int *)d); - if (ei->type != YASM_EXPR_REG) - return 0; - switch ((x86_expritem_reg_size)(ei->data.reg & ~0xFUL)) { - case X86_XMMREG: - if (!ymm) - return 1; - break; - case X86_YMMREG: - if (ymm) - return 1; - break; - default: - break; - } - return 0; -} +static const x86_insn_info movabs_insn[] = { + { CPU_Hammer|CPU_64, MOD_GasSufB, 0, 0, 0, 1, {0xA0, 0, 0}, 0, 2, + {OPT_Areg|OPS_8|OPA_None, + OPT_MemOffs|OPS_8|OPS_Relaxed|OPEAS_64|OPA_EA, 0} }, + { CPU_Hammer|CPU_64, MOD_GasSufW, 16, 0, 0, 1, {0xA1, 0, 0}, 0, 2, + {OPT_Areg|OPS_16|OPA_None, + OPT_MemOffs|OPS_16|OPS_Relaxed|OPEAS_64|OPA_EA, 0} }, + { CPU_Hammer|CPU_64, MOD_GasSufL, 32, 0, 0, 1, {0xA1, 0, 0}, 0, 2, + {OPT_Areg|OPS_32|OPA_None, + OPT_MemOffs|OPS_32|OPS_Relaxed|OPEAS_64|OPA_EA, 0} }, + { CPU_Hammer|CPU_64, MOD_GasSufQ, 64, 0, 0, 1, {0xA1, 0, 0}, 0, 2, + {OPT_Areg|OPS_64|OPA_None, + OPT_MemOffs|OPS_64|OPS_Relaxed|OPEAS_64|OPA_EA, 0} }, + + { CPU_Hammer|CPU_64, MOD_GasSufB, 0, 0, 0, 1, {0xA2, 0, 0}, 0, 2, + {OPT_MemOffs|OPS_8|OPS_Relaxed|OPEAS_64|OPA_EA, + OPT_Areg|OPS_8|OPA_None, 0} }, + { CPU_Hammer|CPU_64, MOD_GasSufW, 16, 0, 0, 1, {0xA3, 0, 0}, 0, 2, + {OPT_MemOffs|OPS_16|OPS_Relaxed|OPEAS_64|OPA_EA, + OPT_Areg|OPS_16|OPA_None, 0} }, + { CPU_Hammer|CPU_64, MOD_GasSufL, 32, 0, 0, 1, {0xA3, 0, 0}, 0, 2, + {OPT_MemOffs|OPS_32|OPS_Relaxed|OPEAS_64|OPA_EA, + OPT_Areg|OPS_32|OPA_None, 0} }, + { CPU_Hammer|CPU_64, MOD_GasSufQ, 64, 0, 0, 1, {0xA3, 0, 0}, 0, 2, + {OPT_MemOffs|OPS_64|OPS_Relaxed|OPEAS_64|OPA_EA, + OPT_Areg|OPS_64|OPA_None, 0} }, + + /* 64-bit immediate form */ + { CPU_Hammer|CPU_64, MOD_GasSufQ, 64, 0, 0, 1, {0xB8, 0, 0}, 0, 2, + {OPT_Reg|OPS_64|OPA_Op0Add, OPT_Imm|OPS_64|OPS_Relaxed|OPA_Imm, 0} }, +}; + +/* Move with sign/zero extend */ +static const x86_insn_info movszx_insn[] = { + { CPU_386, MOD_Op1Add|MOD_GasSufB, 16, 0, 0, 2, {0x0F, 0, 0}, 0, 2, + {OPT_Reg|OPS_16|OPA_Spare, OPT_RM|OPS_8|OPS_Relaxed|OPA_EA, 0} }, + { CPU_386, MOD_Op1Add|MOD_GasSufB, 32, 0, 0, 2, {0x0F, 0, 0}, 0, 2, + {OPT_Reg|OPS_32|OPA_Spare, OPT_RM|OPS_8|OPA_EA, 0} }, + { CPU_Hammer|CPU_64, MOD_Op1Add|MOD_GasSufB, 64, 0, 0, 2, {0x0F, 0, 0}, 0, + 2, {OPT_Reg|OPS_64|OPA_Spare, OPT_RM|OPS_8|OPA_EA, 0} }, + { CPU_386, MOD_Op1Add|MOD_GasSufW, 32, 0, 0, 2, {0x0F, 1, 0}, 0, 2, + {OPT_Reg|OPS_32|OPA_Spare, OPT_RM|OPS_16|OPA_EA, 0} }, + { CPU_Hammer|CPU_64, MOD_Op1Add|MOD_GasSufW, 64, 0, 0, 2, {0x0F, 1, 0}, 0, + 2, {OPT_Reg|OPS_64|OPA_Spare, OPT_RM|OPS_16|OPA_EA, 0} } +}; + +/* Move with sign-extend doubleword (64-bit mode only) */ +static const x86_insn_info movsxd_insn[] = { + { CPU_Hammer|CPU_64, MOD_GasSufL, 64, 0, 0, 1, {0x63, 0, 0}, 0, 2, + {OPT_Reg|OPS_64|OPA_Spare, OPT_RM|OPS_32|OPA_EA, 0} } +}; + +/* Push instructions */ +static const x86_insn_info push_insn[] = { + { CPU_Any, MOD_GasSufW, 16, 64, 0, 1, {0x50, 0, 0}, 0, 1, + {OPT_Reg|OPS_16|OPA_Op0Add, 0, 0} }, + { CPU_386|CPU_Not64, MOD_GasSufL, 32, 0, 0, 1, {0x50, 0, 0}, 0, 1, + {OPT_Reg|OPS_32|OPA_Op0Add, 0, 0} }, + { CPU_Hammer|CPU_64, MOD_GasSufQ, 0, 64, 0, 1, {0x50, 0, 0}, 0, 1, + {OPT_Reg|OPS_64|OPA_Op0Add, 0, 0} }, + { CPU_Any, MOD_GasSufW, 16, 64, 0, 1, {0xFF, 0, 0}, 6, 1, + {OPT_RM|OPS_16|OPA_EA, 0, 0} }, + { CPU_386|CPU_Not64, MOD_GasSufL, 32, 0, 0, 1, {0xFF, 0, 0}, 6, 1, + {OPT_RM|OPS_32|OPA_EA, 0, 0} }, + { CPU_Hammer|CPU_64, MOD_GasSufQ, 0, 64, 0, 1, {0xFF, 0, 0}, 6, 1, + {OPT_RM|OPS_64|OPA_EA, 0, 0} }, + { CPU_186, MOD_GasIllegal, 0, 64, 0, 1, {0x6A, 0, 0}, 0, 1, + {OPT_Imm|OPS_8|OPA_SImm, 0, 0} }, + { CPU_186, MOD_GasOnly|MOD_GasSufB, 0, 64, 0, 1, {0x6A, 0, 0}, 0, 1, + {OPT_Imm|OPS_8|OPS_Relaxed|OPA_SImm, 0, 0} }, + { CPU_186, MOD_GasOnly|MOD_GasSufW, 16, 64, 0, 1, {0x6A, 0x68, 0}, 0, 1, + {OPT_Imm|OPS_16|OPS_Relaxed|OPA_Imm|OPAP_SImm8, 0, 0} }, + { CPU_386|CPU_Not64, MOD_GasOnly|MOD_GasSufL, 32, 0, 0, 1, + {0x6A, 0x68, 0}, 0, 1, + {OPT_Imm|OPS_32|OPS_Relaxed|OPA_Imm|OPAP_SImm8, 0, 0} }, + { CPU_Hammer|CPU_64, MOD_GasSufQ, 64, 64, 0, 1, + {0x6A, 0x68, 0}, 0, 1, + {OPT_Imm|OPS_32|OPS_Relaxed|OPA_SImm|OPAP_SImm8, 0, 0} }, + { CPU_186|CPU_Not64, MOD_GasIllegal, 0, 0, 0, 1, + {0x6A, 0x68, 0}, 0, 1, + {OPT_Imm|OPS_BITS|OPS_Relaxed|OPA_Imm|OPAP_SImm8, 0, 0} }, + /* Need these when we don't match the BITS size, but they need to be + * below the above line so the optimizer can kick in by default. + */ + { CPU_186, MOD_GasIllegal, 16, 64, 0, 1, {0x68, 0, 0}, 0, 1, + {OPT_Imm|OPS_16|OPA_Imm, 0, 0} }, + { CPU_386|CPU_Not64, MOD_GasIllegal, 32, 0, 0, 1, {0x68, 0, 0}, 0, 1, + {OPT_Imm|OPS_32|OPA_Imm, 0, 0} }, + { CPU_Hammer|CPU_64, MOD_GasIllegal, 64, 64, 0, 1, {0x68, 0, 0}, 0, 1, + {OPT_Imm|OPS_32|OPA_SImm, 0, 0} }, + { CPU_Not64, 0, 0, 0, 0, 1, {0x0E, 0, 0}, 0, 1, + {OPT_CS|OPS_Any|OPA_None, 0, 0} }, + { CPU_Not64, MOD_GasSufW, 16, 0, 0, 1, {0x0E, 0, 0}, 0, 1, + {OPT_CS|OPS_16|OPA_None, 0, 0} }, + { CPU_Not64, MOD_GasSufL, 32, 0, 0, 1, {0x0E, 0, 0}, 0, 1, + {OPT_CS|OPS_32|OPA_None, 0, 0} }, + { CPU_Not64, 0, 0, 0, 0, 1, {0x16, 0, 0}, 0, 1, + {OPT_SS|OPS_Any|OPA_None, 0, 0} }, + { CPU_Not64, MOD_GasSufW, 16, 0, 0, 1, {0x16, 0, 0}, 0, 1, + {OPT_SS|OPS_16|OPA_None, 0, 0} }, + { CPU_Not64, MOD_GasSufL, 32, 0, 0, 1, {0x16, 0, 0}, 0, 1, + {OPT_SS|OPS_32|OPA_None, 0, 0} }, + { CPU_Not64, 0, 0, 0, 0, 1, {0x1E, 0, 0}, 0, 1, + {OPT_DS|OPS_Any|OPA_None, 0, 0} }, + { CPU_Not64, MOD_GasSufW, 16, 0, 0, 1, {0x1E, 0, 0}, 0, 1, + {OPT_DS|OPS_16|OPA_None, 0, 0} }, + { CPU_Not64, MOD_GasSufL, 32, 0, 0, 1, {0x1E, 0, 0}, 0, 1, + {OPT_DS|OPS_32|OPA_None, 0, 0} }, + { CPU_Not64, 0, 0, 0, 0, 1, {0x06, 0, 0}, 0, 1, + {OPT_ES|OPS_Any|OPA_None, 0, 0} }, + { CPU_Not64, MOD_GasSufW, 16, 0, 0, 1, {0x06, 0, 0}, 0, 1, + {OPT_ES|OPS_16|OPA_None, 0, 0} }, + { CPU_Not64, MOD_GasSufL, 32, 0, 0, 1, {0x06, 0, 0}, 0, 1, + {OPT_ES|OPS_32|OPA_None, 0, 0} }, + { CPU_386, 0, 0, 0, 0, 2, {0x0F, 0xA0, 0}, 0, 1, + {OPT_FS|OPS_Any|OPA_None, 0, 0} }, + { CPU_386, MOD_GasSufW, 16, 0, 0, 2, {0x0F, 0xA0, 0}, 0, 1, + {OPT_FS|OPS_16|OPA_None, 0, 0} }, + { CPU_386, MOD_GasSufL, 32, 0, 0, 2, {0x0F, 0xA0, 0}, 0, 1, + {OPT_FS|OPS_32|OPA_None, 0, 0} }, + { CPU_386, 0, 0, 0, 0, 2, {0x0F, 0xA8, 0}, 0, 1, + {OPT_GS|OPS_Any|OPA_None, 0, 0} }, + { CPU_386, MOD_GasSufW, 16, 0, 0, 2, {0x0F, 0xA8, 0}, 0, 1, + {OPT_GS|OPS_16|OPA_None, 0, 0} }, + { CPU_386, MOD_GasSufL, 32, 0, 0, 2, {0x0F, 0xA8, 0}, 0, 1, + {OPT_GS|OPS_32|OPA_None, 0, 0} } +}; + +/* Pop instructions */ +static const x86_insn_info pop_insn[] = { + { CPU_Any, MOD_GasSufW, 16, 64, 0, 1, {0x58, 0, 0}, 0, 1, + {OPT_Reg|OPS_16|OPA_Op0Add, 0, 0} }, + { CPU_386|CPU_Not64, MOD_GasSufL, 32, 0, 0, 1, {0x58, 0, 0}, 0, 1, + {OPT_Reg|OPS_32|OPA_Op0Add, 0, 0} }, + { CPU_Hammer|CPU_64, MOD_GasSufQ, 0, 64, 0, 1, {0x58, 0, 0}, 0, 1, + {OPT_Reg|OPS_64|OPA_Op0Add, 0, 0} }, + { CPU_Any, MOD_GasSufW, 16, 64, 0, 1, {0x8F, 0, 0}, 0, 1, + {OPT_RM|OPS_16|OPA_EA, 0, 0} }, + { CPU_386|CPU_Not64, MOD_GasSufL, 32, 0, 0, 1, {0x8F, 0, 0}, 0, 1, + {OPT_RM|OPS_32|OPA_EA, 0, 0} }, + { CPU_Hammer|CPU_64, MOD_GasSufQ, 0, 64, 0, 1, {0x8F, 0, 0}, 0, 1, + {OPT_RM|OPS_64|OPA_EA, 0, 0} }, + /* POP CS is debateably valid on the 8086, if obsolete and undocumented. + * We don't include it because it's VERY unlikely it will ever be used + * anywhere. If someone really wants it they can db 0x0F it. + */ + /*{ CPU_Any|CPU_Undoc|CPU_Obs, 0, 0, 1, {0x0F, 0, 0}, 0, 1, + {OPT_CS|OPS_Any|OPA_None, 0, 0} },*/ + { CPU_Not64, 0, 0, 0, 0, 1, {0x17, 0, 0}, 0, 1, + {OPT_SS|OPS_Any|OPA_None, 0, 0} }, + { CPU_Not64, 0, 16, 0, 0, 1, {0x17, 0, 0}, 0, 1, + {OPT_SS|OPS_16|OPA_None, 0, 0} }, + { CPU_Not64, 0, 32, 0, 0, 1, {0x17, 0, 0}, 0, 1, + {OPT_SS|OPS_32|OPA_None, 0, 0} }, + { CPU_Not64, 0, 0, 0, 0, 1, {0x1F, 0, 0}, 0, 1, + {OPT_DS|OPS_Any|OPA_None, 0, 0} }, + { CPU_Not64, 0, 16, 0, 0, 1, {0x1F, 0, 0}, 0, 1, + {OPT_DS|OPS_16|OPA_None, 0, 0} }, + { CPU_Not64, 0, 32, 0, 0, 1, {0x1F, 0, 0}, 0, 1, + {OPT_DS|OPS_32|OPA_None, 0, 0} }, + { CPU_Not64, 0, 0, 0, 0, 1, {0x07, 0, 0}, 0, 1, + {OPT_ES|OPS_Any|OPA_None, 0, 0} }, + { CPU_Not64, 0, 16, 0, 0, 1, {0x07, 0, 0}, 0, 1, + {OPT_ES|OPS_16|OPA_None, 0, 0} }, + { CPU_Not64, 0, 32, 0, 0, 1, {0x07, 0, 0}, 0, 1, + {OPT_ES|OPS_32|OPA_None, 0, 0} }, + { CPU_386, 0, 0, 0, 0, 2, {0x0F, 0xA1, 0}, 0, 1, + {OPT_FS|OPS_Any|OPA_None, 0, 0} }, + { CPU_386, 0, 16, 0, 0, 2, {0x0F, 0xA1, 0}, 0, 1, + {OPT_FS|OPS_16|OPA_None, 0, 0} }, + { CPU_386, 0, 32, 0, 0, 2, {0x0F, 0xA1, 0}, 0, 1, + {OPT_FS|OPS_32|OPA_None, 0, 0} }, + { CPU_386, 0, 0, 0, 0, 2, {0x0F, 0xA9, 0}, 0, 1, + {OPT_GS|OPS_Any|OPA_None, 0, 0} }, + { CPU_386, 0, 16, 0, 0, 2, {0x0F, 0xA9, 0}, 0, 1, + {OPT_GS|OPS_16|OPA_None, 0, 0} }, + { CPU_386, 0, 32, 0, 0, 2, {0x0F, 0xA9, 0}, 0, 1, + {OPT_GS|OPS_32|OPA_None, 0, 0} } +}; + +/* Exchange instructions */ +static const x86_insn_info xchg_insn[] = { + { CPU_Any, MOD_GasSufB, 0, 0, 0, 1, {0x86, 0, 0}, 0, 2, + {OPT_RM|OPS_8|OPS_Relaxed|OPA_EA, OPT_Reg|OPS_8|OPA_Spare, 0} }, + { CPU_Any, MOD_GasSufB, 0, 0, 0, 1, {0x86, 0, 0}, 0, 2, + {OPT_Reg|OPS_8|OPA_Spare, OPT_RM|OPS_8|OPS_Relaxed|OPA_EA, 0} }, + /* We could be extra-efficient in the 64-bit mode case here. + * XCHG AX, AX in 64-bit mode is a NOP, as it doesn't clear the + * high 48 bits of RAX. Thus we don't need the operand-size prefix. + * But this feels too clever, and probably not what the user really + * expects in the generated code, so we don't do it. + * + * { CPU_Any|CPU_64, MOD_GasSufW, 0, 0, 0, 1, {0x90, 0, 0}, 0, 2, + * {OPT_Areg|OPS_16|OPA_None, OPT_Areg|OPS_16|OPA_Op0Add, 0} }, + */ + { CPU_Any, MOD_GasSufW, 16, 0, 0, 1, {0x90, 0, 0}, 0, 2, + {OPT_Areg|OPS_16|OPA_None, OPT_Reg|OPS_16|OPA_Op0Add, 0} }, + { CPU_Any, MOD_GasSufW, 16, 0, 0, 1, {0x90, 0, 0}, 0, 2, + {OPT_Reg|OPS_16|OPA_Op0Add, OPT_Areg|OPS_16|OPA_None, 0} }, + { CPU_Any, MOD_GasSufW, 16, 0, 0, 1, {0x87, 0, 0}, 0, 2, + {OPT_RM|OPS_16|OPS_Relaxed|OPA_EA, OPT_Reg|OPS_16|OPA_Spare, 0} }, + { CPU_Any, MOD_GasSufW, 16, 0, 0, 1, {0x87, 0, 0}, 0, 2, + {OPT_Reg|OPS_16|OPA_Spare, OPT_RM|OPS_16|OPS_Relaxed|OPA_EA, 0} }, + /* Be careful with XCHG EAX, EAX in 64-bit mode. This needs to use + * the long form rather than the NOP form, as the long form clears + * the high 32 bits of RAX. This makes all 32-bit forms in 64-bit + * mode have consistent operation. + */ + { CPU_386|CPU_64, MOD_GasSufL, 32, 0, 0, 1, {0x87, 0, 0}, 0, 2, + {OPT_Areg|OPS_32|OPA_EA, OPT_Areg|OPS_32|OPA_Spare, 0} }, + { CPU_386, MOD_GasSufL, 32, 0, 0, 1, {0x90, 0, 0}, 0, 2, + {OPT_Areg|OPS_32|OPA_None, OPT_Reg|OPS_32|OPA_Op0Add, 0} }, + { CPU_386, MOD_GasSufL, 32, 0, 0, 1, {0x90, 0, 0}, 0, 2, + {OPT_Reg|OPS_32|OPA_Op0Add, OPT_Areg|OPS_32|OPA_None, 0} }, + { CPU_386, MOD_GasSufL, 32, 0, 0, 1, {0x87, 0, 0}, 0, 2, + {OPT_RM|OPS_32|OPS_Relaxed|OPA_EA, OPT_Reg|OPS_32|OPA_Spare, 0} }, + { CPU_386, MOD_GasSufL, 32, 0, 0, 1, {0x87, 0, 0}, 0, 2, + {OPT_Reg|OPS_32|OPA_Spare, OPT_RM|OPS_32|OPS_Relaxed|OPA_EA, 0} }, + /* Be efficient with XCHG RAX, RAX. + * This is a NOP and thus doesn't need the REX prefix. + */ + { CPU_Hammer|CPU_64, MOD_GasSufQ, 0, 0, 0, 1, {0x90, 0, 0}, 0, 2, + {OPT_Areg|OPS_64|OPA_None, OPT_Areg|OPS_64|OPA_Op0Add, 0} }, + { CPU_Hammer|CPU_64, MOD_GasSufQ, 64, 0, 0, 1, {0x90, 0, 0}, 0, 2, + {OPT_Areg|OPS_64|OPA_None, OPT_Reg|OPS_64|OPA_Op0Add, 0} }, + { CPU_Hammer|CPU_64, MOD_GasSufQ, 64, 0, 0, 1, {0x90, 0, 0}, 0, 2, + {OPT_Reg|OPS_64|OPA_Op0Add, OPT_Areg|OPS_64|OPA_None, 0} }, + { CPU_Hammer|CPU_64, MOD_GasSufQ, 64, 0, 0, 1, {0x87, 0, 0}, 0, 2, + {OPT_RM|OPS_64|OPS_Relaxed|OPA_EA, OPT_Reg|OPS_64|OPA_Spare, 0} }, + { CPU_Hammer|CPU_64, MOD_GasSufQ, 64, 0, 0, 1, {0x87, 0, 0}, 0, 2, + {OPT_Reg|OPS_64|OPA_Spare, OPT_RM|OPS_64|OPS_Relaxed|OPA_EA, 0} } +}; + +/* In/out from ports */ +static const x86_insn_info in_insn[] = { + { CPU_Any, MOD_GasSufB, 0, 0, 0, 1, {0xE4, 0, 0}, 0, 2, + {OPT_Areg|OPS_8|OPA_None, OPT_Imm|OPS_8|OPS_Relaxed|OPA_Imm, 0} }, + { CPU_Any, MOD_GasSufW, 16, 0, 0, 1, {0xE5, 0, 0}, 0, 2, + {OPT_Areg|OPS_16|OPA_None, OPT_Imm|OPS_8|OPS_Relaxed|OPA_Imm, 0} }, + { CPU_386, MOD_GasSufL, 32, 0, 0, 1, {0xE5, 0, 0}, 0, 2, + {OPT_Areg|OPS_32|OPA_None, OPT_Imm|OPS_8|OPS_Relaxed|OPA_Imm, 0} }, + { CPU_Any, MOD_GasSufB, 0, 0, 0, 1, {0xEC, 0, 0}, 0, 2, + {OPT_Areg|OPS_8|OPA_None, OPT_Dreg|OPS_16|OPA_None, 0} }, + { CPU_Any, MOD_GasSufW, 16, 0, 0, 1, {0xED, 0, 0}, 0, 2, + {OPT_Areg|OPS_16|OPA_None, OPT_Dreg|OPS_16|OPA_None, 0} }, + { CPU_386, MOD_GasSufL, 32, 0, 0, 1, {0xED, 0, 0}, 0, 2, + {OPT_Areg|OPS_32|OPA_None, OPT_Dreg|OPS_16|OPA_None, 0} }, + /* GAS-only variants (implict accumulator register) */ + { CPU_Any, MOD_GasOnly|MOD_GasSufB, 0, 0, 0, 1, {0xE4, 0, 0}, 0, 1, + {OPT_Imm|OPS_8|OPS_Relaxed|OPA_Imm, 0, 0} }, + { CPU_Any, MOD_GasOnly|MOD_GasSufW, 16, 0, 0, 1, {0xE5, 0, 0}, 0, 1, + {OPT_Imm|OPS_8|OPS_Relaxed|OPA_Imm, 0, 0} }, + { CPU_386, MOD_GasOnly|MOD_GasSufL, 32, 0, 0, 1, {0xE5, 0, 0}, 0, 1, + {OPT_Imm|OPS_8|OPS_Relaxed|OPA_Imm, 0, 0} }, + { CPU_Any, MOD_GasOnly|MOD_GasSufB, 0, 0, 0, 1, {0xEC, 0, 0}, 0, 1, + {OPT_Dreg|OPS_16|OPA_None, 0, 0} }, + { CPU_Any, MOD_GasOnly|MOD_GasSufW, 16, 0, 0, 1, {0xED, 0, 0}, 0, 1, + {OPT_Dreg|OPS_16|OPA_None, 0, 0} }, + { CPU_386, MOD_GasOnly|MOD_GasSufL, 32, 0, 0, 1, {0xED, 0, 0}, 0, 1, + {OPT_Dreg|OPS_16|OPA_None, 0, 0} } +}; +static const x86_insn_info out_insn[] = { + { CPU_Any, MOD_GasSufB, 0, 0, 0, 1, {0xE6, 0, 0}, 0, 2, + {OPT_Imm|OPS_8|OPS_Relaxed|OPA_Imm, OPT_Areg|OPS_8|OPA_None, 0} }, + { CPU_Any, MOD_GasSufW, 16, 0, 0, 1, {0xE7, 0, 0}, 0, 2, + {OPT_Imm|OPS_8|OPS_Relaxed|OPA_Imm, OPT_Areg|OPS_16|OPA_None, 0} }, + { CPU_386, MOD_GasSufL, 32, 0, 0, 1, {0xE7, 0, 0}, 0, 2, + {OPT_Imm|OPS_8|OPS_Relaxed|OPA_Imm, OPT_Areg|OPS_32|OPA_None, 0} }, + { CPU_Any, MOD_GasSufB, 0, 0, 0, 1, {0xEE, 0, 0}, 0, 2, + {OPT_Dreg|OPS_16|OPA_None, OPT_Areg|OPS_8|OPA_None, 0} }, + { CPU_Any, MOD_GasSufW, 16, 0, 0, 1, {0xEF, 0, 0}, 0, 2, + {OPT_Dreg|OPS_16|OPA_None, OPT_Areg|OPS_16|OPA_None, 0} }, + { CPU_386, MOD_GasSufL, 32, 0, 0, 1, {0xEF, 0, 0}, 0, 2, + {OPT_Dreg|OPS_16|OPA_None, OPT_Areg|OPS_32|OPA_None, 0} }, + /* GAS-only variants (implict accumulator register) */ + { CPU_Any, MOD_GasOnly|MOD_GasSufB, 0, 0, 0, 1, {0xE6, 0, 0}, 0, 1, + {OPT_Imm|OPS_8|OPS_Relaxed|OPA_Imm, 0, 0} }, + { CPU_Any, MOD_GasOnly|MOD_GasSufW, 16, 0, 0, 1, {0xE7, 0, 0}, 0, 1, + {OPT_Imm|OPS_8|OPS_Relaxed|OPA_Imm, 0, 0} }, + { CPU_386, MOD_GasOnly|MOD_GasSufL, 32, 0, 0, 1, {0xE7, 0, 0}, 0, 1, + {OPT_Imm|OPS_8|OPS_Relaxed|OPA_Imm, 0, 0} }, + { CPU_Any, MOD_GasOnly|MOD_GasSufB, 0, 0, 0, 1, {0xEE, 0, 0}, 0, 1, + {OPT_Dreg|OPS_16|OPA_None, 0, 0} }, + { CPU_Any, MOD_GasOnly|MOD_GasSufW, 16, 0, 0, 1, {0xEF, 0, 0}, 0, 1, + {OPT_Dreg|OPS_16|OPA_None, 0, 0} }, + { CPU_386, MOD_GasOnly|MOD_GasSufL, 32, 0, 0, 1, {0xEF, 0, 0}, 0, 1, + {OPT_Dreg|OPS_16|OPA_None, 0, 0} } +}; + +/* Load effective address */ +static const x86_insn_info lea_insn[] = { + { CPU_Any, MOD_GasSufW, 16, 0, 0, 1, {0x8D, 0, 0}, 0, 2, + {OPT_Reg|OPS_16|OPA_Spare, OPT_Mem|OPS_16|OPS_Relaxed|OPA_EA, 0} }, + { CPU_386, MOD_GasSufL, 32, 0, 0, 1, {0x8D, 0, 0}, 0, 2, + {OPT_Reg|OPS_32|OPA_Spare, OPT_Mem|OPS_32|OPS_Relaxed|OPA_EA, 0} }, + { CPU_Hammer|CPU_64, MOD_GasSufQ, 64, 0, 0, 1, {0x8D, 0, 0}, 0, 2, + {OPT_Reg|OPS_64|OPA_Spare, OPT_Mem|OPS_64|OPS_Relaxed|OPA_EA, 0} } +}; + +/* Load segment registers from memory */ +static const x86_insn_info ldes_insn[] = { + { CPU_Not64, MOD_Op0Add|MOD_GasSufW, 16, 0, 0, 1, {0, 0, 0}, 0, 2, + {OPT_Reg|OPS_16|OPA_Spare, OPT_Mem|OPS_Any|OPA_EA, 0} }, + { CPU_386|CPU_Not64, MOD_Op0Add|MOD_GasSufL, 32, 0, 0, 1, {0, 0, 0}, 0, 2, + {OPT_Reg|OPS_32|OPA_Spare, OPT_Mem|OPS_Any|OPA_EA, 0} } +}; +static const x86_insn_info lfgss_insn[] = { + { CPU_386, MOD_Op1Add|MOD_GasSufW, 16, 0, 0, 2, {0x0F, 0x00, 0}, 0, 2, + {OPT_Reg|OPS_16|OPA_Spare, OPT_Mem|OPS_Any|OPA_EA, 0} }, + { CPU_386, MOD_Op1Add|MOD_GasSufL, 32, 0, 0, 2, {0x0F, 0x00, 0}, 0, 2, + {OPT_Reg|OPS_32|OPA_Spare, OPT_Mem|OPS_Any|OPA_EA, 0} } +}; + +/* Arithmetic - general */ +static const x86_insn_info arith_insn[] = { + { CPU_Any, MOD_Op0Add|MOD_GasSufB, 0, 0, 0, 1, {0x04, 0, 0}, 0, 2, + {OPT_Areg|OPS_8|OPA_None, OPT_Imm|OPS_8|OPS_Relaxed|OPA_Imm, 0} }, + { CPU_Any, MOD_Op2Add|MOD_Op1AddSp|MOD_GasSufW, 16, 0, 0, 2, + {0x83, 0xC0, 0x05}, 0, 2, + {OPT_Areg|OPS_16|OPA_None, + OPT_Imm|OPS_16|OPS_Relaxed|OPA_Imm|OPAP_SImm8, 0} }, + { CPU_386, MOD_Op2Add|MOD_Op1AddSp|MOD_GasSufL, 32, 0, 0, 2, + {0x83, 0xC0, 0x05}, 0, 2, + {OPT_Areg|OPS_32|OPA_None, + OPT_Imm|OPS_32|OPS_Relaxed|OPA_Imm|OPAP_SImm8, 0} }, + { CPU_Hammer|CPU_64, MOD_Op2Add|MOD_Op1AddSp|MOD_GasSufQ, 64, 0, 0, 2, + {0x83, 0xC0, 0x05}, 0, + 2, {OPT_Areg|OPS_64|OPA_None, + OPT_Imm|OPS_32|OPS_Relaxed|OPA_Imm|OPAP_SImm8, 0} }, + + { CPU_Any, MOD_Gap0|MOD_SpAdd|MOD_GasSufB, 0, 0, 0, 1, {0x80, 0, 0}, 0, 2, + {OPT_RM|OPS_8|OPA_EA, OPT_Imm|OPS_8|OPS_Relaxed|OPA_Imm, 0} }, + { CPU_Any, MOD_Gap0|MOD_SpAdd|MOD_GasSufB, 0, 0, 0, 1, {0x80, 0, 0}, 0, 2, + {OPT_RM|OPS_8|OPS_Relaxed|OPA_EA, OPT_Imm|OPS_8|OPA_Imm, 0} }, + + { CPU_Any, MOD_Gap0|MOD_SpAdd|MOD_GasSufW, 16, 0, 0, 1, {0x83, 0, 0}, 0, 2, + {OPT_RM|OPS_16|OPA_EA, OPT_Imm|OPS_8|OPA_SImm, 0} }, + { CPU_Any, MOD_Gap0|MOD_SpAdd|MOD_GasIllegal, 16, 0, 0, 1, {0x83, 0x81, 0}, + 0, 2, {OPT_RM|OPS_16|OPS_Relaxed|OPA_EA, + OPT_Imm|OPS_16|OPA_Imm|OPAP_SImm8, 0} }, + { CPU_Any, MOD_Gap0|MOD_SpAdd|MOD_GasSufW, 16, 0, 0, 1, {0x83, 0x81, 0}, 0, + 2, {OPT_RM|OPS_16|OPA_EA, + OPT_Imm|OPS_16|OPS_Relaxed|OPA_Imm|OPAP_SImm8, 0} }, + + { CPU_386, MOD_Gap0|MOD_SpAdd|MOD_GasSufL, 32, 0, 0, 1, {0x83, 0, 0}, 0, 2, + {OPT_RM|OPS_32|OPA_EA, OPT_Imm|OPS_8|OPA_SImm, 0} }, + /* Not64 because we can't tell if add [], dword in 64-bit mode is supposed + * to be a qword destination or a dword destination. + */ + { CPU_386|CPU_Not64, MOD_Gap0|MOD_SpAdd|MOD_GasIllegal, 32, 0, 0, 1, + {0x83, 0x81, 0}, 0, 2, + {OPT_RM|OPS_32|OPS_Relaxed|OPA_EA, + OPT_Imm|OPS_32|OPA_Imm|OPAP_SImm8, 0} }, + { CPU_386, MOD_Gap0|MOD_SpAdd|MOD_GasSufL, 32, 0, 0, 1, {0x83, 0x81, 0}, 0, + 2, {OPT_RM|OPS_32|OPA_EA, + OPT_Imm|OPS_32|OPS_Relaxed|OPA_Imm|OPAP_SImm8, 0} }, + + /* No relaxed-RM mode for 64-bit destinations; see above Not64 comment. */ + { CPU_Hammer|CPU_64, MOD_Gap0|MOD_SpAdd|MOD_GasSufQ, 64, 0, 0, 1, + {0x83, 0, 0}, 0, 2, + {OPT_RM|OPS_64|OPA_EA, OPT_Imm|OPS_8|OPA_SImm, 0} }, + { CPU_Hammer|CPU_64, MOD_Gap0|MOD_SpAdd|MOD_GasSufQ, 64, 0, 0, 1, + {0x83, 0x81, 0}, 0, 2, + {OPT_RM|OPS_64|OPA_EA, + OPT_Imm|OPS_32|OPS_Relaxed|OPA_Imm|OPAP_SImm8, 0} }, + + { CPU_Any, MOD_Op0Add|MOD_GasSufB, 0, 0, 0, 1, {0x00, 0, 0}, 0, 2, + {OPT_RM|OPS_8|OPS_Relaxed|OPA_EA, OPT_Reg|OPS_8|OPA_Spare, 0} }, + { CPU_Any, MOD_Op0Add|MOD_GasSufW, 16, 0, 0, 1, {0x01, 0, 0}, 0, 2, + {OPT_RM|OPS_16|OPS_Relaxed|OPA_EA, OPT_Reg|OPS_16|OPA_Spare, 0} }, + { CPU_386, MOD_Op0Add|MOD_GasSufL, 32, 0, 0, 1, {0x01, 0, 0}, 0, 2, + {OPT_RM|OPS_32|OPS_Relaxed|OPA_EA, OPT_Reg|OPS_32|OPA_Spare, 0} }, + { CPU_Hammer|CPU_64, MOD_Op0Add|MOD_GasSufQ, 64, 0, 0, 1, {0x01, 0, 0}, 0, + 2, {OPT_RM|OPS_64|OPS_Relaxed|OPA_EA, OPT_Reg|OPS_64|OPA_Spare, 0} }, + { CPU_Any, MOD_Op0Add|MOD_GasSufB, 0, 0, 0, 1, {0x02, 0, 0}, 0, 2, + {OPT_Reg|OPS_8|OPA_Spare, OPT_RM|OPS_8|OPS_Relaxed|OPA_EA, 0} }, + { CPU_Any, MOD_Op0Add|MOD_GasSufW, 16, 0, 0, 1, {0x03, 0, 0}, 0, 2, + {OPT_Reg|OPS_16|OPA_Spare, OPT_RM|OPS_16|OPS_Relaxed|OPA_EA, 0} }, + { CPU_386, MOD_Op0Add|MOD_GasSufL, 32, 0, 0, 1, {0x03, 0, 0}, 0, 2, + {OPT_Reg|OPS_32|OPA_Spare, OPT_RM|OPS_32|OPS_Relaxed|OPA_EA, 0} }, + { CPU_Hammer|CPU_64, MOD_Op0Add|MOD_GasSufQ, 64, 0, 0, 1, {0x03, 0, 0}, 0, + 2, {OPT_Reg|OPS_64|OPA_Spare, OPT_RM|OPS_64|OPS_Relaxed|OPA_EA, 0} } +}; + +/* Arithmetic - inc/dec */ +static const x86_insn_info incdec_insn[] = { + { CPU_Any, MOD_Gap0|MOD_SpAdd|MOD_GasSufB, 0, 0, 0, 1, {0xFE, 0, 0}, 0, 1, + {OPT_RM|OPS_8|OPA_EA, 0, 0} }, + { CPU_Not64, MOD_Op0Add|MOD_GasSufW, 16, 0, 0, 1, {0, 0, 0}, 0, 1, + {OPT_Reg|OPS_16|OPA_Op0Add, 0, 0} }, + { CPU_Any, MOD_Gap0|MOD_SpAdd|MOD_GasSufW, 16, 0, 0, 1, {0xFF, 0, 0}, 0, + 1, {OPT_RM|OPS_16|OPA_EA, 0, 0} }, + { CPU_386|CPU_Not64, MOD_Op0Add|MOD_GasSufL, 32, 0, 0, 1, {0, 0, 0}, 0, 1, + {OPT_Reg|OPS_32|OPA_Op0Add, 0, 0} }, + { CPU_386, MOD_Gap0|MOD_SpAdd|MOD_GasSufL, 32, 0, 0, 1, {0xFF, 0, 0}, 0, 1, + {OPT_RM|OPS_32|OPA_EA, 0, 0} }, + { CPU_Hammer|CPU_64, MOD_Gap0|MOD_SpAdd|MOD_GasSufQ, 64, 0, 0, 1, + {0xFF, 0, 0}, 0, 1, {OPT_RM|OPS_64|OPA_EA, 0, 0} }, +}; + +/* Arithmetic - mul/neg/not F6 opcodes */ +static const x86_insn_info f6_insn[] = { + { CPU_Any, MOD_SpAdd|MOD_GasSufB, 0, 0, 0, 1, {0xF6, 0, 0}, 0, 1, + {OPT_RM|OPS_8|OPA_EA, 0, 0} }, + { CPU_Any, MOD_SpAdd|MOD_GasSufW, 16, 0, 0, 1, {0xF7, 0, 0}, 0, 1, + {OPT_RM|OPS_16|OPA_EA, 0, 0} }, + { CPU_386, MOD_SpAdd|MOD_GasSufL, 32, 0, 0, 1, {0xF7, 0, 0}, 0, 1, + {OPT_RM|OPS_32|OPA_EA, 0, 0} }, + { CPU_Hammer|CPU_64, MOD_SpAdd|MOD_GasSufQ, 64, 0, 0, 1, {0xF7, 0, 0}, 0, + 1, {OPT_RM|OPS_64|OPA_EA, 0, 0} }, +}; + +/* Arithmetic - div/idiv F6 opcodes + * These allow explicit accumulator in GAS mode. + */ +static const x86_insn_info div_insn[] = { + { CPU_Any, MOD_SpAdd|MOD_GasSufB, 0, 0, 0, 1, {0xF6, 0, 0}, 0, 1, + {OPT_RM|OPS_8|OPA_EA, 0, 0} }, + { CPU_Any, MOD_SpAdd|MOD_GasSufW, 16, 0, 0, 1, {0xF7, 0, 0}, 0, 1, + {OPT_RM|OPS_16|OPA_EA, 0, 0} }, + { CPU_386, MOD_SpAdd|MOD_GasSufL, 32, 0, 0, 1, {0xF7, 0, 0}, 0, 1, + {OPT_RM|OPS_32|OPA_EA, 0, 0} }, + { CPU_Hammer|CPU_64, MOD_SpAdd|MOD_GasSufQ, 64, 0, 0, 1, {0xF7, 0, 0}, 0, + 1, {OPT_RM|OPS_64|OPA_EA, 0, 0} }, + /* Versions with explicit accumulator */ + { CPU_Any, MOD_SpAdd|MOD_GasSufB, 0, 0, 0, 1, {0xF6, 0, 0}, 0, 2, + {OPT_Areg|OPS_8|OPA_None, OPT_RM|OPS_8|OPA_EA, 0} }, + { CPU_Any, MOD_SpAdd|MOD_GasSufW, 16, 0, 0, 1, {0xF7, 0, 0}, 0, 2, + {OPT_Areg|OPS_16|OPA_None, OPT_RM|OPS_16|OPA_EA, 0} }, + { CPU_386, MOD_SpAdd|MOD_GasSufL, 32, 0, 0, 1, {0xF7, 0, 0}, 0, 2, + {OPT_Areg|OPS_32|OPA_None, OPT_RM|OPS_32|OPA_EA, 0} }, + { CPU_Hammer|CPU_64, MOD_SpAdd|MOD_GasSufQ, 64, 0, 0, 1, {0xF7, 0, 0}, 0, + 2, {OPT_Areg|OPS_64|OPA_None, OPT_RM|OPS_64|OPA_EA, 0} }, +}; + +/* Arithmetic - test instruction */ +static const x86_insn_info test_insn[] = { + { CPU_Any, MOD_GasSufB, 0, 0, 0, 1, {0xA8, 0, 0}, 0, 2, + {OPT_Areg|OPS_8|OPA_None, OPT_Imm|OPS_8|OPS_Relaxed|OPA_Imm, 0} }, + { CPU_Any, MOD_GasSufW, 16, 0, 0, 1, {0xA9, 0, 0}, 0, 2, + {OPT_Areg|OPS_16|OPA_None, OPT_Imm|OPS_16|OPS_Relaxed|OPA_Imm, 0} }, + { CPU_386, MOD_GasSufL, 32, 0, 0, 1, {0xA9, 0, 0}, 0, 2, + {OPT_Areg|OPS_32|OPA_None, OPT_Imm|OPS_32|OPS_Relaxed|OPA_Imm, 0} }, + { CPU_Hammer|CPU_64, MOD_GasSufQ, 64, 0, 0, 1, {0xA9, 0, 0}, 0, 2, + {OPT_Areg|OPS_64|OPA_None, OPT_Imm|OPS_32|OPS_Relaxed|OPA_Imm, 0} }, + + { CPU_Any, MOD_GasSufB, 0, 0, 0, 1, {0xF6, 0, 0}, 0, 2, + {OPT_RM|OPS_8|OPA_EA, OPT_Imm|OPS_8|OPS_Relaxed|OPA_Imm, 0} }, + { CPU_Any, MOD_GasSufB, 0, 0, 0, 1, {0xF6, 0, 0}, 0, 2, + {OPT_RM|OPS_8|OPS_Relaxed|OPA_EA, OPT_Imm|OPS_8|OPA_Imm, 0} }, + { CPU_Any, MOD_GasSufW, 16, 0, 0, 1, {0xF7, 0, 0}, 0, 2, + {OPT_RM|OPS_16|OPA_EA, OPT_Imm|OPS_16|OPS_Relaxed|OPA_Imm, 0} }, + { CPU_Any, MOD_GasSufW, 16, 0, 0, 1, {0xF7, 0, 0}, 0, 2, + {OPT_RM|OPS_16|OPS_Relaxed|OPA_EA, OPT_Imm|OPS_16|OPA_Imm, 0} }, + { CPU_386, MOD_GasSufL, 32, 0, 0, 1, {0xF7, 0, 0}, 0, 2, + {OPT_RM|OPS_32|OPA_EA, OPT_Imm|OPS_32|OPS_Relaxed|OPA_Imm, 0} }, + { CPU_386, MOD_GasSufL, 32, 0, 0, 1, {0xF7, 0, 0}, 0, 2, + {OPT_RM|OPS_32|OPS_Relaxed|OPA_EA, OPT_Imm|OPS_32|OPA_Imm, 0} }, + { CPU_Hammer|CPU_64, MOD_GasSufQ, 64, 0, 0, 1, {0xF7, 0, 0}, 0, 2, + {OPT_RM|OPS_64|OPA_EA, OPT_Imm|OPS_32|OPS_Relaxed|OPA_Imm, 0} }, + { CPU_Hammer|CPU_64, MOD_GasSufQ, 64, 0, 0, 1, {0xF7, 0, 0}, 0, 2, + {OPT_RM|OPS_64|OPS_Relaxed|OPA_EA, OPT_Imm|OPS_32|OPA_Imm, 0} }, + + { CPU_Any, MOD_GasSufB, 0, 0, 0, 1, {0x84, 0, 0}, 0, 2, + {OPT_RM|OPS_8|OPS_Relaxed|OPA_EA, OPT_Reg|OPS_8|OPA_Spare, 0} }, + { CPU_Any, MOD_GasSufW, 16, 0, 0, 1, {0x85, 0, 0}, 0, 2, + {OPT_RM|OPS_16|OPS_Relaxed|OPA_EA, OPT_Reg|OPS_16|OPA_Spare, 0} }, + { CPU_386, MOD_GasSufL, 32, 0, 0, 1, {0x85, 0, 0}, 0, 2, + {OPT_RM|OPS_32|OPS_Relaxed|OPA_EA, OPT_Reg|OPS_32|OPA_Spare, 0} }, + { CPU_Hammer|CPU_64, MOD_GasSufQ, 64, 0, 0, 1, {0x85, 0, 0}, 0, 2, + {OPT_RM|OPS_64|OPS_Relaxed|OPA_EA, OPT_Reg|OPS_64|OPA_Spare, 0} }, + + { CPU_Any, MOD_GasSufB, 0, 0, 0, 1, {0x84, 0, 0}, 0, 2, + {OPT_Reg|OPS_8|OPA_Spare, OPT_RM|OPS_8|OPS_Relaxed|OPA_EA, 0} }, + { CPU_Any, MOD_GasSufW, 16, 0, 0, 1, {0x85, 0, 0}, 0, 2, + {OPT_Reg|OPS_16|OPA_Spare, OPT_RM|OPS_16|OPS_Relaxed|OPA_EA, 0} }, + { CPU_386, MOD_GasSufL, 32, 0, 0, 1, {0x85, 0, 0}, 0, 2, + {OPT_Reg|OPS_32|OPA_Spare, OPT_RM|OPS_32|OPS_Relaxed|OPA_EA, 0} }, + { CPU_Hammer|CPU_64, MOD_GasSufQ, 64, 0, 0, 1, {0x85, 0, 0}, 0, 2, + {OPT_Reg|OPS_64|OPA_Spare, OPT_RM|OPS_64|OPS_Relaxed|OPA_EA, 0} } +}; + +/* Arithmetic - aad/aam */ +static const x86_insn_info aadm_insn[] = { + { CPU_Any, MOD_Op0Add, 0, 0, 0, 2, {0xD4, 0x0A, 0}, 0, 0, {0, 0, 0} }, + { CPU_Any, MOD_Op0Add, 0, 0, 0, 1, {0xD4, 0, 0}, 0, 1, + {OPT_Imm|OPS_8|OPS_Relaxed|OPA_Imm, 0, 0} } +}; + +/* Arithmetic - imul */ +static const x86_insn_info imul_insn[] = { + { CPU_Any, MOD_GasSufB, 0, 0, 0, 1, {0xF6, 0, 0}, 5, 1, + {OPT_RM|OPS_8|OPA_EA, 0, 0} }, + { CPU_Any, MOD_GasSufW, 16, 0, 0, 1, {0xF7, 0, 0}, 5, 1, + {OPT_RM|OPS_16|OPA_EA, 0, 0} }, + { CPU_386, MOD_GasSufL, 32, 0, 0, 1, {0xF7, 0, 0}, 5, 1, + {OPT_RM|OPS_32|OPA_EA, 0, 0} }, + { CPU_Hammer|CPU_64, MOD_GasSufQ, 64, 0, 0, 1, {0xF7, 0, 0}, 5, 1, + {OPT_RM|OPS_64|OPA_EA, 0, 0} }, + + { CPU_386, MOD_GasSufW, 16, 0, 0, 2, {0x0F, 0xAF, 0}, 0, 2, + {OPT_Reg|OPS_16|OPA_Spare, OPT_RM|OPS_16|OPS_Relaxed|OPA_EA, 0} }, + { CPU_386, MOD_GasSufL, 32, 0, 0, 2, {0x0F, 0xAF, 0}, 0, 2, + {OPT_Reg|OPS_32|OPA_Spare, OPT_RM|OPS_32|OPS_Relaxed|OPA_EA, 0} }, + { CPU_Hammer|CPU_64, MOD_GasSufQ, 64, 0, 0, 2, {0x0F, 0xAF, 0}, 0, 2, + {OPT_Reg|OPS_64|OPA_Spare, OPT_RM|OPS_64|OPS_Relaxed|OPA_EA, 0} }, + + { CPU_186, MOD_GasSufW, 16, 0, 0, 1, {0x6B, 0, 0}, 0, 3, + {OPT_Reg|OPS_16|OPA_Spare, OPT_RM|OPS_16|OPS_Relaxed|OPA_EA, + OPT_Imm|OPS_8|OPA_SImm} }, + { CPU_386, MOD_GasSufL, 32, 0, 0, 1, {0x6B, 0, 0}, 0, 3, + {OPT_Reg|OPS_32|OPA_Spare, OPT_RM|OPS_32|OPS_Relaxed|OPA_EA, + OPT_Imm|OPS_8|OPA_SImm} }, + { CPU_Hammer|CPU_64, MOD_GasSufQ, 64, 0, 0, 1, {0x6B, 0, 0}, 0, 3, + {OPT_Reg|OPS_64|OPA_Spare, OPT_RM|OPS_64|OPS_Relaxed|OPA_EA, + OPT_Imm|OPS_8|OPA_SImm} }, + + { CPU_186, MOD_GasSufW, 16, 0, 0, 1, {0x6B, 0, 0}, 0, 2, + {OPT_Reg|OPS_16|OPA_SpareEA, OPT_Imm|OPS_8|OPA_SImm, 0} }, + { CPU_386, MOD_GasSufL, 32, 0, 0, 1, {0x6B, 0, 0}, 0, 2, + {OPT_Reg|OPS_32|OPA_SpareEA, OPT_Imm|OPS_8|OPA_SImm, 0} }, + { CPU_Hammer|CPU_64, MOD_GasSufQ, 64, 0, 0, 1, {0x6B, 0, 0}, 0, 2, + {OPT_Reg|OPS_64|OPA_SpareEA, OPT_Imm|OPS_8|OPA_SImm, 0} }, + + { CPU_186, MOD_GasSufW, 16, 0, 0, 1, {0x6B, 0x69, 0}, 0, 3, + {OPT_Reg|OPS_16|OPA_Spare, OPT_RM|OPS_16|OPS_Relaxed|OPA_EA, + OPT_Imm|OPS_16|OPS_Relaxed|OPA_SImm|OPAP_SImm8} }, + { CPU_386, MOD_GasSufL, 32, 0, 0, 1, {0x6B, 0x69, 0}, 0, 3, + {OPT_Reg|OPS_32|OPA_Spare, OPT_RM|OPS_32|OPS_Relaxed|OPA_EA, + OPT_Imm|OPS_32|OPS_Relaxed|OPA_SImm|OPAP_SImm8} }, + { CPU_Hammer|CPU_64, MOD_GasSufQ, 64, 0, 0, 1, {0x6B, 0x69, 0}, 0, 3, + {OPT_Reg|OPS_64|OPA_Spare, OPT_RM|OPS_64|OPS_Relaxed|OPA_EA, + OPT_Imm|OPS_32|OPS_Relaxed|OPA_SImm|OPAP_SImm8} }, + + { CPU_186, MOD_GasSufW, 16, 0, 0, 1, {0x6B, 0x69, 0}, 0, 2, + {OPT_Reg|OPS_16|OPA_SpareEA, + OPT_Imm|OPS_16|OPS_Relaxed|OPA_SImm|OPAP_SImm8, 0} }, + { CPU_386, MOD_GasSufL, 32, 0, 0, 1, {0x6B, 0x69, 0}, 0, 2, + {OPT_Reg|OPS_32|OPA_SpareEA, + OPT_Imm|OPS_32|OPS_Relaxed|OPA_SImm|OPAP_SImm8, 0} }, + { CPU_Hammer|CPU_64, MOD_GasSufQ, 64, 0, 0, 1, {0x6B, 0x69, 0}, 0, 2, + {OPT_Reg|OPS_64|OPA_SpareEA, + OPT_Imm|OPS_32|OPS_Relaxed|OPA_SImm|OPAP_SImm8, 0} } +}; + +/* Shifts - standard */ +static const x86_insn_info shift_insn[] = { + { CPU_Any, MOD_SpAdd|MOD_GasSufB, 0, 0, 0, 1, {0xD2, 0, 0}, 0, 2, + {OPT_RM|OPS_8|OPA_EA, OPT_Creg|OPS_8|OPA_None, 0} }, + { CPU_Any, MOD_SpAdd|MOD_GasSufB, 0, 0, 0, 1, {0xD0, 0, 0}, 0, 2, + {OPT_RM|OPS_8|OPA_EA, OPT_Imm1|OPS_8|OPS_Relaxed|OPA_None, 0} }, + { CPU_186, MOD_SpAdd|MOD_GasSufB, 0, 0, 0, 1, {0xC0, 0, 0}, 0, 2, + {OPT_RM|OPS_8|OPA_EA, OPT_Imm|OPS_8|OPS_Relaxed|OPA_Imm, 0} }, + { CPU_Any, MOD_SpAdd|MOD_GasSufW, 16, 0, 0, 1, {0xD3, 0, 0}, 0, 2, + {OPT_RM|OPS_16|OPA_EA, OPT_Creg|OPS_8|OPA_None, 0} }, + { CPU_Any, MOD_SpAdd|MOD_GasSufW, 16, 0, 0, 1, {0xD1, 0, 0}, 0, 2, + {OPT_RM|OPS_16|OPA_EA, OPT_Imm1|OPS_8|OPS_Relaxed|OPA_None, 0} }, + { CPU_186, MOD_SpAdd|MOD_GasSufW, 16, 0, 0, 1, {0xC1, 0, 0}, 0, 2, + {OPT_RM|OPS_16|OPA_EA, OPT_Imm|OPS_8|OPS_Relaxed|OPA_Imm, 0} }, + { CPU_Any, MOD_SpAdd|MOD_GasSufL, 32, 0, 0, 1, {0xD3, 0, 0}, 0, 2, + {OPT_RM|OPS_32|OPA_EA, OPT_Creg|OPS_8|OPA_None, 0} }, + { CPU_386, MOD_SpAdd|MOD_GasSufL, 32, 0, 0, 1, {0xD1, 0, 0}, 0, 2, + {OPT_RM|OPS_32|OPA_EA, OPT_Imm1|OPS_8|OPS_Relaxed|OPA_None, 0} }, + { CPU_386, MOD_SpAdd|MOD_GasSufL, 32, 0, 0, 1, {0xC1, 0, 0}, 0, 2, + {OPT_RM|OPS_32|OPA_EA, OPT_Imm|OPS_8|OPS_Relaxed|OPA_Imm, 0} }, + { CPU_Hammer|CPU_64, MOD_SpAdd|MOD_GasSufQ, 64, 0, 0, 1, {0xD3, 0, 0}, 0, + 2, {OPT_RM|OPS_64|OPA_EA, OPT_Creg|OPS_8|OPA_None, 0} }, + { CPU_Hammer|CPU_64, MOD_SpAdd|MOD_GasSufQ, 64, 0, 0, 1, {0xD1, 0, 0}, + 0, 2, {OPT_RM|OPS_64|OPA_EA, OPT_Imm1|OPS_8|OPS_Relaxed|OPA_None, 0} }, + { CPU_Hammer|CPU_64, MOD_SpAdd|MOD_GasSufQ, 64, 0, 0, 1, {0xC1, 0, 0}, + 0, 2, {OPT_RM|OPS_64|OPA_EA, OPT_Imm|OPS_8|OPS_Relaxed|OPA_Imm, 0} }, + /* In GAS mode, single operands are equivalent to shifting by 1 forms */ + { CPU_Any, MOD_SpAdd|MOD_GasOnly|MOD_GasSufB, 0, 0, 0, 1, {0xD0, 0, 0}, + 0, 1, {OPT_RM|OPS_8|OPA_EA, 0, 0} }, + { CPU_Any, MOD_SpAdd|MOD_GasOnly|MOD_GasSufW, 16, 0, 0, 1, {0xD1, 0, 0}, + 0, 1, {OPT_RM|OPS_16|OPA_EA, 0, 0} }, + { CPU_Any, MOD_SpAdd|MOD_GasOnly|MOD_GasSufL, 32, 0, 0, 1, {0xD1, 0, 0}, + 0, 1, {OPT_RM|OPS_32|OPA_EA, 0, 0} }, + { CPU_Hammer|CPU_64, MOD_SpAdd|MOD_GasOnly|MOD_GasSufQ, 64, 0, 0, 1, + {0xD1, 0, 0}, 0, 1, {OPT_RM|OPS_64|OPA_EA, 0, 0} } +}; + +/* Shifts - doubleword */ +static const x86_insn_info shlrd_insn[] = { + { CPU_386, MOD_Op1Add|MOD_GasSufW, 16, 0, 0, 2, {0x0F, 0x00, 0}, 0, 3, + {OPT_RM|OPS_16|OPS_Relaxed|OPA_EA, OPT_Reg|OPS_16|OPA_Spare, + OPT_Imm|OPS_8|OPS_Relaxed|OPA_Imm} }, + { CPU_386, MOD_Op1Add|MOD_GasSufW, 16, 0, 0, 2, {0x0F, 0x01, 0}, 0, 3, + {OPT_RM|OPS_16|OPS_Relaxed|OPA_EA, OPT_Reg|OPS_16|OPA_Spare, + OPT_Creg|OPS_8|OPA_None} }, + { CPU_386, MOD_Op1Add|MOD_GasSufL, 32, 0, 0, 2, {0x0F, 0x00, 0}, 0, 3, + {OPT_RM|OPS_32|OPS_Relaxed|OPA_EA, OPT_Reg|OPS_32|OPA_Spare, + OPT_Imm|OPS_8|OPS_Relaxed|OPA_Imm} }, + { CPU_386, MOD_Op1Add|MOD_GasSufL, 32, 0, 0, 2, {0x0F, 0x01, 0}, 0, 3, + {OPT_RM|OPS_32|OPS_Relaxed|OPA_EA, OPT_Reg|OPS_32|OPA_Spare, + OPT_Creg|OPS_8|OPA_None} }, + { CPU_Hammer|CPU_64, MOD_Op1Add|MOD_GasSufQ, 64, 0, 0, 2, {0x0F, 0x00, 0}, + 0, 3, {OPT_RM|OPS_64|OPS_Relaxed|OPA_EA, OPT_Reg|OPS_64|OPA_Spare, + OPT_Imm|OPS_8|OPS_Relaxed|OPA_Imm} }, + { CPU_Hammer|CPU_64, MOD_Op1Add|MOD_GasSufQ, 64, 0, 0, 2, {0x0F, 0x01, 0}, + 0, 3, {OPT_RM|OPS_64|OPS_Relaxed|OPA_EA, OPT_Reg|OPS_64|OPA_Spare, + OPT_Creg|OPS_8|OPA_None} }, + /* GAS parser supports two-operand form for shift with CL count */ + { CPU_386, MOD_Op1Add|MOD_GasOnly|MOD_GasSufW, 16, 0, 0, 2, + {0x0F, 0x01, 0}, 0, 2, + {OPT_RM|OPS_16|OPS_Relaxed|OPA_EA, OPT_Reg|OPS_16|OPA_Spare, 0} }, + { CPU_386, MOD_Op1Add|MOD_GasOnly|MOD_GasSufL, 32, 0, 0, 2, + {0x0F, 0x01, 0}, 0, 2, + {OPT_RM|OPS_32|OPS_Relaxed|OPA_EA, OPT_Reg|OPS_32|OPA_Spare, 0} }, + { CPU_Hammer|CPU_64, MOD_Op1Add|MOD_GasOnly|MOD_GasSufQ, 64, 0, 0, 2, + {0x0F, 0x01, 0}, 0, 2, + {OPT_RM|OPS_64|OPS_Relaxed|OPA_EA, OPT_Reg|OPS_64|OPA_Spare, 0} } +}; + +/* Control transfer instructions (unconditional) */ +static const x86_insn_info call_insn[] = { + { CPU_Any, 0, 0, 0, 0, 0, {0, 0, 0}, 0, 1, + {OPT_ImmNotSegOff|OPS_Any|OPA_JmpRel, 0, 0} }, + { CPU_Any, 0, 16, 0, 0, 0, {0, 0, 0}, 0, 1, + {OPT_ImmNotSegOff|OPS_16|OPA_JmpRel, 0, 0} }, + { CPU_386|CPU_Not64, 0, 32, 0, 0, 0, {0, 0, 0}, 0, 1, + {OPT_ImmNotSegOff|OPS_32|OPA_JmpRel, 0, 0} }, + { CPU_Hammer|CPU_64, 0, 64, 0, 0, 0, {0, 0, 0}, 0, 1, + {OPT_ImmNotSegOff|OPS_32|OPA_JmpRel, 0, 0} }, + + { CPU_Any, 0, 16, 64, 0, 1, {0xE8, 0, 0}, 0, 1, + {OPT_Imm|OPS_16|OPTM_Near|OPA_JmpRel, 0, 0} }, + { CPU_386|CPU_Not64, 0, 32, 0, 0, 1, {0xE8, 0, 0}, 0, 1, + {OPT_Imm|OPS_32|OPTM_Near|OPA_JmpRel, 0, 0} }, + { CPU_Hammer|CPU_64, 0, 64, 64, 0, 1, {0xE8, 0, 0}, 0, 1, + {OPT_Imm|OPS_32|OPTM_Near|OPA_JmpRel, 0, 0} }, + { CPU_Any, 0, 0, 64, 0, 1, {0xE8, 0, 0}, 0, 1, + {OPT_Imm|OPS_Any|OPTM_Near|OPA_JmpRel, 0, 0} }, + + { CPU_Any, 0, 16, 0, 0, 1, {0xFF, 0, 0}, 2, 1, + {OPT_RM|OPS_16|OPA_EA, 0, 0} }, + { CPU_386|CPU_Not64, 0, 32, 0, 0, 1, {0xFF, 0, 0}, 2, 1, + {OPT_RM|OPS_32|OPA_EA, 0, 0} }, + { CPU_Hammer|CPU_64, 0, 64, 64, 0, 1, {0xFF, 0, 0}, 2, 1, + {OPT_RM|OPS_64|OPA_EA, 0, 0} }, + { CPU_Any, 0, 0, 64, 0, 1, {0xFF, 0, 0}, 2, 1, + {OPT_Mem|OPS_Any|OPA_EA, 0, 0} }, + { CPU_Any, 0, 16, 64, 0, 1, {0xFF, 0, 0}, 2, 1, + {OPT_RM|OPS_16|OPTM_Near|OPA_EA, 0, 0} }, + { CPU_386|CPU_Not64, 0, 32, 0, 0, 1, {0xFF, 0, 0}, 2, 1, + {OPT_RM|OPS_32|OPTM_Near|OPA_EA, 0, 0} }, + { CPU_Hammer|CPU_64, 0, 64, 64, 0, 1, {0xFF, 0, 0}, 2, 1, + {OPT_RM|OPS_64|OPTM_Near|OPA_EA, 0, 0} }, + { CPU_Any, 0, 0, 64, 0, 1, {0xFF, 0, 0}, 2, 1, + {OPT_Mem|OPS_Any|OPTM_Near|OPA_EA, 0, 0} }, + + /* Far indirect (through memory). Needs explicit FAR override. */ + { CPU_Any, 0, 16, 0, 0, 1, {0xFF, 0, 0}, 3, 1, + {OPT_Mem|OPS_16|OPTM_Far|OPA_EA, 0, 0} }, + { CPU_386, 0, 32, 0, 0, 1, {0xFF, 0, 0}, 3, 1, + {OPT_Mem|OPS_32|OPTM_Far|OPA_EA, 0, 0} }, + { CPU_EM64T|CPU_64, 0, 64, 0, 0, 1, {0xFF, 0, 0}, 3, 1, + {OPT_Mem|OPS_64|OPTM_Far|OPA_EA, 0, 0} }, + { CPU_Any, 0, 0, 0, 0, 1, {0xFF, 0, 0}, 3, 1, + {OPT_Mem|OPS_Any|OPTM_Far|OPA_EA, 0, 0} }, + + /* With explicit FAR override */ + { CPU_Not64, 0, 16, 0, 0, 1, {0x9A, 0, 0}, 3, 1, + {OPT_Imm|OPS_16|OPTM_Far|OPA_JmpFar, 0, 0} }, + { CPU_386|CPU_Not64, 0, 32, 0, 0, 1, {0x9A, 0, 0}, 3, 1, + {OPT_Imm|OPS_32|OPTM_Far|OPA_JmpFar, 0, 0} }, + { CPU_Not64, 0, 0, 0, 0, 1, {0x9A, 0, 0}, 3, 1, + {OPT_Imm|OPS_Any|OPTM_Far|OPA_JmpFar, 0, 0} }, + + /* Since not caught by first ImmNotSegOff group, implicitly FAR. */ + { CPU_Not64, 0, 16, 0, 0, 1, {0x9A, 0, 0}, 3, 1, + {OPT_Imm|OPS_16|OPA_JmpFar, 0, 0} }, + { CPU_386|CPU_Not64, 0, 32, 0, 0, 1, {0x9A, 0, 0}, 3, 1, + {OPT_Imm|OPS_32|OPA_JmpFar, 0, 0} }, + { CPU_Not64, 0, 0, 0, 0, 1, {0x9A, 0, 0}, 3, 1, + {OPT_Imm|OPS_Any|OPA_JmpFar, 0, 0} } +}; +static const x86_insn_info jmp_insn[] = { + { CPU_Any, 0, 0, 0, 0, 0, {0, 0, 0}, 0, 1, + {OPT_ImmNotSegOff|OPS_Any|OPA_JmpRel, 0, 0} }, + { CPU_Any, 0, 16, 0, 0, 0, {0, 0, 0}, 0, 1, + {OPT_ImmNotSegOff|OPS_16|OPA_JmpRel, 0, 0} }, + { CPU_386|CPU_Not64, 0, 32, 0, 0, 1, {0, 0, 0}, 0, 1, + {OPT_ImmNotSegOff|OPS_32|OPA_JmpRel, 0, 0} }, + { CPU_Hammer|CPU_64, 0, 64, 0, 0, 1, {0, 0, 0}, 0, 1, + {OPT_ImmNotSegOff|OPS_32|OPA_JmpRel, 0, 0} }, + + { CPU_Any, 0, 0, 64, 0, 1, {0xEB, 0, 0}, 0, 1, + {OPT_Imm|OPS_Any|OPTM_Short|OPA_JmpRel, 0, 0} }, + { CPU_Any, 0, 16, 64, 0, 1, {0xE9, 0, 0}, 0, 1, + {OPT_Imm|OPS_16|OPTM_Near|OPA_JmpRel, 0, 0} }, + { CPU_386|CPU_Not64, 0, 32, 0, 0, 1, {0xE9, 0, 0}, 0, 1, + {OPT_Imm|OPS_32|OPTM_Near|OPA_JmpRel, 0, 0} }, + { CPU_Hammer|CPU_64, 0, 64, 64, 0, 1, {0xE9, 0, 0}, 0, 1, + {OPT_Imm|OPS_32|OPTM_Near|OPA_JmpRel, 0, 0} }, + { CPU_Any, 0, 0, 64, 0, 1, {0xE9, 0, 0}, 0, 1, + {OPT_Imm|OPS_Any|OPTM_Near|OPA_JmpRel, 0, 0} }, + + { CPU_Any, 0, 16, 64, 0, 1, {0xFF, 0, 0}, 4, 1, + {OPT_RM|OPS_16|OPA_EA, 0, 0} }, + { CPU_386|CPU_Not64, 0, 32, 0, 0, 1, {0xFF, 0, 0}, 4, 1, + {OPT_RM|OPS_32|OPA_EA, 0, 0} }, + { CPU_Hammer|CPU_64, 0, 64, 64, 0, 1, {0xFF, 0, 0}, 4, 1, + {OPT_RM|OPS_64|OPA_EA, 0, 0} }, + { CPU_Any, 0, 0, 64, 0, 1, {0xFF, 0, 0}, 4, 1, + {OPT_Mem|OPS_Any|OPA_EA, 0, 0} }, + { CPU_Any, 0, 16, 64, 0, 1, {0xFF, 0, 0}, 4, 1, + {OPT_RM|OPS_16|OPTM_Near|OPA_EA, 0, 0} }, + { CPU_386|CPU_Not64, 0, 32, 0, 0, 1, {0xFF, 0, 0}, 4, 1, + {OPT_RM|OPS_32|OPTM_Near|OPA_EA, 0, 0} }, + { CPU_Hammer|CPU_64, 0, 64, 64, 0, 1, {0xFF, 0, 0}, 4, 1, + {OPT_RM|OPS_64|OPTM_Near|OPA_EA, 0, 0} }, + { CPU_Any, 0, 0, 64, 0, 1, {0xFF, 0, 0}, 4, 1, + {OPT_Mem|OPS_Any|OPTM_Near|OPA_EA, 0, 0} }, + + /* Far indirect (through memory). Needs explicit FAR override. */ + { CPU_Any, 0, 16, 0, 0, 1, {0xFF, 0, 0}, 5, 1, + {OPT_Mem|OPS_16|OPTM_Far|OPA_EA, 0, 0} }, + { CPU_386, 0, 32, 0, 0, 1, {0xFF, 0, 0}, 5, 1, + {OPT_Mem|OPS_32|OPTM_Far|OPA_EA, 0, 0} }, + { CPU_EM64T|CPU_64, 0, 64, 0, 0, 1, {0xFF, 0, 0}, 5, 1, + {OPT_Mem|OPS_64|OPTM_Far|OPA_EA, 0, 0} }, + { CPU_Any, 0, 0, 0, 0, 1, {0xFF, 0, 0}, 5, 1, + {OPT_Mem|OPS_Any|OPTM_Far|OPA_EA, 0, 0} }, + + /* With explicit FAR override */ + { CPU_Not64, 0, 16, 0, 0, 1, {0xEA, 0, 0}, 3, 1, + {OPT_Imm|OPS_16|OPTM_Far|OPA_JmpFar, 0, 0} }, + { CPU_386|CPU_Not64, 0, 32, 0, 0, 1, {0xEA, 0, 0}, 3, 1, + {OPT_Imm|OPS_32|OPTM_Far|OPA_JmpFar, 0, 0} }, + { CPU_Not64, 0, 0, 0, 0, 1, {0xEA, 0, 0}, 3, 1, + {OPT_Imm|OPS_Any|OPTM_Far|OPA_JmpFar, 0, 0} }, + + /* Since not caught by first ImmNotSegOff group, implicitly FAR. */ + { CPU_Not64, 0, 16, 0, 0, 1, {0xEA, 0, 0}, 3, 1, + {OPT_Imm|OPS_16|OPA_JmpFar, 0, 0} }, + { CPU_386|CPU_Not64, 0, 32, 0, 0, 1, {0xEA, 0, 0}, 3, 1, + {OPT_Imm|OPS_32|OPA_JmpFar, 0, 0} }, + { CPU_Not64, 0, 0, 0, 0, 1, {0xEA, 0, 0}, 3, 1, + {OPT_Imm|OPS_Any|OPA_JmpFar, 0, 0} } +}; +static const x86_insn_info retnf_insn[] = { + { CPU_Not64, MOD_Op0Add, 0, 0, 0, 1, + {0x01, 0, 0}, 0, 0, {0, 0, 0} }, + { CPU_Not64, MOD_Op0Add, 0, 0, 0, 1, + {0x00, 0, 0}, 0, 1, {OPT_Imm|OPS_16|OPS_Relaxed|OPA_Imm, 0, 0} }, + { CPU_64, MOD_Op0Add|MOD_OpSizeR, 0, 0, 0, 1, + {0x01, 0, 0}, 0, 0, {0, 0, 0} }, + { CPU_64, MOD_Op0Add|MOD_OpSizeR, 0, 0, 0, 1, + {0x00, 0, 0}, 0, 1, {OPT_Imm|OPS_16|OPS_Relaxed|OPA_Imm, 0, 0} }, + /* GAS suffix versions */ + { CPU_Any, MOD_Op0Add|MOD_OpSizeR|MOD_GasSufW|MOD_GasSufL|MOD_GasSufQ, 0, + 0, 0, 1, {0x01, 0, 0}, 0, 0, {0, 0, 0} }, + { CPU_Any, MOD_Op0Add|MOD_OpSizeR|MOD_GasSufW|MOD_GasSufL|MOD_GasSufQ, 0, + 0, 0, 1, {0x00, 0, 0}, 0, 1, {OPT_Imm|OPS_16|OPS_Relaxed|OPA_Imm, 0, 0} } +}; +static const x86_insn_info enter_insn[] = { + { CPU_186|CPU_Not64, MOD_GasNoRev|MOD_GasSufL, 0, 0, 0, 1, {0xC8, 0, 0}, 0, + 2, {OPT_Imm|OPS_16|OPS_Relaxed|OPA_EA|OPAP_A16, + OPT_Imm|OPS_8|OPS_Relaxed|OPA_Imm, 0} }, + { CPU_Hammer|CPU_64, MOD_GasNoRev|MOD_GasSufQ, 64, 64, 0, 1, {0xC8, 0, 0}, + 0, 2, {OPT_Imm|OPS_16|OPS_Relaxed|OPA_EA|OPAP_A16, + OPT_Imm|OPS_8|OPS_Relaxed|OPA_Imm, 0} }, + /* GAS suffix version */ + { CPU_186, MOD_GasOnly|MOD_GasNoRev|MOD_GasSufW, 16, 0, 0, 1, + {0xC8, 0, 0}, 0, 2, {OPT_Imm|OPS_16|OPS_Relaxed|OPA_EA|OPAP_A16, + OPT_Imm|OPS_8|OPS_Relaxed|OPA_Imm, 0} }, +}; + +/* Conditional jumps */ +static const x86_insn_info jcc_insn[] = { + { CPU_Any, 0, 0, 0, 0, 0, {0, 0, 0}, 0, 1, + {OPT_Imm|OPS_Any|OPA_JmpRel, 0, 0} }, + { CPU_Any, 0, 16, 0, 0, 0, {0, 0, 0}, 0, 1, + {OPT_Imm|OPS_16|OPA_JmpRel, 0, 0} }, + { CPU_386|CPU_Not64, 0, 32, 0, 0, 0, {0, 0, 0}, 0, 1, + {OPT_Imm|OPS_32|OPA_JmpRel, 0, 0} }, + { CPU_Hammer|CPU_64, 0, 64, 0, 0, 0, {0, 0, 0}, 0, 1, + {OPT_Imm|OPS_32|OPA_JmpRel, 0, 0} }, + + { CPU_Any, MOD_Op0Add, 0, 64, 0, 1, {0x70, 0, 0}, 0, 1, + {OPT_Imm|OPS_Any|OPTM_Short|OPA_JmpRel, 0, 0} }, + { CPU_386, MOD_Op1Add, 16, 64, 0, 2, {0x0F, 0x80, 0}, 0, 1, + {OPT_Imm|OPS_16|OPTM_Near|OPA_JmpRel, 0, 0} }, + { CPU_386|CPU_Not64, MOD_Op1Add, 32, 0, 0, 2, {0x0F, 0x80, 0}, 0, 1, + {OPT_Imm|OPS_32|OPTM_Near|OPA_JmpRel, 0, 0} }, + { CPU_Hammer|CPU_64, MOD_Op1Add, 64, 64, 0, 2, {0x0F, 0x80, 0}, 0, 1, + {OPT_Imm|OPS_32|OPTM_Near|OPA_JmpRel, 0, 0} }, + { CPU_386, MOD_Op1Add, 0, 64, 0, 2, {0x0F, 0x80, 0}, 0, 1, + {OPT_Imm|OPS_Any|OPTM_Near|OPA_JmpRel, 0, 0} } +}; +static const x86_insn_info jcxz_insn[] = { + { CPU_Any, MOD_AdSizeR, 0, 0, 0, 0, {0, 0, 0}, 0, 1, + {OPT_Imm|OPS_Any|OPA_JmpRel, 0, 0} }, + { CPU_Any, MOD_AdSizeR, 0, 64, 0, 1, {0xE3, 0, 0}, 0, 1, + {OPT_Imm|OPS_Any|OPTM_Short|OPA_JmpRel, 0, 0} } +}; + +/* Loop instructions */ +static const x86_insn_info loop_insn[] = { + { CPU_Any, 0, 0, 0, 0, 0, {0, 0, 0}, 0, 1, + {OPT_Imm|OPS_Any|OPA_JmpRel, 0, 0} }, + { CPU_Not64, 0, 0, 0, 0, 0, {0, 0, 0}, 0, 2, + {OPT_Imm|OPS_Any|OPA_JmpRel, OPT_Creg|OPS_16|OPA_AdSizeR, 0} }, + { CPU_386, 0, 0, 64, 0, 0, {0, 0, 0}, 0, 2, + {OPT_Imm|OPS_Any|OPA_JmpRel, OPT_Creg|OPS_32|OPA_AdSizeR, 0} }, + { CPU_Hammer|CPU_64, 0, 0, 64, 0, 0, {0, 0, 0}, 0, 2, + {OPT_Imm|OPS_Any|OPA_JmpRel, OPT_Creg|OPS_64|OPA_AdSizeR, 0} }, + + { CPU_Not64, MOD_Op0Add, 0, 0, 0, 1, {0xE0, 0, 0}, 0, 1, + {OPT_Imm|OPS_Any|OPTM_Short|OPA_JmpRel, 0, 0} }, + { CPU_Any, MOD_Op0Add, 0, 64, 0, 1, {0xE0, 0, 0}, 0, 2, + {OPT_Imm|OPS_Any|OPTM_Short|OPA_JmpRel, OPT_Creg|OPS_16|OPA_AdSizeR, 0} + }, + { CPU_386, MOD_Op0Add, 0, 64, 0, 1, {0xE0, 0, 0}, 0, 2, + {OPT_Imm|OPS_Any|OPTM_Short|OPA_JmpRel, OPT_Creg|OPS_32|OPA_AdSizeR, 0} + }, + { CPU_Hammer|CPU_64, MOD_Op0Add, 0, 64, 0, 1, {0xE0, 0, 0}, 0, 2, + {OPT_Imm|OPS_Any|OPTM_Short|OPA_JmpRel, OPT_Creg|OPS_64|OPA_AdSizeR, 0} } +}; + +/* Set byte on flag instructions */ +static const x86_insn_info setcc_insn[] = { + { CPU_386, MOD_Op1Add|MOD_GasSufB, 0, 0, 0, 2, {0x0F, 0x90, 0}, 2, 1, + {OPT_RM|OPS_8|OPS_Relaxed|OPA_EA, 0, 0} } +}; + +/* Bit manipulation - bit tests */ +static const x86_insn_info bittest_insn[] = { + { CPU_386, MOD_Op1Add|MOD_GasSufW, 16, 0, 0, 2, {0x0F, 0x00, 0}, 0, 2, + {OPT_RM|OPS_16|OPS_Relaxed|OPA_EA, OPT_Reg|OPS_16|OPA_Spare, 0} }, + { CPU_386, MOD_Op1Add|MOD_GasSufL, 32, 0, 0, 2, {0x0F, 0x00, 0}, 0, 2, + {OPT_RM|OPS_32|OPS_Relaxed|OPA_EA, OPT_Reg|OPS_32|OPA_Spare, 0} }, + { CPU_Hammer|CPU_64, MOD_Op1Add|MOD_GasSufQ, 64, 0, 0, 2, {0x0F, 0x00, 0}, + 0, 2, {OPT_RM|OPS_64|OPS_Relaxed|OPA_EA, OPT_Reg|OPS_64|OPA_Spare, 0} }, + { CPU_386, MOD_Gap0|MOD_SpAdd|MOD_GasSufW, 16, 0, 0, 2, {0x0F, 0xBA, 0}, + 0, 2, {OPT_RM|OPS_16|OPA_EA, OPT_Imm|OPS_8|OPS_Relaxed|OPA_Imm, 0} }, + { CPU_386, MOD_Gap0|MOD_SpAdd|MOD_GasSufL, 32, 0, 0, 2, {0x0F, 0xBA, 0}, + 0, 2, {OPT_RM|OPS_32|OPA_EA, OPT_Imm|OPS_8|OPS_Relaxed|OPA_Imm, 0} }, + { CPU_Hammer|CPU_64, MOD_Gap0|MOD_SpAdd|MOD_GasSufQ, 64, 0, 0, 2, + {0x0F, 0xBA, 0}, 0, 2, + {OPT_RM|OPS_64|OPA_EA, OPT_Imm|OPS_8|OPS_Relaxed|OPA_Imm, 0} } +}; + +/* Bit manipulation - bit scans - also used for lar/lsl */ +static const x86_insn_info bsfr_insn[] = { + { CPU_286, MOD_Op1Add|MOD_GasSufW, 16, 0, 0, 2, {0x0F, 0x00, 0}, 0, 2, + {OPT_Reg|OPS_16|OPA_Spare, OPT_RM|OPS_16|OPS_Relaxed|OPA_EA, 0} }, + { CPU_386, MOD_Op1Add|MOD_GasSufL, 32, 0, 0, 2, {0x0F, 0x00, 0}, 0, 2, + {OPT_Reg|OPS_32|OPA_Spare, OPT_RM|OPS_32|OPS_Relaxed|OPA_EA, 0} }, + { CPU_Hammer|CPU_64, MOD_Op1Add|MOD_GasSufQ, 64, 0, 0, 2, {0x0F, 0x00, 0}, + 0, 2, {OPT_Reg|OPS_64|OPA_Spare, OPT_RM|OPS_64|OPS_Relaxed|OPA_EA, 0} } +}; + +/* Interrupts and operating system instructions */ +static const x86_insn_info int_insn[] = { + { CPU_Any, 0, 0, 0, 0, 1, {0xCD, 0, 0}, 0, 1, + {OPT_Imm|OPS_8|OPS_Relaxed|OPA_Imm, 0, 0} } +}; +static const x86_insn_info bound_insn[] = { + { CPU_186, MOD_GasSufW, 16, 0, 0, 1, {0x62, 0, 0}, 0, 2, + {OPT_Reg|OPS_16|OPA_Spare, OPT_Mem|OPS_16|OPS_Relaxed|OPA_EA, 0} }, + { CPU_386, MOD_GasSufL, 32, 0, 0, 1, {0x62, 0, 0}, 0, 2, + {OPT_Reg|OPS_32|OPA_Spare, OPT_Mem|OPS_32|OPS_Relaxed|OPA_EA, 0} } +}; + +/* Protection control */ +static const x86_insn_info arpl_insn[] = { + { CPU_286|CPU_Prot, MOD_GasSufW, 0, 0, 0, 1, {0x63, 0, 0}, 0, 2, + {OPT_RM|OPS_16|OPS_Relaxed|OPA_EA, OPT_Reg|OPS_16|OPA_Spare, 0} } +}; +static const x86_insn_info str_insn[] = { + { CPU_286|CPU_Prot, MOD_GasSufW, 16, 0, 0, 2, {0x0F, 0x00, 0}, 1, 1, + {OPT_Reg|OPS_16|OPA_EA, 0, 0} }, + { CPU_386|CPU_Prot, MOD_GasSufL, 32, 0, 0, 2, {0x0F, 0x00, 0}, 1, 1, + {OPT_Reg|OPS_32|OPA_EA, 0, 0} }, + { CPU_Hammer|CPU_64|CPU_Prot, MOD_GasSufQ, 64, 0, 0, 2, {0x0F, 0x00, 0}, 1, + 1, {OPT_Reg|OPS_64|OPA_EA, 0, 0} }, + { CPU_286|CPU_Prot, MOD_GasSufW|MOD_GasSufL, 0, 0, 0, 2, {0x0F, 0x00, 0}, + 1, 1, {OPT_RM|OPS_16|OPS_Relaxed|OPA_EA, 0, 0} } +}; +static const x86_insn_info prot286_insn[] = { + { CPU_286, MOD_Op1Add|MOD_SpAdd|MOD_GasSufW, 0, 0, 0, 2, {0x0F, 0x00, 0}, + 0, 1, {OPT_RM|OPS_16|OPS_Relaxed|OPA_EA, 0, 0} } +}; +static const x86_insn_info sldtmsw_insn[] = { + { CPU_286, MOD_Op1Add|MOD_SpAdd|MOD_GasSufW, 0, 0, 0, 2, {0x0F, 0x00, 0}, + 0, 1, {OPT_Mem|OPS_16|OPS_Relaxed|OPA_EA, 0, 0} }, + { CPU_386, MOD_Op1Add|MOD_SpAdd|MOD_GasSufL, 0, 0, 0, 2, {0x0F, 0x00, 0}, + 0, 1, {OPT_Mem|OPS_32|OPS_Relaxed|OPA_EA, 0, 0} }, + { CPU_Hammer|CPU_64, MOD_Op1Add|MOD_SpAdd|MOD_GasSufQ, 0, 0, 0, 2, + {0x0F, 0x00, 0}, 0, 1, {OPT_Mem|OPS_64|OPS_Relaxed|OPA_EA, 0, 0} }, + { CPU_286, MOD_Op1Add|MOD_SpAdd|MOD_GasSufW, 16, 0, 0, 2, {0x0F, 0x00, 0}, + 0, 1, {OPT_Reg|OPS_16|OPA_EA, 0, 0} }, + { CPU_386, MOD_Op1Add|MOD_SpAdd|MOD_GasSufL, 32, 0, 0, 2, {0x0F, 0x00, 0}, + 0, 1, {OPT_Reg|OPS_32|OPA_EA, 0, 0} }, + { CPU_Hammer|CPU_64, MOD_Op1Add|MOD_SpAdd|MOD_GasSufQ, 64, 0, 0, 2, + {0x0F, 0x00, 0}, 0, 1, {OPT_Reg|OPS_64|OPA_EA, 0, 0} } +}; + +/* Floating point instructions - load/store with pop (integer and normal) */ +static const x86_insn_info fld_insn[] = { + { CPU_FPU, MOD_GasSufS, 0, 0, 0, 1, {0xD9, 0, 0}, 0, 1, + {OPT_Mem|OPS_32|OPA_EA, 0, 0} }, + { CPU_FPU, MOD_GasSufL, 0, 0, 0, 1, {0xDD, 0, 0}, 0, 1, + {OPT_Mem|OPS_64|OPA_EA, 0, 0} }, + { CPU_FPU, 0, 0, 0, 0, 1, {0xDB, 0, 0}, 5, 1, + {OPT_Mem|OPS_80|OPA_EA, 0, 0} }, + { CPU_FPU, 0, 0, 0, 0, 2, {0xD9, 0xC0, 0}, 0, 1, + {OPT_Reg|OPS_80|OPA_Op1Add, 0, 0} } +}; +static const x86_insn_info fstp_insn[] = { + { CPU_FPU, MOD_GasSufS, 0, 0, 0, 1, {0xD9, 0, 0}, 3, 1, + {OPT_Mem|OPS_32|OPA_EA, 0, 0} }, + { CPU_FPU, MOD_GasSufL, 0, 0, 0, 1, {0xDD, 0, 0}, 3, 1, + {OPT_Mem|OPS_64|OPA_EA, 0, 0} }, + { CPU_FPU, 0, 0, 0, 0, 1, {0xDB, 0, 0}, 7, 1, + {OPT_Mem|OPS_80|OPA_EA, 0, 0} }, + { CPU_FPU, 0, 0, 0, 0, 2, {0xDD, 0xD8, 0}, 0, 1, + {OPT_Reg|OPS_80|OPA_Op1Add, 0, 0} } +}; +/* Long memory version of floating point load/store for GAS */ +static const x86_insn_info fldstpt_insn[] = { + { CPU_FPU, MOD_SpAdd, 0, 0, 0, 1, {0xDB, 0, 0}, 0, 1, + {OPT_Mem|OPS_80|OPA_EA, 0, 0} } +}; +static const x86_insn_info fildstp_insn[] = { + { CPU_FPU, MOD_SpAdd|MOD_GasSufS, 0, 0, 0, 1, {0xDF, 0, 0}, 0, 1, + {OPT_Mem|OPS_16|OPA_EA, 0, 0} }, + { CPU_FPU, MOD_SpAdd|MOD_GasSufL, 0, 0, 0, 1, {0xDB, 0, 0}, 0, 1, + {OPT_Mem|OPS_32|OPA_EA, 0, 0} }, + { CPU_FPU, MOD_Gap0|MOD_Op0Add|MOD_SpAdd|MOD_GasSufQ, 0, 0, 0, 1, + {0xDD, 0, 0}, 0, 1, {OPT_Mem|OPS_64|OPA_EA, 0, 0} } +}; +static const x86_insn_info fbldstp_insn[] = { + { CPU_FPU, MOD_SpAdd, 0, 0, 0, 1, {0xDF, 0, 0}, 0, 1, + {OPT_Mem|OPS_80|OPS_Relaxed|OPA_EA, 0, 0} } +}; +/* Floating point instructions - store (normal) */ +static const x86_insn_info fst_insn[] = { + { CPU_FPU, MOD_GasSufS, 0, 0, 0, 1, {0xD9, 0, 0}, 2, 1, + {OPT_Mem|OPS_32|OPA_EA, 0, 0} }, + { CPU_FPU, MOD_GasSufL, 0, 0, 0, 1, {0xDD, 0, 0}, 2, 1, + {OPT_Mem|OPS_64|OPA_EA, 0, 0} }, + { CPU_FPU, 0, 0, 0, 0, 2, {0xDD, 0xD0, 0}, 0, 1, + {OPT_Reg|OPS_80|OPA_Op1Add, 0, 0} } +}; +/* Floating point instructions - exchange (with ST0) */ +static const x86_insn_info fxch_insn[] = { + { CPU_FPU, 0, 0, 0, 0, 2, {0xD9, 0xC8, 0}, 0, 1, + {OPT_Reg|OPS_80|OPA_Op1Add, 0, 0} }, + { CPU_FPU, 0, 0, 0, 0, 2, {0xD9, 0xC8, 0}, 0, 2, + {OPT_ST0|OPS_80|OPA_None, OPT_Reg|OPS_80|OPA_Op1Add, 0} }, + { CPU_FPU, 0, 0, 0, 0, 2, {0xD9, 0xC8, 0}, 0, 2, + {OPT_Reg|OPS_80|OPA_Op1Add, OPT_ST0|OPS_80|OPA_None, 0} }, + { CPU_FPU, 0, 0, 0, 0, 2, {0xD9, 0xC9, 0}, 0, 0, {0, 0, 0} } +}; +/* Floating point instructions - comparisons */ +static const x86_insn_info fcom_insn[] = { + { CPU_FPU, MOD_Gap0|MOD_SpAdd|MOD_GasSufS, 0, 0, 0, 1, {0xD8, 0, 0}, 0, 1, + {OPT_Mem|OPS_32|OPA_EA, 0, 0} }, + { CPU_FPU, MOD_Gap0|MOD_SpAdd|MOD_GasSufL, 0, 0, 0, 1, {0xDC, 0, 0}, 0, 1, + {OPT_Mem|OPS_64|OPA_EA, 0, 0} }, + { CPU_FPU, MOD_Op1Add, 0, 0, 0, 2, {0xD8, 0x00, 0}, 0, 1, + {OPT_Reg|OPS_80|OPA_Op1Add, 0, 0} }, + /* Alias for fcom %st(1) for GAS compat */ + { CPU_FPU, MOD_Op1Add|MOD_GasOnly, 0, 0, 0, 2, {0xD8, 0x01, 0}, 0, 0, + {0, 0, 0} }, + { CPU_FPU, MOD_Op1Add|MOD_GasIllegal, 0, 0, 0, 2, {0xD8, 0x00, 0}, 0, 2, + {OPT_ST0|OPS_80|OPA_None, OPT_Reg|OPS_80|OPA_Op1Add, 0} } +}; +/* Floating point instructions - extended comparisons */ +static const x86_insn_info fcom2_insn[] = { + { CPU_286|CPU_FPU, MOD_Op0Add|MOD_Op1Add, 0, 0, 0, 2, {0x00, 0x00, 0}, + 0, 1, {OPT_Reg|OPS_80|OPA_Op1Add, 0, 0} }, + { CPU_286|CPU_FPU, MOD_Op0Add|MOD_Op1Add, 0, 0, 0, 2, {0x00, 0x00, 0}, + 0, 2, {OPT_ST0|OPS_80|OPA_None, OPT_Reg|OPS_80|OPA_Op1Add, 0} } +}; +/* Floating point instructions - arithmetic */ +static const x86_insn_info farith_insn[] = { + { CPU_FPU, MOD_Gap0|MOD_Gap1|MOD_SpAdd|MOD_GasSufS, 0, 0, 0, 1, + {0xD8, 0, 0}, 0, 1, {OPT_Mem|OPS_32|OPA_EA, 0, 0} }, + { CPU_FPU, MOD_Gap0|MOD_Gap1|MOD_SpAdd|MOD_GasSufL, 0, 0, 0, 1, + {0xDC, 0, 0}, 0, 1, {OPT_Mem|OPS_64|OPA_EA, 0, 0} }, + { CPU_FPU, MOD_Gap0|MOD_Op1Add, 0, 0, 0, 2, {0xD8, 0x00, 0}, 0, 1, + {OPT_Reg|OPS_80|OPA_Op1Add, 0, 0} }, + { CPU_FPU, MOD_Gap0|MOD_Op1Add, 0, 0, 0, 2, {0xD8, 0x00, 0}, 0, 2, + {OPT_ST0|OPS_80|OPA_None, OPT_Reg|OPS_80|OPA_Op1Add, 0} }, + { CPU_FPU, MOD_Op1Add, 0, 0, 0, 2, {0xDC, 0x00, 0}, 0, 1, + {OPT_Reg|OPS_80|OPTM_To|OPA_Op1Add, 0, 0} }, + { CPU_FPU, MOD_Op1Add|MOD_GasIllegal, 0, 0, 0, 2, {0xDC, 0x00, 0}, 0, 2, + {OPT_Reg|OPS_80|OPA_Op1Add, OPT_ST0|OPS_80|OPA_None, 0} }, + { CPU_FPU, MOD_Gap0|MOD_Op1Add|MOD_GasOnly, 0, 0, 0, 2, {0xDC, 0x00, 0}, + 0, 2, {OPT_Reg|OPS_80|OPA_Op1Add, OPT_ST0|OPS_80|OPA_None, 0} } +}; +static const x86_insn_info farithp_insn[] = { + { CPU_FPU, MOD_Op1Add, 0, 0, 0, 2, {0xDE, 0x01, 0}, 0, 0, {0, 0, 0} }, + { CPU_FPU, MOD_Op1Add, 0, 0, 0, 2, {0xDE, 0x00, 0}, 0, 1, + {OPT_Reg|OPS_80|OPA_Op1Add, 0, 0} }, + { CPU_FPU, MOD_Op1Add, 0, 0, 0, 2, {0xDE, 0x00, 0}, 0, 2, + {OPT_Reg|OPS_80|OPA_Op1Add, OPT_ST0|OPS_80|OPA_None, 0} } +}; +/* Floating point instructions - integer arith/store wo pop/compare */ +static const x86_insn_info fiarith_insn[] = { + { CPU_FPU, MOD_Op0Add|MOD_SpAdd|MOD_GasSufS, 0, 0, 0, 1, {0x04, 0, 0}, 0, + 1, {OPT_Mem|OPS_16|OPA_EA, 0, 0} }, + { CPU_FPU, MOD_Op0Add|MOD_SpAdd|MOD_GasSufL, 0, 0, 0, 1, {0x00, 0, 0}, 0, + 1, {OPT_Mem|OPS_32|OPA_EA, 0, 0} } +}; +/* Floating point instructions - processor control */ +static const x86_insn_info fldnstcw_insn[] = { + { CPU_FPU, MOD_SpAdd|MOD_GasSufW, 0, 0, 0, 1, {0xD9, 0, 0}, 0, 1, + {OPT_Mem|OPS_16|OPS_Relaxed|OPA_EA, 0, 0} } +}; +static const x86_insn_info fstcw_insn[] = { + { CPU_FPU, MOD_GasSufW, 0, 0, 0, 2, {0x9B, 0xD9, 0}, 7, 1, + {OPT_Mem|OPS_16|OPS_Relaxed|OPA_EA, 0, 0} } +}; +static const x86_insn_info fnstsw_insn[] = { + { CPU_FPU, MOD_GasSufW, 0, 0, 0, 1, {0xDD, 0, 0}, 7, 1, + {OPT_Mem|OPS_16|OPS_Relaxed|OPA_EA, 0, 0} }, + { CPU_FPU, MOD_GasSufW, 0, 0, 0, 2, {0xDF, 0xE0, 0}, 0, 1, + {OPT_Areg|OPS_16|OPA_None, 0, 0} } +}; +static const x86_insn_info fstsw_insn[] = { + { CPU_FPU, MOD_GasSufW, 0, 0, 0, 2, {0x9B, 0xDD, 0}, 7, 1, + {OPT_Mem|OPS_16|OPS_Relaxed|OPA_EA, 0, 0} }, + { CPU_FPU, MOD_GasSufW, 0, 0, 0, 3, {0x9B, 0xDF, 0xE0}, 0, 1, + {OPT_Areg|OPS_16|OPA_None, 0, 0} } +}; +static const x86_insn_info ffree_insn[] = { + { CPU_FPU, MOD_Op0Add, 0, 0, 0, 2, {0x00, 0xC0, 0}, 0, 1, + {OPT_Reg|OPS_80|OPA_Op1Add, 0, 0} } +}; + +/* 486 extensions */ +static const x86_insn_info bswap_insn[] = { + { CPU_486, MOD_GasSufL, 32, 0, 0, 2, {0x0F, 0xC8, 0}, 0, 1, + {OPT_Reg|OPS_32|OPA_Op1Add, 0, 0} }, + { CPU_Hammer|CPU_64, MOD_GasSufQ, 64, 0, 0, 2, {0x0F, 0xC8, 0}, 0, 1, + {OPT_Reg|OPS_64|OPA_Op1Add, 0, 0} } +}; +static const x86_insn_info cmpxchgxadd_insn[] = { + { CPU_486, MOD_Op1Add|MOD_GasSufB, 0, 0, 0, 2, {0x0F, 0x00, 0}, 0, 2, + {OPT_RM|OPS_8|OPS_Relaxed|OPA_EA, OPT_Reg|OPS_8|OPA_Spare, 0} }, + { CPU_486, MOD_Op1Add|MOD_GasSufW, 16, 0, 0, 2, {0x0F, 0x01, 0}, 0, 2, + {OPT_RM|OPS_16|OPS_Relaxed|OPA_EA, OPT_Reg|OPS_16|OPA_Spare, 0} }, + { CPU_486, MOD_Op1Add|MOD_GasSufL, 32, 0, 0, 2, {0x0F, 0x01, 0}, 0, 2, + {OPT_RM|OPS_32|OPS_Relaxed|OPA_EA, OPT_Reg|OPS_32|OPA_Spare, 0} }, + { CPU_Hammer|CPU_64, MOD_Op1Add|MOD_GasSufQ, 64, 0, 0, 2, {0x0F, 0x01, 0}, + 0, 2, {OPT_RM|OPS_64|OPS_Relaxed|OPA_EA, OPT_Reg|OPS_64|OPA_Spare, 0} } +}; + +/* Pentium extensions */ +static const x86_insn_info cmpxchg8b_insn[] = { + { CPU_586, MOD_GasSufQ, 0, 0, 0, 2, {0x0F, 0xC7, 0}, 1, 1, + {OPT_Mem|OPS_64|OPS_Relaxed|OPA_EA, 0, 0} } +}; + +/* Pentium II/Pentium Pro extensions */ +static const x86_insn_info cmovcc_insn[] = { + { CPU_686, MOD_Op1Add|MOD_GasSufW, 16, 0, 0, 2, {0x0F, 0x40, 0}, 0, 2, + {OPT_Reg|OPS_16|OPA_Spare, OPT_RM|OPS_16|OPS_Relaxed|OPA_EA, 0} }, + { CPU_686, MOD_Op1Add|MOD_GasSufL, 32, 0, 0, 2, {0x0F, 0x40, 0}, 0, 2, + {OPT_Reg|OPS_32|OPA_Spare, OPT_RM|OPS_32|OPS_Relaxed|OPA_EA, 0} }, + { CPU_Hammer|CPU_64, MOD_Op1Add|MOD_GasSufQ, 64, 0, 0, 2, {0x0F, 0x40, 0}, + 0, 2, {OPT_Reg|OPS_64|OPA_Spare, OPT_RM|OPS_64|OPS_Relaxed|OPA_EA, 0} } +}; +static const x86_insn_info fcmovcc_insn[] = { + { CPU_686|CPU_FPU, MOD_Op0Add|MOD_Op1Add, 0, 0, 0, 2, {0x00, 0x00, 0}, + 0, 2, {OPT_ST0|OPS_80|OPA_None, OPT_Reg|OPS_80|OPA_Op1Add, 0} } +}; + +/* Pentium4 extensions */ +static const x86_insn_info movnti_insn[] = { + { CPU_P4, MOD_GasSufL, 0, 0, 0, 2, {0x0F, 0xC3, 0}, 0, 2, + {OPT_Mem|OPS_32|OPS_Relaxed|OPA_EA, OPT_Reg|OPS_32|OPA_Spare, 0} }, + { CPU_Hammer|CPU_64, MOD_GasSufQ, 64, 0, 0, 2, {0x0F, 0xC3, 0}, 0, 2, + {OPT_Mem|OPS_64|OPS_Relaxed|OPA_EA, OPT_Reg|OPS_64|OPA_Spare, 0} } +}; +static const x86_insn_info clflush_insn[] = { + { CPU_P3, 0, 0, 0, 0, 2, {0x0F, 0xAE, 0}, 7, 1, + {OPT_Mem|OPS_8|OPS_Relaxed|OPA_EA, 0, 0} } +}; + +/* MMX/SSE2 instructions */ +static const x86_insn_info movd_insn[] = { + { CPU_MMX, 0, 0, 0, 0, 2, {0x0F, 0x6E, 0}, 0, 2, + {OPT_SIMDReg|OPS_64|OPA_Spare, OPT_RM|OPS_32|OPS_Relaxed|OPA_EA, 0} }, + { CPU_MMX|CPU_Hammer|CPU_64, 0, 64, 0, 0, 2, {0x0F, 0x6E, 0}, 0, 2, + {OPT_SIMDReg|OPS_64|OPA_Spare, OPT_RM|OPS_64|OPS_Relaxed|OPA_EA, 0} }, + { CPU_MMX, 0, 0, 0, 0, 2, {0x0F, 0x7E, 0}, 0, 2, + {OPT_RM|OPS_32|OPS_Relaxed|OPA_EA, OPT_SIMDReg|OPS_64|OPA_Spare, 0} }, + { CPU_MMX|CPU_Hammer|CPU_64, 0, 64, 0, 0, 2, {0x0F, 0x7E, 0}, 0, 2, + {OPT_RM|OPS_64|OPS_Relaxed|OPA_EA, OPT_SIMDReg|OPS_64|OPA_Spare, 0} }, + { CPU_SSE2, 0, 0, 0, 0x66, 2, {0x0F, 0x6E, 0}, 0, 2, + {OPT_SIMDReg|OPS_128|OPA_Spare, OPT_RM|OPS_32|OPS_Relaxed|OPA_EA, 0} }, + { CPU_SSE2|CPU_Hammer|CPU_64, 0, 64, 0, 0x66, 2, {0x0F, 0x6E, 0}, 0, 2, + {OPT_SIMDReg|OPS_128|OPA_Spare, OPT_RM|OPS_64|OPS_Relaxed|OPA_EA, 0} }, + { CPU_SSE2, 0, 0, 0, 0x66, 2, {0x0F, 0x7E, 0}, 0, 2, + {OPT_RM|OPS_32|OPS_Relaxed|OPA_EA, OPT_SIMDReg|OPS_128|OPA_Spare, 0} }, + { CPU_SSE2|CPU_Hammer|CPU_64, 0, 64, 0, 0x66, 2, {0x0F, 0x7E, 0}, 0, 2, + {OPT_RM|OPS_64|OPS_Relaxed|OPA_EA, OPT_SIMDReg|OPS_128|OPA_Spare, 0} } +}; +static const x86_insn_info movq_insn[] = { + { CPU_MMX, 0, 0, 0, 0, 2, {0x0F, 0x6F, 0}, 0, 2, + {OPT_SIMDReg|OPS_64|OPA_Spare, OPT_SIMDRM|OPS_64|OPS_Relaxed|OPA_EA, 0} + }, + { CPU_MMX|CPU_Hammer|CPU_64, 0, 64, 0, 0, 2, {0x0F, 0x6E, 0}, 0, 2, + {OPT_SIMDReg|OPS_64|OPA_Spare, OPT_RM|OPS_64|OPS_Relaxed|OPA_EA, 0} }, + { CPU_MMX, 0, 0, 0, 0, 2, {0x0F, 0x7F, 0}, 0, 2, + {OPT_SIMDRM|OPS_64|OPS_Relaxed|OPA_EA, OPT_SIMDReg|OPS_64|OPA_Spare, 0} + }, + { CPU_MMX|CPU_Hammer|CPU_64, 0, 64, 0, 0, 2, {0x0F, 0x7E, 0}, 0, 2, + {OPT_RM|OPS_64|OPS_Relaxed|OPA_EA, OPT_SIMDReg|OPS_64|OPA_Spare, 0} }, + { CPU_SSE2, 0, 0, 0, 0xF3, 2, {0x0F, 0x7E, 0}, 0, 2, + {OPT_SIMDReg|OPS_128|OPA_Spare, OPT_SIMDReg|OPS_128|OPA_EA, 0} }, + { CPU_SSE2, 0, 0, 0, 0xF3, 2, {0x0F, 0x7E, 0}, 0, 2, + {OPT_SIMDReg|OPS_128|OPA_Spare, OPT_SIMDRM|OPS_64|OPS_Relaxed|OPA_EA, 0} + }, + { CPU_SSE2|CPU_Hammer|CPU_64, 0, 64, 0, 0x66, 2, {0x0F, 0x6E, 0}, 0, 2, + {OPT_SIMDReg|OPS_128|OPA_Spare, OPT_RM|OPS_64|OPS_Relaxed|OPA_EA, 0} }, + { CPU_SSE2, 0, 0, 0, 0x66, 2, {0x0F, 0xD6, 0}, 0, 2, + {OPT_SIMDRM|OPS_64|OPS_Relaxed|OPA_EA, OPT_SIMDReg|OPS_128|OPA_Spare, 0} + }, + { CPU_SSE2|CPU_Hammer|CPU_64, 0, 64, 0, 0x66, 2, {0x0F, 0x7E, 0}, 0, 2, + {OPT_RM|OPS_64|OPS_Relaxed|OPA_EA, OPT_SIMDReg|OPS_128|OPA_Spare, 0} } +}; +static const x86_insn_info mmxsse2_insn[] = { + { CPU_MMX, MOD_Op1Add, 0, 0, 0, 2, {0x0F, 0x00, 0}, 0, 2, + {OPT_SIMDReg|OPS_64|OPA_Spare, OPT_SIMDRM|OPS_64|OPS_Relaxed|OPA_EA, 0} + }, + { CPU_SSE2, MOD_Op1Add, 0, 0, 0x66, 2, {0x0F, 0x00, 0}, 0, 2, + {OPT_SIMDReg|OPS_128|OPA_Spare, OPT_SIMDRM|OPS_128|OPS_Relaxed|OPA_EA, 0} + } +}; +static const x86_insn_info pshift_insn[] = { + { CPU_MMX, MOD_Op1Add, 0, 0, 0, 2, {0x0F, 0x00, 0}, 0, 2, + {OPT_SIMDReg|OPS_64|OPA_Spare, OPT_SIMDRM|OPS_64|OPS_Relaxed|OPA_EA, 0} + }, + { CPU_MMX, MOD_Gap0|MOD_Op1Add|MOD_SpAdd, 0, 0, 0, 2, {0x0F, 0x00, 0}, 0, + 2, {OPT_SIMDReg|OPS_64|OPA_EA, OPT_Imm|OPS_8|OPS_Relaxed|OPA_Imm, 0} }, + { CPU_SSE2, MOD_Op1Add, 0, 0, 0x66, 2, {0x0F, 0x00, 0}, 0, 2, + {OPT_SIMDReg|OPS_128|OPA_Spare, OPT_SIMDRM|OPS_128|OPS_Relaxed|OPA_EA, 0} + }, + { CPU_SSE2, MOD_Gap0|MOD_Op1Add|MOD_SpAdd, 0, 0, 0x66, 2, {0x0F, 0x00, 0}, + 0, 2, + {OPT_SIMDReg|OPS_128|OPA_EA, OPT_Imm|OPS_8|OPS_Relaxed|OPA_Imm, 0} } +}; + +/* PIII (Katmai) new instructions / SIMD instructiosn */ +static const x86_insn_info sseps_insn[] = { + { CPU_SSE, MOD_Op1Add, 0, 0, 0, 2, {0x0F, 0x00, 0}, 0, 2, + {OPT_SIMDReg|OPS_128|OPA_Spare, OPT_SIMDRM|OPS_128|OPS_Relaxed|OPA_EA, 0} + } +}; +static const x86_insn_info cvt_xmm_xmm64_ss_insn[] = { + { CPU_SSE, MOD_PreAdd|MOD_Op1Add, 0, 0, 0x00, 2, {0x0F, 0x00, 0}, 0, 2, + {OPT_SIMDReg|OPS_128|OPA_Spare, OPT_SIMDReg|OPS_128|OPA_EA, 0} + }, + { CPU_SSE, MOD_PreAdd|MOD_Op1Add, 0, 0, 0x00, 2, {0x0F, 0x00, 0}, 0, 2, + {OPT_SIMDReg|OPS_128|OPA_Spare, OPT_Mem|OPS_64|OPS_Relaxed|OPA_EA, 0} + } +}; +static const x86_insn_info cvt_xmm_xmm64_ps_insn[] = { + { CPU_SSE, MOD_Op1Add, 0, 0, 0, 2, {0x0F, 0x00, 0x00}, 0, 2, + {OPT_SIMDReg|OPS_128|OPA_Spare, OPT_SIMDReg|OPS_128|OPA_EA, 0} + }, + { CPU_SSE, MOD_Op1Add, 0, 0, 0, 2, {0x0F, 0x00, 0x00}, 0, 2, + {OPT_SIMDReg|OPS_128|OPA_Spare, OPT_Mem|OPS_64|OPS_Relaxed|OPA_EA, 0} + } +}; +static const x86_insn_info cvt_xmm_xmm32_insn[] = { + { CPU_SSE, MOD_PreAdd|MOD_Op1Add, 0, 0, 0x00, 2, {0x0F, 0x00, 0}, 0, 2, + {OPT_SIMDReg|OPS_128|OPA_Spare, OPT_SIMDReg|OPS_128|OPA_EA, 0} + }, + { CPU_SSE, MOD_PreAdd|MOD_Op1Add, 0, 0, 0x00, 2, {0x0F, 0x00, 0}, 0, 2, + {OPT_SIMDReg|OPS_128|OPA_Spare, OPT_Mem|OPS_32|OPS_Relaxed|OPA_EA, 0} + } +}; +static const x86_insn_info cvt_rx_xmm64_insn[] = { + { CPU_SSE, MOD_PreAdd|MOD_Op1Add|MOD_GasSufL, 0, 0, 0x00, 2, + {0x0F, 0x00, 0}, 0, 2, + {OPT_Reg|OPS_32|OPA_Spare, OPT_SIMDReg|OPS_128|OPA_EA, 0} + }, + { CPU_SSE, MOD_PreAdd|MOD_Op1Add|MOD_GasSufL, 0, 0, 0x00, 2, + {0x0F, 0x00, 0}, 0, 2, + {OPT_Reg|OPS_32|OPA_Spare, OPT_Mem|OPS_64|OPS_Relaxed|OPA_EA, 0} + }, + /* REX */ + { CPU_SSE|CPU_Hammer|CPU_64, MOD_PreAdd|MOD_Op1Add|MOD_GasSufQ, 64, 0, + 0x00, 2, {0x0F, 0x00, 0}, 0, 2, + {OPT_Reg|OPS_64|OPA_Spare, OPT_SIMDReg|OPS_128|OPA_EA, 0} + }, + { CPU_SSE|CPU_Hammer|CPU_64, MOD_PreAdd|MOD_Op1Add|MOD_GasSufQ, 64, 0, + 0x00, 2, {0x0F, 0x00, 0}, 0, 2, + {OPT_Reg|OPS_64|OPA_Spare, OPT_Mem|OPS_64|OPS_Relaxed|OPA_EA, 0} + } +}; +static const x86_insn_info cvt_rx_xmm32_insn[] = { + { CPU_SSE, MOD_PreAdd|MOD_Op1Add|MOD_GasSufL, 0, 0, 0x00, 2, + {0x0F, 0x00, 0}, 0, 2, + {OPT_Reg|OPS_32|OPA_Spare, OPT_SIMDReg|OPS_128|OPA_EA, 0} + }, + { CPU_SSE, MOD_PreAdd|MOD_Op1Add|MOD_GasSufL, 0, 0, 0x00, 2, + {0x0F, 0x00, 0}, 0, 2, + {OPT_Reg|OPS_32|OPA_Spare, OPT_Mem|OPS_32|OPS_Relaxed|OPA_EA, 0} + }, + /* REX */ + { CPU_SSE|CPU_Hammer|CPU_64, MOD_PreAdd|MOD_Op1Add|MOD_GasSufQ, 64, 0, + 0x00, 2, {0x0F, 0x00, 0}, 0, 2, + {OPT_Reg|OPS_64|OPA_Spare, OPT_SIMDReg|OPS_128|OPA_EA, 0} + }, + { CPU_SSE|CPU_Hammer|CPU_64, MOD_PreAdd|MOD_Op1Add|MOD_GasSufQ, 64, 0, + 0x00, 2, {0x0F, 0x00, 0}, 0, 2, + {OPT_Reg|OPS_64|OPA_Spare, OPT_Mem|OPS_32|OPS_Relaxed|OPA_EA, 0} + } +}; +static const x86_insn_info cvt_mm_xmm64_insn[] = { + { CPU_SSE, MOD_Op1Add, 0, 0, 0, 2, {0x0F, 0x00, 0x00}, 0, 2, + {OPT_SIMDReg|OPS_64|OPA_Spare, OPT_SIMDReg|OPS_128|OPA_EA, 0} + }, + { CPU_SSE, MOD_Op1Add, 0, 0, 0, 2, {0x0F, 0x00, 0x00}, 0, 2, + {OPT_SIMDReg|OPS_64|OPA_Spare, OPT_Mem|OPS_64|OPS_Relaxed|OPA_EA, 0} + } +}; +static const x86_insn_info cvt_mm_xmm_insn[] = { + { CPU_SSE, MOD_PreAdd|MOD_Op1Add, 0, 0, 0x00, 2, {0x0F, 0x00, 0}, 0, 2, + {OPT_SIMDReg|OPS_64|OPA_Spare, OPT_SIMDRM|OPS_128|OPS_Relaxed|OPA_EA, 0} + } +}; +static const x86_insn_info cvt_xmm_mm_ss_insn[] = { + { CPU_SSE, MOD_PreAdd|MOD_Op1Add, 0, 0, 0x00, 2, {0x0F, 0x00, 0}, 0, 2, + {OPT_SIMDReg|OPS_128|OPA_Spare, OPT_SIMDRM|OPS_64|OPS_Relaxed|OPA_EA, 0} + } +}; +static const x86_insn_info cvt_xmm_mm_ps_insn[] = { + { CPU_SSE, MOD_Op1Add, 0, 0, 0, 2, {0x0F, 0x00, 0x00}, 0, 2, + {OPT_SIMDReg|OPS_128|OPA_Spare, OPT_SIMDRM|OPS_64|OPS_Relaxed|OPA_EA, 0} + } +}; +static const x86_insn_info cvt_xmm_rmx_insn[] = { + { CPU_SSE, MOD_PreAdd|MOD_Op1Add|MOD_GasSufL, 0, 0, 0x00, 2, + {0x0F, 0x00, 0}, 0, 2, + {OPT_SIMDReg|OPS_128|OPA_Spare, OPT_RM|OPS_32|OPS_Relaxed|OPA_EA, 0} + }, + /* REX */ + { CPU_Hammer|CPU_64, MOD_PreAdd|MOD_Op1Add|MOD_GasSufQ, 64, 0, 0x00, 2, + {0x0F, 0x00, 0}, 0, 2, + {OPT_SIMDReg|OPS_128|OPA_Spare, OPT_RM|OPS_64|OPS_Relaxed|OPA_EA, 0} + } +}; +static const x86_insn_info ssess_insn[] = { + { CPU_SSE, MOD_PreAdd|MOD_Op1Add, 0, 0, 0x00, 2, {0x0F, 0x00, 0}, 0, 2, + {OPT_SIMDReg|OPS_128|OPA_Spare, OPT_SIMDRM|OPS_128|OPS_Relaxed|OPA_EA, 0} + } +}; +static const x86_insn_info ssecmpps_insn[] = { + { CPU_SSE, MOD_Imm8, 0, 0, 0, 2, {0x0F, 0xC2, 0}, 0, 2, + {OPT_SIMDReg|OPS_128|OPA_Spare, OPT_SIMDRM|OPS_128|OPS_Relaxed|OPA_EA, 0} + } +}; +static const x86_insn_info ssecmpss_insn[] = { + { CPU_SSE, MOD_PreAdd|MOD_Imm8, 0, 0, 0x00, 2, {0x0F, 0xC2, 0}, 0, 2, + {OPT_SIMDReg|OPS_128|OPA_Spare, OPT_SIMDRM|OPS_128|OPS_Relaxed|OPA_EA, 0} + } +}; +static const x86_insn_info ssepsimm_insn[] = { + { CPU_SSE, MOD_Op1Add, 0, 0, 0, 2, {0x0F, 0x00, 0}, 0, 3, + {OPT_SIMDReg|OPS_128|OPA_Spare, OPT_SIMDRM|OPS_128|OPS_Relaxed|OPA_EA, + OPT_Imm|OPS_8|OPS_Relaxed|OPA_Imm} } +}; +static const x86_insn_info ssessimm_insn[] = { + { CPU_SSE, MOD_PreAdd|MOD_Op1Add, 0, 0, 0x00, 2, {0x0F, 0x00, 0}, 0, 3, + {OPT_SIMDReg|OPS_128|OPA_Spare, OPT_SIMDRM|OPS_128|OPS_Relaxed|OPA_EA, + OPT_Imm|OPS_8|OPS_Relaxed|OPA_Imm} } +}; +static const x86_insn_info ldstmxcsr_insn[] = { + { CPU_SSE, MOD_SpAdd, 0, 0, 0, 2, {0x0F, 0xAE, 0}, 0, 1, + {OPT_Mem|OPS_32|OPS_Relaxed|OPA_EA, 0, 0} } +}; +static const x86_insn_info maskmovq_insn[] = { + { CPU_P3|CPU_MMX, 0, 0, 0, 0, 2, {0x0F, 0xF7, 0}, 0, 2, + {OPT_SIMDReg|OPS_64|OPA_Spare, OPT_SIMDReg|OPS_64|OPA_EA, 0} } +}; +static const x86_insn_info movaups_insn[] = { + { CPU_SSE, MOD_Op1Add, 0, 0, 0, 2, {0x0F, 0x00, 0}, 0, 2, + {OPT_SIMDReg|OPS_128|OPA_Spare, OPT_SIMDRM|OPS_128|OPS_Relaxed|OPA_EA, 0} + }, + { CPU_SSE, MOD_Op1Add, 0, 0, 0, 2, {0x0F, 0x01, 0}, 0, 2, + {OPT_SIMDRM|OPS_128|OPS_Relaxed|OPA_EA, OPT_SIMDReg|OPS_128|OPA_Spare, 0} + } +}; +static const x86_insn_info movhllhps_insn[] = { + { CPU_SSE, MOD_Op1Add, 0, 0, 0, 2, {0x0F, 0x00, 0}, 0, 2, + {OPT_SIMDReg|OPS_128|OPA_Spare, OPT_SIMDReg|OPS_128|OPA_EA, 0} } +}; +static const x86_insn_info movhlps_insn[] = { + { CPU_SSE, MOD_Op1Add, 0, 0, 0, 2, {0x0F, 0x00, 0}, 0, 2, + {OPT_SIMDReg|OPS_128|OPA_Spare, OPT_Mem|OPS_64|OPS_Relaxed|OPA_EA, 0} }, + { CPU_SSE, MOD_Op1Add, 0, 0, 0, 2, {0x0F, 0x01, 0}, 0, 2, + {OPT_Mem|OPS_64|OPS_Relaxed|OPA_EA, OPT_SIMDReg|OPS_128|OPA_Spare, 0} } +}; +static const x86_insn_info movmskps_insn[] = { + { CPU_SSE, MOD_GasSufL, 0, 0, 0, 2, {0x0F, 0x50, 0}, 0, 2, + {OPT_Reg|OPS_32|OPA_Spare, OPT_SIMDReg|OPS_128|OPA_EA, 0} }, + { CPU_Hammer|CPU_64, MOD_GasSufQ, 64, 0, 0, 2, {0x0F, 0x50, 0}, 0, 2, + {OPT_Reg|OPS_64|OPA_Spare, OPT_SIMDReg|OPS_128|OPA_EA, 0} } +}; +static const x86_insn_info movntps_insn[] = { + { CPU_SSE, 0, 0, 0, 0, 2, {0x0F, 0x2B, 0}, 0, 2, + {OPT_Mem|OPS_128|OPS_Relaxed|OPA_EA, OPT_SIMDReg|OPS_128|OPA_Spare, 0} } +}; +static const x86_insn_info movntq_insn[] = { + { CPU_SSE, 0, 0, 0, 0, 2, {0x0F, 0xE7, 0}, 0, 2, + {OPT_Mem|OPS_64|OPS_Relaxed|OPA_EA, OPT_SIMDReg|OPS_64|OPA_Spare, 0} } +}; +static const x86_insn_info movss_insn[] = { + { CPU_SSE, 0, 0, 0, 0xF3, 2, {0x0F, 0x10, 0}, 0, 2, + {OPT_SIMDReg|OPS_128|OPA_Spare, OPT_SIMDReg|OPS_128|OPA_EA, 0} }, + { CPU_SSE, 0, 0, 0, 0xF3, 2, {0x0F, 0x10, 0}, 0, 2, + {OPT_SIMDReg|OPS_128|OPA_Spare, OPT_Mem|OPS_32|OPS_Relaxed|OPA_EA, 0} }, + { CPU_SSE, 0, 0, 0, 0xF3, 2, {0x0F, 0x11, 0}, 0, 2, + {OPT_Mem|OPS_32|OPS_Relaxed|OPA_EA, OPT_SIMDReg|OPS_128|OPA_Spare, 0} } +}; +static const x86_insn_info pextrw_insn[] = { + { CPU_P3|CPU_MMX, MOD_GasSufL, 0, 0, 0, 2, {0x0F, 0xC5, 0}, 0, 3, + {OPT_Reg|OPS_32|OPA_Spare, OPT_SIMDReg|OPS_64|OPA_EA, + OPT_Imm|OPS_8|OPS_Relaxed|OPA_Imm} }, + { CPU_SSE2, MOD_GasSufL, 0, 0, 0x66, 2, {0x0F, 0xC5, 0}, 0, 3, + {OPT_Reg|OPS_32|OPA_Spare, OPT_SIMDReg|OPS_128|OPA_EA, + OPT_Imm|OPS_8|OPS_Relaxed|OPA_Imm} }, + { CPU_SSE2|CPU_Hammer|CPU_64, MOD_GasSufQ, 64, 0, 0, 2, {0x0F, 0xC5, 0}, + 0, 3, + {OPT_Reg|OPS_64|OPA_Spare, OPT_SIMDReg|OPS_64|OPA_EA, + OPT_Imm|OPS_8|OPS_Relaxed|OPA_Imm} }, + { CPU_SSE2|CPU_Hammer|CPU_64, MOD_GasSufQ, 64, 0, 0x66, 2, {0x0F, 0xC5, 0}, + 0, 3, + {OPT_Reg|OPS_64|OPA_Spare, OPT_SIMDReg|OPS_128|OPA_EA, + OPT_Imm|OPS_8|OPS_Relaxed|OPA_Imm} }, + /* SSE4.1 instructions */ + { CPU_SSE41, 0, 0, 0, 0x66, 3, {0x0F, 0x3A, 0x15}, 0, 3, + {OPT_Mem|OPS_16|OPS_Relaxed|OPA_EA, OPT_SIMDReg|OPS_128|OPA_Spare, + OPT_Imm|OPS_8|OPS_Relaxed|OPA_Imm} }, + { CPU_SSE41, 0, 32, 0, 0x66, 3, {0x0F, 0x3A, 0x15}, 0, 3, + {OPT_Reg|OPS_32|OPA_EA, OPT_SIMDReg|OPS_128|OPA_Spare, + OPT_Imm|OPS_8|OPS_Relaxed|OPA_Imm} }, + { CPU_SSE41|CPU_64, 0, 64, 0, 0x66, 3, {0x0F, 0x3A, 0x15}, 0, 3, + {OPT_Reg|OPS_64|OPA_EA, OPT_SIMDReg|OPS_128|OPA_Spare, + OPT_Imm|OPS_8|OPS_Relaxed|OPA_Imm} } +}; +static const x86_insn_info pinsrw_insn[] = { + { CPU_P3|CPU_MMX, MOD_GasSufL, 0, 0, 0, 2, {0x0F, 0xC4, 0}, 0, 3, + {OPT_SIMDReg|OPS_64|OPA_Spare, OPT_Reg|OPS_32|OPA_EA, + OPT_Imm|OPS_8|OPS_Relaxed|OPA_Imm} }, + { CPU_Hammer|CPU_64, MOD_GasSufQ, 64, 0, 0, 2, {0x0F, 0xC4, 0}, 0, 3, + {OPT_SIMDReg|OPS_64|OPA_Spare, OPT_Reg|OPS_64|OPA_EA, + OPT_Imm|OPS_8|OPS_Relaxed|OPA_Imm} }, + { CPU_P3|CPU_MMX, MOD_GasSufL, 0, 0, 0, 2, {0x0F, 0xC4, 0}, 0, 3, + {OPT_SIMDReg|OPS_64|OPA_Spare, OPT_Mem|OPS_16|OPS_Relaxed|OPA_EA, + OPT_Imm|OPS_8|OPS_Relaxed|OPA_Imm} }, + { CPU_SSE2, MOD_GasSufL, 0, 0, 0x66, 2, {0x0F, 0xC4, 0}, 0, 3, + {OPT_SIMDReg|OPS_128|OPA_Spare, OPT_Reg|OPS_32|OPA_EA, + OPT_Imm|OPS_8|OPS_Relaxed|OPA_Imm} }, + { CPU_Hammer|CPU_64, MOD_GasSufQ, 64, 0, 0x66, 2, {0x0F, 0xC4, 0}, 0, 3, + {OPT_SIMDReg|OPS_128|OPA_Spare, OPT_Reg|OPS_64|OPA_EA, + OPT_Imm|OPS_8|OPS_Relaxed|OPA_Imm} }, + { CPU_SSE2, MOD_GasSufL, 0, 0, 0x66, 2, {0x0F, 0xC4, 0}, 0, 3, + {OPT_SIMDReg|OPS_128|OPA_Spare, OPT_Mem|OPS_16|OPS_Relaxed|OPA_EA, + OPT_Imm|OPS_8|OPS_Relaxed|OPA_Imm} } +}; +static const x86_insn_info pmovmskb_insn[] = { + { CPU_P3|CPU_MMX, MOD_GasSufL, 0, 0, 0, 2, {0x0F, 0xD7, 0}, 0, 2, + {OPT_Reg|OPS_32|OPA_Spare, OPT_SIMDReg|OPS_64|OPA_EA, 0} }, + { CPU_SSE2, MOD_GasSufL, 0, 0, 0x66, 2, {0x0F, 0xD7, 0}, 0, 2, + {OPT_Reg|OPS_32|OPA_Spare, OPT_SIMDReg|OPS_128|OPA_EA, 0} }, + { CPU_Hammer|CPU_64, MOD_GasSufQ, 64, 0, 0, 2, {0x0F, 0xD7, 0}, 0, 2, + {OPT_Reg|OPS_64|OPA_Spare, OPT_SIMDReg|OPS_64|OPA_EA, 0} }, + { CPU_Hammer|CPU_64, MOD_GasSufQ, 64, 0, 0x66, 2, {0x0F, 0xD7, 0}, 0, 2, + {OPT_Reg|OPS_64|OPA_Spare, OPT_SIMDReg|OPS_128|OPA_EA, 0} } +}; +static const x86_insn_info pshufw_insn[] = { + { CPU_P3|CPU_MMX, 0, 0, 0, 0, 2, {0x0F, 0x70, 0}, 0, 3, + {OPT_SIMDReg|OPS_64|OPA_Spare, OPT_SIMDRM|OPS_64|OPS_Relaxed|OPA_EA, + OPT_Imm|OPS_8|OPS_Relaxed|OPA_Imm} } +}; + +/* SSE2 instructions */ +static const x86_insn_info cmpsd_insn[] = { + { CPU_Any, MOD_GasIllegal, 32, 0, 0, 1, {0xA7, 0, 0}, 0, 0, {0, 0, 0} }, + { CPU_SSE2, 0, 0, 0, 0xF2, 2, {0x0F, 0xC2, 0}, 0, 3, + {OPT_SIMDReg|OPS_128|OPA_Spare, OPT_SIMDRM|OPS_128|OPS_Relaxed|OPA_EA, + OPT_Imm|OPS_8|OPS_Relaxed|OPA_Imm} } +}; +static const x86_insn_info movaupd_insn[] = { + { CPU_SSE2, MOD_Op1Add, 0, 0, 0x66, 2, {0x0F, 0x00, 0}, 0, 2, + {OPT_SIMDReg|OPS_128|OPA_Spare, OPT_SIMDRM|OPS_128|OPS_Relaxed|OPA_EA, 0} + }, + { CPU_SSE2, MOD_Op1Add, 0, 0, 0x66, 2, {0x0F, 0x01, 0}, 0, 2, + {OPT_SIMDRM|OPS_128|OPS_Relaxed|OPA_EA, OPT_SIMDReg|OPS_128|OPA_Spare, 0} + } +}; +static const x86_insn_info movhlpd_insn[] = { + { CPU_SSE2, MOD_Op1Add, 0, 0, 0x66, 2, {0x0F, 0x00, 0}, 0, 2, + {OPT_SIMDReg|OPS_128|OPA_Spare, OPT_Mem|OPS_64|OPS_Relaxed|OPA_EA, 0} }, + { CPU_SSE2, MOD_Op1Add, 0, 0, 0x66, 2, {0x0F, 0x01, 0}, 0, 2, + {OPT_Mem|OPS_64|OPS_Relaxed|OPA_EA, OPT_SIMDReg|OPS_128|OPA_Spare, 0} } +}; +static const x86_insn_info movmskpd_insn[] = { + { CPU_SSE2, MOD_GasSufL, 0, 0, 0x66, 2, {0x0F, 0x50, 0}, 0, 2, + {OPT_Reg|OPS_32|OPA_Spare, OPT_SIMDReg|OPS_128|OPA_EA, 0} } +}; +static const x86_insn_info movntpddq_insn[] = { + { CPU_SSE2, MOD_Op1Add, 0, 0, 0x66, 2, {0x0F, 0x00, 0}, 0, 2, + {OPT_Mem|OPS_128|OPS_Relaxed|OPA_EA, OPT_SIMDReg|OPS_128|OPA_Spare, 0} } +}; +static const x86_insn_info movsd_insn[] = { + { CPU_Any, MOD_GasIllegal, 32, 0, 0, 1, {0xA5, 0, 0}, 0, 0, {0, 0, 0} }, + { CPU_SSE2, 0, 0, 0, 0xF2, 2, {0x0F, 0x10, 0}, 0, 2, + {OPT_SIMDReg|OPS_128|OPA_Spare, OPT_SIMDReg|OPS_128|OPA_EA, 0} }, + { CPU_SSE2, 0, 0, 0, 0xF2, 2, {0x0F, 0x10, 0}, 0, 2, + {OPT_SIMDReg|OPS_128|OPA_Spare, OPT_Mem|OPS_64|OPS_Relaxed|OPA_EA, 0} }, + { CPU_SSE2, 0, 0, 0, 0xF2, 2, {0x0F, 0x11, 0}, 0, 2, + {OPT_Mem|OPS_64|OPS_Relaxed|OPA_EA, OPT_SIMDReg|OPS_128|OPA_Spare, 0} } +}; +static const x86_insn_info maskmovdqu_insn[] = { + { CPU_SSE2, 0, 0, 0, 0x66, 2, {0x0F, 0xF7, 0}, 0, 2, + {OPT_SIMDReg|OPS_128|OPA_Spare, OPT_SIMDReg|OPS_128|OPA_EA, 0} } +}; +static const x86_insn_info movdqau_insn[] = { + { CPU_SSE2, MOD_PreAdd, 0, 0, 0x00, 2, {0x0F, 0x6F, 0}, 0, 2, + {OPT_SIMDReg|OPS_128|OPA_Spare, OPT_SIMDRM|OPS_128|OPS_Relaxed|OPA_EA, 0} + }, + { CPU_SSE2, MOD_PreAdd, 0, 0, 0x00, 2, {0x0F, 0x7F, 0}, 0, 2, + {OPT_SIMDRM|OPS_128|OPS_Relaxed|OPA_EA, OPT_SIMDReg|OPS_128|OPA_Spare, 0} + } +}; +static const x86_insn_info movdq2q_insn[] = { + { CPU_SSE2, 0, 0, 0, 0xF2, 2, {0x0F, 0xD6, 0}, 0, 2, + {OPT_SIMDReg|OPS_64|OPA_Spare, OPT_SIMDReg|OPS_128|OPA_EA, 0} } +}; +static const x86_insn_info movq2dq_insn[] = { + { CPU_SSE2, 0, 0, 0, 0xF3, 2, {0x0F, 0xD6, 0}, 0, 2, + {OPT_SIMDReg|OPS_128|OPA_Spare, OPT_SIMDReg|OPS_64|OPA_EA, 0} } +}; +static const x86_insn_info pslrldq_insn[] = { + { CPU_SSE2, MOD_SpAdd, 0, 0, 0x66, 2, {0x0F, 0x73, 0}, 0, 2, + {OPT_SIMDReg|OPS_128|OPA_EA, OPT_Imm|OPS_8|OPS_Relaxed|OPA_Imm, 0} } +}; + +/* SSE3 instructions */ +static const x86_insn_info lddqu_insn[] = { + { CPU_SSE3, 0, 0, 0, 0xF2, 2, {0x0F, 0xF0, 0}, 0, 2, + {OPT_SIMDReg|OPS_128|OPA_Spare, OPT_Mem|OPS_Any|OPA_EA, 0} } +}; + +/* SSSE3 instructions */ +static const x86_insn_info ssse3_insn[] = { + { CPU_SSSE3, MOD_Op2Add, 0, 0, 0, 3, {0x0F, 0x38, 0x00}, 0, 2, + {OPT_SIMDReg|OPS_64|OPA_Spare, OPT_SIMDRM|OPS_64|OPS_Relaxed|OPA_EA, 0} + }, + { CPU_SSSE3, MOD_Op2Add, 0, 0, 0x66, 3, {0x0F, 0x38, 0x00}, 0, 2, + {OPT_SIMDReg|OPS_128|OPA_Spare, OPT_SIMDRM|OPS_128|OPS_Relaxed|OPA_EA, 0} + } +}; + +static const x86_insn_info ssse3imm_insn[] = { + { CPU_SSSE3, MOD_Op2Add, 0, 0, 0, 3, {0x0F, 0x3A, 0x00}, 0, 3, + {OPT_SIMDReg|OPS_64|OPA_Spare, OPT_SIMDRM|OPS_64|OPS_Relaxed|OPA_EA, OPT_Imm|OPS_8|OPS_Relaxed|OPA_Imm} + }, + { CPU_SSSE3, MOD_Op2Add, 0, 0, 0x66, 3, {0x0F, 0x3A, 0x00}, 0, 3, + {OPT_SIMDReg|OPS_128|OPA_Spare, OPT_SIMDRM|OPS_128|OPS_Relaxed|OPA_EA, OPT_Imm|OPS_8|OPS_Relaxed|OPA_Imm} + } +}; + +/* SSE4 instructions */ + +static const x86_insn_info sse4_insn[] = { + { CPU_Any, MOD_Op2Add, 0, 0, 0x66, 3, {0x0F, 0x38, 0x00}, 0, 2, + {OPT_SIMDReg|OPS_128|OPA_Spare, OPT_SIMDRM|OPS_128|OPS_Relaxed|OPA_EA, 0} + } +}; + +static const x86_insn_info sse4imm_insn[] = { + { CPU_SSE41, MOD_Op2Add, 0, 0, 0x66, 3, {0x0F, 0x3A, 0x00}, 0, 3, + {OPT_SIMDReg|OPS_128|OPA_Spare, OPT_SIMDRM|OPS_128|OPS_Relaxed|OPA_EA, + OPT_Imm|OPS_8|OPS_Relaxed|OPA_Imm} } +}; + +static const x86_insn_info sse4xmm0_insn[] = { + { CPU_SSE41, MOD_Op2Add, 0, 0, 0x66, 3, {0x0F, 0x38, 0x00}, 0, 2, + {OPT_SIMDReg|OPS_128|OPA_Spare, OPT_SIMDRM|OPS_128|OPS_Relaxed|OPA_EA, 0} + }, + { CPU_SSE41, MOD_Op2Add, 0, 0, 0x66, 3, {0x0F, 0x38, 0x00}, 0, 3, + {OPT_SIMDReg|OPS_128|OPA_Spare, OPT_SIMDRM|OPS_128|OPS_Relaxed|OPA_EA, + OPT_XMM0|OPS_128|OPA_None} + } +}; + +static const x86_insn_info crc32_insn[] = { + { CPU_SSE42, MOD_GasSufB, 0, 0, 0xF2, 3, {0x0F, 0x38, 0xF0}, 0, 2, + {OPT_Reg|OPS_32|OPA_Spare, OPT_RM|OPS_8|OPA_EA, 0} }, + { CPU_SSE42, MOD_GasSufW, 16, 0, 0xF2, 3, {0x0F, 0x38, 0xF1}, 0, 2, + {OPT_Reg|OPS_32|OPA_Spare, OPT_RM|OPS_16|OPA_EA, 0} }, + { CPU_SSE42, MOD_GasSufL, 32, 0, 0xF2, 3, {0x0F, 0x38, 0xF1}, 0, 2, + {OPT_Reg|OPS_32|OPA_Spare, OPT_RM|OPS_32|OPS_Relaxed|OPA_EA, 0} }, + { CPU_SSE42|CPU_64, MOD_GasSufB, 64, 0, 0xF2, 3, {0x0F, 0x38, 0xF0}, 0, 2, + {OPT_Reg|OPS_64|OPA_Spare, OPT_RM|OPS_8|OPA_EA, 0} }, + { CPU_SSE42|CPU_64, MOD_GasSufQ, 64, 0, 0xF2, 3, {0x0F, 0x38, 0xF1}, 0, 2, + {OPT_Reg|OPS_64|OPA_Spare, OPT_RM|OPS_64|OPS_Relaxed|OPA_EA, 0} } +}; + +static const x86_insn_info extractps_insn[] = { + { CPU_SSE41, 0, 32, 0, 0x66, 3, {0x0F, 0x3A, 0x17}, 0, 3, + {OPT_RM|OPS_32|OPS_Relaxed|OPA_EA, OPT_SIMDReg|OPS_128|OPA_Spare, + OPT_Imm|OPS_8|OPS_Relaxed|OPA_Imm} }, + { CPU_SSE41|CPU_64, 0, 64, 0, 0x66, 3, {0x0F, 0x3A, 0x17}, 0, 3, + {OPT_Reg|OPS_64|OPA_EA, OPT_SIMDReg|OPS_128|OPA_Spare, + OPT_Imm|OPS_8|OPS_Relaxed|OPA_Imm} } +}; + +static const x86_insn_info insertps_insn[] = { + { CPU_SSE41, 0, 0, 0, 0x66, 3, {0x0F, 0x3A, 0x21}, 0, 3, + {OPT_SIMDReg|OPS_128|OPA_Spare, OPT_Mem|OPS_32|OPS_Relaxed|OPA_EA, + OPT_Imm|OPS_8|OPS_Relaxed|OPA_Imm} }, + { CPU_SSE41, 0, 0, 0, 0x66, 3, {0x0F, 0x3A, 0x21}, 0, 3, + {OPT_SIMDReg|OPS_128|OPA_Spare, OPT_SIMDReg|OPS_128|OPA_EA, + OPT_Imm|OPS_8|OPS_Relaxed|OPA_Imm} } +}; + +static const x86_insn_info movntdqa_insn[] = { + { CPU_SSE41, 0, 0, 0, 0x66, 3, {0x0F, 0x38, 0x2A}, 0, 2, + {OPT_SIMDReg|OPS_128|OPA_Spare, OPT_Mem|OPS_128|OPS_Relaxed|OPA_EA, 0} } +}; + +static const x86_insn_info sse4pcmpstr_insn[] = { + { CPU_SSE42, MOD_Op2Add, 0, 0, 0x66, 3, {0x0F, 0x3A, 0x00}, 0, 3, + {OPT_SIMDReg|OPS_128|OPA_Spare, OPT_SIMDRM|OPS_128|OPS_Relaxed|OPA_EA, + OPT_Imm|OPS_8|OPS_Relaxed|OPA_Imm} }, + { CPU_SSE42, MOD_Op2Add|MOD_GasOnly|MOD_GasSufW, 16, 0, 0x66, 3, + {0x0F, 0x3A, 0x00}, 0, 3, + {OPT_SIMDReg|OPS_128|OPA_Spare, OPT_SIMDRM|OPS_128|OPS_Relaxed|OPA_EA, + OPT_Imm|OPS_8|OPS_Relaxed|OPA_Imm} + }, + { CPU_SSE42, MOD_Op2Add|MOD_GasOnly|MOD_GasSufL, 32, 0, 0x66, 3, + {0x0F, 0x3A, 0x00}, 0, 3, + {OPT_SIMDReg|OPS_128|OPA_Spare, OPT_SIMDRM|OPS_128|OPS_Relaxed|OPA_EA, + OPT_Imm|OPS_8|OPS_Relaxed|OPA_Imm} + }, + { CPU_SSE42, MOD_Op2Add|MOD_GasOnly|MOD_GasSufQ, 64, 0, 0x66, 3, + {0x0F, 0x3A, 0x00}, 0, 3, + {OPT_SIMDReg|OPS_128|OPA_Spare, OPT_SIMDRM|OPS_128|OPS_Relaxed|OPA_EA, + OPT_Imm|OPS_8|OPS_Relaxed|OPA_Imm} + } +}; + +static const x86_insn_info pextrb_insn[] = { + { CPU_SSE41, 0, 0, 0, 0x66, 3, {0x0F, 0x3A, 0x14}, 0, 3, + {OPT_Mem|OPS_8|OPS_Relaxed|OPA_EA, OPT_SIMDReg|OPS_128|OPA_Spare, + OPT_Imm|OPS_8|OPS_Relaxed|OPA_Imm} }, + { CPU_SSE41, 0, 32, 0, 0x66, 3, {0x0F, 0x3A, 0x14}, 0, 3, + {OPT_Reg|OPS_32|OPA_EA, OPT_SIMDReg|OPS_128|OPA_Spare, + OPT_Imm|OPS_8|OPS_Relaxed|OPA_Imm} }, + { CPU_SSE41|CPU_64, 0, 64, 0, 0x66, 3, {0x0F, 0x3A, 0x14}, 0, 3, + {OPT_Reg|OPS_64|OPA_EA, OPT_SIMDReg|OPS_128|OPA_Spare, + OPT_Imm|OPS_8|OPS_Relaxed|OPA_Imm} } +}; + +static const x86_insn_info pextrd_insn[] = { + { CPU_SSE41, 0, 32, 0, 0x66, 3, {0x0F, 0x3A, 0x16}, 0, 3, + {OPT_RM|OPS_32|OPS_Relaxed|OPA_EA, OPT_SIMDReg|OPS_128|OPA_Spare, + OPT_Imm|OPS_8|OPS_Relaxed|OPA_Imm} } +}; + +static const x86_insn_info pextrq_insn[] = { + { CPU_SSE41|CPU_64, 0, 64, 0, 0x66, 3, {0x0F, 0x3A, 0x16}, 0, 3, + {OPT_RM|OPS_64|OPS_Relaxed|OPA_EA, OPT_SIMDReg|OPS_128|OPA_Spare, + OPT_Imm|OPS_8|OPS_Relaxed|OPA_Imm} } +}; + +static const x86_insn_info pinsrb_insn[] = { + { CPU_SSE41, 0, 0, 0, 0x66, 3, {0x0F, 0x3A, 0x20}, 0, 3, + {OPT_SIMDReg|OPS_128|OPA_Spare, OPT_Mem|OPS_8|OPS_Relaxed|OPA_EA, + OPT_Imm|OPS_8|OPS_Relaxed|OPA_Imm} }, + { CPU_SSE41, 0, 32, 0, 0x66, 3, {0x0F, 0x3A, 0x20}, 0, 3, + {OPT_SIMDReg|OPS_128|OPA_Spare, OPT_Reg|OPS_32|OPA_EA, + OPT_Imm|OPS_8|OPS_Relaxed|OPA_Imm} } +}; + +static const x86_insn_info pinsrd_insn[] = { + { CPU_SSE41, 0, 32, 0, 0x66, 3, {0x0F, 0x3A, 0x22}, 0, 3, + {OPT_SIMDReg|OPS_128|OPA_Spare, OPT_RM|OPS_32|OPS_Relaxed|OPA_EA, + OPT_Imm|OPS_8|OPS_Relaxed|OPA_Imm} } +}; + +static const x86_insn_info pinsrq_insn[] = { + { CPU_SSE41|CPU_64, 0, 64, 0, 0x66, 3, {0x0F, 0x3A, 0x22}, 0, 3, + {OPT_SIMDReg|OPS_128|OPA_Spare, OPT_RM|OPS_64|OPS_Relaxed|OPA_EA, + OPT_Imm|OPS_8|OPS_Relaxed|OPA_Imm} } +}; + +static const x86_insn_info sse4m64_insn[] = { + { CPU_SSE41, MOD_Op2Add, 0, 0, 0x66, 3, {0x0F, 0x38, 0x00}, 0, 2, + {OPT_SIMDReg|OPS_128|OPA_Spare, OPT_Mem|OPS_64|OPS_Relaxed|OPA_EA, 0} }, + { CPU_SSE41, MOD_Op2Add, 0, 0, 0x66, 3, {0x0F, 0x38, 0x00}, 0, 2, + {OPT_SIMDReg|OPS_128|OPA_Spare, OPT_SIMDReg|OPS_128|OPA_EA, 0} } +}; + +static const x86_insn_info sse4m32_insn[] = { + { CPU_SSE41, MOD_Op2Add, 0, 0, 0x66, 3, {0x0F, 0x38, 0x00}, 0, 2, + {OPT_SIMDReg|OPS_128|OPA_Spare, OPT_Mem|OPS_32|OPS_Relaxed|OPA_EA, 0} }, + { CPU_SSE41, MOD_Op2Add, 0, 0, 0x66, 3, {0x0F, 0x38, 0x00}, 0, 2, + {OPT_SIMDReg|OPS_128|OPA_Spare, OPT_SIMDReg|OPS_128|OPA_EA, 0} } +}; + +static const x86_insn_info sse4m16_insn[] = { + { CPU_SSE41, MOD_Op2Add, 0, 0, 0x66, 3, {0x0F, 0x38, 0x00}, 0, 2, + {OPT_SIMDReg|OPS_128|OPA_Spare, OPT_Mem|OPS_16|OPS_Relaxed|OPA_EA, 0} }, + { CPU_SSE41, MOD_Op2Add, 0, 0, 0x66, 3, {0x0F, 0x38, 0x00}, 0, 2, + {OPT_SIMDReg|OPS_128|OPA_Spare, OPT_SIMDReg|OPS_128|OPA_EA, 0} } +}; + +static const x86_insn_info popcnt_insn[] = { + { CPU_SSE42, MOD_GasSufW, 16, 0, 0xF3, 2, {0x0F, 0xB8, 0}, 0, 2, + {OPT_Reg|OPS_16|OPA_Spare, OPT_RM|OPS_16|OPS_Relaxed|OPA_EA, 0} }, + { CPU_SSE42, MOD_GasSufL, 32, 0, 0xF3, 2, {0x0F, 0xB8, 0}, 0, 2, + {OPT_Reg|OPS_32|OPA_Spare, OPT_RM|OPS_32|OPS_Relaxed|OPA_EA, 0} }, + { CPU_SSE42|CPU_64, MOD_GasSufQ, 64, 0, 0xF3, 2, {0x0F, 0xB8, 0}, 0, 2, + {OPT_Reg|OPS_64|OPA_Spare, OPT_RM|OPS_64|OPS_Relaxed|OPA_EA, 0} } +}; + +/* AMD 3DNow! instructions */ +static const x86_insn_info now3d_insn[] = { + { CPU_3DNow, MOD_Imm8, 0, 0, 0, 2, {0x0F, 0x0F, 0}, 0, 2, + {OPT_SIMDReg|OPS_64|OPA_Spare, OPT_SIMDRM|OPS_64|OPS_Relaxed|OPA_EA, 0} } +}; + +/* AMD x86-64 extensions */ +static const x86_insn_info cmpxchg16b_insn[] = { + { CPU_64|CPU_Hammer, 0, 64, 0, 0, 2, {0x0F, 0xC7, 0}, 1, 1, + {OPT_Mem|OPS_128|OPS_Relaxed|OPA_EA, 0, 0} } +}; + +/* AMD Pacifica (SVM) instructions */ +static const x86_insn_info invlpga_insn[] = { + { CPU_SVM, 0, 0, 0, 0, 3, {0x0F, 0x01, 0xDF}, 0, 0, {0, 0, 0} }, + { CPU_SVM, 0, 0, 0, 0, 3, {0x0F, 0x01, 0xDF}, 0, 2, + {OPT_MemrAX|OPS_Any|OPA_AdSizeEA, OPT_Creg|OPS_32|OPA_None, 0} } +}; +static const x86_insn_info skinit_insn[] = { + { CPU_SVM, 0, 0, 0, 0, 3, {0x0F, 0x01, 0xDE}, 0, 0, {0, 0, 0} }, + { CPU_SVM, 0, 0, 0, 0, 3, {0x0F, 0x01, 0xDE}, 0, 1, + {OPT_MemEAX|OPS_Any|OPA_None, 0, 0} } +}; +static const x86_insn_info svm_rax_insn[] = { + { CPU_SVM, MOD_Op2Add, 0, 0, 0, 3, {0x0F, 0x01, 0x00}, 0, 0, {0, 0, 0} }, + { CPU_SVM, MOD_Op2Add, 0, 0, 0, 3, {0x0F, 0x01, 0x00}, 0, 1, + {OPT_MemrAX|OPS_Any|OPA_AdSizeEA, 0, 0} } +}; +/* VIA PadLock instructions */ +static const x86_insn_info padlock_insn[] = { + { CPU_Any, MOD_Imm8|MOD_PreAdd|MOD_Op1Add, 0, 0, 0x00, 2, {0x0F, 0x00, 0}, + 0, 0, {0, 0, 0} } +}; + +/* Cyrix MMX instructions */ +static const x86_insn_info cyrixmmx_insn[] = { + { CPU_Cyrix|CPU_MMX, MOD_Op1Add, 0, 0, 0, 2, {0x0F, 0x00, 0}, 0, 2, + {OPT_SIMDReg|OPS_64|OPA_Spare, OPT_SIMDRM|OPS_64|OPS_Relaxed|OPA_EA, 0} } +}; +static const x86_insn_info pmachriw_insn[] = { + { CPU_Cyrix|CPU_MMX, 0, 0, 0, 0, 2, {0x0F, 0x5E, 0}, 0, 2, + {OPT_SIMDReg|OPS_64|OPA_Spare, OPT_Mem|OPS_64|OPS_Relaxed|OPA_EA, 0} } +}; + +/* Cyrix extensions */ +static const x86_insn_info rdwrshr_insn[] = { + { CPU_486|CPU_Cyrix|CPU_SMM, MOD_Op1Add, 0, 0, 0, 2, {0x0F, 0x36, 0}, 0, 1, + {OPT_RM|OPS_32|OPS_Relaxed|OPA_EA, 0} } +}; +static const x86_insn_info rsdc_insn[] = { + { CPU_486|CPU_Cyrix|CPU_SMM, 0, 0, 0, 0, 2, {0x0F, 0x79, 0}, 0, 2, + {OPT_SegReg|OPS_16|OPS_Relaxed|OPA_Spare, + OPT_Mem|OPS_80|OPS_Relaxed|OPA_EA, 0} } +}; +static const x86_insn_info cyrixsmm_insn[] = { + { CPU_486|CPU_Cyrix|CPU_SMM, MOD_Op1Add, 0, 0, 0, 2, {0x0F, 0x00, 0}, 0, 1, + {OPT_Mem|OPS_80|OPS_Relaxed|OPA_EA, 0, 0} } +}; +static const x86_insn_info svdc_insn[] = { + { CPU_486|CPU_Cyrix|CPU_SMM, 0, 0, 0, 0, 2, {0x0F, 0x78, 0}, 0, 2, + {OPT_Mem|OPS_80|OPS_Relaxed|OPA_EA, + OPT_SegReg|OPS_16|OPS_Relaxed|OPA_Spare, 0} } +}; + +/* Obsolete/undocumented instructions */ +static const x86_insn_info ibts_insn[] = { + { CPU_386|CPU_Undoc|CPU_Obs, 0, 16, 0, 0, 2, {0x0F, 0xA7, 0}, 0, 2, + {OPT_RM|OPS_16|OPS_Relaxed|OPA_EA, OPT_Reg|OPS_16|OPA_Spare, 0} }, + { CPU_386|CPU_Undoc|CPU_Obs, 0, 32, 0, 0, 2, {0x0F, 0xA7, 0}, 0, 2, + {OPT_RM|OPS_32|OPS_Relaxed|OPA_EA, OPT_Reg|OPS_32|OPA_Spare, 0} } +}; +static const x86_insn_info umov_insn[] = { + { CPU_386|CPU_Undoc, 0, 0, 0, 0, 2, {0x0F, 0x10, 0}, 0, 2, + {OPT_RM|OPS_8|OPS_Relaxed|OPA_EA, OPT_Reg|OPS_8|OPA_Spare, 0} }, + { CPU_386|CPU_Undoc, 0, 16, 0, 0, 2, {0x0F, 0x11, 0}, 0, 2, + {OPT_RM|OPS_16|OPS_Relaxed|OPA_EA, OPT_Reg|OPS_16|OPA_Spare, 0} }, + { CPU_386|CPU_Undoc, 0, 32, 0, 0, 2, {0x0F, 0x11, 0}, 0, 2, + {OPT_RM|OPS_32|OPS_Relaxed|OPA_EA, OPT_Reg|OPS_32|OPA_Spare, 0} }, + { CPU_386|CPU_Undoc, 0, 0, 0, 0, 2, {0x0F, 0x12, 0}, 0, 2, + {OPT_Reg|OPS_8|OPA_Spare, OPT_RM|OPS_8|OPS_Relaxed|OPA_EA, 0} }, + { CPU_386|CPU_Undoc, 0, 16, 0, 0, 2, {0x0F, 0x13, 0}, 0, 2, + {OPT_Reg|OPS_16|OPA_Spare, OPT_RM|OPS_16|OPS_Relaxed|OPA_EA, 0} }, + { CPU_386|CPU_Undoc, 0, 32, 0, 0, 2, {0x0F, 0x13, 0}, 0, 2, + {OPT_Reg|OPS_32|OPA_Spare, OPT_RM|OPS_32|OPS_Relaxed|OPA_EA, 0} } +}; +static const x86_insn_info xbts_insn[] = { + { CPU_386|CPU_Undoc|CPU_Obs, 0, 16, 0, 0, 2, {0x0F, 0xA6, 0}, 0, 2, + {OPT_Reg|OPS_16|OPA_Spare, OPT_Mem|OPS_16|OPS_Relaxed|OPA_EA, 0} }, + { CPU_386|CPU_Undoc|CPU_Obs, 0, 32, 0, 0, 2, {0x0F, 0xA6, 0}, 0, 2, + {OPT_Reg|OPS_32|OPA_Spare, OPT_Mem|OPS_32|OPS_Relaxed|OPA_EA, 0} } +}; -static int -x86_expr_contains_simd(const yasm_expr *e, int ymm) -{ - return yasm_expr__traverse_leaves_in_const(e, &ymm, - x86_expr_contains_simd_cb); -} static void x86_finalize_common(x86_common *common, const x86_insn_info *info, - unsigned int mode_bits) + uintptr_t mode_bits) { common->addrsize = 0; common->opersize = info->opersize; common->lockrep_pre = 0; - common->acqrel_pre = 0; common->mode_bits = (unsigned char)mode_bits; } @@ -402,158 +2292,106 @@ x86_finalize_opcode(x86_opcode *opcode, const x86_insn_info *info) opcode->opcode[2] = info->opcode[2]; } -/* Clear operands so they don't get destroyed after we've copied references. */ static void -x86_id_insn_clear_operands(x86_id_insn *id_insn) +x86_finalize_jmpfar(yasm_arch *arch, yasm_bytecode *bc, yasm_bytecode *prev_bc, + const uintptr_t data[4], int num_operands, + yasm_insn_operands *operands, int num_prefixes, + uintptr_t **prefixes, const x86_insn_info *info) { - yasm_insn_operand *op = yasm_insn_ops_first(&id_insn->insn); - while (op) { - op->type = YASM_INSN__OPERAND_REG; - op = yasm_insn_op_next(op); - } -} - -static void -x86_finalize_jmpfar(yasm_bytecode *bc, yasm_bytecode *prev_bc, - const x86_insn_info *info) -{ - x86_id_insn *id_insn = (x86_id_insn *)bc->contents; - unsigned char *mod_data = id_insn->mod_data; - unsigned int mode_bits = id_insn->mode_bits; x86_jmpfar *jmpfar; yasm_insn_operand *op; - unsigned int i; + /*@only@*/ yasm_expr *segment; jmpfar = yasm_xmalloc(sizeof(x86_jmpfar)); - x86_finalize_common(&jmpfar->common, info, mode_bits); + x86_finalize_common(&jmpfar->common, info, data[3]); x86_finalize_opcode(&jmpfar->opcode, info); - op = yasm_insn_ops_first(&id_insn->insn); + op = yasm_ops_first(operands); - if (op->type == YASM_INSN__OPERAND_IMM && op->seg) { - /* SEG:OFF */ - if (yasm_value_finalize_expr(&jmpfar->segment, op->seg, prev_bc, 16)) - yasm_error_set(YASM_ERROR_TOO_COMPLEX, - N_("jump target segment too complex")); - if (yasm_value_finalize_expr(&jmpfar->offset, op->data.val, prev_bc, - 0)) - yasm_error_set(YASM_ERROR_TOO_COMPLEX, - N_("jump target offset too complex")); + if (op->type == YASM_INSN__OPERAND_IMM && + yasm_expr_is_op(op->data.val, YASM_EXPR_SEGOFF)) { + /* SEG:OFF expression; split it. */ + segment = yasm_expr_extract_segoff(&op->data.val); + if (!segment) + yasm_internal_error(N_("didn't get SEG:OFF expression in jmpfar")); + if (yasm_value_finalize_expr(&jmpfar->segment, segment, prev_bc, 16)) + yasm_error_set(YASM_ERROR_TOO_COMPLEX, + N_("jump target segment too complex")); + if (yasm_value_finalize_expr(&jmpfar->offset, op->data.val, prev_bc, + 0)) + yasm_error_set(YASM_ERROR_TOO_COMPLEX, + N_("jump target offset too complex")); } else if (op->targetmod == X86_FAR) { - /* "FAR imm" target needs to become "seg imm:imm". */ - yasm_expr *e = yasm_expr_create_branch(YASM_EXPR_SEG, - yasm_expr_copy(op->data.val), - op->data.val->line); - if (yasm_value_finalize_expr(&jmpfar->offset, op->data.val, prev_bc, 0) - || yasm_value_finalize_expr(&jmpfar->segment, e, prev_bc, 16)) - yasm_error_set(YASM_ERROR_TOO_COMPLEX, - N_("jump target expression too complex")); - } else if (yasm_insn_op_next(op)) { - /* Two operand form (gas) */ - yasm_insn_operand *op2 = yasm_insn_op_next(op); - if (yasm_value_finalize_expr(&jmpfar->segment, op->data.val, prev_bc, - 16)) - yasm_error_set(YASM_ERROR_TOO_COMPLEX, - N_("jump target segment too complex")); - if (yasm_value_finalize_expr(&jmpfar->offset, op2->data.val, prev_bc, - 0)) - yasm_error_set(YASM_ERROR_TOO_COMPLEX, - N_("jump target offset too complex")); - if (op2->size == OPS_BITS) - jmpfar->common.opersize = (unsigned char)mode_bits; + /* "FAR imm" target needs to become "seg imm:imm". */ + if (yasm_value_finalize_expr(&jmpfar->offset, + yasm_expr_copy(op->data.val), prev_bc, 0) + || yasm_value_finalize_expr(&jmpfar->segment, op->data.val, + prev_bc, 16)) + yasm_error_set(YASM_ERROR_TOO_COMPLEX, + N_("jump target expression too complex")); + jmpfar->segment.seg_of = 1; } else - yasm_internal_error(N_("didn't get FAR expression in jmpfar")); - - /* Apply modifiers */ - for (i=0; imodifiers); i++) { - switch (info->modifiers[i]) { - case MOD_Gap: - break; - case MOD_Op0Add: - jmpfar->opcode.opcode[0] += mod_data[i]; - break; - case MOD_Op1Add: - jmpfar->opcode.opcode[1] += mod_data[i]; - break; - case MOD_Op2Add: - jmpfar->opcode.opcode[2] += mod_data[i]; - break; - case MOD_Op3Add: - jmpfar->opcode.opcode[3] += mod_data[i]; - break; - case MOD_Op1AddSp: - jmpfar->opcode.opcode[1] += mod_data[i]<<3; - break; - default: - break; - } - } + yasm_internal_error(N_("didn't get FAR expression in jmpfar")); yasm_x86__bc_apply_prefixes((x86_common *)jmpfar, NULL, - info->def_opersize_64, - id_insn->insn.num_prefixes, - id_insn->insn.prefixes); - - x86_id_insn_clear_operands(id_insn); + info->def_opersize_64, num_prefixes, + prefixes); /* Transform the bytecode */ yasm_x86__bc_transform_jmpfar(bc, jmpfar); } static void -x86_finalize_jmp(yasm_bytecode *bc, yasm_bytecode *prev_bc, - const x86_insn_info *jinfo) +x86_finalize_jmp(yasm_arch *arch, yasm_bytecode *bc, yasm_bytecode *prev_bc, + const uintptr_t data[4], int num_operands, + yasm_insn_operands *operands, int num_prefixes, + uintptr_t **prefixes, const x86_insn_info *jinfo) { - x86_id_insn *id_insn = (x86_id_insn *)bc->contents; x86_jmp *jmp; - int num_info = id_insn->num_info; - const x86_insn_info *info = id_insn->group; - unsigned char *mod_data = id_insn->mod_data; - unsigned int mode_bits = id_insn->mode_bits; - /*unsigned char suffix = id_insn->suffix;*/ + int num_info = (int)(data[1]&0xFF); + x86_insn_info *info = (x86_insn_info *)data[0]; + unsigned long mod_data = (unsigned long)(data[1] >> 8); + unsigned int mode_bits = (unsigned int)(data[3] & 0xFF); + /*unsigned char suffix = (unsigned char)((data[3]>>8) & 0xFF);*/ yasm_insn_operand *op; - static const unsigned char size_lookup[] = - {0, 8, 16, 32, 64, 80, 128, 0, 0}; /* 256 not needed */ - unsigned int i; + static const unsigned char size_lookup[] = {0, 8, 16, 32, 64, 80, 128, 0}; /* We know the target is in operand 0, but sanity check for Imm. */ - op = yasm_insn_ops_first(&id_insn->insn); + op = yasm_ops_first(operands); if (op->type != YASM_INSN__OPERAND_IMM) - yasm_internal_error(N_("invalid operand conversion")); + yasm_internal_error(N_("invalid operand conversion")); jmp = yasm_xmalloc(sizeof(x86_jmp)); x86_finalize_common(&jmp->common, jinfo, mode_bits); if (yasm_value_finalize_expr(&jmp->target, op->data.val, prev_bc, 0)) - yasm_error_set(YASM_ERROR_TOO_COMPLEX, - N_("jump target expression too complex")); + yasm_error_set(YASM_ERROR_TOO_COMPLEX, + N_("jump target expression too complex")); if (jmp->target.seg_of || jmp->target.rshift || jmp->target.curpos_rel) - yasm_error_set(YASM_ERROR_VALUE, N_("invalid jump target")); + yasm_error_set(YASM_ERROR_VALUE, N_("invalid jump target")); yasm_value_set_curpos_rel(&jmp->target, bc, 0); jmp->target.jump_target = 1; /* See if the user explicitly specified short/near/far. */ - switch (insn_operands[jinfo->operands_index+0].targetmod) { - case OPTM_Short: - jmp->op_sel = JMP_SHORT_FORCED; - break; - case OPTM_Near: - jmp->op_sel = JMP_NEAR_FORCED; - break; - default: - jmp->op_sel = JMP_NONE; + switch ((int)(jinfo->operands[0] & OPTM_MASK)) { + case OPTM_Short: + jmp->op_sel = JMP_SHORT_FORCED; + break; + case OPTM_Near: + jmp->op_sel = JMP_NEAR_FORCED; + break; + default: + jmp->op_sel = JMP_NONE; } /* Check for address size setting in second operand, if present */ if (jinfo->num_operands > 1 && - insn_operands[jinfo->operands_index+1].action == OPA_AdSizeR) - jmp->common.addrsize = (unsigned char) - size_lookup[insn_operands[jinfo->operands_index+1].size]; + (jinfo->operands[1] & OPA_MASK) == OPA_AdSizeR) + jmp->common.addrsize = (unsigned char) + size_lookup[(jinfo->operands[1] & OPS_MASK)>>OPS_SHIFT]; /* Check for address size override */ - for (i=0; imodifiers); i++) { - if (jinfo->modifiers[i] == MOD_AdSizeR) - jmp->common.addrsize = mod_data[i]; - } + if (jinfo->modifiers & MOD_AdSizeR) + jmp->common.addrsize = (unsigned char)(mod_data & 0xFF); /* Scan through other infos for this insn looking for short/near versions. * Needs to match opersize and number of operands, also be within CPU. @@ -561,449 +2399,423 @@ x86_finalize_jmp(yasm_bytecode *bc, yasm_bytecode *prev_bc, jmp->shortop.len = 0; jmp->nearop.len = 0; for (; num_info>0 && (jmp->shortop.len == 0 || jmp->nearop.len == 0); - num_info--, info++) { - /* Match CPU */ - if (mode_bits != 64 && (info->misc_flags & ONLY_64)) - continue; - if (mode_bits == 64 && (info->misc_flags & NOT_64)) - continue; + num_info--, info++) { + unsigned long cpu = info->cpu; - if (!BitVector_bit_test(id_insn->cpu_enabled, info->cpu0) || - !BitVector_bit_test(id_insn->cpu_enabled, info->cpu1) || - !BitVector_bit_test(id_insn->cpu_enabled, info->cpu2)) - continue; + if ((cpu & CPU_64) && mode_bits != 64) + continue; + if ((cpu & CPU_Not64) && mode_bits == 64) + continue; + cpu &= ~(CPU_64 | CPU_Not64); - if (info->num_operands == 0) - continue; + if ((data[2] & cpu) != cpu) + continue; - if (insn_operands[info->operands_index+0].action != OPA_JmpRel) - continue; + if (info->num_operands == 0) + continue; - if (info->opersize != jmp->common.opersize) - continue; + if ((info->operands[0] & OPA_MASK) != OPA_JmpRel) + continue; - switch (insn_operands[info->operands_index+0].targetmod) { - case OPTM_Short: - x86_finalize_opcode(&jmp->shortop, info); - for (i=0; imodifiers); i++) { - if (info->modifiers[i] == MOD_Op0Add) - jmp->shortop.opcode[0] += mod_data[i]; - } - break; - case OPTM_Near: - x86_finalize_opcode(&jmp->nearop, info); - for (i=0; imodifiers); i++) { - if (info->modifiers[i] == MOD_Op1Add) - jmp->nearop.opcode[1] += mod_data[i]; - } - break; - } + if (info->opersize != jmp->common.opersize) + continue; + + switch ((int)(info->operands[0] & OPTM_MASK)) { + case OPTM_Short: + x86_finalize_opcode(&jmp->shortop, info); + if (info->modifiers & MOD_Op0Add) + jmp->shortop.opcode[0] += (unsigned char)(mod_data & 0xFF); + break; + case OPTM_Near: + x86_finalize_opcode(&jmp->nearop, info); + if (info->modifiers & MOD_Op1Add) + jmp->nearop.opcode[1] += (unsigned char)(mod_data & 0xFF); + break; + } } - if ((jmp->op_sel == JMP_SHORT_FORCED) && (jmp->shortop.len == 0)) - yasm_error_set(YASM_ERROR_TYPE, - N_("no SHORT form of that jump instruction exists")); - if ((jmp->op_sel == JMP_NEAR_FORCED) && (jmp->nearop.len == 0)) - yasm_error_set(YASM_ERROR_TYPE, - N_("no NEAR form of that jump instruction exists")); + if ((jmp->op_sel == JMP_SHORT_FORCED) && (jmp->nearop.len == 0)) + yasm_error_set(YASM_ERROR_TYPE, + N_("no SHORT form of that jump instruction exists")); + if ((jmp->op_sel == JMP_NEAR_FORCED) && (jmp->shortop.len == 0)) + yasm_error_set(YASM_ERROR_TYPE, + N_("no NEAR form of that jump instruction exists")); if (jmp->op_sel == JMP_NONE) { - if (jmp->nearop.len == 0) - jmp->op_sel = JMP_SHORT_FORCED; - if (jmp->shortop.len == 0) - jmp->op_sel = JMP_NEAR_FORCED; + if (jmp->nearop.len == 0) + jmp->op_sel = JMP_SHORT_FORCED; + if (jmp->shortop.len == 0) + jmp->op_sel = JMP_NEAR_FORCED; } - yasm_x86__bc_apply_prefixes((x86_common *)jmp, NULL, - jinfo->def_opersize_64, - id_insn->insn.num_prefixes, - id_insn->insn.prefixes); - - x86_id_insn_clear_operands(id_insn); + yasm_x86__bc_apply_prefixes((x86_common *)jmp, NULL, info->def_opersize_64, + num_prefixes, prefixes); /* Transform the bytecode */ yasm_x86__bc_transform_jmp(bc, jmp); } static const x86_insn_info * -x86_find_match(x86_id_insn *id_insn, yasm_insn_operand **ops, - yasm_insn_operand **rev_ops, const unsigned int *size_lookup, - int bypass) +x86_find_match(yasm_arch *arch, int num_info, const x86_insn_info *info, + uintptr_t cpu, unsigned int mode_bits, unsigned int suffix, + int num_operands, yasm_insn_operand **ops, + yasm_insn_operand **rev_ops, const unsigned int *size_lookup, + int bypass) { - const x86_insn_info *info = id_insn->group; - unsigned int num_info = id_insn->num_info; - unsigned int suffix = id_insn->suffix; - unsigned int mode_bits = id_insn->mode_bits; + yasm_arch_x86 *arch_x86 = (yasm_arch_x86 *)arch; int found = 0; /* Just do a simple linear search through the info array for a match. * First match wins. */ for (; num_info>0 && !found; num_info--, info++) { - yasm_insn_operand *op, **use_ops; - const x86_info_operand *info_ops = - &insn_operands[info->operands_index]; - unsigned int gas_flags = info->gas_flags; - unsigned int misc_flags = info->misc_flags; - unsigned int size; - int mismatch = 0; - unsigned int i; + yasm_insn_operand *op, **use_ops; + unsigned long icpu; + unsigned int size; + int mismatch = 0; + int i; - /* Match CPU */ - if (mode_bits != 64 && (misc_flags & ONLY_64)) - continue; - if (mode_bits == 64 && (misc_flags & NOT_64)) - continue; + /* Match CPU */ + icpu = info->cpu; - if (bypass != 8 && - (!BitVector_bit_test(id_insn->cpu_enabled, info->cpu0) || - !BitVector_bit_test(id_insn->cpu_enabled, info->cpu1) || - !BitVector_bit_test(id_insn->cpu_enabled, info->cpu2))) - continue; + if ((icpu & CPU_64) && mode_bits != 64) + continue; + if ((icpu & CPU_Not64) && mode_bits == 64) + continue; + icpu &= ~(CPU_64 | CPU_Not64); - /* Match # of operands */ - if (id_insn->insn.num_operands != info->num_operands) - continue; + if (bypass != 7 && (cpu & icpu) != icpu) + continue; - /* Match AVX */ - if (!(id_insn->misc_flags & ONLY_AVX) && (misc_flags & ONLY_AVX)) - continue; - if ((id_insn->misc_flags & ONLY_AVX) && (misc_flags & NOT_AVX)) - continue; + /* Match # of operands */ + if (num_operands != info->num_operands) + continue; - /* Match parser mode */ - if ((gas_flags & GAS_ONLY) && id_insn->parser != X86_PARSER_GAS) - continue; - if ((gas_flags & GAS_ILLEGAL) && id_insn->parser == X86_PARSER_GAS) - continue; + /* Match parser mode */ + if ((info->modifiers & MOD_GasOnly) + && arch_x86->parser != X86_PARSER_GAS) + continue; + if ((info->modifiers & MOD_GasIllegal) + && arch_x86->parser == X86_PARSER_GAS) + continue; - /* Match suffix (if required) */ - if (id_insn->parser == X86_PARSER_GAS - && ((suffix & SUF_MASK) & (gas_flags & SUF_MASK)) == 0) - continue; + /* Match suffix (if required) */ + if (suffix != 0 && suffix != 0x80 + && ((suffix<modifiers) == 0) + continue; - /* Use reversed operands in GAS mode if not otherwise specified */ - use_ops = ops; - if (id_insn->parser == X86_PARSER_GAS && !(gas_flags & GAS_NO_REV)) - use_ops = rev_ops; + /* Use reversed operands in GAS mode if not otherwise specified */ + use_ops = ops; + if (arch_x86->parser == X86_PARSER_GAS + && !(info->modifiers & MOD_GasNoRev)) + use_ops = rev_ops; - if (id_insn->insn.num_operands == 0) { - found = 1; /* no operands -> must have a match here. */ - break; - } + if (num_operands == 0) { + found = 1; /* no operands -> must have a match here. */ + break; + } - /* Match each operand type and size */ - for (i = 0, op = use_ops[0]; op && inum_operands && !mismatch; - op = use_ops[++i]) { - /* Check operand type */ - switch (info_ops[i].type) { - case OPT_Imm: - if (op->type != YASM_INSN__OPERAND_IMM) - mismatch = 1; - break; - case OPT_RM: - if (op->type == YASM_INSN__OPERAND_MEMORY) - break; - /*@fallthrough@*/ - case OPT_Reg: - if (op->type != YASM_INSN__OPERAND_REG) - mismatch = 1; - else { - switch ((x86_expritem_reg_size)(op->data.reg&~0xFUL)) { - case X86_REG8: - case X86_REG8X: - case X86_REG16: - case X86_REG32: - case X86_REG64: - case X86_FPUREG: - break; - default: - mismatch = 1; - break; - } - } - break; - case OPT_Mem: - if (op->type != YASM_INSN__OPERAND_MEMORY) - mismatch = 1; - break; - case OPT_SIMDRM: - if (op->type == YASM_INSN__OPERAND_MEMORY) - break; - /*@fallthrough@*/ - case OPT_SIMDReg: - if (op->type != YASM_INSN__OPERAND_REG) - mismatch = 1; - else { - switch ((x86_expritem_reg_size)(op->data.reg&~0xFUL)) { - case X86_MMXREG: - case X86_XMMREG: - case X86_YMMREG: - break; - default: - mismatch = 1; - break; - } - } - break; - case OPT_SegReg: - if (op->type != YASM_INSN__OPERAND_SEGREG) - mismatch = 1; - break; - case OPT_CRReg: - if (op->type != YASM_INSN__OPERAND_REG || - (op->data.reg & ~0xFUL) != X86_CRREG) - mismatch = 1; - break; - case OPT_DRReg: - if (op->type != YASM_INSN__OPERAND_REG || - (op->data.reg & ~0xFUL) != X86_DRREG) - mismatch = 1; - break; - case OPT_TRReg: - if (op->type != YASM_INSN__OPERAND_REG || - (op->data.reg & ~0xFUL) != X86_TRREG) - mismatch = 1; - break; - case OPT_ST0: - if (op->type != YASM_INSN__OPERAND_REG || - op->data.reg != X86_FPUREG) - mismatch = 1; - break; - case OPT_Areg: - if (op->type != YASM_INSN__OPERAND_REG || - (info_ops[i].size == OPS_8 && - op->data.reg != (X86_REG8 | 0) && - op->data.reg != (X86_REG8X | 0)) || - (info_ops[i].size == OPS_16 && - op->data.reg != (X86_REG16 | 0)) || - (info_ops[i].size == OPS_32 && - op->data.reg != (X86_REG32 | 0)) || - (info_ops[i].size == OPS_64 && - op->data.reg != (X86_REG64 | 0))) - mismatch = 1; - break; - case OPT_Creg: - if (op->type != YASM_INSN__OPERAND_REG || - (info_ops[i].size == OPS_8 && - op->data.reg != (X86_REG8 | 1) && - op->data.reg != (X86_REG8X | 1)) || - (info_ops[i].size == OPS_16 && - op->data.reg != (X86_REG16 | 1)) || - (info_ops[i].size == OPS_32 && - op->data.reg != (X86_REG32 | 1)) || - (info_ops[i].size == OPS_64 && - op->data.reg != (X86_REG64 | 1))) - mismatch = 1; - break; - case OPT_Dreg: - if (op->type != YASM_INSN__OPERAND_REG || - (info_ops[i].size == OPS_8 && - op->data.reg != (X86_REG8 | 2) && - op->data.reg != (X86_REG8X | 2)) || - (info_ops[i].size == OPS_16 && - op->data.reg != (X86_REG16 | 2)) || - (info_ops[i].size == OPS_32 && - op->data.reg != (X86_REG32 | 2)) || - (info_ops[i].size == OPS_64 && - op->data.reg != (X86_REG64 | 2))) - mismatch = 1; - break; - case OPT_CS: - if (op->type != YASM_INSN__OPERAND_SEGREG || - (op->data.reg & 0xF) != 1) - mismatch = 1; - break; - case OPT_DS: - if (op->type != YASM_INSN__OPERAND_SEGREG || - (op->data.reg & 0xF) != 3) - mismatch = 1; - break; - case OPT_ES: - if (op->type != YASM_INSN__OPERAND_SEGREG || - (op->data.reg & 0xF) != 0) - mismatch = 1; - break; - case OPT_FS: - if (op->type != YASM_INSN__OPERAND_SEGREG || - (op->data.reg & 0xF) != 4) - mismatch = 1; - break; - case OPT_GS: - if (op->type != YASM_INSN__OPERAND_SEGREG || - (op->data.reg & 0xF) != 5) - mismatch = 1; - break; - case OPT_SS: - if (op->type != YASM_INSN__OPERAND_SEGREG || - (op->data.reg & 0xF) != 2) - mismatch = 1; - break; - case OPT_CR4: - if (op->type != YASM_INSN__OPERAND_REG || - op->data.reg != (X86_CRREG | 4)) - mismatch = 1; - break; - case OPT_MemOffs: - if (op->type != YASM_INSN__OPERAND_MEMORY || - yasm_expr__contains(op->data.ea->disp.abs, - YASM_EXPR_REG) || - op->data.ea->pc_rel || - (!op->data.ea->not_pc_rel && id_insn->default_rel && - op->data.ea->disp.size != 64)) - mismatch = 1; - break; - case OPT_Imm1: - if (op->type == YASM_INSN__OPERAND_IMM) { - const yasm_intnum *num; - num = yasm_expr_get_intnum(&op->data.val, 0); - if (!num || !yasm_intnum_is_pos1(num)) - mismatch = 1; - } else - mismatch = 1; - break; - case OPT_ImmNotSegOff: - if (op->type != YASM_INSN__OPERAND_IMM || - op->targetmod != 0 || op->seg) - mismatch = 1; - break; - case OPT_XMM0: - if (op->type != YASM_INSN__OPERAND_REG || - op->data.reg != X86_XMMREG) - mismatch = 1; - break; - case OPT_MemrAX: { - const uintptr_t *regp; - if (op->type != YASM_INSN__OPERAND_MEMORY || - !(regp = yasm_expr_get_reg(&op->data.ea->disp.abs, 0)) || - (*regp != (X86_REG16 | 0) && - *regp != (X86_REG32 | 0) && - *regp != (X86_REG64 | 0))) - mismatch = 1; - break; - } - case OPT_MemEAX: { - const uintptr_t *regp; - if (op->type != YASM_INSN__OPERAND_MEMORY || - !(regp = yasm_expr_get_reg(&op->data.ea->disp.abs, 0)) || - *regp != (X86_REG32 | 0)) - mismatch = 1; - break; - } - case OPT_MemXMMIndex: - if (op->type != YASM_INSN__OPERAND_MEMORY || - !x86_expr_contains_simd(op->data.ea->disp.abs, 0)) - mismatch = 1; - break; - case OPT_MemYMMIndex: - if (op->type != YASM_INSN__OPERAND_MEMORY || - !x86_expr_contains_simd(op->data.ea->disp.abs, 1)) - mismatch = 1; - break; - default: - yasm_internal_error(N_("invalid operand type")); - } + /* Match each operand type and size */ + for (i = 0, op = use_ops[0]; op && inum_operands && !mismatch; + op = use_ops[++i]) { + /* Check operand type */ + switch ((int)(info->operands[i] & OPT_MASK)) { + case OPT_Imm: + if (op->type != YASM_INSN__OPERAND_IMM) + mismatch = 1; + break; + case OPT_RM: + if (op->type == YASM_INSN__OPERAND_MEMORY) + break; + /*@fallthrough@*/ + case OPT_Reg: + if (op->type != YASM_INSN__OPERAND_REG) + mismatch = 1; + else { + switch ((x86_expritem_reg_size)(op->data.reg&~0xFUL)) { + case X86_REG8: + case X86_REG8X: + case X86_REG16: + case X86_REG32: + case X86_REG64: + case X86_FPUREG: + break; + default: + mismatch = 1; + break; + } + } + break; + case OPT_Mem: + if (op->type != YASM_INSN__OPERAND_MEMORY) + mismatch = 1; + break; + case OPT_SIMDRM: + if (op->type == YASM_INSN__OPERAND_MEMORY) + break; + /*@fallthrough@*/ + case OPT_SIMDReg: + if (op->type != YASM_INSN__OPERAND_REG) + mismatch = 1; + else { + switch ((x86_expritem_reg_size)(op->data.reg&~0xFUL)) { + case X86_MMXREG: + case X86_XMMREG: + break; + default: + mismatch = 1; + break; + } + } + break; + case OPT_SegReg: + if (op->type != YASM_INSN__OPERAND_SEGREG) + mismatch = 1; + break; + case OPT_CRReg: + if (op->type != YASM_INSN__OPERAND_REG || + (op->data.reg & ~0xFUL) != X86_CRREG) + mismatch = 1; + break; + case OPT_DRReg: + if (op->type != YASM_INSN__OPERAND_REG || + (op->data.reg & ~0xFUL) != X86_DRREG) + mismatch = 1; + break; + case OPT_TRReg: + if (op->type != YASM_INSN__OPERAND_REG || + (op->data.reg & ~0xFUL) != X86_TRREG) + mismatch = 1; + break; + case OPT_ST0: + if (op->type != YASM_INSN__OPERAND_REG || + op->data.reg != X86_FPUREG) + mismatch = 1; + break; + case OPT_Areg: + if (op->type != YASM_INSN__OPERAND_REG || + ((info->operands[i] & OPS_MASK) == OPS_8 && + op->data.reg != (X86_REG8 | 0) && + op->data.reg != (X86_REG8X | 0)) || + ((info->operands[i] & OPS_MASK) == OPS_16 && + op->data.reg != (X86_REG16 | 0)) || + ((info->operands[i] & OPS_MASK) == OPS_32 && + op->data.reg != (X86_REG32 | 0)) || + ((info->operands[i] & OPS_MASK) == OPS_64 && + op->data.reg != (X86_REG64 | 0))) + mismatch = 1; + break; + case OPT_Creg: + if (op->type != YASM_INSN__OPERAND_REG || + ((info->operands[i] & OPS_MASK) == OPS_8 && + op->data.reg != (X86_REG8 | 1) && + op->data.reg != (X86_REG8X | 1)) || + ((info->operands[i] & OPS_MASK) == OPS_16 && + op->data.reg != (X86_REG16 | 1)) || + ((info->operands[i] & OPS_MASK) == OPS_32 && + op->data.reg != (X86_REG32 | 1)) || + ((info->operands[i] & OPS_MASK) == OPS_64 && + op->data.reg != (X86_REG64 | 1))) + mismatch = 1; + break; + case OPT_Dreg: + if (op->type != YASM_INSN__OPERAND_REG || + ((info->operands[i] & OPS_MASK) == OPS_8 && + op->data.reg != (X86_REG8 | 2) && + op->data.reg != (X86_REG8X | 2)) || + ((info->operands[i] & OPS_MASK) == OPS_16 && + op->data.reg != (X86_REG16 | 2)) || + ((info->operands[i] & OPS_MASK) == OPS_32 && + op->data.reg != (X86_REG32 | 2)) || + ((info->operands[i] & OPS_MASK) == OPS_64 && + op->data.reg != (X86_REG64 | 2))) + mismatch = 1; + break; + case OPT_CS: + if (op->type != YASM_INSN__OPERAND_SEGREG || + (op->data.reg & 0xF) != 1) + mismatch = 1; + break; + case OPT_DS: + if (op->type != YASM_INSN__OPERAND_SEGREG || + (op->data.reg & 0xF) != 3) + mismatch = 1; + break; + case OPT_ES: + if (op->type != YASM_INSN__OPERAND_SEGREG || + (op->data.reg & 0xF) != 0) + mismatch = 1; + break; + case OPT_FS: + if (op->type != YASM_INSN__OPERAND_SEGREG || + (op->data.reg & 0xF) != 4) + mismatch = 1; + break; + case OPT_GS: + if (op->type != YASM_INSN__OPERAND_SEGREG || + (op->data.reg & 0xF) != 5) + mismatch = 1; + break; + case OPT_SS: + if (op->type != YASM_INSN__OPERAND_SEGREG || + (op->data.reg & 0xF) != 2) + mismatch = 1; + break; + case OPT_CR4: + if (op->type != YASM_INSN__OPERAND_REG || + op->data.reg != (X86_CRREG | 4)) + mismatch = 1; + break; + case OPT_MemOffs: + if (op->type != YASM_INSN__OPERAND_MEMORY || + yasm_expr__contains(yasm_ea_get_disp(op->data.ea), + YASM_EXPR_REG)) + mismatch = 1; + break; + case OPT_Imm1: + if (op->type == YASM_INSN__OPERAND_IMM) { + const yasm_intnum *num; + num = yasm_expr_get_intnum(&op->data.val, 0); + if (!num || !yasm_intnum_is_pos1(num)) + mismatch = 1; + } else + mismatch = 1; + break; + case OPT_ImmNotSegOff: + if (op->type != YASM_INSN__OPERAND_IMM || + op->targetmod != 0 || + yasm_expr_is_op(op->data.val, YASM_EXPR_SEGOFF)) + mismatch = 1; + break; + case OPT_XMM0: + if (op->type != YASM_INSN__OPERAND_REG || + op->data.reg != X86_XMMREG) + mismatch = 1; + break; + case OPT_MemrAX: { + const uintptr_t *regp; + if (op->type != YASM_INSN__OPERAND_MEMORY || + !(regp = yasm_expr_get_reg(&op->data.ea->disp.abs, 0)) || + (*regp != (X86_REG16 | 0) && + *regp != (X86_REG32 | 0) && + *regp != (X86_REG64 | 0))) + mismatch = 1; + break; + } + case OPT_MemEAX: { + const uintptr_t *regp; + if (op->type != YASM_INSN__OPERAND_MEMORY || + !(regp = yasm_expr_get_reg(&op->data.ea->disp.abs, 0)) || + *regp != (X86_REG32 | 0)) + mismatch = 1; + break; + } + default: + yasm_internal_error(N_("invalid operand type")); + } - if (mismatch) - break; + if (mismatch) + break; - /* Check operand size */ - size = size_lookup[info_ops[i].size]; - if (id_insn->parser == X86_PARSER_GAS) { - /* Require relaxed operands for GAS mode (don't allow - * per-operand sizing). - */ - if (op->type == YASM_INSN__OPERAND_REG && op->size == 0) { - /* Register size must exactly match */ - if (yasm_x86__get_reg_size(op->data.reg) != size) - mismatch = 1; - } else if ((info_ops[i].type == OPT_Imm - || info_ops[i].type == OPT_ImmNotSegOff - || info_ops[i].type == OPT_Imm1) - && !info_ops[i].relaxed - && info_ops[i].action != OPA_JmpRel) - mismatch = 1; - } else { - if (op->type == YASM_INSN__OPERAND_REG && op->size == 0) { - /* Register size must exactly match */ - if ((bypass == 4 && i == 0) || (bypass == 5 && i == 1) - || (bypass == 6 && i == 2)) - ; - else if (yasm_x86__get_reg_size(op->data.reg) != size) - mismatch = 1; - } else { - if ((bypass == 1 && i == 0) || (bypass == 2 && i == 1) - || (bypass == 3 && i == 2)) - ; - else if (info_ops[i].relaxed) { - /* Relaxed checking */ - if (size != 0 && op->size != size && op->size != 0) - mismatch = 1; - } else { - /* Strict checking */ - if (op->size != size) - mismatch = 1; - } - } - } + /* Check operand size */ + size = size_lookup[(info->operands[i] & OPS_MASK)>>OPS_SHIFT]; + if (suffix != 0) { + /* Require relaxed operands for GAS mode (don't allow + * per-operand sizing). + */ + if (op->type == YASM_INSN__OPERAND_REG && op->size == 0) { + /* Register size must exactly match */ + if (yasm_x86__get_reg_size(arch, op->data.reg) != size) + mismatch = 1; + } else if (((info->operands[i] & OPT_MASK) == OPT_Imm + || (info->operands[i] & OPT_MASK) == OPT_ImmNotSegOff + || (info->operands[i] & OPT_MASK) == OPT_Imm1) + && (info->operands[i] & OPS_RMASK) != OPS_Relaxed + && (info->operands[i] & OPA_MASK) != OPA_JmpRel) + mismatch = 1; + } else { + if (op->type == YASM_INSN__OPERAND_REG && op->size == 0) { + /* Register size must exactly match */ + if ((bypass == 4 && i == 0) || (bypass == 5 && i == 1) + || (bypass == 6 && i == 3)) + ; + else if (yasm_x86__get_reg_size(arch, + op->data.reg) != size) + mismatch = 1; + } else { + if ((bypass == 1 && i == 0) || (bypass == 2 && i == 1) + || (bypass == 3 && i == 3)) + ; + else if ((info->operands[i] & OPS_RMASK) == OPS_Relaxed) { + /* Relaxed checking */ + if (size != 0 && op->size != size && op->size != 0) + mismatch = 1; + } else { + /* Strict checking */ + if (op->size != size) + mismatch = 1; + } + } + } - if (mismatch) - break; + if (mismatch) + break; - /* Check for 64-bit effective address size in NASM mode */ - if (id_insn->parser != X86_PARSER_GAS && - op->type == YASM_INSN__OPERAND_MEMORY) { - if (info_ops[i].eas64) { - if (op->data.ea->disp.size != 64) - mismatch = 1; - } else if (op->data.ea->disp.size == 64) - mismatch = 1; - } + /* Check for 64-bit effective address size in NASM mode */ + if (suffix == 0 && op->type == YASM_INSN__OPERAND_MEMORY) { + if ((info->operands[i] & OPEAS_MASK) == OPEAS_64) { + if (op->data.ea->disp.size != 64) + mismatch = 1; + } else if (op->data.ea->disp.size == 64) + mismatch = 1; + } - if (mismatch) - break; + if (mismatch) + break; - /* Check target modifier */ - switch (info_ops[i].targetmod) { - case OPTM_None: - if (op->targetmod != 0) - mismatch = 1; - break; - case OPTM_Near: - if (op->targetmod != X86_NEAR) - mismatch = 1; - break; - case OPTM_Short: - if (op->targetmod != X86_SHORT) - mismatch = 1; - break; - case OPTM_Far: - if (op->targetmod != X86_FAR) - mismatch = 1; - break; - case OPTM_To: - if (op->targetmod != X86_TO) - mismatch = 1; - break; - default: - yasm_internal_error(N_("invalid target modifier type")); - } - } + /* Check target modifier */ + switch ((int)(info->operands[i] & OPTM_MASK)) { + case OPTM_None: + if (op->targetmod != 0) + mismatch = 1; + break; + case OPTM_Near: + if (op->targetmod != X86_NEAR) + mismatch = 1; + break; + case OPTM_Short: + if (op->targetmod != X86_SHORT) + mismatch = 1; + break; + case OPTM_Far: + if (op->targetmod != X86_FAR) + mismatch = 1; + break; + case OPTM_To: + if (op->targetmod != X86_TO) + mismatch = 1; + break; + default: + yasm_internal_error(N_("invalid target modifier type")); + } + } - if (!mismatch) { - found = 1; - break; - } + if (!mismatch) { + found = 1; + break; + } } if (!found) - return NULL; + return NULL; return info; } static void -x86_match_error(x86_id_insn *id_insn, yasm_insn_operand **ops, - yasm_insn_operand **rev_ops, const unsigned int *size_lookup) +x86_match_error(yasm_arch *arch, int num_info, const x86_insn_info *info, + uintptr_t cpu, unsigned int mode_bits, unsigned int suffix, + int num_operands, yasm_insn_operand **ops, + yasm_insn_operand **rev_ops, const unsigned int *size_lookup) { const x86_insn_info *i; int ni; @@ -1012,151 +2824,159 @@ x86_match_error(x86_id_insn *id_insn, yasm_insn_operand **ops, /* Check for matching # of operands */ found = 0; - for (ni=id_insn->num_info, i=id_insn->group; ni>0; ni--, i++) { - if (id_insn->insn.num_operands == i->num_operands) { - found = 1; - break; - } + for (ni=num_info, i=info; ni>0; ni--, i++) { + if (num_operands == i->num_operands) { + found = 1; + break; + } } if (!found) { - yasm_error_set(YASM_ERROR_TYPE, N_("invalid number of operands")); - return; + yasm_error_set(YASM_ERROR_TYPE, N_("invalid number of operands")); + return; } - for (bypass=1; bypass<9; bypass++) { - i = x86_find_match(id_insn, ops, rev_ops, size_lookup, bypass); - if (i) - break; + for (bypass=1; bypass<8; bypass++) { + i = x86_find_match(arch, num_info, info, cpu, mode_bits, suffix, + num_operands, ops, rev_ops, size_lookup, bypass); + if (i) + break; } switch (bypass) { - case 1: - case 4: - yasm_error_set(YASM_ERROR_TYPE, - N_("invalid size for operand %d"), 1); - break; - case 2: - case 5: - yasm_error_set(YASM_ERROR_TYPE, - N_("invalid size for operand %d"), 2); - break; - case 3: - case 6: - yasm_error_set(YASM_ERROR_TYPE, - N_("invalid size for operand %d"), 3); - break; - case 7: - yasm_error_set(YASM_ERROR_TYPE, - N_("one of source operand 1 or 3 must match dest operand")); - break; - case 8: - { - unsigned int cpu0 = i->cpu0, cpu1 = i->cpu1, cpu2 = i->cpu2; - yasm_error_set(YASM_ERROR_TYPE, - N_("requires CPU%s"), - cpu_find_reverse(cpu0, cpu1, cpu2)); - break; - } - default: - yasm_error_set(YASM_ERROR_TYPE, - N_("invalid combination of opcode and operands")); + case 1: + case 4: + yasm_error_set(YASM_ERROR_TYPE, + N_("invalid size for operand %d"), 1); + break; + case 2: + case 5: + yasm_error_set(YASM_ERROR_TYPE, + N_("invalid size for operand %d"), 2); + break; + case 3: + case 6: + yasm_error_set(YASM_ERROR_TYPE, + N_("invalid size for operand %d"), 3); + break; + case 7: + yasm_error_set(YASM_ERROR_TYPE, + N_("requires CPU%s"), + cpu_find_reverse(i->cpu & ~(CPU_64 | CPU_Not64))); + break; + default: + yasm_error_set(YASM_ERROR_TYPE, + N_("invalid combination of opcode and operands")); } } -static void -x86_id_insn_finalize(yasm_bytecode *bc, yasm_bytecode *prev_bc) +void +yasm_x86__finalize_insn(yasm_arch *arch, yasm_bytecode *bc, + yasm_bytecode *prev_bc, const uintptr_t data[4], + int num_operands, + /*@null@*/ yasm_insn_operands *operands, + int num_prefixes, uintptr_t **prefixes, + int num_segregs, const uintptr_t *segregs) { - x86_id_insn *id_insn = (x86_id_insn *)bc->contents; + yasm_arch_x86 *arch_x86 = (yasm_arch_x86 *)arch; x86_insn *insn; - const x86_insn_info *info = id_insn->group; - unsigned int mode_bits = id_insn->mode_bits; - unsigned char *mod_data = id_insn->mod_data; - yasm_insn_operand *op, *ops[5], *rev_ops[5]; + int num_info = (int)(data[1]&0xFF); + const x86_insn_info *info = (const x86_insn_info *)data[0]; + unsigned long mod_data = (unsigned long)(data[1] >> 8); + unsigned int mode_bits = (unsigned int)(data[3] & 0xFF); + unsigned int suffix = (unsigned int)((data[3]>>8) & 0xFF); + yasm_insn_operand *op, *ops[4], *rev_ops[4]; /*@null@*/ yasm_expr *imm; unsigned char im_len; unsigned char im_sign; unsigned char spare; - unsigned char vexdata, vexreg; - unsigned int i; - unsigned int size_lookup[] = {0, 8, 16, 32, 64, 80, 128, 256, 0}; + int i; + unsigned int size_lookup[] = {0, 8, 16, 32, 64, 80, 128, 0}; unsigned long do_postop = 0; - size_lookup[OPS_BITS] = mode_bits; + size_lookup[7] = mode_bits; - yasm_insn_finalize(&id_insn->insn); + if (!info) { + num_info = 1; + info = empty_insn; + } /* Build local array of operands from list, since we know we have a max - * of 5 operands. + * of 3 operands. */ - if (id_insn->insn.num_operands > 5) { - yasm_error_set(YASM_ERROR_TYPE, N_("too many operands")); - return; + if (num_operands > 3) { + yasm_error_set(YASM_ERROR_TYPE, N_("too many operands")); + return; } - ops[0] = ops[1] = ops[2] = ops[3] = ops[4] = NULL; - for (i = 0, op = yasm_insn_ops_first(&id_insn->insn); - op && i < id_insn->insn.num_operands; - op = yasm_insn_op_next(op), i++) - ops[i] = op; + ops[0] = ops[1] = ops[2] = ops[3] = NULL; + for (i = 0, op = yasm_ops_first(operands); op && i < num_operands; + op = yasm_operand_next(op), i++) + ops[i] = op; /* If we're running in GAS mode, build a reverse array of the operands * as most GAS instructions have reversed operands from Intel style. */ - if (id_insn->parser == X86_PARSER_GAS) { - rev_ops[0] = rev_ops[1] = rev_ops[2] = rev_ops[3] = rev_ops[4] = NULL; - for (i = id_insn->insn.num_operands-1, - op = yasm_insn_ops_first(&id_insn->insn); - op; op = yasm_insn_op_next(op), i--) - rev_ops[i] = op; + if (arch_x86->parser == X86_PARSER_GAS) { + rev_ops[0] = rev_ops[1] = rev_ops[2] = rev_ops[3] = NULL; + for (i = num_operands-1, op = yasm_ops_first(operands); op && i >= 0; + op = yasm_operand_next(op), i--) + rev_ops[i] = op; } /* If we're running in GAS mode, look at the first insn_info to see * if this is a relative jump (OPA_JmpRel). If so, run through the * operands and adjust for dereferences / lack thereof. */ - if (id_insn->parser == X86_PARSER_GAS - && insn_operands[info->operands_index+0].action == OPA_JmpRel) { - for (i = 0, op = ops[0]; op; op = ops[++i]) { - if (!op->deref && (op->type == YASM_INSN__OPERAND_REG - || (op->type == YASM_INSN__OPERAND_MEMORY - && op->data.ea->strong))) - yasm_warn_set(YASM_WARN_GENERAL, - N_("indirect call without `*'")); - if (!op->deref && op->type == YASM_INSN__OPERAND_MEMORY - && !op->data.ea->strong) { - /* Memory that is not dereferenced, and not strong, is - * actually an immediate for the purposes of relative jumps. - */ - if (op->data.ea->segreg != 0) - yasm_warn_set(YASM_WARN_GENERAL, - N_("skipping prefixes on this instruction")); - imm = op->data.ea->disp.abs; - op->data.ea->disp.abs = NULL; - yasm_x86__ea_destroy(op->data.ea); - op->type = YASM_INSN__OPERAND_IMM; - op->data.val = imm; - } - } + if (arch_x86->parser == X86_PARSER_GAS + && (info->operands[0] & OPA_MASK) == OPA_JmpRel) { + for (i = 0, op = ops[0]; op; op = ops[++i]) { + if (!op->deref && (op->type == YASM_INSN__OPERAND_REG + || (op->type == YASM_INSN__OPERAND_MEMORY + && op->data.ea->strong))) + yasm_warn_set(YASM_WARN_GENERAL, + N_("indirect call without `*'")); + if (!op->deref && op->type == YASM_INSN__OPERAND_MEMORY + && !op->data.ea->strong) { + /* Memory that is not dereferenced, and not strong, is + * actually an immediate for the purposes of relative jumps. + */ + if (op->data.ea->segreg != 0) + yasm_warn_set(YASM_WARN_GENERAL, + N_("skipping prefixes on this instruction")); + imm = op->data.ea->disp.abs; + op->data.ea->disp.abs = NULL; + yasm_ea_destroy(op->data.ea); + op->type = YASM_INSN__OPERAND_IMM; + op->data.val = imm; + } + } } - info = x86_find_match(id_insn, ops, rev_ops, size_lookup, 0); + info = x86_find_match(arch, num_info, info, data[2], mode_bits, suffix, + num_operands, ops, rev_ops, size_lookup, 0); if (!info) { - /* Didn't find a match */ - x86_match_error(id_insn, ops, rev_ops, size_lookup); - return; + /* Didn't find a match */ + info = (const x86_insn_info *)data[0]; + if (!info) + info = empty_insn; + x86_match_error(arch, num_info, info, data[2], mode_bits, suffix, + num_operands, ops, rev_ops, size_lookup); + return; } - if (id_insn->insn.num_operands > 0) { - switch (insn_operands[info->operands_index+0].action) { - case OPA_JmpRel: - /* Shortcut to JmpRel */ - x86_finalize_jmp(bc, prev_bc, info); - return; - case OPA_JmpFar: - /* Shortcut to JmpFar */ - x86_finalize_jmpfar(bc, prev_bc, info); - return; - } + if (operands) { + switch (info->operands[0] & OPA_MASK) { + case OPA_JmpRel: + /* Shortcut to JmpRel */ + x86_finalize_jmp(arch, bc, prev_bc, data, num_operands, + operands, num_prefixes, prefixes, info); + return; + case OPA_JmpFar: + /* Shortcut to JmpFar */ + x86_finalize_jmpfar(arch, bc, prev_bc, data, num_operands, + operands, num_prefixes, prefixes, info); + return; + } } /* Copy what we can from info */ @@ -1168,510 +2988,316 @@ x86_id_insn_finalize(yasm_bytecode *bc, yasm_bytecode *prev_bc) insn->def_opersize_64 = info->def_opersize_64; insn->special_prefix = info->special_prefix; spare = info->spare; - vexdata = 0; - vexreg = 0; im_len = 0; im_sign = 0; insn->postop = X86_POSTOP_NONE; insn->rex = 0; - /* Move VEX/XOP data (stored in special prefix) to separate location to - * allow overriding of special prefix by modifiers. - */ - if ((insn->special_prefix & 0xF0) == 0xC0 || - (insn->special_prefix & 0xF0) == 0x80) { - vexdata = insn->special_prefix; - insn->special_prefix = 0; - } - /* Apply modifiers */ - for (i=0; imodifiers); i++) { - switch (info->modifiers[i]) { - case MOD_Gap: - break; - case MOD_PreAdd: - insn->special_prefix += mod_data[i]; - break; - case MOD_Op0Add: - insn->opcode.opcode[0] += mod_data[i]; - break; - case MOD_Op1Add: - insn->opcode.opcode[1] += mod_data[i]; - break; - case MOD_Op2Add: - insn->opcode.opcode[2] += mod_data[i]; - break; - case MOD_Op3Add: - insn->opcode.opcode[3] += mod_data[i]; - break; - case MOD_SpAdd: - spare += mod_data[i]; - break; - case MOD_OpSizeR: - insn->common.opersize = mod_data[i]; - break; - case MOD_Imm8: - imm = yasm_expr_create_ident(yasm_expr_int( - yasm_intnum_create_uint(mod_data[i])), bc->line); - im_len = 8; - break; - case MOD_DOpS64R: - insn->def_opersize_64 = mod_data[i]; - break; - case MOD_Op1AddSp: - insn->opcode.opcode[1] += mod_data[i]<<3; - break; - case MOD_SetVEX: - vexdata = mod_data[i]; - break; - default: - break; - } + if (info->modifiers & MOD_Gap0) + mod_data >>= 8; + if (info->modifiers & MOD_Op2Add) { + insn->opcode.opcode[2] += (unsigned char)(mod_data & 0xFF); + mod_data >>= 8; + } + if (info->modifiers & MOD_Gap1) + mod_data >>= 8; + if (info->modifiers & MOD_Op1Add) { + insn->opcode.opcode[1] += (unsigned char)(mod_data & 0xFF); + mod_data >>= 8; + } + if (info->modifiers & MOD_Gap2) + mod_data >>= 8; + if (info->modifiers & MOD_Op0Add) { + insn->opcode.opcode[0] += (unsigned char)(mod_data & 0xFF); + mod_data >>= 8; + } + if (info->modifiers & MOD_PreAdd) { + insn->special_prefix += (unsigned char)(mod_data & 0xFF); + mod_data >>= 8; + } + if (info->modifiers & MOD_SpAdd) { + spare += (unsigned char)(mod_data & 0xFF); + mod_data >>= 8; + } + if (info->modifiers & MOD_OpSizeR) { + insn->common.opersize = (unsigned char)(mod_data & 0xFF); + mod_data >>= 8; + } + if (info->modifiers & MOD_Imm8) { + imm = yasm_expr_create_ident(yasm_expr_int( + yasm_intnum_create_uint(mod_data & 0xFF)), bc->line); + im_len = 8; + mod_data >>= 8; + } + if (info->modifiers & MOD_DOpS64R) { + insn->def_opersize_64 = (unsigned char)(mod_data & 0xFF); + mod_data >>= 8; + } + if (info->modifiers & MOD_Op1AddSp) { + insn->opcode.opcode[1] += (unsigned char)(mod_data & 0xFF)<<3; + /*mod_data >>= 8;*/ } - /* In 64-bit mode, if opersize is 64 and default is not 64, - * force REX byte. - */ + /* In 64-bit mode, if opersize is 64 and default is not 64, force REX byte */ if (mode_bits == 64 && insn->common.opersize == 64 && insn->def_opersize_64 != 64) insn->rex = 0x48; /* Go through operands and assign */ - if (id_insn->insn.num_operands > 0) { - yasm_insn_operand **use_ops = ops; - const x86_info_operand *info_ops = - &insn_operands[info->operands_index]; + if (operands) { + yasm_insn_operand **use_ops = ops; - /* Use reversed operands in GAS mode if not otherwise specified */ - if (id_insn->parser == X86_PARSER_GAS - && !(info->gas_flags & GAS_NO_REV)) - use_ops = rev_ops; + /* Use reversed operands in GAS mode if not otherwise specified */ + if (arch_x86->parser == X86_PARSER_GAS + && !(info->modifiers & MOD_GasNoRev)) + use_ops = rev_ops; - for (i = 0, op = use_ops[0]; op && inum_operands; - op = use_ops[++i]) { - switch (info_ops[i].action) { - case OPA_None: - /* Throw away the operand contents */ - switch (op->type) { - case YASM_INSN__OPERAND_REG: - case YASM_INSN__OPERAND_SEGREG: - break; - case YASM_INSN__OPERAND_MEMORY: - yasm_x86__ea_destroy(op->data.ea); - break; - case YASM_INSN__OPERAND_IMM: - yasm_expr_destroy(op->data.val); - break; - } - break; - case OPA_EA: - switch (op->type) { - case YASM_INSN__OPERAND_REG: - insn->x86_ea = - yasm_x86__ea_create_reg(insn->x86_ea, - (unsigned long)op->data.reg, &insn->rex, - mode_bits); - break; - case YASM_INSN__OPERAND_SEGREG: - yasm_internal_error( - N_("invalid operand conversion")); - case YASM_INSN__OPERAND_MEMORY: - if (op->seg) - yasm_error_set(YASM_ERROR_VALUE, - N_("invalid segment in effective address")); - insn->x86_ea = (x86_effaddr *)op->data.ea; - if (info_ops[i].type == OPT_MemOffs) - /* Special-case for MOV MemOffs instruction */ - yasm_x86__ea_set_disponly(insn->x86_ea); - else if (info_ops[i].type == OPT_MemXMMIndex) { - /* Remember VSIB mode */ - insn->x86_ea->vsib_mode = 1; - insn->x86_ea->need_sib = 1; - } else if (info_ops[i].type == OPT_MemYMMIndex) { - /* Remember VSIB mode */ - insn->x86_ea->vsib_mode = 2; - insn->x86_ea->need_sib = 1; - } else if (id_insn->default_rel && - !op->data.ea->not_pc_rel && - op->data.ea->segreg != 0x6404 && - op->data.ea->segreg != 0x6505 && - !yasm_expr__contains( - op->data.ea->disp.abs, YASM_EXPR_REG)) - /* Enable default PC-rel if no regs and segreg - * is not FS or GS. - */ - insn->x86_ea->ea.pc_rel = 1; - break; - case YASM_INSN__OPERAND_IMM: - insn->x86_ea = - yasm_x86__ea_create_imm(insn->x86_ea, - op->data.val, - size_lookup[info_ops[i].size]); - break; - } - break; - case OPA_EAVEX: - if (op->type != YASM_INSN__OPERAND_REG) - yasm_internal_error(N_("invalid operand conversion")); - insn->x86_ea = - yasm_x86__ea_create_reg(insn->x86_ea, - (unsigned long)op->data.reg, &insn->rex, mode_bits); - vexreg = op->data.reg & 0xF; - break; - case OPA_Imm: - if (op->seg) - yasm_error_set(YASM_ERROR_VALUE, - N_("immediate does not support segment")); - if (op->type == YASM_INSN__OPERAND_IMM) { - imm = op->data.val; - im_len = size_lookup[info_ops[i].size]; - } else - yasm_internal_error(N_("invalid operand conversion")); - break; - case OPA_SImm: - if (op->seg) - yasm_error_set(YASM_ERROR_VALUE, - N_("immediate does not support segment")); - if (op->type == YASM_INSN__OPERAND_IMM) { - imm = op->data.val; - im_len = size_lookup[info_ops[i].size]; - im_sign = 1; - } else - yasm_internal_error(N_("invalid operand conversion")); - break; - case OPA_Spare: - if (op->type == YASM_INSN__OPERAND_SEGREG) - spare = (unsigned char)(op->data.reg&7); - else if (op->type == YASM_INSN__OPERAND_REG) { - if (yasm_x86__set_rex_from_reg(&insn->rex, &spare, - op->data.reg, mode_bits, X86_REX_R)) - return; - } else - yasm_internal_error(N_("invalid operand conversion")); - break; - case OPA_SpareVEX: - if (op->type != YASM_INSN__OPERAND_REG) - yasm_internal_error(N_("invalid operand conversion")); - if (yasm_x86__set_rex_from_reg(&insn->rex, &spare, - op->data.reg, mode_bits, X86_REX_R)) - return; - vexreg = op->data.reg & 0xF; - break; - case OPA_Op0Add: - if (op->type == YASM_INSN__OPERAND_REG) { - unsigned char opadd; - if (yasm_x86__set_rex_from_reg(&insn->rex, &opadd, - op->data.reg, mode_bits, X86_REX_B)) - return; - insn->opcode.opcode[0] += opadd; - } else - yasm_internal_error(N_("invalid operand conversion")); - break; - case OPA_Op1Add: - if (op->type == YASM_INSN__OPERAND_REG) { - unsigned char opadd; - if (yasm_x86__set_rex_from_reg(&insn->rex, &opadd, - op->data.reg, mode_bits, X86_REX_B)) - return; - insn->opcode.opcode[1] += opadd; - } else - yasm_internal_error(N_("invalid operand conversion")); - break; - case OPA_SpareEA: - if (op->type == YASM_INSN__OPERAND_REG) { - insn->x86_ea = - yasm_x86__ea_create_reg(insn->x86_ea, - (unsigned long)op->data.reg, &insn->rex, - mode_bits); - if (!insn->x86_ea || - yasm_x86__set_rex_from_reg(&insn->rex, &spare, - op->data.reg, mode_bits, X86_REX_R)) { - if (insn->x86_ea) - yasm_xfree(insn->x86_ea); - yasm_xfree(insn); - return; - } - } else - yasm_internal_error(N_("invalid operand conversion")); - break; - case OPA_AdSizeEA: { - const uintptr_t *regp = NULL; - /* Only implement this for OPT_MemrAX and OPT_MemEAX - * for now. - */ - if (op->type != YASM_INSN__OPERAND_MEMORY || - !(regp = yasm_expr_get_reg(&op->data.ea->disp.abs, 0))) - yasm_internal_error(N_("invalid operand conversion")); - /* 64-bit mode does not allow 16-bit addresses */ - if (mode_bits == 64 && *regp == (X86_REG16 | 0)) - yasm_error_set(YASM_ERROR_TYPE, - N_("16-bit addresses not supported in 64-bit mode")); - else if (*regp == (X86_REG16 | 0)) - insn->common.addrsize = 16; - else if (*regp == (X86_REG32 | 0)) - insn->common.addrsize = 32; - else if (mode_bits == 64 && *regp == (X86_REG64 | 0)) - insn->common.addrsize = 64; - else - yasm_error_set(YASM_ERROR_TYPE, - N_("unsupported address size")); - yasm_x86__ea_destroy(op->data.ea); - break; - } - case OPA_VEX: - if (op->type != YASM_INSN__OPERAND_REG) - yasm_internal_error(N_("invalid operand conversion")); - vexreg = op->data.reg & 0xF; - break; - case OPA_VEXImmSrc: - if (op->type != YASM_INSN__OPERAND_REG) - yasm_internal_error(N_("invalid operand conversion")); + for (i = 0, op = use_ops[0]; op && inum_operands; + op = use_ops[++i]) { + switch ((int)(info->operands[i] & OPA_MASK)) { + case OPA_None: + /* Throw away the operand contents */ + switch (op->type) { + case YASM_INSN__OPERAND_REG: + case YASM_INSN__OPERAND_SEGREG: + break; + case YASM_INSN__OPERAND_MEMORY: + yasm_ea_destroy(op->data.ea); + break; + case YASM_INSN__OPERAND_IMM: + yasm_expr_destroy(op->data.val); + break; + } + break; + case OPA_EA: + switch (op->type) { + case YASM_INSN__OPERAND_REG: + insn->x86_ea = yasm_x86__ea_create_reg( + (unsigned long)op->data.reg, &insn->rex, + mode_bits); + break; + case YASM_INSN__OPERAND_SEGREG: + yasm_internal_error( + N_("invalid operand conversion")); + case YASM_INSN__OPERAND_MEMORY: + insn->x86_ea = (x86_effaddr *)op->data.ea; + if ((info->operands[i] & OPT_MASK) == OPT_MemOffs) + /* Special-case for MOV MemOffs instruction */ + yasm_x86__ea_set_disponly(insn->x86_ea); + break; + case YASM_INSN__OPERAND_IMM: + insn->x86_ea = + yasm_x86__ea_create_imm(op->data.val, + size_lookup[(info->operands[i] & + OPS_MASK)>>OPS_SHIFT]); + break; + } + break; + case OPA_Imm: + if (op->type == YASM_INSN__OPERAND_IMM) { + imm = op->data.val; + im_len = size_lookup[(info->operands[i] & + OPS_MASK)>>OPS_SHIFT]; + } else + yasm_internal_error(N_("invalid operand conversion")); + break; + case OPA_SImm: + if (op->type == YASM_INSN__OPERAND_IMM) { + imm = op->data.val; + im_len = size_lookup[(info->operands[i] & + OPS_MASK)>>OPS_SHIFT]; + im_sign = 1; + } else + yasm_internal_error(N_("invalid operand conversion")); + break; + case OPA_Spare: + if (op->type == YASM_INSN__OPERAND_SEGREG) + spare = (unsigned char)(op->data.reg&7); + else if (op->type == YASM_INSN__OPERAND_REG) { + if (yasm_x86__set_rex_from_reg(&insn->rex, &spare, + op->data.reg, mode_bits, X86_REX_R)) + return; + } else + yasm_internal_error(N_("invalid operand conversion")); + break; + case OPA_Op0Add: + if (op->type == YASM_INSN__OPERAND_REG) { + unsigned char opadd; + if (yasm_x86__set_rex_from_reg(&insn->rex, &opadd, + op->data.reg, mode_bits, X86_REX_B)) + return; + insn->opcode.opcode[0] += opadd; + } else + yasm_internal_error(N_("invalid operand conversion")); + break; + case OPA_Op1Add: + if (op->type == YASM_INSN__OPERAND_REG) { + unsigned char opadd; + if (yasm_x86__set_rex_from_reg(&insn->rex, &opadd, + op->data.reg, mode_bits, X86_REX_B)) + return; + insn->opcode.opcode[1] += opadd; + } else + yasm_internal_error(N_("invalid operand conversion")); + break; + case OPA_SpareEA: + if (op->type == YASM_INSN__OPERAND_REG) { + insn->x86_ea = + yasm_x86__ea_create_reg((unsigned long)op->data.reg, + &insn->rex, mode_bits); + if (!insn->x86_ea || + yasm_x86__set_rex_from_reg(&insn->rex, &spare, + op->data.reg, mode_bits, X86_REX_R)) { + if (insn->x86_ea) + yasm_xfree(insn->x86_ea); + yasm_xfree(insn); + return; + } + } else + yasm_internal_error(N_("invalid operand conversion")); + break; + case OPA_AdSizeEA: { + const uintptr_t *regp = NULL; + /* Only implement this for OPT_MemrAX and OPT_MemEAX + * for now. + */ + if (op->type != YASM_INSN__OPERAND_MEMORY || + !(regp = yasm_expr_get_reg(&op->data.ea->disp.abs, 0))) + yasm_internal_error(N_("invalid operand conversion")); + /* 64-bit mode does not allow 16-bit addresses */ + if (mode_bits == 64 && *regp == (X86_REG16 | 0)) + yasm_error_set(YASM_ERROR_TYPE, + N_("16-bit addresses not supported in 64-bit mode")); + else if (*regp == (X86_REG16 | 0)) + insn->common.addrsize = 16; + else if (*regp == (X86_REG32 | 0)) + insn->common.addrsize = 32; + else if (mode_bits == 64 && *regp == (X86_REG64 | 0)) + insn->common.addrsize = 64; + else + yasm_error_set(YASM_ERROR_TYPE, + N_("unsupported address size")); + yasm_ea_destroy(op->data.ea); + break; + } + default: + yasm_internal_error(N_("unknown operand action")); + } - if (!imm) { - imm = yasm_expr_create_ident( - yasm_expr_int( - yasm_intnum_create_uint((op->data.reg << 4) - & 0xF0)), - bc->line); - } else { - imm = yasm_expr_create( - YASM_EXPR_OR, - yasm_expr_expr(yasm_expr_create( - YASM_EXPR_AND, - yasm_expr_expr(imm), - yasm_expr_int(yasm_intnum_create_uint(0x0F)), - bc->line)), - yasm_expr_int( - yasm_intnum_create_uint((op->data.reg << 4) - & 0xF0)), - bc->line); - } - im_len = 8; - break; - case OPA_VEXImm: - if (op->type != YASM_INSN__OPERAND_IMM) - yasm_internal_error(N_("invalid operand conversion")); + if ((info->operands[i] & OPS_MASK) == OPS_BITS) + insn->common.opersize = (unsigned char)mode_bits; - if (!imm) - imm = op->data.val; - else { - imm = yasm_expr_create( - YASM_EXPR_OR, - yasm_expr_expr(yasm_expr_create( - YASM_EXPR_AND, - yasm_expr_expr(op->data.val), - yasm_expr_int(yasm_intnum_create_uint(0x0F)), - bc->line)), - yasm_expr_expr(yasm_expr_create( - YASM_EXPR_AND, - yasm_expr_expr(imm), - yasm_expr_int(yasm_intnum_create_uint(0xF0)), - bc->line)), - bc->line); - } - im_len = 8; - break; - default: - yasm_internal_error(N_("unknown operand action")); - } - - if (info_ops[i].size == OPS_BITS) - insn->common.opersize = (unsigned char)mode_bits; - - switch (info_ops[i].post_action) { - case OPAP_None: - break; - case OPAP_SImm8: - /* Check operand strictness; if strict and non-8-bit, - * pre-emptively expand to full size. - * For unspecified size case, still optimize. - */ - if (!(id_insn->force_strict || op->strict) - || op->size == 0) - insn->postop = X86_POSTOP_SIGNEXT_IMM8; - else if (op->size != 8) { - insn->opcode.opcode[0] = - insn->opcode.opcode[insn->opcode.len]; - insn->opcode.len = 1; - } - break; - case OPAP_ShortMov: - do_postop = OPAP_ShortMov; - break; - case OPAP_A16: - insn->postop = X86_POSTOP_ADDRESS16; - break; - case OPAP_SImm32Avail: - do_postop = OPAP_SImm32Avail; - break; - default: - yasm_internal_error( - N_("unknown operand postponed action")); - } - } + switch ((int)(info->operands[i] & OPAP_MASK)) { + case OPAP_None: + break; + case OPAP_SImm8: + /* Check operand strictness; if strict and non-8-bit, + * pre-emptively expand to full size. + * For unspecified size case, still optimize. + */ + if (!(arch_x86->force_strict || op->strict) + || op->size == 0) + insn->postop = X86_POSTOP_SIGNEXT_IMM8; + else if (op->size != 8) { + insn->opcode.opcode[0] = + insn->opcode.opcode[insn->opcode.len]; + insn->opcode.len = 1; + } + break; + case OPAP_ShortMov: + do_postop = OPAP_ShortMov; + break; + case OPAP_A16: + insn->postop = X86_POSTOP_ADDRESS16; + break; + case OPAP_SImm32Avail: + do_postop = OPAP_SImm32Avail; + break; + default: + yasm_internal_error( + N_("unknown operand postponed action")); + } + } } if (insn->x86_ea) { - yasm_x86__ea_init(insn->x86_ea, spare, prev_bc); - for (i=0; iinsn.num_segregs; i++) - yasm_ea_set_segreg(&insn->x86_ea->ea, id_insn->insn.segregs[i]); - } else if (id_insn->insn.num_segregs > 0 && insn->special_prefix == 0) { - if (id_insn->insn.num_segregs > 1) - yasm_warn_set(YASM_WARN_GENERAL, - N_("multiple segment overrides, using leftmost")); - insn->special_prefix = (unsigned char) - (id_insn->insn.segregs[id_insn->insn.num_segregs-1]>>8); - } else if (id_insn->insn.num_segregs > 0) - yasm_internal_error(N_("unhandled segment prefix")); + yasm_x86__ea_init(insn->x86_ea, spare, prev_bc); + for (i=0; ix86_ea->ea, segregs[i]); + } else if (num_segregs > 0 && insn->special_prefix == 0) { + if (num_segregs > 1) + yasm_warn_set(YASM_WARN_GENERAL, + N_("multiple segment overrides, using leftmost")); + insn->special_prefix = (unsigned char)(segregs[num_segregs-1]>>8); + } else if (num_segregs > 0) + yasm_internal_error(N_("unhandled segment prefix")); if (imm) { - insn->imm = yasm_xmalloc(sizeof(yasm_value)); - if (yasm_value_finalize_expr(insn->imm, imm, prev_bc, im_len)) - yasm_error_set(YASM_ERROR_TOO_COMPLEX, - N_("immediate expression too complex")); - insn->imm->sign = im_sign; + insn->imm = yasm_xmalloc(sizeof(yasm_value)); + if (yasm_value_finalize_expr(insn->imm, imm, prev_bc, 0)) + yasm_error_set(YASM_ERROR_TOO_COMPLEX, + N_("immediate expression too complex")); + insn->imm->size = im_len; + insn->imm->sign = im_sign; } else - insn->imm = NULL; + insn->imm = NULL; yasm_x86__bc_apply_prefixes((x86_common *)insn, &insn->rex, - insn->def_opersize_64, - id_insn->insn.num_prefixes, - id_insn->insn.prefixes); + insn->def_opersize_64, num_prefixes, prefixes); if (insn->postop == X86_POSTOP_ADDRESS16 && insn->common.addrsize) { - yasm_warn_set(YASM_WARN_GENERAL, N_("address size override ignored")); - insn->common.addrsize = 0; + yasm_warn_set(YASM_WARN_GENERAL, N_("address size override ignored")); + insn->common.addrsize = 0; } /* Handle non-span-dependent post-ops here */ switch (do_postop) { - case OPAP_ShortMov: - /* Long (modrm+sib) mov instructions in amd64 can be optimized into - * short mov instructions if a 32-bit address override is applied in - * 64-bit mode to an EA of just an offset (no registers) and the - * target register is al/ax/eax/rax. - * - * We don't want to do this if we're in default rel mode. - */ - if (!id_insn->default_rel && - insn->common.mode_bits == 64 && - insn->common.addrsize == 32 && - (!insn->x86_ea->ea.disp.abs || - !yasm_expr__contains(insn->x86_ea->ea.disp.abs, - YASM_EXPR_REG))) { - yasm_x86__ea_set_disponly(insn->x86_ea); - /* Make the short form permanent. */ - insn->opcode.opcode[0] = insn->opcode.opcode[1]; - } - insn->opcode.opcode[1] = 0; /* avoid possible confusion */ - break; - case OPAP_SImm32Avail: - /* Used for 64-bit mov immediate, which can take a sign-extended - * imm32 as well as imm64 values. The imm32 form is put in the - * second byte of the opcode and its ModRM byte is put in the third - * byte of the opcode. - */ - if (!insn->imm->abs || - (yasm_expr_get_intnum(&insn->imm->abs, 0) && - yasm_intnum_check_size( - yasm_expr_get_intnum(&insn->imm->abs, 0), 32, 0, 1))) { - /* Throwaway REX byte */ - unsigned char rex_temp = 0; + case OPAP_ShortMov: + /* Long (modrm+sib) mov instructions in amd64 can be optimized into + * short mov instructions if a 32-bit address override is applied in + * 64-bit mode to an EA of just an offset (no registers) and the + * target register is al/ax/eax/rax. + */ + if (insn->common.mode_bits == 64 && insn->common.addrsize == 32 && + (!insn->x86_ea->ea.disp.abs || + !yasm_expr__contains(insn->x86_ea->ea.disp.abs, + YASM_EXPR_REG))) { + yasm_x86__ea_set_disponly(insn->x86_ea); + /* Make the short form permanent. */ + insn->opcode.opcode[0] = insn->opcode.opcode[1]; + } + insn->opcode.opcode[1] = 0; /* avoid possible confusion */ + break; + case OPAP_SImm32Avail: + /* Used for 64-bit mov immediate, which can take a sign-extended + * imm32 as well as imm64 values. The imm32 form is put in the + * second byte of the opcode and its ModRM byte is put in the third + * byte of the opcode. + */ + if (!insn->imm->abs || + (yasm_expr_get_intnum(&insn->imm->abs, 0) && + yasm_intnum_check_size( + yasm_expr_get_intnum(&insn->imm->abs, 0), 32, 0, 1))) { + /* Throwaway REX byte */ + unsigned char rex_temp = 0; - /* Build ModRM EA - CAUTION: this depends on - * opcode 0 being a mov instruction! - */ - insn->x86_ea = yasm_x86__ea_create_reg(insn->x86_ea, - (unsigned long)insn->opcode.opcode[0]-0xB8, &rex_temp, 64); + /* Build ModRM EA - CAUTION: this depends on + * opcode 0 being a mov instruction! + */ + insn->x86_ea = yasm_x86__ea_create_reg( + (unsigned long)insn->opcode.opcode[0]-0xB8, &rex_temp, 64); - /* Make the imm32s form permanent. */ - insn->opcode.opcode[0] = insn->opcode.opcode[1]; - insn->imm->size = 32; - } - insn->opcode.opcode[1] = 0; /* avoid possible confusion */ - break; - default: - break; + /* Make the imm32s form permanent. */ + insn->opcode.opcode[0] = insn->opcode.opcode[1]; + insn->imm->size = 32; + } + insn->opcode.opcode[1] = 0; /* avoid possible confusion */ + break; + default: + break; } - /* Convert to VEX/XOP prefixes if requested. - * To save space in the insn structure, the VEX/XOP prefix is written into - * special_prefix and the first 2 bytes of the instruction are set to - * the second two VEX/XOP bytes. During calc_len() it may be shortened to - * one VEX byte (this can only be done after knowledge of REX value); this - * further optimization is not possible for XOP. - */ - if (vexdata) { - int xop = ((vexdata & 0xF0) == 0x80); - unsigned char vex1 = 0xE0; /* R=X=B=1, mmmmm=0 */ - unsigned char vex2; - - if (xop) { - /* Look at the first bytes of the opcode for the XOP mmmmm field. - * Leave R=X=B=1 for now. - */ - if (insn->opcode.opcode[0] != 0x08 && - insn->opcode.opcode[0] != 0x09 && - insn->opcode.opcode[0] != 0x0A) - yasm_internal_error(N_("first opcode byte of XOP must be 0x08, 0x09, or 0x0A")); - vex1 |= insn->opcode.opcode[0]; - /* Move opcode byte back one byte to make room for XOP prefix. */ - insn->opcode.opcode[2] = insn->opcode.opcode[1]; - } else { - /* Look at the first bytes of the opcode to see what leading bytes - * to encode in the VEX mmmmm field. Leave R=X=B=1 for now. - */ - if (insn->opcode.opcode[0] != 0x0F) - yasm_internal_error(N_("first opcode byte of VEX must be 0x0F")); - - if (insn->opcode.opcode[1] == 0x38) - vex1 |= 0x02; /* implied 0x0F 0x38 */ - else if (insn->opcode.opcode[1] == 0x3A) - vex1 |= 0x03; /* implied 0x0F 0x3A */ - else { - /* Originally a 0F-only opcode; move opcode byte back one - * position to make room for VEX prefix. - */ - insn->opcode.opcode[2] = insn->opcode.opcode[1]; - vex1 |= 0x01; /* implied 0x0F */ - } - } - - /* Check for update of special prefix by modifiers */ - if (insn->special_prefix != 0) { - vexdata &= ~0x03; - switch (insn->special_prefix) { - case 0x66: - vexdata |= 0x01; - break; - case 0xF3: - vexdata |= 0x02; - break; - case 0xF2: - vexdata |= 0x03; - break; - default: - yasm_internal_error(N_("unrecognized special prefix")); - } - } - - /* 2nd VEX byte is WvvvvLpp. - * W, L, pp come from vexdata - * vvvv comes from 1s complement of vexreg - */ - vex2 = (((vexdata & 0x8) << 4) | /* W */ - ((15 - (vexreg & 0xF)) << 3) | /* vvvv */ - (vexdata & 0x7)); /* Lpp */ - - /* Save to special_prefix and opcode */ - insn->special_prefix = xop ? 0x8F : 0xC4; /* VEX/XOP prefix */ - insn->opcode.opcode[0] = vex1; - insn->opcode.opcode[1] = vex2; - insn->opcode.len = 3; /* two prefix bytes and 1 opcode byte */ - } - - x86_id_insn_clear_operands(id_insn); - /* Transform the bytecode */ yasm_x86__bc_transform_insn(bc, insn); } @@ -1683,276 +3309,297 @@ typedef struct insnprefix_parse_data { /* instruction parse group - NULL if prefix */ /*@null@*/ const x86_insn_info *group; - /* For instruction, number of elements in group. - * For prefix, prefix type shifted right by 8. + /* For instruction, modifier in upper 24 bits, number of elements in group + * in lower 8 bits. + * For prefix, prefix type. */ - unsigned int num_info:8; + unsigned long data1; - /* For instruction, GAS suffix flags. + /* For instruction, cpu flags. * For prefix, prefix value. */ - unsigned int flags:8; + unsigned long data2; - /* Instruction modifier data. */ - unsigned int mod_data0:8; - unsigned int mod_data1:8; - unsigned int mod_data2:8; - - /* Tests against BITS==64 and AVX */ - unsigned int misc_flags:6; - - /* CPU flags */ - unsigned int cpu0:6; - unsigned int cpu1:6; - unsigned int cpu2:6; + /* suffix flags for instructions */ + enum { + NONE = 0, + SUF_B = (MOD_GasSufB >> MOD_GasSuf_SHIFT), + SUF_W = (MOD_GasSufW >> MOD_GasSuf_SHIFT), + SUF_L = (MOD_GasSufL >> MOD_GasSuf_SHIFT), + SUF_Q = (MOD_GasSufQ >> MOD_GasSuf_SHIFT), + SUF_S = (MOD_GasSufS >> MOD_GasSuf_SHIFT), + WEAK = 0x80 /* Relaxed operand mode for GAS */ + } flags; } insnprefix_parse_data; +#define INSN(name, flags, group, mod, cpu) \ + { name, group##_insn, (mod##UL<<8)|NELEMS(group##_insn), cpu, flags } +#define PREFIX(name, type, value) \ + { name, NULL, type, value, NONE } + +/* Static parse data structure for CPU feature flags */ +typedef struct cpu_parse_data { + const char *name; + + unsigned long cpu; + enum { + CPU_MODE_VERBATIM, + CPU_MODE_SET, + CPU_MODE_CLEAR + } mode; +} cpu_parse_data; + +typedef struct regtmod_parse_data { + const char *name; + + unsigned long regtmod; +} regtmod_parse_data; +#define REG(name, type, index, bits) \ + { name, (((unsigned long)YASM_ARCH_REG) << 24) | \ + (((unsigned long)bits) << 16) | (type | index) } +#define REGGROUP(name, group) \ + { name, (((unsigned long)YASM_ARCH_REGGROUP) << 24) | (group) } +#define SEGREG(name, prefix, num, bits) \ + { name, (((unsigned long)YASM_ARCH_SEGREG) << 24) | \ + (((unsigned long)bits) << 16) | (prefix << 8) | (num) } +#define TARGETMOD(name, mod) \ + { name, (((unsigned long)YASM_ARCH_TARGETMOD) << 24) | (mod) } /* Pull in all parse data */ -#include "x86insn_nasm.c" -#include "x86insn_gas.c" +#include "x86parse.c" static const char * -cpu_find_reverse(unsigned int cpu0, unsigned int cpu1, unsigned int cpu2) +cpu_find_reverse(unsigned long cpu) { static char cpuname[200]; - wordptr cpu = BitVector_Create(128, TRUE); - - if (cpu0 != CPU_Any) - BitVector_Bit_On(cpu, cpu0); - if (cpu1 != CPU_Any) - BitVector_Bit_On(cpu, cpu1); - if (cpu2 != CPU_Any) - BitVector_Bit_On(cpu, cpu2); cpuname[0] = '\0'; - if (BitVector_bit_test(cpu, CPU_Prot)) - strcat(cpuname, " Protected"); - if (BitVector_bit_test(cpu, CPU_Undoc)) - strcat(cpuname, " Undocumented"); - if (BitVector_bit_test(cpu, CPU_Obs)) - strcat(cpuname, " Obsolete"); - if (BitVector_bit_test(cpu, CPU_Priv)) - strcat(cpuname, " Privileged"); + if (cpu & CPU_Prot) + strcat(cpuname, " Protected"); + if (cpu & CPU_Undoc) + strcat(cpuname, " Undocumented"); + if (cpu & CPU_Obs) + strcat(cpuname, " Obsolete"); + if (cpu & CPU_Priv) + strcat(cpuname, " Privileged"); - if (BitVector_bit_test(cpu, CPU_FPU)) - strcat(cpuname, " FPU"); - if (BitVector_bit_test(cpu, CPU_MMX)) - strcat(cpuname, " MMX"); - if (BitVector_bit_test(cpu, CPU_SSE)) - strcat(cpuname, " SSE"); - if (BitVector_bit_test(cpu, CPU_SSE2)) - strcat(cpuname, " SSE2"); - if (BitVector_bit_test(cpu, CPU_SSE3)) - strcat(cpuname, " SSE3"); - if (BitVector_bit_test(cpu, CPU_3DNow)) - strcat(cpuname, " 3DNow"); - if (BitVector_bit_test(cpu, CPU_Cyrix)) - strcat(cpuname, " Cyrix"); - if (BitVector_bit_test(cpu, CPU_AMD)) - strcat(cpuname, " AMD"); - if (BitVector_bit_test(cpu, CPU_SMM)) - strcat(cpuname, " SMM"); - if (BitVector_bit_test(cpu, CPU_SVM)) - strcat(cpuname, " SVM"); - if (BitVector_bit_test(cpu, CPU_PadLock)) - strcat(cpuname, " PadLock"); - if (BitVector_bit_test(cpu, CPU_EM64T)) - strcat(cpuname, " EM64T"); - if (BitVector_bit_test(cpu, CPU_SSSE3)) - strcat(cpuname, " SSSE3"); - if (BitVector_bit_test(cpu, CPU_SSE41)) + if (cpu & CPU_FPU) + strcat(cpuname, " FPU"); + if (cpu & CPU_MMX) + strcat(cpuname, " MMX"); + if (cpu & CPU_SSE) + strcat(cpuname, " SSE"); + if (cpu & CPU_SSE2) + strcat(cpuname, " SSE2"); + if (cpu & CPU_SSE3) + strcat(cpuname, " SSE3"); + if (cpu & CPU_3DNow) + strcat(cpuname, " 3DNow"); + if (cpu & CPU_Cyrix) + strcat(cpuname, " Cyrix"); + if (cpu & CPU_AMD) + strcat(cpuname, " AMD"); + if (cpu & CPU_SMM) + strcat(cpuname, " SMM"); + if (cpu & CPU_SVM) + strcat(cpuname, " SVM"); + if (cpu & CPU_PadLock) + strcat(cpuname, " PadLock"); + if (cpu & CPU_EM64T) + strcat(cpuname, " EM64T"); + if (cpu & CPU_SSSE3) + strcat(cpuname, " SSSE3"); + if (cpu & CPU_SSE41) strcat(cpuname, " SSE4.1"); - if (BitVector_bit_test(cpu, CPU_SSE42)) + if (cpu & CPU_SSE42) strcat(cpuname, " SSE4.2"); - if (BitVector_bit_test(cpu, CPU_186)) - strcat(cpuname, " 186"); - if (BitVector_bit_test(cpu, CPU_286)) - strcat(cpuname, " 286"); - if (BitVector_bit_test(cpu, CPU_386)) - strcat(cpuname, " 386"); - if (BitVector_bit_test(cpu, CPU_486)) - strcat(cpuname, " 486"); - if (BitVector_bit_test(cpu, CPU_586)) - strcat(cpuname, " 586"); - if (BitVector_bit_test(cpu, CPU_686)) - strcat(cpuname, " 686"); - if (BitVector_bit_test(cpu, CPU_P3)) - strcat(cpuname, " P3"); - if (BitVector_bit_test(cpu, CPU_P4)) - strcat(cpuname, " P4"); - if (BitVector_bit_test(cpu, CPU_IA64)) - strcat(cpuname, " IA64"); - if (BitVector_bit_test(cpu, CPU_K6)) - strcat(cpuname, " K6"); - if (BitVector_bit_test(cpu, CPU_Athlon)) - strcat(cpuname, " Athlon"); - if (BitVector_bit_test(cpu, CPU_Hammer)) - strcat(cpuname, " Hammer"); - - BitVector_Destroy(cpu); + if (cpu & CPU_186) + strcat(cpuname, " 186"); + if (cpu & CPU_286) + strcat(cpuname, " 286"); + if (cpu & CPU_386) + strcat(cpuname, " 386"); + if (cpu & CPU_486) + strcat(cpuname, " 486"); + if (cpu & CPU_586) + strcat(cpuname, " 586"); + if (cpu & CPU_686) + strcat(cpuname, " 686"); + if (cpu & CPU_P3) + strcat(cpuname, " P3"); + if (cpu & CPU_P4) + strcat(cpuname, " P4"); + if (cpu & CPU_IA64) + strcat(cpuname, " IA64"); + if (cpu & CPU_K6) + strcat(cpuname, " K6"); + if (cpu & CPU_Athlon) + strcat(cpuname, " Athlon"); + if (cpu & CPU_Hammer) + strcat(cpuname, " Hammer"); return cpuname; } yasm_arch_insnprefix -yasm_x86__parse_check_insnprefix(yasm_arch *arch, const char *id, - size_t id_len, unsigned long line, - yasm_bytecode **bc, uintptr_t *prefix) +yasm_x86__parse_check_insnprefix(yasm_arch *arch, uintptr_t data[4], + const char *id, size_t id_len) { yasm_arch_x86 *arch_x86 = (yasm_arch_x86 *)arch; /*@null@*/ const insnprefix_parse_data *pdata; size_t i; - static char lcaseid[17]; + static char lcaseid[16]; - *bc = (yasm_bytecode *)NULL; - *prefix = 0; - - if (id_len > 16) - return YASM_ARCH_NOTINSNPREFIX; + if (id_len > 15) + return YASM_ARCH_NOTINSNPREFIX; for (i=0; iparser) { + case X86_PARSER_NASM: + pdata = insnprefix_nasm_find(lcaseid, id_len); + break; + case X86_PARSER_GAS: + pdata = insnprefix_gas_find(lcaseid, id_len); + break; + default: + pdata = NULL; } if (!pdata) - return YASM_ARCH_NOTINSNPREFIX; + return YASM_ARCH_NOTINSNPREFIX; if (pdata->group) { - x86_id_insn *id_insn; - wordptr cpu_enabled = arch_x86->cpu_enables[arch_x86->active_cpu]; - unsigned int cpu0, cpu1, cpu2; + unsigned long cpu = pdata->data2; - if (arch_x86->mode_bits != 64 && (pdata->misc_flags & ONLY_64)) { - yasm_warn_set(YASM_WARN_GENERAL, - N_("`%s' is an instruction in 64-bit mode"), id); - return YASM_ARCH_NOTINSNPREFIX; - } - if (arch_x86->mode_bits == 64 && (pdata->misc_flags & NOT_64)) { - yasm_error_set(YASM_ERROR_GENERAL, - N_("`%s' invalid in 64-bit mode"), id); - id_insn = yasm_xmalloc(sizeof(x86_id_insn)); - yasm_insn_initialize(&id_insn->insn); - id_insn->group = not64_insn; - id_insn->cpu_enabled = cpu_enabled; - id_insn->mod_data[0] = 0; - id_insn->mod_data[1] = 0; - id_insn->mod_data[2] = 0; - id_insn->num_info = NELEMS(not64_insn); - id_insn->mode_bits = arch_x86->mode_bits; - id_insn->suffix = 0; - id_insn->misc_flags = 0; - id_insn->parser = PARSER(arch_x86); - - id_insn->force_strict = arch_x86->force_strict != 0; - id_insn->default_rel = arch_x86->default_rel != 0; - *bc = yasm_bc_create_common(&x86_id_insn_callback, id_insn, line); - return YASM_ARCH_INSN; - } + if ((cpu & CPU_64) && arch_x86->mode_bits != 64) { + yasm_warn_set(YASM_WARN_GENERAL, + N_("`%s' is an instruction in 64-bit mode"), id); + return YASM_ARCH_NOTINSNPREFIX; + } + if ((cpu & CPU_Not64) && arch_x86->mode_bits == 64) { + yasm_error_set(YASM_ERROR_GENERAL, + N_("`%s' invalid in 64-bit mode"), id); + data[0] = (uintptr_t)not64_insn; + data[1] = NELEMS(not64_insn); + data[2] = CPU_Not64; + data[3] = arch_x86->mode_bits; + return YASM_ARCH_INSN; + } - cpu0 = pdata->cpu0; - cpu1 = pdata->cpu1; - cpu2 = pdata->cpu2; + cpu &= ~(CPU_64 | CPU_Not64); + if ((arch_x86->cpu_enabled & cpu) != cpu) { + yasm_warn_set(YASM_WARN_GENERAL, + N_("`%s' is an instruction in CPU%s"), id, + cpu_find_reverse(cpu)); + return YASM_ARCH_NOTINSNPREFIX; + } - if (!BitVector_bit_test(cpu_enabled, cpu0) || - !BitVector_bit_test(cpu_enabled, cpu1) || - !BitVector_bit_test(cpu_enabled, cpu2)) { - yasm_warn_set(YASM_WARN_GENERAL, - N_("`%s' is an instruction in CPU%s"), id, - cpu_find_reverse(cpu0, cpu1, cpu2)); - return YASM_ARCH_NOTINSNPREFIX; - } - - id_insn = yasm_xmalloc(sizeof(x86_id_insn)); - yasm_insn_initialize(&id_insn->insn); - id_insn->group = pdata->group; - id_insn->cpu_enabled = cpu_enabled; - id_insn->mod_data[0] = pdata->mod_data0; - id_insn->mod_data[1] = pdata->mod_data1; - id_insn->mod_data[2] = pdata->mod_data2; - id_insn->num_info = pdata->num_info; - id_insn->mode_bits = arch_x86->mode_bits; - id_insn->suffix = pdata->flags; - id_insn->misc_flags = pdata->misc_flags; - id_insn->parser = PARSER(arch_x86); - id_insn->force_strict = arch_x86->force_strict != 0; - id_insn->default_rel = arch_x86->default_rel != 0; - *bc = yasm_bc_create_common(&x86_id_insn_callback, id_insn, line); - return YASM_ARCH_INSN; + data[0] = (uintptr_t)pdata->group; + data[1] = pdata->data1; + data[2] = arch_x86->cpu_enabled; + data[3] = (((unsigned long)pdata->flags)<<8) | arch_x86->mode_bits; + return YASM_ARCH_INSN; } else { - unsigned long type = pdata->num_info<<8; - unsigned long value = pdata->flags; + unsigned long type = pdata->data1; + unsigned long value = pdata->data2; - if (arch_x86->mode_bits == 64 && type == X86_OPERSIZE && value == 32) { - yasm_error_set(YASM_ERROR_GENERAL, - N_("Cannot override data size to 32 bits in 64-bit mode")); - return YASM_ARCH_NOTINSNPREFIX; - } + if (arch_x86->mode_bits == 64 && type == X86_OPERSIZE && value == 32) { + yasm_error_set(YASM_ERROR_GENERAL, + N_("Cannot override data size to 32 bits in 64-bit mode")); + return YASM_ARCH_NOTINSNPREFIX; + } - if (arch_x86->mode_bits == 64 && type == X86_ADDRSIZE && value == 16) { - yasm_error_set(YASM_ERROR_GENERAL, - N_("Cannot override address size to 16 bits in 64-bit mode")); - return YASM_ARCH_NOTINSNPREFIX; - } + if (arch_x86->mode_bits == 64 && type == X86_ADDRSIZE && value == 16) { + yasm_error_set(YASM_ERROR_GENERAL, + N_("Cannot override address size to 16 bits in 64-bit mode")); + return YASM_ARCH_NOTINSNPREFIX; + } - if (arch_x86->mode_bits != 64 && (pdata->misc_flags & ONLY_64)) { - yasm_warn_set(YASM_WARN_GENERAL, - N_("`%s' is a prefix in 64-bit mode"), id); - return YASM_ARCH_NOTINSNPREFIX; - } - *prefix = type|value; - return YASM_ARCH_PREFIX; + if ((type == X86_REX || + (value == 64 && (type == X86_OPERSIZE || type == X86_ADDRSIZE))) + && arch_x86->mode_bits != 64) { + yasm_warn_set(YASM_WARN_GENERAL, + N_("`%s' is a prefix in 64-bit mode"), id); + return YASM_ARCH_NOTINSNPREFIX; + } + data[0] = type; + data[1] = value; + return YASM_ARCH_PREFIX; } } -static void -x86_id_insn_destroy(void *contents) +void +yasm_x86__parse_cpu(yasm_arch_x86 *arch_x86, const char *cpuid, + size_t cpuid_len) { - x86_id_insn *id_insn = (x86_id_insn *)contents; - yasm_insn_delete(&id_insn->insn, yasm_x86__ea_destroy); - yasm_xfree(contents); + /*@null@*/ const cpu_parse_data *pdata; + size_t i; + static char lcaseid[16]; + + if (cpuid_len > 15) + return; + for (i=0; imode) { + case CPU_MODE_VERBATIM: + arch_x86->cpu_enabled = pdata->cpu; + break; + case CPU_MODE_SET: + arch_x86->cpu_enabled |= pdata->cpu; + break; + case CPU_MODE_CLEAR: + arch_x86->cpu_enabled &= ~pdata->cpu; + break; + } } -static void -x86_id_insn_print(const void *contents, FILE *f, int indent_level) -{ - const x86_id_insn *id_insn = (const x86_id_insn *)contents; - yasm_insn_print(&id_insn->insn, f, indent_level); - /*TODO*/ -} - -/*@only@*/ yasm_bytecode * -yasm_x86__create_empty_insn(yasm_arch *arch, unsigned long line) +yasm_arch_regtmod +yasm_x86__parse_check_regtmod(yasm_arch *arch, uintptr_t *data, + const char *id, size_t id_len) { yasm_arch_x86 *arch_x86 = (yasm_arch_x86 *)arch; - x86_id_insn *id_insn = yasm_xmalloc(sizeof(x86_id_insn)); + /*@null@*/ const regtmod_parse_data *pdata; + size_t i; + static char lcaseid[8]; + unsigned int bits; + yasm_arch_regtmod type; - yasm_insn_initialize(&id_insn->insn); - id_insn->group = empty_insn; - id_insn->cpu_enabled = arch_x86->cpu_enables[arch_x86->active_cpu]; - id_insn->mod_data[0] = 0; - id_insn->mod_data[1] = 0; - id_insn->mod_data[2] = 0; - id_insn->num_info = NELEMS(empty_insn); - id_insn->mode_bits = arch_x86->mode_bits; - id_insn->suffix = (PARSER(arch_x86) == X86_PARSER_GAS) ? SUF_Z : 0; - id_insn->misc_flags = 0; - id_insn->parser = PARSER(arch_x86); - id_insn->force_strict = arch_x86->force_strict != 0; - id_insn->default_rel = arch_x86->default_rel != 0; + if (id_len > 7) + return YASM_ARCH_NOTREGTMOD; + for (i=0; iregtmod >> 24); + bits = (pdata->regtmod >> 16) & 0xFF; + + if (type == YASM_ARCH_REG && bits != 0 && arch_x86->mode_bits != bits) { + yasm_warn_set(YASM_WARN_GENERAL, + N_("`%s' is a register in %u-bit mode"), id, bits); + return YASM_ARCH_NOTREGTMOD; + } + + if (type == YASM_ARCH_SEGREG && bits != 0 && arch_x86->mode_bits == bits) { + yasm_warn_set(YASM_WARN_GENERAL, + N_("`%s' segment register ignored in %u-bit mode"), id, + bits); + } + + *data = pdata->regtmod & 0x0000FFFFUL; + return type; } diff --git a/modules/arch/x86/x86parse.gap b/modules/arch/x86/x86parse.gap new file mode 100644 index 00000000..c9d71411 --- /dev/null +++ b/modules/arch/x86/x86parse.gap @@ -0,0 +1,1268 @@ +# GAP (gen_arch_parse) input file for x86 architecture +# $Id$ +# +# Copyright (C) 2001-2007 Peter Johnson +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND OTHER CONTRIBUTORS ``AS IS'' +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR OTHER CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. + +# Configure GAP for x86 generation mode +ARCH x86 + +# Supported x86 parsers +PARSERS nasm gas + +# INSN parameters: +# - parser (- if any) +# - base name of instruction +# - if string, each character is an allowed GAS suffix +# if defined name, value is GAS suffix mode set (no character suffix reqd) +# - instruction group (sans _insn suffix) +# - modifiers (up to 3 bytes) +# - CPU flags +# +# The string mode of the second parameter is a shortcut for GAS forms, e.g.: +# INSN - mov "bwl" mov 0 CPU_Any +# is equivalent to: +# INSN - mov NONE mov 0 CPU_Any +# INSN gas movb SUF_B mov 0 CPU_Any +# INSN gas movw SUF_W mov 0 CPU_Any +# INSN gas movl SUF_L mov 0 CPU_Any + +# Move +INSN - mov "bwl" mov 0 CPU_Any +INSN gas movabs "bwlq" movabs 0 CPU_Hammer|CPU_64 + +# Move with sign/zero extend +INSN gas movsbw SUF_B movszx 0xBE CPU_386 +INSN gas movsbl SUF_B movszx 0xBE CPU_386 +INSN gas movswl SUF_W movszx 0xBE CPU_386 +INSN gas movsbq SUF_B movszx 0xBE CPU_Hammer|CPU_64 +INSN gas movswq SUF_W movszx 0xBE CPU_Hammer|CPU_64 +INSN - movsx "bw" movszx 0xBE CPU_386 +INSN gas movslq SUF_L movsxd 0 CPU_Hammer|CPU_64 +INSN nasm movsxd NONE movsxd 0 CPU_Hammer|CPU_64 +INSN gas movzbw SUF_B movszx 0xB6 CPU_386 +INSN gas movzbl SUF_B movszx 0xB6 CPU_386 +INSN gas movzwl SUF_W movszx 0xB6 CPU_386 +INSN gas movzbq SUF_B movszx 0xB6 CPU_Hammer|CPU_64 +INSN gas movzwq SUF_W movszx 0xB6 CPU_Hammer|CPU_64 +INSN - movzx NONE movszx 0xB6 CPU_386 + +# Push instructions +INSN - push "wlq" push 0 CPU_Any +INSN - pusha NONE onebyte 0x0060 CPU_186|CPU_Not64 +INSN nasm pushad NONE onebyte 0x2060 CPU_386|CPU_Not64 +INSN gas pushal NONE onebyte 0x2060 CPU_386|CPU_Not64 +INSN - pushaw NONE onebyte 0x1060 CPU_186|CPU_Not64 + +# Pop instructions +INSN - pop "wlq" pop 0 CPU_Any +INSN - popa NONE onebyte 0x0061 CPU_186|CPU_Not64 +INSN nasm popad NONE onebyte 0x2061 CPU_386|CPU_Not64 +INSN gas popal NONE onebyte 0x2061 CPU_386|CPU_Not64 +INSN - popaw NONE onebyte 0x1061 CPU_186|CPU_Not64 + +# Exchange +INSN - xchg "bwlq" xchg 0 CPU_Any + +# In/out from ports +INSN - in "bwl" in 0 CPU_Any +INSN - out "bwl" out 0 CPU_Any +# Load effective address +INSN - lea "wlq" lea 0 CPU_Any +# Load segment registers from memory +INSN - lds "wl" ldes 0xC5 CPU_Not64 +INSN - les "wl" ldes 0xC4 CPU_Not64 +INSN - lfs "wl" lfgss 0xB4 CPU_386 +INSN - lgs "wl" lfgss 0xB5 CPU_386 +INSN - lss "wl" lfgss 0xB2 CPU_386 +# Flags register instructions +INSN - clc NONE onebyte 0x00F8 CPU_Any +INSN - cld NONE onebyte 0x00FC CPU_Any +INSN - cli NONE onebyte 0x00FA CPU_Any +INSN - clts NONE twobyte 0x0F06 CPU_286|CPU_Priv +INSN - cmc NONE onebyte 0x00F5 CPU_Any +INSN - lahf NONE onebyte 0x009F CPU_Any +INSN - sahf NONE onebyte 0x009E CPU_Any +INSN - pushf NONE onebyte 0x40009C CPU_Any +INSN nasm pushfd NONE onebyte 0x00209C CPU_386|CPU_Not64 +INSN gas pushfl NONE onebyte 0x00209C CPU_386|CPU_Not64 +INSN - pushfw NONE onebyte 0x40109C CPU_Any +INSN - pushfq NONE onebyte 0x40409C CPU_Hammer|CPU_64 +INSN - popf NONE onebyte 0x40009D CPU_Any +INSN nasm popfd NONE onebyte 0x00209D CPU_386|CPU_Not64 +INSN gas popfl NONE onebyte 0x00209D CPU_386|CPU_Not64 +INSN - popfw NONE onebyte 0x40109D CPU_Any +INSN - popfq NONE onebyte 0x40409D CPU_Hammer|CPU_64 +INSN - stc NONE onebyte 0x00F9 CPU_Any +INSN - std NONE onebyte 0x00FD CPU_Any +INSN - sti NONE onebyte 0x00FB CPU_Any +# Arithmetic +INSN - add "bwlq" arith 0x0000 CPU_Any +INSN - inc "bwlq" incdec 0x0040 CPU_Any +INSN - sub "bwlq" arith 0x0528 CPU_Any +INSN - dec "bwlq" incdec 0x0148 CPU_Any +INSN - sbb "bwlq" arith 0x0318 CPU_Any +INSN - cmp "bwlq" arith 0x0738 CPU_Any +INSN - test "bwlq" test 0 CPU_Any +INSN - and "bwlq" arith 0x0420 CPU_Any +INSN - or "bwlq" arith 0x0108 CPU_Any +INSN - xor "bwlq" arith 0x0630 CPU_Any +INSN - adc "bwlq" arith 0x0210 CPU_Any +INSN - neg "bwlq" f6 0x03 CPU_Any +INSN - not "bwlq" f6 0x02 CPU_Any +INSN - aaa NONE onebyte 0x0037 CPU_Not64 +INSN - aas NONE onebyte 0x003F CPU_Not64 +INSN - daa NONE onebyte 0x0027 CPU_Not64 +INSN - das NONE onebyte 0x002F CPU_Not64 +INSN - aad NONE aadm 0x01 CPU_Not64 +INSN - aam NONE aadm 0x00 CPU_Not64 +# Conversion instructions +INSN - cbw NONE onebyte 0x1098 CPU_Any +INSN - cwde NONE onebyte 0x2098 CPU_386 +INSN - cdqe NONE onebyte 0x4098 CPU_Hammer|CPU_64 +INSN - cwd NONE onebyte 0x1099 CPU_Any +INSN - cdq NONE onebyte 0x2099 CPU_386 +INSN - cqo NONE onebyte 0x4099 CPU_Hammer|CPU_64 +# Conversion instructions - GAS / AT&T naming +INSN gas cbtw NONE onebyte 0x1098 CPU_Any +INSN gas cwtl NONE onebyte 0x2098 CPU_386 +INSN gas cltq NONE onebyte 0x4098 CPU_Hammer|CPU_64 +INSN gas cwtd NONE onebyte 0x1099 CPU_Any +INSN gas cltd NONE onebyte 0x2099 CPU_386 +INSN gas cqto NONE onebyte 0x4099 CPU_Hammer|CPU_64 +# Multiplication and division +INSN - mul "bwlq" f6 0x04 CPU_Any +INSN - imul "bwlq" imul 0 CPU_Any +INSN - div "bwlq" div 0x06 CPU_Any +INSN - idiv "bwlq" div 0x07 CPU_Any +# Shifts +INSN - rol "bwlq" shift 0x00 CPU_Any +INSN - ror "bwlq" shift 0x01 CPU_Any +INSN - rcl "bwlq" shift 0x02 CPU_Any +INSN - rcr "bwlq" shift 0x03 CPU_Any +INSN - sal "bwlq" shift 0x04 CPU_Any +INSN - shl "bwlq" shift 0x04 CPU_Any +INSN - shr "bwlq" shift 0x05 CPU_Any +INSN - sar "bwlq" shift 0x07 CPU_Any +INSN - shld "wlq" shlrd 0xA4 CPU_386 +INSN - shrd "wlq" shlrd 0xAC CPU_386 +# Control transfer instructions unconditional) +INSN - call NONE call 0 CPU_Any +INSN gas calll NONE call 0 CPU_Not64 +INSN gas callq NONE call 0 CPU_Hammer|CPU_64 +INSN - jmp NONE jmp 0 CPU_Any +INSN - ret NONE retnf 0x00C2 CPU_Any +INSN gas retw NONE retnf 0x10C2 CPU_Any +INSN gas retl NONE retnf 0x00C2 CPU_Not64 +INSN gas retq NONE retnf 0x00C2 CPU_Hammer|CPU_64 +INSN nasm retn NONE retnf 0x00C2 CPU_Any +INSN nasm retf NONE retnf 0x40CA CPU_Any +INSN gas lretw NONE retnf 0x10CA CPU_Any +INSN gas lretl NONE retnf 0x00CA CPU_Any +INSN gas lretq NONE retnf 0x40CA CPU_Hammer|CPU_64 +INSN - enter "wlq" enter 0 CPU_186 +INSN - leave NONE onebyte 0x4000C9 CPU_186 +INSN gas leavew NONE onebyte 0x0010C9 CPU_186 +INSN gas leavel NONE onebyte 0x4000C9 CPU_186 +INSN gas leaveq NONE onebyte 0x4000C9 CPU_Hammer|CPU_64 +# Conditional jumps +INSN - jo NONE jcc 0x00 CPU_Any +INSN - jno NONE jcc 0x01 CPU_Any +INSN - jb NONE jcc 0x02 CPU_Any +INSN - jc NONE jcc 0x02 CPU_Any +INSN - jnae NONE jcc 0x02 CPU_Any +INSN - jnb NONE jcc 0x03 CPU_Any +INSN - jnc NONE jcc 0x03 CPU_Any +INSN - jae NONE jcc 0x03 CPU_Any +INSN - je NONE jcc 0x04 CPU_Any +INSN - jz NONE jcc 0x04 CPU_Any +INSN - jne NONE jcc 0x05 CPU_Any +INSN - jnz NONE jcc 0x05 CPU_Any +INSN - jbe NONE jcc 0x06 CPU_Any +INSN - jna NONE jcc 0x06 CPU_Any +INSN - jnbe NONE jcc 0x07 CPU_Any +INSN - ja NONE jcc 0x07 CPU_Any +INSN - js NONE jcc 0x08 CPU_Any +INSN - jns NONE jcc 0x09 CPU_Any +INSN - jp NONE jcc 0x0A CPU_Any +INSN - jpe NONE jcc 0x0A CPU_Any +INSN - jnp NONE jcc 0x0B CPU_Any +INSN - jpo NONE jcc 0x0B CPU_Any +INSN - jl NONE jcc 0x0C CPU_Any +INSN - jnge NONE jcc 0x0C CPU_Any +INSN - jnl NONE jcc 0x0D CPU_Any +INSN - jge NONE jcc 0x0D CPU_Any +INSN - jle NONE jcc 0x0E CPU_Any +INSN - jng NONE jcc 0x0E CPU_Any +INSN - jnle NONE jcc 0x0F CPU_Any +INSN - jg NONE jcc 0x0F CPU_Any +INSN - jcxz NONE jcxz 0x10 CPU_Any +INSN - jecxz NONE jcxz 0x20 CPU_386 +INSN - jrcxz NONE jcxz 0x40 CPU_Hammer|CPU_64 +# Loop instructions +INSN - loop NONE loop 0x02 CPU_Any +INSN - loopz NONE loop 0x01 CPU_Any +INSN - loope NONE loop 0x01 CPU_Any +INSN - loopnz NONE loop 0x00 CPU_Any +INSN - loopne NONE loop 0x00 CPU_Any +# Set byte on flag instructions +INSN - seto "b" setcc 0x00 CPU_386 +INSN - setno "b" setcc 0x01 CPU_386 +INSN - setb "b" setcc 0x02 CPU_386 +INSN - setc "b" setcc 0x02 CPU_386 +INSN - setnae "b" setcc 0x02 CPU_386 +INSN - setnb "b" setcc 0x03 CPU_386 +INSN - setnc "b" setcc 0x03 CPU_386 +INSN - setae "b" setcc 0x03 CPU_386 +INSN - sete "b" setcc 0x04 CPU_386 +INSN - setz "b" setcc 0x04 CPU_386 +INSN - setne "b" setcc 0x05 CPU_386 +INSN - setnz "b" setcc 0x05 CPU_386 +INSN - setbe "b" setcc 0x06 CPU_386 +INSN - setna "b" setcc 0x06 CPU_386 +INSN - setnbe "b" setcc 0x07 CPU_386 +INSN - seta "b" setcc 0x07 CPU_386 +INSN - sets "b" setcc 0x08 CPU_386 +INSN - setns "b" setcc 0x09 CPU_386 +INSN - setp "b" setcc 0x0A CPU_386 +INSN - setpe "b" setcc 0x0A CPU_386 +INSN - setnp "b" setcc 0x0B CPU_386 +INSN - setpo "b" setcc 0x0B CPU_386 +INSN - setl "b" setcc 0x0C CPU_386 +INSN - setnge "b" setcc 0x0C CPU_386 +INSN - setnl "b" setcc 0x0D CPU_386 +INSN - setge "b" setcc 0x0D CPU_386 +INSN - setle "b" setcc 0x0E CPU_386 +INSN - setng "b" setcc 0x0E CPU_386 +INSN - setnle "b" setcc 0x0F CPU_386 +INSN - setg "b" setcc 0x0F CPU_386 +# String instructions +INSN - cmpsb NONE onebyte 0x00A6 CPU_Any +INSN - cmpsw NONE onebyte 0x10A7 CPU_Any +INSN - cmpsd NONE cmpsd 0 CPU_Any +INSN gas cmpsl NONE onebyte 0x20A7 CPU_386 +INSN - cmpsq NONE onebyte 0x40A7 CPU_Hammer|CPU_64 +INSN - insb NONE onebyte 0x006C CPU_Any +INSN - insw NONE onebyte 0x106D CPU_Any +INSN nasm insd NONE onebyte 0x206D CPU_386 +INSN gas insl NONE onebyte 0x206D CPU_386 +INSN - outsb NONE onebyte 0x006E CPU_Any +INSN - outsw NONE onebyte 0x106F CPU_Any +INSN nasm outsd NONE onebyte 0x206F CPU_386 +INSN gas outsl NONE onebyte 0x206F CPU_386 +INSN - lodsb NONE onebyte 0x00AC CPU_Any +INSN - lodsw NONE onebyte 0x10AD CPU_Any +INSN nasm lodsd NONE onebyte 0x20AD CPU_386 +INSN gas lodsl NONE onebyte 0x20AD CPU_386 +INSN - lodsq NONE onebyte 0x40AD CPU_Hammer|CPU_64 +INSN - movsb NONE onebyte 0x00A4 CPU_Any +INSN - movsw NONE onebyte 0x10A5 CPU_Any +INSN - movsd NONE movsd 0 CPU_386 +INSN gas movsl NONE onebyte 0x20A5 CPU_386 +INSN - movsq NONE onebyte 0x40A5 CPU_Hammer|CPU_64 +# smov alias for movs in GAS mode +INSN gas smovb NONE onebyte 0x00A4 CPU_Any +INSN gas smovw NONE onebyte 0x10A5 CPU_Any +INSN gas smovl NONE onebyte 0x20A5 CPU_386 +INSN gas smovq NONE onebyte 0x40A5 CPU_Hammer|CPU_64 +INSN - scasb NONE onebyte 0x00AE CPU_Any +INSN - scasw NONE onebyte 0x10AF CPU_Any +INSN nasm scasd NONE onebyte 0x20AF CPU_386 +INSN gas scasl NONE onebyte 0x20AF CPU_386 +INSN - scasq NONE onebyte 0x40AF CPU_Hammer|CPU_64 +# ssca alias for scas in GAS mode +INSN gas sscab NONE onebyte 0x00AE CPU_Any +INSN gas sscaw NONE onebyte 0x10AF CPU_Any +INSN gas sscal NONE onebyte 0x20AF CPU_386 +INSN gas sscaq NONE onebyte 0x40AF CPU_Hammer|CPU_64 +INSN - stosb NONE onebyte 0x00AA CPU_Any +INSN - stosw NONE onebyte 0x10AB CPU_Any +INSN nasm stosd NONE onebyte 0x20AB CPU_386 +INSN gas stosl NONE onebyte 0x20AB CPU_386 +INSN - stosq NONE onebyte 0x40AB CPU_Hammer|CPU_64 +INSN - xlatb NONE onebyte 0x00D7 CPU_Any +# Bit manipulation +INSN - bsf "wlq" bsfr 0xBC CPU_386 +INSN - bsr "wlq" bsfr 0xBD CPU_386 +INSN - bt "wlq" bittest 0x04A3 CPU_386 +INSN - btc "wlq" bittest 0x07BB CPU_386 +INSN - btr "wlq" bittest 0x06B3 CPU_386 +INSN - bts "wlq" bittest 0x05AB CPU_386 +# Interrupts and operating system instructions +INSN - int NONE int 0 CPU_Any +INSN - int3 NONE onebyte 0x00CC CPU_Any +INSN nasm int03 NONE onebyte 0x00CC CPU_Any +INSN - into NONE onebyte 0x00CE CPU_Not64 +INSN - iret NONE onebyte 0x00CF CPU_Any +INSN - iretw NONE onebyte 0x10CF CPU_Any +INSN nasm iretd NONE onebyte 0x20CF CPU_386 +INSN gas iretl NONE onebyte 0x20CF CPU_386 +INSN - iretq NONE onebyte 0x40CF CPU_Hammer|CPU_64 +INSN - rsm NONE twobyte 0x0FAA CPU_586|CPU_SMM +INSN - bound "wl" bound 0 CPU_186|CPU_Not64 +INSN - hlt NONE onebyte 0x00F4 CPU_Priv +INSN - nop NONE onebyte 0x0090 CPU_Any +# Protection control +INSN - arpl "w" arpl 0 CPU_286|CPU_Prot|CPU_Not64 +INSN - lar "wlq" bsfr 0x02 CPU_286|CPU_Prot +INSN - lgdt "wlq" twobytemem 0x020F01 CPU_286|CPU_Priv +INSN - lidt "wlq" twobytemem 0x030F01 CPU_286|CPU_Priv +INSN - lldt "w" prot286 0x0200 CPU_286|CPU_Prot|CPU_Priv +INSN - lmsw "w" prot286 0x0601 CPU_286|CPU_Priv +INSN - lsl "wlq" bsfr 0x03 CPU_286|CPU_Prot +INSN - ltr "w" prot286 0x0300 CPU_286|CPU_Prot|CPU_Priv +INSN - sgdt "wlq" twobytemem 0x000F01 CPU_286|CPU_Priv +INSN - sidt "wlq" twobytemem 0x010F01 CPU_286|CPU_Priv +INSN - sldt "wlq" sldtmsw 0x0000 CPU_286 +INSN - smsw "wlq" sldtmsw 0x0401 CPU_286 +INSN - str "wlq" str 0 CPU_286|CPU_Prot +INSN - verr "w" prot286 0x0400 CPU_286|CPU_Prot +INSN - verw "w" prot286 0x0500 CPU_286|CPU_Prot +# Floating point instructions +INSN - fld "ls" fld 0 CPU_FPU +INSN gas fldt WEAK fldstpt 0x05 CPU_FPU +INSN - fild "lqs" fildstp 0x050200 CPU_FPU +INSN gas fildll NONE fbldstp 0x05 CPU_FPU +INSN - fbld NONE fbldstp 0x04 CPU_FPU +INSN - fst "ls" fst 0 CPU_FPU +INSN - fist "ls" fiarith 0x02DB CPU_FPU +INSN - fstp "ls" fstp 0 CPU_FPU +INSN gas fstpt WEAK fldstpt 0x07 CPU_FPU +INSN - fistp "lqs" fildstp 0x070203 CPU_FPU +INSN gas fistpll NONE fbldstp 0x07 CPU_FPU +INSN - fbstp NONE fbldstp 0x06 CPU_FPU +INSN - fxch NONE fxch 0 CPU_FPU +INSN - fcom "ls" fcom 0x02D0 CPU_FPU +INSN - ficom "ls" fiarith 0x02DA CPU_FPU +INSN - fcomp "ls" fcom 0x03D8 CPU_FPU +INSN - ficomp "ls" fiarith 0x03DA CPU_FPU +INSN - fcompp NONE twobyte 0xDED9 CPU_FPU +INSN - fucom NONE fcom2 0xDDE0 CPU_286|CPU_FPU +INSN - fucomp NONE fcom2 0xDDE8 CPU_286|CPU_FPU +INSN - fucompp NONE twobyte 0xDAE9 CPU_286|CPU_FPU +INSN - ftst NONE twobyte 0xD9E4 CPU_FPU +INSN - fxam NONE twobyte 0xD9E5 CPU_FPU +INSN - fld1 NONE twobyte 0xD9E8 CPU_FPU +INSN - fldl2t NONE twobyte 0xD9E9 CPU_FPU +INSN - fldl2e NONE twobyte 0xD9EA CPU_FPU +INSN - fldpi NONE twobyte 0xD9EB CPU_FPU +INSN - fldlg2 NONE twobyte 0xD9EC CPU_FPU +INSN - fldln2 NONE twobyte 0xD9ED CPU_FPU +INSN - fldz NONE twobyte 0xD9EE CPU_FPU +INSN - fadd "ls" farith 0x00C0C0 CPU_FPU +INSN - faddp NONE farithp 0xC0 CPU_FPU +INSN - fiadd "ls" fiarith 0x00DA CPU_FPU +INSN - fsub "ls" farith 0x04E0E8 CPU_FPU +INSN - fisub "ls" fiarith 0x04DA CPU_FPU +INSN nasm fsubp NONE farithp 0xE8 CPU_FPU +INSN gas fsubp NONE farithp 0xE0 CPU_FPU +INSN - fsubr "ls" farith 0x05E8E0 CPU_FPU +INSN - fisubr "ls" fiarith 0x05DA CPU_FPU +INSN nasm fsubrp NONE farithp 0xE0 CPU_FPU +INSN gas fsubrp NONE farithp 0xE8 CPU_FPU +INSN - fmul "ls" farith 0x01C8C8 CPU_FPU +INSN - fimul "ls" fiarith 0x01DA CPU_FPU +INSN - fmulp NONE farithp 0xC8 CPU_FPU +INSN - fdiv "ls" farith 0x06F0F8 CPU_FPU +INSN - fidiv "ls" fiarith 0x06DA CPU_FPU +INSN nasm fdivp NONE farithp 0xF8 CPU_FPU +INSN gas fdivp NONE farithp 0xF0 CPU_FPU +INSN - fdivr "ls" farith 0x07F8F0 CPU_FPU +INSN - fidivr "ls" fiarith 0x07DA CPU_FPU +INSN nasm fdivrp NONE farithp 0xF0 CPU_FPU +INSN gas fdivrp NONE farithp 0xF8 CPU_FPU +INSN - f2xm1 NONE twobyte 0xD9F0 CPU_FPU +INSN - fyl2x NONE twobyte 0xD9F1 CPU_FPU +INSN - fptan NONE twobyte 0xD9F2 CPU_FPU +INSN - fpatan NONE twobyte 0xD9F3 CPU_FPU +INSN - fxtract NONE twobyte 0xD9F4 CPU_FPU +INSN - fprem1 NONE twobyte 0xD9F5 CPU_286|CPU_FPU +INSN - fdecstp NONE twobyte 0xD9F6 CPU_FPU +INSN - fincstp NONE twobyte 0xD9F7 CPU_FPU +INSN - fprem NONE twobyte 0xD9F8 CPU_FPU +INSN - fyl2xp1 NONE twobyte 0xD9F9 CPU_FPU +INSN - fsqrt NONE twobyte 0xD9FA CPU_FPU +INSN - fsincos NONE twobyte 0xD9FB CPU_286|CPU_FPU +INSN - frndint NONE twobyte 0xD9FC CPU_FPU +INSN - fscale NONE twobyte 0xD9FD CPU_FPU +INSN - fsin NONE twobyte 0xD9FE CPU_286|CPU_FPU +INSN - fcos NONE twobyte 0xD9FF CPU_286|CPU_FPU +INSN - fchs NONE twobyte 0xD9E0 CPU_FPU +INSN - fabs NONE twobyte 0xD9E1 CPU_FPU +INSN - fninit NONE twobyte 0xDBE3 CPU_FPU +INSN - finit NONE threebyte 0x9BDBE3 CPU_FPU +INSN - fldcw "w" fldnstcw 0x05 CPU_FPU +INSN - fnstcw "w" fldnstcw 0x07 CPU_FPU +INSN - fstcw "w" fstcw 0 CPU_FPU +INSN - fnstsw "w" fnstsw 0 CPU_FPU +INSN - fstsw "w" fstsw 0 CPU_FPU +INSN - fnclex NONE twobyte 0xDBE2 CPU_FPU +INSN - fclex NONE threebyte 0x9BDBE2 CPU_FPU +INSN - fnstenv "ls" onebytemem 0x06D9 CPU_FPU +INSN - fstenv "ls" twobytemem 0x069BD9 CPU_FPU +INSN - fldenv "ls" onebytemem 0x04D9 CPU_FPU +INSN - fnsave "ls" onebytemem 0x06DD CPU_FPU +INSN - fsave "ls" twobytemem 0x069BDD CPU_FPU +INSN - frstor "ls" onebytemem 0x04DD CPU_FPU +INSN - ffree NONE ffree 0xDD CPU_FPU +INSN - ffreep NONE ffree 0xDF CPU_686|CPU_FPU|CPU_Undoc +INSN - fnop NONE twobyte 0xD9D0 CPU_FPU +INSN - fwait NONE onebyte 0x009B CPU_FPU +# Prefixes should the others be here too? should wait be a prefix? +INSN - wait NONE onebyte 0x009B CPU_Any +# 486 extensions +INSN - bswap "lq" bswap 0 CPU_486 +INSN - xadd "bwlq" cmpxchgxadd 0xC0 CPU_486 +INSN - cmpxchg "bwlq" cmpxchgxadd 0xB0 CPU_486 +INSN nasm cmpxchg486 NONE cmpxchgxadd 0xA6 CPU_486|CPU_Undoc +INSN - invd NONE twobyte 0x0F08 CPU_486|CPU_Priv +INSN - wbinvd NONE twobyte 0x0F09 CPU_486|CPU_Priv +INSN - invlpg NONE twobytemem 0x070F01 CPU_486|CPU_Priv +# 586+ and late 486 extensions +INSN - cpuid NONE twobyte 0x0FA2 CPU_486 +# Pentium extensions +INSN - wrmsr NONE twobyte 0x0F30 CPU_586|CPU_Priv +INSN - rdtsc NONE twobyte 0x0F31 CPU_586 +INSN - rdmsr NONE twobyte 0x0F32 CPU_586|CPU_Priv +INSN - cmpxchg8b "q" cmpxchg8b 0 CPU_586 +# Pentium II/Pentium Pro extensions +INSN - sysenter NONE twobyte 0x0F34 CPU_686|CPU_Not64 +INSN - sysexit NONE twobyte 0x0F35 CPU_686|CPU_Priv|CPU_Not64 +INSN - fxsave "q" twobytemem 0x000FAE CPU_686|CPU_FPU +INSN - fxrstor "q" twobytemem 0x010FAE CPU_686|CPU_FPU +INSN - rdpmc NONE twobyte 0x0F33 CPU_686 +INSN - ud2 NONE twobyte 0x0F0B CPU_286 +INSN - ud1 NONE twobyte 0x0FB9 CPU_286|CPU_Undoc +INSN - cmovo "wlq" cmovcc 0x00 CPU_686 +INSN - cmovno "wlq" cmovcc 0x01 CPU_686 +INSN - cmovb "wlq" cmovcc 0x02 CPU_686 +INSN - cmovc "wlq" cmovcc 0x02 CPU_686 +INSN - cmovnae "wlq" cmovcc 0x02 CPU_686 +INSN - cmovnb "wlq" cmovcc 0x03 CPU_686 +INSN - cmovnc "wlq" cmovcc 0x03 CPU_686 +INSN - cmovae "wlq" cmovcc 0x03 CPU_686 +INSN - cmove "wlq" cmovcc 0x04 CPU_686 +INSN - cmovz "wlq" cmovcc 0x04 CPU_686 +INSN - cmovne "wlq" cmovcc 0x05 CPU_686 +INSN - cmovnz "wlq" cmovcc 0x05 CPU_686 +INSN - cmovbe "wlq" cmovcc 0x06 CPU_686 +INSN - cmovna "wlq" cmovcc 0x06 CPU_686 +INSN - cmovnbe "wlq" cmovcc 0x07 CPU_686 +INSN - cmova "wlq" cmovcc 0x07 CPU_686 +INSN - cmovs "wlq" cmovcc 0x08 CPU_686 +INSN - cmovns "wlq" cmovcc 0x09 CPU_686 +INSN - cmovp "wlq" cmovcc 0x0A CPU_686 +INSN - cmovpe "wlq" cmovcc 0x0A CPU_686 +INSN - cmovnp "wlq" cmovcc 0x0B CPU_686 +INSN - cmovpo "wlq" cmovcc 0x0B CPU_686 +INSN - cmovl "wlq" cmovcc 0x0C CPU_686 +INSN - cmovnge "wlq" cmovcc 0x0C CPU_686 +INSN - cmovnl "wlq" cmovcc 0x0D CPU_686 +INSN - cmovge "wlq" cmovcc 0x0D CPU_686 +INSN - cmovle "wlq" cmovcc 0x0E CPU_686 +INSN - cmovng "wlq" cmovcc 0x0E CPU_686 +INSN - cmovnle "wlq" cmovcc 0x0F CPU_686 +INSN - cmovg "wlq" cmovcc 0x0F CPU_686 +INSN - fcmovb NONE fcmovcc 0xDAC0 CPU_686|CPU_FPU +INSN - fcmove NONE fcmovcc 0xDAC8 CPU_686|CPU_FPU +INSN - fcmovbe NONE fcmovcc 0xDAD0 CPU_686|CPU_FPU +INSN - fcmovu NONE fcmovcc 0xDAD8 CPU_686|CPU_FPU +INSN - fcmovnb NONE fcmovcc 0xDBC0 CPU_686|CPU_FPU +INSN - fcmovne NONE fcmovcc 0xDBC8 CPU_686|CPU_FPU +INSN - fcmovnbe NONE fcmovcc 0xDBD0 CPU_686|CPU_FPU +INSN - fcmovnu NONE fcmovcc 0xDBD8 CPU_686|CPU_FPU +INSN - fcomi NONE fcom2 0xDBF0 CPU_686|CPU_FPU +INSN - fucomi NONE fcom2 0xDBE8 CPU_686|CPU_FPU +INSN - fcomip NONE fcom2 0xDFF0 CPU_686|CPU_FPU +INSN - fucomip NONE fcom2 0xDFE8 CPU_686|CPU_FPU +# Pentium4 extensions +INSN - movnti "lq" movnti 0 CPU_P4 +INSN - clflush NONE clflush 0 CPU_P3 +INSN - lfence NONE threebyte 0x0FAEE8 CPU_P3 +INSN - mfence NONE threebyte 0x0FAEF0 CPU_P3 +INSN - pause NONE onebyte_prefix 0xF390 CPU_P4 +# MMX/SSE2 instructions +INSN - emms NONE twobyte 0x0F77 CPU_MMX +INSN - movd NONE movd 0 CPU_MMX +# For GAS movq must use standard mov instruction. +# For NASM it can use a dedicated instruction. +INSN gas movq SUF_Q mov 0 CPU_Any +INSN nasm movq NONE movq 0 CPU_MMX +INSN - packssdw NONE mmxsse2 0x6B CPU_MMX +INSN - packsswb NONE mmxsse2 0x63 CPU_MMX +INSN - packuswb NONE mmxsse2 0x67 CPU_MMX +INSN - paddb NONE mmxsse2 0xFC CPU_MMX +INSN - paddw NONE mmxsse2 0xFD CPU_MMX +INSN - paddd NONE mmxsse2 0xFE CPU_MMX +INSN - paddq NONE mmxsse2 0xD4 CPU_MMX +INSN - paddsb NONE mmxsse2 0xEC CPU_MMX +INSN - paddsw NONE mmxsse2 0xED CPU_MMX +INSN - paddusb NONE mmxsse2 0xDC CPU_MMX +INSN - paddusw NONE mmxsse2 0xDD CPU_MMX +INSN - pand NONE mmxsse2 0xDB CPU_MMX +INSN - pandn NONE mmxsse2 0xDF CPU_MMX +INSN - pcmpeqb NONE mmxsse2 0x74 CPU_MMX +INSN - pcmpeqw NONE mmxsse2 0x75 CPU_MMX +INSN - pcmpeqd NONE mmxsse2 0x76 CPU_MMX +INSN - pcmpgtb NONE mmxsse2 0x64 CPU_MMX +INSN - pcmpgtw NONE mmxsse2 0x65 CPU_MMX +INSN - pcmpgtd NONE mmxsse2 0x66 CPU_MMX +INSN - pmaddwd NONE mmxsse2 0xF5 CPU_MMX +INSN - pmulhw NONE mmxsse2 0xE5 CPU_MMX +INSN - pmullw NONE mmxsse2 0xD5 CPU_MMX +INSN - por NONE mmxsse2 0xEB CPU_MMX +INSN - psllw NONE pshift 0x0671F1 CPU_MMX +INSN - pslld NONE pshift 0x0672F2 CPU_MMX +INSN - psllq NONE pshift 0x0673F3 CPU_MMX +INSN - psraw NONE pshift 0x0471E1 CPU_MMX +INSN - psrad NONE pshift 0x0472E2 CPU_MMX +INSN - psrlw NONE pshift 0x0271D1 CPU_MMX +INSN - psrld NONE pshift 0x0272D2 CPU_MMX +INSN - psrlq NONE pshift 0x0273D3 CPU_MMX +INSN - psubb NONE mmxsse2 0xF8 CPU_MMX +INSN - psubw NONE mmxsse2 0xF9 CPU_MMX +INSN - psubd NONE mmxsse2 0xFA CPU_MMX +INSN - psubq NONE mmxsse2 0xFB CPU_MMX +INSN - psubsb NONE mmxsse2 0xE8 CPU_MMX +INSN - psubsw NONE mmxsse2 0xE9 CPU_MMX +INSN - psubusb NONE mmxsse2 0xD8 CPU_MMX +INSN - psubusw NONE mmxsse2 0xD9 CPU_MMX +INSN - punpckhbw NONE mmxsse2 0x68 CPU_MMX +INSN - punpckhwd NONE mmxsse2 0x69 CPU_MMX +INSN - punpckhdq NONE mmxsse2 0x6A CPU_MMX +INSN - punpcklbw NONE mmxsse2 0x60 CPU_MMX +INSN - punpcklwd NONE mmxsse2 0x61 CPU_MMX +INSN - punpckldq NONE mmxsse2 0x62 CPU_MMX +INSN - pxor NONE mmxsse2 0xEF CPU_MMX +# PIII Katmai new instructions / SIMD instructions +INSN - addps NONE sseps 0x58 CPU_SSE +INSN - addss NONE ssess 0xF358 CPU_SSE +INSN - andnps NONE sseps 0x55 CPU_SSE +INSN - andps NONE sseps 0x54 CPU_SSE +INSN - cmpeqps NONE ssecmpps 0x00 CPU_SSE +INSN - cmpeqss NONE ssecmpss 0x00F3 CPU_SSE +INSN - cmpleps NONE ssecmpps 0x02 CPU_SSE +INSN - cmpless NONE ssecmpss 0x02F3 CPU_SSE +INSN - cmpltps NONE ssecmpps 0x01 CPU_SSE +INSN - cmpltss NONE ssecmpss 0x01F3 CPU_SSE +INSN - cmpneqps NONE ssecmpps 0x04 CPU_SSE +INSN - cmpneqss NONE ssecmpss 0x04F3 CPU_SSE +INSN - cmpnleps NONE ssecmpps 0x06 CPU_SSE +INSN - cmpnless NONE ssecmpss 0x06F3 CPU_SSE +INSN - cmpnltps NONE ssecmpps 0x05 CPU_SSE +INSN - cmpnltss NONE ssecmpss 0x05F3 CPU_SSE +INSN - cmpordps NONE ssecmpps 0x07 CPU_SSE +INSN - cmpordss NONE ssecmpss 0x07F3 CPU_SSE +INSN - cmpunordps NONE ssecmpps 0x03 CPU_SSE +INSN - cmpunordss NONE ssecmpss 0x03F3 CPU_SSE +INSN - cmpps NONE ssepsimm 0xC2 CPU_SSE +INSN - cmpss NONE ssessimm 0xF3C2 CPU_SSE +INSN - comiss NONE sseps 0x2F CPU_SSE +INSN - cvtpi2ps NONE cvt_xmm_mm_ps 0x2A CPU_SSE +INSN - cvtps2pi NONE cvt_mm_xmm64 0x2D CPU_SSE +INSN - cvtsi2ss "lq" cvt_xmm_rmx 0xF32A CPU_SSE +INSN - cvtss2si "lq" cvt_rx_xmm32 0xF32D CPU_SSE +INSN - cvttps2pi NONE cvt_mm_xmm64 0x2C CPU_SSE +INSN - cvttss2si "lq" cvt_rx_xmm32 0xF32C CPU_SSE +INSN - divps NONE sseps 0x5E CPU_SSE +INSN - divss NONE ssess 0xF35E CPU_SSE +INSN - ldmxcsr NONE ldstmxcsr 0x02 CPU_SSE +INSN - maskmovq NONE maskmovq 0 CPU_P3|CPU_MMX +INSN - maxps NONE sseps 0x5F CPU_SSE +INSN - maxss NONE ssess 0xF35F CPU_SSE +INSN - minps NONE sseps 0x5D CPU_SSE +INSN - minss NONE ssess 0xF35D CPU_SSE +INSN - movaps NONE movaups 0x28 CPU_SSE +INSN - movhlps NONE movhllhps 0x12 CPU_SSE +INSN - movhps NONE movhlps 0x16 CPU_SSE +INSN - movlhps NONE movhllhps 0x16 CPU_SSE +INSN - movlps NONE movhlps 0x12 CPU_SSE +INSN - movmskps "lq" movmskps 0 CPU_SSE +INSN - movntps NONE movntps 0 CPU_SSE +INSN - movntq NONE movntq 0 CPU_SSE +INSN - movss NONE movss 0 CPU_SSE +INSN - movups NONE movaups 0x10 CPU_SSE +INSN - mulps NONE sseps 0x59 CPU_SSE +INSN - mulss NONE ssess 0xF359 CPU_SSE +INSN - orps NONE sseps 0x56 CPU_SSE +INSN - pavgb NONE mmxsse2 0xE0 CPU_P3|CPU_MMX +INSN - pavgw NONE mmxsse2 0xE3 CPU_P3|CPU_MMX +INSN - pextrw "lq" pextrw 0 CPU_P3|CPU_MMX +INSN - pinsrw "lq" pinsrw 0 CPU_P3|CPU_MMX +INSN - pmaxsw NONE mmxsse2 0xEE CPU_P3|CPU_MMX +INSN - pmaxub NONE mmxsse2 0xDE CPU_P3|CPU_MMX +INSN - pminsw NONE mmxsse2 0xEA CPU_P3|CPU_MMX +INSN - pminub NONE mmxsse2 0xDA CPU_P3|CPU_MMX +INSN - pmovmskb "lq" pmovmskb 0 CPU_SSE +INSN - pmulhuw NONE mmxsse2 0xE4 CPU_P3|CPU_MMX +INSN - prefetchnta NONE twobytemem 0x000F18 CPU_P3 +INSN - prefetcht0 NONE twobytemem 0x010F18 CPU_P3 +INSN - prefetcht1 NONE twobytemem 0x020F18 CPU_P3 +INSN - prefetcht2 NONE twobytemem 0x030F18 CPU_P3 +INSN - psadbw NONE mmxsse2 0xF6 CPU_P3|CPU_MMX +INSN - pshufw NONE pshufw 0 CPU_P3|CPU_MMX +INSN - rcpps NONE sseps 0x53 CPU_SSE +INSN - rcpss NONE ssess 0xF353 CPU_SSE +INSN - rsqrtps NONE sseps 0x52 CPU_SSE +INSN - rsqrtss NONE ssess 0xF352 CPU_SSE +INSN - sfence NONE threebyte 0x0FAEF8 CPU_P3 +INSN - shufps NONE ssepsimm 0xC6 CPU_SSE +INSN - sqrtps NONE sseps 0x51 CPU_SSE +INSN - sqrtss NONE ssess 0xF351 CPU_SSE +INSN - stmxcsr NONE ldstmxcsr 0x03 CPU_SSE +INSN - subps NONE sseps 0x5C CPU_SSE +INSN - subss NONE ssess 0xF35C CPU_SSE +INSN - ucomiss NONE ssess 0x2E CPU_SSE +INSN - unpckhps NONE sseps 0x15 CPU_SSE +INSN - unpcklps NONE sseps 0x14 CPU_SSE +INSN - xorps NONE sseps 0x57 CPU_SSE +# SSE2 instructions +INSN - addpd NONE ssess 0x6658 CPU_SSE2 +INSN - addsd NONE ssess 0xF258 CPU_SSE2 +INSN - andnpd NONE ssess 0x6655 CPU_SSE2 +INSN - andpd NONE ssess 0x6654 CPU_SSE2 +INSN - cmpeqpd NONE ssecmpss 0x0066 CPU_SSE2 +INSN - cmpeqsd NONE ssecmpss 0x00F2 CPU_SSE2 +INSN - cmplepd NONE ssecmpss 0x0266 CPU_SSE2 +INSN - cmplesd NONE ssecmpss 0x02F2 CPU_SSE2 +INSN - cmpltpd NONE ssecmpss 0x0166 CPU_SSE2 +INSN - cmpltsd NONE ssecmpss 0x01F2 CPU_SSE2 +INSN - cmpneqpd NONE ssecmpss 0x0466 CPU_SSE2 +INSN - cmpneqsd NONE ssecmpss 0x04F2 CPU_SSE2 +INSN - cmpnlepd NONE ssecmpss 0x0666 CPU_SSE2 +INSN - cmpnlesd NONE ssecmpss 0x06F2 CPU_SSE2 +INSN - cmpnltpd NONE ssecmpss 0x0566 CPU_SSE2 +INSN - cmpnltsd NONE ssecmpss 0x05F2 CPU_SSE2 +INSN - cmpordpd NONE ssecmpss 0x0766 CPU_SSE2 +INSN - cmpordsd NONE ssecmpss 0x07F2 CPU_SSE2 +INSN - cmpunordpd NONE ssecmpss 0x0366 CPU_SSE2 +INSN - cmpunordsd NONE ssecmpss 0x03F2 CPU_SSE2 +INSN - cmppd NONE ssessimm 0x66C2 CPU_SSE2 +# cmpsd is in string instructions above +INSN - comisd NONE ssess 0x662F CPU_SSE2 +INSN - cvtpi2pd NONE cvt_xmm_mm_ss 0x662A CPU_SSE2 +INSN - cvtsi2sd "lq" cvt_xmm_rmx 0xF22A CPU_SSE2 +INSN - divpd NONE ssess 0x665E CPU_SSE2 +INSN - divsd NONE ssess 0xF25E CPU_SSE2 +INSN - maxpd NONE ssess 0x665F CPU_SSE2 +INSN - maxsd NONE ssess 0xF25F CPU_SSE2 +INSN - minpd NONE ssess 0x665D CPU_SSE2 +INSN - minsd NONE ssess 0xF25D CPU_SSE2 +INSN - movapd NONE movaupd 0x28 CPU_SSE2 +INSN - movhpd NONE movhlpd 0x16 CPU_SSE2 +INSN - movlpd NONE movhlpd 0x12 CPU_SSE2 +INSN - movmskpd "lq" movmskpd 0 CPU_SSE2 +INSN - movntpd NONE movntpddq 0x2B CPU_SSE2 +INSN - movntdq NONE movntpddq 0xE7 CPU_SSE2 +# movsd is in string instructions above +INSN - movupd NONE movaupd 0x10 CPU_SSE2 +INSN - mulpd NONE ssess 0x6659 CPU_SSE2 +INSN - mulsd NONE ssess 0xF259 CPU_SSE2 +INSN - orpd NONE ssess 0x6656 CPU_SSE2 +INSN - shufpd NONE ssessimm 0x66C6 CPU_SSE2 +INSN - sqrtpd NONE ssess 0x6651 CPU_SSE2 +INSN - sqrtsd NONE ssess 0xF251 CPU_SSE2 +INSN - subpd NONE ssess 0x665C CPU_SSE2 +INSN - subsd NONE ssess 0xF25C CPU_SSE2 +INSN - ucomisd NONE ssess 0x662E CPU_SSE2 +INSN - unpckhpd NONE ssess 0x6615 CPU_SSE2 +INSN - unpcklpd NONE ssess 0x6614 CPU_SSE2 +INSN - xorpd NONE ssess 0x6657 CPU_SSE2 +INSN - cvtdq2pd NONE cvt_xmm_xmm64_ss 0xF3E6 CPU_SSE2 +INSN - cvtpd2dq NONE ssess 0xF2E6 CPU_SSE2 +INSN - cvtdq2ps NONE sseps 0x5B CPU_SSE2 +INSN - cvtpd2pi NONE cvt_mm_xmm 0x662D CPU_SSE2 +INSN - cvtpd2ps NONE ssess 0x665A CPU_SSE2 +INSN - cvtps2pd NONE cvt_xmm_xmm64_ps 0x5A CPU_SSE2 +INSN - cvtps2dq NONE ssess 0x665B CPU_SSE2 +INSN - cvtsd2si "lq" cvt_rx_xmm64 0xF22D CPU_SSE2 +INSN - cvtsd2ss NONE cvt_xmm_xmm64_ss 0xF25A CPU_SSE2 +# P4 VMX Instructions +INSN - vmcall NONE threebyte 0x0F01C1 CPU_P4 +INSN - vmlaunch NONE threebyte 0x0F01C2 CPU_P4 +INSN - vmresume NONE threebyte 0x0F01C3 CPU_P4 +INSN - vmxoff NONE threebyte 0x0F01C4 CPU_P4 +INSN - vmread "lq" vmxmemrd 0x0F78 CPU_P4 +INSN - vmwrite "lq" vmxmemwr 0x0F79 CPU_P4 +INSN - vmptrld NONE vmxtwobytemem 0x06C7 CPU_P4 +INSN - vmptrst NONE vmxtwobytemem 0x07C7 CPU_P4 +INSN - vmclear NONE vmxthreebytemem 0x0666C7 CPU_P4 +INSN - vmxon NONE vmxthreebytemem 0x06F3C7 CPU_P4 +INSN - cvtss2sd NONE cvt_xmm_xmm32 0xF35A CPU_SSE2 +INSN - cvttpd2pi NONE cvt_mm_xmm 0x662C CPU_SSE2 +INSN - cvttsd2si "lq" cvt_rx_xmm64 0xF22C CPU_SSE2 +INSN - cvttpd2dq NONE ssess 0x66E6 CPU_SSE2 +INSN - cvttps2dq NONE ssess 0xF35B CPU_SSE2 +INSN - maskmovdqu NONE maskmovdqu 0 CPU_SSE2 +INSN - movdqa NONE movdqau 0x66 CPU_SSE2 +INSN - movdqu NONE movdqau 0xF3 CPU_SSE2 +INSN - movdq2q NONE movdq2q 0 CPU_SSE2 +INSN - movq2dq NONE movq2dq 0 CPU_SSE2 +INSN - pmuludq NONE mmxsse2 0xF4 CPU_SSE2 +INSN - pshufd NONE ssessimm 0x6670 CPU_SSE2 +INSN - pshufhw NONE ssessimm 0xF370 CPU_SSE2 +INSN - pshuflw NONE ssessimm 0xF270 CPU_SSE2 +INSN - pslldq NONE pslrldq 0x07 CPU_SSE2 +INSN - psrldq NONE pslrldq 0x03 CPU_SSE2 +INSN - punpckhqdq NONE ssess 0x666D CPU_SSE2 +INSN - punpcklqdq NONE ssess 0x666C CPU_SSE2 +# SSE3 / PNI Prescott New Instructions instructions +INSN - addsubpd NONE ssess 0x66D0 CPU_SSE3 +INSN - addsubps NONE ssess 0xF2D0 CPU_SSE3 +INSN - fisttp "lqs" fildstp 0x010001 CPU_SSE3 +INSN gas fisttpll SUF_Q fildstp 0x07 CPU_FPU +INSN - haddpd NONE ssess 0x667C CPU_SSE3 +INSN - haddps NONE ssess 0xF27C CPU_SSE3 +INSN - hsubpd NONE ssess 0x667D CPU_SSE3 +INSN - hsubps NONE ssess 0xF27D CPU_SSE3 +INSN - lddqu NONE lddqu 0 CPU_SSE3 +INSN - monitor NONE threebyte 0x0F01C8 CPU_SSE3 +INSN - movddup NONE cvt_xmm_xmm64_ss 0xF212 CPU_SSE3 +INSN - movshdup NONE ssess 0xF316 CPU_SSE3 +INSN - movsldup NONE ssess 0xF312 CPU_SSE3 +INSN - mwait NONE threebyte 0x0F01C9 CPU_SSE3 +# SSSE3 / TNI Tejas New Intructions instructions +INSN - pshufb NONE ssse3 0x00 CPU_SSSE3 +INSN - phaddw NONE ssse3 0x01 CPU_SSSE3 +INSN - phaddd NONE ssse3 0x02 CPU_SSSE3 +INSN - phaddsw NONE ssse3 0x03 CPU_SSSE3 +INSN - pmaddubsw NONE ssse3 0x04 CPU_SSSE3 +INSN - phsubw NONE ssse3 0x05 CPU_SSSE3 +INSN - phsubd NONE ssse3 0x06 CPU_SSSE3 +INSN - phsubsw NONE ssse3 0x07 CPU_SSSE3 +INSN - psignb NONE ssse3 0x08 CPU_SSSE3 +INSN - psignw NONE ssse3 0x09 CPU_SSSE3 +INSN - psignd NONE ssse3 0x0A CPU_SSSE3 +INSN - pmulhrsw NONE ssse3 0x0B CPU_SSSE3 +INSN - pabsb NONE ssse3 0x1C CPU_SSSE3 +INSN - pabsw NONE ssse3 0x1D CPU_SSSE3 +INSN - pabsd NONE ssse3 0x1E CPU_SSSE3 +INSN - palignr NONE ssse3imm 0x0F CPU_SSSE3 +# SSE4.1 / SSE4.2 instructions +INSN - blendpd NONE sse4imm 0x0D CPU_SSE41 +INSN - blendps NONE sse4imm 0x0C CPU_SSE41 +INSN - blendvpd NONE sse4xmm0 0x15 CPU_SSE41 +INSN - blendvps NONE sse4xmm0 0x14 CPU_SSE41 +INSN - crc32 "bwlq" crc32 0 CPU_SSE42 +INSN - dppd NONE sse4imm 0x41 CPU_SSE41 +INSN - dpps NONE sse4imm 0x40 CPU_SSE41 +INSN - extractps NONE extractps 0 CPU_SSE41 +INSN - insertps NONE insertps 0 CPU_SSE41 +INSN - movntdqa NONE movntdqa 0 CPU_SSE41 +INSN - mpsadbw NONE sse4imm 0x42 CPU_SSE41 +INSN - packusdw NONE sse4 0x2B CPU_SSE41 +INSN - pblendvb NONE sse4xmm0 0x10 CPU_SSE41 +INSN - pblendw NONE sse4imm 0x0E CPU_SSE41 +INSN - pcmpeqq NONE sse4 0x29 CPU_SSE41 +INSN - pcmpestri "wlq" sse4pcmpstr 0x61 CPU_SSE42 +INSN - pcmpestrm "wlq" sse4pcmpstr 0x60 CPU_SSE42 +INSN - pcmpistri "wlq" sse4pcmpstr 0x63 CPU_SSE42 +INSN - pcmpistrm "wlq" sse4pcmpstr 0x62 CPU_SSE42 +INSN - pcmpgtq NONE sse4 0x37 CPU_SSE42 +INSN - pextrb NONE pextrb 0 CPU_SSE41 +INSN - pextrd NONE pextrd 0 CPU_SSE41 +INSN - pextrq NONE pextrq 0 CPU_SSE41 +#INSN - pextrw NONE pextrw 0 CPU_SSE41 +INSN - phminposuw NONE sse4 0x41 CPU_SSE41 +INSN - pinsrb NONE pinsrb 0 CPU_SSE41 +INSN - pinsrd NONE pinsrd 0 CPU_SSE41 +INSN - pinsrq NONE pinsrq 0 CPU_SSE41 +INSN - pmaxsb NONE sse4 0x3C CPU_SSE41 +INSN - pmaxsd NONE sse4 0x3D CPU_SSE41 +INSN - pmaxud NONE sse4 0x3F CPU_SSE41 +INSN - pmaxuw NONE sse4 0x3E CPU_SSE41 +INSN - pminsb NONE sse4 0x38 CPU_SSE41 +INSN - pminsd NONE sse4 0x39 CPU_SSE41 +INSN - pminud NONE sse4 0x3B CPU_SSE41 +INSN - pminuw NONE sse4 0x3A CPU_SSE41 +INSN - pmovsxbw NONE sse4m64 0x20 CPU_SSE41 +INSN - pmovsxbd NONE sse4m32 0x21 CPU_SSE41 +INSN - pmovsxbq NONE sse4m16 0x22 CPU_SSE41 +INSN - pmovsxwd NONE sse4m64 0x23 CPU_SSE41 +INSN - pmovsxwq NONE sse4m32 0x24 CPU_SSE41 +INSN - pmovsxdq NONE sse4m64 0x25 CPU_SSE41 +INSN - pmovzxbw NONE sse4m64 0x30 CPU_SSE41 +INSN - pmovzxbd NONE sse4m32 0x31 CPU_SSE41 +INSN - pmovzxbq NONE sse4m16 0x32 CPU_SSE41 +INSN - pmovzxwd NONE sse4m64 0x33 CPU_SSE41 +INSN - pmovzxwq NONE sse4m32 0x34 CPU_SSE41 +INSN - pmovzxdq NONE sse4m64 0x35 CPU_SSE41 +INSN - pmuldq NONE sse4 0x28 CPU_SSE41 +INSN - pmulld NONE sse4 0x40 CPU_SSE41 +INSN - popcnt "wlq" popcnt 0 CPU_SSE42 +INSN - ptest NONE sse4 0x17 CPU_SSE41 +INSN - roundpd NONE sse4imm 0x09 CPU_SSE41 +INSN - roundps NONE sse4imm 0x08 CPU_SSE41 +INSN - roundsd NONE sse4imm 0x0B CPU_SSE41 +INSN - roundss NONE sse4imm 0x0A CPU_SSE41 +# AMD 3DNow! instructions +INSN - prefetch NONE twobytemem 0x000F0D CPU_3DNow +INSN - prefetchw NONE twobytemem 0x010F0D CPU_3DNow +INSN - femms NONE twobyte 0x0F0E CPU_3DNow +INSN - pavgusb NONE now3d 0xBF CPU_3DNow +INSN - pf2id NONE now3d 0x1D CPU_3DNow +INSN - pf2iw NONE now3d 0x1C CPU_Athlon|CPU_3DNow +INSN - pfacc NONE now3d 0xAE CPU_3DNow +INSN - pfadd NONE now3d 0x9E CPU_3DNow +INSN - pfcmpeq NONE now3d 0xB0 CPU_3DNow +INSN - pfcmpge NONE now3d 0x90 CPU_3DNow +INSN - pfcmpgt NONE now3d 0xA0 CPU_3DNow +INSN - pfmax NONE now3d 0xA4 CPU_3DNow +INSN - pfmin NONE now3d 0x94 CPU_3DNow +INSN - pfmul NONE now3d 0xB4 CPU_3DNow +INSN - pfnacc NONE now3d 0x8A CPU_Athlon|CPU_3DNow +INSN - pfpnacc NONE now3d 0x8E CPU_Athlon|CPU_3DNow +INSN - pfrcp NONE now3d 0x96 CPU_3DNow +INSN - pfrcpit1 NONE now3d 0xA6 CPU_3DNow +INSN - pfrcpit2 NONE now3d 0xB6 CPU_3DNow +INSN - pfrsqit1 NONE now3d 0xA7 CPU_3DNow +INSN - pfrsqrt NONE now3d 0x97 CPU_3DNow +INSN - pfsub NONE now3d 0x9A CPU_3DNow +INSN - pfsubr NONE now3d 0xAA CPU_3DNow +INSN - pi2fd NONE now3d 0x0D CPU_3DNow +INSN - pi2fw NONE now3d 0x0C CPU_Athlon|CPU_3DNow +INSN - pmulhrwa NONE now3d 0xB7 CPU_3DNow +INSN - pswapd NONE now3d 0xBB CPU_Athlon|CPU_3DNow +# AMD extensions +INSN - syscall NONE twobyte 0x0F05 CPU_686|CPU_AMD +INSN - sysret "lq" twobyte 0x0F07 CPU_686|CPU_AMD|CPU_Priv +# AMD x86-64 extensions +INSN - swapgs NONE threebyte 0x0F01F8 CPU_Hammer|CPU_64 +INSN - rdtscp NONE threebyte 0x0F01F9 CPU_686|CPU_AMD|CPU_Priv +INSN - cmpxchg16b NONE cmpxchg16b 0 CPU_Hammer|CPU_64 +# AMD Pacifica SVM instructions +INSN - clgi NONE threebyte 0x0F01DD CPU_SVM +INSN - invlpga NONE invlpga 0 CPU_SVM +INSN - skinit NONE skinit 0 CPU_SVM +INSN - stgi NONE threebyte 0x0F01DC CPU_SVM +INSN - vmload NONE svm_rax 0xDA CPU_SVM +INSN - vmmcall NONE threebyte 0x0F01D9 CPU_SVM +INSN - vmrun NONE svm_rax 0xD8 CPU_SVM +INSN - vmsave NONE svm_rax 0xDB CPU_SVM +# VIA PadLock instructions +INSN - xstore NONE padlock 0xC000A7 CPU_PadLock +INSN - xstorerng NONE padlock 0xC000A7 CPU_PadLock +INSN - xcryptecb NONE padlock 0xC8F3A7 CPU_PadLock +INSN - xcryptcbc NONE padlock 0xD0F3A7 CPU_PadLock +INSN - xcryptctr NONE padlock 0xD8F3A7 CPU_PadLock +INSN - xcryptcfb NONE padlock 0xE0F3A7 CPU_PadLock +INSN - xcryptofb NONE padlock 0xE8F3A7 CPU_PadLock +INSN - montmul NONE padlock 0xC0F3A6 CPU_PadLock +INSN - xsha1 NONE padlock 0xC8F3A6 CPU_PadLock +INSN - xsha256 NONE padlock 0xD0F3A6 CPU_PadLock +# Cyrix MMX instructions +INSN - paddsiw NONE cyrixmmx 0x51 CPU_Cyrix|CPU_MMX +INSN - paveb NONE cyrixmmx 0x50 CPU_Cyrix|CPU_MMX +INSN - pdistib NONE cyrixmmx 0x54 CPU_Cyrix|CPU_MMX +INSN - pmachriw NONE pmachriw 0 CPU_Cyrix|CPU_MMX +INSN - pmagw NONE cyrixmmx 0x52 CPU_Cyrix|CPU_MMX +INSN - pmulhriw NONE cyrixmmx 0x5D CPU_Cyrix|CPU_MMX +INSN - pmulhrwc NONE cyrixmmx 0x59 CPU_Cyrix|CPU_MMX +INSN - pmvgezb NONE cyrixmmx 0x5C CPU_Cyrix|CPU_MMX +INSN - pmvlzb NONE cyrixmmx 0x5B CPU_Cyrix|CPU_MMX +INSN - pmvnzb NONE cyrixmmx 0x5A CPU_Cyrix|CPU_MMX +INSN - pmvzb NONE cyrixmmx 0x58 CPU_Cyrix|CPU_MMX +INSN - psubsiw NONE cyrixmmx 0x55 CPU_Cyrix|CPU_MMX +# Cyrix extensions +INSN - rdshr NONE rdwrshr 0x00 CPU_686|CPU_Cyrix|CPU_SMM +INSN - rsdc NONE rsdc 0 CPU_486|CPU_Cyrix|CPU_SMM +INSN - rsldt NONE cyrixsmm 0x7B CPU_486|CPU_Cyrix|CPU_SMM +INSN - rsts NONE cyrixsmm 0x7D CPU_486|CPU_Cyrix|CPU_SMM +INSN - svdc NONE svdc 0 CPU_486|CPU_Cyrix|CPU_SMM +INSN - svldt NONE cyrixsmm 0x7A CPU_486|CPU_Cyrix|CPU_SMM +INSN - svts NONE cyrixsmm 0x7C CPU_486|CPU_Cyrix|CPU_SMM +INSN - smint NONE twobyte 0x0F38 CPU_686|CPU_Cyrix +INSN - smintold NONE twobyte 0x0F7E CPU_486|CPU_Cyrix|CPU_Obs +INSN - wrshr NONE rdwrshr 0x01 CPU_686|CPU_Cyrix|CPU_SMM +# Obsolete/undocumented instructions +INSN - fsetpm NONE twobyte 0xDBE4 CPU_286|CPU_FPU|CPU_Obs +INSN - ibts NONE ibts 0 CPU_386|CPU_Undoc|CPU_Obs +INSN - loadall NONE twobyte 0x0F07 CPU_386|CPU_Undoc +INSN - loadall286 NONE twobyte 0x0F05 CPU_286|CPU_Undoc +INSN - salc NONE onebyte 0x00D6 CPU_Undoc|CPU_Not64 +INSN - smi NONE onebyte 0x00F1 CPU_386|CPU_Undoc +INSN - umov NONE umov 0 CPU_386|CPU_Undoc +INSN - xbts NONE xbts 0 CPU_386|CPU_Undoc|CPU_Obs + + +# DEF_CPU parameters: +# - CPU name +# - CPU flags to set +# DEF_CPU_ALIAS parameters: +# - CPU alias name +# - CPU base name +# DEF_CPU_FEATURE parameters: +# - CPU feature name +# - CPU flag to set feature name alone or unset ("no" + feature name) + +# The standard CPU names /set/ cpu_enabled. +CPU 8086 CPU_Priv +CPU 186 CPU_186|CPU_Priv +CPU_ALIAS 80186 186 +CPU_ALIAS i186 186 +CPU 286 CPU_186|CPU_286|CPU_Priv +CPU_ALIAS 80286 286 +CPU_ALIAS i286 286 +CPU 386 CPU_186|CPU_286|CPU_386|CPU_SMM|CPU_Prot|CPU_Priv +CPU_ALIAS 80386 386 +CPU_ALIAS i386 386 +CPU 486 CPU_186|CPU_286|CPU_386|CPU_486|CPU_FPU|CPU_SMM|\ + CPU_Prot|CPU_Priv +CPU_ALIAS 80486 486 +CPU_ALIAS i486 486 +CPU 586 CPU_186|CPU_286|CPU_386|CPU_486|CPU_586|CPU_FPU|\ + CPU_SMM|CPU_Prot|CPU_Priv +CPU_ALIAS i586 586 +CPU_ALIAS pentium 586 +CPU_ALIAS p5 586 +CPU 686 CPU_186|CPU_286|CPU_386|CPU_486|CPU_586|CPU_686|\ + CPU_FPU|CPU_SMM|CPU_Prot|CPU_Priv +CPU_ALIAS i686 686 +CPU_ALIAS p6 686 +CPU_ALIAS ppro 686 +CPU_ALIAS pentiumpro 686 +CPU p2 CPU_186|CPU_286|CPU_386|CPU_486|CPU_586|CPU_686|\ + CPU_FPU|CPU_MMX|CPU_SMM|CPU_Prot|CPU_Priv +CPU_ALIAS pentium2 p2 +CPU_ALIAS pentium-2 p2 +CPU_ALIAS pentiumii p2 +CPU_ALIAS pentium-ii p2 +CPU p3 CPU_186|CPU_286|CPU_386|CPU_486|CPU_586|CPU_686|\ + CPU_P3|CPU_FPU|CPU_MMX|CPU_SSE|CPU_SMM|CPU_Prot|\ + CPU_Priv +CPU_ALIAS pentium3 p3 +CPU_ALIAS pentium-3 p3 +CPU_ALIAS pentiumiii p3 +CPU_ALIAS pentium-iii p3 +CPU_ALIAS katmai p3 +CPU p4 CPU_186|CPU_286|CPU_386|CPU_486|CPU_586|CPU_686|\ + CPU_P3|CPU_P4|CPU_FPU|CPU_MMX|CPU_SSE|CPU_SSE2|\ + CPU_SMM|CPU_Prot|CPU_Priv +CPU_ALIAS pentium4 p4 +CPU_ALIAS pentium-4 p4 +CPU_ALIAS pentiumiv p4 +CPU_ALIAS pentium-iv p4 +CPU_ALIAS williamette p4 +CPU ia64 CPU_186|CPU_286|CPU_386|CPU_486|CPU_586|CPU_686|\ + CPU_P3|CPU_P4|CPU_IA64|CPU_FPU|CPU_MMX|CPU_SSE|\ + CPU_SSE2|CPU_SMM|CPU_Prot|CPU_Priv +CPU_ALIAS ia-64 ia64 +CPU_ALIAS itanium ia64 +CPU k6 CPU_186|CPU_286|CPU_386|CPU_486|CPU_586|CPU_686|\ + CPU_K6|CPU_FPU|CPU_MMX|CPU_3DNow|CPU_SMM|CPU_Prot|\ + CPU_Priv +CPU k7 CPU_186|CPU_286|CPU_386|CPU_486|CPU_586|CPU_686|\ + CPU_K6|CPU_Athlon|CPU_FPU|CPU_MMX|CPU_SSE|CPU_3DNow|\ + CPU_SMM|CPU_Prot|CPU_Priv +CPU_ALIAS athlon k7 +CPU hammer CPU_186|CPU_286|CPU_386|CPU_486|CPU_586|CPU_686|\ + CPU_K6|CPU_Athlon|CPU_Hammer|CPU_FPU|CPU_MMX|\ + CPU_SSE|CPU_SSE2|CPU_3DNow|CPU_SMM|CPU_Prot|\ + CPU_Priv +CPU_ALIAS sledgehammer hammer +CPU_ALIAS opteron hammer +CPU_ALIAS athlon64 hammer +CPU_ALIAS athlon-64 hammer +CPU prescott CPU_186|CPU_286|CPU_386|CPU_486|CPU_586|CPU_686|\ + CPU_Hammer|CPU_EM64T|CPU_FPU|CPU_MMX|\ + CPU_SSE|CPU_SSE2|CPU_SSE3|CPU_SMM|\ + CPU_Prot|CPU_Priv +CPU conroe CPU_186|CPU_286|CPU_386|CPU_486|CPU_586|CPU_686|\ + CPU_Hammer|CPU_EM64T|CPU_FPU|CPU_MMX|\ + CPU_SSE|CPU_SSE2|CPU_SSE3|CPU_SSSE3|CPU_SMM|\ + CPU_Prot|CPU_Priv +CPU penryn CPU_186|CPU_286|CPU_386|CPU_486|CPU_586|CPU_686|\ + CPU_Hammer|CPU_EM64T|CPU_FPU|CPU_MMX|\ + CPU_SSE|CPU_SSE2|CPU_SSE3|CPU_SSSE3|CPU_SSE41|CPU_SMM|\ + CPU_Prot|CPU_Priv +CPU nehalem CPU_186|CPU_286|CPU_386|CPU_486|CPU_586|CPU_686|\ + CPU_Hammer|CPU_EM64T|CPU_FPU|CPU_MMX|\ + CPU_SSE|CPU_SSE2|CPU_SSE3|CPU_SSSE3|CPU_SSE41|\ + CPU_SSE42|CPU_SMM|CPU_Prot|CPU_Priv + +# Features have "no" versions to disable them, and only set/reset the +# specific feature being changed. All other bits are left alone. + +CPU_FEATURE fpu CPU_FPU +CPU_FEATURE mmx CPU_MMX +CPU_FEATURE sse CPU_SSE +CPU_FEATURE sse2 CPU_SSE2 +CPU_FEATURE sse3 CPU_SSE3 +#CPU_FEATURE pni CPU_PNI +CPU_FEATURE 3dnow CPU_3DNow +CPU_FEATURE cyrix CPU_Cyrix +CPU_FEATURE amd CPU_AMD +CPU_FEATURE smm CPU_SMM +CPU_FEATURE prot CPU_Prot +CPU_FEATURE protected CPU_Prot +CPU_FEATURE undoc CPU_Undoc +CPU_FEATURE undocumented CPU_Undoc +CPU_FEATURE obs CPU_Obs +CPU_FEATURE obsolete CPU_Obs +CPU_FEATURE priv CPU_Priv +CPU_FEATURE privileged CPU_Priv +CPU_FEATURE svm CPU_SVM +CPU_FEATURE padlock CPU_PadLock +CPU_FEATURE em64t CPU_EM64T +CPU_FEATURE ssse3 CPU_SSSE3 +CPU_FEATURE sse4.1 CPU_SSE41 +CPU_FEATURE sse4.2 CPU_SSE42 +CPU_FEATURE sse4 CPU_SSE4 + + +# TARGETMOD parameters: +# - target modifier name +# - modifier to return + +TARGETMOD near X86_NEAR +TARGETMOD short X86_SHORT +TARGETMOD far X86_FAR +TARGETMOD to X86_TO + + +# PREFIX parameters: +# - parser +# - prefix name +# - prefix type +# - prefix value + +# operand size overrides +PREFIX nasm o16 X86_OPERSIZE 16 +PREFIX gas data16 X86_OPERSIZE 16 +PREFIX gas word X86_OPERSIZE 16 +PREFIX nasm o32 X86_OPERSIZE 32 +PREFIX gas data32 X86_OPERSIZE 32 +PREFIX gas dword X86_OPERSIZE 32 +PREFIX nasm o64 X86_OPERSIZE 64 +PREFIX gas data64 X86_OPERSIZE 64 +PREFIX gas qword X86_OPERSIZE 64 + +# address size overrides +PREFIX nasm a16 X86_ADDRSIZE 16 +PREFIX gas addr16 X86_ADDRSIZE 16 +PREFIX gas aword X86_ADDRSIZE 16 +PREFIX nasm a32 X86_ADDRSIZE 32 +PREFIX gas addr32 X86_ADDRSIZE 32 +PREFIX gas adword X86_ADDRSIZE 32 +PREFIX nasm a64 X86_ADDRSIZE 64 +PREFIX gas addr64 X86_ADDRSIZE 64 +PREFIX gas aqword X86_ADDRSIZE 64 + +# instruction prefixes +PREFIX - lock X86_LOCKREP 0xF0 +PREFIX - repne X86_LOCKREP 0xF2 +PREFIX - repnz X86_LOCKREP 0xF2 +PREFIX - rep X86_LOCKREP 0xF3 +PREFIX - repe X86_LOCKREP 0xF3 +PREFIX - repz X86_LOCKREP 0xF3 + +# other prefixes, limited to GAS-only at the moment +# Hint taken/not taken for jumps +PREFIX gas ht X86_SEGREG 0x3E +PREFIX gas hnt X86_SEGREG 0x2E + +# REX byte explicit prefixes +PREFIX gas rex X86_REX 0x40 +PREFIX gas rexz X86_REX 0x41 +PREFIX gas rexy X86_REX 0x42 +PREFIX gas rexyz X86_REX 0x43 +PREFIX gas rexx X86_REX 0x44 +PREFIX gas rexxz X86_REX 0x45 +PREFIX gas rexxy X86_REX 0x46 +PREFIX gas rexxyz X86_REX 0x47 +PREFIX gas rex64 X86_REX 0x48 +PREFIX gas rex64z X86_REX 0x49 +PREFIX gas rex64y X86_REX 0x4A +PREFIX gas rex64yz X86_REX 0x4B +PREFIX gas rex64x X86_REX 0x4C +PREFIX gas rex64xz X86_REX 0x4D +PREFIX gas rex64xy X86_REX 0x4E +PREFIX gas rex64xyz X86_REX 0x4F + + +# REG parameters: +# - register name +# - register type +# - register index +# - required BITS setting (0 for any) +# +# REGGROUP parameters: +# - register group name +# - register group type +# +# SEGREG parameters: +# - segment register name +# - prefix encoding +# - register encoding +# - BITS in which the segment is ignored + +# control, debug, and test registers +REG cr0 X86_CRREG 0 0 +REG cr2 X86_CRREG 2 0 +REG cr3 X86_CRREG 3 0 +REG cr4 X86_CRREG 4 0 +REG cr8 X86_CRREG 8 64 + +REG dr0 X86_DRREG 0 0 +REG dr1 X86_DRREG 1 0 +REG dr2 X86_DRREG 2 0 +REG dr3 X86_DRREG 3 0 +REG dr4 X86_DRREG 4 0 +REG dr5 X86_DRREG 5 0 +REG dr6 X86_DRREG 6 0 +REG dr7 X86_DRREG 7 0 + +REG tr0 X86_TRREG 0 0 +REG tr1 X86_TRREG 1 0 +REG tr2 X86_TRREG 2 0 +REG tr3 X86_TRREG 3 0 +REG tr4 X86_TRREG 4 0 +REG tr5 X86_TRREG 5 0 +REG tr6 X86_TRREG 6 0 +REG tr7 X86_TRREG 7 0 + +# floating point, MMX, and SSE/SSE2 registers +REG st0 X86_FPUREG 0 0 +REG st1 X86_FPUREG 1 0 +REG st2 X86_FPUREG 2 0 +REG st3 X86_FPUREG 3 0 +REG st4 X86_FPUREG 4 0 +REG st5 X86_FPUREG 5 0 +REG st6 X86_FPUREG 6 0 +REG st7 X86_FPUREG 7 0 + +REG mm0 X86_MMXREG 0 0 +REG mm1 X86_MMXREG 1 0 +REG mm2 X86_MMXREG 2 0 +REG mm3 X86_MMXREG 3 0 +REG mm4 X86_MMXREG 4 0 +REG mm5 X86_MMXREG 5 0 +REG mm6 X86_MMXREG 6 0 +REG mm7 X86_MMXREG 7 0 + +REG xmm0 X86_XMMREG 0 0 +REG xmm1 X86_XMMREG 1 0 +REG xmm2 X86_XMMREG 2 0 +REG xmm3 X86_XMMREG 3 0 +REG xmm4 X86_XMMREG 4 0 +REG xmm5 X86_XMMREG 5 0 +REG xmm6 X86_XMMREG 6 0 +REG xmm7 X86_XMMREG 7 0 +REG xmm8 X86_XMMREG 8 64 +REG xmm9 X86_XMMREG 9 64 +REG xmm10 X86_XMMREG 10 64 +REG xmm11 X86_XMMREG 11 64 +REG xmm12 X86_XMMREG 12 64 +REG xmm13 X86_XMMREG 13 64 +REG xmm14 X86_XMMREG 14 64 +REG xmm15 X86_XMMREG 15 64 + +# integer registers +REG rax X86_REG64 0 64 +REG rcx X86_REG64 1 64 +REG rdx X86_REG64 2 64 +REG rbx X86_REG64 3 64 +REG rsp X86_REG64 4 64 +REG rbp X86_REG64 5 64 +REG rsi X86_REG64 6 64 +REG rdi X86_REG64 7 64 +REG r8 X86_REG64 8 64 +REG r9 X86_REG64 9 64 +REG r10 X86_REG64 10 64 +REG r11 X86_REG64 11 64 +REG r12 X86_REG64 12 64 +REG r13 X86_REG64 13 64 +REG r14 X86_REG64 14 64 +REG r15 X86_REG64 15 64 + +REG eax X86_REG32 0 0 +REG ecx X86_REG32 1 0 +REG edx X86_REG32 2 0 +REG ebx X86_REG32 3 0 +REG esp X86_REG32 4 0 +REG ebp X86_REG32 5 0 +REG esi X86_REG32 6 0 +REG edi X86_REG32 7 0 +REG r8d X86_REG32 8 64 +REG r9d X86_REG32 9 64 +REG r10d X86_REG32 10 64 +REG r11d X86_REG32 11 64 +REG r12d X86_REG32 12 64 +REG r13d X86_REG32 13 64 +REG r14d X86_REG32 14 64 +REG r15d X86_REG32 15 64 + +REG ax X86_REG16 0 0 +REG cx X86_REG16 1 0 +REG dx X86_REG16 2 0 +REG bx X86_REG16 3 0 +REG sp X86_REG16 4 0 +REG bp X86_REG16 5 0 +REG si X86_REG16 6 0 +REG di X86_REG16 7 0 +REG r8w X86_REG16 8 64 +REG r9w X86_REG16 9 64 +REG r10w X86_REG16 10 64 +REG r11w X86_REG16 11 64 +REG r12w X86_REG16 12 64 +REG r13w X86_REG16 13 64 +REG r14w X86_REG16 14 64 +REG r15w X86_REG16 15 64 + +REG al X86_REG8 0 0 +REG cl X86_REG8 1 0 +REG dl X86_REG8 2 0 +REG bl X86_REG8 3 0 +REG ah X86_REG8 4 0 +REG ch X86_REG8 5 0 +REG dh X86_REG8 6 0 +REG bh X86_REG8 7 0 +REG r8b X86_REG8 8 64 +REG r9b X86_REG8 9 64 +REG r10b X86_REG8 10 64 +REG r11b X86_REG8 11 64 +REG r12b X86_REG8 12 64 +REG r13b X86_REG8 13 64 +REG r14b X86_REG8 14 64 +REG r15b X86_REG8 15 64 + +REG spl X86_REG8X 4 64 +REG bpl X86_REG8X 5 64 +REG sil X86_REG8X 6 64 +REG dil X86_REG8X 7 64 + +REG rip X86_RIP 0 64 + +# floating point, MMX, and SSE/SSE2 registers +REGGROUP st X86_FPUREG +REGGROUP mm X86_MMXREG +REGGROUP xmm X86_XMMREG + +# segment registers +SEGREG es 0x26 0x00 64 +SEGREG cs 0x2e 0x01 0 +SEGREG ss 0x36 0x02 64 +SEGREG ds 0x3e 0x03 64 +SEGREG fs 0x64 0x04 0 +SEGREG gs 0x65 0x05 0 + diff --git a/modules/arch/x86/x86regtmod.gperf b/modules/arch/x86/x86regtmod.gperf deleted file mode 100644 index 38986df0..00000000 --- a/modules/arch/x86/x86regtmod.gperf +++ /dev/null @@ -1,297 +0,0 @@ -# -# x86 register and target modifier recognition -# -# Copyright (C) 2002-2007 Peter Johnson -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND OTHER CONTRIBUTORS ``AS IS'' -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR OTHER CONTRIBUTORS BE -# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -%{ -#include - -#include -#include -#include - -#include "modules/arch/x86/x86arch.h" - -enum regtmod_type { - REG = 1, - REGGROUP, - SEGREG, - TARGETMOD -}; -%} -%ignore-case -%language=ANSI-C -%compare-strncmp -%readonly-tables -%enum -%struct-type -%define hash-function-name regtmod_hash -%define lookup-function-name regtmod_find -struct regtmod_parse_data { - const char *name; - unsigned int type:8; /* regtmod_type */ - - /* REG: register size - * SEGREG: prefix encoding - * Others: 0 - */ - unsigned int size_prefix:8; - - /* REG: register index - * REGGROUP: register group type - * SEGREG: register encoding - * TARGETMOD: target modifier - */ - unsigned int data:8; - - /* REG: required bits setting - * SEGREG: BITS in which the segment is ignored - * Others: 0 - */ - unsigned int bits:8; -}; -%% -# -# control, debug, and test registers -# -cr0, REG, X86_CRREG, 0, 0 -cr2, REG, X86_CRREG, 2, 0 -cr3, REG, X86_CRREG, 3, 0 -cr4, REG, X86_CRREG, 4, 0 -cr8, REG, X86_CRREG, 8, 64 -# -dr0, REG, X86_DRREG, 0, 0 -dr1, REG, X86_DRREG, 1, 0 -dr2, REG, X86_DRREG, 2, 0 -dr3, REG, X86_DRREG, 3, 0 -dr4, REG, X86_DRREG, 4, 0 -dr5, REG, X86_DRREG, 5, 0 -dr6, REG, X86_DRREG, 6, 0 -dr7, REG, X86_DRREG, 7, 0 -# -tr0, REG, X86_TRREG, 0, 0 -tr1, REG, X86_TRREG, 1, 0 -tr2, REG, X86_TRREG, 2, 0 -tr3, REG, X86_TRREG, 3, 0 -tr4, REG, X86_TRREG, 4, 0 -tr5, REG, X86_TRREG, 5, 0 -tr6, REG, X86_TRREG, 6, 0 -tr7, REG, X86_TRREG, 7, 0 -# -# floating point, MMX, and SSE/SSE2 registers -# -st0, REG, X86_FPUREG, 0, 0 -st1, REG, X86_FPUREG, 1, 0 -st2, REG, X86_FPUREG, 2, 0 -st3, REG, X86_FPUREG, 3, 0 -st4, REG, X86_FPUREG, 4, 0 -st5, REG, X86_FPUREG, 5, 0 -st6, REG, X86_FPUREG, 6, 0 -st7, REG, X86_FPUREG, 7, 0 -# -mm0, REG, X86_MMXREG, 0, 0 -mm1, REG, X86_MMXREG, 1, 0 -mm2, REG, X86_MMXREG, 2, 0 -mm3, REG, X86_MMXREG, 3, 0 -mm4, REG, X86_MMXREG, 4, 0 -mm5, REG, X86_MMXREG, 5, 0 -mm6, REG, X86_MMXREG, 6, 0 -mm7, REG, X86_MMXREG, 7, 0 -# -xmm0, REG, X86_XMMREG, 0, 0 -xmm1, REG, X86_XMMREG, 1, 0 -xmm2, REG, X86_XMMREG, 2, 0 -xmm3, REG, X86_XMMREG, 3, 0 -xmm4, REG, X86_XMMREG, 4, 0 -xmm5, REG, X86_XMMREG, 5, 0 -xmm6, REG, X86_XMMREG, 6, 0 -xmm7, REG, X86_XMMREG, 7, 0 -xmm8, REG, X86_XMMREG, 8, 64 -xmm9, REG, X86_XMMREG, 9, 64 -xmm10, REG, X86_XMMREG, 10, 64 -xmm11, REG, X86_XMMREG, 11, 64 -xmm12, REG, X86_XMMREG, 12, 64 -xmm13, REG, X86_XMMREG, 13, 64 -xmm14, REG, X86_XMMREG, 14, 64 -xmm15, REG, X86_XMMREG, 15, 64 -# AVX registers -ymm0, REG, X86_YMMREG, 0, 0 -ymm1, REG, X86_YMMREG, 1, 0 -ymm2, REG, X86_YMMREG, 2, 0 -ymm3, REG, X86_YMMREG, 3, 0 -ymm4, REG, X86_YMMREG, 4, 0 -ymm5, REG, X86_YMMREG, 5, 0 -ymm6, REG, X86_YMMREG, 6, 0 -ymm7, REG, X86_YMMREG, 7, 0 -ymm8, REG, X86_YMMREG, 8, 64 -ymm9, REG, X86_YMMREG, 9, 64 -ymm10, REG, X86_YMMREG, 10, 64 -ymm11, REG, X86_YMMREG, 11, 64 -ymm12, REG, X86_YMMREG, 12, 64 -ymm13, REG, X86_YMMREG, 13, 64 -ymm14, REG, X86_YMMREG, 14, 64 -ymm15, REG, X86_YMMREG, 15, 64 -# -# integer registers -# -rax, REG, X86_REG64, 0, 64 -rcx, REG, X86_REG64, 1, 64 -rdx, REG, X86_REG64, 2, 64 -rbx, REG, X86_REG64, 3, 64 -rsp, REG, X86_REG64, 4, 64 -rbp, REG, X86_REG64, 5, 64 -rsi, REG, X86_REG64, 6, 64 -rdi, REG, X86_REG64, 7, 64 -r8, REG, X86_REG64, 8, 64 -r9, REG, X86_REG64, 9, 64 -r10, REG, X86_REG64, 10, 64 -r11, REG, X86_REG64, 11, 64 -r12, REG, X86_REG64, 12, 64 -r13, REG, X86_REG64, 13, 64 -r14, REG, X86_REG64, 14, 64 -r15, REG, X86_REG64, 15, 64 -# -eax, REG, X86_REG32, 0, 0 -ecx, REG, X86_REG32, 1, 0 -edx, REG, X86_REG32, 2, 0 -ebx, REG, X86_REG32, 3, 0 -esp, REG, X86_REG32, 4, 0 -ebp, REG, X86_REG32, 5, 0 -esi, REG, X86_REG32, 6, 0 -edi, REG, X86_REG32, 7, 0 -r8d, REG, X86_REG32, 8, 64 -r9d, REG, X86_REG32, 9, 64 -r10d, REG, X86_REG32, 10, 64 -r11d, REG, X86_REG32, 11, 64 -r12d, REG, X86_REG32, 12, 64 -r13d, REG, X86_REG32, 13, 64 -r14d, REG, X86_REG32, 14, 64 -r15d, REG, X86_REG32, 15, 64 -# -ax, REG, X86_REG16, 0, 0 -cx, REG, X86_REG16, 1, 0 -dx, REG, X86_REG16, 2, 0 -bx, REG, X86_REG16, 3, 0 -sp, REG, X86_REG16, 4, 0 -bp, REG, X86_REG16, 5, 0 -si, REG, X86_REG16, 6, 0 -di, REG, X86_REG16, 7, 0 -r8w, REG, X86_REG16, 8, 64 -r9w, REG, X86_REG16, 9, 64 -r10w, REG, X86_REG16, 10, 64 -r11w, REG, X86_REG16, 11, 64 -r12w, REG, X86_REG16, 12, 64 -r13w, REG, X86_REG16, 13, 64 -r14w, REG, X86_REG16, 14, 64 -r15w, REG, X86_REG16, 15, 64 -# -al, REG, X86_REG8, 0, 0 -cl, REG, X86_REG8, 1, 0 -dl, REG, X86_REG8, 2, 0 -bl, REG, X86_REG8, 3, 0 -ah, REG, X86_REG8, 4, 0 -ch, REG, X86_REG8, 5, 0 -dh, REG, X86_REG8, 6, 0 -bh, REG, X86_REG8, 7, 0 -r8b, REG, X86_REG8, 8, 64 -r9b, REG, X86_REG8, 9, 64 -r10b, REG, X86_REG8, 10, 64 -r11b, REG, X86_REG8, 11, 64 -r12b, REG, X86_REG8, 12, 64 -r13b, REG, X86_REG8, 13, 64 -r14b, REG, X86_REG8, 14, 64 -r15b, REG, X86_REG8, 15, 64 -# -spl, REG, X86_REG8X, 4, 64 -bpl, REG, X86_REG8X, 5, 64 -sil, REG, X86_REG8X, 6, 64 -dil, REG, X86_REG8X, 7, 64 -# -rip, REG, X86_RIP, 0, 64 -# -# floating point, MMX, and SSE/SSE2 registers -# -st, REGGROUP, 0, X86_FPUREG, 0 -mm, REGGROUP, 0, X86_MMXREG, 0 -xmm, REGGROUP, 0, X86_XMMREG, 0 -ymm, REGGROUP, 0, X86_YMMREG, 0 -# -# segment registers -# -es, SEGREG, 0x26, 0x00, 64 -cs, SEGREG, 0x2e, 0x01, 0 -ss, SEGREG, 0x36, 0x02, 64 -ds, SEGREG, 0x3e, 0x03, 64 -fs, SEGREG, 0x64, 0x04, 0 -gs, SEGREG, 0x65, 0x05, 0 -# -# target modifiers -# -near, TARGETMOD, 0, X86_NEAR, 0 -short, TARGETMOD, 0, X86_SHORT, 0 -far, TARGETMOD, 0, X86_FAR, 0 -to, TARGETMOD, 0, X86_TO, 0 -%% - -yasm_arch_regtmod -yasm_x86__parse_check_regtmod(yasm_arch *arch, const char *id, size_t id_len, - uintptr_t *data) -{ - yasm_arch_x86 *arch_x86 = (yasm_arch_x86 *)arch; - /*@null@*/ const struct regtmod_parse_data *pdata; - size_t i; - static char lcaseid[8]; - unsigned int bits; - yasm_arch_regtmod type; - - if (id_len > 7) - return YASM_ARCH_NOTREGTMOD; - for (i=0; itype; - bits = pdata->bits; - - if (type == YASM_ARCH_REG && bits != 0 && arch_x86->mode_bits != bits) { - yasm_warn_set(YASM_WARN_GENERAL, - N_("`%s' is a register in %u-bit mode"), id, bits); - return YASM_ARCH_NOTREGTMOD; - } - - if (type == YASM_ARCH_SEGREG && bits != 0 && arch_x86->mode_bits == bits) { - yasm_warn_set(YASM_WARN_SEGREG_IN_64BIT, - N_("`%s' segment register ignored in %u-bit mode"), id, - bits); - } - - if (type == YASM_ARCH_SEGREG) - *data = (pdata->size_prefix<<8) | pdata->data; - else - *data = pdata->size_prefix | pdata->data; - return type; -} diff --git a/modules/arch/yasm_arch.xml b/modules/arch/yasm_arch.xml index a35510c0..46002919 100644 --- a/modules/arch/yasm_arch.xml +++ b/modules/arch/yasm_arch.xml @@ -2,6 +2,8 @@ + + @@ -20,7 +22,6 @@ 2004 2005 2006 - 2007 Peter Johnson @@ -132,9 +133,7 @@ assembled will be run in 64-bit mode. To specify an AMD64 object file, use on the Yasm command line, or explicitly target a 64-bit object format such as or . can be used to select 32-bit ELF object format - for AMD64 processors. + win64 or . Register Changes @@ -230,23 +229,6 @@ mov ecx, -1 ; 5 byte, equivalent to above mov rcx, sym ; 5 byte, 32-bit size default for symbols mov rcx, qword sym ; 10 byte, override default size - - The handling of mov reg64, unsized immediate is different - between YASM and NASM 2.x; YASM follows the above behavior, while - NASM 2.x does the following: - - add rax, 0xffffffff ; sign-extended 32-bit immediate - add rax, -1 ; same as above - add rax, 0xffffffffffffffff ; truncated 32-bit (warning) - add rax, sym ; sign-extended 32-bit immediate - mov eax, 1 ; 5 byte (32-bit immediate) - mov rax, 1 ; 10 byte (64-bit immediate) - mov rbx, 0x1234567890abcdef ; 10 byte instruction - mov rcx, 0xffffffff ; 10 byte instruction - mov ecx, -1 ; 5 byte, equivalent to above - mov ecx, sym ; 5 byte (32-bit immediate) - mov rcx, sym ; 10 byte instruction - mov rcx, qword sym ; 10 byte (64-bit immediate) @@ -298,67 +280,6 @@ value 1 there. If symb is a variable, this will not store the value 1 into the symb variable! - - Yasm also supports the following syntax for RIP-relative - addressing: - - mov [rel sym], rax ; RIP-relative - mov [abs sym], rax ; not RIP-relative - - The behavior of: - - mov [sym], rax - - Depends on a mode set by the DEFAULT directive, as follows. - The default mode is always "abs", and in "rel" mode, use of - registers, an fs or gs segment override, or an explicit "abs" - override will result in a non-RIP-relative effective - address. - - default rel - mov [sym], rbx ; RIP-relative - mov [abs sym], rbx ; not RIP-relative (explicit override) - mov [rbx+1], rbx ; not RIP-relative (register use) - mov [fs:sym], rbx ; not RIP-relative (fs or gs use) - mov [ds:sym], rbx ; RIP-relative (segment, but not fs or gs) - mov [rel sym], rbx ; RIP-relative (redundant override) - - default abs - mov [sym], rbx ; not RIP-relative - mov [abs sym], rbx ; not RIP-relative - mov [rbx+1], rbx ; not RIP-relative - mov [fs:sym], rbx ; not RIP-relative - mov [ds:sym], rbx ; not RIP-relative - mov [rel sym], rbx ; RIP-relative (explicit override) - - - - Memory references - - Usually the size of a memory reference can be deduced by - which registers you're moving--for example, "mov [rax],ecx" is a - 32-bit move, because ecx is 32 bits. YASM currently gives the - non-obvious "invalid combination of opcode and operands" error if - it can't figure out how much memory you're moving. The fix in - this case is to add a memory size specifier: qword, dword, word, - or byte. - - Here's a 64-bit memory move, which sets 8 bytes starting at - rax: - - mov qword [rax], 1 - - Here's a 32-bit memory move, which sets 4 bytes: - - mov dword [rax], 1 - - Here's a 16-bit memory move, which sets 2 bytes: - - mov word [rax], 1 - - Here's an 8-bit memory move, which sets 1 byte: - - mov byte [rax], 1 diff --git a/modules/dbgfmts/CMakeLists.txt b/modules/dbgfmts/CMakeLists.txt deleted file mode 100644 index 93c29fe8..00000000 --- a/modules/dbgfmts/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -INCLUDE(dbgfmts/codeview/CMakeLists.txt) -INCLUDE(dbgfmts/dwarf2/CMakeLists.txt) -INCLUDE(dbgfmts/null/CMakeLists.txt) -INCLUDE(dbgfmts/stabs/CMakeLists.txt) diff --git a/modules/dbgfmts/Makefile.inc b/modules/dbgfmts/Makefile.inc index 8da62104..be53622c 100644 --- a/modules/dbgfmts/Makefile.inc +++ b/modules/dbgfmts/Makefile.inc @@ -1,3 +1,5 @@ +# $Id$ + EXTRA_DIST += modules/dbgfmts/codeview/Makefile.inc EXTRA_DIST += modules/dbgfmts/dwarf2/Makefile.inc EXTRA_DIST += modules/dbgfmts/null/Makefile.inc @@ -8,7 +10,7 @@ include modules/dbgfmts/dwarf2/Makefile.inc include modules/dbgfmts/null/Makefile.inc include modules/dbgfmts/stabs/Makefile.inc -notrans_dist_man_MANS += yasm_dbgfmts.7 +dist_man_MANS += yasm_dbgfmts.7 if BUILD_MAN yasm_dbgfmts.7: modules/dbgfmts/yasm_dbgfmts.xml diff --git a/modules/dbgfmts/codeview/CMakeLists.txt b/modules/dbgfmts/codeview/CMakeLists.txt deleted file mode 100644 index 3ecd9fa5..00000000 --- a/modules/dbgfmts/codeview/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -YASM_ADD_MODULE(dbgfmt_cv8 - dbgfmts/codeview/cv-dbgfmt.c - dbgfmts/codeview/cv-symline.c - dbgfmts/codeview/cv-type.c - ) diff --git a/modules/dbgfmts/codeview/Makefile.inc b/modules/dbgfmts/codeview/Makefile.inc index 19f2db65..1a11f729 100644 --- a/modules/dbgfmts/codeview/Makefile.inc +++ b/modules/dbgfmts/codeview/Makefile.inc @@ -1,3 +1,5 @@ +# $Id$ + libyasm_a_SOURCES += modules/dbgfmts/codeview/cv-dbgfmt.h libyasm_a_SOURCES += modules/dbgfmts/codeview/cv-dbgfmt.c libyasm_a_SOURCES += modules/dbgfmts/codeview/cv-symline.c diff --git a/modules/dbgfmts/codeview/cv-dbgfmt.c b/modules/dbgfmts/codeview/cv-dbgfmt.c index e39a725f..0c69afbe 100644 --- a/modules/dbgfmts/codeview/cv-dbgfmt.c +++ b/modules/dbgfmts/codeview/cv-dbgfmt.c @@ -25,7 +25,10 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include +/*@unused@*/ RCSID("$Id$"); +#define YASM_LIB_INTERNAL +#define YASM_BC_INTERNAL #include #include "cv-dbgfmt.h" @@ -44,12 +47,12 @@ cv_dbgfmt_create(yasm_object *object, yasm_dbgfmt_module *module, int version) dbgfmt_cv->filenames_allocated = 32; dbgfmt_cv->filenames_size = 0; dbgfmt_cv->filenames = - yasm_xmalloc(sizeof(cv_filename)*dbgfmt_cv->filenames_allocated); + yasm_xmalloc(sizeof(cv_filename)*dbgfmt_cv->filenames_allocated); for (i=0; ifilenames_allocated; i++) { - dbgfmt_cv->filenames[i].pathname = NULL; - dbgfmt_cv->filenames[i].filename = NULL; - dbgfmt_cv->filenames[i].str_off = 0; - dbgfmt_cv->filenames[i].info_off = 0; + dbgfmt_cv->filenames[i].pathname = NULL; + dbgfmt_cv->filenames[i].filename = NULL; + dbgfmt_cv->filenames[i].str_off = 0; + dbgfmt_cv->filenames[i].info_off = 0; } dbgfmt_cv->version = version; @@ -69,10 +72,8 @@ cv_dbgfmt_destroy(/*@only@*/ yasm_dbgfmt *dbgfmt) yasm_dbgfmt_cv *dbgfmt_cv = (yasm_dbgfmt_cv *)dbgfmt; size_t i; for (i=0; ifilenames_size; i++) { - if (dbgfmt_cv->filenames[i].pathname) - yasm_xfree(dbgfmt_cv->filenames[i].pathname); - if (dbgfmt_cv->filenames[i].filename) - yasm_xfree(dbgfmt_cv->filenames[i].filename); + if (dbgfmt_cv->filenames[i].pathname) + yasm_xfree(dbgfmt_cv->filenames[i].pathname); } yasm_xfree(dbgfmt_cv->filenames); yasm_xfree(dbgfmt); @@ -92,7 +93,7 @@ yasm_cv__append_bc(yasm_section *sect, yasm_bytecode *bc) static void cv_dbgfmt_generate(yasm_object *object, yasm_linemap *linemap, - yasm_errwarns *errwarns) + yasm_errwarns *errwarns) { yasm_cv__generate_symline(object, linemap, errwarns); yasm_cv__generate_type(object); diff --git a/modules/dbgfmts/codeview/cv-dbgfmt.h b/modules/dbgfmts/codeview/cv-dbgfmt.h index 134b0b88..1e146e22 100644 --- a/modules/dbgfmts/codeview/cv-dbgfmt.h +++ b/modules/dbgfmts/codeview/cv-dbgfmt.h @@ -1,4 +1,4 @@ -/* +/* $Id$ * CodeView debugging formats implementation for Yasm * * Copyright (C) 2006-2007 Peter Johnson @@ -28,16 +28,16 @@ #define YASM_CV_DBGFMT_H typedef struct { - char *pathname; /* full pathname (drive+basepath+filename) */ - char *filename; /* filename as yasm knows it internally */ - unsigned long str_off; /* offset into pathname string table */ - unsigned long info_off; /* offset into source info table */ - unsigned char digest[16]; /* MD5 digest of source file */ + char *pathname; /* full pathname (drive+basepath+filename) */ + char *filename; /* filename as yasm knows it internally */ + unsigned long str_off; /* offset into pathname string table */ + unsigned long info_off; /* offset into source info table */ + unsigned char digest[16]; /* MD5 digest of source file */ } cv_filename; /* Global data */ typedef struct yasm_dbgfmt_cv { - yasm_dbgfmt_base dbgfmt; /* base structure */ + yasm_dbgfmt_base dbgfmt; /* base structure */ cv_filename *filenames; size_t filenames_size; diff --git a/modules/dbgfmts/codeview/cv-symline.c b/modules/dbgfmts/codeview/cv-symline.c index 8d703022..94cf1ef9 100644 --- a/modules/dbgfmts/codeview/cv-symline.c +++ b/modules/dbgfmts/codeview/cv-symline.c @@ -28,86 +28,89 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include +/*@unused@*/ RCSID("$Id$"); +#define YASM_LIB_INTERNAL +#define YASM_BC_INTERNAL #include #include "cv-dbgfmt.h" enum cv8_symheadtype { - CV8_DEBUG_SYMS = 0xF1, /* CV5 symbol information */ - CV8_LINE_NUMS = 0xF2, /* line numbers for a section */ - CV8_FILE_STRTAB = 0xF3, /* filename string table */ - CV8_FILE_INFO = 0xF4 /* source file info */ + CV8_DEBUG_SYMS = 0xF1, /* CV5 symbol information */ + CV8_LINE_NUMS = 0xF2, /* line numbers for a section */ + CV8_FILE_STRTAB = 0xF3, /* filename string table */ + CV8_FILE_INFO = 0xF4 /* source file info */ }; enum cv_symtype { /* Non-modal Symbols */ - CV_S_COMPILE = 0x0001, /* Compile Flag */ - CV_S_REGISTER = 0x0002, /* Register */ - CV_S_CONSTANT = 0x0003, /* Constant */ - CV_S_UDT = 0x0004, /* User-defined Type */ - CV_S_SSEARCH = 0x0005, /* Start Search */ - CV_S_END = 0x0006, /* End of Block */ - CV_S_SKIP = 0x0007, /* Skip Record */ - CV_S_OBJNAME = 0x0009, /* Object File Name */ - CV_S_ENDARG = 0x000a, /* End of Arguments */ - CV_S_COBOLUDT = 0x000b, /* COBOL User-defined Type */ - CV_S_MANYREG = 0x000c, /* Many Registers */ - CV_S_RETURN = 0x000d, /* Function Return */ - CV_S_ENTRYTHIS = 0x000e, /* "this" at Method Entry */ + CV_S_COMPILE = 0x0001, /* Compile Flag */ + CV_S_REGISTER = 0x0002, /* Register */ + CV_S_CONSTANT = 0x0003, /* Constant */ + CV_S_UDT = 0x0004, /* User-defined Type */ + CV_S_SSEARCH = 0x0005, /* Start Search */ + CV_S_END = 0x0006, /* End of Block */ + CV_S_SKIP = 0x0007, /* Skip Record */ + CV_S_OBJNAME = 0x0009, /* Object File Name */ + CV_S_ENDARG = 0x000a, /* End of Arguments */ + CV_S_COBOLUDT = 0x000b, /* COBOL User-defined Type */ + CV_S_MANYREG = 0x000c, /* Many Registers */ + CV_S_RETURN = 0x000d, /* Function Return */ + CV_S_ENTRYTHIS = 0x000e, /* "this" at Method Entry */ /* Symbols for 16:16 Segmented Architectures */ - CV_S_BPREL16 = 0x0100, /* BP Relative 16:16 */ - CV_S_LDATA16 = 0x0101, /* Local Data 16:16 */ - CV_S_GDATA16 = 0x0102, /* Global Data Symbol 16:16 */ - CV_S_PUB16 = 0x0103, /* Public Symbol 16:16 */ - CV_S_LPROC16 = 0x0104, /* Local Start 16:16 */ - CV_S_GPROC16 = 0x0105, /* Global Start 16:16 */ - CV_S_THUNK16 = 0x0106, /* Thunk Start 16:16 */ - CV_S_BLOCK16 = 0x0107, /* Block Start 16:16 */ - CV_S_WITH16 = 0x0108, /* With Start 16:16 */ - CV_S_LABEL16 = 0x0109, /* Code Label 16:16 */ - CV_S_CEXMODEL16 = 0x0110, /* Change Execution Model 16:16 */ - CV_S_VFTPATH16 = 0x010b, /* Virtual Function Table Path 16:16 */ - CV_S_REGREL16 = 0x010c, /* Register Relative 16:16 */ + CV_S_BPREL16 = 0x0100, /* BP Relative 16:16 */ + CV_S_LDATA16 = 0x0101, /* Local Data 16:16 */ + CV_S_GDATA16 = 0x0102, /* Global Data Symbol 16:16 */ + CV_S_PUB16 = 0x0103, /* Public Symbol 16:16 */ + CV_S_LPROC16 = 0x0104, /* Local Start 16:16 */ + CV_S_GPROC16 = 0x0105, /* Global Start 16:16 */ + CV_S_THUNK16 = 0x0106, /* Thunk Start 16:16 */ + CV_S_BLOCK16 = 0x0107, /* Block Start 16:16 */ + CV_S_WITH16 = 0x0108, /* With Start 16:16 */ + CV_S_LABEL16 = 0x0109, /* Code Label 16:16 */ + CV_S_CEXMODEL16 = 0x0110, /* Change Execution Model 16:16 */ + CV_S_VFTPATH16 = 0x010b, /* Virtual Function Table Path 16:16 */ + CV_S_REGREL16 = 0x010c, /* Register Relative 16:16 */ /* Symbols for 16:32 Segmented Architectures */ - CV_S_BPREL32 = 0x0200, /* BP Relative 16:32 */ - CV_S_LDATA32 = 0x0201, /* Local Data 16:32 */ - CV_S_GDATA32 = 0x0202, /* Global Data Symbol 16:32 */ - CV_S_PUB32 = 0x0203, /* Public Symbol 16:32 */ - CV_S_LPROC32 = 0x0204, /* Local Start 16:32 */ - CV_S_GPROC32 = 0x0205, /* Global Start 16:32 */ - CV_S_THUNK32 = 0x0206, /* Thunk Start 16:32 */ - CV_S_BLOCK32 = 0x0207, /* Block Start 16:32 */ - CV_S_WITH32 = 0x0208, /* With Start 16:32 */ - CV_S_LABEL32 = 0x0209, /* Code Label 16:32 */ - CV_S_CEXMODEL32 = 0x0210, /* Change Execution Model 16:32 */ - CV_S_VFTPATH32 = 0x020b, /* Virtual Function Table Path 16:32 */ - CV_S_REGREL32 = 0x020c, /* Register Relative 16:32 */ - CV_S_LTHREAD32 = 0x020d, /* Local Thread Storage 16:32 */ - CV_S_GTHREAD32 = 0x020e, /* Global Thread Storage 16:32 */ + CV_S_BPREL32 = 0x0200, /* BP Relative 16:32 */ + CV_S_LDATA32 = 0x0201, /* Local Data 16:32 */ + CV_S_GDATA32 = 0x0202, /* Global Data Symbol 16:32 */ + CV_S_PUB32 = 0x0203, /* Public Symbol 16:32 */ + CV_S_LPROC32 = 0x0204, /* Local Start 16:32 */ + CV_S_GPROC32 = 0x0205, /* Global Start 16:32 */ + CV_S_THUNK32 = 0x0206, /* Thunk Start 16:32 */ + CV_S_BLOCK32 = 0x0207, /* Block Start 16:32 */ + CV_S_WITH32 = 0x0208, /* With Start 16:32 */ + CV_S_LABEL32 = 0x0209, /* Code Label 16:32 */ + CV_S_CEXMODEL32 = 0x0210, /* Change Execution Model 16:32 */ + CV_S_VFTPATH32 = 0x020b, /* Virtual Function Table Path 16:32 */ + CV_S_REGREL32 = 0x020c, /* Register Relative 16:32 */ + CV_S_LTHREAD32 = 0x020d, /* Local Thread Storage 16:32 */ + CV_S_GTHREAD32 = 0x020e, /* Global Thread Storage 16:32 */ /* Symbols for MIPS */ - CV_S_LPROCMIPS = 0x0300, /* Local procedure start MIPS */ - CV_S_GPROCMIPS = 0x0301, /* Global procedure start MIPS */ + CV_S_LPROCMIPS = 0x0300, /* Local procedure start MIPS */ + CV_S_GPROCMIPS = 0x0301, /* Global procedure start MIPS */ /* Symbols for CV8 - strings are 0 terminated rather than length-prefix. * Incomplete and unofficial. */ - CV8_S_OBJNAME = 0x1101, /* Object File Name */ - CV8_S_LABEL32 = 0x1105, /* Code Label 16:32 */ - CV8_S_LDATA32 = 0x110c, /* Local Data 16:32 */ - CV8_S_GDATA32 = 0x110d, /* Global Data 16:32 */ - CV8_S_LPROC32 = 0x1110, /* Local Start 16:32 */ - CV8_S_COMPILE = 0x1116 /* Compile Flag */ + CV8_S_OBJNAME = 0x1101, /* Object File Name */ + CV8_S_LABEL32 = 0x1105, /* Code Label 16:32 */ + CV8_S_LDATA32 = 0x110c, /* Local Data 16:32 */ + CV8_S_GDATA32 = 0x110d, /* Global Data 16:32 */ + CV8_S_LPROC32 = 0x1110, /* Local Start 16:32 */ + CV8_S_COMPILE = 0x1116 /* Compile Flag */ }; typedef struct cv8_symhead { enum cv8_symheadtype type; yasm_bytecode *start_prevbc; yasm_bytecode *end_prevbc; - int first; /* nonzero if first symhead in section */ + int first; /* nonzero if first symhead in section */ } cv8_symhead; typedef struct cv8_fileinfo { @@ -127,16 +130,13 @@ typedef struct cv8_lineset { size_t num_pairs; } cv8_lineset; -/* Note: Due to line number sorting requirements (by section offset it seems) - * one file may need more than one record per section. */ typedef struct cv8_lineinfo { STAILQ_ENTRY(cv8_lineinfo) link; - const cv_filename *fn; /* filename associated with line numbers */ - yasm_section *sect; /* section line numbers are for */ - yasm_symrec *sectsym; /* symbol for beginning of sect */ + const cv_filename *fn; /* filename associated with line numbers */ + yasm_section *sect; /* section line numbers are for */ + yasm_symrec *sectsym; /* symbol for beginning of sect */ unsigned long num_linenums; - int first_in_sect; /* First lineinfo for this section. */ - STAILQ_HEAD(cv8_lineset_head, cv8_lineset) linesets; + STAILQ_HEAD(, cv8_lineset) linesets; } cv8_lineinfo; /* Symbols use a bit of meta-programming to encode formats: each character @@ -153,39 +153,39 @@ typedef struct cv_sym { enum cv_symtype type; const char *format; union { - unsigned long i; - void *p; + unsigned long i; + void *p; } args[10]; } cv_sym; /* Bytecode callback function prototypes */ static void cv8_symhead_bc_destroy(void *contents); static void cv8_symhead_bc_print(const void *contents, FILE *f, - int indent_level); + int indent_level); static int cv8_symhead_bc_calc_len (yasm_bytecode *bc, yasm_bc_add_span_func add_span, void *add_span_data); static int cv8_symhead_bc_tobytes - (yasm_bytecode *bc, unsigned char **bufp, unsigned char *bufstart, void *d, + (yasm_bytecode *bc, unsigned char **bufp, void *d, yasm_output_value_func output_value, /*@null@*/ yasm_output_reloc_func output_reloc); static void cv8_fileinfo_bc_destroy(void *contents); static void cv8_fileinfo_bc_print(const void *contents, FILE *f, - int indent_level); + int indent_level); static int cv8_fileinfo_bc_calc_len (yasm_bytecode *bc, yasm_bc_add_span_func add_span, void *add_span_data); static int cv8_fileinfo_bc_tobytes - (yasm_bytecode *bc, unsigned char **bufp, unsigned char *bufstart, void *d, + (yasm_bytecode *bc, unsigned char **bufp, void *d, yasm_output_value_func output_value, /*@null@*/ yasm_output_reloc_func output_reloc); static void cv8_lineinfo_bc_destroy(void *contents); static void cv8_lineinfo_bc_print(const void *contents, FILE *f, - int indent_level); + int indent_level); static int cv8_lineinfo_bc_calc_len (yasm_bytecode *bc, yasm_bc_add_span_func add_span, void *add_span_data); static int cv8_lineinfo_bc_tobytes - (yasm_bytecode *bc, unsigned char **bufp, unsigned char *bufstart, void *d, + (yasm_bytecode *bc, unsigned char **bufp, void *d, yasm_output_value_func output_value, /*@null@*/ yasm_output_reloc_func output_reloc); @@ -194,7 +194,7 @@ static void cv_sym_bc_print(const void *contents, FILE *f, int indent_level); static int cv_sym_bc_calc_len (yasm_bytecode *bc, yasm_bc_add_span_func add_span, void *add_span_data); static int cv_sym_bc_tobytes - (yasm_bytecode *bc, unsigned char **bufp, unsigned char *bufstart, void *d, + (yasm_bytecode *bc, unsigned char **bufp, void *d, yasm_output_value_func output_value, /*@null@*/ yasm_output_reloc_func output_reloc); @@ -203,7 +203,6 @@ static const yasm_bytecode_callback cv8_symhead_bc_callback = { cv8_symhead_bc_destroy, cv8_symhead_bc_print, yasm_bc_finalize_common, - NULL, cv8_symhead_bc_calc_len, yasm_bc_expand_common, cv8_symhead_bc_tobytes, @@ -214,7 +213,6 @@ static const yasm_bytecode_callback cv8_fileinfo_bc_callback = { cv8_fileinfo_bc_destroy, cv8_fileinfo_bc_print, yasm_bc_finalize_common, - NULL, cv8_fileinfo_bc_calc_len, yasm_bc_expand_common, cv8_fileinfo_bc_tobytes, @@ -225,7 +223,6 @@ static const yasm_bytecode_callback cv8_lineinfo_bc_callback = { cv8_lineinfo_bc_destroy, cv8_lineinfo_bc_print, yasm_bc_finalize_common, - NULL, cv8_lineinfo_bc_calc_len, yasm_bc_expand_common, cv8_lineinfo_bc_tobytes, @@ -236,7 +233,6 @@ static const yasm_bytecode_callback cv_sym_bc_callback = { cv_sym_bc_destroy, cv_sym_bc_print, yasm_bc_finalize_common, - NULL, cv_sym_bc_calc_len, yasm_bc_expand_common, cv_sym_bc_tobytes, @@ -244,7 +240,7 @@ static const yasm_bytecode_callback cv_sym_bc_callback = { }; static cv8_symhead *cv8_add_symhead(yasm_section *sect, unsigned long type, - int first); + int first); static void cv8_set_symhead_end(cv8_symhead *head, yasm_bytecode *end_prevbc); static yasm_bytecode *cv8_add_fileinfo @@ -260,8 +256,8 @@ cv8_add_sym_objname(yasm_section *sect, /*@keep@*/ char *objname) cv_sym *cvs = yasm_xmalloc(sizeof(cv_sym)); cvs->type = CV8_S_OBJNAME; cvs->format = "wZ"; - cvs->args[0].i = 0; /* signature (0=asm) */ - cvs->args[1].p = objname; /* object filename */ + cvs->args[0].i = 0; /* signature (0=asm) */ + cvs->args[1].p = objname; /* object filename */ bc = yasm_bc_create_common(&cv_sym_bc_callback, cvs, 0); bc->len = cv_sym_size(cvs); @@ -271,27 +267,27 @@ cv8_add_sym_objname(yasm_section *sect, /*@keep@*/ char *objname) static cv_sym * cv8_add_sym_compile(yasm_object *object, yasm_section *sect, - /*@keep@*/ char *creator) + /*@keep@*/ char *creator) { yasm_bytecode *bc; cv_sym *cvs = yasm_xmalloc(sizeof(cv_sym)); cvs->type = CV8_S_COMPILE; cvs->format = "wwwwZh"; - cvs->args[0].i = 3; /* language (3=Masm) */ + cvs->args[0].i = 3; /* language (3=Masm) */ /* target processor; 0xD0 = AMD64 */ if (strcmp(yasm_arch_keyword(object->arch), "x86") == 0) { - if (strcmp(yasm_arch_get_machine(object->arch), "amd64") == 0) - cvs->args[1].i = 0xD0; - else - cvs->args[1].i = 0x6; /* 686, FIXME */ + if (strcmp(yasm_arch_get_machine(object->arch), "amd64") == 0) + cvs->args[1].i = 0xD0; + else + cvs->args[1].i = 0x6; /* 686, FIXME */ } else - cvs->args[1].i = 0; /* XXX: unknown */ + cvs->args[1].i = 0; /* XXX: unknown */ - cvs->args[2].i = 0; /* flags (assume 0 for now) */ - cvs->args[3].i = 0; /* creator version number (assume 0 for now) */ - cvs->args[4].p = creator; /* creator string */ - cvs->args[5].i = 0; /* no pairs of key/value */ + cvs->args[2].i = 0; /* flags (assume 0 for now) */ + cvs->args[3].i = 0; /* creator version number (assume 0 for now) */ + cvs->args[4].p = creator; /* creator string */ + cvs->args[5].i = 0; /* no pairs of key/value */ bc = yasm_bc_create_common(&cv_sym_bc_callback, cvs, 0); bc->len = cv_sym_size(cvs); @@ -306,8 +302,8 @@ cv8_add_sym_label(yasm_section *sect, yasm_symrec *sym) cv_sym *cvs = yasm_xmalloc(sizeof(cv_sym)); cvs->type = CV8_S_LABEL32; cvs->format = "YbZ"; - cvs->args[0].p = sym; /* symrec for label */ - cvs->args[1].i = 0; /* flags (assume 0 for now) */ + cvs->args[0].p = sym; /* symrec for label */ + cvs->args[1].i = 0; /* flags (assume 0 for now) */ cvs->args[2].p = yasm__xstrdup(yasm_symrec_get_name(sym)); bc = yasm_bc_create_common(&cv_sym_bc_callback, cvs, 0); @@ -318,14 +314,14 @@ cv8_add_sym_label(yasm_section *sect, yasm_symrec *sym) static cv_sym * cv8_add_sym_data(yasm_section *sect, unsigned long type, yasm_symrec *sym, - int is_global) + int is_global) { yasm_bytecode *bc; cv_sym *cvs = yasm_xmalloc(sizeof(cv_sym)); cvs->type = is_global ? CV8_S_GDATA32 : CV8_S_LDATA32; cvs->format = "wYZ"; - cvs->args[0].i = type; /* type index */ - cvs->args[1].p = sym; /* symrec for label */ + cvs->args[0].i = type; /* type index */ + cvs->args[1].p = sym; /* symrec for label */ cvs->args[2].p = yasm__xstrdup(yasm_symrec_get_name(sym)); bc = yasm_bc_create_common(&cv_sym_bc_callback, cvs, 0); @@ -336,7 +332,7 @@ cv8_add_sym_data(yasm_section *sect, unsigned long type, yasm_symrec *sym, static size_t cv_dbgfmt_add_file(yasm_dbgfmt_cv *dbgfmt_cv, size_t filenum, - const char *filename) + const char *filename) { char *pathname; size_t i; @@ -347,27 +343,27 @@ cv_dbgfmt_add_file(yasm_dbgfmt_cv *dbgfmt_cv, size_t filenum, /* Put the filename into the filename table */ if (filenum == 0) { - /* Look to see if we already have that filename in the table */ - for (; filenumfilenames_size; filenum++) { - if (!dbgfmt_cv->filenames[filenum].filename || - strcmp(dbgfmt_cv->filenames[filenum].filename, filename) == 0) - break; - } + /* Look to see if we already have that filename in the table */ + for (; filenumfilenames_size; filenum++) { + if (!dbgfmt_cv->filenames[filenum].filename || + strcmp(dbgfmt_cv->filenames[filenum].filename, filename) == 0) + break; + } } else - filenum--; /* array index is 0-based */ + filenum--; /* array index is 0-based */ /* Realloc table if necessary */ if (filenum >= dbgfmt_cv->filenames_allocated) { - size_t old_allocated = dbgfmt_cv->filenames_allocated; - dbgfmt_cv->filenames_allocated = filenum+32; - dbgfmt_cv->filenames = yasm_xrealloc(dbgfmt_cv->filenames, - sizeof(cv_filename)*dbgfmt_cv->filenames_allocated); - for (i=old_allocated; ifilenames_allocated; i++) { - dbgfmt_cv->filenames[i].pathname = NULL; - dbgfmt_cv->filenames[i].filename = NULL; - dbgfmt_cv->filenames[i].str_off = 0; - dbgfmt_cv->filenames[i].info_off = 0; - } + size_t old_allocated = dbgfmt_cv->filenames_allocated; + dbgfmt_cv->filenames_allocated = filenum+32; + dbgfmt_cv->filenames = yasm_xrealloc(dbgfmt_cv->filenames, + sizeof(cv_filename)*dbgfmt_cv->filenames_allocated); + for (i=old_allocated; ifilenames_allocated; i++) { + dbgfmt_cv->filenames[i].pathname = NULL; + dbgfmt_cv->filenames[i].filename = NULL; + dbgfmt_cv->filenames[i].str_off = 0; + dbgfmt_cv->filenames[i].info_off = 0; + } } /* Calculate MD5 checksum of file */ @@ -375,18 +371,18 @@ cv_dbgfmt_add_file(yasm_dbgfmt_cv *dbgfmt_cv, size_t filenum, yasm_md5_init(&context); f = fopen(filename, "rb"); if (!f) - yasm__fatal(N_("codeview: could not open source file")); + yasm__fatal(N_("codeview: could not open source file")); while ((len = fread(buf, 1, 1024, f)) > 0) - yasm_md5_update(&context, buf, (unsigned long)len); + yasm_md5_update(&context, buf, (unsigned long)len); yasm_md5_final(dbgfmt_cv->filenames[filenum].digest, &context); fclose(f); yasm_xfree(buf); /* Actually save in table */ if (dbgfmt_cv->filenames[filenum].pathname) - yasm_xfree(dbgfmt_cv->filenames[filenum].pathname); + yasm_xfree(dbgfmt_cv->filenames[filenum].pathname); if (dbgfmt_cv->filenames[filenum].filename) - yasm_xfree(dbgfmt_cv->filenames[filenum].filename); + yasm_xfree(dbgfmt_cv->filenames[filenum].filename); pathname = yasm__abspath(filename); dbgfmt_cv->filenames[filenum].pathname = pathname; @@ -394,7 +390,7 @@ cv_dbgfmt_add_file(yasm_dbgfmt_cv *dbgfmt_cv, size_t filenum, /* Update table size */ if (filenum >= dbgfmt_cv->filenames_size) - dbgfmt_cv->filenames_size = filenum + 1; + dbgfmt_cv->filenames_size = filenum + 1; return filenum; } @@ -407,7 +403,7 @@ cv_append_str(yasm_section *sect, const char *str) yasm_dvs_initialize(&dvs); yasm_dvs_append(&dvs, yasm_dv_create_string(yasm__xstrdup(str), - strlen(str))); + strlen(str))); bc = yasm_bc_create_data(&dvs, 1, 1, NULL, 0); yasm_bc_finalize(bc, yasm_cv__append_bc(sect, bc)); yasm_bc_calc_len(bc, NULL, NULL); @@ -421,7 +417,7 @@ typedef struct cv_line_info { yasm_linemap *linemap; yasm_errwarns *errwarns; unsigned int num_lineinfos; - STAILQ_HEAD(cv8_lineinfo_head, cv8_lineinfo) cv8_lineinfos; + STAILQ_HEAD(, cv8_lineinfo) cv8_lineinfos; /*@null@*/ cv8_lineinfo *cv8_cur_li; /*@null@*/ cv8_lineset *cv8_cur_ls; } cv_line_info; @@ -438,55 +434,69 @@ cv_generate_line_bc(yasm_bytecode *bc, /*@null@*/ void *d) yasm_section *sect = yasm_bc_get_section(bc); if (nextbc && bc->offset == nextbc->offset) - return 0; + return 0; yasm_linemap_lookup(info->linemap, bc->line, &filename, &line); if (!info->cv8_cur_li - || strcmp(filename, info->cv8_cur_li->fn->filename) != 0) { - yasm_bytecode *sectbc; - char symname[8]; - int first_in_sect = !info->cv8_cur_li; + || strcmp(filename, info->cv8_cur_li->fn->filename) != 0) { + yasm_bytecode *sectbc; + char symname[8]; - /* Find file */ - for (i=0; ifilenames_size; i++) { - if (strcmp(filename, dbgfmt_cv->filenames[i].filename) == 0) - break; - } - if (i >= dbgfmt_cv->filenames_size) - yasm_internal_error(N_("could not find filename in table")); + /* first see if we already have a lineinfo that is for this section and + * filename + */ + STAILQ_FOREACH(info->cv8_cur_li, &info->cv8_lineinfos, link) { + if (sect == info->cv8_cur_li->sect + && strcmp(filename, info->cv8_cur_li->fn->filename) == 0) + break; + } - /* and create new lineinfo structure */ - info->cv8_cur_li = yasm_xmalloc(sizeof(cv8_lineinfo)); - info->cv8_cur_li->fn = &dbgfmt_cv->filenames[i]; - info->cv8_cur_li->sect = sect; - info->cv8_cur_li->first_in_sect = first_in_sect; - sectbc = yasm_section_bcs_first(sect); - if (sectbc->symrecs && sectbc->symrecs[0]) - info->cv8_cur_li->sectsym = sectbc->symrecs[0]; - else { - sprintf(symname, ".%06u", info->num_lineinfos++); - info->cv8_cur_li->sectsym = - yasm_symtab_define_label(info->object->symtab, symname, sectbc, - 1, 0); - } - info->cv8_cur_li->num_linenums = 0; - STAILQ_INIT(&info->cv8_cur_li->linesets); - STAILQ_INSERT_TAIL(&info->cv8_lineinfos, info->cv8_cur_li, link); - info->cv8_cur_ls = NULL; + if (info->cv8_cur_li) { + info->cv8_cur_ls = STAILQ_LAST(&info->cv8_cur_li->linesets, + cv8_lineset, link); + goto done; /* found one */ + } + + /* Nope; find file */ + for (i=0; ifilenames_size; i++) { + if (strcmp(filename, dbgfmt_cv->filenames[i].filename) == 0) + break; + } + if (i >= dbgfmt_cv->filenames_size) + yasm_internal_error(N_("could not find filename in table")); + + /* and create new lineinfo structure */ + info->cv8_cur_li = yasm_xmalloc(sizeof(cv8_lineinfo)); + info->cv8_cur_li->fn = &dbgfmt_cv->filenames[i]; + info->cv8_cur_li->sect = sect; + sectbc = yasm_section_bcs_first(sect); + if (sectbc->symrecs && sectbc->symrecs[0]) + info->cv8_cur_li->sectsym = sectbc->symrecs[0]; + else { + sprintf(symname, ".%06u", info->num_lineinfos++); + info->cv8_cur_li->sectsym = + yasm_symtab_define_label(info->object->symtab, symname, sectbc, + 1, 0); + } + info->cv8_cur_li->num_linenums = 0; + STAILQ_INIT(&info->cv8_cur_li->linesets); + STAILQ_INSERT_TAIL(&info->cv8_lineinfos, info->cv8_cur_li, link); + info->cv8_cur_ls = NULL; } +done: /* build new lineset if necessary */ if (!info->cv8_cur_ls || info->cv8_cur_ls->num_pairs >= 126) { - info->cv8_cur_ls = yasm_xmalloc(sizeof(cv8_lineset)); - info->cv8_cur_ls->num_pairs = 0; - STAILQ_INSERT_TAIL(&info->cv8_cur_li->linesets, info->cv8_cur_ls, link); + info->cv8_cur_ls = yasm_xmalloc(sizeof(cv8_lineset)); + info->cv8_cur_ls->num_pairs = 0; + STAILQ_INSERT_TAIL(&info->cv8_cur_li->linesets, info->cv8_cur_ls, link); } /* add linepair for this bytecode */ info->cv8_cur_ls->pairs[info->cv8_cur_ls->num_pairs].offset = bc->offset; info->cv8_cur_ls->pairs[info->cv8_cur_ls->num_pairs].line = - 0x80000000 | line; + 0x80000000 | line; info->cv8_cur_ls->num_pairs++; info->cv8_cur_li->num_linenums++; @@ -499,7 +509,7 @@ cv_generate_line_section(yasm_section *sect, /*@null@*/ void *d) cv_line_info *info = (cv_line_info *)d; if (!yasm_section_is_code(sect)) - return 0; /* not code, so no line data for this section */ + return 0; /* not code, so no line data for this section */ info->cv8_cur_li = NULL; info->cv8_cur_ls = NULL; @@ -528,20 +538,20 @@ cv_generate_sym(yasm_symrec *sym, void *d) * symbols). */ if (name[0] == '.' || !yasm_symrec_get_label(sym, &precbc)) - return 0; + return 0; /* TODO: add data types; until then, just mark everything as UBYTE */ if (yasm_section_is_code(yasm_bc_get_section(precbc))) - cv8_add_sym_label(info->debug_symline, sym); + cv8_add_sym_label(info->debug_symline, sym); else - cv8_add_sym_data(info->debug_symline, 0x20, sym, - yasm_symrec_get_visibility(sym) & YASM_SYM_GLOBAL?1:0); + cv8_add_sym_data(info->debug_symline, 0x20, sym, + yasm_symrec_get_visibility(sym) & YASM_SYM_GLOBAL?1:0); return 0; } yasm_section * yasm_cv__generate_symline(yasm_object *object, yasm_linemap *linemap, - yasm_errwarns *errwarns) + yasm_errwarns *errwarns) { yasm_dbgfmt_cv *dbgfmt_cv = (yasm_dbgfmt_cv *)object->dbgfmt; cv_line_info info; @@ -554,14 +564,14 @@ yasm_cv__generate_symline(yasm_object *object, yasm_linemap *linemap, /* Generate filenames based on linemap */ yasm_linemap_traverse_filenames(linemap, dbgfmt_cv, - cv_generate_filename); + cv_generate_filename); info.object = object; info.dbgfmt_cv = dbgfmt_cv; info.linemap = linemap; info.errwarns = errwarns; info.debug_symline = - yasm_object_get_general(object, ".debug$S", 1, 0, 0, &new, 0); + yasm_object_get_general(object, ".debug$S", 0, 1, 0, 0, &new, 0); info.num_lineinfos = 0; STAILQ_INIT(&info.cv8_lineinfos); info.cv8_cur_li = NULL; @@ -572,23 +582,23 @@ yasm_cv__generate_symline(yasm_object *object, yasm_linemap *linemap, cv_append_str(info.debug_symline, ""); off = 1; for (i=0; ifilenames_size; i++) { - if (!dbgfmt_cv->filenames[i].pathname) { - yasm_error_set(YASM_ERROR_GENERAL, - N_("codeview file number %d unassigned"), i+1); - yasm_errwarn_propagate(errwarns, 0); - continue; - } - bc = cv_append_str(info.debug_symline, - dbgfmt_cv->filenames[i].pathname); - dbgfmt_cv->filenames[i].str_off = off; - off += bc->len; + if (!dbgfmt_cv->filenames[i].pathname) { + yasm_error_set(YASM_ERROR_GENERAL, + N_("codeview file number %d unassigned"), i+1); + yasm_errwarn_propagate(errwarns, 0); + continue; + } + bc = cv_append_str(info.debug_symline, + dbgfmt_cv->filenames[i].pathname); + dbgfmt_cv->filenames[i].str_off = off; + off += bc->len; } cv8_set_symhead_end(head, yasm_section_bcs_last(info.debug_symline)); /* Align 4 */ bc = yasm_bc_create_align - (yasm_expr_create_ident(yasm_expr_int(yasm_intnum_create_uint(4)), 0), - NULL, NULL, NULL, 0); + (yasm_expr_create_ident(yasm_expr_int(yasm_intnum_create_uint(4)), 0), + NULL, NULL, NULL, 0); yasm_bc_finalize(bc, yasm_cv__append_bc(info.debug_symline, bc)); yasm_bc_calc_len(bc, NULL, NULL); @@ -596,11 +606,11 @@ yasm_cv__generate_symline(yasm_object *object, yasm_linemap *linemap, head = cv8_add_symhead(info.debug_symline, CV8_FILE_INFO, 0); off = 0; for (i=0; ifilenames_size; i++) { - if (!dbgfmt_cv->filenames[i].pathname) - continue; - bc = cv8_add_fileinfo(info.debug_symline, &dbgfmt_cv->filenames[i]); - dbgfmt_cv->filenames[i].info_off = off; - off += bc->len; + if (!dbgfmt_cv->filenames[i].pathname) + continue; + bc = cv8_add_fileinfo(info.debug_symline, &dbgfmt_cv->filenames[i]); + dbgfmt_cv->filenames[i].info_off = off; + off += bc->len; } cv8_set_symhead_end(head, yasm_section_bcs_last(info.debug_symline)); @@ -608,22 +618,16 @@ yasm_cv__generate_symline(yasm_object *object, yasm_linemap *linemap, /* Generate line numbers for sections */ yasm_object_sections_traverse(object, (void *)&info, - cv_generate_line_section); + cv_generate_line_section); /* Output line numbers for sections */ - head = NULL; STAILQ_FOREACH(li, &info.cv8_lineinfos, link) { - if (li->first_in_sect) { - if (head) - cv8_set_symhead_end(head, yasm_section_bcs_last(info.debug_symline)); - head = cv8_add_symhead(info.debug_symline, CV8_LINE_NUMS, 0); - } - bc = yasm_bc_create_common(&cv8_lineinfo_bc_callback, li, 0); - bc->len = (li->first_in_sect ? 24 : 12) + li->num_linenums*8; - yasm_cv__append_bc(info.debug_symline, bc); + head = cv8_add_symhead(info.debug_symline, CV8_LINE_NUMS, 0); + bc = yasm_bc_create_common(&cv8_lineinfo_bc_callback, li, 0); + bc->len = 24+li->num_linenums*8; + yasm_cv__append_bc(info.debug_symline, bc); + cv8_set_symhead_end(head, yasm_section_bcs_last(info.debug_symline)); } - if (head) - cv8_set_symhead_end(head, yasm_section_bcs_last(info.debug_symline)); /* Already aligned 4 */ @@ -631,21 +635,18 @@ yasm_cv__generate_symline(yasm_object *object, yasm_linemap *linemap, head = cv8_add_symhead(info.debug_symline, CV8_DEBUG_SYMS, 0); /* add object and compile flag first */ cv8_add_sym_objname(info.debug_symline, - yasm__abspath(object->obj_filename)); - if (getenv("YASM_TEST_SUITE")) - cv8_add_sym_compile(object, info.debug_symline, - yasm__xstrdup("yasm HEAD")); - else - cv8_add_sym_compile(object, info.debug_symline, - yasm__xstrdup(PACKAGE_STRING)); + yasm__abspath(object->obj_filename)); + cv8_add_sym_compile(object, info.debug_symline, + yasm__xstrdup(PACKAGE_NAME " " PACKAGE_INTVER "." + PACKAGE_BUILD)); /* then iterate through symbol table */ yasm_symtab_traverse(object->symtab, &info, cv_generate_sym); cv8_set_symhead_end(head, yasm_section_bcs_last(info.debug_symline)); /* Align 4 at end */ bc = yasm_bc_create_align - (yasm_expr_create_ident(yasm_expr_int(yasm_intnum_create_uint(4)), 0), - NULL, NULL, NULL, 0); + (yasm_expr_create_ident(yasm_expr_int(yasm_intnum_create_uint(4)), 0), + NULL, NULL, NULL, 0); yasm_bc_finalize(bc, yasm_cv__append_bc(info.debug_symline, bc)); yasm_bc_calc_len(bc, NULL, NULL); @@ -654,7 +655,7 @@ yasm_cv__generate_symline(yasm_object *object, yasm_linemap *linemap, static void cv_out_sym(yasm_symrec *sym, unsigned long off, yasm_bytecode *bc, - unsigned char **bufp, void *d, yasm_output_value_func output_value) + unsigned char **bufp, void *d, yasm_output_value_func output_value) { yasm_value val; @@ -684,9 +685,9 @@ cv8_add_symhead(yasm_section *sect, unsigned long type, int first) bc = yasm_bc_create_common(&cv8_symhead_bc_callback, head, 0); if (first) - bc->len = 12; + bc->len = 12; else - bc->len = 8; + bc->len = 8; head->end_prevbc = bc; yasm_cv__append_bc(sect, bc); @@ -713,7 +714,7 @@ cv8_symhead_bc_print(const void *contents, FILE *f, int indent_level) static int cv8_symhead_bc_calc_len(yasm_bytecode *bc, yasm_bc_add_span_func add_span, - void *add_span_data) + void *add_span_data) { yasm_internal_error(N_("tried to calc_len a codeview symhead bytecode")); /*@notreached@*/ @@ -721,10 +722,9 @@ cv8_symhead_bc_calc_len(yasm_bytecode *bc, yasm_bc_add_span_func add_span, } static int -cv8_symhead_bc_tobytes(yasm_bytecode *bc, unsigned char **bufp, - unsigned char *bufstart, void *d, - yasm_output_value_func output_value, - yasm_output_reloc_func output_reloc) +cv8_symhead_bc_tobytes(yasm_bytecode *bc, unsigned char **bufp, void *d, + yasm_output_value_func output_value, + yasm_output_reloc_func output_reloc) { yasm_object *object = yasm_section_get_object(bc->section); cv8_symhead *head = (cv8_symhead *)bc->contents; @@ -734,8 +734,8 @@ cv8_symhead_bc_tobytes(yasm_bytecode *bc, unsigned char **bufp, cval = yasm_intnum_create_uint(4); /* Output "version" if first */ if (head->first) { - yasm_arch_intnum_tobytes(object->arch, cval, buf, 4, 32, 0, bc, 0); - buf += 4; + yasm_arch_intnum_tobytes(object->arch, cval, buf, 4, 32, 0, bc, 0); + buf += 4; } /* Type contained - 4 bytes */ @@ -787,7 +787,7 @@ cv8_fileinfo_bc_print(const void *contents, FILE *f, int indent_level) static int cv8_fileinfo_bc_calc_len(yasm_bytecode *bc, yasm_bc_add_span_func add_span, - void *add_span_data) + void *add_span_data) { yasm_internal_error(N_("tried to calc_len a codeview fileinfo bytecode")); /*@notreached@*/ @@ -795,10 +795,9 @@ cv8_fileinfo_bc_calc_len(yasm_bytecode *bc, yasm_bc_add_span_func add_span, } static int -cv8_fileinfo_bc_tobytes(yasm_bytecode *bc, unsigned char **bufp, - unsigned char *bufstart, void *d, - yasm_output_value_func output_value, - yasm_output_reloc_func output_reloc) +cv8_fileinfo_bc_tobytes(yasm_bytecode *bc, unsigned char **bufp, void *d, + yasm_output_value_func output_value, + yasm_output_reloc_func output_reloc) { yasm_object *object = yasm_section_get_object(bc->section); cv8_fileinfo *fi = (cv8_fileinfo *)bc->contents; @@ -818,7 +817,7 @@ cv8_fileinfo_bc_tobytes(yasm_bytecode *bc, unsigned char **bufp, /* Checksum */ for (i=0; i<16; i++) - YASM_WRITE_8(buf, fi->fn->digest[i]); + YASM_WRITE_8(buf, fi->fn->digest[i]); /* Pad */ YASM_WRITE_8(buf, 0); @@ -839,9 +838,9 @@ cv8_lineinfo_bc_destroy(void *contents) /* delete line sets */ ls1 = STAILQ_FIRST(&li->linesets); while (ls1) { - ls2 = STAILQ_NEXT(ls1, link); - yasm_xfree(ls1); - ls1 = ls2; + ls2 = STAILQ_NEXT(ls1, link); + yasm_xfree(ls1); + ls1 = ls2; } yasm_xfree(contents); @@ -855,7 +854,7 @@ cv8_lineinfo_bc_print(const void *contents, FILE *f, int indent_level) static int cv8_lineinfo_bc_calc_len(yasm_bytecode *bc, yasm_bc_add_span_func add_span, - void *add_span_data) + void *add_span_data) { yasm_internal_error(N_("tried to calc_len a codeview linehead bytecode")); /*@notreached@*/ @@ -863,10 +862,9 @@ cv8_lineinfo_bc_calc_len(yasm_bytecode *bc, yasm_bc_add_span_func add_span, } static int -cv8_lineinfo_bc_tobytes(yasm_bytecode *bc, unsigned char **bufp, - unsigned char *bufstart, void *d, - yasm_output_value_func output_value, - yasm_output_reloc_func output_reloc) +cv8_lineinfo_bc_tobytes(yasm_bytecode *bc, unsigned char **bufp, void *d, + yasm_output_value_func output_value, + yasm_output_reloc_func output_reloc) { yasm_object *object = yasm_section_get_object(bc->section); cv8_lineinfo *li = (cv8_lineinfo *)bc->contents; @@ -875,25 +873,21 @@ cv8_lineinfo_bc_tobytes(yasm_bytecode *bc, unsigned char **bufp, unsigned long i; cv8_lineset *ls; - if (li->first_in_sect) { - /* start offset and section */ - cv_out_sym(li->sectsym, (unsigned long)(buf - bufstart), bc, &buf, - d, output_value); + /* start offset and section */ + cv_out_sym(li->sectsym, 0, bc, &buf, d, output_value); - /* Two bytes of pad/alignment */ - YASM_WRITE_8(buf, 0); - YASM_WRITE_8(buf, 0); + /* Two bytes of pad/alignment */ + YASM_WRITE_8(buf, 0); + YASM_WRITE_8(buf, 0); - /* Section length covered by line number info */ - cval = yasm_calc_bc_dist(yasm_section_bcs_first(li->sect), - yasm_section_bcs_last(li->sect)); - yasm_arch_intnum_tobytes(object->arch, cval, buf, 4, 32, 0, bc, 0); - yasm_intnum_destroy(cval); - buf += 4; - } + /* Section length covered by line number info */ + cval = yasm_calc_bc_dist(yasm_section_bcs_first(li->sect), + yasm_section_bcs_last(li->sect)); + yasm_arch_intnum_tobytes(object->arch, cval, buf, 4, 32, 0, bc, 0); + buf += 4; /* Offset of source file in info table */ - cval = yasm_intnum_create_uint(li->fn->info_off); + yasm_intnum_set_uint(cval, li->fn->info_off); yasm_arch_intnum_tobytes(object->arch, cval, buf, 4, 32, 0, bc, 0); buf += 4; @@ -910,18 +904,18 @@ cv8_lineinfo_bc_tobytes(yasm_bytecode *bc, unsigned char **bufp, /* Offset / line number pairs */ i = 0; STAILQ_FOREACH(ls, &li->linesets, link) { - unsigned long j; - for (j=0; inum_linenums && j<126; i++, j++) { - /* offset in section */ - yasm_intnum_set_uint(cval, ls->pairs[j].offset); - yasm_arch_intnum_tobytes(object->arch, cval, buf, 4, 32, 0, bc, 0); - buf += 4; + unsigned long j; + for (j=0; inum_linenums && j<126; i++, j++) { + /* offset in section */ + yasm_intnum_set_uint(cval, ls->pairs[j].offset); + yasm_arch_intnum_tobytes(object->arch, cval, buf, 4, 32, 0, bc, 0); + buf += 4; - /* line number in file */ - yasm_intnum_set_uint(cval, ls->pairs[j].line); - yasm_arch_intnum_tobytes(object->arch, cval, buf, 4, 32, 0, bc, 0); - buf += 4; - } + /* line number in file */ + yasm_intnum_set_uint(cval, ls->pairs[j].line); + yasm_arch_intnum_tobytes(object->arch, cval, buf, 4, 32, 0, bc, 0); + buf += 4; + } } *bufp = buf; @@ -939,40 +933,40 @@ cv_sym_size(const cv_sym *cvs) int arg = 0; while (*ch) { - switch (*ch) { - case 'b': - len++; - arg++; - break; - case 'h': - len += 2; - arg++; - break; - case 'w': - len += 4; - arg++; - break; - case 'Y': - len += 6; /* XXX: will be 4 in 16-bit version */ - arg++; - break; - case 'T': - len += 4; /* XXX: will be 2 in CV4 */ - arg++; - break; - case 'S': - len += 1; /* XXX: is this 1 or 2? */ - slen = (unsigned long)strlen((const char *)cvs->args[arg++].p); - len += slen <= 0xff ? slen : 0xff; - break; - case 'Z': - len += - (unsigned long)strlen((const char *)cvs->args[arg++].p) + 1; - break; - default: - yasm_internal_error(N_("unknown sym format character")); - } - ch++; + switch (*ch) { + case 'b': + len++; + arg++; + break; + case 'h': + len += 2; + arg++; + break; + case 'w': + len += 4; + arg++; + break; + case 'Y': + len += 6; /* XXX: will be 4 in 16-bit version */ + arg++; + break; + case 'T': + len += 4; /* XXX: will be 2 in CV4 */ + arg++; + break; + case 'S': + len += 1; /* XXX: is this 1 or 2? */ + slen = (unsigned long)strlen((const char *)cvs->args[arg++].p); + len += slen <= 0xff ? slen : 0xff; + break; + case 'Z': + len += + (unsigned long)strlen((const char *)cvs->args[arg++].p) + 1; + break; + default: + yasm_internal_error(N_("unknown sym format character")); + } + ch++; } return len; @@ -986,22 +980,22 @@ cv_sym_bc_destroy(void *contents) int arg = 0; while (*ch) { - switch (*ch) { - case 'b': - case 'h': - case 'w': - case 'Y': - case 'T': - arg++; - break; /* nothing to destroy */ - case 'S': - case 'Z': - yasm_xfree(cvs->args[arg++].p); - break; - default: - yasm_internal_error(N_("unknown sym format character")); - } - ch++; + switch (*ch) { + case 'b': + case 'h': + case 'w': + case 'Y': + case 'T': + arg++; + break; /* nothing to destroy */ + case 'S': + case 'Z': + yasm_xfree(cvs->args[arg++].p); + break; + default: + yasm_internal_error(N_("unknown sym format character")); + } + ch++; } yasm_xfree(contents); @@ -1015,7 +1009,7 @@ cv_sym_bc_print(const void *contents, FILE *f, int indent_level) static int cv_sym_bc_calc_len(yasm_bytecode *bc, yasm_bc_add_span_func add_span, - void *add_span_data) + void *add_span_data) { yasm_internal_error(N_("tried to calc_len a codeview sym bytecode")); /*@notreached@*/ @@ -1023,10 +1017,9 @@ cv_sym_bc_calc_len(yasm_bytecode *bc, yasm_bc_add_span_func add_span, } static int -cv_sym_bc_tobytes(yasm_bytecode *bc, unsigned char **bufp, - unsigned char *bufstart, void *d, - yasm_output_value_func output_value, - yasm_output_reloc_func output_reloc) +cv_sym_bc_tobytes(yasm_bytecode *bc, unsigned char **bufp, void *d, + yasm_output_value_func output_value, + yasm_output_reloc_func output_reloc) { yasm_object *object = yasm_section_get_object(bc->section); cv_sym *cvs = (cv_sym *)bc->contents; @@ -1047,52 +1040,52 @@ cv_sym_bc_tobytes(yasm_bytecode *bc, unsigned char **bufp, buf += 2; while (*ch) { - switch (*ch) { - case 'b': - YASM_WRITE_8(buf, cvs->args[arg].i); - arg++; - break; - case 'h': - yasm_intnum_set_uint(cval, cvs->args[arg++].i); - yasm_arch_intnum_tobytes(object->arch, cval, buf, 2, 16, 0, - bc, 0); - buf += 2; - break; - case 'w': - yasm_intnum_set_uint(cval, cvs->args[arg++].i); - yasm_arch_intnum_tobytes(object->arch, cval, buf, 4, 32, 0, - bc, 0); - buf += 4; - break; - case 'Y': - cv_out_sym((yasm_symrec *)cvs->args[arg++].p, - (unsigned long)(buf-bufstart), bc, &buf, d, - output_value); - break; - case 'T': - yasm_intnum_set_uint(cval, cvs->args[arg++].i); - yasm_arch_intnum_tobytes(object->arch, cval, buf, 4, 32, 0, - bc, 0); - buf += 4; /* XXX: will be 2 in CV4 */ - break; - case 'S': - len = strlen((char *)cvs->args[arg].p); - len = len <= 0xff ? len : 0xff; - YASM_WRITE_8(buf, len); - memcpy(buf, (char *)cvs->args[arg].p, len); - buf += len; - arg++; - break; - case 'Z': - len = strlen((char *)cvs->args[arg].p)+1; - memcpy(buf, (char *)cvs->args[arg].p, len); - buf += len; - arg++; - break; - default: - yasm_internal_error(N_("unknown leaf format character")); - } - ch++; + switch (*ch) { + case 'b': + YASM_WRITE_8(buf, cvs->args[arg].i); + arg++; + break; + case 'h': + yasm_intnum_set_uint(cval, cvs->args[arg++].i); + yasm_arch_intnum_tobytes(object->arch, cval, buf, 2, 16, 0, + bc, 0); + buf += 2; + break; + case 'w': + yasm_intnum_set_uint(cval, cvs->args[arg++].i); + yasm_arch_intnum_tobytes(object->arch, cval, buf, 4, 32, 0, + bc, 0); + buf += 4; + break; + case 'Y': + cv_out_sym((yasm_symrec *)cvs->args[arg++].p, + (unsigned long)(buf-(*bufp)), bc, &buf, d, + output_value); + break; + case 'T': + yasm_intnum_set_uint(cval, cvs->args[arg++].i); + yasm_arch_intnum_tobytes(object->arch, cval, buf, 4, 32, 0, + bc, 0); + buf += 4; /* XXX: will be 2 in CV4 */ + break; + case 'S': + len = strlen((char *)cvs->args[arg].p); + len = len <= 0xff ? len : 0xff; + YASM_WRITE_8(buf, len); + memcpy(buf, (char *)cvs->args[arg].p, len); + buf += len; + arg++; + break; + case 'Z': + len = strlen((char *)cvs->args[arg].p)+1; + memcpy(buf, (char *)cvs->args[arg].p, len); + buf += len; + arg++; + break; + default: + yasm_internal_error(N_("unknown leaf format character")); + } + ch++; } *bufp = buf; diff --git a/modules/dbgfmts/codeview/cv-type.c b/modules/dbgfmts/codeview/cv-type.c index c374c2ba..f92f1884 100644 --- a/modules/dbgfmts/codeview/cv-type.c +++ b/modules/dbgfmts/codeview/cv-type.c @@ -28,428 +28,431 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include +/*@unused@*/ RCSID("$Id$"); +#define YASM_LIB_INTERNAL +#define YASM_BC_INTERNAL #include #include "cv-dbgfmt.h" enum cv_reservedtype { /* Bitfields representation - type */ - CV_TYPE_SPECIAL = 0x00<<4, /* Special */ - CV_TYPE_SIGNED = 0x01<<4, /* Signed integral value */ - CV_TYPE_UNSIGNED = 0x02<<4, /* Unsigned integral value */ - CV_TYPE_BOOLEAN = 0x03<<4, /* Boolean */ - CV_TYPE_REAL = 0x04<<4, /* Real */ - CV_TYPE_COMPLEX = 0x05<<4, /* Complex */ - CV_TYPE_SPECIAL2 = 0x06<<4, /* Special2 */ - CV_TYPE_REALINT = 0x07<<4, /* Really int value */ + CV_TYPE_SPECIAL = 0x00<<4, /* Special */ + CV_TYPE_SIGNED = 0x01<<4, /* Signed integral value */ + CV_TYPE_UNSIGNED = 0x02<<4, /* Unsigned integral value */ + CV_TYPE_BOOLEAN = 0x03<<4, /* Boolean */ + CV_TYPE_REAL = 0x04<<4, /* Real */ + CV_TYPE_COMPLEX = 0x05<<4, /* Complex */ + CV_TYPE_SPECIAL2 = 0x06<<4, /* Special2 */ + CV_TYPE_REALINT = 0x07<<4, /* Really int value */ /* "size" of CV_TYPE_SPECIAL */ - CV_SPECIAL_NOTYPE = 0x00<<0, /* No type */ - CV_SPECIAL_ABS = 0x01<<0, /* Absolute symbol */ - CV_SPECIAL_SEG = 0x02<<0, /* Segment */ - CV_SPECIAL_VOID = 0x03<<0, /* Void */ - CV_SPECIAL_CURRENCY = 0x04<<0, /* Basic 8-byte currency value */ - CV_SPECIAL_NEARBSTR = 0x05<<0, /* Near Basic string */ - CV_SPECIAL_FARBSTR = 0x06<<0, /* Far Basic string */ + CV_SPECIAL_NOTYPE = 0x00<<0, /* No type */ + CV_SPECIAL_ABS = 0x01<<0, /* Absolute symbol */ + CV_SPECIAL_SEG = 0x02<<0, /* Segment */ + CV_SPECIAL_VOID = 0x03<<0, /* Void */ + CV_SPECIAL_CURRENCY = 0x04<<0, /* Basic 8-byte currency value */ + CV_SPECIAL_NEARBSTR = 0x05<<0, /* Near Basic string */ + CV_SPECIAL_FARBSTR = 0x06<<0, /* Far Basic string */ /* Size of CV_TYPE_SIGNED, CV_TYPE_UNSIGNED, and CV_TYPE_BOOLEAN */ - CV_INTEGER_1BYTE = 0x00<<0, /* 1 byte */ - CV_INTEGER_2BYTE = 0x01<<0, /* 2 byte */ - CV_INTEGER_4BYTE = 0x02<<0, /* 4 byte */ - CV_INTEGER_8BYTE = 0x03<<0, /* 8 byte */ + CV_INTEGER_1BYTE = 0x00<<0, /* 1 byte */ + CV_INTEGER_2BYTE = 0x01<<0, /* 2 byte */ + CV_INTEGER_4BYTE = 0x02<<0, /* 4 byte */ + CV_INTEGER_8BYTE = 0x03<<0, /* 8 byte */ /* Size of CV_TYPE_REAL and CV_TYPE_COMPLEX */ - CV_REAL_32BIT = 0x00<<0, /* 32 bit */ - CV_REAL_64BIT = 0x01<<0, /* 64 bit */ - CV_REAL_80BIT = 0x02<<0, /* 80 bit */ - CV_REAL_128BIT = 0x03<<0, /* 128 bit */ - CV_REAL_48BIT = 0x04<<0, /* 48 bit */ + CV_REAL_32BIT = 0x00<<0, /* 32 bit */ + CV_REAL_64BIT = 0x01<<0, /* 64 bit */ + CV_REAL_80BIT = 0x02<<0, /* 80 bit */ + CV_REAL_128BIT = 0x03<<0, /* 128 bit */ + CV_REAL_48BIT = 0x04<<0, /* 48 bit */ /* "size" of CV_TYPE_SPECIAL2 */ - CV_SPECIAL2_BIT = 0x00<<0, /* Bit */ - CV_SPECIAL2_PASCHAR = 0x01<<0, /* Pascal CHAR */ + CV_SPECIAL2_BIT = 0x00<<0, /* Bit */ + CV_SPECIAL2_PASCHAR = 0x01<<0, /* Pascal CHAR */ /* Size of CV_TYPE_REALINT */ - CV_REALINT_CHAR = 0x00<<0, /* Char */ - CV_REALINT_WCHAR = 0x01<<0, /* Wide character */ - CV_REALINT_S2BYTE = 0x02<<0, /* 2-byte signed integer */ - CV_REALINT_U2BYTE = 0x03<<0, /* 2-byte unsigned integer */ - CV_REALINT_S4BYTE = 0x04<<0, /* 4-byte signed integer */ - CV_REALINT_U4BYTE = 0x05<<0, /* 4-byte unsigned integer */ - CV_REALINT_S8BYTE = 0x06<<0, /* 8-byte signed integer */ - CV_REALINT_U8BYTE = 0x07<<0, /* 8-byte unsigned integer */ + CV_REALINT_CHAR = 0x00<<0, /* Char */ + CV_REALINT_WCHAR = 0x01<<0, /* Wide character */ + CV_REALINT_S2BYTE = 0x02<<0, /* 2-byte signed integer */ + CV_REALINT_U2BYTE = 0x03<<0, /* 2-byte unsigned integer */ + CV_REALINT_S4BYTE = 0x04<<0, /* 4-byte signed integer */ + CV_REALINT_U4BYTE = 0x05<<0, /* 4-byte unsigned integer */ + CV_REALINT_S8BYTE = 0x06<<0, /* 8-byte signed integer */ + CV_REALINT_U8BYTE = 0x07<<0, /* 8-byte unsigned integer */ /* Mode */ - CV_MODE_DIRECT = 0x00<<8, /* Direct; not a pointer */ - CV_MODE_NEAR = 0x01<<8, /* Near pointer */ - CV_MODE_FAR = 0x02<<8, /* Far pointer */ - CV_MODE_HUGE = 0x03<<8, /* Huge pointer */ - CV_MODE_NEAR32 = 0x04<<8, /* 32-bit near pointer */ - CV_MODE_FAR32 = 0x05<<8, /* 32-bit far pointer */ - CV_MODE_NEAR64 = 0x06<<8, /* 64-bit near pointer */ + CV_MODE_DIRECT = 0x00<<8, /* Direct; not a pointer */ + CV_MODE_NEAR = 0x01<<8, /* Near pointer */ + CV_MODE_FAR = 0x02<<8, /* Far pointer */ + CV_MODE_HUGE = 0x03<<8, /* Huge pointer */ + CV_MODE_NEAR32 = 0x04<<8, /* 32-bit near pointer */ + CV_MODE_FAR32 = 0x05<<8, /* 32-bit far pointer */ + CV_MODE_NEAR64 = 0x06<<8, /* 64-bit near pointer */ /* Pure primitive type listing - based on above bitfields */ /* Special Types */ - CV_T_NOTYPE = 0x0000, /* Uncharacterized type (no type) */ - CV_T_ABS = 0x0001, /* Absolute symbol */ - CV_T_SEGMENT = 0x0002, /* Segment type */ - CV_T_VOID = 0x0003, /* Void */ - CV_T_PVOID = 0x0103, /* Near pointer to void */ - CV_T_PFVOID = 0x0203, /* Far pointer to void */ - CV_T_PHVOID = 0x0303, /* Huge pointer to void */ - CV_T_32PVOID = 0x0403, /* 32-bit near pointer to void */ - CV_T_32PFVOID = 0x0503, /* 32-bit far pointer to void */ - CV_T_CURRENCY = 0x0004, /* Basic 8-byte currency value */ - CV_T_NBASICSTR = 0x0005, /* Near Basic string */ - CV_T_FBASICSTR = 0x0006, /* Far Basic string */ - CV_T_BIT = 0x0060, /* Bit */ - CV_T_PASCHAR = 0x0061, /* Pascal CHAR */ + CV_T_NOTYPE = 0x0000, /* Uncharacterized type (no type) */ + CV_T_ABS = 0x0001, /* Absolute symbol */ + CV_T_SEGMENT = 0x0002, /* Segment type */ + CV_T_VOID = 0x0003, /* Void */ + CV_T_PVOID = 0x0103, /* Near pointer to void */ + CV_T_PFVOID = 0x0203, /* Far pointer to void */ + CV_T_PHVOID = 0x0303, /* Huge pointer to void */ + CV_T_32PVOID = 0x0403, /* 32-bit near pointer to void */ + CV_T_32PFVOID = 0x0503, /* 32-bit far pointer to void */ + CV_T_CURRENCY = 0x0004, /* Basic 8-byte currency value */ + CV_T_NBASICSTR = 0x0005, /* Near Basic string */ + CV_T_FBASICSTR = 0x0006, /* Far Basic string */ + CV_T_BIT = 0x0060, /* Bit */ + CV_T_PASCHAR = 0x0061, /* Pascal CHAR */ /* Character Types */ - CV_T_CHAR = 0x0010, /* 8-bit signed */ - CV_T_UCHAR = 0x0020, /* 8-bit unsigned */ - CV_T_PCHAR = 0x0110, /* Near pointer to 8-bit signed */ - CV_T_PUCHAR = 0x0120, /* Near pointer to 8-bit unsigned */ - CV_T_PFCHAR = 0x0210, /* Far pointer to 8-bit signed */ - CV_T_PFUCHAR = 0x0220, /* Far pointer to 8-bit unsigned */ - CV_T_PHCHAR = 0x0310, /* Huge pointer to 8-bit signed */ - CV_T_PHUCHAR = 0x0320, /* Huge pointer to 8-bit unsigned */ - CV_T_32PCHAR = 0x0410, /* 16:32 near pointer to 8-bit signed */ - CV_T_32PUCHAR = 0x0420, /* 16:32 near pointer to 8-bit unsigned */ - CV_T_32PFCHAR = 0x0510, /* 16:32 far pointer to 8-bit signed */ - CV_T_32PFUCHAR = 0x0520, /* 16:32 far pointer to 8-bit unsigned */ + CV_T_CHAR = 0x0010, /* 8-bit signed */ + CV_T_UCHAR = 0x0020, /* 8-bit unsigned */ + CV_T_PCHAR = 0x0110, /* Near pointer to 8-bit signed */ + CV_T_PUCHAR = 0x0120, /* Near pointer to 8-bit unsigned */ + CV_T_PFCHAR = 0x0210, /* Far pointer to 8-bit signed */ + CV_T_PFUCHAR = 0x0220, /* Far pointer to 8-bit unsigned */ + CV_T_PHCHAR = 0x0310, /* Huge pointer to 8-bit signed */ + CV_T_PHUCHAR = 0x0320, /* Huge pointer to 8-bit unsigned */ + CV_T_32PCHAR = 0x0410, /* 16:32 near pointer to 8-bit signed */ + CV_T_32PUCHAR = 0x0420, /* 16:32 near pointer to 8-bit unsigned */ + CV_T_32PFCHAR = 0x0510, /* 16:32 far pointer to 8-bit signed */ + CV_T_32PFUCHAR = 0x0520, /* 16:32 far pointer to 8-bit unsigned */ /* Real Character Types */ - CV_T_RCHAR = 0x0070, /* Real char */ - CV_T_PRCHAR = 0x0170, /* Near pointer to a real char */ - CV_T_PFRCHAR = 0x0270, /* Far pointer to a real char */ - CV_T_PHRCHAR = 0x0370, /* Huge pointer to a real char */ - CV_T_32PRCHAR = 0x0470, /* 16:32 near pointer to a real char */ - CV_T_32PFRCHAR = 0x0570, /* 16:32 far pointer to a real char */ + CV_T_RCHAR = 0x0070, /* Real char */ + CV_T_PRCHAR = 0x0170, /* Near pointer to a real char */ + CV_T_PFRCHAR = 0x0270, /* Far pointer to a real char */ + CV_T_PHRCHAR = 0x0370, /* Huge pointer to a real char */ + CV_T_32PRCHAR = 0x0470, /* 16:32 near pointer to a real char */ + CV_T_32PFRCHAR = 0x0570, /* 16:32 far pointer to a real char */ /* Wide Character Types */ - CV_T_WCHAR = 0x0071, /* Wide char */ - CV_T_PWCHAR = 0x0171, /* Near pointer to a wide char */ - CV_T_PFWCHAR = 0x0271, /* Far pointer to a wide char */ - CV_T_PHWCHAR = 0x0371, /* Huge pointer to a wide char */ - CV_T_32PWCHAR = 0x0471, /* 16:32 near pointer to a wide char */ - CV_T_32PFWCHAR = 0x0571, /* 16:32 far pointer to a wide char */ + CV_T_WCHAR = 0x0071, /* Wide char */ + CV_T_PWCHAR = 0x0171, /* Near pointer to a wide char */ + CV_T_PFWCHAR = 0x0271, /* Far pointer to a wide char */ + CV_T_PHWCHAR = 0x0371, /* Huge pointer to a wide char */ + CV_T_32PWCHAR = 0x0471, /* 16:32 near pointer to a wide char */ + CV_T_32PFWCHAR = 0x0571, /* 16:32 far pointer to a wide char */ /* Real 16-bit Integer Types */ - CV_T_INT2 = 0x0072, /* Real 16-bit signed int */ - CV_T_UINT2 = 0x0073, /* Real 16-bit unsigned int */ - CV_T_PINT2 = 0x0172, /* Near pointer to 16-bit signed int */ - CV_T_PUINT2 = 0x0173, /* Near pointer to 16-bit unsigned int */ - CV_T_PFINT2 = 0x0272, /* Far pointer to 16-bit signed int */ - CV_T_PFUINT2 = 0x0273, /* Far pointer to 16-bit unsigned int */ - CV_T_PHINT2 = 0x0372, /* Huge pointer to 16-bit signed int */ - CV_T_PHUINT2 = 0x0373, /* Huge pointer to 16-bit unsigned int */ - CV_T_32PINT2 = 0x0472, /* 16:32 near pointer to 16-bit signed int */ - CV_T_32PUINT2 = 0x0473, /* 16:32 near pointer to 16-bit unsigned int */ - CV_T_32PFINT2 = 0x0572, /* 16:32 far pointer to 16-bit signed int */ - CV_T_32PFUINT2 = 0x0573, /* 16:32 far pointer to 16-bit unsigned int */ + CV_T_INT2 = 0x0072, /* Real 16-bit signed int */ + CV_T_UINT2 = 0x0073, /* Real 16-bit unsigned int */ + CV_T_PINT2 = 0x0172, /* Near pointer to 16-bit signed int */ + CV_T_PUINT2 = 0x0173, /* Near pointer to 16-bit unsigned int */ + CV_T_PFINT2 = 0x0272, /* Far pointer to 16-bit signed int */ + CV_T_PFUINT2 = 0x0273, /* Far pointer to 16-bit unsigned int */ + CV_T_PHINT2 = 0x0372, /* Huge pointer to 16-bit signed int */ + CV_T_PHUINT2 = 0x0373, /* Huge pointer to 16-bit unsigned int */ + CV_T_32PINT2 = 0x0472, /* 16:32 near pointer to 16-bit signed int */ + CV_T_32PUINT2 = 0x0473, /* 16:32 near pointer to 16-bit unsigned int */ + CV_T_32PFINT2 = 0x0572, /* 16:32 far pointer to 16-bit signed int */ + CV_T_32PFUINT2 = 0x0573, /* 16:32 far pointer to 16-bit unsigned int */ /* 16-bit Short Types */ - CV_T_SHORT = 0x0011, /* 16-bit signed */ - CV_T_USHORT = 0x0021, /* 16-bit unsigned */ - CV_T_PSHORT = 0x0111, /* Near pointer to 16-bit signed */ - CV_T_PUSHORT = 0x0121, /* Near pointer to 16-bit unsigned */ - CV_T_PFSHORT = 0x0211, /* Far pointer to 16-bit signed */ - CV_T_PFUSHORT = 0x0221, /* Far pointer to 16-bit unsigned */ - CV_T_PHSHORT = 0x0311, /* Huge pointer to 16-bit signed */ - CV_T_PHUSHORT = 0x0321, /* Huge pointer to 16-bit unsigned */ - CV_T_32PSHORT = 0x0411, /* 16:32 near pointer to 16-bit signed */ - CV_T_32PUSHORT = 0x0421, /* 16:32 near pointer to 16-bit unsigned */ - CV_T_32PFSHORT = 0x0511, /* 16:32 far pointer to 16-bit signed */ - CV_T_32PFUSHORT = 0x0521, /* 16:32 far pointer to 16-bit unsigned */ + CV_T_SHORT = 0x0011, /* 16-bit signed */ + CV_T_USHORT = 0x0021, /* 16-bit unsigned */ + CV_T_PSHORT = 0x0111, /* Near pointer to 16-bit signed */ + CV_T_PUSHORT = 0x0121, /* Near pointer to 16-bit unsigned */ + CV_T_PFSHORT = 0x0211, /* Far pointer to 16-bit signed */ + CV_T_PFUSHORT = 0x0221, /* Far pointer to 16-bit unsigned */ + CV_T_PHSHORT = 0x0311, /* Huge pointer to 16-bit signed */ + CV_T_PHUSHORT = 0x0321, /* Huge pointer to 16-bit unsigned */ + CV_T_32PSHORT = 0x0411, /* 16:32 near pointer to 16-bit signed */ + CV_T_32PUSHORT = 0x0421, /* 16:32 near pointer to 16-bit unsigned */ + CV_T_32PFSHORT = 0x0511, /* 16:32 far pointer to 16-bit signed */ + CV_T_32PFUSHORT = 0x0521, /* 16:32 far pointer to 16-bit unsigned */ /* Real 32-bit Integer Types */ - CV_T_INT4 = 0x0074, /* Real 32-bit signed int */ - CV_T_UINT4 = 0x0075, /* Real 32-bit unsigned int */ - CV_T_PINT4 = 0x0174, /* Near pointer to 32-bit signed int */ - CV_T_PUINT4 = 0x0175, /* Near pointer to 32-bit unsigned int */ - CV_T_PFINT4 = 0x0274, /* Far pointer to 32-bit signed int */ - CV_T_PFUINT4 = 0x0275, /* Far pointer to 32-bit unsigned int */ - CV_T_PHINT4 = 0x0374, /* Huge pointer to 32-bit signed int */ - CV_T_PHUINT4 = 0x0375, /* Huge pointer to 32-bit unsigned int */ - CV_T_32PINT4 = 0x0474, /* 16:32 near pointer to 32-bit signed int */ - CV_T_32PUINT4 = 0x0475, /* 16:32 near pointer to 32-bit unsigned int */ - CV_T_32PFINT4 = 0x0574, /* 16:32 far pointer to 32-bit signed int */ - CV_T_32PFUINT4 = 0x0575, /* 16:32 far pointer to 32-bit unsigned int */ + CV_T_INT4 = 0x0074, /* Real 32-bit signed int */ + CV_T_UINT4 = 0x0075, /* Real 32-bit unsigned int */ + CV_T_PINT4 = 0x0174, /* Near pointer to 32-bit signed int */ + CV_T_PUINT4 = 0x0175, /* Near pointer to 32-bit unsigned int */ + CV_T_PFINT4 = 0x0274, /* Far pointer to 32-bit signed int */ + CV_T_PFUINT4 = 0x0275, /* Far pointer to 32-bit unsigned int */ + CV_T_PHINT4 = 0x0374, /* Huge pointer to 32-bit signed int */ + CV_T_PHUINT4 = 0x0375, /* Huge pointer to 32-bit unsigned int */ + CV_T_32PINT4 = 0x0474, /* 16:32 near pointer to 32-bit signed int */ + CV_T_32PUINT4 = 0x0475, /* 16:32 near pointer to 32-bit unsigned int */ + CV_T_32PFINT4 = 0x0574, /* 16:32 far pointer to 32-bit signed int */ + CV_T_32PFUINT4 = 0x0575, /* 16:32 far pointer to 32-bit unsigned int */ /* 32-bit Long Types */ - CV_T_LONG = 0x0012, /* 32-bit signed */ - CV_T_ULONG = 0x0022, /* 32-bit unsigned */ - CV_T_PLONG = 0x0112, /* Near pointer to 32-bit signed */ - CV_T_PULONG = 0x0122, /* Near pointer to 32-bit unsigned */ - CV_T_PFLONG = 0x0212, /* Far pointer to 32-bit signed */ - CV_T_PFULONG = 0x0222, /* Far pointer to 32-bit unsigned */ - CV_T_PHLONG = 0x0312, /* Huge pointer to 32-bit signed */ - CV_T_PHULONG = 0x0322, /* Huge pointer to 32-bit unsigned */ - CV_T_32PLONG = 0x0412, /* 16:32 near pointer to 32-bit signed */ - CV_T_32PULONG = 0x0422, /* 16:32 near pointer to 32-bit unsigned */ - CV_T_32PFLONG = 0x0512, /* 16:32 far pointer to 32-bit signed */ - CV_T_32PFULONG = 0x0522, /* 16:32 far pointer to 32-bit unsigned */ + CV_T_LONG = 0x0012, /* 32-bit signed */ + CV_T_ULONG = 0x0022, /* 32-bit unsigned */ + CV_T_PLONG = 0x0112, /* Near pointer to 32-bit signed */ + CV_T_PULONG = 0x0122, /* Near pointer to 32-bit unsigned */ + CV_T_PFLONG = 0x0212, /* Far pointer to 32-bit signed */ + CV_T_PFULONG = 0x0222, /* Far pointer to 32-bit unsigned */ + CV_T_PHLONG = 0x0312, /* Huge pointer to 32-bit signed */ + CV_T_PHULONG = 0x0322, /* Huge pointer to 32-bit unsigned */ + CV_T_32PLONG = 0x0412, /* 16:32 near pointer to 32-bit signed */ + CV_T_32PULONG = 0x0422, /* 16:32 near pointer to 32-bit unsigned */ + CV_T_32PFLONG = 0x0512, /* 16:32 far pointer to 32-bit signed */ + CV_T_32PFULONG = 0x0522, /* 16:32 far pointer to 32-bit unsigned */ /* Real 64-bit int Types */ - CV_T_INT8 = 0x0076, /* 64-bit signed int */ - CV_T_UINT8 = 0x0077, /* 64-bit unsigned int */ - CV_T_PINT8 = 0x0176, /* Near pointer to 64-bit signed int */ - CV_T_PUINT8 = 0x0177, /* Near pointer to 64-bit unsigned int */ - CV_T_PFINT8 = 0x0276, /* Far pointer to 64-bit signed int */ - CV_T_PFUINT8 = 0x0277, /* Far pointer to 64-bit unsigned int */ - CV_T_PHINT8 = 0x0376, /* Huge pointer to 64-bit signed int */ - CV_T_PHUINT8 = 0x0377, /* Huge pointer to 64-bit unsigned int */ - CV_T_32PINT8 = 0x0476, /* 16:32 near pointer to 64-bit signed int */ - CV_T_32PUINT8 = 0x0477, /* 16:32 near pointer to 64-bit unsigned int */ - CV_T_32PFINT8 = 0x0576, /* 16:32 far pointer to 64-bit signed int */ - CV_T_32PFUINT8 = 0x0577, /* 16:32 far pointer to 64-bit unsigned int */ + CV_T_INT8 = 0x0076, /* 64-bit signed int */ + CV_T_UINT8 = 0x0077, /* 64-bit unsigned int */ + CV_T_PINT8 = 0x0176, /* Near pointer to 64-bit signed int */ + CV_T_PUINT8 = 0x0177, /* Near pointer to 64-bit unsigned int */ + CV_T_PFINT8 = 0x0276, /* Far pointer to 64-bit signed int */ + CV_T_PFUINT8 = 0x0277, /* Far pointer to 64-bit unsigned int */ + CV_T_PHINT8 = 0x0376, /* Huge pointer to 64-bit signed int */ + CV_T_PHUINT8 = 0x0377, /* Huge pointer to 64-bit unsigned int */ + CV_T_32PINT8 = 0x0476, /* 16:32 near pointer to 64-bit signed int */ + CV_T_32PUINT8 = 0x0477, /* 16:32 near pointer to 64-bit unsigned int */ + CV_T_32PFINT8 = 0x0576, /* 16:32 far pointer to 64-bit signed int */ + CV_T_32PFUINT8 = 0x0577, /* 16:32 far pointer to 64-bit unsigned int */ /* 64-bit Integral Types */ - CV_T_QUAD = 0x0013, /* 64-bit signed */ - CV_T_UQUAD = 0x0023, /* 64-bit unsigned */ - CV_T_PQUAD = 0x0113, /* Near pointer to 64-bit signed */ - CV_T_PUQUAD = 0x0123, /* Near pointer to 64-bit unsigned */ - CV_T_PFQUAD = 0x0213, /* Far pointer to 64-bit signed */ - CV_T_PFUQUAD = 0x0223, /* Far pointer to 64-bit unsigned */ - CV_T_PHQUAD = 0x0313, /* Huge pointer to 64-bit signed */ - CV_T_PHUQUAD = 0x0323, /* Huge pointer to 64-bit unsigned */ - CV_T_32PQUAD = 0x0413, /* 16:32 near pointer to 64-bit signed */ - CV_T_32PUQUAD = 0x0423, /* 16:32 near pointer to 64-bit unsigned */ - CV_T_32PFQUAD = 0x0513, /* 16:32 far pointer to 64-bit signed */ - CV_T_32PFUQUAD = 0x0523, /* 16:32 far pointer to 64-bit unsigned */ + CV_T_QUAD = 0x0013, /* 64-bit signed */ + CV_T_UQUAD = 0x0023, /* 64-bit unsigned */ + CV_T_PQUAD = 0x0113, /* Near pointer to 64-bit signed */ + CV_T_PUQUAD = 0x0123, /* Near pointer to 64-bit unsigned */ + CV_T_PFQUAD = 0x0213, /* Far pointer to 64-bit signed */ + CV_T_PFUQUAD = 0x0223, /* Far pointer to 64-bit unsigned */ + CV_T_PHQUAD = 0x0313, /* Huge pointer to 64-bit signed */ + CV_T_PHUQUAD = 0x0323, /* Huge pointer to 64-bit unsigned */ + CV_T_32PQUAD = 0x0413, /* 16:32 near pointer to 64-bit signed */ + CV_T_32PUQUAD = 0x0423, /* 16:32 near pointer to 64-bit unsigned */ + CV_T_32PFQUAD = 0x0513, /* 16:32 far pointer to 64-bit signed */ + CV_T_32PFUQUAD = 0x0523, /* 16:32 far pointer to 64-bit unsigned */ /* 32-bit Real Types */ - CV_T_REAL32 = 0x0040, /* 32-bit real */ - CV_T_PREAL32 = 0x0140, /* Near pointer to 32-bit real */ - CV_T_PFREAL32 = 0x0240, /* Far pointer to 32-bit real */ - CV_T_PHREAL32 = 0x0340, /* Huge pointer to 32-bit real */ - CV_T_32PREAL32 = 0x0440, /* 16:32 near pointer to 32-bit real */ - CV_T_32PFREAL32 = 0x0540, /* 16:32 far pointer to 32-bit real */ + CV_T_REAL32 = 0x0040, /* 32-bit real */ + CV_T_PREAL32 = 0x0140, /* Near pointer to 32-bit real */ + CV_T_PFREAL32 = 0x0240, /* Far pointer to 32-bit real */ + CV_T_PHREAL32 = 0x0340, /* Huge pointer to 32-bit real */ + CV_T_32PREAL32 = 0x0440, /* 16:32 near pointer to 32-bit real */ + CV_T_32PFREAL32 = 0x0540, /* 16:32 far pointer to 32-bit real */ /* 48-bit Real Types */ - CV_T_REAL48 = 0x0044, /* 48-bit real */ - CV_T_PREAL48 = 0x0144, /* Near pointer to 48-bit real */ - CV_T_PFREAL48 = 0x0244, /* Far pointer to 48-bit real */ - CV_T_PHREAL48 = 0x0344, /* Huge pointer to 48-bit real */ - CV_T_32PREAL48 = 0x0444, /* 16:32 near pointer to 48-bit real */ - CV_T_32PFREAL48 = 0x0544, /* 16:32 far pointer to 48-bit real */ + CV_T_REAL48 = 0x0044, /* 48-bit real */ + CV_T_PREAL48 = 0x0144, /* Near pointer to 48-bit real */ + CV_T_PFREAL48 = 0x0244, /* Far pointer to 48-bit real */ + CV_T_PHREAL48 = 0x0344, /* Huge pointer to 48-bit real */ + CV_T_32PREAL48 = 0x0444, /* 16:32 near pointer to 48-bit real */ + CV_T_32PFREAL48 = 0x0544, /* 16:32 far pointer to 48-bit real */ /* 64-bit Real Types */ - CV_T_REAL64 = 0x0041, /* 64-bit real */ - CV_T_PREAL64 = 0x0141, /* Near pointer to 64-bit real */ - CV_T_PFREAL64 = 0x0241, /* Far pointer to 64-bit real */ - CV_T_PHREAL64 = 0x0341, /* Huge pointer to 64-bit real */ - CV_T_32PREAL64 = 0x0441, /* 16:32 near pointer to 64-bit real */ - CV_T_32PFREAL64 = 0x0541, /* 16:32 far pointer to 64-bit real */ + CV_T_REAL64 = 0x0041, /* 64-bit real */ + CV_T_PREAL64 = 0x0141, /* Near pointer to 64-bit real */ + CV_T_PFREAL64 = 0x0241, /* Far pointer to 64-bit real */ + CV_T_PHREAL64 = 0x0341, /* Huge pointer to 64-bit real */ + CV_T_32PREAL64 = 0x0441, /* 16:32 near pointer to 64-bit real */ + CV_T_32PFREAL64 = 0x0541, /* 16:32 far pointer to 64-bit real */ /* 80-bit Real Types */ - CV_T_REAL80 = 0x0042, /* 80-bit real */ - CV_T_PREAL80 = 0x0142, /* Near pointer to 80-bit real */ - CV_T_PFREAL80 = 0x0242, /* Far pointer to 80-bit real */ - CV_T_PHREAL80 = 0x0342, /* Huge pointer to 80-bit real */ - CV_T_32PREAL80 = 0x0442, /* 16:32 near pointer to 80-bit real */ - CV_T_32PFREAL80 = 0x0542, /* 16:32 far pointer to 80-bit real */ + CV_T_REAL80 = 0x0042, /* 80-bit real */ + CV_T_PREAL80 = 0x0142, /* Near pointer to 80-bit real */ + CV_T_PFREAL80 = 0x0242, /* Far pointer to 80-bit real */ + CV_T_PHREAL80 = 0x0342, /* Huge pointer to 80-bit real */ + CV_T_32PREAL80 = 0x0442, /* 16:32 near pointer to 80-bit real */ + CV_T_32PFREAL80 = 0x0542, /* 16:32 far pointer to 80-bit real */ /* 128-bit Real Types */ - CV_T_REAL128 = 0x0043, /* 128-bit real */ - CV_T_PREAL128 = 0x0143, /* Near pointer to 128-bit real */ - CV_T_PFREAL128 = 0x0243, /* Far pointer to 128-bit real */ - CV_T_PHREAL128 = 0x0343, /* Huge pointer to 128-bit real */ - CV_T_32PREAL128 = 0x0443, /* 16:32 near pointer to 128-bit real */ - CV_T_32PFREAL128 = 0x0543, /* 16:32 far pointer to 128-bit real */ + CV_T_REAL128 = 0x0043, /* 128-bit real */ + CV_T_PREAL128 = 0x0143, /* Near pointer to 128-bit real */ + CV_T_PFREAL128 = 0x0243, /* Far pointer to 128-bit real */ + CV_T_PHREAL128 = 0x0343, /* Huge pointer to 128-bit real */ + CV_T_32PREAL128 = 0x0443, /* 16:32 near pointer to 128-bit real */ + CV_T_32PFREAL128 = 0x0543, /* 16:32 far pointer to 128-bit real */ /* 32-bit Complex Types */ - CV_T_CPLX32 = 0x0050, /* 32-bit complex */ - CV_T_PCPLX32 = 0x0150, /* Near pointer to 32-bit complex */ - CV_T_PFCPLX32 = 0x0250, /* Far pointer to 32-bit complex */ - CV_T_PHCPLX32 = 0x0350, /* Huge pointer to 32-bit complex */ - CV_T_32PCPLX32 = 0x0450, /* 16:32 near pointer to 32-bit complex */ - CV_T_32PFCPLX32 = 0x0550, /* 16:32 far pointer to 32-bit complex */ + CV_T_CPLX32 = 0x0050, /* 32-bit complex */ + CV_T_PCPLX32 = 0x0150, /* Near pointer to 32-bit complex */ + CV_T_PFCPLX32 = 0x0250, /* Far pointer to 32-bit complex */ + CV_T_PHCPLX32 = 0x0350, /* Huge pointer to 32-bit complex */ + CV_T_32PCPLX32 = 0x0450, /* 16:32 near pointer to 32-bit complex */ + CV_T_32PFCPLX32 = 0x0550, /* 16:32 far pointer to 32-bit complex */ /* 64-bit Complex Types */ - CV_T_CPLX64 = 0x0051, /* 64-bit complex */ - CV_T_PCPLX64 = 0x0151, /* Near pointer to 64-bit complex */ - CV_T_PFCPLX64 = 0x0251, /* Far pointer to 64-bit complex */ - CV_T_PHCPLX64 = 0x0351, /* Huge pointer to 64-bit complex */ - CV_T_32PCPLX64 = 0x0451, /* 16:32 near pointer to 64-bit complex */ - CV_T_32PFCPLX64 = 0x0551, /* 16:32 far pointer to 64-bit complex */ + CV_T_CPLX64 = 0x0051, /* 64-bit complex */ + CV_T_PCPLX64 = 0x0151, /* Near pointer to 64-bit complex */ + CV_T_PFCPLX64 = 0x0251, /* Far pointer to 64-bit complex */ + CV_T_PHCPLX64 = 0x0351, /* Huge pointer to 64-bit complex */ + CV_T_32PCPLX64 = 0x0451, /* 16:32 near pointer to 64-bit complex */ + CV_T_32PFCPLX64 = 0x0551, /* 16:32 far pointer to 64-bit complex */ /* 80-bit Complex Types */ - CV_T_CPLX80 = 0x0052, /* 80-bit complex */ - CV_T_PCPLX80 = 0x0152, /* Near pointer to 80-bit complex */ - CV_T_PFCPLX80 = 0x0252, /* Far pointer to 80-bit complex */ - CV_T_PHCPLX80 = 0x0352, /* Huge pointer to 80-bit complex */ - CV_T_32PCPLX80 = 0x0452, /* 16:32 near pointer to 80-bit complex */ - CV_T_32PFCPLX80 = 0x0552, /* 16:32 far pointer to 80-bit complex */ + CV_T_CPLX80 = 0x0052, /* 80-bit complex */ + CV_T_PCPLX80 = 0x0152, /* Near pointer to 80-bit complex */ + CV_T_PFCPLX80 = 0x0252, /* Far pointer to 80-bit complex */ + CV_T_PHCPLX80 = 0x0352, /* Huge pointer to 80-bit complex */ + CV_T_32PCPLX80 = 0x0452, /* 16:32 near pointer to 80-bit complex */ + CV_T_32PFCPLX80 = 0x0552, /* 16:32 far pointer to 80-bit complex */ /* 128-bit Complex Types */ - CV_T_CPLX128 = 0x0053, /* 128-bit complex */ - CV_T_PCPLX128 = 0x0153, /* Near pointer to 128-bit complex */ - CV_T_PFCPLX128 = 0x0253, /* Far pointer to 128-bit complex */ - CV_T_PHCPLX128 = 0x0353, /* Huge pointer to 128-bit real */ - CV_T_32PCPLX128 = 0x0453, /* 16:32 near pointer to 128-bit complex */ - CV_T_32PFCPLX128 = 0x0553, /* 16:32 far pointer to 128-bit complex */ + CV_T_CPLX128 = 0x0053, /* 128-bit complex */ + CV_T_PCPLX128 = 0x0153, /* Near pointer to 128-bit complex */ + CV_T_PFCPLX128 = 0x0253, /* Far pointer to 128-bit complex */ + CV_T_PHCPLX128 = 0x0353, /* Huge pointer to 128-bit real */ + CV_T_32PCPLX128 = 0x0453, /* 16:32 near pointer to 128-bit complex */ + CV_T_32PFCPLX128 = 0x0553, /* 16:32 far pointer to 128-bit complex */ /* Boolean Types */ - CV_T_BOOL08 = 0x0030, /* 8-bit Boolean */ - CV_T_BOOL16 = 0x0031, /* 16-bit Boolean */ - CV_T_BOOL32 = 0x0032, /* 32-bit Boolean */ - CV_T_BOOL64 = 0x0033, /* 64-bit Boolean */ - CV_T_PBOOL08 = 0x0130, /* Near pointer to 8-bit Boolean */ - CV_T_PBOOL16 = 0x0131, /* Near pointer to 16-bit Boolean */ - CV_T_PBOOL32 = 0x0132, /* Near pointer to 32-bit Boolean */ - CV_T_PBOOL64 = 0x0133, /* Near pointer to 64-bit Boolean */ - CV_T_PFBOOL08 = 0x0230, /* Far pointer to 8-bit Boolean */ - CV_T_PFBOOL16 = 0x0231, /* Far pointer to 16-bit Boolean */ - CV_T_PFBOOL32 = 0x0232, /* Far pointer to 32-bit Boolean */ - CV_T_PFBOOL64 = 0x0233, /* Far pointer to 64-bit Boolean */ - CV_T_PHBOOL08 = 0x0330, /* Huge pointer to 8-bit Boolean */ - CV_T_PHBOOL16 = 0x0331, /* Huge pointer to 16-bit Boolean */ - CV_T_PHBOOL32 = 0x0332, /* Huge pointer to 32-bit Boolean */ - CV_T_PHBOOL64 = 0x0333, /* Huge pointer to 64-bit Boolean */ - CV_T_32PBOOL08 = 0x0430, /* 16:32 near pointer to 8-bit Boolean */ - CV_T_32PBOOL16 = 0x0431, /* 16:32 near pointer to 16-bit Boolean */ - CV_T_32PBOOL32 = 0x0432, /* 16:32 near pointer to 32-bit Boolean */ - CV_T_32PBOOL64 = 0x0433, /* 16:32 near pointer to 64-bit Boolean */ - CV_T_32PFBOOL08 = 0x0530, /* 16:32 far pointer to 8-bit Boolean */ - CV_T_32PFBOOL16 = 0x0531, /* 16:32 far pointer to 16-bit Boolean */ - CV_T_32PFBOOL32 = 0x0532, /* 16:32 far pointer to 32-bit Boolean */ - CV_T_32PFBOOL64 = 0x0533, /* 16:32 far pointer to 64-bit Boolean */ + CV_T_BOOL08 = 0x0030, /* 8-bit Boolean */ + CV_T_BOOL16 = 0x0031, /* 16-bit Boolean */ + CV_T_BOOL32 = 0x0032, /* 32-bit Boolean */ + CV_T_BOOL64 = 0x0033, /* 64-bit Boolean */ + CV_T_PBOOL08 = 0x0130, /* Near pointer to 8-bit Boolean */ + CV_T_PBOOL16 = 0x0131, /* Near pointer to 16-bit Boolean */ + CV_T_PBOOL32 = 0x0132, /* Near pointer to 32-bit Boolean */ + CV_T_PBOOL64 = 0x0133, /* Near pointer to 64-bit Boolean */ + CV_T_PFBOOL08 = 0x0230, /* Far pointer to 8-bit Boolean */ + CV_T_PFBOOL16 = 0x0231, /* Far pointer to 16-bit Boolean */ + CV_T_PFBOOL32 = 0x0232, /* Far pointer to 32-bit Boolean */ + CV_T_PFBOOL64 = 0x0233, /* Far pointer to 64-bit Boolean */ + CV_T_PHBOOL08 = 0x0330, /* Huge pointer to 8-bit Boolean */ + CV_T_PHBOOL16 = 0x0331, /* Huge pointer to 16-bit Boolean */ + CV_T_PHBOOL32 = 0x0332, /* Huge pointer to 32-bit Boolean */ + CV_T_PHBOOL64 = 0x0333, /* Huge pointer to 64-bit Boolean */ + CV_T_32PBOOL08 = 0x0430, /* 16:32 near pointer to 8-bit Boolean */ + CV_T_32PBOOL16 = 0x0431, /* 16:32 near pointer to 16-bit Boolean */ + CV_T_32PBOOL32 = 0x0432, /* 16:32 near pointer to 32-bit Boolean */ + CV_T_32PBOOL64 = 0x0433, /* 16:32 near pointer to 64-bit Boolean */ + CV_T_32PFBOOL08 = 0x0530, /* 16:32 far pointer to 8-bit Boolean */ + CV_T_32PFBOOL16 = 0x0531, /* 16:32 far pointer to 16-bit Boolean */ + CV_T_32PFBOOL32 = 0x0532, /* 16:32 far pointer to 32-bit Boolean */ + CV_T_32PFBOOL64 = 0x0533, /* 16:32 far pointer to 64-bit Boolean */ /* Non-primitive types are stored in the TYPES section (generated in * cv-type.c) and start at this index (e.g. 0x1000 is the first type * in TYPES, 0x1001 the second, etc. */ - CV_FIRST_NONPRIM = 0x1000 + CV_FIRST_NONPRIM = 0x1000 }; enum cv_leaftype { /* Leaf indices for type records that can be referenced from symbols */ - CV4_LF_MODIFIER = 0x0001, /* Type Modifier */ - CV4_LF_POINTER = 0x0002, /* Pointer */ - CV4_LF_ARRAY = 0x0003, /* Simple Array */ - CV4_LF_CLASS = 0x0004, /* Classes */ - CV4_LF_STRUCTURE = 0x0005, /* Structures */ - CV4_LF_UNION = 0x0006, /* Unions */ - CV4_LF_ENUM = 0x0007, /* Enumeration */ - CV4_LF_PROCEDURE = 0x0008, /* Procedure */ - CV4_LF_MFUNCTION = 0x0009, /* Member Function */ - CV4_LF_VTSHAPE = 0x000a, /* Virtual Function Table Shape */ - CV4_LF_BARRAY = 0x000d, /* Basic Array */ - CV4_LF_LABEL = 0x000e, /* Label */ - CV4_LF_NULL = 0x000f, /* Null */ - CV4_LF_DIMARRAY = 0x0011, /* Multiply Dimensioned Array */ - CV4_LF_VFTPATH = 0x0012, /* Path to Virtual Function Table */ - CV4_LF_PRECOMP = 0x0013, /* Reference Precompiled Types */ - CV4_LF_ENDPRECOMP = 0x0014, /* End of Precompiled Types */ + CV4_LF_MODIFIER = 0x0001, /* Type Modifier */ + CV4_LF_POINTER = 0x0002, /* Pointer */ + CV4_LF_ARRAY = 0x0003, /* Simple Array */ + CV4_LF_CLASS = 0x0004, /* Classes */ + CV4_LF_STRUCTURE = 0x0005, /* Structures */ + CV4_LF_UNION = 0x0006, /* Unions */ + CV4_LF_ENUM = 0x0007, /* Enumeration */ + CV4_LF_PROCEDURE = 0x0008, /* Procedure */ + CV4_LF_MFUNCTION = 0x0009, /* Member Function */ + CV4_LF_VTSHAPE = 0x000a, /* Virtual Function Table Shape */ + CV4_LF_BARRAY = 0x000d, /* Basic Array */ + CV4_LF_LABEL = 0x000e, /* Label */ + CV4_LF_NULL = 0x000f, /* Null */ + CV4_LF_DIMARRAY = 0x0011, /* Multiply Dimensioned Array */ + CV4_LF_VFTPATH = 0x0012, /* Path to Virtual Function Table */ + CV4_LF_PRECOMP = 0x0013, /* Reference Precompiled Types */ + CV4_LF_ENDPRECOMP = 0x0014, /* End of Precompiled Types */ /* CodeView 5.0 version */ - CV5_LF_MODIFIER = 0x1001, /* Type Modifier */ - CV5_LF_POINTER = 0x1002, /* Pointer */ - CV5_LF_ARRAY = 0x1003, /* Simple Array */ - CV5_LF_CLASS = 0x1004, /* Classes */ - CV5_LF_STRUCTURE = 0x1005, /* Structures */ - CV5_LF_UNION = 0x1006, /* Unions */ - CV5_LF_ENUM = 0x1007, /* Enumeration */ - CV5_LF_PROCEDURE = 0x1008, /* Procedure */ - CV5_LF_MFUNCTION = 0x1009, /* Member Function */ - CV5_LF_VTSHAPE = 0x000a, /* Virtual Function Table Shape */ - CV5_LF_BARRAY = 0x100d, /* Basic Array */ - CV5_LF_LABEL = 0x000e, /* Label */ - CV5_LF_NULL = 0x000f, /* Null */ - CV5_LF_DIMARRAY = 0x100c, /* Multiply Dimensioned Array */ - CV5_LF_VFTPATH = 0x100d, /* Path to Virtual Function Table */ - CV5_LF_PRECOMP = 0x100e, /* Reference Precompiled Types */ - CV5_LF_ENDPRECOMP = 0x0014, /* End of Precompiled Types */ - CV5_LF_TYPESERVER = 0x0016, /* Reference Typeserver */ + CV5_LF_MODIFIER = 0x1001, /* Type Modifier */ + CV5_LF_POINTER = 0x1002, /* Pointer */ + CV5_LF_ARRAY = 0x1003, /* Simple Array */ + CV5_LF_CLASS = 0x1004, /* Classes */ + CV5_LF_STRUCTURE = 0x1005, /* Structures */ + CV5_LF_UNION = 0x1006, /* Unions */ + CV5_LF_ENUM = 0x1007, /* Enumeration */ + CV5_LF_PROCEDURE = 0x1008, /* Procedure */ + CV5_LF_MFUNCTION = 0x1009, /* Member Function */ + CV5_LF_VTSHAPE = 0x000a, /* Virtual Function Table Shape */ + CV5_LF_BARRAY = 0x100d, /* Basic Array */ + CV5_LF_LABEL = 0x000e, /* Label */ + CV5_LF_NULL = 0x000f, /* Null */ + CV5_LF_DIMARRAY = 0x100c, /* Multiply Dimensioned Array */ + CV5_LF_VFTPATH = 0x100d, /* Path to Virtual Function Table */ + CV5_LF_PRECOMP = 0x100e, /* Reference Precompiled Types */ + CV5_LF_ENDPRECOMP = 0x0014, /* End of Precompiled Types */ + CV5_LF_TYPESERVER = 0x0016, /* Reference Typeserver */ /* Leaf indices for type records that can be referenced from other type * records */ - CV4_LF_SKIP = 0x0200, /* Skip */ - CV4_LF_ARGLIST = 0x0201, /* Argument List */ - CV4_LF_DEFARG = 0x0202, /* Default Argument */ - CV4_LF_LIST = 0x0203, /* Arbitrary List */ - CV4_LF_FIELDLIST = 0x0204, /* Field List */ - CV4_LF_DERIVED = 0x0205, /* Derived Classes */ - CV4_LF_BITFIELD = 0x0206, /* Bit Fields */ - CV4_LF_METHODLIST = 0x0207, /* Method List */ - CV4_LF_DIMCONU = 0x0208, /* Dimensioned Array with Constant Upper Bound */ - CV4_LF_DIMCONLU = 0x0209, /* Dimensioned Array with Constant Lower and Upper Bounds */ - CV4_LF_DIMVARU = 0x020a, /* Dimensioned Array with Variable Upper Bound */ - CV4_LF_DIMVARLU = 0x020b, /* Dimensioned Array with Variable Lower and Upper Bounds */ - CV4_LF_REFSYM = 0x020c, /* Referenced Symbol */ + CV4_LF_SKIP = 0x0200, /* Skip */ + CV4_LF_ARGLIST = 0x0201, /* Argument List */ + CV4_LF_DEFARG = 0x0202, /* Default Argument */ + CV4_LF_LIST = 0x0203, /* Arbitrary List */ + CV4_LF_FIELDLIST = 0x0204, /* Field List */ + CV4_LF_DERIVED = 0x0205, /* Derived Classes */ + CV4_LF_BITFIELD = 0x0206, /* Bit Fields */ + CV4_LF_METHODLIST = 0x0207, /* Method List */ + CV4_LF_DIMCONU = 0x0208, /* Dimensioned Array with Constant Upper Bound */ + CV4_LF_DIMCONLU = 0x0209, /* Dimensioned Array with Constant Lower and Upper Bounds */ + CV4_LF_DIMVARU = 0x020a, /* Dimensioned Array with Variable Upper Bound */ + CV4_LF_DIMVARLU = 0x020b, /* Dimensioned Array with Variable Lower and Upper Bounds */ + CV4_LF_REFSYM = 0x020c, /* Referenced Symbol */ /* CodeView 5.0 version */ - CV5_LF_SKIP = 0x1200, /* Skip */ - CV5_LF_ARGLIST = 0x1201, /* Argument List */ - CV5_LF_DEFARG = 0x1202, /* Default Argument */ - CV5_LF_FIELDLIST = 0x1203, /* Field List */ - CV5_LF_DERIVED = 0x1204, /* Derived Classes */ - CV5_LF_BITFIELD = 0x1205, /* Bit Fields */ - CV5_LF_METHODLIST = 0x1206, /* Method List */ - CV5_LF_DIMCONU = 0x1207, /* Dimensioned Array with Constant Upper Bound */ - CV5_LF_DIMCONLU = 0x1208, /* Dimensioned Array with Constant Lower and Upper Bounds */ - CV5_LF_DIMVARU = 0x1209, /* Dimensioned Array with Variable Upper Bound */ - CV5_LF_DIMVARLU = 0x120a, /* Dimensioned Array with Variable Lower and Upper Bounds */ - CV5_LF_REFSYM = 0x020c, /* Referenced Symbol */ + CV5_LF_SKIP = 0x1200, /* Skip */ + CV5_LF_ARGLIST = 0x1201, /* Argument List */ + CV5_LF_DEFARG = 0x1202, /* Default Argument */ + CV5_LF_FIELDLIST = 0x1203, /* Field List */ + CV5_LF_DERIVED = 0x1204, /* Derived Classes */ + CV5_LF_BITFIELD = 0x1205, /* Bit Fields */ + CV5_LF_METHODLIST = 0x1206, /* Method List */ + CV5_LF_DIMCONU = 0x1207, /* Dimensioned Array with Constant Upper Bound */ + CV5_LF_DIMCONLU = 0x1208, /* Dimensioned Array with Constant Lower and Upper Bounds */ + CV5_LF_DIMVARU = 0x1209, /* Dimensioned Array with Variable Upper Bound */ + CV5_LF_DIMVARLU = 0x120a, /* Dimensioned Array with Variable Lower and Upper Bounds */ + CV5_LF_REFSYM = 0x020c, /* Referenced Symbol */ /* Leaf indices for fields of complex lists */ - CV4_LF_BCLASS = 0x0400, /* Real Base Class */ - CV4_LF_VBCLASS = 0x0401, /* Direct Virtual Base Class */ - CV4_LF_IVBCLASS = 0x0402, /* Indirect Virtual Base Class */ - CV4_LF_ENUMERATE = 0x0403, /* Enumeration Name and Value */ - CV4_LF_FRIENDFCN = 0x0404, /* Friend Function */ - CV4_LF_INDEX = 0x0405, /* Index To Another Type Record */ - CV4_LF_MEMBER = 0x0406, /* Data Member */ - CV4_LF_STMEMBER = 0x0407, /* Static Data Member */ - CV4_LF_METHOD = 0x0408, /* Method */ - CV4_LF_NESTTYPE = 0x0409, /* Nested Type Definition */ - CV4_LF_VFUNCTAB = 0x040a, /* Virtual Function Table Pointer */ - CV4_LF_FRIENDCLS = 0x040b, /* Friend Class */ - CV4_LF_ONEMETHOD = 0x040c, /* One Method */ - CV4_LF_VFUNCOFF = 0x040d, /* Virtual Function Offset */ + CV4_LF_BCLASS = 0x0400, /* Real Base Class */ + CV4_LF_VBCLASS = 0x0401, /* Direct Virtual Base Class */ + CV4_LF_IVBCLASS = 0x0402, /* Indirect Virtual Base Class */ + CV4_LF_ENUMERATE = 0x0403, /* Enumeration Name and Value */ + CV4_LF_FRIENDFCN = 0x0404, /* Friend Function */ + CV4_LF_INDEX = 0x0405, /* Index To Another Type Record */ + CV4_LF_MEMBER = 0x0406, /* Data Member */ + CV4_LF_STMEMBER = 0x0407, /* Static Data Member */ + CV4_LF_METHOD = 0x0408, /* Method */ + CV4_LF_NESTTYPE = 0x0409, /* Nested Type Definition */ + CV4_LF_VFUNCTAB = 0x040a, /* Virtual Function Table Pointer */ + CV4_LF_FRIENDCLS = 0x040b, /* Friend Class */ + CV4_LF_ONEMETHOD = 0x040c, /* One Method */ + CV4_LF_VFUNCOFF = 0x040d, /* Virtual Function Offset */ /* CodeView 5.0 version */ - CV5_LF_BCLASS = 0x1400, /* Real Base Class */ - CV5_LF_VBCLASS = 0x1401, /* Direct Virtual Base Class */ - CV5_LF_IVBCLASS = 0x1402, /* Indirect Virtual Base Class */ - CV5_LF_ENUMERATE = 0x0403, /* Enumeration Name and Value */ - CV5_LF_FRIENDFCN = 0x1403, /* Friend Function */ - CV5_LF_INDEX = 0x1404, /* Index To Another Type Record */ - CV5_LF_MEMBER = 0x1405, /* Data Member */ - CV5_LF_STMEMBER = 0x1406, /* Static Data Member */ - CV5_LF_METHOD = 0x1407, /* Method */ - CV5_LF_NESTTYPE = 0x1408, /* Nested Type Definition */ - CV5_LF_VFUNCTAB = 0x1409, /* Virtual Function Table Pointer */ - CV5_LF_FRIENDCLS = 0x140a, /* Friend Class */ - CV5_LF_ONEMETHOD = 0x140b, /* One Method */ - CV5_LF_VFUNCOFF = 0x140c, /* Virtual Function Offset */ - CV5_LF_NESTTYPEEX = 0x140d, /* Nested Type Extended Definition */ - CV5_LF_MEMBERMODIFY = 0x140e, /* Member Modification */ + CV5_LF_BCLASS = 0x1400, /* Real Base Class */ + CV5_LF_VBCLASS = 0x1401, /* Direct Virtual Base Class */ + CV5_LF_IVBCLASS = 0x1402, /* Indirect Virtual Base Class */ + CV5_LF_ENUMERATE = 0x0403, /* Enumeration Name and Value */ + CV5_LF_FRIENDFCN = 0x1403, /* Friend Function */ + CV5_LF_INDEX = 0x1404, /* Index To Another Type Record */ + CV5_LF_MEMBER = 0x1405, /* Data Member */ + CV5_LF_STMEMBER = 0x1406, /* Static Data Member */ + CV5_LF_METHOD = 0x1407, /* Method */ + CV5_LF_NESTTYPE = 0x1408, /* Nested Type Definition */ + CV5_LF_VFUNCTAB = 0x1409, /* Virtual Function Table Pointer */ + CV5_LF_FRIENDCLS = 0x140a, /* Friend Class */ + CV5_LF_ONEMETHOD = 0x140b, /* One Method */ + CV5_LF_VFUNCOFF = 0x140c, /* Virtual Function Offset */ + CV5_LF_NESTTYPEEX = 0x140d, /* Nested Type Extended Definition */ + CV5_LF_MEMBERMODIFY = 0x140e, /* Member Modification */ /* XXX: CodeView 5.0 spec also lists 0x040f as LF_MEMBERMODIFY? */ /* Leaf indices for numeric fields of symbols and type records */ - CV_LF_NUMERIC = 0x8000, - CV_LF_CHAR = 0x8000, /* Signed Char (8-bit) */ - CV_LF_SHORT = 0x8001, /* Signed Short (16-bit) */ - CV_LF_USHORT = 0x8002, /* Unsigned Short (16-bit) */ - CV_LF_LONG = 0x8003, /* Signed Long (32-bit) */ - CV_LF_ULONG = 0x8004, /* Unsigned Long (32-bit) */ - CV_LF_REAL32 = 0x8005, /* 32-bit Float */ - CV_LF_REAL64 = 0x8006, /* 64-bit Float */ - CV_LF_REAL80 = 0x8007, /* 80-bit Float */ - CV_LF_REAL128 = 0x8008, /* 128-bit Float */ - CV_LF_QUADWORD = 0x8009, /* Signed Quad Word (64-bit) */ - CV_LF_UQUADWORD = 0x800a, /* Unsigned Quad Word (64-bit) */ - CV_LF_REAL48 = 0x800b, /* 48-bit Float */ - CV_LF_COMPLEX32 = 0x800c, /* 32-bit Complex */ - CV_LF_COMPLEX64 = 0x800d, /* 64-bit Complex */ - CV_LF_COMPLEX80 = 0x800e, /* 80-bit Complex */ - CV_LF_COMPLEX128 = 0x800f, /* 128-bit Complex */ - CV_LF_VARSTRING = 0x8010, /* Variable-length String */ + CV_LF_NUMERIC = 0x8000, + CV_LF_CHAR = 0x8000, /* Signed Char (8-bit) */ + CV_LF_SHORT = 0x8001, /* Signed Short (16-bit) */ + CV_LF_USHORT = 0x8002, /* Unsigned Short (16-bit) */ + CV_LF_LONG = 0x8003, /* Signed Long (32-bit) */ + CV_LF_ULONG = 0x8004, /* Unsigned Long (32-bit) */ + CV_LF_REAL32 = 0x8005, /* 32-bit Float */ + CV_LF_REAL64 = 0x8006, /* 64-bit Float */ + CV_LF_REAL80 = 0x8007, /* 80-bit Float */ + CV_LF_REAL128 = 0x8008, /* 128-bit Float */ + CV_LF_QUADWORD = 0x8009, /* Signed Quad Word (64-bit) */ + CV_LF_UQUADWORD = 0x800a, /* Unsigned Quad Word (64-bit) */ + CV_LF_REAL48 = 0x800b, /* 48-bit Float */ + CV_LF_COMPLEX32 = 0x800c, /* 32-bit Complex */ + CV_LF_COMPLEX64 = 0x800d, /* 64-bit Complex */ + CV_LF_COMPLEX80 = 0x800e, /* 80-bit Complex */ + CV_LF_COMPLEX128 = 0x800f, /* 128-bit Complex */ + CV_LF_VARSTRING = 0x8010, /* Variable-length String */ /* Leaf padding bytes */ - CV_LF_PAD0 = 0xf0, - CV_LF_PAD1 = 0xf1, - CV_LF_PAD2 = 0xf2, - CV_LF_PAD3 = 0xf3, - CV_LF_PAD4 = 0xf4, - CV_LF_PAD5 = 0xf5, - CV_LF_PAD6 = 0xf6, - CV_LF_PAD7 = 0xf7, - CV_LF_PAD8 = 0xf8, - CV_LF_PAD9 = 0xf9, - CV_LF_PAD10 = 0xfa, - CV_LF_PAD11 = 0xfb, - CV_LF_PAD12 = 0xfc, - CV_LF_PAD13 = 0xfc, - CV_LF_PAD14 = 0xfe, - CV_LF_PAD15 = 0xff + CV_LF_PAD0 = 0xf0, + CV_LF_PAD1 = 0xf1, + CV_LF_PAD2 = 0xf2, + CV_LF_PAD3 = 0xf3, + CV_LF_PAD4 = 0xf4, + CV_LF_PAD5 = 0xf5, + CV_LF_PAD6 = 0xf6, + CV_LF_PAD7 = 0xf7, + CV_LF_PAD8 = 0xf8, + CV_LF_PAD9 = 0xf9, + CV_LF_PAD10 = 0xfa, + CV_LF_PAD11 = 0xfb, + CV_LF_PAD12 = 0xfc, + CV_LF_PAD13 = 0xfc, + CV_LF_PAD14 = 0xfe, + CV_LF_PAD15 = 0xff }; /* Leaves use a bit of meta-programming to encode formats: each character @@ -463,15 +466,15 @@ enum cv_leaftype { */ typedef struct cv_leaf { enum cv_leaftype type; - const char *format; /* format of args */ + const char *format; /* format of args */ union { - unsigned long i; - void *p; + unsigned long i; + void *p; } args[6]; } cv_leaf; typedef struct cv_type { - unsigned long indx; /* type # (must be same as output order) */ + unsigned long indx; /* type # (must be same as output order) */ size_t num_leaves; /*@null@*/ /*@only@*/ cv_leaf **leaves; } cv_type; @@ -482,7 +485,7 @@ static void cv_type_bc_print(const void *contents, FILE *f, int indent_level); static int cv_type_bc_calc_len (yasm_bytecode *bc, yasm_bc_add_span_func add_span, void *add_span_data); static int cv_type_bc_tobytes - (yasm_bytecode *bc, unsigned char **bufp, unsigned char *bufstart, void *d, + (yasm_bytecode *bc, unsigned char **bufp, void *d, yasm_output_value_func output_value, /*@null@*/ yasm_output_reloc_func output_reloc); @@ -491,7 +494,6 @@ static const yasm_bytecode_callback cv_type_bc_callback = { cv_type_bc_destroy, cv_type_bc_print, yasm_bc_finalize_common, - NULL, cv_type_bc_calc_len, yasm_bc_expand_common, cv_type_bc_tobytes, @@ -522,7 +524,7 @@ yasm_cv__generate_type(yasm_object *object) cv_type *type; debug_type = - yasm_object_get_general(object, ".debug$T", 1, 0, 0, &new, 0); + yasm_object_get_general(object, ".debug$T", 0, 1, 0, 0, &new, 0); /* Add label type */ type = cv_type_create(indx++); @@ -541,27 +543,26 @@ cv_leaf_destroy(cv_leaf *leaf) int arg = 0; while (*ch) { - switch (*ch) { - case 'b': - case 'h': - case 'w': - arg++; - break; /* nothing to destroy */ - case 'L': - cv_leaf_destroy((cv_leaf *)leaf->args[arg++].p); - break; - case 'T': - arg++; /* nothing to destroy */ - break; - case 'S': - yasm_xfree(leaf->args[arg++].p); - break; - default: - yasm_internal_error(N_("unknown leaf format character")); - } - ch++; + switch (*ch) { + case 'b': + case 'h': + case 'w': + arg++; + break; /* nothing to destroy */ + case 'L': + cv_leaf_destroy((cv_leaf *)leaf->args[arg++].p); + break; + case 'T': + arg++; /* nothing to destroy */ + break; + case 'S': + yasm_xfree(leaf->args[arg++].p); + break; + default: + yasm_internal_error(N_("unknown leaf format character")); + } + ch++; } - yasm_xfree(leaf); } static unsigned long @@ -573,35 +574,35 @@ cv_leaf_size(const cv_leaf *leaf) int arg = 0; while (*ch) { - switch (*ch) { - case 'b': - len++; - arg++; - break; - case 'h': - len += 2; - arg++; - break; - case 'w': - len += 4; - arg++; - break; - case 'L': - len += cv_leaf_size((const cv_leaf *)leaf->args[arg++].p); - break; - case 'T': - len += 4; /* XXX: will be 2 in CV4 */ - arg++; - break; - case 'S': - len += 1; /* XXX: is this 1 or 2? */ - slen = (unsigned long)strlen((const char *)leaf->args[arg++].p); - len += slen <= 0xff ? slen : 0xff; - break; - default: - yasm_internal_error(N_("unknown leaf format character")); - } - ch++; + switch (*ch) { + case 'b': + len++; + arg++; + break; + case 'h': + len += 2; + arg++; + break; + case 'w': + len += 4; + arg++; + break; + case 'L': + len += cv_leaf_size((const cv_leaf *)leaf->args[arg++].p); + break; + case 'T': + len += 4; /* XXX: will be 2 in CV4 */ + arg++; + break; + case 'S': + len += 1; /* XXX: is this 1 or 2? */ + slen = (unsigned long)strlen((const char *)leaf->args[arg++].p); + len += slen <= 0xff ? slen : 0xff; + break; + default: + yasm_internal_error(N_("unknown leaf format character")); + } + ch++; } return len; @@ -609,7 +610,7 @@ cv_leaf_size(const cv_leaf *leaf) static void cv_leaf_tobytes(const cv_leaf *leaf, yasm_bytecode *bc, yasm_arch *arch, - unsigned char **bufp, yasm_intnum *cval) + unsigned char **bufp, yasm_intnum *cval) { unsigned char *buf = *bufp; const char *ch = leaf->format; @@ -622,43 +623,43 @@ cv_leaf_tobytes(const cv_leaf *leaf, yasm_bytecode *bc, yasm_arch *arch, buf += 2; while (*ch) { - switch (*ch) { - case 'b': - YASM_WRITE_8(buf, leaf->args[arg].i); - arg++; - break; - case 'h': - yasm_intnum_set_uint(cval, leaf->args[arg++].i); - yasm_arch_intnum_tobytes(arch, cval, buf, 2, 16, 0, bc, 0); - buf += 2; - break; - case 'w': - yasm_intnum_set_uint(cval, leaf->args[arg++].i); - yasm_arch_intnum_tobytes(arch, cval, buf, 4, 32, 0, bc, 0); - buf += 4; - break; - case 'L': - cv_leaf_tobytes((const cv_leaf *)leaf->args[arg++].p, bc, arch, - &buf, cval); - break; - case 'T': - yasm_intnum_set_uint(cval, - ((const cv_type *)leaf->args[arg++].p)->indx); - yasm_arch_intnum_tobytes(arch, cval, buf, 4, 32, 0, bc, 0); - buf += 4; /* XXX: will be 2 in CV4 */ - break; - case 'S': - len = strlen((const char *)leaf->args[arg].p); - len = len <= 0xff ? len : 0xff; - YASM_WRITE_8(buf, len); - memcpy(buf, (const char *)leaf->args[arg].p, len); - buf += len; - arg++; - break; - default: - yasm_internal_error(N_("unknown leaf format character")); - } - ch++; + switch (*ch) { + case 'b': + YASM_WRITE_8(buf, leaf->args[arg].i); + arg++; + break; + case 'h': + yasm_intnum_set_uint(cval, leaf->args[arg++].i); + yasm_arch_intnum_tobytes(arch, cval, buf, 2, 16, 0, bc, 0); + buf += 2; + break; + case 'w': + yasm_intnum_set_uint(cval, leaf->args[arg++].i); + yasm_arch_intnum_tobytes(arch, cval, buf, 4, 32, 0, bc, 0); + buf += 4; + break; + case 'L': + cv_leaf_tobytes((const cv_leaf *)leaf->args[arg++].p, bc, arch, + &buf, cval); + break; + case 'T': + yasm_intnum_set_uint(cval, + ((const cv_type *)leaf->args[arg++].p)->indx); + yasm_arch_intnum_tobytes(arch, cval, buf, 4, 32, 0, bc, 0); + buf += 4; /* XXX: will be 2 in CV4 */ + break; + case 'S': + len = strlen((const char *)leaf->args[arg].p); + len = len <= 0xff ? len : 0xff; + YASM_WRITE_8(buf, len); + memcpy(buf, (const char *)leaf->args[arg].p, len); + buf += len; + arg++; + break; + default: + yasm_internal_error(N_("unknown leaf format character")); + } + ch++; } *bufp = buf; @@ -685,7 +686,7 @@ cv_type_append_leaf(cv_type *type, /*@keep@*/ cv_leaf *leaf) * until we add structure support. */ type->leaves = yasm_xrealloc(type->leaves, - type->num_leaves*sizeof(cv_leaf *)); + type->num_leaves*sizeof(cv_leaf *)); type->leaves[type->num_leaves-1] = leaf; } @@ -697,9 +698,9 @@ cv_type_bc_destroy(void *contents) size_t i; for (i=0; inum_leaves; i++) - cv_leaf_destroy(type->leaves[i]); + cv_leaf_destroy(type->leaves[i]); if (type->leaves) - yasm_xfree(type->leaves); + yasm_xfree(type->leaves); yasm_xfree(contents); } @@ -711,31 +712,30 @@ cv_type_bc_print(const void *contents, FILE *f, int indent_level) static int cv_type_bc_calc_len(yasm_bytecode *bc, yasm_bc_add_span_func add_span, - void *add_span_data) + void *add_span_data) { cv_type *type = (cv_type *)bc->contents; size_t i; if (type->indx == CV_FIRST_NONPRIM) - bc->len = 4+2; + bc->len = 4+2; else - bc->len = 2; + bc->len = 2; for (i=0; inum_leaves; i++) - bc->len += cv_leaf_size(type->leaves[i]); + bc->len += cv_leaf_size(type->leaves[i]); /* Pad to multiple of 4 */ if (bc->len & 0x3) - bc->len += 4-(bc->len & 0x3); + bc->len += 4-(bc->len & 0x3); return 0; } static int -cv_type_bc_tobytes(yasm_bytecode *bc, unsigned char **bufp, - unsigned char *bufstart, void *d, - yasm_output_value_func output_value, - yasm_output_reloc_func output_reloc) +cv_type_bc_tobytes(yasm_bytecode *bc, unsigned char **bufp, void *d, + yasm_output_value_func output_value, + yasm_output_reloc_func output_reloc) { yasm_object *object = yasm_section_get_object(bc->section); cv_type *type = (cv_type *)bc->contents; @@ -744,11 +744,11 @@ cv_type_bc_tobytes(yasm_bytecode *bc, unsigned char **bufp, size_t i; unsigned long reclen = bc->len - 2; - cval = yasm_intnum_create_uint(4); /* version */ + cval = yasm_intnum_create_uint(4); /* version */ if (type->indx == CV_FIRST_NONPRIM) { - yasm_arch_intnum_tobytes(object->arch, cval, buf, 4, 32, 0, bc, 1); - buf += 4; - reclen -= 4; + yasm_arch_intnum_tobytes(object->arch, cval, buf, 4, 32, 0, bc, 1); + buf += 4; + reclen -= 4; } /* Total length of record (following this field) - 2 bytes */ @@ -758,18 +758,18 @@ cv_type_bc_tobytes(yasm_bytecode *bc, unsigned char **bufp, /* Leaves */ for (i=0; inum_leaves; i++) - cv_leaf_tobytes(type->leaves[i], bc, object->arch, &buf, cval); + cv_leaf_tobytes(type->leaves[i], bc, object->arch, &buf, cval); /* Pad to multiple of 4 */ switch ((buf-(*bufp)) & 0x3) { - case 3: - YASM_WRITE_8(buf, CV_LF_PAD3); - case 2: - YASM_WRITE_8(buf, CV_LF_PAD2); - case 1: - YASM_WRITE_8(buf, CV_LF_PAD1); - case 0: - break; + case 3: + YASM_WRITE_8(buf, CV_LF_PAD3); + case 2: + YASM_WRITE_8(buf, CV_LF_PAD2); + case 1: + YASM_WRITE_8(buf, CV_LF_PAD1); + case 0: + break; } *bufp = buf; diff --git a/modules/dbgfmts/codeview/cv8.txt b/modules/dbgfmts/codeview/cv8.txt index a4bbdd8e..04f152b2 100644 --- a/modules/dbgfmts/codeview/cv8.txt +++ b/modules/dbgfmts/codeview/cv8.txt @@ -25,17 +25,15 @@ the end (not included in length). 2 bytes - section index (SECTION to section start) 2 bytes - pad/align (0) 4 bytes - section length covered by line number info + 4 bytes - offset of source file in source file info table + 4 bytes - number of line number pairs + 4 bytes - number of bytes of line number pairs + 12 - followed by one or more source mappings: - 4 bytes - offset of source file in source file info table - 4 bytes - number of line number pairs - 4 bytes - number of bytes this mapping takes, i.e. 12 + pair-count * 8. - - followed by pairs of: - 4 bytes - offset in section - 4 bytes - line number; if high bit is set, - end of statement/breakpointable (?) - e.g. lines containing - just labels should have line numbers + followed by pairs of: + 4 bytes - offset in section + 4 bytes - line number; if high bit is set, + end of statement/breakpointable (?) - e.g. lines containing + just labels should have line numbers 0x000000F1: symbol information enclosed data per below diff --git a/modules/dbgfmts/codeview/tests/cv8-multi.asm b/modules/dbgfmts/codeview/tests/cv8-multi.asm deleted file mode 100644 index ddb9adcd..00000000 --- a/modules/dbgfmts/codeview/tests/cv8-multi.asm +++ /dev/null @@ -1,23 +0,0 @@ -; -; Test for windbg's ability to single step thru two (or more) source files -; contributing instructions to the same sections. -; -; YASM 1.2.0 and earlier used to generate one CV8_LINE_NUMS per file per -; section, thus potentially having several CV8_LINE_NUMS records for each -; section. It is seems that this confuses either the linker or/and windbg -; and prevents single stepping in and out of include files. -; -; MASM generates one line number debug subsection for each code section, -; repeating the 12 bytes before the offset/lineno pairs for each new file. -; -; It also appears that line numbers must be ordered by section offset, and -; therefore cannot be grouped per file as done by YASM 1.2.0 and earlier. -; -_start: -global _start -%include "cv8-multi.mac" - mov eax, 42 -%include "cv8-multi.mac" - xor eax, eax - ret - diff --git a/modules/dbgfmts/codeview/tests/cv8-multi.mac b/modules/dbgfmts/codeview/tests/cv8-multi.mac deleted file mode 100644 index 5a559f48..00000000 --- a/modules/dbgfmts/codeview/tests/cv8-multi.mac +++ /dev/null @@ -1,4 +0,0 @@ - int3 - nop - ; Must be able to step back into the main file. - diff --git a/modules/dbgfmts/dwarf2/CMakeLists.txt b/modules/dbgfmts/dwarf2/CMakeLists.txt deleted file mode 100644 index 671910ee..00000000 --- a/modules/dbgfmts/dwarf2/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -YASM_ADD_MODULE(dbgfmt_dwarf2 - dbgfmts/dwarf2/dwarf2-dbgfmt.c - dbgfmts/dwarf2/dwarf2-line.c - dbgfmts/dwarf2/dwarf2-aranges.c - dbgfmts/dwarf2/dwarf2-info.c - ) diff --git a/modules/dbgfmts/dwarf2/Makefile.inc b/modules/dbgfmts/dwarf2/Makefile.inc index 606b699e..602ae641 100644 --- a/modules/dbgfmts/dwarf2/Makefile.inc +++ b/modules/dbgfmts/dwarf2/Makefile.inc @@ -1,3 +1,5 @@ +# $Id$ + libyasm_a_SOURCES += modules/dbgfmts/dwarf2/dwarf2-dbgfmt.h libyasm_a_SOURCES += modules/dbgfmts/dwarf2/dwarf2-dbgfmt.c libyasm_a_SOURCES += modules/dbgfmts/dwarf2/dwarf2-line.c diff --git a/modules/dbgfmts/dwarf2/dwarf2-aranges.c b/modules/dbgfmts/dwarf2/dwarf2-aranges.c index f398b7fa..8e93d3f6 100644 --- a/modules/dbgfmts/dwarf2/dwarf2-aranges.c +++ b/modules/dbgfmts/dwarf2/dwarf2-aranges.c @@ -25,7 +25,9 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include +/*@unused@*/ RCSID("$Id$"); +#define YASM_LIB_INTERNAL #include #include "dwarf2-dbgfmt.h" @@ -33,7 +35,7 @@ static void dwarf2_append_arange(yasm_section *debug_aranges, /*@only@*/ yasm_expr *start, - /*@only@*/ yasm_expr *length, unsigned int sizeof_address) + /*@only@*/ yasm_expr *length, unsigned int sizeof_address) { yasm_datavalhead dvs; yasm_bytecode *bc; @@ -62,17 +64,17 @@ dwarf2_generate_aranges_section(yasm_section *sect, /*@null@*/ void *d) dsd = yasm_section_get_data(sect, &yasm_dwarf2__section_data_cb); if (!dsd) - return 0; /* no line data for this section */ + return 0; /* no line data for this section */ /* Create address range descriptor */ start = yasm_expr_create_ident( - yasm_expr_sym(yasm_dwarf2__bc_sym(info->object->symtab, - yasm_section_bcs_first(sect))), 0); + yasm_expr_sym(yasm_dwarf2__bc_sym(info->object->symtab, + yasm_section_bcs_first(sect))), 0); length = yasm_expr_create_ident( - yasm_expr_int(yasm_calc_bc_dist(yasm_section_bcs_first(sect), - yasm_section_bcs_last(sect))), 0); + yasm_expr_int(yasm_calc_bc_dist(yasm_section_bcs_first(sect), + yasm_section_bcs_last(sect))), 0); dwarf2_append_arange(info->debug_aranges, start, length, - dbgfmt_dwarf2->sizeof_address); + dbgfmt_dwarf2->sizeof_address); return 0; } @@ -88,19 +90,19 @@ yasm_dwarf2__generate_aranges(yasm_object *object, yasm_section *debug_info) dwarf2_aranges_info info; debug_aranges = - yasm_object_get_general(object, ".debug_aranges", - 2*dbgfmt_dwarf2->sizeof_address, 0, 0, &new, - 0); + yasm_object_get_general(object, ".debug_aranges", 0, + 2*dbgfmt_dwarf2->sizeof_address, 0, 0, &new, + 0); /* header */ head = yasm_dwarf2__add_head(dbgfmt_dwarf2, debug_aranges, debug_info, 1, - 1); + 1); /* align ranges to 2x address size (range size) */ bc = yasm_bc_create_align( - yasm_expr_create_ident(yasm_expr_int( - yasm_intnum_create_uint(dbgfmt_dwarf2->sizeof_address*2)), 0), - NULL, NULL, NULL, 0); + yasm_expr_create_ident(yasm_expr_int( + yasm_intnum_create_uint(dbgfmt_dwarf2->sizeof_address*2)), 0), + NULL, NULL, NULL, 0); yasm_bc_finalize(bc, yasm_dwarf2__append_bc(debug_aranges, bc)); yasm_bc_calc_len(bc, NULL, NULL); @@ -109,13 +111,13 @@ yasm_dwarf2__generate_aranges(yasm_object *object, yasm_section *debug_info) info.dbgfmt_dwarf2 = dbgfmt_dwarf2; yasm_object_sections_traverse(object, (void *)&info, - dwarf2_generate_aranges_section); + dwarf2_generate_aranges_section); /* Terminate with empty address range descriptor */ dwarf2_append_arange(debug_aranges, - yasm_expr_create_ident(yasm_expr_int(yasm_intnum_create_uint(0)), 0), - yasm_expr_create_ident(yasm_expr_int(yasm_intnum_create_uint(0)), 0), - dbgfmt_dwarf2->sizeof_address); + yasm_expr_create_ident(yasm_expr_int(yasm_intnum_create_uint(0)), 0), + yasm_expr_create_ident(yasm_expr_int(yasm_intnum_create_uint(0)), 0), + dbgfmt_dwarf2->sizeof_address); /* mark end of aranges information */ yasm_dwarf2__set_head_end(head, yasm_section_bcs_last(debug_aranges)); diff --git a/modules/dbgfmts/dwarf2/dwarf2-dbgfmt.c b/modules/dbgfmts/dwarf2/dwarf2-dbgfmt.c index 5b66f8a7..9836fd54 100644 --- a/modules/dbgfmts/dwarf2/dwarf2-dbgfmt.c +++ b/modules/dbgfmts/dwarf2/dwarf2-dbgfmt.c @@ -25,7 +25,10 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include +/*@unused@*/ RCSID("$Id$"); +#define YASM_LIB_INTERNAL +#define YASM_BC_INTERNAL #include #include "dwarf2-dbgfmt.h" @@ -41,11 +44,11 @@ struct dwarf2_head { /* Bytecode callback function prototypes */ static void dwarf2_head_bc_destroy(void *contents); static void dwarf2_head_bc_print(const void *contents, FILE *f, - int indent_level); + int indent_level); static int dwarf2_head_bc_calc_len (yasm_bytecode *bc, yasm_bc_add_span_func add_span, void *add_span_data); static int dwarf2_head_bc_tobytes - (yasm_bytecode *bc, unsigned char **bufp, unsigned char *bufstart, void *d, + (yasm_bytecode *bc, unsigned char **bufp, void *d, yasm_output_value_func output_value, /*@null@*/ yasm_output_reloc_func output_reloc); @@ -54,7 +57,6 @@ static const yasm_bytecode_callback dwarf2_head_bc_callback = { dwarf2_head_bc_destroy, dwarf2_head_bc_print, yasm_bc_finalize_common, - NULL, dwarf2_head_bc_calc_len, yasm_bc_expand_common, dwarf2_head_bc_tobytes, @@ -78,7 +80,7 @@ static /*@null@*/ /*@only@*/ yasm_dbgfmt * dwarf2_dbgfmt_create(yasm_object *object) { yasm_dbgfmt_dwarf2 *dbgfmt_dwarf2 = - yasm_xmalloc(sizeof(yasm_dbgfmt_dwarf2)); + yasm_xmalloc(sizeof(yasm_dbgfmt_dwarf2)); size_t i; dbgfmt_dwarf2->dbgfmt.module = &yasm_dwarf2_LTX_dbgfmt; @@ -86,28 +88,28 @@ dwarf2_dbgfmt_create(yasm_object *object) dbgfmt_dwarf2->dirs_allocated = 32; dbgfmt_dwarf2->dirs_size = 0; dbgfmt_dwarf2->dirs = - yasm_xmalloc(sizeof(char *)*dbgfmt_dwarf2->dirs_allocated); + yasm_xmalloc(sizeof(char *)*dbgfmt_dwarf2->dirs_allocated); dbgfmt_dwarf2->filenames_allocated = 32; dbgfmt_dwarf2->filenames_size = 0; dbgfmt_dwarf2->filenames = - yasm_xmalloc(sizeof(dwarf2_filename)*dbgfmt_dwarf2->filenames_allocated); + yasm_xmalloc(sizeof(dwarf2_filename)*dbgfmt_dwarf2->filenames_allocated); for (i=0; ifilenames_allocated; i++) { - dbgfmt_dwarf2->filenames[i].pathname = NULL; - dbgfmt_dwarf2->filenames[i].filename = NULL; - dbgfmt_dwarf2->filenames[i].dir = 0; + dbgfmt_dwarf2->filenames[i].pathname = NULL; + dbgfmt_dwarf2->filenames[i].filename = NULL; + dbgfmt_dwarf2->filenames[i].dir = 0; } dbgfmt_dwarf2->format = DWARF2_FORMAT_32BIT; /* TODO: flexible? */ dbgfmt_dwarf2->sizeof_address = yasm_arch_get_address_size(object->arch)/8; switch (dbgfmt_dwarf2->format) { - case DWARF2_FORMAT_32BIT: - dbgfmt_dwarf2->sizeof_offset = 4; - break; - case DWARF2_FORMAT_64BIT: - dbgfmt_dwarf2->sizeof_offset = 8; - break; + case DWARF2_FORMAT_32BIT: + dbgfmt_dwarf2->sizeof_offset = 4; + break; + case DWARF2_FORMAT_64BIT: + dbgfmt_dwarf2->sizeof_offset = 8; + break; } dbgfmt_dwarf2->min_insn_len = yasm_arch_min_insn_len(object->arch); @@ -120,14 +122,14 @@ dwarf2_dbgfmt_destroy(/*@only@*/ yasm_dbgfmt *dbgfmt) yasm_dbgfmt_dwarf2 *dbgfmt_dwarf2 = (yasm_dbgfmt_dwarf2 *)dbgfmt; size_t i; for (i=0; idirs_size; i++) - if (dbgfmt_dwarf2->dirs[i]) - yasm_xfree(dbgfmt_dwarf2->dirs[i]); + if (dbgfmt_dwarf2->dirs[i]) + yasm_xfree(dbgfmt_dwarf2->dirs[i]); yasm_xfree(dbgfmt_dwarf2->dirs); for (i=0; ifilenames_size; i++) { - if (dbgfmt_dwarf2->filenames[i].pathname) - yasm_xfree(dbgfmt_dwarf2->filenames[i].pathname); - if (dbgfmt_dwarf2->filenames[i].filename) - yasm_xfree(dbgfmt_dwarf2->filenames[i].filename); + if (dbgfmt_dwarf2->filenames[i].pathname) + yasm_xfree(dbgfmt_dwarf2->filenames[i].pathname); + if (dbgfmt_dwarf2->filenames[i].filename) + yasm_xfree(dbgfmt_dwarf2->filenames[i].filename); } yasm_xfree(dbgfmt_dwarf2->filenames); yasm_xfree(dbgfmt); @@ -147,7 +149,7 @@ yasm_dwarf2__append_bc(yasm_section *sect, yasm_bytecode *bc) static void dwarf2_dbgfmt_generate(yasm_object *object, yasm_linemap *linemap, - yasm_errwarns *errwarns) + yasm_errwarns *errwarns) { yasm_dbgfmt_dwarf2 *dbgfmt_dwarf2 = (yasm_dbgfmt_dwarf2 *)object->dbgfmt; size_t num_line_sections; @@ -157,8 +159,8 @@ dwarf2_dbgfmt_generate(yasm_object *object, yasm_linemap *linemap, * based on the asm source. */ debug_line = yasm_dwarf2__generate_line(object, linemap, errwarns, - dbgfmt_dwarf2->filenames_size == 0, - &main_code, &num_line_sections); + dbgfmt_dwarf2->filenames_size == 0, + &main_code, &num_line_sections); /* If we don't have a .debug_info (or it's empty), generate the minimal * set of .debug_info, .debug_aranges, and .debug_abbrev so that the @@ -166,11 +168,11 @@ dwarf2_dbgfmt_generate(yasm_object *object, yasm_linemap *linemap, */ debug_info = yasm_object_find_general(object, ".debug_info"); if (num_line_sections > 0 && - (!debug_info || yasm_section_bcs_first(debug_info) - == yasm_section_bcs_last(debug_info))) { - debug_info = yasm_dwarf2__generate_info(object, debug_line, main_code); - yasm_dwarf2__generate_aranges(object, debug_info); - /*yasm_dwarf2__generate_pubnames(object, debug_info);*/ + (!debug_info || yasm_section_bcs_first(debug_info) + == yasm_section_bcs_last(debug_info))) { + debug_info = yasm_dwarf2__generate_info(object, debug_line, main_code); + yasm_dwarf2__generate_aranges(object, debug_info); + /*yasm_dwarf2__generate_pubnames(object, debug_info);*/ } } @@ -179,9 +181,9 @@ yasm_dwarf2__bc_sym(yasm_symtab *symtab, yasm_bytecode *bc) { /*@dependent@*/ yasm_symrec *sym; if (bc->symrecs && bc->symrecs[0]) - sym = bc->symrecs[0]; + sym = bc->symrecs[0]; else - sym = yasm_symtab_define_label(symtab, ".bcsym", bc, 0, 0); + sym = yasm_symtab_define_label(symtab, ".bcsym", bc, 0, 0); return sym; } @@ -199,20 +201,20 @@ yasm_dwarf2__add_head bc = yasm_bc_create_common(&dwarf2_head_bc_callback, head, 0); bc->len = dbgfmt_dwarf2->sizeof_offset + 2; if (dbgfmt_dwarf2->format == DWARF2_FORMAT_64BIT) - bc->len += 4; + bc->len += 4; if (debug_ptr) { - head->debug_ptr = debug_ptr; - bc->len += dbgfmt_dwarf2->sizeof_offset; + head->debug_ptr = debug_ptr; + bc->len += dbgfmt_dwarf2->sizeof_offset; } else - head->debug_ptr = NULL; + head->debug_ptr = NULL; head->with_address = with_address; head->with_segment = with_segment; if (with_address) - bc->len++; + bc->len++; if (with_segment) - bc->len++; + bc->len++; head->end_prevbc = bc; yasm_dwarf2__append_bc(sect, bc); @@ -239,7 +241,7 @@ dwarf2_head_bc_print(const void *contents, FILE *f, int indent_level) static int dwarf2_head_bc_calc_len(yasm_bytecode *bc, yasm_bc_add_span_func add_span, - void *add_span_data) + void *add_span_data) { yasm_internal_error(N_("tried to calc_len a dwarf2 head bytecode")); /*@notreached@*/ @@ -247,10 +249,9 @@ dwarf2_head_bc_calc_len(yasm_bytecode *bc, yasm_bc_add_span_func add_span, } static int -dwarf2_head_bc_tobytes(yasm_bytecode *bc, unsigned char **bufp, - unsigned char *bufstart, void *d, - yasm_output_value_func output_value, - yasm_output_reloc_func output_reloc) +dwarf2_head_bc_tobytes(yasm_bytecode *bc, unsigned char **bufp, void *d, + yasm_output_value_func output_value, + yasm_output_reloc_func output_reloc) { yasm_object *object = yasm_section_get_object(bc->section); yasm_dbgfmt_dwarf2 *dbgfmt_dwarf2 = (yasm_dbgfmt_dwarf2 *)object->dbgfmt; @@ -259,10 +260,10 @@ dwarf2_head_bc_tobytes(yasm_bytecode *bc, unsigned char **bufp, yasm_intnum *intn, *cval; if (dbgfmt_dwarf2->format == DWARF2_FORMAT_64BIT) { - YASM_WRITE_8(buf, 0xff); - YASM_WRITE_8(buf, 0xff); - YASM_WRITE_8(buf, 0xff); - YASM_WRITE_8(buf, 0xff); + YASM_WRITE_8(buf, 0xff); + YASM_WRITE_8(buf, 0xff); + YASM_WRITE_8(buf, 0xff); + YASM_WRITE_8(buf, 0xff); } /* Total length of aranges info (following this field) */ @@ -270,8 +271,8 @@ dwarf2_head_bc_tobytes(yasm_bytecode *bc, unsigned char **bufp, intn = yasm_calc_bc_dist(head->start_prevbc, head->end_prevbc); yasm_intnum_calc(intn, YASM_EXPR_SUB, cval); yasm_arch_intnum_tobytes(object->arch, intn, buf, - dbgfmt_dwarf2->sizeof_offset, - dbgfmt_dwarf2->sizeof_offset*8, 0, bc, 0); + dbgfmt_dwarf2->sizeof_offset, + dbgfmt_dwarf2->sizeof_offset*8, 0, bc, 0); buf += dbgfmt_dwarf2->sizeof_offset; yasm_intnum_destroy(intn); @@ -282,23 +283,23 @@ dwarf2_head_bc_tobytes(yasm_bytecode *bc, unsigned char **bufp, /* Pointer to another debug section */ if (head->debug_ptr) { - yasm_value value; - yasm_value_init_sym(&value, - yasm_dwarf2__bc_sym(object->symtab, - yasm_section_bcs_first(head->debug_ptr)), - dbgfmt_dwarf2->sizeof_offset*8); - output_value(&value, buf, dbgfmt_dwarf2->sizeof_offset, - (unsigned long)(buf-bufstart), bc, 0, d); - buf += dbgfmt_dwarf2->sizeof_offset; + yasm_value value; + yasm_value_init_sym(&value, + yasm_dwarf2__bc_sym(object->symtab, + yasm_section_bcs_first(head->debug_ptr)), + dbgfmt_dwarf2->sizeof_offset*8); + output_value(&value, buf, dbgfmt_dwarf2->sizeof_offset, + (unsigned long)(buf-*bufp), bc, 0, d); + buf += dbgfmt_dwarf2->sizeof_offset; } /* Size of the offset portion of the address */ if (head->with_address) - YASM_WRITE_8(buf, dbgfmt_dwarf2->sizeof_address); + YASM_WRITE_8(buf, dbgfmt_dwarf2->sizeof_address); /* Size of a segment descriptor. 0 = flat address space */ if (head->with_segment) - YASM_WRITE_8(buf, 0); + YASM_WRITE_8(buf, 0); *bufp = buf; @@ -315,9 +316,9 @@ dwarf2_section_data_destroy(void *data) /* Delete locations */ n1 = STAILQ_FIRST(&dsd->locs); while (n1) { - n2 = STAILQ_NEXT(n1, link); - yasm_xfree(n1); - n1 = n2; + n2 = STAILQ_NEXT(n1, link); + yasm_xfree(n1); + n1 = n2; } yasm_xfree(data); @@ -330,10 +331,10 @@ dwarf2_section_data_print(void *data, FILE *f, int indent_level) } static const yasm_directive dwarf2_directives[] = { - { ".loc", "gas", yasm_dwarf2__dir_loc, YASM_DIR_ARG_REQUIRED }, - { ".file", "gas", yasm_dwarf2__dir_file, YASM_DIR_ARG_REQUIRED }, - { "loc", "nasm", yasm_dwarf2__dir_loc, YASM_DIR_ARG_REQUIRED }, - { "file", "nasm", yasm_dwarf2__dir_file, YASM_DIR_ARG_REQUIRED }, + { ".loc", "gas", yasm_dwarf2__dir_loc, YASM_DIR_ARG_REQUIRED }, + { ".file", "gas", yasm_dwarf2__dir_file, YASM_DIR_ARG_REQUIRED }, + { "loc", "nasm", yasm_dwarf2__dir_loc, YASM_DIR_ARG_REQUIRED }, + { "file", "nasm", yasm_dwarf2__dir_file, YASM_DIR_ARG_REQUIRED }, { NULL, NULL, NULL, 0 } }; diff --git a/modules/dbgfmts/dwarf2/dwarf2-dbgfmt.h b/modules/dbgfmts/dwarf2/dwarf2-dbgfmt.h index 03752345..6ed9d1e2 100644 --- a/modules/dbgfmts/dwarf2/dwarf2-dbgfmt.h +++ b/modules/dbgfmts/dwarf2/dwarf2-dbgfmt.h @@ -1,4 +1,4 @@ -/* +/* $Id$ * DWARF2 debugging format * * Copyright (C) 2006-2007 Peter Johnson @@ -30,15 +30,15 @@ #define WITH_DWARF3 1 typedef struct { - char *pathname; /* full filename */ - char *filename; /* basename of full filename */ - unsigned long dir; /* index into directories array for relative path; - * 0 for current directory. */ + char *pathname; /* full filename */ + char *filename; /* basename of full filename */ + unsigned long dir; /* index into directories array for relative path; + * 0 for current directory. */ } dwarf2_filename; /* Global data */ typedef struct yasm_dbgfmt_dwarf2 { - yasm_dbgfmt_base dbgfmt; /* base structure */ + yasm_dbgfmt_base dbgfmt; /* base structure */ char **dirs; unsigned long dirs_size; @@ -49,8 +49,8 @@ typedef struct yasm_dbgfmt_dwarf2 { unsigned long filenames_allocated; enum { - DWARF2_FORMAT_32BIT, - DWARF2_FORMAT_64BIT + DWARF2_FORMAT_32BIT, + DWARF2_FORMAT_64BIT } format; unsigned int sizeof_address, sizeof_offset, min_insn_len; @@ -63,23 +63,22 @@ typedef struct dwarf2_loc { unsigned long vline; /* virtual line number of .loc directive */ /* source information */ - unsigned long file; /* index into table of filenames */ - unsigned long line; /* source line number */ + unsigned long file; /* index into table of filenames */ + unsigned long line; /* source line number */ unsigned long column; /* source column */ - unsigned long discriminator; int isa_change; unsigned long isa; enum { - IS_STMT_NOCHANGE = 0, - IS_STMT_SET, - IS_STMT_CLEAR + IS_STMT_NOCHANGE = 0, + IS_STMT_SET, + IS_STMT_CLEAR } is_stmt; int basic_block; int prologue_end; int epilogue_begin; - yasm_bytecode *bc; /* first bytecode following */ - yasm_symrec *sym; /* last symbol preceding */ + yasm_bytecode *bc; /* first bytecode following */ + yasm_symrec *sym; /* last symbol preceding */ } dwarf2_loc; /* Per-section data */ @@ -95,7 +94,7 @@ extern const yasm_assoc_data_callback yasm_dwarf2__section_data_cb; yasm_bytecode *yasm_dwarf2__append_bc(yasm_section *sect, yasm_bytecode *bc); /*@dependent@*/ yasm_symrec *yasm_dwarf2__bc_sym(yasm_symtab *symtab, - yasm_bytecode *bc); + yasm_bytecode *bc); typedef struct dwarf2_head dwarf2_head; dwarf2_head *yasm_dwarf2__add_head @@ -109,19 +108,19 @@ yasm_section *yasm_dwarf2__generate_line int asm_source, /*@out@*/ yasm_section **main_code, /*@out@*/ size_t *num_line_sections); void yasm_dwarf2__dir_loc(yasm_object *object, yasm_valparamhead *valparams, - yasm_valparamhead *objext_valparams, - unsigned long line); + yasm_valparamhead *objext_valparams, + unsigned long line); void yasm_dwarf2__dir_file(yasm_object *object, yasm_valparamhead *valparams, - yasm_valparamhead *objext_valparams, - unsigned long line); + yasm_valparamhead *objext_valparams, + unsigned long line); /* Address range table functions */ yasm_section *yasm_dwarf2__generate_aranges(yasm_object *object, - yasm_section *debug_info); + yasm_section *debug_info); /* Name lookup table functions */ yasm_section *yasm_dwarf2__generate_pubnames(yasm_object *object, - yasm_section *debug_info); + yasm_section *debug_info); /* Information functions */ yasm_section *yasm_dwarf2__generate_info diff --git a/modules/dbgfmts/dwarf2/dwarf2-info.c b/modules/dbgfmts/dwarf2/dwarf2-info.c index 7dbe43a9..5ae66479 100644 --- a/modules/dbgfmts/dwarf2/dwarf2-info.c +++ b/modules/dbgfmts/dwarf2/dwarf2-info.c @@ -25,12 +25,22 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include +/*@unused@*/ RCSID("$Id$"); +/* Need either unistd.h or direct.h (on Windows) to prototype getcwd() */ +#ifdef HAVE_UNISTD_H +#include +#elif defined(WIN32) || defined(_WIN32) +#include +#endif + +#define YASM_LIB_INTERNAL +#define YASM_BC_INTERNAL #include #include "dwarf2-dbgfmt.h" -#define DW_LANG_Mips_Assembler 0x8001 +#define DW_LANG_Mips_Assembler 0x8001 /* Tag encodings */ typedef enum { @@ -192,11 +202,11 @@ typedef struct dwarf2_abbrev { static void dwarf2_abbrev_bc_destroy(void *contents); static void dwarf2_abbrev_bc_print(const void *contents, FILE *f, - int indent_level); + int indent_level); static int dwarf2_abbrev_bc_calc_len (yasm_bytecode *bc, yasm_bc_add_span_func add_span, void *add_span_data); static int dwarf2_abbrev_bc_tobytes - (yasm_bytecode *bc, unsigned char **bufp, unsigned char *bufstart, void *d, + (yasm_bytecode *bc, unsigned char **bufp, void *d, yasm_output_value_func output_value, /*@null@*/ yasm_output_reloc_func output_reloc); @@ -206,7 +216,6 @@ static const yasm_bytecode_callback dwarf2_abbrev_bc_callback = { dwarf2_abbrev_bc_destroy, dwarf2_abbrev_bc_print, yasm_bc_finalize_common, - NULL, dwarf2_abbrev_bc_calc_len, yasm_bc_expand_common, dwarf2_abbrev_bc_tobytes, @@ -216,7 +225,7 @@ static const yasm_bytecode_callback dwarf2_abbrev_bc_callback = { static unsigned long dwarf2_add_abbrev_attr(dwarf2_abbrev *abbrev, dwarf_attribute name, - dwarf_form form) + dwarf_form form) { dwarf2_abbrev_attr *attr = yasm_xmalloc(sizeof(dwarf2_abbrev_attr)); attr->name = name; @@ -227,7 +236,7 @@ dwarf2_add_abbrev_attr(dwarf2_abbrev *abbrev, dwarf_attribute name, static void dwarf2_append_expr(yasm_section *sect, /*@only@*/ yasm_expr *expr, - unsigned int size, int leb) + unsigned int size, int leb) { yasm_datavalhead dvs; yasm_bytecode *bc; @@ -235,9 +244,9 @@ dwarf2_append_expr(yasm_section *sect, /*@only@*/ yasm_expr *expr, yasm_dvs_initialize(&dvs); yasm_dvs_append(&dvs, yasm_dv_create_expr(expr)); if (leb == 0) - bc = yasm_bc_create_data(&dvs, size, 0, NULL, 0); + bc = yasm_bc_create_data(&dvs, size, 0, NULL, 0); else - bc = yasm_bc_create_leb128(&dvs, leb<0, 0); + bc = yasm_bc_create_leb128(&dvs, leb<0, 0); yasm_bc_finalize(bc, yasm_dwarf2__append_bc(sect, bc)); yasm_bc_calc_len(bc, NULL, NULL); } @@ -250,7 +259,7 @@ dwarf2_append_str(yasm_section *sect, const char *str) yasm_dvs_initialize(&dvs); yasm_dvs_append(&dvs, yasm_dv_create_string(yasm__xstrdup(str), - strlen(str))); + strlen(str))); bc = yasm_bc_create_data(&dvs, 1, 1, NULL, 0); yasm_bc_finalize(bc, yasm_dwarf2__append_bc(sect, bc)); yasm_bc_calc_len(bc, NULL, NULL); @@ -258,7 +267,7 @@ dwarf2_append_str(yasm_section *sect, const char *str) yasm_section * yasm_dwarf2__generate_info(yasm_object *object, yasm_section *debug_line, - yasm_section *main_code) + yasm_section *main_code) { yasm_dbgfmt_dwarf2 *dbgfmt_dwarf2 = (yasm_dbgfmt_dwarf2 *)object->dbgfmt; int new; @@ -267,9 +276,9 @@ yasm_dwarf2__generate_info(yasm_object *object, yasm_section *debug_line, dwarf2_head *head; char *buf; yasm_section *debug_abbrev = - yasm_object_get_general(object, ".debug_abbrev", 4, 0, 0, &new, 0); + yasm_object_get_general(object, ".debug_abbrev", 0, 4, 0, 0, &new, 0); yasm_section *debug_info = - yasm_object_get_general(object, ".debug_info", 4, 0, 0, &new, 0); + yasm_object_get_general(object, ".debug_info", 0, 4, 0, 0, &new, 0); yasm_section_set_align(debug_abbrev, 0, 0); yasm_section_set_align(debug_info, 0, 0); @@ -281,7 +290,7 @@ yasm_dwarf2__generate_info(yasm_object *object, yasm_section *debug_line, abbrev->tag = DW_TAG_compile_unit; abbrev->has_children = 0; abc->len = yasm_size_uleb128(abbrev->id) + yasm_size_uleb128(abbrev->tag) - + 3; + + 3; STAILQ_INIT(&abbrev->attrs); yasm_dwarf2__append_bc(debug_abbrev, abc); @@ -294,34 +303,34 @@ yasm_dwarf2__generate_info(yasm_object *object, yasm_section *debug_line, /* generating info using abbrev 1 */ dwarf2_append_expr(debug_info, - yasm_expr_create_ident(yasm_expr_int(yasm_intnum_create_uint(1)), 0), - 0, 1); + yasm_expr_create_ident(yasm_expr_int(yasm_intnum_create_uint(1)), 0), + 0, 1); /* statement list (line numbers) */ abc->len += dwarf2_add_abbrev_attr(abbrev, DW_AT_stmt_list, DW_FORM_data4); dwarf2_append_expr(debug_info, - yasm_expr_create_ident(yasm_expr_sym( - yasm_dwarf2__bc_sym(object->symtab, - yasm_section_bcs_first(debug_line))), 0), - dbgfmt_dwarf2->sizeof_offset, 0); + yasm_expr_create_ident(yasm_expr_sym( + yasm_dwarf2__bc_sym(object->symtab, + yasm_section_bcs_first(debug_line))), 0), + dbgfmt_dwarf2->sizeof_offset, 0); if (main_code) { - yasm_symrec *first; - first = yasm_dwarf2__bc_sym(object->symtab, - yasm_section_bcs_first(main_code)); - /* All code is contiguous in one section */ - abc->len += dwarf2_add_abbrev_attr(abbrev, DW_AT_low_pc, DW_FORM_addr); - dwarf2_append_expr(debug_info, - yasm_expr_create_ident(yasm_expr_sym(first), 0), - dbgfmt_dwarf2->sizeof_address, 0); + yasm_symrec *first; + first = yasm_dwarf2__bc_sym(object->symtab, + yasm_section_bcs_first(main_code)); + /* All code is contiguous in one section */ + abc->len += dwarf2_add_abbrev_attr(abbrev, DW_AT_low_pc, DW_FORM_addr); + dwarf2_append_expr(debug_info, + yasm_expr_create_ident(yasm_expr_sym(first), 0), + dbgfmt_dwarf2->sizeof_address, 0); - abc->len += dwarf2_add_abbrev_attr(abbrev, DW_AT_high_pc, DW_FORM_addr); - dwarf2_append_expr(debug_info, - yasm_expr_create(YASM_EXPR_ADD, yasm_expr_sym(first), - yasm_expr_int(yasm_calc_bc_dist( - yasm_section_bcs_first(main_code), - yasm_section_bcs_last(main_code))), 0), - dbgfmt_dwarf2->sizeof_address, 0); + abc->len += dwarf2_add_abbrev_attr(abbrev, DW_AT_high_pc, DW_FORM_addr); + dwarf2_append_expr(debug_info, + yasm_expr_create(YASM_EXPR_ADD, yasm_expr_sym(first), + yasm_expr_int(yasm_calc_bc_dist( + yasm_section_bcs_first(main_code), + yasm_section_bcs_last(main_code))), 0), + dbgfmt_dwarf2->sizeof_address, 0); } /* input filename */ @@ -330,22 +339,19 @@ yasm_dwarf2__generate_info(yasm_object *object, yasm_section *debug_line, /* compile directory (current working directory) */ abc->len += dwarf2_add_abbrev_attr(abbrev, DW_AT_comp_dir, DW_FORM_string); - buf = yasm__getcwd(); + buf = getcwd(NULL, 0); dwarf2_append_str(debug_info, buf); - yasm_xfree(buf); + free(buf); /* producer - assembler name */ abc->len += dwarf2_add_abbrev_attr(abbrev, DW_AT_producer, DW_FORM_string); - if (getenv("YASM_TEST_SUITE")) - dwarf2_append_str(debug_info, "yasm HEAD"); - else - dwarf2_append_str(debug_info, PACKAGE_STRING); + dwarf2_append_str(debug_info, PACKAGE " " VERSION); /* language - no standard code for assembler, use MIPS as a substitute */ abc->len += dwarf2_add_abbrev_attr(abbrev, DW_AT_language, DW_FORM_data2); dwarf2_append_expr(debug_info, - yasm_expr_create_ident(yasm_expr_int( - yasm_intnum_create_uint(DW_LANG_Mips_Assembler)), 0), 2, 0); + yasm_expr_create_ident(yasm_expr_int( + yasm_intnum_create_uint(DW_LANG_Mips_Assembler)), 0), 2, 0); /* Terminate list of abbreviations */ abbrev = yasm_xmalloc(sizeof(dwarf2_abbrev)); @@ -372,9 +378,9 @@ dwarf2_abbrev_bc_destroy(void *contents) /* Delete attributes */ n1 = STAILQ_FIRST(&abbrev->attrs); while (n1) { - n2 = STAILQ_NEXT(n1, link); - yasm_xfree(n1); - n1 = n2; + n2 = STAILQ_NEXT(n1, link); + yasm_xfree(n1); + n1 = n2; } yasm_xfree(contents); @@ -388,7 +394,7 @@ dwarf2_abbrev_bc_print(const void *contents, FILE *f, int indent_level) static int dwarf2_abbrev_bc_calc_len(yasm_bytecode *bc, yasm_bc_add_span_func add_span, - void *add_span_data) + void *add_span_data) { yasm_internal_error(N_("tried to calc_len a dwarf2 aranges head bytecode")); /*@notreached@*/ @@ -396,19 +402,18 @@ dwarf2_abbrev_bc_calc_len(yasm_bytecode *bc, yasm_bc_add_span_func add_span, } static int -dwarf2_abbrev_bc_tobytes(yasm_bytecode *bc, unsigned char **bufp, - unsigned char *bufstart, void *d, - yasm_output_value_func output_value, - yasm_output_reloc_func output_reloc) +dwarf2_abbrev_bc_tobytes(yasm_bytecode *bc, unsigned char **bufp, void *d, + yasm_output_value_func output_value, + yasm_output_reloc_func output_reloc) { dwarf2_abbrev *abbrev = (dwarf2_abbrev *)bc->contents; unsigned char *buf = *bufp; dwarf2_abbrev_attr *attr; if (abbrev->id == 0) { - YASM_WRITE_8(buf, 0); - *bufp = buf; - return 0; + YASM_WRITE_8(buf, 0); + *bufp = buf; + return 0; } buf += yasm_get_uleb128(abbrev->id, buf); @@ -416,8 +421,8 @@ dwarf2_abbrev_bc_tobytes(yasm_bytecode *bc, unsigned char **bufp, YASM_WRITE_8(buf, abbrev->has_children); STAILQ_FOREACH(attr, &abbrev->attrs, link) { - buf += yasm_get_uleb128(attr->name, buf); - buf += yasm_get_uleb128(attr->form, buf); + buf += yasm_get_uleb128(attr->name, buf); + buf += yasm_get_uleb128(attr->form, buf); } YASM_WRITE_8(buf, 0); diff --git a/modules/dbgfmts/dwarf2/dwarf2-line.c b/modules/dbgfmts/dwarf2/dwarf2-line.c index 8943c067..0ebd0ef3 100644 --- a/modules/dbgfmts/dwarf2/dwarf2-line.c +++ b/modules/dbgfmts/dwarf2/dwarf2-line.c @@ -28,7 +28,10 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include +/*@unused@*/ RCSID("$Id$"); +#define YASM_LIB_INTERNAL +#define YASM_BC_INTERNAL #include #include "dwarf2-dbgfmt.h" @@ -56,19 +59,19 @@ typedef enum { /* # of LEB128 operands needed for each of the above opcodes */ static unsigned char line_opcode_num_operands[DWARF2_LINE_OPCODE_BASE-1] = { - 0, /* DW_LNS_copy */ - 1, /* DW_LNS_advance_pc */ - 1, /* DW_LNS_advance_line */ - 1, /* DW_LNS_set_file */ - 1, /* DW_LNS_set_column */ - 0, /* DW_LNS_negate_stmt */ - 0, /* DW_LNS_set_basic_block */ - 0, /* DW_LNS_const_add_pc */ - 1, /* DW_LNS_fixed_advance_pc */ + 0, /* DW_LNS_copy */ + 1, /* DW_LNS_advance_pc */ + 1, /* DW_LNS_advance_line */ + 1, /* DW_LNS_set_file */ + 1, /* DW_LNS_set_column */ + 0, /* DW_LNS_negate_stmt */ + 0, /* DW_LNS_set_basic_block */ + 0, /* DW_LNS_const_add_pc */ + 1, /* DW_LNS_fixed_advance_pc */ #ifdef WITH_DWARF3 - 0, /* DW_LNS_set_prologue_end */ - 0, /* DW_LNS_set_epilogue_begin */ - 1 /* DW_LNS_set_isa */ + 0, /* DW_LNS_set_prologue_end */ + 0, /* DW_LNS_set_epilogue_begin */ + 1 /* DW_LNS_set_isa */ #endif }; @@ -76,20 +79,19 @@ static unsigned char line_opcode_num_operands[DWARF2_LINE_OPCODE_BASE-1] = { typedef enum { DW_LNE_end_sequence = 1, DW_LNE_set_address, - DW_LNE_define_file, - DW_LNE_set_discriminator + DW_LNE_define_file } dwarf_line_number_ext_op; /* Base and range for line offsets in special opcodes */ -#define DWARF2_LINE_BASE -5 -#define DWARF2_LINE_RANGE 14 +#define DWARF2_LINE_BASE -5 +#define DWARF2_LINE_RANGE 14 -#define DWARF2_MAX_SPECIAL_ADDR_DELTA \ +#define DWARF2_MAX_SPECIAL_ADDR_DELTA \ (((255-DWARF2_LINE_OPCODE_BASE)/DWARF2_LINE_RANGE)*\ dbgfmt_dwarf2->min_insn_len) /* Initial value of is_stmt register */ -#define DWARF2_LINE_DEFAULT_IS_STMT 1 +#define DWARF2_LINE_DEFAULT_IS_STMT 1 /* Line number state machine register state */ typedef struct dwarf2_line_state { @@ -120,28 +122,27 @@ typedef struct dwarf2_line_op { /* extended opcode */ dwarf_line_number_ext_op ext_opcode; /*@null@*/ /*@dependent@*/ yasm_symrec *ext_operand; /* unsigned */ - /*@null@*/ /*@dependent@*/ yasm_intnum *ext_operand_int; /* unsigned */ unsigned long ext_operandsize; } dwarf2_line_op; /* Bytecode callback function prototypes */ static void dwarf2_spp_bc_destroy(void *contents); static void dwarf2_spp_bc_print(const void *contents, FILE *f, - int indent_level); + int indent_level); static int dwarf2_spp_bc_calc_len (yasm_bytecode *bc, yasm_bc_add_span_func add_span, void *add_span_data); static int dwarf2_spp_bc_tobytes - (yasm_bytecode *bc, unsigned char **bufp, unsigned char *bufstart, void *d, + (yasm_bytecode *bc, unsigned char **bufp, void *d, yasm_output_value_func output_value, /*@null@*/ yasm_output_reloc_func output_reloc); static void dwarf2_line_op_bc_destroy(void *contents); static void dwarf2_line_op_bc_print(const void *contents, FILE *f, - int indent_level); + int indent_level); static int dwarf2_line_op_bc_calc_len (yasm_bytecode *bc, yasm_bc_add_span_func add_span, void *add_span_data); static int dwarf2_line_op_bc_tobytes - (yasm_bytecode *bc, unsigned char **bufp, unsigned char *bufstart, void *d, + (yasm_bytecode *bc, unsigned char **bufp, void *d, yasm_output_value_func output_value, /*@null@*/ yasm_output_reloc_func output_reloc); @@ -150,7 +151,6 @@ static const yasm_bytecode_callback dwarf2_spp_bc_callback = { dwarf2_spp_bc_destroy, dwarf2_spp_bc_print, yasm_bc_finalize_common, - NULL, dwarf2_spp_bc_calc_len, yasm_bc_expand_common, dwarf2_spp_bc_tobytes, @@ -161,7 +161,6 @@ static const yasm_bytecode_callback dwarf2_line_op_bc_callback = { dwarf2_line_op_bc_destroy, dwarf2_line_op_bc_print, yasm_bc_finalize_common, - NULL, dwarf2_line_op_bc_calc_len, yasm_bc_expand_common, dwarf2_line_op_bc_tobytes, @@ -171,7 +170,7 @@ static const yasm_bytecode_callback dwarf2_line_op_bc_callback = { static size_t dwarf2_dbgfmt_add_file(yasm_dbgfmt_dwarf2 *dbgfmt_dwarf2, unsigned long filenum, - const char *pathname) + const char *pathname) { size_t dirlen; const char *filename; @@ -181,62 +180,62 @@ dwarf2_dbgfmt_add_file(yasm_dbgfmt_dwarf2 *dbgfmt_dwarf2, unsigned long filenum, dir = 0; dirlen = yasm__splitpath(pathname, &filename); if (dirlen > 0) { - /* Look to see if we already have that dir in the table */ - for (dir=1; dirdirs_size+1; dir++) { - if (strncmp(dbgfmt_dwarf2->dirs[dir-1], pathname, dirlen) == 0 - && dbgfmt_dwarf2->dirs[dir-1][dirlen] == '\0') - break; - } - if (dir >= dbgfmt_dwarf2->dirs_size+1) { - /* Not found in table, add to end, reallocing if necessary */ - if (dir >= dbgfmt_dwarf2->dirs_allocated+1) { - dbgfmt_dwarf2->dirs_allocated = dir+32; - dbgfmt_dwarf2->dirs = yasm_xrealloc(dbgfmt_dwarf2->dirs, - sizeof(char *)*dbgfmt_dwarf2->dirs_allocated); - } - dbgfmt_dwarf2->dirs[dir-1] = yasm__xstrndup(pathname, dirlen); - dbgfmt_dwarf2->dirs_size = dir; - } + /* Look to see if we already have that dir in the table */ + for (dir=1; dirdirs_size+1; dir++) { + if (strncmp(dbgfmt_dwarf2->dirs[dir-1], pathname, dirlen) == 0 + && dbgfmt_dwarf2->dirs[dir-1][dirlen] == '\0') + break; + } + if (dir >= dbgfmt_dwarf2->dirs_size+1) { + /* Not found in table, add to end, reallocing if necessary */ + if (dir >= dbgfmt_dwarf2->dirs_allocated+1) { + dbgfmt_dwarf2->dirs_allocated = dir+32; + dbgfmt_dwarf2->dirs = yasm_xrealloc(dbgfmt_dwarf2->dirs, + sizeof(char *)*dbgfmt_dwarf2->dirs_allocated); + } + dbgfmt_dwarf2->dirs[dir-1] = yasm__xstrndup(pathname, dirlen); + dbgfmt_dwarf2->dirs_size = dir; + } } /* Put the filename into the filename table */ if (filenum == 0) { - /* Look to see if we already have that filename in the table */ - for (; filenumfilenames_size; filenum++) { - if (!dbgfmt_dwarf2->filenames[filenum].filename || - (dbgfmt_dwarf2->filenames[filenum].dir == dir - && strcmp(dbgfmt_dwarf2->filenames[filenum].filename, - filename) == 0)) - break; - } + /* Look to see if we already have that filename in the table */ + for (; filenumfilenames_size; filenum++) { + if (!dbgfmt_dwarf2->filenames[filenum].filename || + (dbgfmt_dwarf2->filenames[filenum].dir == dir + && strcmp(dbgfmt_dwarf2->filenames[filenum].filename, + filename) == 0)) + break; + } } else - filenum--; /* array index is 0-based */ + filenum--; /* array index is 0-based */ /* Realloc table if necessary */ if (filenum >= dbgfmt_dwarf2->filenames_allocated) { - unsigned long old_allocated = dbgfmt_dwarf2->filenames_allocated; - dbgfmt_dwarf2->filenames_allocated = filenum+32; - dbgfmt_dwarf2->filenames = yasm_xrealloc(dbgfmt_dwarf2->filenames, - sizeof(dwarf2_filename)*dbgfmt_dwarf2->filenames_allocated); - for (i=old_allocated; ifilenames_allocated; i++) { - dbgfmt_dwarf2->filenames[i].pathname = NULL; - dbgfmt_dwarf2->filenames[i].filename = NULL; - dbgfmt_dwarf2->filenames[i].dir = 0; - } + unsigned long old_allocated = dbgfmt_dwarf2->filenames_allocated; + dbgfmt_dwarf2->filenames_allocated = filenum+32; + dbgfmt_dwarf2->filenames = yasm_xrealloc(dbgfmt_dwarf2->filenames, + sizeof(dwarf2_filename)*dbgfmt_dwarf2->filenames_allocated); + for (i=old_allocated; ifilenames_allocated; i++) { + dbgfmt_dwarf2->filenames[i].pathname = NULL; + dbgfmt_dwarf2->filenames[i].filename = NULL; + dbgfmt_dwarf2->filenames[i].dir = 0; + } } /* Actually save in table */ if (dbgfmt_dwarf2->filenames[filenum].pathname) - yasm_xfree(dbgfmt_dwarf2->filenames[filenum].pathname); + yasm_xfree(dbgfmt_dwarf2->filenames[filenum].pathname); if (dbgfmt_dwarf2->filenames[filenum].filename) - yasm_xfree(dbgfmt_dwarf2->filenames[filenum].filename); + yasm_xfree(dbgfmt_dwarf2->filenames[filenum].filename); dbgfmt_dwarf2->filenames[filenum].pathname = yasm__xstrdup(pathname); dbgfmt_dwarf2->filenames[filenum].filename = yasm__xstrdup(filename); dbgfmt_dwarf2->filenames[filenum].dir = dir; /* Update table size */ if (filenum >= dbgfmt_dwarf2->filenames_size) - dbgfmt_dwarf2->filenames_size = filenum + 1; + dbgfmt_dwarf2->filenames_size = filenum + 1; return filenum; } @@ -246,7 +245,7 @@ dwarf2_dbgfmt_add_file(yasm_dbgfmt_dwarf2 *dbgfmt_dwarf2, unsigned long filenum, */ static yasm_bytecode * dwarf2_dbgfmt_append_line_op(yasm_section *sect, dwarf_line_number_op opcode, - /*@only@*/ /*@null@*/ yasm_intnum *operand) + /*@only@*/ /*@null@*/ yasm_intnum *operand) { dwarf2_line_op *line_op = yasm_xmalloc(sizeof(dwarf2_line_op)); yasm_bytecode *bc; @@ -255,14 +254,13 @@ dwarf2_dbgfmt_append_line_op(yasm_section *sect, dwarf_line_number_op opcode, line_op->operand = operand; line_op->ext_opcode = 0; line_op->ext_operand = NULL; - line_op->ext_operand_int = NULL; line_op->ext_operandsize = 0; bc = yasm_bc_create_common(&dwarf2_line_op_bc_callback, line_op, 0); bc->len = 1; if (operand) - bc->len += yasm_intnum_size_leb128(operand, - opcode == DW_LNS_advance_line); + bc->len += yasm_intnum_size_leb128(operand, + opcode == DW_LNS_advance_line); yasm_dwarf2__append_bc(sect, bc); return bc; @@ -273,9 +271,9 @@ dwarf2_dbgfmt_append_line_op(yasm_section *sect, dwarf_line_number_op opcode, */ static yasm_bytecode * dwarf2_dbgfmt_append_line_ext_op(yasm_section *sect, - dwarf_line_number_ext_op ext_opcode, - unsigned long ext_operandsize, - /*@null@*/ yasm_symrec *ext_operand) + dwarf_line_number_ext_op ext_opcode, + unsigned long ext_operandsize, + /*@null@*/ yasm_symrec *ext_operand) { dwarf2_line_op *line_op = yasm_xmalloc(sizeof(dwarf2_line_op)); yasm_bytecode *bc; @@ -284,36 +282,11 @@ dwarf2_dbgfmt_append_line_ext_op(yasm_section *sect, line_op->operand = yasm_intnum_create_uint(ext_operandsize+1); line_op->ext_opcode = ext_opcode; line_op->ext_operand = ext_operand; - line_op->ext_operand_int = NULL; line_op->ext_operandsize = ext_operandsize; bc = yasm_bc_create_common(&dwarf2_line_op_bc_callback, line_op, 0); bc->len = 2 + yasm_intnum_size_leb128(line_op->operand, 0) + - ext_operandsize; - - yasm_dwarf2__append_bc(sect, bc); - return bc; -} - -static yasm_bytecode * -dwarf2_dbgfmt_append_line_ext_op_int(yasm_section *sect, - dwarf_line_number_ext_op ext_opcode, - /*@only@*/ yasm_intnum *ext_operand) -{ - dwarf2_line_op *line_op = yasm_xmalloc(sizeof(dwarf2_line_op)); - unsigned long ext_operandsize = yasm_intnum_size_leb128(ext_operand, 0); - yasm_bytecode *bc; - - line_op->opcode = DW_LNS_extended_op; - line_op->operand = yasm_intnum_create_uint(ext_operandsize+1); - line_op->ext_opcode = ext_opcode; - line_op->ext_operand = NULL; - line_op->ext_operand_int = ext_operand; - line_op->ext_operandsize = ext_operandsize; - - bc = yasm_bc_create_common(&dwarf2_line_op_bc_callback, line_op, 0); - bc->len = 2 + yasm_intnum_size_leb128(line_op->operand, 0) + - ext_operandsize; + ext_operandsize; yasm_dwarf2__append_bc(sect, bc); return bc; @@ -328,33 +301,33 @@ dwarf2_dbgfmt_finalize_locs(yasm_section *sect, dwarf2_section_data *dsd) bc = yasm_section_bcs_first(sect); STAILQ_FOREACH(loc, &dsd->locs, link) { - /* Find the first bytecode following this loc by looking at - * the virtual line numbers. XXX: this assumes the source file - * order will be the same as the actual section order. If we ever - * implement subsegs this will NOT necessarily be true and this logic - * will need to be fixed to handle it! - * - * Keep track of last symbol seen prior to the loc. - */ - while (bc && bc->line <= loc->vline) { - if (bc->symrecs) { - int i = 0; - while (bc->symrecs[i]) { - lastsym = bc->symrecs[i]; - i++; - } - } - bc = yasm_bc__next(bc); - } - loc->sym = lastsym; - loc->bc = bc; + /* Find the first bytecode following this loc by looking at + * the virtual line numbers. XXX: this assumes the source file + * order will be the same as the actual section order. If we ever + * implement subsegs this will NOT necessarily be true and this logic + * will need to be fixed to handle it! + * + * Keep track of last symbol seen prior to the loc. + */ + while (bc && bc->line <= loc->vline) { + if (bc->symrecs) { + int i = 0; + while (bc->symrecs[i]) { + lastsym = bc->symrecs[i]; + i++; + } + } + bc = yasm_bc__next(bc); + } + loc->sym = lastsym; + loc->bc = bc; } } static int dwarf2_dbgfmt_gen_line_op(yasm_section *debug_line, dwarf2_line_state *state, - const dwarf2_loc *loc, - /*@null@*/ const dwarf2_loc *nextloc) + const dwarf2_loc *loc, + /*@null@*/ const dwarf2_loc *nextloc) { unsigned long addr_delta; long line_delta; @@ -362,68 +335,63 @@ dwarf2_dbgfmt_gen_line_op(yasm_section *debug_line, dwarf2_line_state *state, yasm_dbgfmt_dwarf2 *dbgfmt_dwarf2 = state->dbgfmt_dwarf2; if (state->file != loc->file) { - state->file = loc->file; - dwarf2_dbgfmt_append_line_op(debug_line, DW_LNS_set_file, - yasm_intnum_create_uint(state->file)); + state->file = loc->file; + dwarf2_dbgfmt_append_line_op(debug_line, DW_LNS_set_file, + yasm_intnum_create_uint(state->file)); } if (state->column != loc->column) { - state->column = loc->column; - dwarf2_dbgfmt_append_line_op(debug_line, DW_LNS_set_column, - yasm_intnum_create_uint(state->column)); - } - if (loc->discriminator != 0) { - dwarf2_dbgfmt_append_line_ext_op_int(debug_line, - DW_LNE_set_discriminator, - yasm_intnum_create_uint(loc->discriminator)); + state->column = loc->column; + dwarf2_dbgfmt_append_line_op(debug_line, DW_LNS_set_column, + yasm_intnum_create_uint(state->column)); } #ifdef WITH_DWARF3 if (loc->isa_change) { - state->isa = loc->isa; - dwarf2_dbgfmt_append_line_op(debug_line, DW_LNS_set_isa, - yasm_intnum_create_uint(state->isa)); + state->isa = loc->isa; + dwarf2_dbgfmt_append_line_op(debug_line, DW_LNS_set_isa, + yasm_intnum_create_uint(state->isa)); } #endif if (state->is_stmt == 0 && loc->is_stmt == IS_STMT_SET) { - state->is_stmt = 1; - dwarf2_dbgfmt_append_line_op(debug_line, DW_LNS_negate_stmt, NULL); + state->is_stmt = 1; + dwarf2_dbgfmt_append_line_op(debug_line, DW_LNS_negate_stmt, NULL); } else if (state->is_stmt == 1 && loc->is_stmt == IS_STMT_CLEAR) { - state->is_stmt = 0; - dwarf2_dbgfmt_append_line_op(debug_line, DW_LNS_negate_stmt, NULL); + state->is_stmt = 0; + dwarf2_dbgfmt_append_line_op(debug_line, DW_LNS_negate_stmt, NULL); } if (loc->basic_block) { - dwarf2_dbgfmt_append_line_op(debug_line, DW_LNS_set_basic_block, NULL); + dwarf2_dbgfmt_append_line_op(debug_line, DW_LNS_set_basic_block, NULL); } #ifdef WITH_DWARF3 if (loc->prologue_end) { - dwarf2_dbgfmt_append_line_op(debug_line, DW_LNS_set_prologue_end, NULL); + dwarf2_dbgfmt_append_line_op(debug_line, DW_LNS_set_prologue_end, NULL); } if (loc->epilogue_begin) { - dwarf2_dbgfmt_append_line_op(debug_line, DW_LNS_set_epilogue_begin, - NULL); + dwarf2_dbgfmt_append_line_op(debug_line, DW_LNS_set_epilogue_begin, + NULL); } #endif /* If multiple loc for the same location, use last */ if (nextloc && nextloc->bc->offset == loc->bc->offset) - return 0; + return 0; if (!state->precbc) { - /* Set the starting address for the section */ - if (!loc->sym) { - /* shouldn't happen! */ - yasm_error_set(YASM_ERROR_GENERAL, - N_("could not find label prior to loc")); - return 1; - } - dwarf2_dbgfmt_append_line_ext_op(debug_line, DW_LNE_set_address, - dbgfmt_dwarf2->sizeof_address, loc->sym); - addr_delta = 0; + /* Set the starting address for the section */ + if (!loc->sym) { + /* shouldn't happen! */ + yasm_error_set(YASM_ERROR_GENERAL, + N_("could not find label prior to loc")); + return 1; + } + dwarf2_dbgfmt_append_line_ext_op(debug_line, DW_LNE_set_address, + dbgfmt_dwarf2->sizeof_address, loc->sym); + addr_delta = 0; } else if (loc->bc) { - if (state->precbc->offset > loc->bc->offset) - yasm_internal_error(N_("dwarf2 address went backwards?")); - addr_delta = loc->bc->offset - state->precbc->offset; + if (state->precbc->offset > loc->bc->offset) + yasm_internal_error(N_("dwarf2 address went backwards?")); + addr_delta = loc->bc->offset - state->precbc->offset; } else - return 0; /* ran out of bytecodes! XXX: do something? */ + return 0; /* ran out of bytecodes! XXX: do something? */ /* Generate appropriate opcode(s). Address can only increment, * whereas line number can go backwards. @@ -433,42 +401,42 @@ dwarf2_dbgfmt_gen_line_op(yasm_section *debug_line, dwarf2_line_state *state, /* First handle the line delta */ if (line_delta < DWARF2_LINE_BASE - || line_delta >= DWARF2_LINE_BASE+DWARF2_LINE_RANGE) { - /* Won't fit in special opcode, use (signed) line advance */ - dwarf2_dbgfmt_append_line_op(debug_line, DW_LNS_advance_line, - yasm_intnum_create_int(line_delta)); - line_delta = 0; + || line_delta >= DWARF2_LINE_BASE+DWARF2_LINE_RANGE) { + /* Won't fit in special opcode, use (signed) line advance */ + dwarf2_dbgfmt_append_line_op(debug_line, DW_LNS_advance_line, + yasm_intnum_create_int(line_delta)); + line_delta = 0; } /* Next handle the address delta */ opcode1 = DWARF2_LINE_OPCODE_BASE + line_delta - DWARF2_LINE_BASE + - DWARF2_LINE_RANGE * (addr_delta / dbgfmt_dwarf2->min_insn_len); + DWARF2_LINE_RANGE * (addr_delta / dbgfmt_dwarf2->min_insn_len); opcode2 = DWARF2_LINE_OPCODE_BASE + line_delta - DWARF2_LINE_BASE + - DWARF2_LINE_RANGE * ((addr_delta - DWARF2_MAX_SPECIAL_ADDR_DELTA) / - dbgfmt_dwarf2->min_insn_len); + DWARF2_LINE_RANGE * ((addr_delta - DWARF2_MAX_SPECIAL_ADDR_DELTA) / + dbgfmt_dwarf2->min_insn_len); if (line_delta == 0 && addr_delta == 0) { - /* Both line and addr deltas are 0: do DW_LNS_copy */ - dwarf2_dbgfmt_append_line_op(debug_line, DW_LNS_copy, NULL); + /* Both line and addr deltas are 0: do DW_LNS_copy */ + dwarf2_dbgfmt_append_line_op(debug_line, DW_LNS_copy, NULL); } else if (addr_delta <= DWARF2_MAX_SPECIAL_ADDR_DELTA && opcode1 <= 255) { - /* Addr delta in range of special opcode */ - dwarf2_dbgfmt_append_line_op(debug_line, opcode1, NULL); + /* Addr delta in range of special opcode */ + dwarf2_dbgfmt_append_line_op(debug_line, opcode1, NULL); } else if (addr_delta <= 2*DWARF2_MAX_SPECIAL_ADDR_DELTA - && opcode2 <= 255) { - /* Addr delta in range of const_add_pc + special */ - dwarf2_dbgfmt_append_line_op(debug_line, DW_LNS_const_add_pc, NULL); - dwarf2_dbgfmt_append_line_op(debug_line, opcode2, NULL); + && opcode2 <= 255) { + /* Addr delta in range of const_add_pc + special */ + dwarf2_dbgfmt_append_line_op(debug_line, DW_LNS_const_add_pc, NULL); + dwarf2_dbgfmt_append_line_op(debug_line, opcode2, NULL); } else { - /* Need advance_pc */ - dwarf2_dbgfmt_append_line_op(debug_line, DW_LNS_advance_pc, - yasm_intnum_create_uint(addr_delta)); - /* Take care of any remaining line_delta and add entry to matrix */ - if (line_delta == 0) - dwarf2_dbgfmt_append_line_op(debug_line, DW_LNS_copy, NULL); - else { - unsigned int opcode; - opcode = DWARF2_LINE_OPCODE_BASE + line_delta - DWARF2_LINE_BASE; - dwarf2_dbgfmt_append_line_op(debug_line, opcode, NULL); - } + /* Need advance_pc */ + dwarf2_dbgfmt_append_line_op(debug_line, DW_LNS_advance_pc, + yasm_intnum_create_uint(addr_delta)); + /* Take care of any remaining line_delta and add entry to matrix */ + if (line_delta == 0) + dwarf2_dbgfmt_append_line_op(debug_line, DW_LNS_copy, NULL); + else { + unsigned int opcode; + opcode = DWARF2_LINE_OPCODE_BASE + line_delta - DWARF2_LINE_BASE; + dwarf2_dbgfmt_append_line_op(debug_line, opcode, NULL); + } } state->precbc = loc->bc; return 0; @@ -484,81 +452,54 @@ typedef struct dwarf2_line_bc_info { unsigned long lastfile; } dwarf2_line_bc_info; -static int -dwarf2_filename_equals(const dwarf2_filename *fn, - char **dirs, - const char *pathname, - unsigned long dirlen, - const char *filename) -{ - /* check directory */ - if (fn->dir == 0) { - if (dirlen != 0) - return 0; - } else { - if (strncmp(dirs[fn->dir-1], pathname, dirlen) != 0 || - dirs[fn->dir-1][dirlen] != '\0') - return 0; - } - - /* check filename */ - return strcmp(fn->filename, filename) == 0; -} - static int dwarf2_generate_line_bc(yasm_bytecode *bc, /*@null@*/ void *d) { dwarf2_line_bc_info *info = (dwarf2_line_bc_info *)d; yasm_dbgfmt_dwarf2 *dbgfmt_dwarf2 = info->dbgfmt_dwarf2; unsigned long i; - size_t dirlen; - const char *pathname, *filename; + const char *filename; /*@null@*/ yasm_bytecode *nextbc = yasm_bc__next(bc); if (nextbc && bc->offset == nextbc->offset) - return 0; + return 0; info->loc.vline = bc->line; info->loc.bc = bc; /* Keep track of last symbol seen */ if (bc->symrecs) { - i = 0; - while (bc->symrecs[i]) { - info->loc.sym = bc->symrecs[i]; - i++; - } + i = 0; + while (bc->symrecs[i]) { + info->loc.sym = bc->symrecs[i]; + i++; + } } - yasm_linemap_lookup(info->linemap, bc->line, &pathname, &info->loc.line); - dirlen = yasm__splitpath(pathname, &filename); - + yasm_linemap_lookup(info->linemap, bc->line, &filename, &info->loc.line); /* Find file index; just linear search it unless it was the last used */ if (info->lastfile > 0 - && dwarf2_filename_equals(&dbgfmt_dwarf2->filenames[info->lastfile-1], - dbgfmt_dwarf2->dirs, pathname, dirlen, - filename)) - info->loc.file = info->lastfile; + && strcmp(filename, dbgfmt_dwarf2->filenames[info->lastfile-1].pathname) + == 0) + info->loc.file = info->lastfile; else { - for (i=0; ifilenames_size; i++) { - if (dwarf2_filename_equals(&dbgfmt_dwarf2->filenames[i], - dbgfmt_dwarf2->dirs, pathname, dirlen, - filename)) - break; - } - if (i >= dbgfmt_dwarf2->filenames_size) - yasm_internal_error(N_("could not find filename in table")); - info->loc.file = i+1; - info->lastfile = i+1; + for (i=0; ifilenames_size; i++) { + if (strcmp(filename, dbgfmt_dwarf2->filenames[i].pathname) == 0) + break; + } + if (i >= dbgfmt_dwarf2->filenames_size) + yasm_internal_error(N_("could not find filename in table")); + info->loc.file = i+1; + info->lastfile = i+1; } if (dwarf2_dbgfmt_gen_line_op(info->debug_line, info->state, &info->loc, - NULL)) - return 1; + NULL)) + return 1; return 0; } typedef struct dwarf2_line_info { - yasm_section *debug_line; /* section to which line number info goes */ + yasm_section *debug_line; /* section to which line number info goes */ yasm_object *object; yasm_linemap *linemap; yasm_dbgfmt_dwarf2 *dbgfmt_dwarf2; @@ -587,13 +528,13 @@ dwarf2_generate_line_section(yasm_section *sect, /*@null@*/ void *d) dsd = yasm_section_get_data(sect, &yasm_dwarf2__section_data_cb); if (!dsd) { - if (info->asm_source && yasm_section_is_code(sect)) { - /* Create line data for asm code sections */ - dsd = yasm_xmalloc(sizeof(dwarf2_section_data)); - STAILQ_INIT(&dsd->locs); - yasm_section_add_data(sect, &yasm_dwarf2__section_data_cb, dsd); - } else - return 0; /* no line data for this section */ + if (info->asm_source && yasm_section_is_code(sect)) { + /* Create line data for asm code sections */ + dsd = yasm_xmalloc(sizeof(dwarf2_section_data)); + STAILQ_INIT(&dsd->locs); + yasm_section_add_data(sect, &yasm_dwarf2__section_data_cb, dsd); + } else + return 0; /* no line data for this section */ } info->num_sections++; @@ -610,47 +551,46 @@ dwarf2_generate_line_section(yasm_section *sect, /*@null@*/ void *d) state.precbc = NULL; if (info->asm_source) { - dwarf2_line_bc_info bcinfo; + dwarf2_line_bc_info bcinfo; - bcinfo.debug_line = info->debug_line; - bcinfo.object = info->object; - bcinfo.linemap = info->linemap; - bcinfo.dbgfmt_dwarf2 = dbgfmt_dwarf2; - bcinfo.state = &state; - bcinfo.lastfile = 0; - bcinfo.loc.isa_change = 0; - bcinfo.loc.column = 0; - bcinfo.loc.discriminator = 0; - bcinfo.loc.is_stmt = IS_STMT_NOCHANGE; - bcinfo.loc.basic_block = 0; - bcinfo.loc.prologue_end = 0; - bcinfo.loc.epilogue_begin = 0; - bcinfo.loc.sym = NULL; + bcinfo.debug_line = info->debug_line; + bcinfo.object = info->object; + bcinfo.linemap = info->linemap; + bcinfo.dbgfmt_dwarf2 = dbgfmt_dwarf2; + bcinfo.state = &state; + bcinfo.lastfile = 0; + bcinfo.loc.isa_change = 0; + bcinfo.loc.column = 0; + bcinfo.loc.is_stmt = IS_STMT_NOCHANGE; + bcinfo.loc.basic_block = 0; + bcinfo.loc.prologue_end = 0; + bcinfo.loc.epilogue_begin = 0; + bcinfo.loc.sym = NULL; - /* bcs_traverse() skips first "dummy" bytecode, so look at it - * separately to determine the initial symrec. - */ - bc = yasm_section_bcs_first(sect); - if (bc->symrecs) { - size_t i = 0; - while (bc->symrecs[i]) { - bcinfo.loc.sym = bc->symrecs[i]; - i++; - } - } + /* bcs_traverse() skips first "dummy" bytecode, so look at it + * separately to determine the initial symrec. + */ + bc = yasm_section_bcs_first(sect); + if (bc->symrecs) { + size_t i = 0; + while (bc->symrecs[i]) { + bcinfo.loc.sym = bc->symrecs[i]; + i++; + } + } - yasm_section_bcs_traverse(sect, info->errwarns, &bcinfo, - dwarf2_generate_line_bc); + yasm_section_bcs_traverse(sect, info->errwarns, &bcinfo, + dwarf2_generate_line_bc); } else { - /*@null@*/ dwarf2_loc *loc; + /*@null@*/ dwarf2_loc *loc; - dwarf2_dbgfmt_finalize_locs(sect, dsd); + dwarf2_dbgfmt_finalize_locs(sect, dsd); - STAILQ_FOREACH(loc, &dsd->locs, link) { - if (dwarf2_dbgfmt_gen_line_op(info->debug_line, &state, loc, - STAILQ_NEXT(loc, link))) - return 1; - } + STAILQ_FOREACH(loc, &dsd->locs, link) { + if (dwarf2_dbgfmt_gen_line_op(info->debug_line, &state, loc, + STAILQ_NEXT(loc, link))) + return 1; + } } /* End sequence: bring address to end of section, then output end @@ -658,17 +598,17 @@ dwarf2_generate_line_section(yasm_section *sect, /*@null@*/ void *d) * want an extra entry in the line matrix. */ if (!state.precbc) - state.precbc = yasm_section_bcs_first(sect); + state.precbc = yasm_section_bcs_first(sect); bc = yasm_section_bcs_last(sect); addr_delta = yasm_bc_next_offset(bc) - state.precbc->offset; if (addr_delta == DWARF2_MAX_SPECIAL_ADDR_DELTA) - dwarf2_dbgfmt_append_line_op(info->debug_line, DW_LNS_const_add_pc, - NULL); + dwarf2_dbgfmt_append_line_op(info->debug_line, DW_LNS_const_add_pc, + NULL); else if (addr_delta > 0) - dwarf2_dbgfmt_append_line_op(info->debug_line, DW_LNS_advance_pc, - yasm_intnum_create_uint(addr_delta)); + dwarf2_dbgfmt_append_line_op(info->debug_line, DW_LNS_advance_pc, + yasm_intnum_create_uint(addr_delta)); dwarf2_dbgfmt_append_line_ext_op(info->debug_line, DW_LNE_end_sequence, 0, - NULL); + NULL); return 0; } @@ -683,22 +623,22 @@ dwarf2_generate_filename(const char *filename, void *d) yasm_section * yasm_dwarf2__generate_line(yasm_object *object, yasm_linemap *linemap, - yasm_errwarns *errwarns, int asm_source, - /*@out@*/ yasm_section **main_code, - /*@out@*/ size_t *num_line_sections) + yasm_errwarns *errwarns, int asm_source, + /*@out@*/ yasm_section **main_code, + /*@out@*/ size_t *num_line_sections) { yasm_dbgfmt_dwarf2 *dbgfmt_dwarf2 = (yasm_dbgfmt_dwarf2 *)object->dbgfmt; dwarf2_line_info info; int new; size_t i; - yasm_bytecode *sppbc; + yasm_bytecode *last, *sppbc; dwarf2_spp *spp; dwarf2_head *head; if (asm_source) { - /* Generate dirs and filenames based on linemap */ - yasm_linemap_traverse_filenames(linemap, dbgfmt_dwarf2, - dwarf2_generate_filename); + /* Generate dirs and filenames based on linemap */ + yasm_linemap_traverse_filenames(linemap, dbgfmt_dwarf2, + dwarf2_generate_filename); } info.num_sections = 0; @@ -707,9 +647,9 @@ yasm_dwarf2__generate_line(yasm_object *object, yasm_linemap *linemap, info.object = object; info.linemap = linemap; info.dbgfmt_dwarf2 = dbgfmt_dwarf2; - info.debug_line = yasm_object_get_general(object, ".debug_line", 1, 0, 0, - &new, 0); - info.errwarns = errwarns; + info.debug_line = yasm_object_get_general(object, ".debug_line", 0, 1, 0, + 0, &new, 0); + last = yasm_section_bcs_last(info.debug_line); /* header */ head = yasm_dwarf2__add_head(dbgfmt_dwarf2, info.debug_line, NULL, 0, 0); @@ -718,40 +658,40 @@ yasm_dwarf2__generate_line(yasm_object *object, yasm_linemap *linemap, spp = yasm_xmalloc(sizeof(dwarf2_spp)); sppbc = yasm_bc_create_common(&dwarf2_spp_bc_callback, spp, 0); sppbc->len = dbgfmt_dwarf2->sizeof_offset + 5 + - NELEMS(line_opcode_num_operands); + NELEMS(line_opcode_num_operands); /* directory list */ for (i=0; idirs_size; i++) - sppbc->len += (unsigned long)strlen(dbgfmt_dwarf2->dirs[i])+1; + sppbc->len += (unsigned long)strlen(dbgfmt_dwarf2->dirs[i])+1; sppbc->len++; /* filename list */ for (i=0; ifilenames_size; i++) { - if (!dbgfmt_dwarf2->filenames[i].filename) { - yasm_error_set(YASM_ERROR_GENERAL, - N_("dwarf2 file number %d unassigned"), i+1); - yasm_errwarn_propagate(errwarns, 0); - continue; - } - sppbc->len += - (unsigned long)strlen(dbgfmt_dwarf2->filenames[i].filename) + 1 + - yasm_size_uleb128(dbgfmt_dwarf2->filenames[i].dir) + 2; + if (!dbgfmt_dwarf2->filenames[i].filename) { + yasm_error_set(YASM_ERROR_GENERAL, + N_("dwarf2 file number %d unassigned"), i+1); + yasm_errwarn_propagate(errwarns, 0); + continue; + } + sppbc->len += + (unsigned long)strlen(dbgfmt_dwarf2->filenames[i].filename) + 1 + + yasm_size_uleb128(dbgfmt_dwarf2->filenames[i].dir) + 2; } sppbc->len++; yasm_dwarf2__append_bc(info.debug_line, sppbc); /* statement program */ yasm_object_sections_traverse(object, (void *)&info, - dwarf2_generate_line_section); + dwarf2_generate_line_section); /* mark end of line information */ yasm_dwarf2__set_head_end(head, yasm_section_bcs_last(info.debug_line)); *num_line_sections = info.num_sections; if (info.num_sections == 1) - *main_code = info.last_code; + *main_code = info.last_code; else - *main_code = NULL; + *main_code = NULL; return info.debug_line; } @@ -769,7 +709,7 @@ dwarf2_spp_bc_print(const void *contents, FILE *f, int indent_level) static int dwarf2_spp_bc_calc_len(yasm_bytecode *bc, yasm_bc_add_span_func add_span, - void *add_span_data) + void *add_span_data) { yasm_internal_error(N_("tried to calc_len a dwarf2 spp bytecode")); /*@notreached@*/ @@ -777,10 +717,9 @@ dwarf2_spp_bc_calc_len(yasm_bytecode *bc, yasm_bc_add_span_func add_span, } static int -dwarf2_spp_bc_tobytes(yasm_bytecode *bc, unsigned char **bufp, - unsigned char *bufstart, void *d, - yasm_output_value_func output_value, - yasm_output_reloc_func output_reloc) +dwarf2_spp_bc_tobytes(yasm_bytecode *bc, unsigned char **bufp, void *d, + yasm_output_value_func output_value, + yasm_output_reloc_func output_reloc) { yasm_object *object = yasm_section_get_object(bc->section); yasm_dbgfmt_dwarf2 *dbgfmt_dwarf2 = (yasm_dbgfmt_dwarf2 *)object->dbgfmt; @@ -790,41 +729,41 @@ dwarf2_spp_bc_tobytes(yasm_bytecode *bc, unsigned char **bufp, /* Prologue length (following this field) */ cval = yasm_intnum_create_uint(bc->len - (unsigned long)(buf-*bufp) - - dbgfmt_dwarf2->sizeof_offset); + dbgfmt_dwarf2->sizeof_offset); yasm_arch_intnum_tobytes(object->arch, cval, buf, - dbgfmt_dwarf2->sizeof_offset, - dbgfmt_dwarf2->sizeof_offset*8, 0, bc, 0); + dbgfmt_dwarf2->sizeof_offset, + dbgfmt_dwarf2->sizeof_offset*8, 0, bc, 0); buf += dbgfmt_dwarf2->sizeof_offset; - YASM_WRITE_8(buf, dbgfmt_dwarf2->min_insn_len); /* minimum_instr_len */ - YASM_WRITE_8(buf, DWARF2_LINE_DEFAULT_IS_STMT); /* default_is_stmt */ - YASM_WRITE_8(buf, DWARF2_LINE_BASE); /* line_base */ - YASM_WRITE_8(buf, DWARF2_LINE_RANGE); /* line_range */ - YASM_WRITE_8(buf, DWARF2_LINE_OPCODE_BASE); /* opcode_base */ + YASM_WRITE_8(buf, dbgfmt_dwarf2->min_insn_len); /* minimum_instr_len */ + YASM_WRITE_8(buf, DWARF2_LINE_DEFAULT_IS_STMT); /* default_is_stmt */ + YASM_WRITE_8(buf, DWARF2_LINE_BASE); /* line_base */ + YASM_WRITE_8(buf, DWARF2_LINE_RANGE); /* line_range */ + YASM_WRITE_8(buf, DWARF2_LINE_OPCODE_BASE); /* opcode_base */ /* Standard opcode # operands array */ for (i=0; idirs_size; i++) { - len = strlen(dbgfmt_dwarf2->dirs[i])+1; - memcpy(buf, dbgfmt_dwarf2->dirs[i], len); - buf += len; + len = strlen(dbgfmt_dwarf2->dirs[i])+1; + memcpy(buf, dbgfmt_dwarf2->dirs[i], len); + buf += len; } /* finish with single 0 byte */ YASM_WRITE_8(buf, 0); /* filename list */ for (i=0; ifilenames_size; i++) { - len = strlen(dbgfmt_dwarf2->filenames[i].filename)+1; - memcpy(buf, dbgfmt_dwarf2->filenames[i].filename, len); - buf += len; + len = strlen(dbgfmt_dwarf2->filenames[i].filename)+1; + memcpy(buf, dbgfmt_dwarf2->filenames[i].filename, len); + buf += len; - /* dir */ - buf += yasm_get_uleb128(dbgfmt_dwarf2->filenames[i].dir, buf); - YASM_WRITE_8(buf, 0); /* time */ - YASM_WRITE_8(buf, 0); /* length */ + /* dir */ + buf += yasm_get_uleb128(dbgfmt_dwarf2->filenames[i].dir, buf); + YASM_WRITE_8(buf, 0); /* time */ + YASM_WRITE_8(buf, 0); /* length */ } /* finish with single 0 byte */ YASM_WRITE_8(buf, 0); @@ -840,9 +779,7 @@ dwarf2_line_op_bc_destroy(void *contents) { dwarf2_line_op *line_op = (dwarf2_line_op *)contents; if (line_op->operand) - yasm_intnum_destroy(line_op->operand); - if (line_op->ext_operand_int) - yasm_intnum_destroy(line_op->ext_operand_int); + yasm_intnum_destroy(line_op->operand); yasm_xfree(contents); } @@ -854,7 +791,7 @@ dwarf2_line_op_bc_print(const void *contents, FILE *f, int indent_level) static int dwarf2_line_op_bc_calc_len(yasm_bytecode *bc, yasm_bc_add_span_func add_span, - void *add_span_data) + void *add_span_data) { yasm_internal_error(N_("tried to calc_len a dwarf2 line_op bytecode")); /*@notreached@*/ @@ -862,31 +799,27 @@ dwarf2_line_op_bc_calc_len(yasm_bytecode *bc, yasm_bc_add_span_func add_span, } static int -dwarf2_line_op_bc_tobytes(yasm_bytecode *bc, unsigned char **bufp, - unsigned char *bufstart, void *d, - yasm_output_value_func output_value, - yasm_output_reloc_func output_reloc) +dwarf2_line_op_bc_tobytes(yasm_bytecode *bc, unsigned char **bufp, void *d, + yasm_output_value_func output_value, + yasm_output_reloc_func output_reloc) { dwarf2_line_op *line_op = (dwarf2_line_op *)bc->contents; unsigned char *buf = *bufp; YASM_WRITE_8(buf, line_op->opcode); if (line_op->operand) - buf += yasm_intnum_get_leb128(line_op->operand, buf, - line_op->opcode == DW_LNS_advance_line); + buf += yasm_intnum_get_leb128(line_op->operand, buf, + line_op->opcode == DW_LNS_advance_line); if (line_op->ext_opcode > 0) { - YASM_WRITE_8(buf, line_op->ext_opcode); - if (line_op->ext_operand) { - yasm_value value; - yasm_value_init_sym(&value, line_op->ext_operand, - line_op->ext_operandsize*8); - output_value(&value, buf, line_op->ext_operandsize, - (unsigned long)(buf-bufstart), bc, 0, d); - buf += line_op->ext_operandsize; - } - if (line_op->ext_operand_int) { - buf += yasm_intnum_get_leb128(line_op->ext_operand_int, buf, 0); - } + YASM_WRITE_8(buf, line_op->ext_opcode); + if (line_op->ext_operand) { + yasm_value value; + yasm_value_init_sym(&value, line_op->ext_operand, + line_op->ext_operandsize*8); + output_value(&value, buf, line_op->ext_operandsize, + (unsigned long)(buf-*bufp), bc, 0, d); + buf += line_op->ext_operandsize; + } } *bufp = buf; @@ -895,10 +828,10 @@ dwarf2_line_op_bc_tobytes(yasm_bytecode *bc, unsigned char **bufp, void yasm_dwarf2__dir_loc(yasm_object *object, yasm_valparamhead *valparams, - yasm_valparamhead *objext_valparams, unsigned long line) + yasm_valparamhead *objext_valparams, unsigned long line) { yasm_valparam *vp; - int in_is_stmt = 0, in_isa = 0, in_discriminator = 0; + int in_is_stmt = 0, in_isa = 0; /*@dependent@*/ /*@null@*/ const yasm_intnum *intn; dwarf2_section_data *dsd; @@ -907,37 +840,37 @@ yasm_dwarf2__dir_loc(yasm_object *object, yasm_valparamhead *valparams, /* File number (required) */ if (!valparams || !(vp = yasm_vps_first(valparams)) || vp->val || vp->type != YASM_PARAM_EXPR) { - yasm_error_set(YASM_ERROR_SYNTAX, N_("file number required")); - yasm_xfree(loc); - return; + yasm_error_set(YASM_ERROR_SYNTAX, N_("file number required")); + yasm_xfree(loc); + return; } intn = yasm_expr_get_intnum(&vp->param.e, 0); if (!intn) { - yasm_error_set(YASM_ERROR_NOT_CONSTANT, - N_("file number is not a constant")); - yasm_xfree(loc); - return; + yasm_error_set(YASM_ERROR_NOT_CONSTANT, + N_("file number is not a constant")); + yasm_xfree(loc); + return; } if (yasm_intnum_sign(intn) != 1) { - yasm_error_set(YASM_ERROR_VALUE, N_("file number less than one")); - yasm_xfree(loc); - return; + yasm_error_set(YASM_ERROR_VALUE, N_("file number less than one")); + yasm_xfree(loc); + return; } loc->file = yasm_intnum_get_uint(intn); /* Line number (required) */ vp = yasm_vps_next(vp); if (!vp || vp->val || vp->type != YASM_PARAM_EXPR) { - yasm_error_set(YASM_ERROR_SYNTAX, N_("line number required")); - yasm_xfree(loc); - return; + yasm_error_set(YASM_ERROR_SYNTAX, N_("line number required")); + yasm_xfree(loc); + return; } intn = yasm_expr_get_intnum(&vp->param.e, 0); if (!intn) { - yasm_error_set(YASM_ERROR_NOT_CONSTANT, + yasm_error_set(YASM_ERROR_NOT_CONSTANT, N_("line number is not a constant")); - yasm_xfree(loc); - return; + yasm_xfree(loc); + return; } loc->line = yasm_intnum_get_uint(intn); @@ -949,17 +882,16 @@ yasm_dwarf2__dir_loc(yasm_object *object, yasm_valparamhead *valparams, return; } dsd = yasm_section_get_data(object->cur_section, - &yasm_dwarf2__section_data_cb); + &yasm_dwarf2__section_data_cb); if (!dsd) { - dsd = yasm_xmalloc(sizeof(dwarf2_section_data)); - STAILQ_INIT(&dsd->locs); - yasm_section_add_data(object->cur_section, - &yasm_dwarf2__section_data_cb, dsd); + dsd = yasm_xmalloc(sizeof(dwarf2_section_data)); + STAILQ_INIT(&dsd->locs); + yasm_section_add_data(object->cur_section, + &yasm_dwarf2__section_data_cb, dsd); } /* Defaults for optional settings */ loc->column = 0; - loc->discriminator = 0; loc->isa_change = 0; loc->isa = 0; loc->is_stmt = IS_STMT_NOCHANGE; @@ -971,14 +903,14 @@ yasm_dwarf2__dir_loc(yasm_object *object, yasm_valparamhead *valparams, vp = yasm_vps_next(vp); if (vp && !vp->val && vp->type == YASM_PARAM_EXPR) { intn = yasm_expr_get_intnum(&vp->param.e, 0); - if (!intn) { - yasm_error_set(YASM_ERROR_NOT_CONSTANT, - N_("column number is not a constant")); - yasm_xfree(loc); - return; - } - loc->column = yasm_intnum_get_uint(intn); - vp = yasm_vps_next(vp); + if (!intn) { + yasm_error_set(YASM_ERROR_NOT_CONSTANT, + N_("column number is not a constant")); + yasm_xfree(loc); + return; + } + loc->column = yasm_intnum_get_uint(intn); + vp = yasm_vps_next(vp); } /* Other options; note for GAS compatibility we need to support both: @@ -994,73 +926,51 @@ restart: in_is_stmt = 0; if (!(e = yasm_vp_expr(vp, object->symtab, line)) || !(intn = yasm_expr_get_intnum(&e, 0))) { - yasm_error_set(YASM_ERROR_NOT_CONSTANT, - N_("is_stmt value is not a constant")); - yasm_xfree(loc); + yasm_error_set(YASM_ERROR_NOT_CONSTANT, + N_("is_stmt value is not a constant")); + yasm_xfree(loc); if (e) yasm_expr_destroy(e); - return; - } - if (yasm_intnum_is_zero(intn)) - loc->is_stmt = IS_STMT_SET; - else if (yasm_intnum_is_pos1(intn)) - loc->is_stmt = IS_STMT_CLEAR; - else { - yasm_error_set(YASM_ERROR_VALUE, - N_("is_stmt value not 0 or 1")); - yasm_xfree(loc); + return; + } + if (yasm_intnum_is_zero(intn)) + loc->is_stmt = IS_STMT_SET; + else if (yasm_intnum_is_pos1(intn)) + loc->is_stmt = IS_STMT_CLEAR; + else { + yasm_error_set(YASM_ERROR_VALUE, + N_("is_stmt value not 0 or 1")); + yasm_xfree(loc); yasm_expr_destroy(e); - return; - } + return; + } yasm_expr_destroy(e); } else if (in_isa) { in_isa = 0; if (!(e = yasm_vp_expr(vp, object->symtab, line)) || !(intn = yasm_expr_get_intnum(&e, 0))) { - yasm_error_set(YASM_ERROR_NOT_CONSTANT, - N_("isa value is not a constant")); - yasm_xfree(loc); + yasm_error_set(YASM_ERROR_NOT_CONSTANT, + N_("isa value is not a constant")); + yasm_xfree(loc); if (e) yasm_expr_destroy(e); - return; - } - if (yasm_intnum_sign(intn) < 0) { - yasm_error_set(YASM_ERROR_VALUE, - N_("isa value less than zero")); - yasm_xfree(loc); + return; + } + if (yasm_intnum_sign(intn) < 0) { + yasm_error_set(YASM_ERROR_VALUE, + N_("isa value less than zero")); + yasm_xfree(loc); yasm_expr_destroy(e); - return; - } - loc->isa_change = 1; - loc->isa = yasm_intnum_get_uint(intn); - yasm_expr_destroy(e); - } else if (in_discriminator) { - in_discriminator = 0; - if (!(e = yasm_vp_expr(vp, object->symtab, line)) || - !(intn = yasm_expr_get_intnum(&e, 0))) { - yasm_error_set(YASM_ERROR_NOT_CONSTANT, - N_("discriminator value is not a constant")); - yasm_xfree(loc); - if (e) - yasm_expr_destroy(e); - return; - } - if (yasm_intnum_sign(intn) < 0) { - yasm_error_set(YASM_ERROR_VALUE, - N_("discriminator value less than zero")); - yasm_xfree(loc); - yasm_expr_destroy(e); - return; - } - loc->discriminator = yasm_intnum_get_uint(intn); + return; + } + loc->isa_change = 1; + loc->isa = yasm_intnum_get_uint(intn); yasm_expr_destroy(e); } else if (!vp->val && (s = yasm_vp_id(vp))) { if (yasm__strcasecmp(s, "is_stmt") == 0) in_is_stmt = 1; else if (yasm__strcasecmp(s, "isa") == 0) in_isa = 1; - else if (yasm__strcasecmp(s, "discriminator") == 0) - in_discriminator = 1; else if (yasm__strcasecmp(s, "basic_block") == 0) loc->basic_block = 1; else if (yasm__strcasecmp(s, "prologue_end") == 0) @@ -1079,19 +989,15 @@ restart: } else if (yasm__strcasecmp(vp->val, "isa") == 0) { in_isa = 1; goto restart; /* don't go to the next valparam */ - } else if (yasm__strcasecmp(vp->val, "discriminator") == 0) { - in_discriminator = 1; - goto restart; /* don't go to the next valparam */ - } else - yasm_warn_set(YASM_WARN_GENERAL, - N_("unrecognized loc option `%s'"), vp->val); + } else + yasm_warn_set(YASM_WARN_GENERAL, + N_("unrecognized loc option `%s'"), vp->val); vp = yasm_vps_next(vp); } - if (in_is_stmt || in_isa || in_discriminator) { + if (in_is_stmt || in_isa) { yasm_error_set(YASM_ERROR_SYNTAX, N_("%s requires value"), - in_is_stmt ? "is_stmt" : - (in_isa ? "isa" : "discriminator")); + in_is_stmt ? "is_stmt" : "isa"); yasm_xfree(loc); return; } @@ -1105,7 +1011,7 @@ restart: void yasm_dwarf2__dir_file(yasm_object *object, yasm_valparamhead *valparams, - yasm_valparamhead *objext_valparams, unsigned long line) + yasm_valparamhead *objext_valparams, unsigned long line) { yasm_dbgfmt_dwarf2 *dbgfmt_dwarf2 = (yasm_dbgfmt_dwarf2 *)object->dbgfmt; yasm_valparam *vp; @@ -1113,32 +1019,32 @@ yasm_dwarf2__dir_file(yasm_object *object, yasm_valparamhead *valparams, unsigned long filenum; if (!valparams) { - yasm_error_set(YASM_ERROR_SYNTAX, N_("[%s] requires an argument"), - "FILE"); - return; + yasm_error_set(YASM_ERROR_SYNTAX, N_("[%s] requires an argument"), + "FILE"); + return; } vp = yasm_vps_first(valparams); if (yasm_vp_string(vp)) { - /* Just a bare filename */ + /* Just a bare filename */ yasm_object_set_source_fn(object, yasm_vp_string(vp)); - return; + return; } /* Otherwise.. first vp is the file number */ if (vp->type != YASM_PARAM_EXPR || !(file_intn = yasm_expr_get_intnum(&vp->param.e, 0))) { - yasm_error_set(YASM_ERROR_NOT_CONSTANT, - N_("file number is not a constant")); - return; + yasm_error_set(YASM_ERROR_NOT_CONSTANT, + N_("file number is not a constant")); + return; } filenum = yasm_intnum_get_uint(file_intn); vp = yasm_vps_next(vp); if (!yasm_vp_string(vp)) { - yasm_error_set(YASM_ERROR_SYNTAX, - N_("file number given but no filename")); - return; + yasm_error_set(YASM_ERROR_SYNTAX, + N_("file number given but no filename")); + return; } dwarf2_dbgfmt_add_file(dbgfmt_dwarf2, filenum, yasm_vp_string(vp)); diff --git a/modules/dbgfmts/dwarf2/tests/Makefile.inc b/modules/dbgfmts/dwarf2/tests/Makefile.inc index e1dc1d4e..1136e288 100644 --- a/modules/dbgfmts/dwarf2/tests/Makefile.inc +++ b/modules/dbgfmts/dwarf2/tests/Makefile.inc @@ -1,8 +1,8 @@ -EXTRA_DIST += modules/dbgfmts/dwarf2/tests/gen64/Makefile.inc +# $Id$ + EXTRA_DIST += modules/dbgfmts/dwarf2/tests/pass32/Makefile.inc EXTRA_DIST += modules/dbgfmts/dwarf2/tests/pass64/Makefile.inc EXTRA_DIST += modules/dbgfmts/dwarf2/tests/passwin64/Makefile.inc -include modules/dbgfmts/dwarf2/tests/gen64/Makefile.inc include modules/dbgfmts/dwarf2/tests/pass32/Makefile.inc include modules/dbgfmts/dwarf2/tests/pass64/Makefile.inc include modules/dbgfmts/dwarf2/tests/passwin64/Makefile.inc diff --git a/modules/dbgfmts/dwarf2/tests/gen64/Makefile.inc b/modules/dbgfmts/dwarf2/tests/gen64/Makefile.inc deleted file mode 100644 index 88ca78c6..00000000 --- a/modules/dbgfmts/dwarf2/tests/gen64/Makefile.inc +++ /dev/null @@ -1,6 +0,0 @@ -TESTS += modules/dbgfmts/dwarf2/tests/gen64/dwarf2_gen64_test.sh - -EXTRA_DIST += modules/dbgfmts/dwarf2/tests/gen64/dwarf2_gen64_test.sh -EXTRA_DIST += modules/dbgfmts/dwarf2/tests/gen64/dwarf64_pathname.asm -EXTRA_DIST += modules/dbgfmts/dwarf2/tests/gen64/dwarf64_pathname.hex - diff --git a/modules/dbgfmts/dwarf2/tests/gen64/dwarf2_gen64_test.sh b/modules/dbgfmts/dwarf2/tests/gen64/dwarf2_gen64_test.sh deleted file mode 100755 index dae5f429..00000000 --- a/modules/dbgfmts/dwarf2/tests/gen64/dwarf2_gen64_test.sh +++ /dev/null @@ -1,3 +0,0 @@ -#! /bin/sh -${srcdir}/out_test.sh dwarf2_gen64_test modules/dbgfmts/dwarf2/tests/gen64 "dwarf2 dbgfmt gen64" "-f elf64 -g dwarf2" ".o" -exit $? diff --git a/modules/dbgfmts/dwarf2/tests/gen64/dwarf64_pathname.asm b/modules/dbgfmts/dwarf2/tests/gen64/dwarf64_pathname.asm deleted file mode 100644 index a216f9bd..00000000 --- a/modules/dbgfmts/dwarf2/tests/gen64/dwarf64_pathname.asm +++ /dev/null @@ -1,22 +0,0 @@ -[bits 64] -[section .text] -[default rel] - -%line 1+0 ./some_filename -; program tst_wyjatki -global _start -_start: - XOR EBP, EBP - CALL main - XOR RAX, RAX - MOV RDI, RAX - MOV RAX, 60 - SYSCALL - HLT - -main: - PUSH rbp - MOV rbp, rsp - SUB RSP, 0x20 - %line 2+0 some_filename - SUB RSP, 64 diff --git a/modules/dbgfmts/dwarf2/tests/gen64/dwarf64_pathname.hex b/modules/dbgfmts/dwarf2/tests/gen64/dwarf64_pathname.hex deleted file mode 100644 index c67b19de..00000000 --- a/modules/dbgfmts/dwarf2/tests/gen64/dwarf64_pathname.hex +++ /dev/null @@ -1,1632 +0,0 @@ -7f -45 -4c -46 -02 -01 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -01 -00 -3e -00 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -60 -03 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -40 -00 -00 -00 -00 -00 -40 -00 -0c -00 -01 -00 -31 -ed -e8 -10 -00 -00 -00 -48 -31 -c0 -48 -89 -c7 -48 -c7 -c0 -3c -00 -00 -00 -0f -05 -f4 -55 -48 -89 -e5 -48 -83 -ec -20 -48 -83 -ec -40 -4c -00 -00 -00 -02 -00 -29 -00 -00 -00 -01 -01 -fb -0e -0d -00 -01 -01 -01 -01 -00 -00 -00 -01 -00 -00 -01 -00 -2d -00 -00 -00 -00 -73 -6f -6d -65 -5f -66 -69 -6c -65 -6e -61 -6d -65 -00 -00 -00 -00 -00 -04 -02 -00 -09 -02 -00 -00 -00 -00 -00 -00 -00 -00 -01 -2e -58 -3c -3c -74 -2e -20 -20 -3c -4b -02 -04 -00 -01 -01 -00 -38 -00 -00 -00 -00 -00 -00 -00 -01 -00 -00 -00 -08 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -01 -11 -00 -10 -06 -11 -01 -12 -01 -03 -08 -1b -08 -25 -08 -13 -05 -00 -00 -00 -2d -00 -00 -00 -02 -00 -00 -00 -00 -00 -08 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -2d -00 -2e -2f -00 -79 -61 -73 -6d -20 -48 -45 -41 -44 -00 -01 -80 -00 -00 -00 -06 -00 -00 -00 -00 -00 -00 -00 -0a -00 -00 -00 -04 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -0c -00 -00 -00 -00 -00 -00 -00 -0a -00 -00 -00 -05 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -10 -00 -00 -00 -00 -00 -00 -00 -01 -00 -00 -00 -07 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -18 -00 -00 -00 -00 -00 -00 -00 -01 -00 -00 -00 -07 -00 -00 -00 -23 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -2c -00 -00 -00 -02 -00 -00 -00 -00 -00 -08 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -23 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -06 -00 -00 -00 -00 -00 -00 -00 -0a -00 -00 -00 -03 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -10 -00 -00 -00 -00 -00 -00 -00 -01 -00 -00 -00 -07 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -2e -74 -65 -78 -74 -00 -2e -64 -65 -62 -75 -67 -5f -6c -69 -6e -65 -00 -2e -64 -65 -62 -75 -67 -5f -61 -62 -62 -72 -65 -76 -00 -2e -64 -65 -62 -75 -67 -5f -69 -6e -66 -6f -00 -2e -64 -65 -62 -75 -67 -5f -61 -72 -61 -6e -67 -65 -73 -00 -2e -72 -65 -6c -61 -2e -64 -65 -62 -75 -67 -5f -6c -69 -6e -65 -00 -2e -72 -65 -6c -61 -2e -64 -65 -62 -75 -67 -5f -69 -6e -66 -6f -00 -2e -72 -65 -6c -61 -2e -64 -65 -62 -75 -67 -5f -61 -72 -61 -6e -67 -65 -73 -00 -2e -73 -74 -72 -74 -61 -62 -00 -2e -73 -79 -6d -74 -61 -62 -00 -2e -73 -68 -73 -74 -72 -74 -61 -62 -00 -00 -2d -00 -5f -73 -74 -61 -72 -74 -00 -6d -61 -69 -6e -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -01 -00 -00 -00 -04 -00 -f1 -ff -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -03 -00 -0a -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -03 -00 -08 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -03 -00 -07 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -03 -00 -05 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -0a -00 -00 -00 -00 -00 -04 -00 -17 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -03 -00 -04 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -03 -00 -00 -00 -10 -00 -04 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -82 -00 -00 -00 -03 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -e0 -01 -00 -00 -00 -00 -00 -00 -8c -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -72 -00 -00 -00 -03 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -6c -02 -00 -00 -00 -00 -00 -00 -0f -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -7a -00 -00 -00 -02 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -7c -02 -00 -00 -00 -00 -00 -00 -d8 -00 -00 -00 -00 -00 -00 -00 -02 -00 -00 -00 -08 -00 -00 -00 -08 -00 -00 -00 -00 -00 -00 -00 -18 -00 -00 -00 -00 -00 -00 -00 -01 -00 -00 -00 -01 -00 -00 -00 -06 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -40 -00 -00 -00 -00 -00 -00 -00 -23 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -10 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -07 -00 -00 -00 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -63 -00 -00 -00 -00 -00 -00 -00 -50 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -3c -00 -00 -00 -04 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -b4 -00 -00 -00 -00 -00 -00 -00 -18 -00 -00 -00 -00 -00 -00 -00 -03 -00 -00 -00 -05 -00 -00 -00 -08 -00 -00 -00 -00 -00 -00 -00 -18 -00 -00 -00 -00 -00 -00 -00 -13 -00 -00 -00 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -cc -00 -00 -00 -00 -00 -00 -00 -14 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -21 -00 -00 -00 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -e0 -00 -00 -00 -00 -00 -00 -00 -31 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -4d -00 -00 -00 -04 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -14 -01 -00 -00 -00 -00 -00 -00 -60 -00 -00 -00 -00 -00 -00 -00 -03 -00 -00 -00 -08 -00 -00 -00 -08 -00 -00 -00 -00 -00 -00 -00 -18 -00 -00 -00 -00 -00 -00 -00 -2d -00 -00 -00 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -80 -01 -00 -00 -00 -00 -00 -00 -30 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -10 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -5e -00 -00 -00 -04 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -b0 -01 -00 -00 -00 -00 -00 -00 -30 -00 -00 -00 -00 -00 -00 -00 -03 -00 -00 -00 -0a -00 -00 -00 -08 -00 -00 -00 -00 -00 -00 -00 -18 -00 -00 -00 -00 -00 -00 -00 diff --git a/modules/dbgfmts/dwarf2/tests/pass32/Makefile.inc b/modules/dbgfmts/dwarf2/tests/pass32/Makefile.inc index be69cbf8..4c3fabc9 100644 --- a/modules/dbgfmts/dwarf2/tests/pass32/Makefile.inc +++ b/modules/dbgfmts/dwarf2/tests/pass32/Makefile.inc @@ -1,3 +1,5 @@ +# $Id$ + TESTS += modules/dbgfmts/dwarf2/tests/pass32/dwarf2_pass32_test.sh EXTRA_DIST += modules/dbgfmts/dwarf2/tests/pass32/dwarf2_pass32_test.sh diff --git a/modules/dbgfmts/dwarf2/tests/pass32/dwarf2_pass32_test.sh b/modules/dbgfmts/dwarf2/tests/pass32/dwarf2_pass32_test.sh index 8b159a37..ba89b781 100755 --- a/modules/dbgfmts/dwarf2/tests/pass32/dwarf2_pass32_test.sh +++ b/modules/dbgfmts/dwarf2/tests/pass32/dwarf2_pass32_test.sh @@ -1,3 +1,4 @@ #! /bin/sh +# $Id$ ${srcdir}/out_test.sh dwarf2_pass32_test modules/dbgfmts/dwarf2/tests/pass32 "dwarf2 dbgfmt pass32" "-f elf -p gas -g dwarf2" ".o" exit $? diff --git a/modules/dbgfmts/dwarf2/tests/pass32/dwarf32-err.errwarn b/modules/dbgfmts/dwarf2/tests/pass32/dwarf32-err.errwarn index 9c333565..d22fdf91 100644 --- a/modules/dbgfmts/dwarf2/tests/pass32/dwarf32-err.errwarn +++ b/modules/dbgfmts/dwarf2/tests/pass32/dwarf32-err.errwarn @@ -1,22 +1,22 @@ --:1: error: directive `.loc' requires an argument --:2: error: file number required --:3: error: file number required --:4: error: file number less than one --:6: error: line number required --:7: error: line number required --:8: error: line number required --:11: error: line number required +-:1: directive `.loc' requires an argument +-:2: file number required +-:3: file number required +-:4: file number less than one +-:6: line number required +-:7: line number required +-:8: line number required +-:11: line number required -:12: warning: unrecognized numeric qualifier --:13: error: column number is not a constant --:14: error: is_stmt requires value --:17: error: is_stmt value is not a constant --:19: error: is_stmt value is not a constant --:20: error: is_stmt value is not a constant --:22: error: is_stmt value not 0 or 1 --:23: error: isa requires value --:26: error: isa value is not a constant --:28: error: isa value is not a constant --:30: error: isa value less than zero --:31: error: column number is not a constant +-:13: column number is not a constant +-:14: is_stmt requires value +-:17: is_stmt value is not a constant +-:19: is_stmt value is not a constant +-:20: is_stmt value is not a constant +-:22: is_stmt value not 0 or 1 +-:23: isa requires value +-:26: isa value is not a constant +-:28: isa value is not a constant +-:30: isa value less than zero +-:31: column number is not a constant -:33: warning: unrecognized loc option `foo' -:33: warning: unrecognized numeric qualifier diff --git a/modules/dbgfmts/dwarf2/tests/pass32/dwarf32_testhd.hex b/modules/dbgfmts/dwarf2/tests/pass32/dwarf32_testhd.hex index 7cfddd03..e73e882a 100644 --- a/modules/dbgfmts/dwarf2/tests/pass32/dwarf32_testhd.hex +++ b/modules/dbgfmts/dwarf2/tests/pass32/dwarf32_testhd.hex @@ -168,8 +168,8 @@ b8 00 eb 72 -66 -90 +89 +f6 83 ec 08 @@ -280,8 +280,8 @@ b8 00 00 00 -66 -90 +89 +f6 8d 65 f8 diff --git a/modules/dbgfmts/dwarf2/tests/pass64/Makefile.inc b/modules/dbgfmts/dwarf2/tests/pass64/Makefile.inc index e9760145..2ca475d5 100644 --- a/modules/dbgfmts/dwarf2/tests/pass64/Makefile.inc +++ b/modules/dbgfmts/dwarf2/tests/pass64/Makefile.inc @@ -1,3 +1,5 @@ +# $Id$ + TESTS += modules/dbgfmts/dwarf2/tests/pass64/dwarf2_pass64_test.sh EXTRA_DIST += modules/dbgfmts/dwarf2/tests/pass64/dwarf2_pass64_test.sh diff --git a/modules/dbgfmts/dwarf2/tests/pass64/dwarf2_pass64_test.sh b/modules/dbgfmts/dwarf2/tests/pass64/dwarf2_pass64_test.sh index a377327c..f4dddfe8 100755 --- a/modules/dbgfmts/dwarf2/tests/pass64/dwarf2_pass64_test.sh +++ b/modules/dbgfmts/dwarf2/tests/pass64/dwarf2_pass64_test.sh @@ -1,3 +1,4 @@ #! /bin/sh +# $Id$ ${srcdir}/out_test.sh dwarf2_pass64_test modules/dbgfmts/dwarf2/tests/pass64 "dwarf2 dbgfmt pass64" "-f elf64 -p gas -g dwarf2" ".o" exit $? diff --git a/modules/dbgfmts/dwarf2/tests/pass64/dwarf64_leb128.hex b/modules/dbgfmts/dwarf2/tests/pass64/dwarf64_leb128.hex index 2af91504..af09833c 100644 --- a/modules/dbgfmts/dwarf2/tests/pass64/dwarf64_leb128.hex +++ b/modules/dbgfmts/dwarf2/tests/pass64/dwarf64_leb128.hex @@ -183,13 +183,13 @@ e8 c4 08 c3 -0f -1f -80 -00 -00 -00 -00 +66 +66 +66 +90 +66 +66 +90 48 83 ec @@ -410,10 +410,10 @@ e8 c4 18 c3 -0f -1f -40 -00 +66 +66 +66 +90 48 8b 3d @@ -459,9 +459,9 @@ e8 c4 18 c3 -0f -1f -00 +66 +66 +90 ba 00 00 @@ -485,15 +485,15 @@ ff ff ff 66 -2e -0f -1f -84 -00 -00 -00 -00 -00 +66 +66 +90 +66 +66 +90 +66 +66 +90 48 89 6c @@ -682,10 +682,10 @@ d8 c4 18 c3 -0f -1f -40 -00 +66 +66 +66 +90 ba 00 00 @@ -709,15 +709,15 @@ ff ff ff 66 -2e -0f -1f -84 -00 -00 -00 -00 -00 +66 +66 +90 +66 +66 +90 +66 +66 +90 48 89 6c @@ -933,15 +933,15 @@ ff ff ff 66 -2e -0f -1f -84 -00 -00 -00 -00 -00 +66 +66 +90 +66 +66 +90 +66 +66 +90 48 89 6c @@ -1157,15 +1157,15 @@ ff ff ff 66 -2e -0f -1f -84 -00 -00 -00 -00 -00 +66 +66 +90 +66 +66 +90 +66 +66 +90 48 89 5c @@ -1371,9 +1371,9 @@ e8 c4 28 c3 -0f -1f -00 +66 +66 +90 4d 85 e4 @@ -1450,10 +1450,10 @@ ff 23 31 db -0f -1f -40 -00 +66 +66 +66 +90 48 8b 3d @@ -1557,15 +1557,15 @@ ff ff 66 66 -2e -0f -1f -84 -00 -00 -00 -00 -00 +66 +90 +66 +66 +66 +90 +66 +66 +90 53 48 89 @@ -1610,10 +1610,10 @@ fb 5b eb d4 -0f -1f -40 -00 +66 +66 +66 +90 48 8b 3d @@ -1714,18 +1714,18 @@ c3 66 66 66 +90 66 66 66 -2e -0f -1f -84 -00 -00 -00 -00 -00 +90 +66 +66 +66 +90 +66 +66 +90 48 89 6c @@ -1833,11 +1833,11 @@ c4 18 c3 66 -0f -1f -44 -00 -00 +66 +90 +66 +66 +90 48 8b 7d @@ -1881,11 +1881,11 @@ d8 c4 18 c3 -0f -1f -44 -00 -00 +66 +66 +90 +66 +90 53 83 7f @@ -2281,11 +2281,11 @@ ff 4c 8b 27 -0f -1f -44 -00 -00 +66 +66 +90 +66 +90 e9 fb fe @@ -3299,17 +3299,17 @@ ff 66 66 66 +90 66 66 -2e -0f -1f -84 -00 -00 -00 -00 -00 +66 +90 +66 +66 +90 +66 +66 +90 53 83 7f @@ -3353,11 +3353,11 @@ c7 00 5b c3 -0f -1f -44 -00 -00 +66 +66 +90 +66 +90 8b 4f 08 @@ -3382,14 +3382,14 @@ c3 c0 c3 66 -0f -1f -84 -00 -00 -00 -00 -00 +66 +90 +66 +66 +90 +66 +66 +90 8b 77 08 @@ -3413,15 +3413,15 @@ c0 f3 c3 66 -2e -0f -1f -84 -00 -00 -00 -00 -00 +66 +66 +90 +66 +66 +90 +66 +66 +90 48 83 ec @@ -3465,11 +3465,11 @@ d0 c4 08 c3 -0f -1f -44 -00 -00 +66 +66 +90 +66 +90 44 8b 47 @@ -3497,11 +3497,11 @@ e9 00 00 00 -0f -1f -44 -00 -00 +66 +66 +90 +66 +90 48 83 ec @@ -3545,11 +3545,11 @@ c0 c4 08 c3 -0f -1f -44 -00 -00 +66 +66 +90 +66 +90 48 8b 07 @@ -3577,11 +3577,11 @@ e9 00 00 00 -0f -1f -44 -00 -00 +66 +66 +90 +66 +90 53 8b 47 @@ -3641,11 +3641,11 @@ ff ff 7f c3 -0f -1f -44 -00 -00 +66 +66 +90 +66 +90 48 8b 3f @@ -3733,15 +3733,15 @@ d8 c3 66 66 -2e -0f -1f -84 -00 -00 -00 -00 -00 +66 +90 +66 +66 +66 +90 +66 +66 +90 48 89 5c @@ -3929,11 +3929,11 @@ c4 38 c3 66 -0f -1f -44 -00 -00 +66 +90 +66 +66 +90 48 89 ef @@ -3947,9 +3947,9 @@ e8 41 89 c4 -0f -1f -00 +66 +66 +90 44 89 e6 @@ -3979,9 +3979,9 @@ d2 48 8b 2f -0f -1f -00 +66 +66 +90 e9 64 ff @@ -4070,14 +4070,14 @@ e9 ff ff ff -0f -1f -84 -00 -00 -00 -00 -00 +66 +66 +66 +90 +66 +66 +66 +90 48 89 5c @@ -4649,11 +4649,11 @@ fe ff ff 66 -0f -1f -44 -00 -00 +66 +90 +66 +66 +90 48 89 ef @@ -4715,9 +4715,9 @@ d0 fd ff ff -0f -1f -00 +66 +66 +90 48 89 5c @@ -4875,9 +4875,9 @@ ed 2f 74 be -0f -1f -00 +66 +66 +90 4c 89 ef @@ -4954,10 +4954,10 @@ d8 f0 eb 85 -0f -1f -40 -00 +66 +66 +66 +90 b8 01 00 @@ -5010,18 +5010,18 @@ ff 66 66 66 +90 66 66 66 -2e -0f -1f -84 -00 -00 -00 -00 -00 +90 +66 +66 +66 +90 +66 +66 +90 48 89 5c @@ -5251,17 +5251,17 @@ eb 66 66 66 +90 66 66 -2e -0f -1f -84 -00 -00 -00 -00 -00 +66 +90 +66 +66 +90 +66 +66 +90 48 89 6c @@ -5767,13 +5767,13 @@ b8 00 00 00 -0f -1f -80 -00 -00 -00 -00 +66 +66 +66 +90 +66 +66 +90 c6 44 28 @@ -90134,7 +90134,7 @@ c0 00 00 00 -02 +00 00 00 00 diff --git a/modules/dbgfmts/dwarf2/tests/passwin64/Makefile.inc b/modules/dbgfmts/dwarf2/tests/passwin64/Makefile.inc index e1d9c4d9..32027367 100644 --- a/modules/dbgfmts/dwarf2/tests/passwin64/Makefile.inc +++ b/modules/dbgfmts/dwarf2/tests/passwin64/Makefile.inc @@ -1,3 +1,5 @@ +# $Id$ + TESTS += modules/dbgfmts/dwarf2/tests/passwin64/dwarf2_passwin64_test.sh EXTRA_DIST += modules/dbgfmts/dwarf2/tests/passwin64/dwarf2_passwin64_test.sh diff --git a/modules/dbgfmts/dwarf2/tests/passwin64/dwarf2_passwin64_test.sh b/modules/dbgfmts/dwarf2/tests/passwin64/dwarf2_passwin64_test.sh index 336ceab9..e892d33e 100755 --- a/modules/dbgfmts/dwarf2/tests/passwin64/dwarf2_passwin64_test.sh +++ b/modules/dbgfmts/dwarf2/tests/passwin64/dwarf2_passwin64_test.sh @@ -1,3 +1,4 @@ #! /bin/sh +# $Id$ ${srcdir}/out_test.sh dwarf2_passwin64_test modules/dbgfmts/dwarf2/tests/passwin64 "dwarf2 dbgfmt passwin64" "-f win64 -p gas -g dwarf2" ".o" exit $? diff --git a/modules/dbgfmts/dwarf2/tests/passwin64/dwarfwin64_testhd.errwarn b/modules/dbgfmts/dwarf2/tests/passwin64/dwarfwin64_testhd.errwarn index be2a237e..d383da2a 100644 --- a/modules/dbgfmts/dwarf2/tests/passwin64/dwarfwin64_testhd.errwarn +++ b/modules/dbgfmts/dwarf2/tests/passwin64/dwarfwin64_testhd.errwarn @@ -4,7 +4,7 @@ -:10: warning: unrecognized section attribute: `M' -:10: warning: unrecognized section attribute: `S' -:10: warning: Unrecognized qualifier `progbits' --:24: warning: .type pseudo-op used outside of .def/.endef; ignored +-:24: warning: directive `.type' not recognized -:152: warning: directive `.size' not recognized -:153: warning: Unrecognized qualifier `progbits' -:190: warning: Unrecognized qualifier `progbits' diff --git a/modules/dbgfmts/dwarf2/tests/passwin64/dwarfwin64_testhd.hex b/modules/dbgfmts/dwarf2/tests/passwin64/dwarfwin64_testhd.hex index 18adfd50..fdf74cc5 100644 --- a/modules/dbgfmts/dwarf2/tests/passwin64/dwarfwin64_testhd.hex +++ b/modules/dbgfmts/dwarf2/tests/passwin64/dwarfwin64_testhd.hex @@ -66,8 +66,8 @@ 00 00 00 -00 -00 +04 +01 00 00 00 @@ -106,8 +106,8 @@ c0 00 00 00 -00 -00 +ec +01 00 00 00 @@ -146,8 +146,8 @@ f3 00 00 00 -00 -00 +37 +05 00 00 00 @@ -186,8 +186,8 @@ f3 00 00 00 -00 -00 +d6 +05 00 00 00 @@ -226,8 +226,8 @@ f3 00 00 00 -00 -00 +22 +06 00 00 00 @@ -266,8 +266,8 @@ ce 00 00 00 -00 -00 +6a +06 00 00 00 @@ -306,8 +306,8 @@ c0 00 00 00 -00 -00 +b2 +06 00 00 00 @@ -346,8 +346,8 @@ c0 00 00 00 -00 -00 +bf +08 00 00 00 @@ -386,8 +386,8 @@ c0 00 00 00 -00 -00 +da +08 00 00 00 @@ -426,8 +426,8 @@ c0 00 00 00 -00 -00 +0a +09 00 00 00 @@ -466,8 +466,8 @@ aa 00 00 00 -00 -00 +54 +0b 00 00 00 @@ -506,8 +506,8 @@ f4 00 00 00 -00 -00 +77 +0b 00 00 00 @@ -611,13 +611,13 @@ b8 c4 18 c3 -0f -1f -80 -00 -00 -00 -00 +66 +66 +66 +90 +66 +66 +90 48 8b 7d @@ -646,10 +646,10 @@ c3 14 eb 77 -0f -1f -40 -00 +66 +66 +66 +90 89 c6 bf diff --git a/modules/dbgfmts/null/CMakeLists.txt b/modules/dbgfmts/null/CMakeLists.txt deleted file mode 100644 index 9f85b2fd..00000000 --- a/modules/dbgfmts/null/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -YASM_ADD_MODULE(dbgfmt_null - dbgfmts/null/null-dbgfmt.c - ) diff --git a/modules/dbgfmts/null/Makefile.inc b/modules/dbgfmts/null/Makefile.inc index 94f7cdbe..6582d744 100644 --- a/modules/dbgfmts/null/Makefile.inc +++ b/modules/dbgfmts/null/Makefile.inc @@ -1,3 +1,5 @@ +# $Id$ + libyasm_a_SOURCES += modules/dbgfmts/null/null-dbgfmt.c YASM_MODULES += dbgfmt_null diff --git a/modules/dbgfmts/null/null-dbgfmt.c b/modules/dbgfmts/null/null-dbgfmt.c index d2d1bed5..6baac617 100644 --- a/modules/dbgfmts/null/null-dbgfmt.c +++ b/modules/dbgfmts/null/null-dbgfmt.c @@ -25,7 +25,9 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include +/*@unused@*/ RCSID("$Id$"); +#define YASM_LIB_INTERNAL #include @@ -48,7 +50,7 @@ null_dbgfmt_destroy(/*@only@*/ yasm_dbgfmt *dbgfmt) static void null_dbgfmt_generate(yasm_object *object, yasm_linemap *linemap, - yasm_errwarns *errwarns) + yasm_errwarns *errwarns) { } @@ -57,7 +59,7 @@ null_dbgfmt_generate(yasm_object *object, yasm_linemap *linemap, yasm_dbgfmt_module yasm_null_LTX_dbgfmt = { "No debugging info", "null", - NULL, /* no directives */ + NULL, /* no directives */ null_dbgfmt_create, null_dbgfmt_destroy, null_dbgfmt_generate diff --git a/modules/dbgfmts/stabs/CMakeLists.txt b/modules/dbgfmts/stabs/CMakeLists.txt deleted file mode 100644 index bd3b0268..00000000 --- a/modules/dbgfmts/stabs/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -YASM_ADD_MODULE(dbgfmt_stabs - dbgfmts/stabs/stabs-dbgfmt.c - ) diff --git a/modules/dbgfmts/stabs/Makefile.inc b/modules/dbgfmts/stabs/Makefile.inc index 745c0dec..f5ba1422 100644 --- a/modules/dbgfmts/stabs/Makefile.inc +++ b/modules/dbgfmts/stabs/Makefile.inc @@ -1,3 +1,5 @@ +# $Id$ + libyasm_a_SOURCES += modules/dbgfmts/stabs/stabs-dbgfmt.c YASM_MODULES += dbgfmt_stabs diff --git a/modules/dbgfmts/stabs/stabs-dbgfmt.c b/modules/dbgfmts/stabs/stabs-dbgfmt.c index 64896cab..c7409e52 100644 --- a/modules/dbgfmts/stabs/stabs-dbgfmt.c +++ b/modules/dbgfmts/stabs/stabs-dbgfmt.c @@ -25,72 +25,75 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include +/*@unused@*/ RCSID("$Id$"); +#define YASM_LIB_INTERNAL +#define YASM_BC_INTERNAL #include typedef enum { - N_UNDF = 0x00, /* Undefined */ - N_GSYM = 0x20, /* Global symbol */ - N_FNAME = 0x22, /* Function name (BSD Fortran) */ - N_FUN = 0x24, /* Function name or Text segment variable */ - N_STSYM = 0x26, /* Data segment file-scope variable */ - N_LCSYM = 0x28, /* BSS segment file-scope variable */ - N_MAIN = 0x2a, /* Name of main routine */ - N_ROSYM = 0x2c, /* Variable in .rodata section */ - N_PC = 0x30, /* Global symbol (Pascal) */ - N_SYMS = 0x32, /* Number of symbols (Ultrix V4.0) */ - N_NOMAP = 0x34, /* No DST map */ - N_OBJ = 0x38, /* Object file (Solaris2) */ - N_OPT = 0x3c, /* Debugger options (Solaris2) */ - N_RSYM = 0x40, /* Register variable */ - N_M2C = 0x42, /* Modula-2 compilation unit */ - N_SLINE = 0x44, /* Line numbers in .text segment */ - N_DSLINE = 0x46, /* Line numbers in .data segment */ - N_BSLINE = 0x48, /* Line numbers in .bss segment */ - N_BROWS = 0x48, /* Source code .cb file's path */ - N_DEFD = 0x4a, /* GNU Modula-2 definition module dependency */ - N_FLINE = 0x4c, /* Function start/body/end line numbers (Solaris2) */ - N_EHDECL = 0x50, /* GNU C++ exception variable */ - N_MOD2 = 0x50, /* Modula2 info for imc (Ultrix V4.0) */ - N_CATCH = 0x54, /* GNU C++ catch clause */ - N_SSYM = 0x60, /* Structure or union element */ - N_ENDM = 0x62, /* Last stab for module (Solaris2) */ - N_SO = 0x64, /* Path and name of source files */ - N_LSYM = 0x80, /* Stack variable */ - N_BINCL = 0x84, /* Beginning of include file */ - N_SOL = 0x84, /* Name of include file */ - N_PSYM = 0xa0, /* Parameter variable */ - N_EINCL = 0xa2, /* End of include file */ - N_ENTRY = 0xa4, /* Alternate entry point */ - N_LBRAC = 0xc0, /* Beginning of lexical block */ - N_EXCL = 0xc2, /* Placeholder for a deleted include file */ - N_SCOPE = 0xc4, /* Modula 2 scope info (Sun) */ - N_RBRAC = 0xe0, /* End of lexical block */ - N_BCOMM = 0xe2, /* Begin named common block */ - N_ECOMM = 0xe4, /* End named common block */ - N_ECOML = 0xe8, /* Member of common block */ - N_WITH = 0xea, /* Pascal with statement: type,,0,0,offset (Solaris2) */ - N_NBTEXT = 0xf0, /* Gould non-base registers */ - N_NBDATA = 0xf2, /* Gould non-base registers */ - N_NBBSS = 0xf4, /* Gould non-base registers */ - N_NBSTS = 0xf6, /* Gould non-base registers */ - N_NBLCS = 0xf8 /* Gould non-base registers */ + N_UNDF = 0x00, /* Undefined */ + N_GSYM = 0x20, /* Global symbol */ + N_FNAME = 0x22, /* Function name (BSD Fortran) */ + N_FUN = 0x24, /* Function name or Text segment variable */ + N_STSYM = 0x26, /* Data segment file-scope variable */ + N_LCSYM = 0x28, /* BSS segment file-scope variable */ + N_MAIN = 0x2a, /* Name of main routine */ + N_ROSYM = 0x2c, /* Variable in .rodata section */ + N_PC = 0x30, /* Global symbol (Pascal) */ + N_SYMS = 0x32, /* Number of symbols (Ultrix V4.0) */ + N_NOMAP = 0x34, /* No DST map */ + N_OBJ = 0x38, /* Object file (Solaris2) */ + N_OPT = 0x3c, /* Debugger options (Solaris2) */ + N_RSYM = 0x40, /* Register variable */ + N_M2C = 0x42, /* Modula-2 compilation unit */ + N_SLINE = 0x44, /* Line numbers in .text segment */ + N_DSLINE = 0x46, /* Line numbers in .data segment */ + N_BSLINE = 0x48, /* Line numbers in .bss segment */ + N_BROWS = 0x48, /* Source code .cb file's path */ + N_DEFD = 0x4a, /* GNU Modula-2 definition module dependency */ + N_FLINE = 0x4c, /* Function start/body/end line numbers (Solaris2) */ + N_EHDECL = 0x50, /* GNU C++ exception variable */ + N_MOD2 = 0x50, /* Modula2 info for imc (Ultrix V4.0) */ + N_CATCH = 0x54, /* GNU C++ catch clause */ + N_SSYM = 0x60, /* Structure or union element */ + N_ENDM = 0x62, /* Last stab for module (Solaris2) */ + N_SO = 0x64, /* Path and name of source files */ + N_LSYM = 0x80, /* Stack variable */ + N_BINCL = 0x84, /* Beginning of include file */ + N_SOL = 0x84, /* Name of include file */ + N_PSYM = 0xa0, /* Parameter variable */ + N_EINCL = 0xa2, /* End of include file */ + N_ENTRY = 0xa4, /* Alternate entry point */ + N_LBRAC = 0xc0, /* Beginning of lexical block */ + N_EXCL = 0xc2, /* Placeholder for a deleted include file */ + N_SCOPE = 0xc4, /* Modula 2 scope info (Sun) */ + N_RBRAC = 0xe0, /* End of lexical block */ + N_BCOMM = 0xe2, /* Begin named common block */ + N_ECOMM = 0xe4, /* End named common block */ + N_ECOML = 0xe8, /* Member of common block */ + N_WITH = 0xea, /* Pascal with statement: type,,0,0,offset (Solaris2) */ + N_NBTEXT = 0xf0, /* Gould non-base registers */ + N_NBDATA = 0xf2, /* Gould non-base registers */ + N_NBBSS = 0xf4, /* Gould non-base registers */ + N_NBSTS = 0xf6, /* Gould non-base registers */ + N_NBLCS = 0xf8 /* Gould non-base registers */ } stabs_stab_type; typedef struct yasm_dbgfmt_stabs { - yasm_dbgfmt_base dbgfmt; /* base structure */ + yasm_dbgfmt_base dbgfmt; /* base structure */ } yasm_dbgfmt_stabs; typedef struct { - unsigned long lastline; /* track line and file of bytecodes */ + unsigned long lastline; /* track line and file of bytecodes */ unsigned long curline; const char *lastfile; const char *curfile; - unsigned int stablen; /* size of a stab for current machine */ - unsigned long stabcount; /* count stored stabs; doesn't include first */ + unsigned int stablen; /* size of a stab for current machine */ + unsigned long stabcount; /* count stored stabs; doesn't include first */ - yasm_section *stab; /* sections to which stabs, stabstrs appended */ + yasm_section *stab; /* sections to which stabs, stabstrs appended */ yasm_section *stabstr; yasm_bytecode *basebc; /* base bytecode from which to track SLINEs */ @@ -101,34 +104,34 @@ typedef struct { } stabs_info; typedef struct { - /*@null@*/ yasm_bytecode *bcstr; /* bytecode in stabstr for string */ - stabs_stab_type type; /* stab type: N_* */ - unsigned char other; /* unused, but stored here anyway */ - unsigned short desc; /* description element of a stab */ - /*@null@*/ yasm_symrec *symvalue; /* value element needing relocation */ - /*@null@*/yasm_bytecode *bcvalue; /* relocated stab's bytecode */ - unsigned long value; /* fallthrough value if above NULL */ + /*@null@*/ yasm_bytecode *bcstr; /* bytecode in stabstr for string */ + stabs_stab_type type; /* stab type: N_* */ + unsigned char other; /* unused, but stored here anyway */ + unsigned short desc; /* description element of a stab */ + /*@null@*/ yasm_symrec *symvalue; /* value element needing relocation */ + /*@null@*/yasm_bytecode *bcvalue; /* relocated stab's bytecode */ + unsigned long value; /* fallthrough value if above NULL */ } stabs_stab; /* Bytecode callback function prototypes */ static void stabs_bc_str_destroy(void *contents); static void stabs_bc_str_print(const void *contents, FILE *f, int - indent_level); + indent_level); static int stabs_bc_str_calc_len (yasm_bytecode *bc, yasm_bc_add_span_func add_span, void *add_span_data); static int stabs_bc_str_tobytes - (yasm_bytecode *bc, unsigned char **bufp, unsigned char *bufstart, void *d, + (yasm_bytecode *bc, unsigned char **bufp, void *d, yasm_output_value_func output_value, /*@null@*/ yasm_output_reloc_func output_reloc); static void stabs_bc_stab_destroy(void *contents); static void stabs_bc_stab_print(const void *contents, FILE *f, int - indent_level); + indent_level); static int stabs_bc_stab_calc_len (yasm_bytecode *bc, yasm_bc_add_span_func add_span, void *add_span_data); static int stabs_bc_stab_tobytes - (yasm_bytecode *bc, unsigned char **bufp, unsigned char *bufstart, void *d, + (yasm_bytecode *bc, unsigned char **bufp, void *d, yasm_output_value_func output_value, /*@null@*/ yasm_output_reloc_func output_reloc); @@ -138,7 +141,6 @@ static const yasm_bytecode_callback stabs_bc_str_callback = { stabs_bc_str_destroy, stabs_bc_str_print, yasm_bc_finalize_common, - NULL, stabs_bc_str_calc_len, yasm_bc_expand_common, stabs_bc_str_tobytes, @@ -149,7 +151,6 @@ static const yasm_bytecode_callback stabs_bc_stab_callback = { stabs_bc_stab_destroy, stabs_bc_stab_print, yasm_bc_finalize_common, - NULL, stabs_bc_stab_calc_len, yasm_bc_expand_common, stabs_bc_stab_tobytes, @@ -195,9 +196,9 @@ stabs_dbgfmt_append_bcstr(yasm_section *sect, const char *str) /* Requires a string bytecode, or NULL, for its string entry */ static stabs_stab * stabs_dbgfmt_append_stab(stabs_info *info, yasm_section *sect, - /*@null@*/ yasm_bytecode *bcstr, stabs_stab_type type, - unsigned long desc, /*@null@*/ yasm_symrec *symvalue, - /*@null@*/ yasm_bytecode *bcvalue, unsigned long value) + /*@null@*/ yasm_bytecode *bcstr, stabs_stab_type type, + unsigned long desc, /*@null@*/ yasm_symrec *symvalue, + /*@null@*/ yasm_bytecode *bcvalue, unsigned long value) { yasm_bytecode *bc; stabs_stab *stab = yasm_xmalloc(sizeof(stabs_stab)); @@ -211,7 +212,7 @@ stabs_dbgfmt_append_stab(stabs_info *info, yasm_section *sect, stab->value = value; bc = yasm_bc_create_common(&stabs_bc_stab_callback, stab, - bcvalue ? bcvalue->line : 0); + bcvalue ? bcvalue->line : 0); bc->len = info->stablen; bc->offset = yasm_bc_next_offset(yasm_section_bcs_last(sect)); @@ -242,10 +243,10 @@ stabs_dbgfmt_generate_n_fun(stabs_info *info, yasm_bytecode *bc) str = yasm_xmalloc(strlen(name)+4); strcpy(str, name); strcat(str, ":F1"); - stabs_dbgfmt_append_stab(info, info->stab, - stabs_dbgfmt_append_bcstr(info->stabstr, str), - N_FUN, 0, sym, info->basebc, 0); - yasm_xfree(str); + stabs_dbgfmt_append_stab(info, info->stab, + stabs_dbgfmt_append_bcstr(info->stabstr, str), + N_FUN, 0, sym, info->basebc, 0); + yasm_xfree(str); break; } } @@ -255,24 +256,24 @@ stabs_dbgfmt_generate_bcs(yasm_bytecode *bc, void *d) { stabs_info *info = (stabs_info *)d; yasm_linemap_lookup(info->linemap, bc->line, &info->curfile, - &info->curline); + &info->curline); /* check for new function */ stabs_dbgfmt_generate_n_fun(info, bc); if (info->lastfile != info->curfile) { - info->lastline = 0; /* new file, so line changes */ - /*stabs_dbgfmt_append_stab(info, info->stab, - stabs_dbgfmt_append_bcstr(info->stabstr, info->curfile), - N_SOL, 0, NULL, bc, 0);*/ + info->lastline = 0; /* new file, so line changes */ + /*stabs_dbgfmt_append_stab(info, info->stab, + stabs_dbgfmt_append_bcstr(info->stabstr, info->curfile), + N_SOL, 0, NULL, bc, 0);*/ } /* output new line stabs if there's a basebc (known function) */ if (info->basebc != NULL && info->curline != info->lastline) { - info->lastline = bc->line; - stabs_dbgfmt_append_stab(info, info->stab, NULL, N_SLINE, - info->curline, NULL, NULL, - bc->offset - info->basebc->offset); + info->lastline = bc->line; + stabs_dbgfmt_append_stab(info, info->stab, NULL, N_SLINE, + info->curline, NULL, NULL, + bc->offset - info->basebc->offset); } info->lastline = info->curline; @@ -294,15 +295,15 @@ stabs_dbgfmt_generate_sections(yasm_section *sect, /*@null@*/ void *d) stabs_dbgfmt_generate_n_fun(d, yasm_section_bcs_first(sect)); yasm_section_bcs_traverse(sect, info->errwarns, d, - stabs_dbgfmt_generate_bcs); + stabs_dbgfmt_generate_bcs); if (yasm__strcasecmp(sectname, ".text")==0) { /* Close out last function by appending a null SO stab after last bc */ yasm_bytecode *bc = yasm_section_bcs_last(sect); yasm_symrec *sym = - yasm_symtab_define_label(info->object->symtab, ".n_so", bc, 1, - bc->line); - stabs_dbgfmt_append_stab(info, info->stab, 0, N_SO, 0, sym, bc, 0); + yasm_symtab_define_label(info->object->symtab, ".n_so", bc, 1, + bc->line); + stabs_dbgfmt_append_stab(info, info->stab, 0, N_SO, 0, sym, bc, 0); } return 1; @@ -310,13 +311,13 @@ stabs_dbgfmt_generate_sections(yasm_section *sect, /*@null@*/ void *d) static void stabs_dbgfmt_generate(yasm_object *object, yasm_linemap *linemap, - yasm_errwarns *errwarns) + yasm_errwarns *errwarns) { stabs_info info; int new; yasm_bytecode *dbgbc; stabs_stab *stab; - yasm_bytecode *filebc, *laststr, *firstbc; + yasm_bytecode *filebc, *nullbc, *laststr, *firstbc; yasm_symrec *firstsym; yasm_section *stext; @@ -325,42 +326,42 @@ stabs_dbgfmt_generate(yasm_object *object, yasm_linemap *linemap, info.stablen = 12; } else /* unknown machine; generate nothing */ - return; + return; info.object = object; info.linemap = linemap; info.errwarns = errwarns; info.lastline = 0; info.stabcount = 0; - info.stab = yasm_object_get_general(object, ".stab", 4, 0, 0, &new, 0); + info.stab = yasm_object_get_general(object, ".stab", 0, 4, 0, 0, &new, 0); if (!new) { - yasm_bytecode *last = yasm_section_bcs_last(info.stab); - if (last == NULL) { - yasm_error_set(YASM_ERROR_GENERAL, - N_("stabs debugging conflicts with user-defined section .stab")); - yasm_errwarn_propagate(errwarns, - yasm_section_bcs_first(info.stab)->line); - } else { - yasm_warn_set(YASM_WARN_GENERAL, - N_("stabs debugging overrides empty section .stab")); - yasm_errwarn_propagate(errwarns, 0); - } + yasm_bytecode *last = yasm_section_bcs_last(info.stab); + if (last == NULL) { + yasm_error_set(YASM_ERROR_GENERAL, + N_("stabs debugging conflicts with user-defined section .stab")); + yasm_errwarn_propagate(errwarns, + yasm_section_bcs_first(info.stab)->line); + } else { + yasm_warn_set(YASM_WARN_GENERAL, + N_("stabs debugging overrides empty section .stab")); + yasm_errwarn_propagate(errwarns, 0); + } } info.stabstr = - yasm_object_get_general(object, ".stabstr", 1, 0, 0, &new, 0); + yasm_object_get_general(object, ".stabstr", 0, 1, 0, 0, &new, 0); if (!new) { - yasm_bytecode *last = yasm_section_bcs_last(info.stabstr); - if (last == NULL) { - yasm_error_set(YASM_ERROR_GENERAL, - N_("stabs debugging conflicts with user-defined section .stabstr")); - yasm_errwarn_propagate(errwarns, - yasm_section_bcs_first(info.stabstr)->line); - } else { - yasm_warn_set(YASM_WARN_GENERAL, - N_("stabs debugging overrides empty section .stabstr")); - yasm_errwarn_propagate(errwarns, 0); - } + yasm_bytecode *last = yasm_section_bcs_last(info.stabstr); + if (last == NULL) { + yasm_error_set(YASM_ERROR_GENERAL, + N_("stabs debugging conflicts with user-defined section .stabstr")); + yasm_errwarn_propagate(errwarns, + yasm_section_bcs_first(info.stab)->line); + } else { + yasm_warn_set(YASM_WARN_GENERAL, + N_("stabs debugging overrides empty section .stabstr")); + yasm_errwarn_propagate(errwarns, 0); + } } /* initial pseudo-stab */ @@ -371,7 +372,7 @@ stabs_dbgfmt_generate(yasm_object *object, yasm_linemap *linemap, yasm_section_bcs_append(info.stab, dbgbc); /* initial strtab bytecodes */ - stabs_dbgfmt_append_bcstr(info.stabstr, ""); + nullbc = stabs_dbgfmt_append_bcstr(info.stabstr, ""); filebc = stabs_dbgfmt_append_bcstr(info.stabstr, object->src_filename); stext = yasm_object_find_general(object, ".text"); @@ -379,15 +380,15 @@ stabs_dbgfmt_generate(yasm_object *object, yasm_linemap *linemap, firstbc = yasm_section_bcs_first(stext); /* N_SO file stab */ stabs_dbgfmt_append_stab(&info, info.stab, filebc, N_SO, 0, - firstsym, firstbc, 0); + firstsym, firstbc, 0); yasm_object_sections_traverse(object, (void *)&info, - stabs_dbgfmt_generate_sections); + stabs_dbgfmt_generate_sections); /* fill initial pseudo-stab's fields */ laststr = yasm_section_bcs_last(info.stabstr); if (laststr == NULL) - yasm_internal_error(".stabstr has no entries"); + yasm_internal_error(".stabstr has no entries"); stab->bcvalue = NULL; stab->symvalue = NULL; @@ -396,18 +397,17 @@ stabs_dbgfmt_generate(yasm_object *object, yasm_linemap *linemap, stab->type = N_UNDF; stab->other = 0; if (info.stabcount > 0xffff) { - yasm_warn_set(YASM_WARN_GENERAL, N_("over 65535 stabs")); - yasm_errwarn_propagate(errwarns, 0); - stab->desc = 0xffff; + yasm_warn_set(YASM_WARN_GENERAL, N_("over 65535 stabs")); + yasm_errwarn_propagate(errwarns, 0); + stab->desc = 0xffff; } else - stab->desc = (unsigned short)info.stabcount; + stab->desc = (unsigned short)info.stabcount; } static int -stabs_bc_stab_tobytes(yasm_bytecode *bc, unsigned char **bufp, - unsigned char *bufstart, void *d, - yasm_output_value_func output_value, - yasm_output_reloc_func output_reloc) +stabs_bc_stab_tobytes(yasm_bytecode *bc, unsigned char **bufp, void *d, + yasm_output_value_func output_value, + yasm_output_reloc_func output_reloc) { /* This entire function, essentially the core of rendering stabs to a file, * needs to become endian aware. Size appears not to be an issue, as known @@ -422,16 +422,16 @@ stabs_bc_stab_tobytes(yasm_bytecode *bc, unsigned char **bufp, YASM_WRITE_16_L(buf, stab->desc); if (stab->symvalue != NULL) { - bc->offset += 8; - output_reloc(stab->symvalue, bc, buf, 4, 32, 0, d); - bc->offset -= 8; - buf += 4; + bc->offset += 8; + output_reloc(stab->symvalue, bc, buf, 4, 32, 0, d); + bc->offset -= 8; + buf += 4; } else if (stab->bcvalue != NULL) { - YASM_WRITE_32_L(buf, stab->bcvalue->offset); + YASM_WRITE_32_L(buf, stab->bcvalue->offset); } else { - YASM_WRITE_32_L(buf, stab->value); + YASM_WRITE_32_L(buf, stab->value); } *bufp = buf; @@ -439,10 +439,9 @@ stabs_bc_stab_tobytes(yasm_bytecode *bc, unsigned char **bufp, } static int -stabs_bc_str_tobytes(yasm_bytecode *bc, unsigned char **bufp, - unsigned char *bufstart, void *d, - yasm_output_value_func output_value, - yasm_output_reloc_func output_reloc) +stabs_bc_str_tobytes(yasm_bytecode *bc, unsigned char **bufp, void *d, + yasm_output_value_func output_value, + yasm_output_reloc_func output_reloc) { const char *str = (const char *)bc->contents; unsigned char *buf = *bufp; @@ -472,8 +471,8 @@ stabs_bc_stab_print(const void *contents, FILE *f, int indent_level) const stabs_stab *stab = (const stabs_stab *)contents; const char *str = ""; fprintf(f, "%*s.stabs \"%s\", 0x%x, 0x%x, 0x%x, 0x%lx\n", - indent_level, "", str, stab->type, stab->other, stab->desc, - stab->bcvalue ? stab->bcvalue->offset : stab->value); + indent_level, "", str, stab->type, stab->other, stab->desc, + stab->bcvalue ? stab->bcvalue->offset : stab->value); } static void @@ -484,7 +483,7 @@ stabs_bc_str_print(const void *contents, FILE *f, int indent_level) static int stabs_bc_stab_calc_len(yasm_bytecode *bc, yasm_bc_add_span_func add_span, - void *add_span_data) + void *add_span_data) { yasm_internal_error(N_("tried to resolve a stabs stab bytecode")); /*@notreached@*/ @@ -493,7 +492,7 @@ stabs_bc_stab_calc_len(yasm_bytecode *bc, yasm_bc_add_span_func add_span, static int stabs_bc_str_calc_len(yasm_bytecode *bc, yasm_bc_add_span_func add_span, - void *add_span_data) + void *add_span_data) { yasm_internal_error(N_("tried to resolve a stabs str bytecode")); /*@notreached@*/ @@ -504,7 +503,7 @@ stabs_bc_str_calc_len(yasm_bytecode *bc, yasm_bc_add_span_func add_span, yasm_dbgfmt_module yasm_stabs_LTX_dbgfmt = { "Stabs debugging format", "stabs", - NULL, /* no directives */ + NULL, /* no directives */ stabs_dbgfmt_create, stabs_dbgfmt_destroy, stabs_dbgfmt_generate diff --git a/modules/dbgfmts/stabs/tests/Makefile.inc b/modules/dbgfmts/stabs/tests/Makefile.inc index 6f789eb8..9563d9c5 100644 --- a/modules/dbgfmts/stabs/tests/Makefile.inc +++ b/modules/dbgfmts/stabs/tests/Makefile.inc @@ -1,3 +1,5 @@ +# $Id$ + EXTRA_DIST += modules/dbgfmts/stabs/tests/stabs_test.sh TESTS += modules/dbgfmts/stabs/tests/stabs_test.sh diff --git a/modules/dbgfmts/stabs/tests/stabs-elf.hex b/modules/dbgfmts/stabs/tests/stabs-elf.hex index 71cd7c9f..c2e9e3cf 100644 --- a/modules/dbgfmts/stabs/tests/stabs-elf.hex +++ b/modules/dbgfmts/stabs/tests/stabs-elf.hex @@ -599,7 +599,7 @@ c3 00 00 01 -02 +04 00 00 00 @@ -862,22 +862,6 @@ c3 00 f1 ff -69 -00 -00 -00 -3d -00 -00 -00 -00 -00 -00 -00 -00 -00 -04 -00 00 00 00 @@ -910,6 +894,22 @@ ff 00 09 00 +69 +00 +00 +00 +3d +00 +00 +00 +00 +00 +00 +00 +00 +00 +04 +00 00 00 00 diff --git a/modules/dbgfmts/stabs/tests/stabs_test.sh b/modules/dbgfmts/stabs/tests/stabs_test.sh index e04b9522..64f24f33 100755 --- a/modules/dbgfmts/stabs/tests/stabs_test.sh +++ b/modules/dbgfmts/stabs/tests/stabs_test.sh @@ -1,4 +1,5 @@ #! /bin/sh +# $Id$ # copied from yasm/modules/objfmts/coff/tests/coff_test.sh ; s/coff/stabs/g ${srcdir}/out_test.sh stabs_test modules/dbgfmts/stabs/tests "stabs dbgfmt" "-f elf -g stabs" ".o" exit $? diff --git a/modules/dbgfmts/yasm_dbgfmts.xml b/modules/dbgfmts/yasm_dbgfmts.xml index 7cd38a49..5b15925f 100644 --- a/modules/dbgfmts/yasm_dbgfmts.xml +++ b/modules/dbgfmts/yasm_dbgfmts.xml @@ -2,6 +2,8 @@ + + diff --git a/modules/listfmts/CMakeLists.txt b/modules/listfmts/CMakeLists.txt deleted file mode 100644 index ce3c92a0..00000000 --- a/modules/listfmts/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -INCLUDE(listfmts/nasm/CMakeLists.txt) diff --git a/modules/listfmts/Makefile.inc b/modules/listfmts/Makefile.inc index 77fb2ec5..2621412e 100644 --- a/modules/listfmts/Makefile.inc +++ b/modules/listfmts/Makefile.inc @@ -1,3 +1,5 @@ +# $Id$ + EXTRA_DIST += modules/listfmts/nasm/Makefile.inc include modules/listfmts/nasm/Makefile.inc diff --git a/modules/listfmts/nasm/CMakeLists.txt b/modules/listfmts/nasm/CMakeLists.txt deleted file mode 100644 index 9d54f82f..00000000 --- a/modules/listfmts/nasm/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -YASM_ADD_MODULE(listfmt_nasm - listfmts/nasm/nasm-listfmt.c - ) diff --git a/modules/listfmts/nasm/Makefile.inc b/modules/listfmts/nasm/Makefile.inc index 6f00499e..7df9badc 100644 --- a/modules/listfmts/nasm/Makefile.inc +++ b/modules/listfmts/nasm/Makefile.inc @@ -1,3 +1,5 @@ +# $Id$ + libyasm_a_SOURCES += modules/listfmts/nasm/nasm-listfmt.c YASM_MODULES += listfmt_nasm diff --git a/modules/listfmts/nasm/nasm-listfmt.c b/modules/listfmts/nasm/nasm-listfmt.c index 1dfc5b62..1d76f82a 100644 --- a/modules/listfmts/nasm/nasm-listfmt.c +++ b/modules/listfmts/nasm/nasm-listfmt.c @@ -25,7 +25,10 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include +/*@unused@*/ RCSID("$Id$"); +#define YASM_LIB_INTERNAL +#define YASM_BC_INTERNAL #include /* NOTE: For this code to generate relocation information, the relocations @@ -44,21 +47,21 @@ yasm_listfmt_module yasm_nasm_LTX_listfmt; typedef struct sectreloc { /*@reldef@*/ SLIST_ENTRY(sectreloc) link; yasm_section *sect; - /*@null@*/ yasm_reloc *next_reloc; /* next relocation in section */ + /*@null@*/ yasm_reloc *next_reloc; /* next relocation in section */ unsigned long next_reloc_addr; } sectreloc; typedef struct bcreloc { /*@reldef@*/ STAILQ_ENTRY(bcreloc) link; - unsigned long offset; /* start of reloc from start of bytecode */ - size_t size; /* size of reloc in bytes */ - int rel; /* PC/IP-relative or "absolute" */ + unsigned long offset; /* start of reloc from start of bytecode */ + size_t size; /* size of reloc in bytes */ + int rel; /* PC/IP-relative or "absolute" */ } bcreloc; typedef struct nasm_listfmt_output_info { yasm_arch *arch; /*@reldef@*/ STAILQ_HEAD(bcrelochead, bcreloc) bcrelocs; - /*@null@*/ yasm_reloc *next_reloc; /* next relocation in section */ + /*@null@*/ yasm_reloc *next_reloc; /* next relocation in section */ unsigned long next_reloc_addr; } nasm_listfmt_output_info; @@ -79,8 +82,8 @@ nasm_listfmt_destroy(/*@only@*/ yasm_listfmt *listfmt) static int nasm_listfmt_output_value(yasm_value *value, unsigned char *buf, - unsigned int destsize, unsigned long offset, - yasm_bytecode *bc, int warn, /*@null@*/ void *d) + unsigned int destsize, unsigned long offset, + yasm_bytecode *bc, int warn, /*@null@*/ void *d) { /*@null@*/ nasm_listfmt_output_info *info = (nasm_listfmt_output_info *)d; /*@dependent@*/ /*@null@*/ yasm_intnum *intn; @@ -90,50 +93,50 @@ nasm_listfmt_output_value(yasm_value *value, unsigned char *buf, /* Output */ switch (yasm_value_output_basic(value, buf, destsize, bc, warn, - info->arch)) { - case -1: - return 1; - case 0: - break; - default: - return 0; + info->arch)) { + case -1: + return 1; + case 0: + break; + default: + return 0; } /* Generate reloc if needed */ if (info->next_reloc && info->next_reloc_addr == bc->offset+offset) { - bcreloc *reloc = yasm_xmalloc(sizeof(bcreloc)); - reloc->offset = offset; - reloc->size = destsize; - reloc->rel = value->curpos_rel; - STAILQ_INSERT_TAIL(&info->bcrelocs, reloc, link); + bcreloc *reloc = yasm_xmalloc(sizeof(bcreloc)); + reloc->offset = offset; + reloc->size = destsize; + reloc->rel = value->curpos_rel; + STAILQ_INSERT_TAIL(&info->bcrelocs, reloc, link); - /* Get next reloc's info */ - info->next_reloc = yasm_section_reloc_next(info->next_reloc); - if (info->next_reloc) { - yasm_intnum *addr; - yasm_symrec *sym; - yasm_reloc_get(info->next_reloc, &addr, &sym); - info->next_reloc_addr = yasm_intnum_get_uint(addr); - } + /* Get next reloc's info */ + info->next_reloc = yasm_section_reloc_next(info->next_reloc); + if (info->next_reloc) { + yasm_intnum *addr; + yasm_symrec *sym; + yasm_reloc_get(info->next_reloc, &addr, &sym); + info->next_reloc_addr = yasm_intnum_get_uint(addr); + } } if (value->abs) { - intn = yasm_expr_get_intnum(&value->abs, 0); - if (intn) - return yasm_arch_intnum_tobytes(info->arch, intn, buf, destsize, - valsize, 0, bc, 0); - else { - yasm_error_set(YASM_ERROR_TOO_COMPLEX, - N_("relocation too complex")); - return 1; - } + intn = yasm_expr_get_intnum(&value->abs, 0); + if (intn) + return yasm_arch_intnum_tobytes(info->arch, intn, buf, destsize, + valsize, 0, bc, 0); + else { + yasm_error_set(YASM_ERROR_TOO_COMPLEX, + N_("relocation too complex")); + return 1; + } } else { - int retval; - intn = yasm_intnum_create_uint(0); - retval = yasm_arch_intnum_tobytes(info->arch, intn, buf, destsize, - valsize, 0, bc, 0); - yasm_intnum_destroy(intn); - return retval; + int retval; + intn = yasm_intnum_create_uint(0); + retval = yasm_arch_intnum_tobytes(info->arch, intn, buf, destsize, + valsize, 0, bc, 0); + yasm_intnum_destroy(intn); + return retval; } return 0; @@ -141,7 +144,7 @@ nasm_listfmt_output_value(yasm_value *value, unsigned char *buf, static void nasm_listfmt_output(yasm_listfmt *listfmt, FILE *f, yasm_linemap *linemap, - yasm_arch *arch) + yasm_arch *arch) { yasm_bytecode *bc; const char *source; @@ -161,131 +164,131 @@ nasm_listfmt_output(yasm_listfmt *listfmt, FILE *f, yasm_linemap *linemap, buf = yasm_xmalloc(REGULAR_BUF_SIZE); while (!yasm_linemap_get_source(linemap, line, &bc, &source)) { - if (!bc) { - fprintf(f, "%6lu %*s%s\n", listline++, 32, "", source); - } else { - /* get the next relocation for the bytecode's section */ - sect = yasm_bc_get_section(bc); - if (!last_hist || last_hist->sect != sect) { - int found = 0; + if (!bc) { + fprintf(f, "%6lu %*s%s\n", listline++, 32, "", source); + } else { + /* get the next relocation for the bytecode's section */ + sect = yasm_bc_get_section(bc); + if (!last_hist || last_hist->sect != sect) { + int found = 0; - /* look through reloc_hist for matching section */ - SLIST_FOREACH(last_hist, &reloc_hist, link) { - if (last_hist->sect == sect) { - found = 1; - break; - } - } + /* look through reloc_hist for matching section */ + SLIST_FOREACH(last_hist, &reloc_hist, link) { + if (last_hist->sect == sect) { + found = 1; + break; + } + } - if (!found) { - /* not found, add to list*/ - last_hist = yasm_xmalloc(sizeof(sectreloc)); - last_hist->sect = sect; - last_hist->next_reloc = yasm_section_relocs_first(sect); + if (!found) { + /* not found, add to list*/ + last_hist = yasm_xmalloc(sizeof(sectreloc)); + last_hist->sect = sect; + last_hist->next_reloc = yasm_section_relocs_first(sect); - if (last_hist->next_reloc) { - yasm_intnum *addr; - yasm_symrec *sym; - yasm_reloc_get(last_hist->next_reloc, &addr, &sym); - last_hist->next_reloc_addr = - yasm_intnum_get_uint(addr); - } + if (last_hist->next_reloc) { + yasm_intnum *addr; + yasm_symrec *sym; + yasm_reloc_get(last_hist->next_reloc, &addr, &sym); + last_hist->next_reloc_addr = + yasm_intnum_get_uint(addr); + } - SLIST_INSERT_HEAD(&reloc_hist, last_hist, link); - } - } + SLIST_INSERT_HEAD(&reloc_hist, last_hist, link); + } + } - info.next_reloc = last_hist->next_reloc; - info.next_reloc_addr = last_hist->next_reloc_addr; - STAILQ_INIT(&info.bcrelocs); + info.next_reloc = last_hist->next_reloc; + info.next_reloc_addr = last_hist->next_reloc_addr; + STAILQ_INIT(&info.bcrelocs); - /* loop over bytecodes on this line (usually only one) */ - while (bc && bc->line == line) { - /*@null@*/ /*@only@*/ unsigned char *bigbuf; - unsigned long size = REGULAR_BUF_SIZE; - long multiple; - unsigned long offset = bc->offset; - unsigned char *origp, *p; - int gap; + /* loop over bytecodes on this line (usually only one) */ + while (bc && bc->line == line) { + /*@null@*/ /*@only@*/ unsigned char *bigbuf; + unsigned long size = REGULAR_BUF_SIZE; + long multiple; + unsigned long offset = bc->offset; + unsigned char *origp, *p; + int gap; - /* convert bytecode into bytes, recording relocs along the - * way - */ - bigbuf = yasm_bc_tobytes(bc, buf, &size, &gap, &info, - nasm_listfmt_output_value, NULL); - yasm_bc_get_multiple(bc, &multiple, 1); - if (multiple <= 0) - size = 0; - else - size /= multiple; + /* convert bytecode into bytes, recording relocs along the + * way + */ + bigbuf = yasm_bc_tobytes(bc, buf, &size, &gap, &info, + nasm_listfmt_output_value, NULL); + yasm_bc_get_multiple(bc, &multiple, 1); + if (multiple <= 0) + size = 0; + else + size /= multiple; - /* output bytes with reloc information */ - origp = bigbuf ? bigbuf : buf; - p = origp; - reloc = STAILQ_FIRST(&info.bcrelocs); - if (gap) { - fprintf(f, "%6lu %08lX %*s%s\n", listline++, offset, - 18, "", source ? source : ""); - } else while (size > 0) { - int i; + /* output bytes with reloc information */ + origp = bigbuf ? bigbuf : buf; + p = origp; + reloc = STAILQ_FIRST(&info.bcrelocs); + if (gap) { + fprintf(f, "%6lu %08lX %*s%s\n", listline++, offset, + 18, "", source ? source : ""); + } else while (size > 0) { + int i; - fprintf(f, "%6lu %08lX ", listline++, offset); - for (i=0; i<18 && size > 0; size--) { - if (reloc && (unsigned long)(p-origp) == - reloc->offset) { - fprintf(f, "%c", reloc->rel ? '(' : '['); - i++; - } - fprintf(f, "%02X", *(p++)); - i+=2; - if (reloc && (unsigned long)(p-origp) == - reloc->offset+reloc->size) { - fprintf(f, "%c", reloc->rel ? ')' : ']'); - i++; - reloc = STAILQ_NEXT(reloc, link); - } - } - if (size > 0) - fprintf(f, "-"); - else { - if (multiple > 1) { - fprintf(f, ""); - i += 6; - } - fprintf(f, "%*s", 18-i+1, ""); - } - if (source) { - fprintf(f, " %s", source); - source = NULL; - } - fprintf(f, "\n"); - } + fprintf(f, "%6lu %08lX ", listline++, offset); + for (i=0; i<18 && size > 0; size--) { + if (reloc && (unsigned long)(p-origp) == + reloc->offset) { + fprintf(f, "%c", reloc->rel ? '(' : '['); + i++; + } + fprintf(f, "%02X", *(p++)); + i+=2; + if (reloc && (unsigned long)(p-origp) == + reloc->offset+reloc->size) { + fprintf(f, "%c", reloc->rel ? ')' : ']'); + i++; + reloc = STAILQ_NEXT(reloc, link); + } + } + if (size > 0) + fprintf(f, "-"); + else { + if (multiple > 1) { + fprintf(f, ""); + i += 6; + } + fprintf(f, "%*s", 18-i+1, ""); + } + if (source) { + fprintf(f, " %s", source); + source = NULL; + } + fprintf(f, "\n"); + } - if (bigbuf) - yasm_xfree(bigbuf); - bc = STAILQ_NEXT(bc, link); - } + if (bigbuf) + yasm_xfree(bigbuf); + bc = STAILQ_NEXT(bc, link); + } - /* delete bcrelocs (newly generated next bytecode if any) */ - reloc = STAILQ_FIRST(&info.bcrelocs); - while (reloc) { - bcreloc *reloc2 = STAILQ_NEXT(reloc, link); - yasm_xfree(reloc); - reloc = reloc2; - } + /* delete bcrelocs (newly generated next bytecode if any) */ + reloc = STAILQ_FIRST(&info.bcrelocs); + while (reloc) { + bcreloc *reloc2 = STAILQ_NEXT(reloc, link); + yasm_xfree(reloc); + reloc = reloc2; + } - /* save reloc context */ - last_hist->next_reloc = info.next_reloc; - last_hist->next_reloc_addr = info.next_reloc_addr; - } - line++; + /* save reloc context */ + last_hist->next_reloc = info.next_reloc; + last_hist->next_reloc_addr = info.next_reloc_addr; + } + line++; } /* delete reloc history */ while (!SLIST_EMPTY(&reloc_hist)) { - last_hist = SLIST_FIRST(&reloc_hist); - SLIST_REMOVE_HEAD(&reloc_hist, link); - yasm_xfree(last_hist); + last_hist = SLIST_FIRST(&reloc_hist); + SLIST_REMOVE_HEAD(&reloc_hist, link); + yasm_xfree(last_hist); } yasm_xfree(buf); diff --git a/modules/objfmts/CMakeLists.txt b/modules/objfmts/CMakeLists.txt deleted file mode 100644 index c00a3a04..00000000 --- a/modules/objfmts/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -INCLUDE(objfmts/dbg/CMakeLists.txt) -INCLUDE(objfmts/bin/CMakeLists.txt) -INCLUDE(objfmts/elf/CMakeLists.txt) -INCLUDE(objfmts/coff/CMakeLists.txt) -INCLUDE(objfmts/macho/CMakeLists.txt) -INCLUDE(objfmts/rdf/CMakeLists.txt) -#INCLUDE(objfmts/win32/CMakeLists.txt) -#INCLUDE(objfmts/win64/CMakeLists.txt) -INCLUDE(objfmts/xdf/CMakeLists.txt) diff --git a/modules/objfmts/Makefile.inc b/modules/objfmts/Makefile.inc index a76359a4..be672182 100644 --- a/modules/objfmts/Makefile.inc +++ b/modules/objfmts/Makefile.inc @@ -1,3 +1,5 @@ +# $Id$ + EXTRA_DIST += modules/objfmts/dbg/Makefile.inc EXTRA_DIST += modules/objfmts/bin/Makefile.inc EXTRA_DIST += modules/objfmts/elf/Makefile.inc @@ -20,7 +22,7 @@ include modules/objfmts/win32/Makefile.inc include modules/objfmts/win64/Makefile.inc include modules/objfmts/xdf/Makefile.inc -notrans_dist_man_MANS += yasm_objfmts.7 +dist_man_MANS += yasm_objfmts.7 if BUILD_MAN yasm_objfmts.7: modules/objfmts/yasm_objfmts.xml diff --git a/modules/objfmts/bin/CMakeLists.txt b/modules/objfmts/bin/CMakeLists.txt deleted file mode 100644 index 7af5e22b..00000000 --- a/modules/objfmts/bin/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -YASM_ADD_MODULE(objfmt_bin - objfmts/bin/bin-objfmt.c - ) - -YASM_ADD_MODULE(objfmt_dosexe - ) diff --git a/modules/objfmts/bin/Makefile.inc b/modules/objfmts/bin/Makefile.inc index ae23cfe7..4d38b539 100644 --- a/modules/objfmts/bin/Makefile.inc +++ b/modules/objfmts/bin/Makefile.inc @@ -1,6 +1,8 @@ +# $Id$ + libyasm_a_SOURCES += modules/objfmts/bin/bin-objfmt.c -YASM_MODULES += objfmt_bin objfmt_dosexe +YASM_MODULES += objfmt_bin EXTRA_DIST += modules/objfmts/bin/tests/Makefile.inc diff --git a/modules/objfmts/bin/bin-objfmt.c b/modules/objfmts/bin/bin-objfmt.c index c5abd87a..885d36c5 100644 --- a/modules/objfmts/bin/bin-objfmt.c +++ b/modules/objfmts/bin/bin-objfmt.c @@ -25,78 +25,20 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include +/*@unused@*/ RCSID("$Id$"); -#ifdef HAVE_UNISTD_H -#include -#endif +#define YASM_LIB_INTERNAL +#define YASM_BC_INTERNAL +#define YASM_EXPR_INTERNAL #include -#include -#define REGULAR_OUTBUF_SIZE 1024 - -typedef struct bin_section_data { - int bss; /* aka nobits */ - - /* User-provided alignment */ - yasm_intnum *align, *valign; - - /* User-provided starts */ - /*@null@*/ /*@owned@*/ yasm_expr *start, *vstart; - - /* User-provided follows */ - /*@null@*/ /*@owned@*/ char *follows, *vfollows; - - /* Calculated (final) starts, used only during output() */ - /*@null@*/ /*@owned@*/ yasm_intnum *istart, *ivstart; - - /* Calculated (final) length, used only during output() */ - /*@null@*/ /*@owned@*/ yasm_intnum *length; -} bin_section_data; +#define REGULAR_OUTBUF_SIZE 1024 typedef struct yasm_objfmt_bin { - yasm_objfmt_base objfmt; /* base structure */ - - enum { - NO_MAP = 0, - MAP_NONE = 0x01, - MAP_BRIEF = 0x02, - MAP_SECTIONS = 0x04, - MAP_SYMBOLS = 0x08 - } map_flags; - /*@null@*/ /*@only@*/ char *map_filename; - - /*@null@*/ /*@only@*/ yasm_expr *org; + yasm_objfmt_base objfmt; /* base structure */ } yasm_objfmt_bin; -/* symrec data is used only for the special symbols section.start, - * section.vstart, and section.length - */ -typedef struct bin_symrec_data { - yasm_section *section; /* referenced section */ - enum bin_ssym { - SSYM_START, - SSYM_VSTART, - SSYM_LENGTH - } which; -} bin_symrec_data; - -static void bin_section_data_destroy(/*@only@*/ void *d); -static void bin_section_data_print(void *data, FILE *f, int indent_level); - -static const yasm_assoc_data_callback bin_section_data_cb = { - bin_section_data_destroy, - bin_section_data_print -}; - -static void bin_symrec_data_destroy(/*@only@*/ void *d); -static void bin_symrec_data_print(void *data, FILE *f, int indent_level); - -static const yasm_assoc_data_callback bin_symrec_data_cb = { - bin_symrec_data_destroy, - bin_symrec_data_print -}; - yasm_objfmt_module yasm_bin_LTX_objfmt; @@ -105,84 +47,40 @@ bin_objfmt_create(yasm_object *object) { yasm_objfmt_bin *objfmt_bin = yasm_xmalloc(sizeof(yasm_objfmt_bin)); objfmt_bin->objfmt.module = &yasm_bin_LTX_objfmt; - - objfmt_bin->map_flags = NO_MAP; - objfmt_bin->map_filename = NULL; - objfmt_bin->org = NULL; - return (yasm_objfmt *)objfmt_bin; } -typedef TAILQ_HEAD(bin_group_head, bin_group) bin_groups; +/* Aligns sect to either its specified alignment. Uses prevsect and base to + * both determine the new starting address (returned) and the total length of + * prevsect after sect has been aligned. + */ +static unsigned long +bin_objfmt_align_section(yasm_section *sect, yasm_section *prevsect, + unsigned long base, + /*@out@*/ unsigned long *prevsectlen, + /*@out@*/ unsigned long *padamt) +{ + unsigned long start; + unsigned long align; -typedef struct bin_group { - TAILQ_ENTRY(bin_group) link; - yasm_section *section; - bin_section_data *bsd; - - /* Groups that (in parallel) logically come immediately after this - * group's section. + /* Figure out the size of .text by looking at the last bytecode's offset + * plus its length. Add the start and size together to get the new start. */ - bin_groups follow_groups; -} bin_group; + *prevsectlen = yasm_bc_next_offset(yasm_section_bcs_last(prevsect)); + start = base + *prevsectlen; -/* Recursive function to find group containing named section. */ -static bin_group * -find_group_by_name(bin_groups *groups, const char *name) -{ - bin_group *group, *found; - TAILQ_FOREACH(group, groups, link) { - if (strcmp(yasm_section_get_name(group->section), name) == 0) - return group; - /* Recurse to loop through follow groups */ - found = find_group_by_name(&group->follow_groups, name); - if (found) - return found; - } - return NULL; -} + /* Round new start up to alignment of .data section, and adjust textlen to + * indicate padded size. Because aignment is always a power of two, we + * can use some bit trickery to do this easily. + */ + align = yasm_section_get_align(sect); -/* Recursive function to find group. Returns NULL if not found. */ -static bin_group * -find_group_by_section(bin_groups *groups, yasm_section *section) -{ - bin_group *group, *found; - TAILQ_FOREACH(group, groups, link) { - if (group->section == section) - return group; - /* Recurse to loop through follow groups */ - found = find_group_by_section(&group->follow_groups, section); - if (found) - return found; - } - return NULL; -} + if (start & (align-1)) + start = (start & ~(align-1)) + align; -#if 0 -/* Debugging function */ -static void -print_groups(const bin_groups *groups, int indent_level) -{ - bin_group *group; - TAILQ_FOREACH(group, groups, link) { - printf("%*sSection `%s':\n", indent_level, "", - yasm_section_get_name(group->section)); - bin_section_data_print(group->bsd, stdout, indent_level+1); - if (!TAILQ_EMPTY(&group->follow_groups)) { - printf("%*sFollowing groups:\n", indent_level, ""); - print_groups(&group->follow_groups, indent_level+1); - } - } -} -#endif + *padamt = start - (base + *prevsectlen); -static void -bin_group_destroy(/*@only@*/ bin_group *group) -{ - bin_group *follow, *group_temp; - TAILQ_FOREACH_SAFE(follow, &group->follow_groups, link, group_temp) - bin_group_destroy(follow); - yasm_xfree(group); + return start; } typedef struct bin_objfmt_output_info { @@ -191,721 +89,46 @@ typedef struct bin_objfmt_output_info { /*@dependent@*/ FILE *f; /*@only@*/ unsigned char *buf; /*@observer@*/ const yasm_section *sect; - unsigned long start; /* what normal variables go against */ - - yasm_intnum *origin; - yasm_intnum *tmp_intn; /* temporary working intnum */ - - bin_groups lma_groups, vma_groups; + unsigned long start; /* what normal variables go against */ + unsigned long abs_start; /* what absolutes go against */ } bin_objfmt_output_info; -static int -bin_objfmt_check_sym(yasm_symrec *sym, /*@null@*/ void *d) -{ - /*@null@*/ bin_objfmt_output_info *info = (bin_objfmt_output_info *)d; - yasm_sym_vis vis = yasm_symrec_get_visibility(sym); - assert(info != NULL); - - /* Don't check internally-generated symbols. Only internally generated - * symbols have symrec data, so simply check for its presence. - */ - if (yasm_symrec_get_data(sym, &bin_symrec_data_cb)) - return 0; - - if (vis & YASM_SYM_EXTERN) { - yasm_warn_set(YASM_WARN_GENERAL, - N_("binary object format does not support extern variables")); - yasm_errwarn_propagate(info->errwarns, yasm_symrec_get_decl_line(sym)); - } else if (vis & YASM_SYM_GLOBAL) { - yasm_warn_set(YASM_WARN_GENERAL, - N_("binary object format does not support global variables")); - yasm_errwarn_propagate(info->errwarns, yasm_symrec_get_decl_line(sym)); - } else if (vis & YASM_SYM_COMMON) { - yasm_error_set(YASM_ERROR_TYPE, - N_("binary object format does not support common variables")); - yasm_errwarn_propagate(info->errwarns, yasm_symrec_get_decl_line(sym)); - } - return 0; -} - -static int -bin_lma_create_group(yasm_section *sect, /*@null@*/ void *d) -{ - bin_objfmt_output_info *info = (bin_objfmt_output_info *)d; - bin_section_data *bsd = yasm_section_get_data(sect, &bin_section_data_cb); - unsigned long align = yasm_section_get_align(sect); - bin_group *group; - - assert(info != NULL); - assert(bsd != NULL); - - group = yasm_xmalloc(sizeof(bin_group)); - group->section = sect; - group->bsd = bsd; - TAILQ_INIT(&group->follow_groups); - - /* Determine section alignment as necessary. */ - if (!bsd->align) - bsd->align = yasm_intnum_create_uint(align > 4 ? align : 4); - else { - yasm_intnum *align_intn = yasm_intnum_create_uint(align); - if (yasm_intnum_compare(align_intn, bsd->align) > 0) { - yasm_warn_set(YASM_WARN_GENERAL, - N_("section `%s' internal align of %lu is greater than `%s' of %lu; using `%s'"), - yasm_section_get_name(sect), - yasm_intnum_get_uint(align_intn), - N_("align"), - yasm_intnum_get_uint(bsd->align), - N_("align")); - yasm_errwarn_propagate(info->errwarns, 0); - } - yasm_intnum_destroy(align_intn); - } - - /* Calculate section integer start. */ - if (bsd->start) { - bsd->istart = yasm_expr_get_intnum(&bsd->start, 0); - if (!bsd->istart) { - yasm_error_set(YASM_ERROR_TOO_COMPLEX, - N_("start expression is too complex")); - yasm_errwarn_propagate(info->errwarns, bsd->start->line); - return 1; - } else - bsd->istart = yasm_intnum_copy(bsd->istart); - } else - bsd->istart = NULL; - - /* Calculate section integer vstart. */ - if (bsd->vstart) { - bsd->ivstart = yasm_expr_get_intnum(&bsd->vstart, 0); - if (!bsd->ivstart) { - yasm_error_set(YASM_ERROR_TOO_COMPLEX, - N_("vstart expression is too complex")); - yasm_errwarn_propagate(info->errwarns, bsd->vstart->line); - return 1; - } else - bsd->ivstart = yasm_intnum_copy(bsd->ivstart); - } else - bsd->ivstart = NULL; - - /* Calculate section integer length. */ - bsd->length = yasm_calc_bc_dist(yasm_section_bcs_first(sect), - yasm_section_bcs_last(sect)); - - TAILQ_INSERT_TAIL(&info->lma_groups, group, link); - return 0; -} - -static int -bin_vma_create_group(yasm_section *sect, /*@null@*/ void *d) -{ - bin_objfmt_output_info *info = (bin_objfmt_output_info *)d; - bin_section_data *bsd = yasm_section_get_data(sect, &bin_section_data_cb); - bin_group *group; - - assert(info != NULL); - assert(bsd != NULL); - - group = yasm_xmalloc(sizeof(bin_group)); - group->section = sect; - group->bsd = bsd; - TAILQ_INIT(&group->follow_groups); - - TAILQ_INSERT_TAIL(&info->vma_groups, group, link); - return 0; -} - -/* Calculates new start address based on alignment constraint. - * Start is modified (rounded up) to the closest aligned value greater than - * what was passed in. - * Align must be a power of 2. - */ -static void -bin_objfmt_align(yasm_intnum *start, const yasm_intnum *align) -{ - /* Because alignment is always a power of two, we can use some bit - * trickery to do this easily. - */ - yasm_intnum *align_intn = - yasm_intnum_create_uint(yasm_intnum_get_uint(align)-1); - yasm_intnum_calc(align_intn, YASM_EXPR_AND, start); - if (!yasm_intnum_is_zero(align_intn)) { - /* start = (start & ~(align-1)) + align; */ - yasm_intnum_set_uint(align_intn, yasm_intnum_get_uint(align)-1); - yasm_intnum_calc(align_intn, YASM_EXPR_NOT, NULL); - yasm_intnum_calc(align_intn, YASM_EXPR_AND, start); - yasm_intnum_set(start, align); - yasm_intnum_calc(start, YASM_EXPR_ADD, align_intn); - } - yasm_intnum_destroy(align_intn); -} - -/* Recursive function to assign start addresses. - * Updates start, last, and vdelta parameters as it goes along. - * The tmp parameter is just a working intnum so one doesn't have to be - * locally allocated for this purpose. - */ -static void -group_assign_start_recurse(bin_group *group, yasm_intnum *start, - yasm_intnum *last, yasm_intnum *vdelta, - yasm_intnum *tmp, yasm_errwarns *errwarns) -{ - bin_group *follow_group; - - /* Determine LMA */ - if (group->bsd->istart) { - yasm_intnum_set(group->bsd->istart, start); - if (group->bsd->align) { - bin_objfmt_align(group->bsd->istart, group->bsd->align); - if (yasm_intnum_compare(start, group->bsd->istart) != 0) { - yasm_warn_set(YASM_WARN_GENERAL, - N_("start inconsistent with align; using aligned value")); - yasm_errwarn_propagate(errwarns, group->bsd->start->line); - } - } - } else { - group->bsd->istart = yasm_intnum_copy(start); - if (group->bsd->align != 0) - bin_objfmt_align(group->bsd->istart, group->bsd->align); - } - - /* Determine VMA if either just valign specified or if no v* specified */ - if (!group->bsd->vstart) { - if (!group->bsd->vfollows && !group->bsd->valign) { - /* No v* specified, set VMA=LMA+vdelta. */ - group->bsd->ivstart = yasm_intnum_copy(group->bsd->istart); - yasm_intnum_calc(group->bsd->ivstart, YASM_EXPR_ADD, vdelta); - } else if (!group->bsd->vfollows) { - /* Just valign specified: set VMA=LMA+vdelta, align VMA, then add - * delta between unaligned and aligned to vdelta parameter. - */ - group->bsd->ivstart = yasm_intnum_copy(group->bsd->istart); - yasm_intnum_calc(group->bsd->ivstart, YASM_EXPR_ADD, vdelta); - yasm_intnum_set(tmp, group->bsd->ivstart); - bin_objfmt_align(group->bsd->ivstart, group->bsd->valign); - yasm_intnum_calc(vdelta, YASM_EXPR_ADD, group->bsd->ivstart); - yasm_intnum_calc(vdelta, YASM_EXPR_SUB, tmp); - } - } - - /* Find the maximum end value */ - yasm_intnum_set(tmp, group->bsd->istart); - yasm_intnum_calc(tmp, YASM_EXPR_ADD, group->bsd->length); - if (yasm_intnum_compare(tmp, last) > 0) /* tmp > last */ - yasm_intnum_set(last, tmp); - - /* Recurse for each following group. */ - TAILQ_FOREACH(follow_group, &group->follow_groups, link) { - /* Following sections have to follow this one, - * so add length to start. - */ - yasm_intnum_set(start, group->bsd->istart); - yasm_intnum_calc(start, YASM_EXPR_ADD, group->bsd->length); - - group_assign_start_recurse(follow_group, start, last, vdelta, tmp, - errwarns); - } -} - -/* Recursive function to assign start addresses. - * Updates start parameter as it goes along. - * The tmp parameter is just a working intnum so one doesn't have to be - * locally allocated for this purpose. - */ -static void -group_assign_vstart_recurse(bin_group *group, yasm_intnum *start, - yasm_errwarns *errwarns) -{ - bin_group *follow_group; - - /* Determine VMA section alignment as necessary. - * Default to LMA alignment if not specified. - */ - if (!group->bsd->valign) - group->bsd->valign = yasm_intnum_copy(group->bsd->align); - else { - unsigned long align = yasm_section_get_align(group->section); - yasm_intnum *align_intn = yasm_intnum_create_uint(align); - if (yasm_intnum_compare(align_intn, group->bsd->valign) > 0) { - yasm_warn_set(YASM_WARN_GENERAL, - N_("section `%s' internal align of %lu is greater than `%s' of %lu; using `%s'"), - yasm_section_get_name(group->section), - yasm_intnum_get_uint(align_intn), - N_("valign"), - yasm_intnum_get_uint(group->bsd->valign), - N_("valign")); - yasm_errwarn_propagate(errwarns, 0); - } - yasm_intnum_destroy(align_intn); - } - - /* Determine VMA */ - if (group->bsd->ivstart) { - yasm_intnum_set(group->bsd->ivstart, start); - if (group->bsd->valign) { - bin_objfmt_align(group->bsd->ivstart, group->bsd->valign); - if (yasm_intnum_compare(start, group->bsd->ivstart) != 0) { - yasm_error_set(YASM_ERROR_VALUE, - N_("vstart inconsistent with valign")); - yasm_errwarn_propagate(errwarns, group->bsd->vstart->line); - } - } - } else { - group->bsd->ivstart = yasm_intnum_copy(start); - if (group->bsd->valign) - bin_objfmt_align(group->bsd->ivstart, group->bsd->valign); - } - - /* Recurse for each following group. */ - TAILQ_FOREACH(follow_group, &group->follow_groups, link) { - /* Following sections have to follow this one, - * so add length to start. - */ - yasm_intnum_set(start, group->bsd->ivstart); - yasm_intnum_calc(start, YASM_EXPR_ADD, group->bsd->length); - - group_assign_vstart_recurse(follow_group, start, errwarns); - } -} - -static /*@null@*/ const yasm_intnum * -get_ssym_value(yasm_symrec *sym) -{ - bin_symrec_data *bsymd = yasm_symrec_get_data(sym, &bin_symrec_data_cb); - bin_section_data *bsd; - - if (!bsymd) - return NULL; - - bsd = yasm_section_get_data(bsymd->section, &bin_section_data_cb); - assert(bsd != NULL); - - switch (bsymd->which) { - case SSYM_START: return bsd->istart; - case SSYM_VSTART: return bsd->ivstart; - case SSYM_LENGTH: return bsd->length; - } - return NULL; -} - static /*@only@*/ yasm_expr * bin_objfmt_expr_xform(/*@returned@*/ /*@only@*/ yasm_expr *e, - /*@unused@*/ /*@null@*/ void *d) + /*@unused@*/ /*@null@*/ void *d) { int i; - for (i=0; inumterms; i++) { - /*@dependent@*/ yasm_section *sect; - /*@dependent@*/ /*@null@*/ yasm_bytecode *precbc; - /*@null@*/ yasm_intnum *dist; - /*@null@*/ const yasm_intnum *ssymval; + /*@dependent@*/ yasm_section *sect; + /*@dependent@*/ /*@null@*/ yasm_bytecode *precbc; + /*@null@*/ yasm_intnum *dist; + for (i=0; inumterms; i++) { /* Transform symrecs or precbcs that reference sections into - * vstart + intnum(dist). - */ + * start expr + intnum(dist). + */ if (((e->terms[i].type == YASM_EXPR_SYM && yasm_symrec_get_label(e->terms[i].data.sym, &precbc)) || (e->terms[i].type == YASM_EXPR_PRECBC && (precbc = e->terms[i].data.precbc))) && - (sect = yasm_bc_get_section(precbc)) && - (dist = yasm_calc_bc_dist(yasm_section_bcs_first(sect), precbc))) { - bin_section_data *bsd; - bsd = yasm_section_get_data(sect, &bin_section_data_cb); - assert(bsd != NULL); - yasm_intnum_calc(dist, YASM_EXPR_ADD, bsd->ivstart); - e->terms[i].type = YASM_EXPR_INT; - e->terms[i].data.intn = dist; - } - - /* Transform our special symrecs into the appropriate value */ - if (e->terms[i].type == YASM_EXPR_SYM && - (ssymval = get_ssym_value(e->terms[i].data.sym))) { - e->terms[i].type = YASM_EXPR_INT; - e->terms[i].data.intn = yasm_intnum_copy(ssymval); - } + (sect = yasm_bc_get_section(precbc)) && + (dist = yasm_calc_bc_dist(yasm_section_bcs_first(sect), precbc))) { + const yasm_expr *start = yasm_section_get_start(sect); + e->terms[i].type = YASM_EXPR_EXPR; + e->terms[i].data.expn = + yasm_expr_create(YASM_EXPR_ADD, + yasm_expr_expr(yasm_expr_copy(start)), + yasm_expr_int(dist), e->line); + } } return e; } -typedef struct map_output_info { - /* address width */ - int bytes; - - /* intnum output static data areas */ - unsigned char *buf; - yasm_intnum *intn; - - /* symrec output information */ - unsigned long count; - yasm_section *section; /* NULL for EQUs */ - - yasm_object *object; /* object */ - FILE *f; /* map output file */ -} map_output_info; - -static int -map_prescan_bytes(yasm_section *sect, void *d) -{ - bin_section_data *bsd = yasm_section_get_data(sect, &bin_section_data_cb); - map_output_info *info = (map_output_info *)d; - - assert(bsd != NULL); - assert(info != NULL); - - while (!yasm_intnum_check_size(bsd->length, info->bytes * 8, 0, 0)) - info->bytes *= 2; - while (!yasm_intnum_check_size(bsd->istart, info->bytes * 8, 0, 0)) - info->bytes *= 2; - while (!yasm_intnum_check_size(bsd->ivstart, info->bytes * 8, 0, 0)) - info->bytes *= 2; - - return 0; -} - -static void -map_print_intnum(const yasm_intnum *intn, map_output_info *info) -{ - size_t i; - yasm_intnum_get_sized(intn, info->buf, info->bytes, info->bytes*8, 0, 0, - 0); - for (i=info->bytes; i != 0; i--) - fprintf(info->f, "%02X", info->buf[i-1]); -} - -static void -map_sections_summary(bin_groups *groups, map_output_info *info) -{ - bin_group *group; - TAILQ_FOREACH(group, groups, link) { - bin_section_data *bsd = group->bsd; - - assert(bsd != NULL); - assert(info != NULL); - - map_print_intnum(bsd->ivstart, info); - fprintf(info->f, " "); - - yasm_intnum_set(info->intn, bsd->ivstart); - yasm_intnum_calc(info->intn, YASM_EXPR_ADD, bsd->length); - map_print_intnum(info->intn, info); - fprintf(info->f, " "); - - map_print_intnum(bsd->istart, info); - fprintf(info->f, " "); - - yasm_intnum_set(info->intn, bsd->istart); - yasm_intnum_calc(info->intn, YASM_EXPR_ADD, bsd->length); - map_print_intnum(info->intn, info); - fprintf(info->f, " "); - - map_print_intnum(bsd->length, info); - fprintf(info->f, " "); - - fprintf(info->f, "%-*s", 10, bsd->bss ? "nobits" : "progbits"); - fprintf(info->f, "%s\n", yasm_section_get_name(group->section)); - - /* Recurse to loop through follow groups */ - map_sections_summary(&group->follow_groups, info); - } -} - -static void -map_sections_detail(bin_groups *groups, map_output_info *info) -{ - bin_group *group; - TAILQ_FOREACH(group, groups, link) { - bin_section_data *bsd = group->bsd; - size_t i; - const char *s; - - s = yasm_section_get_name(group->section); - fprintf(info->f, "---- Section %s ", s); - for (i=0; i<(65-strlen(s)); i++) - fputc('-', info->f); - - fprintf(info->f, "\n\nclass: %s", - bsd->bss ? "nobits" : "progbits"); - fprintf(info->f, "\nlength: "); - map_print_intnum(bsd->length, info); - fprintf(info->f, "\nstart: "); - map_print_intnum(bsd->istart, info); - fprintf(info->f, "\nalign: "); - map_print_intnum(bsd->align, info); - fprintf(info->f, "\nfollows: %s", - bsd->follows ? bsd->follows : "not defined"); - fprintf(info->f, "\nvstart: "); - map_print_intnum(bsd->ivstart, info); - fprintf(info->f, "\nvalign: "); - map_print_intnum(bsd->valign, info); - fprintf(info->f, "\nvfollows: %s\n\n", - bsd->vfollows ? bsd->vfollows : "not defined"); - - /* Recurse to loop through follow groups */ - map_sections_detail(&group->follow_groups, info); - } -} - -static int -map_symrec_count(yasm_symrec *sym, void *d) -{ - map_output_info *info = (map_output_info *)d; - /*@dependent@*/ yasm_bytecode *precbc; - - assert(info != NULL); - - /* TODO: autodetect wider size */ - if (!info->section && yasm_symrec_get_equ(sym)) { - info->count++; - } else if (yasm_symrec_get_label(sym, &precbc) && - yasm_bc_get_section(precbc) == info->section) { - info->count++; - } - return 0; -} - -static int -map_symrec_output(yasm_symrec *sym, void *d) -{ - map_output_info *info = (map_output_info *)d; - const yasm_expr *equ; - /*@dependent@*/ yasm_bytecode *precbc; - /*@only@*/ char *name = yasm_symrec_get_global_name(sym, info->object); - - assert(info != NULL); - - if (!info->section && (equ = yasm_symrec_get_equ(sym))) { - yasm_expr *realequ = yasm_expr_copy(equ); - realequ = yasm_expr__level_tree - (realequ, 1, 1, 1, 0, bin_objfmt_expr_xform, NULL); - yasm_intnum_set(info->intn, yasm_expr_get_intnum(&realequ, 0)); - yasm_expr_destroy(realequ); - map_print_intnum(info->intn, info); - fprintf(info->f, " %s\n", name); - } else if (yasm_symrec_get_label(sym, &precbc) && - yasm_bc_get_section(precbc) == info->section) { - bin_section_data *bsd = - yasm_section_get_data(info->section, &bin_section_data_cb); - - /* Real address */ - yasm_intnum_set_uint(info->intn, yasm_bc_next_offset(precbc)); - yasm_intnum_calc(info->intn, YASM_EXPR_ADD, bsd->istart); - map_print_intnum(info->intn, info); - fprintf(info->f, " "); - - /* Virtual address */ - yasm_intnum_set_uint(info->intn, yasm_bc_next_offset(precbc)); - yasm_intnum_calc(info->intn, YASM_EXPR_ADD, bsd->ivstart); - map_print_intnum(info->intn, info); - - /* Name */ - fprintf(info->f, " %s\n", name); - } - yasm_xfree(name); - return 0; -} - -static void -map_sections_symbols(bin_groups *groups, map_output_info *info) -{ - bin_group *group; - TAILQ_FOREACH(group, groups, link) { - info->count = 0; - info->section = group->section; - yasm_symtab_traverse(info->object->symtab, info, map_symrec_count); - - if (info->count > 0) { - const char *s = yasm_section_get_name(group->section); - size_t i; - fprintf(info->f, "---- Section %s ", s); - for (i=0; i<(65-strlen(s)); i++) - fputc('-', info->f); - fprintf(info->f, "\n\n%-*s%-*s%s\n", - info->bytes*2+2, "Real", - info->bytes*2+2, "Virtual", - "Name"); - yasm_symtab_traverse(info->object->symtab, info, - map_symrec_output); - fprintf(info->f, "\n\n"); - } - - /* Recurse to loop through follow groups */ - map_sections_symbols(&group->follow_groups, info); - } -} - -static void -output_map(bin_objfmt_output_info *info) -{ - yasm_objfmt_bin *objfmt_bin = (yasm_objfmt_bin *)info->object->objfmt; - FILE *f; - int i; - map_output_info mapinfo; - - if (objfmt_bin->map_flags == NO_MAP) - return; - - if (objfmt_bin->map_flags == MAP_NONE) - objfmt_bin->map_flags = MAP_BRIEF; /* default to brief */ - - if (!objfmt_bin->map_filename) - f = stdout; /* default to stdout */ - else { - f = fopen(objfmt_bin->map_filename, "wt"); - if (!f) { - yasm_warn_set(YASM_WARN_GENERAL, - N_("unable to open map file `%s'"), - objfmt_bin->map_filename); - yasm_errwarn_propagate(info->errwarns, 0); - return; - } - } - - mapinfo.object = info->object; - mapinfo.f = f; - - /* Temporary intnum */ - mapinfo.intn = info->tmp_intn; - - /* Prescan all values to figure out what width we should make the output - * fields. Start with a minimum of 4. - */ - mapinfo.bytes = 4; - while (!yasm_intnum_check_size(info->origin, mapinfo.bytes * 8, 0, 0)) - mapinfo.bytes *= 2; - yasm_object_sections_traverse(info->object, &mapinfo, map_prescan_bytes); - mapinfo.buf = yasm_xmalloc(mapinfo.bytes); - - fprintf(f, "\n- YASM Map file "); - for (i=0; i<63; i++) - fputc('-', f); - fprintf(f, "\n\nSource file: %s\n", info->object->src_filename); - if (getenv("YASM_TEST_SUITE")) { - const char *filename = info->object->obj_filename; - const char *next_filename; - while ((next_filename = strpbrk(filename, "/\\"))) - filename = next_filename + 1; - fprintf(f, "Output file: %s\n\n", filename); - } else { - fprintf(f, "Output file: %s\n\n", info->object->obj_filename); - } - - fprintf(f, "-- Program origin "); - for (i=0; i<61; i++) - fputc('-', f); - fprintf(f, "\n\n"); - map_print_intnum(info->origin, &mapinfo); - fprintf(f, "\n\n"); - - if (objfmt_bin->map_flags & MAP_BRIEF) { - fprintf(f, "-- Sections (summary) "); - for (i=0; i<57; i++) - fputc('-', f); - fprintf(f, "\n\n%-*s%-*s%-*s%-*s%-*s%-*s%s\n", - mapinfo.bytes*2+2, "Vstart", - mapinfo.bytes*2+2, "Vstop", - mapinfo.bytes*2+2, "Start", - mapinfo.bytes*2+2, "Stop", - mapinfo.bytes*2+2, "Length", - 10, "Class", "Name"); - - map_sections_summary(&info->lma_groups, &mapinfo); - fprintf(f, "\n"); - } - - if (objfmt_bin->map_flags & MAP_SECTIONS) { - fprintf(f, "-- Sections (detailed) "); - for (i=0; i<56; i++) - fputc('-', f); - fprintf(f, "\n\n"); - map_sections_detail(&info->lma_groups, &mapinfo); - } - - if (objfmt_bin->map_flags & MAP_SYMBOLS) { - fprintf(f, "-- Symbols "); - for (i=0; i<68; i++) - fputc('-', f); - fprintf(f, "\n\n"); - - /* We do two passes for EQU and each section; the first pass - * determines the byte width to use for the value and whether any - * symbols are present, the second pass actually outputs the text. - */ - - /* EQUs */ - mapinfo.count = 0; - mapinfo.section = NULL; - yasm_symtab_traverse(info->object->symtab, &mapinfo, map_symrec_count); - - if (mapinfo.count > 0) { - fprintf(f, "---- No Section "); - for (i=0; i<63; i++) - fputc('-', f); - fprintf(f, "\n\n%-*s%s\n", mapinfo.bytes*2+2, "Value", "Name"); - yasm_symtab_traverse(info->object->symtab, &mapinfo, - map_symrec_output); - fprintf(f, "\n\n"); - } - - /* Other sections */ - map_sections_symbols(&info->lma_groups, &mapinfo); - } - - if (f != stdout) - fclose(f); - - yasm_xfree(mapinfo.buf); -} - -/* Check for LMA overlap using a simple N^2 algorithm. */ -static int -check_lma_overlap(yasm_section *sect, /*@null@*/ void *d) -{ - bin_section_data *bsd, *bsd2; - yasm_section *other = (yasm_section *)d; - yasm_intnum *overlap; - - if (!d) - return yasm_object_sections_traverse(yasm_section_get_object(sect), - sect, check_lma_overlap); - if (sect == other) - return 0; - - bsd = yasm_section_get_data(sect, &bin_section_data_cb); - bsd2 = yasm_section_get_data(other, &bin_section_data_cb); - - if (yasm_intnum_is_zero(bsd->length) || - yasm_intnum_is_zero(bsd2->length)) - return 0; - - if (yasm_intnum_compare(bsd->istart, bsd2->istart) <= 0) { - overlap = yasm_intnum_copy(bsd->istart); - yasm_intnum_calc(overlap, YASM_EXPR_ADD, bsd->length); - yasm_intnum_calc(overlap, YASM_EXPR_SUB, bsd2->istart); - } else { - overlap = yasm_intnum_copy(bsd2->istart); - yasm_intnum_calc(overlap, YASM_EXPR_ADD, bsd2->length); - yasm_intnum_calc(overlap, YASM_EXPR_SUB, bsd->istart); - } - - if (yasm_intnum_sign(overlap) > 0) { - yasm_error_set(YASM_ERROR_GENERAL, - N_("sections `%s' and `%s' overlap by %lu bytes"), - yasm_section_get_name(sect), - yasm_section_get_name(other), - yasm_intnum_get_uint(overlap)); - yasm_intnum_destroy(overlap); - return -1; - } - - yasm_intnum_destroy(overlap); - return 0; -} - static int bin_objfmt_output_value(yasm_value *value, unsigned char *buf, - unsigned int destsize, - /*@unused@*/ unsigned long offset, yasm_bytecode *bc, - int warn, /*@null@*/ void *d) + unsigned int destsize, + /*@unused@*/ unsigned long offset, yasm_bytecode *bc, + int warn, /*@null@*/ void *d) { /*@null@*/ bin_objfmt_output_info *info = (bin_objfmt_output_info *)d; /*@dependent@*/ /*@null@*/ yasm_bytecode *precbc; @@ -915,9 +138,8 @@ bin_objfmt_output_value(yasm_value *value, unsigned char *buf, /* Binary objects we need to resolve against object, not against section. */ if (value->rel) { - unsigned int rshift = (unsigned int)value->rshift; - yasm_expr *syme; - /*@null@*/ const yasm_intnum *ssymval; + unsigned int rshift = (unsigned int)value->rshift; + yasm_expr *syme; if (yasm_symrec_is_abs(value->rel)) { syme = yasm_expr_create_ident(yasm_expr_int( @@ -925,9 +147,6 @@ bin_objfmt_output_value(yasm_value *value, unsigned char *buf, } else if (yasm_symrec_get_label(value->rel, &precbc) && (sect = yasm_bc_get_section(precbc))) { syme = yasm_expr_create_ident(yasm_expr_sym(value->rel), bc->line); - } else if ((ssymval = get_ssym_value(value->rel))) { - syme = yasm_expr_create_ident(yasm_expr_int( - yasm_intnum_copy(ssymval)), bc->line); } else goto done; @@ -941,42 +160,42 @@ bin_objfmt_output_value(yasm_value *value, unsigned char *buf, yasm_expr_expr(sube), bc->line); value->curpos_rel = 0; value->ip_rel = 0; - } + } else - if (value->rshift > 0) + if (value->rshift > 0) syme = yasm_expr_create(YASM_EXPR_SHR, yasm_expr_expr(syme), - yasm_expr_int(yasm_intnum_create_uint(rshift)), bc->line); + yasm_expr_int(yasm_intnum_create_uint(rshift)), bc->line); /* Add into absolute portion */ - if (!value->abs) - value->abs = syme; - else - value->abs = - yasm_expr_create(YASM_EXPR_ADD, yasm_expr_expr(value->abs), - yasm_expr_expr(syme), bc->line); - value->rel = NULL; - value->rshift = 0; + if (!value->abs) + value->abs = syme; + else + value->abs = + yasm_expr_create(YASM_EXPR_ADD, yasm_expr_expr(value->abs), + yasm_expr_expr(syme), bc->line); + value->rel = NULL; + value->rshift = 0; } done: /* Simplify absolute portion of value, transforming symrecs */ if (value->abs) - value->abs = yasm_expr__level_tree - (value->abs, 1, 1, 1, 0, bin_objfmt_expr_xform, NULL); + value->abs = yasm_expr__level_tree + (value->abs, 1, 1, 1, 0, bin_objfmt_expr_xform, NULL); /* Output */ switch (yasm_value_output_basic(value, buf, destsize, bc, warn, - info->object->arch)) { - case -1: - return 1; - case 0: - break; - default: - return 0; + info->object->arch)) { + case -1: + return 1; + case 0: + break; + default: + return 0; } /* Couldn't output, assume it contains an external reference. */ yasm_error_set(YASM_ERROR_GENERAL, - N_("binary object format does not support external references")); + N_("binary object format does not support external references")); return 1; } @@ -991,438 +210,173 @@ bin_objfmt_output_bytecode(yasm_bytecode *bc, /*@null@*/ void *d) assert(info != NULL); bigbuf = yasm_bc_tobytes(bc, info->buf, &size, &gap, info, - bin_objfmt_output_value, NULL); + bin_objfmt_output_value, NULL); /* Don't bother doing anything else if size ended up being 0. */ if (size == 0) { - if (bigbuf) - yasm_xfree(bigbuf); - return 0; + if (bigbuf) + yasm_xfree(bigbuf); + return 0; } /* Warn that gaps are converted to 0 and write out the 0's. */ if (gap) { - unsigned long left; - yasm_warn_set(YASM_WARN_UNINIT_CONTENTS, - N_("uninitialized space declared in code/data section: zeroing")); - /* Write out in chunks */ - memset(info->buf, 0, REGULAR_OUTBUF_SIZE); - left = size; - while (left > REGULAR_OUTBUF_SIZE) { - fwrite(info->buf, REGULAR_OUTBUF_SIZE, 1, info->f); - left -= REGULAR_OUTBUF_SIZE; - } - fwrite(info->buf, left, 1, info->f); + unsigned long left; + yasm_warn_set(YASM_WARN_UNINIT_CONTENTS, + N_("uninitialized space declared in code/data section: zeroing")); + /* Write out in chunks */ + memset(info->buf, 0, REGULAR_OUTBUF_SIZE); + left = size; + while (left > REGULAR_OUTBUF_SIZE) { + fwrite(info->buf, REGULAR_OUTBUF_SIZE, 1, info->f); + left -= REGULAR_OUTBUF_SIZE; + } + fwrite(info->buf, left, 1, info->f); } else { - /* Output buf (or bigbuf if non-NULL) to file */ - fwrite(bigbuf ? bigbuf : info->buf, (size_t)size, 1, info->f); + /* Output buf (or bigbuf if non-NULL) to file */ + fwrite(bigbuf ? bigbuf : info->buf, (size_t)size, 1, info->f); } /* If bigbuf was allocated, free it */ if (bigbuf) - yasm_xfree(bigbuf); - - return 0; -} - -/* Check to ensure bytecode is res* (for BSS sections) */ -static int -bin_objfmt_no_output_bytecode(yasm_bytecode *bc, /*@null@*/ void *d) -{ - /*@null@*/ bin_objfmt_output_info *info = (bin_objfmt_output_info *)d; - /*@null@*/ /*@only@*/ unsigned char *bigbuf; - unsigned long size = REGULAR_OUTBUF_SIZE; - int gap; - - assert(info != NULL); - - bigbuf = yasm_bc_tobytes(bc, info->buf, &size, &gap, info, - bin_objfmt_output_value, NULL); - - /* If bigbuf was allocated, free it */ - if (bigbuf) - yasm_xfree(bigbuf); - - /* Don't bother doing anything else if size ended up being 0. */ - if (size == 0) - return 0; - - /* Warn if not a gap. */ - if (!gap) { - yasm_warn_set(YASM_WARN_GENERAL, - N_("initialized space declared in nobits section: ignoring")); - } + yasm_xfree(bigbuf); return 0; } static int -bin_objfmt_output_section(yasm_section *sect, /*@null@*/ void *d) +bin_objfmt_check_sym(yasm_symrec *sym, /*@null@*/ void *d) { - bin_section_data *bsd = yasm_section_get_data(sect, &bin_section_data_cb); /*@null@*/ bin_objfmt_output_info *info = (bin_objfmt_output_info *)d; - - assert(bsd != NULL); + yasm_sym_vis vis = yasm_symrec_get_visibility(sym); assert(info != NULL); - if (bsd->bss) { - yasm_section_bcs_traverse(sect, info->errwarns, - info, bin_objfmt_no_output_bytecode); - } else { - yasm_intnum_set(info->tmp_intn, bsd->istart); - yasm_intnum_calc(info->tmp_intn, YASM_EXPR_SUB, info->origin); - if (yasm_intnum_sign(info->tmp_intn) < 0) { - yasm_error_set(YASM_ERROR_VALUE, - N_("section `%s' starts before origin (ORG)"), - yasm_section_get_name(sect)); - yasm_errwarn_propagate(info->errwarns, 0); - return 0; - } - if (!yasm_intnum_check_size(info->tmp_intn, sizeof(long)*8, 0, 1)) { - yasm_error_set(YASM_ERROR_VALUE, - N_("section `%s' start value too large"), - yasm_section_get_name(sect)); - yasm_errwarn_propagate(info->errwarns, 0); - return 0; - } - if (fseek(info->f, yasm_intnum_get_int(info->tmp_intn) + info->start, - SEEK_SET) < 0) - yasm__fatal(N_("could not seek on output file")); - yasm_section_bcs_traverse(sect, info->errwarns, - info, bin_objfmt_output_bytecode); + if (vis & YASM_SYM_EXTERN) { + yasm_warn_set(YASM_WARN_GENERAL, + N_("binary object format does not support extern variables")); + yasm_errwarn_propagate(info->errwarns, yasm_symrec_get_decl_line(sym)); + } else if (vis & YASM_SYM_GLOBAL) { + yasm_warn_set(YASM_WARN_GENERAL, + N_("binary object format does not support global variables")); + yasm_errwarn_propagate(info->errwarns, yasm_symrec_get_decl_line(sym)); + } else if (vis & YASM_SYM_COMMON) { + yasm_error_set(YASM_ERROR_TYPE, + N_("binary object format does not support common variables")); + yasm_errwarn_propagate(info->errwarns, yasm_symrec_get_decl_line(sym)); } - return 0; } -static void -bin_objfmt_cleanup(bin_objfmt_output_info *info) -{ - bin_group *group, *group_temp; - - yasm_xfree(info->buf); - yasm_intnum_destroy(info->origin); - yasm_intnum_destroy(info->tmp_intn); - - TAILQ_FOREACH_SAFE(group, &info->lma_groups, link, group_temp) - bin_group_destroy(group); - - TAILQ_FOREACH_SAFE(group, &info->vma_groups, link, group_temp) - bin_group_destroy(group); -} - static void bin_objfmt_output(yasm_object *object, FILE *f, /*@unused@*/ int all_syms, - yasm_errwarns *errwarns) + yasm_errwarns *errwarns) { - yasm_objfmt_bin *objfmt_bin = (yasm_objfmt_bin *)object->objfmt; + /*@observer@*/ /*@null@*/ yasm_section *text, *data, *bss, *prevsect; + /*@null@*/ yasm_expr *startexpr; + /*@dependent@*/ /*@null@*/ const yasm_intnum *startnum; + unsigned long start = 0, textstart = 0, datastart = 0; + unsigned long textlen = 0, textpad = 0, datalen = 0, datapad = 0; + unsigned long *prevsectlenptr, *prevsectpadptr; + unsigned long i; bin_objfmt_output_info info; - bin_group *group, *lma_group, *vma_group, *group_temp; - yasm_intnum *start, *last, *vdelta; - bin_groups unsorted_groups, bss_groups; - - info.start = ftell(f); - - /* Set ORG to 0 unless otherwise specified */ - if (objfmt_bin->org) { - info.origin = yasm_expr_get_intnum(&objfmt_bin->org, 0); - if (!info.origin) { - yasm_error_set(YASM_ERROR_TOO_COMPLEX, - N_("ORG expression is too complex")); - yasm_errwarn_propagate(errwarns, objfmt_bin->org->line); - return; - } - if (yasm_intnum_sign(info.origin) < 0) { - yasm_error_set(YASM_ERROR_VALUE, N_("ORG expression is negative")); - yasm_errwarn_propagate(errwarns, objfmt_bin->org->line); - return; - } - info.origin = yasm_intnum_copy(info.origin); - } else - info.origin = yasm_intnum_create_uint(0); info.object = object; info.errwarns = errwarns; info.f = f; info.buf = yasm_xmalloc(REGULAR_OUTBUF_SIZE); - info.tmp_intn = yasm_intnum_create_uint(0); - TAILQ_INIT(&info.lma_groups); - TAILQ_INIT(&info.vma_groups); /* Check symbol table */ yasm_symtab_traverse(object->symtab, &info, bin_objfmt_check_sym); - /* Create section groups */ - if (yasm_object_sections_traverse(object, &info, bin_lma_create_group)) { - bin_objfmt_cleanup(&info); - return; /* error detected */ - } + text = yasm_object_find_general(object, ".text"); + data = yasm_object_find_general(object, ".data"); + bss = yasm_object_find_general(object, ".bss"); - /* Determine section order according to LMA. - * Sections can be ordered either by (priority): - * - follows - * - start - * - progbits/nobits setting - * - order in the input file + if (!text) + yasm_internal_error(N_("No `.text' section in bin objfmt output")); + + /* First determine the actual starting offsets for .data and .bss. + * As the order in the file is .text -> .data -> .bss (not present), + * use the last bytecode in .text (and the .text section start) to + * determine the starting offset in .data, and likewise for .bss. + * Also compensate properly for alignment. */ - /* Look at each group with follows specified, and find the section - * that group is supposed to follow. - */ - TAILQ_FOREACH_SAFE(lma_group, &info.lma_groups, link, group_temp) { - if (lma_group->bsd->follows) { - bin_group *found; - /* Need to find group containing section this section follows. */ - found = - find_group_by_name(&info.lma_groups, lma_group->bsd->follows); - if (!found) { - yasm_error_set(YASM_ERROR_VALUE, - N_("section `%s' follows an invalid or unknown section `%s'"), - yasm_section_get_name(lma_group->section), - lma_group->bsd->follows); - yasm_errwarn_propagate(errwarns, 0); - bin_objfmt_cleanup(&info); - return; - } + /* Find out the start of .text */ + startexpr = yasm_expr_copy(yasm_section_get_start(text)); + assert(startexpr != NULL); + startnum = yasm_expr_get_intnum(&startexpr, 0); + if (!startnum) { + yasm_error_set(YASM_ERROR_TOO_COMPLEX, + N_("ORG expression too complex")); + yasm_errwarn_propagate(errwarns, startexpr->line); + return; + } + start = yasm_intnum_get_uint(startnum); + yasm_expr_destroy(startexpr); + info.abs_start = start; + textstart = start; - /* Check for loops */ - if (lma_group->section == found->section || - find_group_by_section(&lma_group->follow_groups, - found->section)) { - yasm_error_set(YASM_ERROR_VALUE, - N_("follows loop between section `%s' and section `%s'"), - yasm_section_get_name(lma_group->section), - yasm_section_get_name(found->section)); - yasm_errwarn_propagate(errwarns, 0); - bin_objfmt_cleanup(&info); - return; - } - - /* Remove this section from main lma groups list */ - TAILQ_REMOVE(&info.lma_groups, lma_group, link); - /* Add it after the section it's supposed to follow. */ - TAILQ_INSERT_TAIL(&found->follow_groups, lma_group, link); - } + /* Align .data and .bss (if present) by adjusting their starts. */ + prevsect = text; + prevsectlenptr = &textlen; + prevsectpadptr = &textpad; + if (data) { + start = bin_objfmt_align_section(data, prevsect, start, + prevsectlenptr, prevsectpadptr); + yasm_section_set_start(data, yasm_expr_create_ident( + yasm_expr_int(yasm_intnum_create_uint(start)), 0), 0); + datastart = start; + prevsect = data; + prevsectlenptr = &datalen; + prevsectpadptr = &datapad; + } + if (bss) { + start = bin_objfmt_align_section(bss, prevsect, start, + prevsectlenptr, prevsectpadptr); + yasm_section_set_start(bss, yasm_expr_create_ident( + yasm_expr_int(yasm_intnum_create_uint(start)), 0), 0); } - /* Sort the top-level groups according to their start address. - * Use Shell sort for ease of implementation. - * If no start address is specified for a section, don't change the order, - * and move BSS sections to a separate list so they can be moved to the - * end of the lma list after all other sections are sorted. - */ - unsorted_groups = info.lma_groups; /* structure copy */ - TAILQ_INIT(&info.lma_groups); - TAILQ_INIT(&bss_groups); - TAILQ_FOREACH_SAFE(lma_group, &unsorted_groups, link, group_temp) { - bin_group *before; + /* Output .text first. */ + info.sect = text; + info.start = textstart; + yasm_section_bcs_traverse(text, errwarns, &info, + bin_objfmt_output_bytecode); - if (!lma_group->bsd->istart) { - if (lma_group->bsd->bss) - TAILQ_INSERT_TAIL(&bss_groups, lma_group, link); - else - TAILQ_INSERT_TAIL(&info.lma_groups, lma_group, link); - continue; - } + /* If .data is present, output it */ + if (data) { + /* Add padding to align .data. Just use a for loop, as this will + * seldom be very many bytes. + */ + for (i=0; ibsd->istart) - continue; - if (yasm_intnum_compare(group->bsd->istart, - lma_group->bsd->istart) > 0) { - before = group; - break; - } - } - if (before) - TAILQ_INSERT_BEFORE(before, lma_group, link); - else - TAILQ_INSERT_TAIL(&info.lma_groups, lma_group, link); + /* Output .data bytecodes */ + info.sect = data; + info.start = datastart; + yasm_section_bcs_traverse(data, errwarns, + &info, bin_objfmt_output_bytecode); } - /* Move the pure-BSS sections to the end of the LMA list. */ - TAILQ_FOREACH_SAFE(group, &bss_groups, link, group_temp) - TAILQ_INSERT_TAIL(&info.lma_groups, group, link); - TAILQ_INIT(&bss_groups); /* For sanity */ + /* If .bss is present, check it for non-reserve bytecodes */ - /* Assign a LMA start address to every section. - * Also assign VMA=LMA unless otherwise specified. - * - * We need to assign VMA=LMA here (while walking the tree) for the case: - * sect1 start=0 (size=0x11) - * sect2 follows=sect1 valign=16 (size=0x104) - * sect3 follows=sect2 valign=16 - * Where the valign of sect2 will result in a sect3 vaddr higher than a - * naive segment-by-segment interpretation (where sect3 and sect2 would - * have a VMA overlap). - * - * Algorithm for VMA=LMA setting: - * Start with delta=0. - * If there's no virtual attributes, we simply set VMA = LMA+delta. - * If there's only valign specified, we set VMA = aligned LMA, and add - * any new alignment difference to delta. - * - * We could do the LMA start and VMA=LMA steps in two separate steps, - * but it's easier to just recurse once. - */ - start = yasm_intnum_copy(info.origin); - last = yasm_intnum_copy(info.origin); - vdelta = yasm_intnum_create_uint(0); - TAILQ_FOREACH(lma_group, &info.lma_groups, link) { - if (lma_group->bsd->istart) - yasm_intnum_set(start, lma_group->bsd->istart); - group_assign_start_recurse(lma_group, start, last, vdelta, - info.tmp_intn, errwarns); - yasm_intnum_set(start, last); - } - yasm_intnum_destroy(last); - yasm_intnum_destroy(vdelta); - /* - * Determine section order according to VMA - */ - - /* Create section groups */ - if (yasm_object_sections_traverse(object, &info, bin_vma_create_group)) { - yasm_intnum_destroy(start); - bin_objfmt_cleanup(&info); - return; /* error detected */ - } - - /* Look at each group with vfollows specified, and find the section - * that group is supposed to follow. - */ - TAILQ_FOREACH_SAFE(vma_group, &info.vma_groups, link, group_temp) { - if (vma_group->bsd->vfollows) { - bin_group *found; - /* Need to find group containing section this section follows. */ - found = find_group_by_name(&info.vma_groups, - vma_group->bsd->vfollows); - if (!found) { - yasm_error_set(YASM_ERROR_VALUE, - N_("section `%s' vfollows an invalid or unknown section `%s'"), - yasm_section_get_name(vma_group->section), - vma_group->bsd->vfollows); - yasm_errwarn_propagate(errwarns, 0); - yasm_intnum_destroy(start); - bin_objfmt_cleanup(&info); - return; - } - - /* Check for loops */ - if (vma_group->section == found->section || - find_group_by_section(&vma_group->follow_groups, - found->section)) { - yasm_error_set(YASM_ERROR_VALUE, - N_("vfollows loop between section `%s' and section `%s'"), - yasm_section_get_name(vma_group->section), - yasm_section_get_name(found->section)); - yasm_errwarn_propagate(errwarns, 0); - bin_objfmt_cleanup(&info); - return; - } - - /* Remove this section from main lma groups list */ - TAILQ_REMOVE(&info.vma_groups, vma_group, link); - /* Add it after the section it's supposed to follow. */ - TAILQ_INSERT_TAIL(&found->follow_groups, vma_group, link); - } - } - - /* Due to the combination of steps above, we now know that all top-level - * groups have integer ivstart: - * Vstart Vfollows Valign Handled by - * No No No group_assign_start_recurse() - * No No Yes group_assign_start_recurse() - * No Yes - vfollows loop (above) - * Yes - - bin_lma_create_group() - */ - TAILQ_FOREACH(vma_group, &info.vma_groups, link) { - yasm_intnum_set(start, vma_group->bsd->ivstart); - group_assign_vstart_recurse(vma_group, start, errwarns); - } - - /* Output map file */ - output_map(&info); - - /* Ensure we don't have overlapping progbits LMAs. - * Use a dumb O(N^2) algorithm as the number of sections is essentially - * always low. - */ - if (yasm_object_sections_traverse(object, NULL, check_lma_overlap)) { - yasm_errwarn_propagate(errwarns, 0); - yasm_intnum_destroy(start); - bin_objfmt_cleanup(&info); - return; - } - - /* Output sections */ - yasm_object_sections_traverse(object, &info, bin_objfmt_output_section); - - /* Clean up */ - yasm_intnum_destroy(start); - bin_objfmt_cleanup(&info); + yasm_xfree(info.buf); } static void bin_objfmt_destroy(yasm_objfmt *objfmt) { - yasm_objfmt_bin *objfmt_bin = (yasm_objfmt_bin *)objfmt; - if (objfmt_bin->map_filename) - yasm_xfree(objfmt_bin->map_filename); - yasm_expr_destroy(objfmt_bin->org); yasm_xfree(objfmt); } static void -define_section_symbol(yasm_symtab *symtab, yasm_section *sect, - const char *sectname, const char *suffix, - enum bin_ssym which, unsigned long line) +bin_objfmt_init_new_section(yasm_object *object, yasm_section *sect, + const char *sectname, unsigned long line) { - yasm_symrec *sym; - bin_symrec_data *bsymd = yasm_xmalloc(sizeof(bin_symrec_data)); - char *symname = yasm_xmalloc(8+strlen(sectname)+strlen(suffix)+1); - - strcpy(symname, "section."); - strcat(symname, sectname); - strcat(symname, suffix); - - bsymd->section = sect; - bsymd->which = which; - - sym = yasm_symtab_declare(symtab, symname, YASM_SYM_EXTERN, line); - yasm_xfree(symname); - yasm_symrec_add_data(sym, &bin_symrec_data_cb, bsymd); -} - -static void -bin_objfmt_init_new_section(yasm_section *sect, unsigned long line) -{ - yasm_object *object = yasm_section_get_object(sect); - const char *sectname = yasm_section_get_name(sect); - /*yasm_objfmt_bin *objfmt_bin = (yasm_objfmt_bin *)object->objfmt;*/ - bin_section_data *data; - - data = yasm_xmalloc(sizeof(bin_section_data)); - data->bss = 0; - data->align = NULL; - data->valign = NULL; - data->start = NULL; - data->vstart = NULL; - data->follows = NULL; - data->vfollows = NULL; - data->istart = NULL; - data->ivstart = NULL; - data->length = NULL; - yasm_section_add_data(sect, &bin_section_data_cb, data); - - define_section_symbol(object->symtab, sect, sectname, ".start", - SSYM_START, line); - define_section_symbol(object->symtab, sect, sectname, ".vstart", - SSYM_VSTART, line); - define_section_symbol(object->symtab, sect, sectname, ".length", - SSYM_LENGTH, line); + yasm_symtab_define_label(object->symtab, sectname, + yasm_section_bcs_first(sect), 1, line); } static yasm_section * @@ -1431,71 +385,32 @@ bin_objfmt_add_default_section(yasm_object *object) yasm_section *retval; int isnew; - retval = yasm_object_get_general(object, ".text", 0, 1, 0, &isnew, 0); - if (isnew) - yasm_section_set_default(retval, 1); + retval = yasm_object_get_general(object, ".text", 0, 16, 1, 0, &isnew, 0); + if (isnew) { + bin_objfmt_init_new_section(object, retval, ".text", 0); + yasm_section_set_default(retval, 1); + } return retval; } -/* GAS-style flags */ -static int -bin_helper_gasflags(void *obj, yasm_valparam *vp, unsigned long line, void *d, - /*@unused@*/ uintptr_t arg) -{ - /* TODO */ - return 0; -} - static /*@observer@*/ /*@null@*/ yasm_section * bin_objfmt_section_switch(yasm_object *object, yasm_valparamhead *valparams, - /*@unused@*/ /*@null@*/ - yasm_valparamhead *objext_valparams, - unsigned long line) + /*@unused@*/ /*@null@*/ + yasm_valparamhead *objext_valparams, + unsigned long line) { yasm_valparam *vp; yasm_section *retval; int isnew; - int flags_override = 0; + unsigned long start; const char *sectname; - bin_section_data *bsd = NULL; - - struct bin_section_switch_data { - /*@only@*/ /*@null@*/ char *follows; - /*@only@*/ /*@null@*/ char *vfollows; - /*@only@*/ /*@null@*/ yasm_expr *start; - /*@only@*/ /*@null@*/ yasm_expr *vstart; - /*@only@*/ /*@null@*/ yasm_intnum *align; - /*@only@*/ /*@null@*/ yasm_intnum *valign; - unsigned long bss; - unsigned long code; - } data; + int resonly = 0; + /*@only@*/ /*@null@*/ yasm_intnum *align_intn = NULL; + unsigned long align = 4; + int have_align = 0; static const yasm_dir_help help[] = { - { "follows", 1, yasm_dir_helper_string, - offsetof(struct bin_section_switch_data, follows), 0 }, - { "vfollows", 1, yasm_dir_helper_string, - offsetof(struct bin_section_switch_data, vfollows), 0 }, - { "start", 1, yasm_dir_helper_expr, - offsetof(struct bin_section_switch_data, start), 0 }, - { "vstart", 1, yasm_dir_helper_expr, - offsetof(struct bin_section_switch_data, vstart), 0 }, - { "align", 1, yasm_dir_helper_intn, - offsetof(struct bin_section_switch_data, align), 0 }, - { "valign", 1, yasm_dir_helper_intn, - offsetof(struct bin_section_switch_data, valign), 0 }, - { "nobits", 0, yasm_dir_helper_flag_set, - offsetof(struct bin_section_switch_data, bss), 1 }, - { "progbits", 0, yasm_dir_helper_flag_set, - offsetof(struct bin_section_switch_data, bss), 0 }, - { "code", 0, yasm_dir_helper_flag_set, - offsetof(struct bin_section_switch_data, code), 1 }, - { "data", 0, yasm_dir_helper_flag_set, - offsetof(struct bin_section_switch_data, code), 0 }, - { "execute", 0, yasm_dir_helper_flag_set, - offsetof(struct bin_section_switch_data, code), 1 }, - { "noexecute", 0, yasm_dir_helper_flag_set, - offsetof(struct bin_section_switch_data, code), 0 }, - { "gasflags", 1, bin_helper_gasflags, 0, 0 } + { "align", 1, yasm_dir_helper_intn, 0, 0 } }; vp = yasm_vps_first(valparams); @@ -1504,285 +419,84 @@ bin_objfmt_section_switch(yasm_object *object, yasm_valparamhead *valparams, return NULL; vp = yasm_vps_next(vp); - retval = yasm_object_find_general(object, sectname); - if (retval) { - bsd = yasm_section_get_data(retval, &bin_section_data_cb); - assert(bsd != NULL); - data.follows = bsd->follows; - data.vfollows = bsd->vfollows; - data.start = bsd->start; - data.vstart = bsd->vstart; - data.align = NULL; - data.valign = NULL; - data.bss = bsd->bss; - data.code = yasm_section_is_code(retval); - } else { - data.follows = NULL; - data.vfollows = NULL; - data.start = NULL; - data.vstart = NULL; - data.align = NULL; - data.valign = NULL; - data.bss = strcmp(sectname, ".bss") == 0; - data.code = strcmp(sectname, ".text") == 0; - } + /* If it's the first section output (.text) start at 0, otherwise + * make sure the start is > 128. + */ + if (strcmp(sectname, ".text") == 0) + start = 0; + else if (strcmp(sectname, ".data") == 0) + start = 200; + else if (strcmp(sectname, ".bss") == 0) { + start = 200; + resonly = 1; + } else { + /* other section names not recognized. */ + yasm_error_set(YASM_ERROR_GENERAL, + N_("segment name `%s' not recognized"), sectname); + return NULL; + } - flags_override = yasm_dir_helper(object, vp, line, help, NELEMS(help), - &data, yasm_dir_helper_valparam_warn); - if (flags_override < 0) + have_align = yasm_dir_helper(object, vp, line, help, NELEMS(help), + &align_intn, yasm_dir_helper_valparam_warn); + if (have_align < 0) return NULL; /* error occurred */ - if (data.start && data.follows) { - yasm_error_set(YASM_ERROR_GENERAL, - N_("cannot combine `start' and `follows' section attributes")); - return NULL; - } + if (align_intn) { + align = yasm_intnum_get_uint(align_intn); + yasm_intnum_destroy(align_intn); - if (data.vstart && data.vfollows) { - yasm_error_set(YASM_ERROR_GENERAL, - N_("cannot combine `vstart' and `vfollows' section attributes")); - return NULL; - } - - if (data.align) { - unsigned long align = yasm_intnum_get_uint(data.align); - - /* Alignments must be a power of two. */ - if (!is_exp2(align)) { - yasm_error_set(YASM_ERROR_VALUE, - N_("argument to `%s' is not a power of two"), + /* Alignments must be a power of two. */ + if (!is_exp2(align)) { + yasm_error_set(YASM_ERROR_VALUE, + N_("argument to `%s' is not a power of two"), "align"); - return NULL; - } - } else - data.align = bsd ? bsd->align : NULL; + return NULL; + } + } - if (data.valign) { - unsigned long valign = yasm_intnum_get_uint(data.valign); + retval = yasm_object_get_general(object, sectname, + yasm_expr_create_ident( + yasm_expr_int(yasm_intnum_create_uint(start)), line), align, + strcmp(sectname, ".text") == 0, resonly, &isnew, line); - /* Alignments must be a power of two. */ - if (!is_exp2(valign)) { - yasm_error_set(YASM_ERROR_VALUE, - N_("argument to `%s' is not a power of two"), - "valign"); - return NULL; - } - } else - data.valign = bsd ? bsd->valign : NULL; + if (isnew) + bin_objfmt_init_new_section(object, retval, sectname, line); - retval = yasm_object_get_general(object, sectname, 0, (int)data.code, - (int)data.bss, &isnew, line); + if (isnew || yasm_section_is_default(retval)) { + yasm_section_set_default(retval, 0); + yasm_section_set_align(retval, align, line); + } else if (have_align) + yasm_warn_set(YASM_WARN_GENERAL, + N_("alignment value ignored on section redeclaration")); - bsd = yasm_section_get_data(retval, &bin_section_data_cb); - - if (isnew || yasm_section_is_default(retval)) { - yasm_section_set_default(retval, 0); - } - - /* Update section flags */ - bsd->bss = data.bss; - bsd->align = data.align; - bsd->valign = data.valign; - bsd->start = data.start; - bsd->vstart = data.vstart; - bsd->follows = data.follows; - bsd->vfollows = data.vfollows; - - return retval; -} - -static /*@observer@*/ /*@null@*/ yasm_symrec * -bin_objfmt_get_special_sym(yasm_object *object, const char *name, - const char *parser) -{ - return NULL; + return retval; } static void bin_objfmt_dir_org(yasm_object *object, - /*@null@*/ yasm_valparamhead *valparams, - /*@unused@*/ /*@null@*/ - yasm_valparamhead *objext_valparams, unsigned long line) + /*@null@*/ yasm_valparamhead *valparams, + /*@unused@*/ /*@null@*/ + yasm_valparamhead *objext_valparams, unsigned long line) { - yasm_objfmt_bin *objfmt_bin = (yasm_objfmt_bin *)object->objfmt; + yasm_section *sect; yasm_valparam *vp; + /*@only@*/ /*@null@*/ yasm_expr *start; - /* We only allow a single ORG in a program. */ - if (objfmt_bin->org) { - yasm_error_set(YASM_ERROR_GENERAL, N_("program origin redefined")); - return; - } - - /* ORG takes just a simple expression as param */ + /* ORG takes just a simple integer as param */ vp = yasm_vps_first(valparams); - objfmt_bin->org = yasm_vp_expr(vp, object->symtab, line); - if (!objfmt_bin->org) { - yasm_error_set(YASM_ERROR_SYNTAX, - N_("argument to ORG must be expression")); - return; - } -} - -struct bin_dir_map_data { - unsigned long flags; - /*@only@*/ /*@null@*/ char *filename; -}; - -static int -dir_map_filename(void *obj, yasm_valparam *vp, unsigned long line, void *data) -{ - struct bin_dir_map_data *mdata = (struct bin_dir_map_data *)data; - const char *filename; - - if (mdata->filename) { - yasm_warn_set(YASM_WARN_GENERAL, N_("map file already specified")); - return 0; + start = yasm_vp_expr(vp, object->symtab, line); + if (!start) { + yasm_error_set(YASM_ERROR_SYNTAX, + N_("argument to ORG must be expression")); + return; } - filename = yasm_vp_string(vp); - if (!filename) { - yasm_error_set(YASM_ERROR_SYNTAX, - N_("unexpected expression in [map]")); - return -1; - } - mdata->filename = yasm__xstrdup(filename); - - return 1; -} - -static void -bin_objfmt_dir_map(yasm_object *object, - /*@null@*/ yasm_valparamhead *valparams, - /*@unused@*/ /*@null@*/ - yasm_valparamhead *objext_valparams, unsigned long line) -{ - yasm_objfmt_bin *objfmt_bin = (yasm_objfmt_bin *)object->objfmt; - - struct bin_dir_map_data data; - - static const yasm_dir_help help[] = { - { "all", 0, yasm_dir_helper_flag_or, - offsetof(struct bin_dir_map_data, flags), - MAP_BRIEF|MAP_SECTIONS|MAP_SYMBOLS }, - { "brief", 0, yasm_dir_helper_flag_or, - offsetof(struct bin_dir_map_data, flags), MAP_BRIEF }, - { "sections", 0, yasm_dir_helper_flag_or, - offsetof(struct bin_dir_map_data, flags), MAP_SECTIONS }, - { "segments", 0, yasm_dir_helper_flag_or, - offsetof(struct bin_dir_map_data, flags), MAP_SECTIONS }, - { "symbols", 0, yasm_dir_helper_flag_or, - offsetof(struct bin_dir_map_data, flags), MAP_SYMBOLS } - }; - - data.flags = objfmt_bin->map_flags | MAP_NONE; - data.filename = objfmt_bin->map_filename; - - if (valparams && yasm_dir_helper(object, yasm_vps_first(valparams), line, help, - NELEMS(help), &data, dir_map_filename) < 0) - return; /* error occurred */ - - objfmt_bin->map_flags = data.flags; - objfmt_bin->map_filename = data.filename; -} - -static void -bin_section_data_destroy(void *data) -{ - bin_section_data *bsd = (bin_section_data *)data; - if (bsd->align) - yasm_xfree(bsd->align); - if (bsd->valign) - yasm_xfree(bsd->valign); - if (bsd->start) - yasm_expr_destroy(bsd->start); - if (bsd->vstart) - yasm_expr_destroy(bsd->vstart); - if (bsd->follows) - yasm_xfree(bsd->follows); - if (bsd->vfollows) - yasm_xfree(bsd->vfollows); - if (bsd->istart) - yasm_intnum_destroy(bsd->istart); - if (bsd->ivstart) - yasm_intnum_destroy(bsd->ivstart); - if (bsd->length) - yasm_intnum_destroy(bsd->length); - yasm_xfree(data); -} - -static void -bin_section_data_print(void *data, FILE *f, int indent_level) -{ - bin_section_data *bsd = (bin_section_data *)data; - - fprintf(f, "%*sbss=%d\n", indent_level, "", bsd->bss); - - fprintf(f, "%*salign=", indent_level, ""); - if (bsd->align) - yasm_intnum_print(bsd->align, f); - else - fprintf(f, "(nil)"); - fprintf(f, "\n%*svalign=", indent_level, ""); - if (bsd->valign) - yasm_intnum_print(bsd->valign, f); - else - fprintf(f, "(nil)"); - - fprintf(f, "\n%*sstart=", indent_level, ""); - yasm_expr_print(bsd->start, f); - fprintf(f, "\n%*svstart=", indent_level, ""); - yasm_expr_print(bsd->vstart, f); - - fprintf(f, "\n%*sfollows=", indent_level, ""); - if (bsd->follows) - fprintf(f, "\"%s\"", bsd->follows); - else - fprintf(f, "(nil)"); - fprintf(f, "\n%*svfollows=", indent_level, ""); - if (bsd->vfollows) - fprintf(f, "\"%s\"", bsd->vfollows); - else - fprintf(f, "(nil)"); - - fprintf(f, "\n%*sistart=", indent_level, ""); - if (bsd->istart) - yasm_intnum_print(bsd->istart, f); - else - fprintf(f, "(nil)"); - fprintf(f, "\n%*sivstart=", indent_level, ""); - if (bsd->ivstart) - yasm_intnum_print(bsd->ivstart, f); - else - fprintf(f, "(nil)"); - - fprintf(f, "\n%*slength=", indent_level, ""); - if (bsd->length) - yasm_intnum_print(bsd->length, f); - else - fprintf(f, "(nil)"); - fprintf(f, "\n"); -} - -static void -bin_symrec_data_destroy(void *data) -{ - yasm_xfree(data); -} - -static void -bin_symrec_data_print(void *data, FILE *f, int indent_level) -{ - bin_symrec_data *bsymd = (bin_symrec_data *)data; - - fprintf(f, "%*ssection=\"%s\"\n", indent_level, "", - yasm_section_get_name(bsymd->section)); - fprintf(f, "%*swhich=", indent_level, ""); - switch (bsymd->which) { - case SSYM_START: fprintf(f, "START"); break; - case SSYM_VSTART: fprintf(f, "VSTART"); break; - case SSYM_LENGTH: fprintf(f, "LENGTH"); break; - } - fprintf(f, "\n"); + /* ORG changes the start of the .text section */ + sect = yasm_object_find_general(object, ".text"); + if (!sect) + yasm_internal_error( + N_("bin objfmt: .text section does not exist before ORG is called?")); + yasm_section_set_start(sect, start, line); } @@ -1793,194 +507,22 @@ static const char *bin_objfmt_dbgfmt_keywords[] = { }; static const yasm_directive bin_objfmt_directives[] = { - { "org", "nasm", bin_objfmt_dir_org, YASM_DIR_ARG_REQUIRED }, - { "map", "nasm", bin_objfmt_dir_map, YASM_DIR_ANY }, + { "org", "nasm", bin_objfmt_dir_org, YASM_DIR_ARG_REQUIRED }, { NULL, NULL, NULL, 0 } }; -static const char *bin_nasm_stdmac[] = { - "%imacro org 1+.nolist", - "[org %1]", - "%endmacro", - NULL -}; - -static const yasm_stdmac bin_objfmt_stdmacs[] = { - { "nasm", "nasm", bin_nasm_stdmac }, - { "tasm", "tasm", bin_nasm_stdmac }, - { NULL, NULL, NULL } -}; - /* Define objfmt structure -- see objfmt.h for details */ yasm_objfmt_module yasm_bin_LTX_objfmt = { "Flat format binary", "bin", NULL, 16, - 0, bin_objfmt_dbgfmt_keywords, "null", bin_objfmt_directives, - bin_objfmt_stdmacs, bin_objfmt_create, bin_objfmt_output, bin_objfmt_destroy, bin_objfmt_add_default_section, - bin_objfmt_init_new_section, - bin_objfmt_section_switch, - bin_objfmt_get_special_sym -}; - -#define EXE_HEADER_SIZE 0x200 - -/* DOS .EXE binaries are just raw binaries with a header */ -yasm_objfmt_module yasm_dosexe_LTX_objfmt; - -static yasm_objfmt * -dosexe_objfmt_create(yasm_object *object) -{ - yasm_objfmt_bin *objfmt_bin = (yasm_objfmt_bin *) bin_objfmt_create(object); - objfmt_bin->objfmt.module = &yasm_dosexe_LTX_objfmt; - return (yasm_objfmt *)objfmt_bin; -} - -static unsigned long -get_sym(yasm_object *object, const char *name) { - yasm_symrec *symrec = yasm_symtab_get(object->symtab, name); - yasm_bytecode *prevbc; - if (!symrec) - return 0; - if (!yasm_symrec_get_label(symrec, &prevbc)) - return 0; - return prevbc->offset + prevbc->len; -} - -static void -dosexe_objfmt_output(yasm_object *object, FILE *f, /*@unused@*/ int all_syms, - yasm_errwarns *errwarns) -{ - unsigned long tot_size, size, bss_size; - unsigned long start, bss; - unsigned char c; - - fseek(f, EXE_HEADER_SIZE, SEEK_SET); - - bin_objfmt_output(object, f, all_syms, errwarns); - - tot_size = ftell(f); - - /* if there is a __bss_start symbol, data after it is 0, no need to write - * it. */ - bss = get_sym(object, "__bss_start"); - if (bss) - size = bss; - else - size = tot_size; - bss_size = tot_size - size; -#ifdef HAVE_FTRUNCATE - if (size != tot_size) - if (ftruncate(fileno(f), EXE_HEADER_SIZE + size)) - ; /* No-op. Report an error? */ -#endif - fseek(f, 0, SEEK_SET); - - /* magic */ - fwrite("MZ", 1, 2, f); - - /* file size */ - c = size & 0xff; - fwrite(&c, 1, 1, f); - c = !!(size & 0x100); - fwrite(&c, 1, 1, f); - c = ((size + 511) >> 9) & 0xff; - fwrite(&c, 1, 1, f); - c = ((size + 511) >> 17) & 0xff; - fwrite(&c, 1, 1, f); - - /* relocation # */ - c = 0; - fwrite(&c, 1, 1, f); - fwrite(&c, 1, 1, f); - - /* header size */ - c = EXE_HEADER_SIZE / 16; - fwrite(&c, 1, 1, f); - c = 0; - fwrite(&c, 1, 1, f); - - /* minimum paragraph # */ - bss_size = (bss_size + 15) >> 4; - c = bss_size & 0xff; - fwrite(&c, 1, 1, f); - c = (bss_size >> 8) & 0xff; - fwrite(&c, 1, 1, f); - - /* maximum paragraph # */ - c = 0xFF; - fwrite(&c, 1, 1, f); - fwrite(&c, 1, 1, f); - - /* relative value of stack segment */ - c = 0; - fwrite(&c, 1, 1, f); - fwrite(&c, 1, 1, f); - - /* SP at start */ - c = 0; - fwrite(&c, 1, 1, f); - fwrite(&c, 1, 1, f); - - /* header checksum */ - c = 0; - fwrite(&c, 1, 1, f); - fwrite(&c, 1, 1, f); - - /* IP at start */ - start = get_sym(object, "start"); - if (!start) { - yasm_error_set(YASM_ERROR_GENERAL, - N_("%s: could not find symbol `start'")); - return; - } - c = start & 0xff; - fwrite(&c, 1, 1, f); - c = (start >> 8) & 0xff; - fwrite(&c, 1, 1, f); - - /* CS start */ - c = 0; - fwrite(&c, 1, 1, f); - fwrite(&c, 1, 1, f); - - /* reloc start */ - c = 0x22; - fwrite(&c, 1, 1, f); - c = 0; - fwrite(&c, 1, 1, f); - - /* Overlay number */ - c = 0; - fwrite(&c, 1, 1, f); - fwrite(&c, 1, 1, f); -} - - -/* Define objfmt structure -- see objfmt.h for details */ -yasm_objfmt_module yasm_dosexe_LTX_objfmt = { - "DOS .EXE format binary", - "dosexe", - "exe", - 16, - 0, - bin_objfmt_dbgfmt_keywords, - "null", - bin_objfmt_directives, - bin_objfmt_stdmacs, - dosexe_objfmt_create, - dosexe_objfmt_output, - bin_objfmt_destroy, - bin_objfmt_add_default_section, - bin_objfmt_init_new_section, - bin_objfmt_section_switch, - bin_objfmt_get_special_sym + bin_objfmt_section_switch }; diff --git a/modules/objfmts/bin/tests/Makefile.inc b/modules/objfmts/bin/tests/Makefile.inc index e29ed72f..e1993ea4 100644 --- a/modules/objfmts/bin/tests/Makefile.inc +++ b/modules/objfmts/bin/tests/Makefile.inc @@ -1,3 +1,5 @@ +# $Id$ + TESTS += modules/objfmts/bin/tests/bin_test.sh EXTRA_DIST += modules/objfmts/bin/tests/bin_test.sh @@ -28,7 +30,3 @@ EXTRA_DIST += modules/objfmts/bin/tests/reserve.hex EXTRA_DIST += modules/objfmts/bin/tests/reserve.errwarn EXTRA_DIST += modules/objfmts/bin/tests/shr.asm EXTRA_DIST += modules/objfmts/bin/tests/shr.hex - -EXTRA_DIST += modules/objfmts/bin/tests/multisect/Makefile.inc - -include modules/objfmts/bin/tests/multisect/Makefile.inc diff --git a/modules/objfmts/bin/tests/bin-farabs.asm b/modules/objfmts/bin/tests/bin-farabs.asm index 4d931c1e..e26bcbc6 100644 --- a/modules/objfmts/bin/tests/bin-farabs.asm +++ b/modules/objfmts/bin/tests/bin-farabs.asm @@ -14,16 +14,14 @@ mov es, ax ; Use without seg should yield just the offset part. mov bx, keybuf -;mov bx, 0040h:001Eh ; Illegal +mov bx, 0040h:001Eh ; Illegal in NASM ("invalid combination...") ; Each of the below pairs should be equivalent (and legal) in Yasm. ; There are some differences from NASM here! -; Defaults to near jump (on both NASM and Yasm) -jmp keybuf - ; Direct far jump. -jmp 0040h:001Eh +jmp keybuf ; Results in a near jump in NASM +jmp 0040h:001Eh ; But Yasm sees the equ value as equivalent to this ; Force near (non-far) jump (just offset, no segment). jmp near keybuf diff --git a/modules/objfmts/bin/tests/bin-farabs.hex b/modules/objfmts/bin/tests/bin-farabs.hex index 5ebd4225..6f626b56 100644 --- a/modules/objfmts/bin/tests/bin-farabs.hex +++ b/modules/objfmts/bin/tests/bin-farabs.hex @@ -9,31 +9,36 @@ c0 bb 1e 00 -e9 -10 -ff +bb +1e +00 +ea +1e +00 +40 +00 ea 1e 00 40 00 e9 -08 +03 ff e9 -05 +00 ff e9 -02 -ff -e9 -e1 +fd fe e9 -de +dc +fe +e9 +d9 0e e9 -db +d6 4e eb fe diff --git a/modules/objfmts/bin/tests/bin_test.sh b/modules/objfmts/bin/tests/bin_test.sh index 9ab7e41a..49f4897c 100755 --- a/modules/objfmts/bin/tests/bin_test.sh +++ b/modules/objfmts/bin/tests/bin_test.sh @@ -1,3 +1,4 @@ #! /bin/sh +# $Id$ ${srcdir}/out_test.sh bin_test modules/objfmts/bin/tests "bin objfmt" "-f bin" "" exit $? diff --git a/modules/objfmts/bin/tests/float-err.asm b/modules/objfmts/bin/tests/float-err.asm index 7c608ba0..56a766c2 100644 --- a/modules/objfmts/bin/tests/float-err.asm +++ b/modules/objfmts/bin/tests/float-err.asm @@ -1,6 +1,6 @@ ; Tests illegal float handling db 1.2 -dw 3.14e500 +dw 3.14 dd 5.12e100000 dq 3.141592653589793e-158105 dt 5653894745.318293470142875104710284019245e-1999 diff --git a/modules/objfmts/bin/tests/float-err.errwarn b/modules/objfmts/bin/tests/float-err.errwarn index 4aaa9402..3efe445d 100644 --- a/modules/objfmts/bin/tests/float-err.errwarn +++ b/modules/objfmts/bin/tests/float-err.errwarn @@ -1,8 +1,8 @@ --:2: error: invalid floating point constant size --:3: warning: overflow in floating point expression +-:2: invalid floating point constant size +-:3: invalid floating point constant size -:4: warning: overflow in floating point expression -:5: warning: underflow in floating point expression --:8: error: invalid floating point constant size --:9: warning: overflow in floating point expression +-:8: invalid floating point constant size +-:9: invalid floating point constant size -:11: warning: overflow in floating point expression -:12: warning: underflow in floating point expression diff --git a/modules/objfmts/bin/tests/float.asm b/modules/objfmts/bin/tests/float.asm index 32d2777b..a2823f35 100644 --- a/modules/objfmts/bin/tests/float.asm +++ b/modules/objfmts/bin/tests/float.asm @@ -1,10 +1,8 @@ ; Tests float handling -dw 3.14 dd 5.12 dq 3.141592653589793 dt 5653894745.318293470142875104710284019245e335 -dw -62000.0 dd -47102940.467103581 dq -45102571092751092341095.5827509174509178450917845019 dt -1.e-1000 diff --git a/modules/objfmts/bin/tests/float.hex b/modules/objfmts/bin/tests/float.hex index 33b0d978..066fa76e 100644 --- a/modules/objfmts/bin/tests/float.hex +++ b/modules/objfmts/bin/tests/float.hex @@ -1,5 +1,3 @@ -48 -42 0a d7 a3 @@ -22,8 +20,6 @@ f1 97 78 44 -92 -fb f7 ae 33 diff --git a/modules/objfmts/bin/tests/multisect/Makefile.inc b/modules/objfmts/bin/tests/multisect/Makefile.inc deleted file mode 100644 index dcb7d62a..00000000 --- a/modules/objfmts/bin/tests/multisect/Makefile.inc +++ /dev/null @@ -1,51 +0,0 @@ -TESTS += modules/objfmts/bin/tests/multisect/bin_multi_test.sh - -EXTRA_DIST += modules/objfmts/bin/tests/multisect/bin_multi_test.sh -EXTRA_DIST += modules/objfmts/bin/tests/multisect/bin-align.asm -EXTRA_DIST += modules/objfmts/bin/tests/multisect/bin-align.errwarn -EXTRA_DIST += modules/objfmts/bin/tests/multisect/bin-align.hex -EXTRA_DIST += modules/objfmts/bin/tests/multisect/bin-align.map -EXTRA_DIST += modules/objfmts/bin/tests/multisect/bin-ssym.asm -EXTRA_DIST += modules/objfmts/bin/tests/multisect/bin-ssym.hex -EXTRA_DIST += modules/objfmts/bin/tests/multisect/bin-ssym.map -EXTRA_DIST += modules/objfmts/bin/tests/multisect/follows-loop1-err.asm -EXTRA_DIST += modules/objfmts/bin/tests/multisect/follows-loop1-err.errwarn -EXTRA_DIST += modules/objfmts/bin/tests/multisect/follows-loop2-err.asm -EXTRA_DIST += modules/objfmts/bin/tests/multisect/follows-loop2-err.errwarn -EXTRA_DIST += modules/objfmts/bin/tests/multisect/follows-notfound-err.asm -EXTRA_DIST += modules/objfmts/bin/tests/multisect/follows-notfound-err.errwarn -EXTRA_DIST += modules/objfmts/bin/tests/multisect/initbss.asm -EXTRA_DIST += modules/objfmts/bin/tests/multisect/initbss.errwarn -EXTRA_DIST += modules/objfmts/bin/tests/multisect/initbss.hex -EXTRA_DIST += modules/objfmts/bin/tests/multisect/initbss.map -EXTRA_DIST += modules/objfmts/bin/tests/multisect/ldlinux-sects.asm -EXTRA_DIST += modules/objfmts/bin/tests/multisect/ldlinux-sects.hex -EXTRA_DIST += modules/objfmts/bin/tests/multisect/ldlinux-sects.map -EXTRA_DIST += modules/objfmts/bin/tests/multisect/multisect1.asm -EXTRA_DIST += modules/objfmts/bin/tests/multisect/multisect1.hex -EXTRA_DIST += modules/objfmts/bin/tests/multisect/multisect1.map -EXTRA_DIST += modules/objfmts/bin/tests/multisect/multisect2.asm -EXTRA_DIST += modules/objfmts/bin/tests/multisect/multisect2.hex -EXTRA_DIST += modules/objfmts/bin/tests/multisect/multisect2.map -EXTRA_DIST += modules/objfmts/bin/tests/multisect/multisect3.asm -EXTRA_DIST += modules/objfmts/bin/tests/multisect/multisect3.hex -EXTRA_DIST += modules/objfmts/bin/tests/multisect/multisect3.map -EXTRA_DIST += modules/objfmts/bin/tests/multisect/multisect4.asm -EXTRA_DIST += modules/objfmts/bin/tests/multisect/multisect4.hex -EXTRA_DIST += modules/objfmts/bin/tests/multisect/multisect4.map -EXTRA_DIST += modules/objfmts/bin/tests/multisect/multisect5.asm -EXTRA_DIST += modules/objfmts/bin/tests/multisect/multisect5.hex -EXTRA_DIST += modules/objfmts/bin/tests/multisect/multisect5.map -EXTRA_DIST += modules/objfmts/bin/tests/multisect/nomultisect1.asm -EXTRA_DIST += modules/objfmts/bin/tests/multisect/nomultisect1.hex -EXTRA_DIST += modules/objfmts/bin/tests/multisect/nomultisect1.map -EXTRA_DIST += modules/objfmts/bin/tests/multisect/nomultisect2.asm -EXTRA_DIST += modules/objfmts/bin/tests/multisect/nomultisect2.hex -EXTRA_DIST += modules/objfmts/bin/tests/multisect/nomultisect2.map -EXTRA_DIST += modules/objfmts/bin/tests/multisect/vfollows-loop1-err.asm -EXTRA_DIST += modules/objfmts/bin/tests/multisect/vfollows-loop1-err.errwarn -EXTRA_DIST += modules/objfmts/bin/tests/multisect/vfollows-loop2-err.asm -EXTRA_DIST += modules/objfmts/bin/tests/multisect/vfollows-loop2-err.errwarn -EXTRA_DIST += modules/objfmts/bin/tests/multisect/vfollows-notfound-err.asm -EXTRA_DIST += modules/objfmts/bin/tests/multisect/vfollows-notfound-err.errwarn - diff --git a/modules/objfmts/bin/tests/multisect/bin-align.asm b/modules/objfmts/bin/tests/multisect/bin-align.asm deleted file mode 100644 index e355aac7..00000000 --- a/modules/objfmts/bin/tests/multisect/bin-align.asm +++ /dev/null @@ -1,12 +0,0 @@ -[map all binalign.map] -section .text -db 1 -align 8 -db 0 -section .data -align 8 -db 0 -section .foo align=4 -align 8 -section .bar valign=4 -align 8 diff --git a/modules/objfmts/bin/tests/multisect/bin-align.errwarn b/modules/objfmts/bin/tests/multisect/bin-align.errwarn deleted file mode 100644 index e13f89df..00000000 --- a/modules/objfmts/bin/tests/multisect/bin-align.errwarn +++ /dev/null @@ -1,3 +0,0 @@ --: warning: section `.foo' internal align of 8 is greater than `align' of 4; using `align' --: warning: section `.bar' internal align of 8 is greater than `valign' of 4; using `valign' --:1: warning: map file already specified diff --git a/modules/objfmts/bin/tests/multisect/bin-align.hex b/modules/objfmts/bin/tests/multisect/bin-align.hex deleted file mode 100644 index dd133f77..00000000 --- a/modules/objfmts/bin/tests/multisect/bin-align.hex +++ /dev/null @@ -1,17 +0,0 @@ -01 -8d -74 -00 -8d -bd -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 diff --git a/modules/objfmts/bin/tests/multisect/bin-align.map b/modules/objfmts/bin/tests/multisect/bin-align.map deleted file mode 100644 index bb5a8f23..00000000 --- a/modules/objfmts/bin/tests/multisect/bin-align.map +++ /dev/null @@ -1,66 +0,0 @@ - -- YASM Map file --------------------------------------------------------------- - -Source file: - -Output file: bin-align - --- Program origin ------------------------------------------------------------- - -00000000 - --- Sections (summary) --------------------------------------------------------- - -Vstart Vstop Start Stop Length Class Name -00000000 00000009 00000000 00000009 00000009 progbits .text -00000010 00000011 00000010 00000011 00000001 progbits .data -00000014 00000014 00000014 00000014 00000000 progbits .foo -00000018 00000018 00000018 00000018 00000000 progbits .bar - --- Sections (detailed) -------------------------------------------------------- - ----- Section .text ------------------------------------------------------------ - -class: progbits -length: 00000009 -start: 00000000 -align: 00000008 -follows: not defined -vstart: 00000000 -valign: 00000008 -vfollows: not defined - ----- Section .data ------------------------------------------------------------ - -class: progbits -length: 00000001 -start: 00000010 -align: 00000008 -follows: not defined -vstart: 00000010 -valign: 00000008 -vfollows: not defined - ----- Section .foo ------------------------------------------------------------- - -class: progbits -length: 00000000 -start: 00000014 -align: 00000004 -follows: not defined -vstart: 00000014 -valign: 00000004 -vfollows: not defined - ----- Section .bar ------------------------------------------------------------- - -class: progbits -length: 00000000 -start: 00000018 -align: 00000008 -follows: not defined -vstart: 00000018 -valign: 00000004 -vfollows: not defined - --- Symbols -------------------------------------------------------------------- - diff --git a/modules/objfmts/bin/tests/multisect/bin-ssym.asm b/modules/objfmts/bin/tests/multisect/bin-ssym.asm deleted file mode 100644 index 8c5608cf..00000000 --- a/modules/objfmts/bin/tests/multisect/bin-ssym.asm +++ /dev/null @@ -1,5 +0,0 @@ -section foo start=0x10 vstart=0x6000 -mov si, section.foo.start -mov di, section.foo.vstart -mov cx, section.foo.length -;mov dx, section.foo.vstart-section.foo.start diff --git a/modules/objfmts/bin/tests/multisect/bin-ssym.hex b/modules/objfmts/bin/tests/multisect/bin-ssym.hex deleted file mode 100644 index e89a7e22..00000000 --- a/modules/objfmts/bin/tests/multisect/bin-ssym.hex +++ /dev/null @@ -1,25 +0,0 @@ -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -be -10 -00 -bf -00 -60 -b9 -09 -00 diff --git a/modules/objfmts/bin/tests/multisect/bin-ssym.map b/modules/objfmts/bin/tests/multisect/bin-ssym.map deleted file mode 100644 index 112dc02b..00000000 --- a/modules/objfmts/bin/tests/multisect/bin-ssym.map +++ /dev/null @@ -1,16 +0,0 @@ - -- YASM Map file --------------------------------------------------------------- - -Source file: - -Output file: bin-ssym - --- Program origin ------------------------------------------------------------- - -00000000 - --- Sections (summary) --------------------------------------------------------- - -Vstart Vstop Start Stop Length Class Name -00000000 00000000 00000000 00000000 00000000 progbits .text -00006000 00006009 00000010 00000019 00000009 progbits foo - diff --git a/modules/objfmts/bin/tests/multisect/bin_multi_test.sh b/modules/objfmts/bin/tests/multisect/bin_multi_test.sh deleted file mode 100755 index aa3f616c..00000000 --- a/modules/objfmts/bin/tests/multisect/bin_multi_test.sh +++ /dev/null @@ -1,113 +0,0 @@ -#! /bin/sh - -YASM_TEST_SUITE=1 -export YASM_TEST_SUITE - -case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in - *c*,-n*) ECHO_N= ECHO_C=' -' ECHO_T=' ' ;; - *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; - *) ECHO_N= ECHO_C='\c' ECHO_T= ;; -esac - -mkdir results >/dev/null 2>&1 - -# -# Verify that all test cases match -# - -passedct=0 -failedct=0 - -echo $ECHO_N "Test bin_multi_test: $ECHO_C" -for asm in ${srcdir}/modules/objfmts/bin/tests/multisect/*.asm -do - a=`echo ${asm} | sed 's,^.*/,,;s,.asm$,,'` - o=${a} - oh=${a}.hx - og=`echo ${asm} | sed 's,.asm$,.hex,'` - e=${a}.ew - eg=`echo ${asm} | sed 's,.asm$,.errwarn,'` - m=${a}.map - mg=`echo ${asm} | sed 's,.asm$,.map,'` - if test \! -f ${eg}; then - eg=/dev/null - fi - - # Run within a subshell to prevent signal messages from displaying. - sh -c "cat ${asm} | ./yasm -f bin --mapfile=results/${m} -o results/${o} - 2>results/${e}" >/dev/null 2>/dev/null - status=$? - if test $status -gt 128; then - # We should never get a coredump! - echo $ECHO_N "C$ECHO_C" - eval "failed$failedct='C: ${a} crashed!'" - failedct=`expr $failedct + 1` - elif test $status -gt 0; then - echo ${asm} | grep err >/dev/null - if test $? -gt 0; then - # YASM detected errors but shouldn't have! - echo $ECHO_N "E$ECHO_C" - eval "failed$failedct='E: ${a} returned an error code!'" - failedct=`expr $failedct + 1` - else - # We got errors, check to see if they match: - if diff -w ${eg} results/${e} >/dev/null; then - # Error/warnings match, it passes! - echo $ECHO_N ".$ECHO_C" - passedct=`expr $passedct + 1` - else - # Error/warnings don't match. - echo $ECHO_N "W$ECHO_C" - eval "failed$failedct='W: ${a} did not match errors and warnings!'" - failedct=`expr $failedct + 1` - fi - fi - else - echo ${asm} | grep -v err >/dev/null - if test $? -gt 0; then - # YASM didn't detect errors but should have! - echo $ECHO_N "E$ECHO_C" - eval "failed$failedct='E: ${a} did not return an error code!'" - failedct=`expr $failedct + 1` - else - ./test_hd results/${o} > results/${oh} - if diff -w ${og} results/${oh} >/dev/null; then - if diff -w ${eg} results/${e} >/dev/null; then - if diff -w ${mg} results/${m} >/dev/null; then - # All match, it passes! - echo $ECHO_N ".$ECHO_C" - passedct=`expr $passedct + 1` - else - # Map file doesn't match. - echo $ECHO_N "M$ECHO_C" - eval "failed$failedct='M: ${a} did not match map file!'" - failedct=`expr $failedct + 1` - fi - else - # Error/warnings don't match. - echo $ECHO_N "W$ECHO_C" - eval "failed$failedct='W: ${a} did not match errors and warnings!'" - failedct=`expr $failedct + 1` - fi - else - # Object file doesn't match. - echo $ECHO_N "O$ECHO_C" - eval "failed$failedct='O: ${a} did not match object file!'" - failedct=`expr $failedct + 1` - fi - fi - fi -done - -ct=`expr $failedct + $passedct` -per=`expr 100 \* $passedct / $ct` - -echo " +$passedct-$failedct/$ct $per%" -i=0 -while test $i -lt $failedct; do - eval "failure=\$failed$i" - echo " ** $failure" - i=`expr $i + 1` -done - -exit $failedct diff --git a/modules/objfmts/bin/tests/multisect/follows-loop1-err.asm b/modules/objfmts/bin/tests/multisect/follows-loop1-err.asm deleted file mode 100644 index ad7fef16..00000000 --- a/modules/objfmts/bin/tests/multisect/follows-loop1-err.asm +++ /dev/null @@ -1,2 +0,0 @@ -section sect1 follows=sect2 -section sect2 follows=sect1 diff --git a/modules/objfmts/bin/tests/multisect/follows-loop1-err.errwarn b/modules/objfmts/bin/tests/multisect/follows-loop1-err.errwarn deleted file mode 100644 index 613280e9..00000000 --- a/modules/objfmts/bin/tests/multisect/follows-loop1-err.errwarn +++ /dev/null @@ -1 +0,0 @@ --: error: follows loop between section `sect2' and section `sect1' diff --git a/modules/objfmts/bin/tests/multisect/follows-loop2-err.asm b/modules/objfmts/bin/tests/multisect/follows-loop2-err.asm deleted file mode 100644 index 9b15f465..00000000 --- a/modules/objfmts/bin/tests/multisect/follows-loop2-err.asm +++ /dev/null @@ -1 +0,0 @@ -section sect follows=sect diff --git a/modules/objfmts/bin/tests/multisect/follows-loop2-err.errwarn b/modules/objfmts/bin/tests/multisect/follows-loop2-err.errwarn deleted file mode 100644 index bc832e00..00000000 --- a/modules/objfmts/bin/tests/multisect/follows-loop2-err.errwarn +++ /dev/null @@ -1 +0,0 @@ --: error: follows loop between section `sect' and section `sect' diff --git a/modules/objfmts/bin/tests/multisect/follows-notfound-err.asm b/modules/objfmts/bin/tests/multisect/follows-notfound-err.asm deleted file mode 100644 index 36361d52..00000000 --- a/modules/objfmts/bin/tests/multisect/follows-notfound-err.asm +++ /dev/null @@ -1,2 +0,0 @@ -section foo follows=bar - diff --git a/modules/objfmts/bin/tests/multisect/follows-notfound-err.errwarn b/modules/objfmts/bin/tests/multisect/follows-notfound-err.errwarn deleted file mode 100644 index 53d29d80..00000000 --- a/modules/objfmts/bin/tests/multisect/follows-notfound-err.errwarn +++ /dev/null @@ -1 +0,0 @@ --: error: section `foo' follows an invalid or unknown section `bar' diff --git a/modules/objfmts/bin/tests/multisect/initbss.asm b/modules/objfmts/bin/tests/multisect/initbss.asm deleted file mode 100644 index 8fe39bcc..00000000 --- a/modules/objfmts/bin/tests/multisect/initbss.asm +++ /dev/null @@ -1,5 +0,0 @@ -section .bss -mov ax, 5 - -section foo nobits -db 5 diff --git a/modules/objfmts/bin/tests/multisect/initbss.errwarn b/modules/objfmts/bin/tests/multisect/initbss.errwarn deleted file mode 100644 index e92a68e4..00000000 --- a/modules/objfmts/bin/tests/multisect/initbss.errwarn +++ /dev/null @@ -1,2 +0,0 @@ --:2: warning: initialized space declared in nobits section: ignoring --:5: warning: initialized space declared in nobits section: ignoring diff --git a/modules/objfmts/bin/tests/multisect/initbss.hex b/modules/objfmts/bin/tests/multisect/initbss.hex deleted file mode 100644 index e69de29b..00000000 diff --git a/modules/objfmts/bin/tests/multisect/initbss.map b/modules/objfmts/bin/tests/multisect/initbss.map deleted file mode 100644 index dc444f56..00000000 --- a/modules/objfmts/bin/tests/multisect/initbss.map +++ /dev/null @@ -1,17 +0,0 @@ - -- YASM Map file --------------------------------------------------------------- - -Source file: - -Output file: initbss - --- Program origin ------------------------------------------------------------- - -00000000 - --- Sections (summary) --------------------------------------------------------- - -Vstart Vstop Start Stop Length Class Name -00000000 00000000 00000000 00000000 00000000 progbits .text -00000000 00000003 00000000 00000003 00000003 nobits .bss -00000004 00000005 00000004 00000005 00000001 nobits foo - diff --git a/modules/objfmts/bin/tests/multisect/ldlinux-sects.asm b/modules/objfmts/bin/tests/multisect/ldlinux-sects.asm deleted file mode 100644 index 2beae7c7..00000000 --- a/modules/objfmts/bin/tests/multisect/ldlinux-sects.asm +++ /dev/null @@ -1,102 +0,0 @@ -[map all] -BSS_START equ 0800h -LATEBSS_START equ 0B800h -TEXT_START equ 7C00h -STACK_SIZE equ 4096 -STACK_START equ TEXT_START-STACK_SIZE -org TEXT_START -[section .text] -times 0x2410 db 0x1 -[section .earlybss nobits start=BSS_START] -resb 0x40C4 -[section .bcopy32 align=4 valign=16 follows=.data vfollows=.earlybss] -times 0x2A0 db 0x3 -[section .config align=4 valign=16 follows=.bcopy32 vfollows=.bcopy32] -times 0x23 db 0x4 -[section .config.end nobits valign=4 vfollows=.config] -[section .bss1 nobits valign=16 vfollows=.config.end] -resb 0x1FB -[section .text start=TEXT_START] -[section .data align=16] -times 0x590 db 0x2 -[section .adv progbits align=1 follows=.config] -[section .bss nobits align=16 follows=.adv] -resb 0x3900 -[section .stack nobits align=16 start=STACK_START] -resb STACK_SIZE -[section .stack nobits align=16 start=STACK_START] -[section .stack nobits align=16 start=STACK_START] -[section .earlybss] -[section .bss] -[section .text] -[section .bss] -[section .text] -[section .data] -[section .text] -[section .text] -[section .text] -[section .bss] -[section .text] -[section .data] -[section .bss] -[section .text] -[section .data] -[section .bss] -[section .text] -[section .text] -[section .text] -[section .data] -[section .bss1] -[section .data] -[section .text] -[section .bss1] -[section .text] -[section .text] -[section .data] -[section .text] -[section .text] -[section .bss] -[section .text] -[section .bss] -[section .text] -[section .data] -[section .text] -[section .text] -[section .bss1] -[section .data] -[section .text] -[section .text] -[section .data] -[section .config] -[section .bss] -[section .text] -[section .text] -[section .text] -[section .data] -[section .text] -[section .data] -[section .config] -[section .bss] -[section .text] -[section .text] -[section .data] -[section .bss] -[section .bcopy32] -[section .data] -[section .bcopy32] -[section .earlybss] -[section .text] -[section .text] -[section .bss] -[section .data] -[section .bss1] -[section .text] -[section .data] -[section .bss1] -[section .text] -[section .bss] -[section .text] -[section .text] -[section .text] -[section .bss] -[section .data] diff --git a/modules/objfmts/bin/tests/multisect/ldlinux-sects.hex b/modules/objfmts/bin/tests/multisect/ldlinux-sects.hex deleted file mode 100644 index bb591fc0..00000000 --- a/modules/objfmts/bin/tests/multisect/ldlinux-sects.hex +++ /dev/null @@ -1,11363 +0,0 @@ -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -04 -04 -04 -04 -04 -04 -04 -04 -04 -04 -04 -04 -04 -04 -04 -04 -04 -04 -04 -04 -04 -04 -04 -04 -04 -04 -04 -04 -04 -04 -04 -04 -04 -04 -04 diff --git a/modules/objfmts/bin/tests/multisect/ldlinux-sects.map b/modules/objfmts/bin/tests/multisect/ldlinux-sects.map deleted file mode 100644 index 3a5e33e3..00000000 --- a/modules/objfmts/bin/tests/multisect/ldlinux-sects.map +++ /dev/null @@ -1,148 +0,0 @@ - -- YASM Map file --------------------------------------------------------------- - -Source file: - -Output file: ldlinux-sects - --- Program origin ------------------------------------------------------------- - -00007C00 - --- Sections (summary) --------------------------------------------------------- - -Vstart Vstop Start Stop Length Class Name -00000800 000048C4 00000800 000048C4 000040C4 nobits .earlybss -00006C00 00007C00 00006C00 00007C00 00001000 nobits .stack -00007C00 0000A010 00007C00 0000A010 00002410 progbits .text -0000A010 0000A5A0 0000A010 0000A5A0 00000590 progbits .data -000048D0 00004B70 0000A5A0 0000A840 000002A0 progbits .bcopy32 -00004B70 00004B93 0000A840 0000A863 00000023 progbits .config -0000A863 0000A863 0000A863 0000A863 00000000 progbits .adv -0000A870 0000E170 0000A870 0000E170 00003900 nobits .bss -00004B94 00004B94 0000E170 0000E170 00000000 nobits .config.end -00004BA0 00004D9B 0000E170 0000E36B 000001FB nobits .bss1 - --- Sections (detailed) -------------------------------------------------------- - ----- Section .earlybss -------------------------------------------------------- - -class: nobits -length: 000040C4 -start: 00000800 -align: 00000004 -follows: not defined -vstart: 00000800 -valign: 00000004 -vfollows: not defined - ----- Section .stack ----------------------------------------------------------- - -class: nobits -length: 00001000 -start: 00006C00 -align: 00000010 -follows: not defined -vstart: 00006C00 -valign: 00000010 -vfollows: not defined - ----- Section .text ------------------------------------------------------------ - -class: progbits -length: 00002410 -start: 00007C00 -align: 00000004 -follows: not defined -vstart: 00007C00 -valign: 00000004 -vfollows: not defined - ----- Section .data ------------------------------------------------------------ - -class: progbits -length: 00000590 -start: 0000A010 -align: 00000010 -follows: not defined -vstart: 0000A010 -valign: 00000010 -vfollows: not defined - ----- Section .bcopy32 --------------------------------------------------------- - -class: progbits -length: 000002A0 -start: 0000A5A0 -align: 00000004 -follows: .data -vstart: 000048D0 -valign: 00000010 -vfollows: .earlybss - ----- Section .config ---------------------------------------------------------- - -class: progbits -length: 00000023 -start: 0000A840 -align: 00000004 -follows: .bcopy32 -vstart: 00004B70 -valign: 00000010 -vfollows: .bcopy32 - ----- Section .adv ------------------------------------------------------------- - -class: progbits -length: 00000000 -start: 0000A863 -align: 00000001 -follows: .config -vstart: 0000A863 -valign: 00000001 -vfollows: not defined - ----- Section .bss ------------------------------------------------------------- - -class: nobits -length: 00003900 -start: 0000A870 -align: 00000010 -follows: .adv -vstart: 0000A870 -valign: 00000010 -vfollows: not defined - ----- Section .config.end ------------------------------------------------------ - -class: nobits -length: 00000000 -start: 0000E170 -align: 00000004 -follows: not defined -vstart: 00004B94 -valign: 00000004 -vfollows: .config - ----- Section .bss1 ------------------------------------------------------------ - -class: nobits -length: 000001FB -start: 0000E170 -align: 00000004 -follows: not defined -vstart: 00004BA0 -valign: 00000010 -vfollows: .config.end - --- Symbols -------------------------------------------------------------------- - ----- No Section --------------------------------------------------------------- - -Value Name -00000800 BSS_START -0000B800 LATEBSS_START -00007C00 TEXT_START -00001000 STACK_SIZE -00006C00 STACK_START - - diff --git a/modules/objfmts/bin/tests/multisect/multisect1.asm b/modules/objfmts/bin/tests/multisect/multisect1.asm deleted file mode 100644 index d9699b79..00000000 --- a/modules/objfmts/bin/tests/multisect/multisect1.asm +++ /dev/null @@ -1,31 +0,0 @@ -[BITS 32] - -[MAP all] -; This file is loaded as a DOS .COM file. -[SEGMENT _TEXT start=0 vstart=100h] - -; shrink & relocate stack: - mov sp, stack_ends ; NASM puts 460h here - - ; 9B0h is desired. - mov bx, sp - mov cl, 4 - shr bx, cl - mov ah, 4Ah ; DOS resize mem.block - int 21h - -[SEGMENT GATESEG align=1 follows=_TEXT vstart=0] -; label to use for copying this segment at run-time. -gate0cpy: -dd 0 - -; 32-bit ring-0 protected mode code that interacts -; with the VMM (Win3.x/9x kernel). To be relocated -; at run-time to memory dynamically allocated with -; DPMI, and called through a call-gate from ring-3. -; vstart=0 makes some calculations easier. - -; Reserve space for stack: -[SEGMENT .bss follows=GATESEG align=16] - resb 400h -stack_ends: - diff --git a/modules/objfmts/bin/tests/multisect/multisect1.hex b/modules/objfmts/bin/tests/multisect/multisect1.hex deleted file mode 100644 index 32695b89..00000000 --- a/modules/objfmts/bin/tests/multisect/multisect1.hex +++ /dev/null @@ -1,20 +0,0 @@ -66 -bc -20 -04 -66 -89 -e3 -b1 -04 -66 -d3 -eb -b4 -4a -cd -21 -00 -00 -00 -00 diff --git a/modules/objfmts/bin/tests/multisect/multisect1.map b/modules/objfmts/bin/tests/multisect/multisect1.map deleted file mode 100644 index f52da415..00000000 --- a/modules/objfmts/bin/tests/multisect/multisect1.map +++ /dev/null @@ -1,78 +0,0 @@ - -- YASM Map file --------------------------------------------------------------- - -Source file: - -Output file: multisect1 - --- Program origin ------------------------------------------------------------- - -00000000 - --- Sections (summary) --------------------------------------------------------- - -Vstart Vstop Start Stop Length Class Name -00000000 00000000 00000000 00000000 00000000 progbits .text -00000100 00000110 00000000 00000010 00000010 progbits _TEXT -00000000 00000004 00000010 00000014 00000004 progbits GATESEG -00000020 00000420 00000020 00000420 00000400 nobits .bss - --- Sections (detailed) -------------------------------------------------------- - ----- Section .text ------------------------------------------------------------ - -class: progbits -length: 00000000 -start: 00000000 -align: 00000004 -follows: not defined -vstart: 00000000 -valign: 00000004 -vfollows: not defined - ----- Section _TEXT ------------------------------------------------------------ - -class: progbits -length: 00000010 -start: 00000000 -align: 00000004 -follows: not defined -vstart: 00000100 -valign: 00000004 -vfollows: not defined - ----- Section GATESEG ---------------------------------------------------------- - -class: progbits -length: 00000004 -start: 00000010 -align: 00000001 -follows: _TEXT -vstart: 00000000 -valign: 00000001 -vfollows: not defined - ----- Section .bss ------------------------------------------------------------- - -class: nobits -length: 00000400 -start: 00000020 -align: 00000010 -follows: GATESEG -vstart: 00000020 -valign: 00000010 -vfollows: not defined - --- Symbols -------------------------------------------------------------------- - ----- Section GATESEG ---------------------------------------------------------- - -Real Virtual Name -00000010 00000000 gate0cpy - - ----- Section .bss ------------------------------------------------------------- - -Real Virtual Name -00000420 00000420 stack_ends - - diff --git a/modules/objfmts/bin/tests/multisect/multisect2.asm b/modules/objfmts/bin/tests/multisect/multisect2.asm deleted file mode 100644 index cfbf58c6..00000000 --- a/modules/objfmts/bin/tests/multisect/multisect2.asm +++ /dev/null @@ -1,42 +0,0 @@ -org 100h -[map all] - -section .bss ; follows=.data - buffer resb 123h -section .data - msg db "this is a message", 0 -section .text - mov ax, msg - call showax - mov ax, buffer - call showax - ret - -;----------------- -showax: - push cx - push dx - - mov cx, 4 ; four digits to show - -.top - rol ax, 4 ; rotate one digit into position - mov dl, al ; make a copy to process - and dl, 0Fh ; mask off a single (hex) digit - cmp dl, 9 ; is it in the "A" to "F" range? - jbe .dec_dig ; no, skip it - add dl, 7 ; adjust -.dec_dig: - add dl, 30h ; convert to character - - push ax - mov ah, 2 - int 21h - pop ax - - loop .top - - pop dx - pop cx - ret -;-------------------------- diff --git a/modules/objfmts/bin/tests/multisect/multisect2.hex b/modules/objfmts/bin/tests/multisect/multisect2.hex deleted file mode 100644 index f043f372..00000000 --- a/modules/objfmts/bin/tests/multisect/multisect2.hex +++ /dev/null @@ -1,66 +0,0 @@ -b8 -30 -01 -e8 -07 -00 -b8 -44 -01 -e8 -01 -00 -c3 -51 -52 -b9 -04 -00 -c1 -c0 -04 -88 -c2 -80 -e2 -0f -80 -fa -09 -76 -03 -80 -c2 -07 -80 -c2 -30 -50 -b4 -02 -cd -21 -58 -e2 -e5 -5a -59 -c3 -74 -68 -69 -73 -20 -69 -73 -20 -61 -20 -6d -65 -73 -73 -61 -67 -65 -00 diff --git a/modules/objfmts/bin/tests/multisect/multisect2.map b/modules/objfmts/bin/tests/multisect/multisect2.map deleted file mode 100644 index 858da399..00000000 --- a/modules/objfmts/bin/tests/multisect/multisect2.map +++ /dev/null @@ -1,74 +0,0 @@ - -- YASM Map file --------------------------------------------------------------- - -Source file: - -Output file: multisect2 - --- Program origin ------------------------------------------------------------- - -00000100 - --- Sections (summary) --------------------------------------------------------- - -Vstart Vstop Start Stop Length Class Name -00000100 00000130 00000100 00000130 00000030 progbits .text -00000130 00000142 00000130 00000142 00000012 progbits .data -00000144 00000267 00000144 00000267 00000123 nobits .bss - --- Sections (detailed) -------------------------------------------------------- - ----- Section .text ------------------------------------------------------------ - -class: progbits -length: 00000030 -start: 00000100 -align: 00000004 -follows: not defined -vstart: 00000100 -valign: 00000004 -vfollows: not defined - ----- Section .data ------------------------------------------------------------ - -class: progbits -length: 00000012 -start: 00000130 -align: 00000004 -follows: not defined -vstart: 00000130 -valign: 00000004 -vfollows: not defined - ----- Section .bss ------------------------------------------------------------- - -class: nobits -length: 00000123 -start: 00000144 -align: 00000004 -follows: not defined -vstart: 00000144 -valign: 00000004 -vfollows: not defined - --- Symbols -------------------------------------------------------------------- - ----- Section .text ------------------------------------------------------------ - -Real Virtual Name -0000010D 0000010D showax -00000112 00000112 showax.top -00000122 00000122 showax.dec_dig - - ----- Section .data ------------------------------------------------------------ - -Real Virtual Name -00000130 00000130 msg - - ----- Section .bss ------------------------------------------------------------- - -Real Virtual Name -00000144 00000144 buffer - - diff --git a/modules/objfmts/bin/tests/multisect/multisect3.asm b/modules/objfmts/bin/tests/multisect/multisect3.asm deleted file mode 100644 index d6499f96..00000000 --- a/modules/objfmts/bin/tests/multisect/multisect3.asm +++ /dev/null @@ -1,9 +0,0 @@ -[map all] -section .text - mov ax, bx - -section .foo nobits follows=.text - resb 4 - -section .bss - resb 4 diff --git a/modules/objfmts/bin/tests/multisect/multisect3.hex b/modules/objfmts/bin/tests/multisect/multisect3.hex deleted file mode 100644 index a9949757..00000000 --- a/modules/objfmts/bin/tests/multisect/multisect3.hex +++ /dev/null @@ -1,2 +0,0 @@ -89 -d8 diff --git a/modules/objfmts/bin/tests/multisect/multisect3.map b/modules/objfmts/bin/tests/multisect/multisect3.map deleted file mode 100644 index a3f651b2..00000000 --- a/modules/objfmts/bin/tests/multisect/multisect3.map +++ /dev/null @@ -1,54 +0,0 @@ - -- YASM Map file --------------------------------------------------------------- - -Source file: - -Output file: multisect3 - --- Program origin ------------------------------------------------------------- - -00000000 - --- Sections (summary) --------------------------------------------------------- - -Vstart Vstop Start Stop Length Class Name -00000000 00000002 00000000 00000002 00000002 progbits .text -00000004 00000008 00000004 00000008 00000004 nobits .foo -00000008 0000000C 00000008 0000000C 00000004 nobits .bss - --- Sections (detailed) -------------------------------------------------------- - ----- Section .text ------------------------------------------------------------ - -class: progbits -length: 00000002 -start: 00000000 -align: 00000004 -follows: not defined -vstart: 00000000 -valign: 00000004 -vfollows: not defined - ----- Section .foo ------------------------------------------------------------- - -class: nobits -length: 00000004 -start: 00000004 -align: 00000004 -follows: .text -vstart: 00000004 -valign: 00000004 -vfollows: not defined - ----- Section .bss ------------------------------------------------------------- - -class: nobits -length: 00000004 -start: 00000008 -align: 00000004 -follows: not defined -vstart: 00000008 -valign: 00000004 -vfollows: not defined - --- Symbols -------------------------------------------------------------------- - diff --git a/modules/objfmts/bin/tests/multisect/multisect4.asm b/modules/objfmts/bin/tests/multisect/multisect4.asm deleted file mode 100644 index 94d2415f..00000000 --- a/modules/objfmts/bin/tests/multisect/multisect4.asm +++ /dev/null @@ -1,31 +0,0 @@ -[map all] -; Memory below 0800h is reserved for the BIOS and the MBR -BSS_START equ 0800h - -; PXELINUX needs lots of BSS, so it relocates itself on startup -;%if IS_PXELINUX -TEXT_START equ 9000h -;%else -;TEXT_START equ 7C00h -;%endif - -; -; The various sections and their relationship -; -org TEXT_START - -times 0x100 db 0x3 - -section .earlybss nobits start=BSS_START -resb 0x100 -section .bcopy32 align=16 follows=.data vfollows=.earlybss -times 0x100 db 0x1 -section .bss nobits align=256 vfollows=.bcopy32 -resb 0x100 - -section .text start=TEXT_START -section .data align=16 follows=.text -times 0x100 db 0x2 - -section .latebss nobits align=16 follows=.bcopy32 -resb 0x100 diff --git a/modules/objfmts/bin/tests/multisect/multisect4.hex b/modules/objfmts/bin/tests/multisect/multisect4.hex deleted file mode 100644 index d40d7a19..00000000 --- a/modules/objfmts/bin/tests/multisect/multisect4.hex +++ /dev/null @@ -1,768 +0,0 @@ -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -03 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -02 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 diff --git a/modules/objfmts/bin/tests/multisect/multisect4.map b/modules/objfmts/bin/tests/multisect/multisect4.map deleted file mode 100644 index bb97c9f2..00000000 --- a/modules/objfmts/bin/tests/multisect/multisect4.map +++ /dev/null @@ -1,97 +0,0 @@ - -- YASM Map file --------------------------------------------------------------- - -Source file: - -Output file: multisect4 - --- Program origin ------------------------------------------------------------- - -00009000 - --- Sections (summary) --------------------------------------------------------- - -Vstart Vstop Start Stop Length Class Name -00000800 00000900 00000800 00000900 00000100 nobits .earlybss -00009000 00009100 00009000 00009100 00000100 progbits .text -00009100 00009200 00009100 00009200 00000100 progbits .data -00000900 00000A00 00009200 00009300 00000100 progbits .bcopy32 -00009300 00009400 00009300 00009400 00000100 nobits .latebss -00000A00 00000B00 00009400 00009500 00000100 nobits .bss - --- Sections (detailed) -------------------------------------------------------- - ----- Section .earlybss -------------------------------------------------------- - -class: nobits -length: 00000100 -start: 00000800 -align: 00000004 -follows: not defined -vstart: 00000800 -valign: 00000004 -vfollows: not defined - ----- Section .text ------------------------------------------------------------ - -class: progbits -length: 00000100 -start: 00009000 -align: 00000004 -follows: not defined -vstart: 00009000 -valign: 00000004 -vfollows: not defined - ----- Section .data ------------------------------------------------------------ - -class: progbits -length: 00000100 -start: 00009100 -align: 00000010 -follows: .text -vstart: 00009100 -valign: 00000010 -vfollows: not defined - ----- Section .bcopy32 --------------------------------------------------------- - -class: progbits -length: 00000100 -start: 00009200 -align: 00000010 -follows: .data -vstart: 00000900 -valign: 00000010 -vfollows: .earlybss - ----- Section .latebss --------------------------------------------------------- - -class: nobits -length: 00000100 -start: 00009300 -align: 00000010 -follows: .bcopy32 -vstart: 00009300 -valign: 00000010 -vfollows: not defined - ----- Section .bss ------------------------------------------------------------- - -class: nobits -length: 00000100 -start: 00009400 -align: 00000100 -follows: not defined -vstart: 00000A00 -valign: 00000100 -vfollows: .bcopy32 - --- Symbols -------------------------------------------------------------------- - ----- No Section --------------------------------------------------------------- - -Value Name -00000800 BSS_START -00009000 TEXT_START - - diff --git a/modules/objfmts/bin/tests/multisect/multisect5.asm b/modules/objfmts/bin/tests/multisect/multisect5.asm deleted file mode 100644 index 2b761172..00000000 --- a/modules/objfmts/bin/tests/multisect/multisect5.asm +++ /dev/null @@ -1,22 +0,0 @@ -org 0x100 -[map all] -section sect1 start=0x100 vstart=0x2000 -times 0x100 db 0 -section sect2 follows=sect1 -times 0x100 db 0 - -section sect3 start=0x300 vstart=0x4000 -times 0x100 db 0 -section sect4 follows=sect3 -times 0x100 db 0 -section sect5 vfollows=sect3 -times 0x100 db 0 - -section sect6 start=0x600 vstart=0x6000 -times 0x11 db 0 -section sect7 follows=sect6 valign=16 -times 0x104 db 0 -section sect8 follows=sect7 valign=16 ; NASM bug - sect7 and sect8 overlap -times 0x100 db 0 - -section sect9 vfollows=sect8 diff --git a/modules/objfmts/bin/tests/multisect/multisect5.hex b/modules/objfmts/bin/tests/multisect/multisect5.hex deleted file mode 100644 index a2776bc8..00000000 --- a/modules/objfmts/bin/tests/multisect/multisect5.hex +++ /dev/null @@ -1,1816 +0,0 @@ -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 diff --git a/modules/objfmts/bin/tests/multisect/multisect5.map b/modules/objfmts/bin/tests/multisect/multisect5.map deleted file mode 100644 index e5c972a3..00000000 --- a/modules/objfmts/bin/tests/multisect/multisect5.map +++ /dev/null @@ -1,138 +0,0 @@ - -- YASM Map file --------------------------------------------------------------- - -Source file: - -Output file: multisect5 - --- Program origin ------------------------------------------------------------- - -00000100 - --- Sections (summary) --------------------------------------------------------- - -Vstart Vstop Start Stop Length Class Name -00000100 00000100 00000100 00000100 00000000 progbits .text -00002000 00002100 00000100 00000200 00000100 progbits sect1 -00000200 00000300 00000200 00000300 00000100 progbits sect2 -00004000 00004100 00000300 00000400 00000100 progbits sect3 -00000400 00000500 00000400 00000500 00000100 progbits sect4 -00004100 00004200 00000500 00000600 00000100 progbits sect5 -00006000 00006011 00000600 00000611 00000011 progbits sect6 -00000620 00000724 00000614 00000718 00000104 progbits sect7 -00000730 00000830 00000718 00000818 00000100 progbits sect8 -00000830 00000830 00000818 00000818 00000000 progbits sect9 - --- Sections (detailed) -------------------------------------------------------- - ----- Section .text ------------------------------------------------------------ - -class: progbits -length: 00000000 -start: 00000100 -align: 00000004 -follows: not defined -vstart: 00000100 -valign: 00000004 -vfollows: not defined - ----- Section sect1 ------------------------------------------------------------ - -class: progbits -length: 00000100 -start: 00000100 -align: 00000004 -follows: not defined -vstart: 00002000 -valign: 00000004 -vfollows: not defined - ----- Section sect2 ------------------------------------------------------------ - -class: progbits -length: 00000100 -start: 00000200 -align: 00000004 -follows: sect1 -vstart: 00000200 -valign: 00000004 -vfollows: not defined - ----- Section sect3 ------------------------------------------------------------ - -class: progbits -length: 00000100 -start: 00000300 -align: 00000004 -follows: not defined -vstart: 00004000 -valign: 00000004 -vfollows: not defined - ----- Section sect4 ------------------------------------------------------------ - -class: progbits -length: 00000100 -start: 00000400 -align: 00000004 -follows: sect3 -vstart: 00000400 -valign: 00000004 -vfollows: not defined - ----- Section sect5 ------------------------------------------------------------ - -class: progbits -length: 00000100 -start: 00000500 -align: 00000004 -follows: not defined -vstart: 00004100 -valign: 00000004 -vfollows: sect3 - ----- Section sect6 ------------------------------------------------------------ - -class: progbits -length: 00000011 -start: 00000600 -align: 00000004 -follows: not defined -vstart: 00006000 -valign: 00000004 -vfollows: not defined - ----- Section sect7 ------------------------------------------------------------ - -class: progbits -length: 00000104 -start: 00000614 -align: 00000004 -follows: sect6 -vstart: 00000620 -valign: 00000010 -vfollows: not defined - ----- Section sect8 ------------------------------------------------------------ - -class: progbits -length: 00000100 -start: 00000718 -align: 00000004 -follows: sect7 -vstart: 00000730 -valign: 00000010 -vfollows: not defined - ----- Section sect9 ------------------------------------------------------------ - -class: progbits -length: 00000000 -start: 00000818 -align: 00000004 -follows: not defined -vstart: 00000830 -valign: 00000004 -vfollows: sect8 - --- Symbols -------------------------------------------------------------------- - diff --git a/modules/objfmts/bin/tests/multisect/nomultisect1.asm b/modules/objfmts/bin/tests/multisect/nomultisect1.asm deleted file mode 100644 index 5f720d84..00000000 --- a/modules/objfmts/bin/tests/multisect/nomultisect1.asm +++ /dev/null @@ -1,10 +0,0 @@ -[map all] - -[section .bss] -resb 0x100 - -[section .data] -times 0x100 db 1 - -[section .text] -times 0x100 db 1 diff --git a/modules/objfmts/bin/tests/multisect/nomultisect1.hex b/modules/objfmts/bin/tests/multisect/nomultisect1.hex deleted file mode 100644 index 59c9350b..00000000 --- a/modules/objfmts/bin/tests/multisect/nomultisect1.hex +++ /dev/null @@ -1,512 +0,0 @@ -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 diff --git a/modules/objfmts/bin/tests/multisect/nomultisect1.map b/modules/objfmts/bin/tests/multisect/nomultisect1.map deleted file mode 100644 index 0745189b..00000000 --- a/modules/objfmts/bin/tests/multisect/nomultisect1.map +++ /dev/null @@ -1,54 +0,0 @@ - -- YASM Map file --------------------------------------------------------------- - -Source file: - -Output file: nomultisect1 - --- Program origin ------------------------------------------------------------- - -00000000 - --- Sections (summary) --------------------------------------------------------- - -Vstart Vstop Start Stop Length Class Name -00000000 00000100 00000000 00000100 00000100 progbits .text -00000100 00000200 00000100 00000200 00000100 progbits .data -00000200 00000300 00000200 00000300 00000100 nobits .bss - --- Sections (detailed) -------------------------------------------------------- - ----- Section .text ------------------------------------------------------------ - -class: progbits -length: 00000100 -start: 00000000 -align: 00000004 -follows: not defined -vstart: 00000000 -valign: 00000004 -vfollows: not defined - ----- Section .data ------------------------------------------------------------ - -class: progbits -length: 00000100 -start: 00000100 -align: 00000004 -follows: not defined -vstart: 00000100 -valign: 00000004 -vfollows: not defined - ----- Section .bss ------------------------------------------------------------- - -class: nobits -length: 00000100 -start: 00000200 -align: 00000004 -follows: not defined -vstart: 00000200 -valign: 00000004 -vfollows: not defined - --- Symbols -------------------------------------------------------------------- - diff --git a/modules/objfmts/bin/tests/multisect/nomultisect2.asm b/modules/objfmts/bin/tests/multisect/nomultisect2.asm deleted file mode 100644 index b97e40a7..00000000 --- a/modules/objfmts/bin/tests/multisect/nomultisect2.asm +++ /dev/null @@ -1,12 +0,0 @@ -org 0x100 - -[map all] - -[section .bss] -resb 0x100 - -[section .data] -times 0x100 db 1 - -[section .text] -times 0x100 db 1 diff --git a/modules/objfmts/bin/tests/multisect/nomultisect2.hex b/modules/objfmts/bin/tests/multisect/nomultisect2.hex deleted file mode 100644 index 59c9350b..00000000 --- a/modules/objfmts/bin/tests/multisect/nomultisect2.hex +++ /dev/null @@ -1,512 +0,0 @@ -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 diff --git a/modules/objfmts/bin/tests/multisect/nomultisect2.map b/modules/objfmts/bin/tests/multisect/nomultisect2.map deleted file mode 100644 index 7a9d306f..00000000 --- a/modules/objfmts/bin/tests/multisect/nomultisect2.map +++ /dev/null @@ -1,54 +0,0 @@ - -- YASM Map file --------------------------------------------------------------- - -Source file: - -Output file: nomultisect2 - --- Program origin ------------------------------------------------------------- - -00000100 - --- Sections (summary) --------------------------------------------------------- - -Vstart Vstop Start Stop Length Class Name -00000100 00000200 00000100 00000200 00000100 progbits .text -00000200 00000300 00000200 00000300 00000100 progbits .data -00000300 00000400 00000300 00000400 00000100 nobits .bss - --- Sections (detailed) -------------------------------------------------------- - ----- Section .text ------------------------------------------------------------ - -class: progbits -length: 00000100 -start: 00000100 -align: 00000004 -follows: not defined -vstart: 00000100 -valign: 00000004 -vfollows: not defined - ----- Section .data ------------------------------------------------------------ - -class: progbits -length: 00000100 -start: 00000200 -align: 00000004 -follows: not defined -vstart: 00000200 -valign: 00000004 -vfollows: not defined - ----- Section .bss ------------------------------------------------------------- - -class: nobits -length: 00000100 -start: 00000300 -align: 00000004 -follows: not defined -vstart: 00000300 -valign: 00000004 -vfollows: not defined - --- Symbols -------------------------------------------------------------------- - diff --git a/modules/objfmts/bin/tests/multisect/vfollows-loop1-err.asm b/modules/objfmts/bin/tests/multisect/vfollows-loop1-err.asm deleted file mode 100644 index 84a7c1e4..00000000 --- a/modules/objfmts/bin/tests/multisect/vfollows-loop1-err.asm +++ /dev/null @@ -1,2 +0,0 @@ -section sect1 vfollows=sect2 -section sect2 vfollows=sect1 diff --git a/modules/objfmts/bin/tests/multisect/vfollows-loop1-err.errwarn b/modules/objfmts/bin/tests/multisect/vfollows-loop1-err.errwarn deleted file mode 100644 index 3965e589..00000000 --- a/modules/objfmts/bin/tests/multisect/vfollows-loop1-err.errwarn +++ /dev/null @@ -1 +0,0 @@ --: error: vfollows loop between section `sect2' and section `sect1' diff --git a/modules/objfmts/bin/tests/multisect/vfollows-loop2-err.asm b/modules/objfmts/bin/tests/multisect/vfollows-loop2-err.asm deleted file mode 100644 index ac080b85..00000000 --- a/modules/objfmts/bin/tests/multisect/vfollows-loop2-err.asm +++ /dev/null @@ -1 +0,0 @@ -section sect vfollows=sect diff --git a/modules/objfmts/bin/tests/multisect/vfollows-loop2-err.errwarn b/modules/objfmts/bin/tests/multisect/vfollows-loop2-err.errwarn deleted file mode 100644 index 4f252b42..00000000 --- a/modules/objfmts/bin/tests/multisect/vfollows-loop2-err.errwarn +++ /dev/null @@ -1 +0,0 @@ --: error: vfollows loop between section `sect' and section `sect' diff --git a/modules/objfmts/bin/tests/multisect/vfollows-notfound-err.asm b/modules/objfmts/bin/tests/multisect/vfollows-notfound-err.asm deleted file mode 100644 index fe0f6e5b..00000000 --- a/modules/objfmts/bin/tests/multisect/vfollows-notfound-err.asm +++ /dev/null @@ -1,2 +0,0 @@ -section foo vfollows=bar - diff --git a/modules/objfmts/bin/tests/multisect/vfollows-notfound-err.errwarn b/modules/objfmts/bin/tests/multisect/vfollows-notfound-err.errwarn deleted file mode 100644 index 93b44d08..00000000 --- a/modules/objfmts/bin/tests/multisect/vfollows-notfound-err.errwarn +++ /dev/null @@ -1 +0,0 @@ --: error: section `foo' vfollows an invalid or unknown section `bar' diff --git a/modules/objfmts/coff/CMakeLists.txt b/modules/objfmts/coff/CMakeLists.txt deleted file mode 100644 index b25f9ac8..00000000 --- a/modules/objfmts/coff/CMakeLists.txt +++ /dev/null @@ -1,28 +0,0 @@ -YASM_GENMACRO( - ${CMAKE_CURRENT_SOURCE_DIR}/objfmts/coff/win64-nasm.mac - ${CMAKE_CURRENT_BINARY_DIR}/win64-nasm.c - win64_nasm_stdmac - ) - -YASM_GENMACRO( - ${CMAKE_CURRENT_SOURCE_DIR}/objfmts/coff/win64-gas.mac - ${CMAKE_CURRENT_BINARY_DIR}/win64-gas.c - win64_gas_stdmac - ) - -SET(coff_DEPS - ${CMAKE_CURRENT_BINARY_DIR}/win64-nasm.c - ${CMAKE_CURRENT_BINARY_DIR}/win64-gas.c - ) - -SET_SOURCE_FILES_PROPERTIES(objfmts/coff/coff-objfmt.c PROPERTIES - OBJECT_DEPENDS "${coff_DEPS}" - ) - -YASM_ADD_MODULE(objfmt_coff - objfmts/coff/coff-objfmt.c - objfmts/coff/win64-except.c - ) -list(APPEND YASM_MODULES objfmt_win32) -list(APPEND YASM_MODULES objfmt_win64) -list(APPEND YASM_MODULES objfmt_x64) diff --git a/modules/objfmts/coff/Makefile.inc b/modules/objfmts/coff/Makefile.inc index 9564fed3..526f7713 100644 --- a/modules/objfmts/coff/Makefile.inc +++ b/modules/objfmts/coff/Makefile.inc @@ -1,25 +1,11 @@ +# $Id$ + libyasm_a_SOURCES += modules/objfmts/coff/coff-objfmt.c libyasm_a_SOURCES += modules/objfmts/coff/coff-objfmt.h libyasm_a_SOURCES += modules/objfmts/coff/win64-except.c YASM_MODULES += objfmt_coff -$(top_srcdir)/modules/objfmts/coff/coff-objfmt.c: win64-nasm.c win64-gas.c - -win64-nasm.c: $(srcdir)/modules/objfmts/coff/win64-nasm.mac genmacro$(EXEEXT) - $(top_builddir)/genmacro$(EXEEXT) $@ win64_nasm_stdmac $(srcdir)/modules/objfmts/coff/win64-nasm.mac - -BUILT_SOURCES += win64-nasm.c -CLEANFILES += win64-nasm.c -EXTRA_DIST += modules/objfmts/coff/win64-nasm.mac - -win64-gas.c: $(srcdir)/modules/objfmts/coff/win64-gas.mac genmacro$(EXEEXT) - $(top_builddir)/genmacro$(EXEEXT) $@ win64_gas_stdmac $(srcdir)/modules/objfmts/coff/win64-gas.mac - -BUILT_SOURCES += win64-gas.c -CLEANFILES += win64-gas.c -EXTRA_DIST += modules/objfmts/coff/win64-gas.mac - EXTRA_DIST += modules/objfmts/coff/tests/Makefile.inc include modules/objfmts/coff/tests/Makefile.inc diff --git a/modules/objfmts/coff/coff-objfmt.c b/modules/objfmts/coff/coff-objfmt.c index 8f753bfe..e6cd735e 100644 --- a/modules/objfmts/coff/coff-objfmt.c +++ b/modules/objfmts/coff/coff-objfmt.c @@ -26,123 +26,136 @@ */ #include #include +/*@unused@*/ RCSID("$Id$"); +#define YASM_LIB_INTERNAL +#define YASM_BC_INTERNAL +#define YASM_EXPR_INTERNAL #include #include "coff-objfmt.h" -#define REGULAR_OUTBUF_SIZE 1024 +#define REGULAR_OUTBUF_SIZE 1024 -#define COFF_MACHINE_I386 0x014C -#define COFF_MACHINE_AMD64 0x8664 +/* Defining this to 0 sets all section VMA's to 0 rather than as the same as + * the LMA. According to the DJGPP COFF Spec, this should be set to 1 + * (VMA=LMA), and indeed DJGPP's GCC output shows VMA=LMA. However, NASM + * outputs VMA=0 (as if this was 0), and GNU objdump output looks a lot nicer + * with VMA=0. Who's right? This is #defined as changing this setting affects + * several places in the code. + */ +#define COFF_SET_VMA (!objfmt_coff->win32) -#define COFF_F_LNNO 0x0004 /* line number info NOT present */ -#define COFF_F_LSYMS 0x0008 /* local symbols NOT present */ -#define COFF_F_AR32WR 0x0100 /* 32-bit little endian file */ +#define COFF_MACHINE_I386 0x014C +#define COFF_MACHINE_AMD64 0x8664 + +#define COFF_F_LNNO 0x0004 /* line number info NOT present */ +#define COFF_F_LSYMS 0x0008 /* local symbols NOT present */ +#define COFF_F_AR32WR 0x0100 /* 32-bit little endian file */ typedef struct coff_reloc { yasm_reloc reloc; enum { - COFF_RELOC_ABSOLUTE = 0, /* absolute, no reloc needed */ + COFF_RELOC_ABSOLUTE = 0, /* absolute, no reloc needed */ - /* I386 relocations */ - COFF_RELOC_I386_ADDR16 = 0x1, /* 16-bit absolute reference */ - COFF_RELOC_I386_REL16 = 0x2, /* 16-bit PC-relative reference */ - COFF_RELOC_I386_ADDR32 = 0x6, /* 32-bit absolute reference */ - COFF_RELOC_I386_ADDR32NB = 0x7, /* 32-bit absolute ref w/o base */ - COFF_RELOC_I386_SEG12 = 0x9, /* 16-bit absolute segment ref */ - COFF_RELOC_I386_SECTION = 0xA, /* section index */ - COFF_RELOC_I386_SECREL = 0xB, /* offset from start of segment */ - COFF_RELOC_I386_TOKEN = 0xC, /* CLR metadata token */ - COFF_RELOC_I386_SECREL7 = 0xD, /* 7-bit offset from base of sect */ - COFF_RELOC_I386_REL32 = 0x14, /* 32-bit PC-relative reference */ + /* I386 relocations */ + COFF_RELOC_I386_ADDR16 = 0x1, /* 16-bit absolute reference */ + COFF_RELOC_I386_REL16 = 0x2, /* 16-bit PC-relative reference */ + COFF_RELOC_I386_ADDR32 = 0x6, /* 32-bit absolute reference */ + COFF_RELOC_I386_ADDR32NB = 0x7, /* 32-bit absolute ref w/o base */ + COFF_RELOC_I386_SEG12 = 0x9, /* 16-bit absolute segment ref */ + COFF_RELOC_I386_SECTION = 0xA, /* section index */ + COFF_RELOC_I386_SECREL = 0xB, /* offset from start of segment */ + COFF_RELOC_I386_TOKEN = 0xC, /* CLR metadata token */ + COFF_RELOC_I386_SECREL7 = 0xD, /* 7-bit offset from base of sect */ + COFF_RELOC_I386_REL32 = 0x14, /* 32-bit PC-relative reference */ - /* AMD64 relocations */ - COFF_RELOC_AMD64_ADDR64 = 0x1, /* 64-bit address (VA) */ - COFF_RELOC_AMD64_ADDR32 = 0x2, /* 32-bit address (VA) */ - COFF_RELOC_AMD64_ADDR32NB = 0x3, /* 32-bit address w/o base (RVA) */ - COFF_RELOC_AMD64_REL32 = 0x4, /* 32-bit relative (0 byte dist) */ - COFF_RELOC_AMD64_REL32_1 = 0x5, /* 32-bit relative (1 byte dist) */ - COFF_RELOC_AMD64_REL32_2 = 0x6, /* 32-bit relative (2 byte dist) */ - COFF_RELOC_AMD64_REL32_3 = 0x7, /* 32-bit relative (3 byte dist) */ - COFF_RELOC_AMD64_REL32_4 = 0x8, /* 32-bit relative (4 byte dist) */ - COFF_RELOC_AMD64_REL32_5 = 0x9, /* 32-bit relative (5 byte dist) */ - COFF_RELOC_AMD64_SECTION = 0xA, /* section index */ - COFF_RELOC_AMD64_SECREL = 0xB, /* 32-bit offset from base of sect */ - COFF_RELOC_AMD64_SECREL7 = 0xC, /* 7-bit offset from base of sect */ - COFF_RELOC_AMD64_TOKEN = 0xD /* CLR metadata token */ - } type; /* type of relocation */ + /* AMD64 relocations */ + COFF_RELOC_AMD64_ADDR64 = 0x1, /* 64-bit address (VA) */ + COFF_RELOC_AMD64_ADDR32 = 0x2, /* 32-bit address (VA) */ + COFF_RELOC_AMD64_ADDR32NB = 0x3, /* 32-bit address w/o base (RVA) */ + COFF_RELOC_AMD64_REL32 = 0x4, /* 32-bit relative (0 byte dist) */ + COFF_RELOC_AMD64_REL32_1 = 0x5, /* 32-bit relative (1 byte dist) */ + COFF_RELOC_AMD64_REL32_2 = 0x6, /* 32-bit relative (2 byte dist) */ + COFF_RELOC_AMD64_REL32_3 = 0x7, /* 32-bit relative (3 byte dist) */ + COFF_RELOC_AMD64_REL32_4 = 0x8, /* 32-bit relative (4 byte dist) */ + COFF_RELOC_AMD64_REL32_5 = 0x9, /* 32-bit relative (5 byte dist) */ + COFF_RELOC_AMD64_SECTION = 0xA, /* section index */ + COFF_RELOC_AMD64_SECREL = 0xB, /* 32-bit offset from base of sect */ + COFF_RELOC_AMD64_SECREL7 = 0xC, /* 7-bit offset from base of sect */ + COFF_RELOC_AMD64_TOKEN = 0xD /* CLR metadata token */ + } type; /* type of relocation */ } coff_reloc; -#define COFF_STYP_TEXT 0x00000020UL -#define COFF_STYP_DATA 0x00000040UL -#define COFF_STYP_BSS 0x00000080UL -#define COFF_STYP_INFO 0x00000200UL -#define COFF_STYP_STD_MASK 0x000003FFUL -#define COFF_STYP_ALIGN_MASK 0x00F00000UL -#define COFF_STYP_ALIGN_SHIFT 20 -#define COFF_STYP_NRELOC_OVFL 0x01000000UL -#define COFF_STYP_DISCARD 0x02000000UL -#define COFF_STYP_NOCACHE 0x04000000UL -#define COFF_STYP_NOPAGE 0x08000000UL -#define COFF_STYP_SHARED 0x10000000UL -#define COFF_STYP_EXECUTE 0x20000000UL -#define COFF_STYP_READ 0x40000000UL -#define COFF_STYP_WRITE 0x80000000UL -#define COFF_STYP_WIN32_MASK 0xFF000000UL +#define COFF_STYP_TEXT 0x00000020UL +#define COFF_STYP_DATA 0x00000040UL +#define COFF_STYP_BSS 0x00000080UL +#define COFF_STYP_INFO 0x00000200UL +#define COFF_STYP_STD_MASK 0x000003FFUL +#define COFF_STYP_ALIGN_MASK 0x00F00000UL +#define COFF_STYP_ALIGN_SHIFT 20 +#define COFF_STYP_NRELOC_OVFL 0x01000000UL +#define COFF_STYP_DISCARD 0x02000000UL +#define COFF_STYP_NOCACHE 0x04000000UL +#define COFF_STYP_NOPAGE 0x08000000UL +#define COFF_STYP_SHARED 0x10000000UL +#define COFF_STYP_EXECUTE 0x20000000UL +#define COFF_STYP_READ 0x40000000UL +#define COFF_STYP_WRITE 0x80000000UL +#define COFF_STYP_WIN32_MASK 0xFF000000UL -#define COFF_FLAG_NOBASE (1UL<<0) /* Use no-base (NB) relocs */ +#define COFF_FLAG_NOBASE (1UL<<0) /* Use no-base (NB) relocs */ typedef struct coff_section_data { - /*@dependent@*/ yasm_symrec *sym; /* symbol created for this section */ - unsigned int scnum; /* section number (1=first section) */ + /*@dependent@*/ yasm_symrec *sym; /* symbol created for this section */ + unsigned int scnum; /* section number (1=first section) */ unsigned long flags; /* section flags (see COFF_STYP_* above) */ - unsigned long addr; /* starting memory address (first section -> 0) */ + unsigned long addr; /* starting memory address (first section -> 0) */ unsigned long scnptr; /* file ptr to raw data */ - unsigned long size; /* size of raw data (section data) in bytes */ + unsigned long size; /* size of raw data (section data) in bytes */ unsigned long relptr; /* file ptr to relocation */ unsigned long nreloc; /* number of relocation entries >64k -> error */ unsigned long flags2; /* internal flags (see COFF_FLAG_* above) */ - unsigned long strtab_name; /* strtab offset of name if name > 8 chars */ - int isdebug; /* is a debug section? */ + unsigned long strtab_name; /* strtab offset of name if name > 8 chars */ + int isdebug; /* is a debug section? */ } coff_section_data; typedef enum coff_symrec_sclass { - COFF_SCL_EFCN = 0xff, /* physical end of function */ + COFF_SCL_EFCN = 0xff, /* physical end of function */ COFF_SCL_NULL = 0, - COFF_SCL_AUTO = 1, /* automatic variable */ - COFF_SCL_EXT = 2, /* external symbol */ - COFF_SCL_STAT = 3, /* static */ - COFF_SCL_REG = 4, /* register variable */ - COFF_SCL_EXTDEF = 5, /* external definition */ - COFF_SCL_LABEL = 6, /* label */ - COFF_SCL_ULABEL = 7, /* undefined label */ - COFF_SCL_MOS = 8, /* member of structure */ - COFF_SCL_ARG = 9, /* function argument */ - COFF_SCL_STRTAG = 10, /* structure tag */ - COFF_SCL_MOU = 11, /* member of union */ - COFF_SCL_UNTAG = 12, /* union tag */ - COFF_SCL_TPDEF = 13, /* type definition */ - COFF_SCL_USTATIC = 14, /* undefined static */ - COFF_SCL_ENTAG = 15, /* enumeration tag */ - COFF_SCL_MOE = 16, /* member of enumeration */ - COFF_SCL_REGPARM = 17, /* register parameter */ - COFF_SCL_FIELD = 18, /* bit field */ - COFF_SCL_AUTOARG = 19, /* auto argument */ - COFF_SCL_LASTENT = 20, /* dummy entry (end of block) */ - COFF_SCL_BLOCK = 100, /* ".bb" or ".eb" */ - COFF_SCL_FCN = 101, /* ".bf" or ".ef" */ - COFF_SCL_EOS = 102, /* end of structure */ - COFF_SCL_FILE = 103, /* file name */ - COFF_SCL_LINE = 104, /* line # reformatted as symbol table entry */ - COFF_SCL_ALIAS = 105, /* duplicate tag */ - COFF_SCL_HIDDEN = 106 /* ext symbol in dmert public lib */ + COFF_SCL_AUTO = 1, /* automatic variable */ + COFF_SCL_EXT = 2, /* external symbol */ + COFF_SCL_STAT = 3, /* static */ + COFF_SCL_REG = 4, /* register variable */ + COFF_SCL_EXTDEF = 5, /* external definition */ + COFF_SCL_LABEL = 6, /* label */ + COFF_SCL_ULABEL = 7, /* undefined label */ + COFF_SCL_MOS = 8, /* member of structure */ + COFF_SCL_ARG = 9, /* function argument */ + COFF_SCL_STRTAG = 10, /* structure tag */ + COFF_SCL_MOU = 11, /* member of union */ + COFF_SCL_UNTAG = 12, /* union tag */ + COFF_SCL_TPDEF = 13, /* type definition */ + COFF_SCL_USTATIC = 14, /* undefined static */ + COFF_SCL_ENTAG = 15, /* enumeration tag */ + COFF_SCL_MOE = 16, /* member of enumeration */ + COFF_SCL_REGPARM = 17, /* register parameter */ + COFF_SCL_FIELD = 18, /* bit field */ + COFF_SCL_AUTOARG = 19, /* auto argument */ + COFF_SCL_LASTENT = 20, /* dummy entry (end of block) */ + COFF_SCL_BLOCK = 100, /* ".bb" or ".eb" */ + COFF_SCL_FCN = 101, /* ".bf" or ".ef" */ + COFF_SCL_EOS = 102, /* end of structure */ + COFF_SCL_FILE = 103, /* file name */ + COFF_SCL_LINE = 104, /* line # reformatted as symbol table entry */ + COFF_SCL_ALIAS = 105, /* duplicate tag */ + COFF_SCL_HIDDEN = 106 /* ext symbol in dmert public lib */ } coff_symrec_sclass; typedef union coff_symtab_auxent { /* no data needed for section symbol auxent, all info avail from sym */ - /*@owned@*/ char *fname; /* filename aux entry */ + /*@owned@*/ char *fname; /* filename aux entry */ } coff_symtab_auxent; typedef enum coff_symtab_auxtype { @@ -152,36 +165,29 @@ typedef enum coff_symtab_auxtype { } coff_symtab_auxtype; typedef struct coff_symrec_data { - int forcevis; /* force visibility in symbol table */ - unsigned long index; /* assigned COFF symbol table index */ - unsigned int type; /* type */ - coff_symrec_sclass sclass; /* storage class */ + unsigned long index; /* assigned COFF symbol table index */ + coff_symrec_sclass sclass; /* storage class */ - int numaux; /* number of auxiliary entries */ + int numaux; /* number of auxiliary entries */ coff_symtab_auxtype auxtype; /* type of aux entries */ - coff_symtab_auxent aux[1]; /* actually may be any size (including 0) */ + coff_symtab_auxent aux[1]; /* actually may be any size (including 0) */ } coff_symrec_data; typedef struct yasm_objfmt_coff { - yasm_objfmt_base objfmt; /* base structure */ + yasm_objfmt_base objfmt; /* base structure */ - unsigned int parse_scnum; /* sect numbering in parser */ - int win32; /* nonzero for win32/64 output */ - int win64; /* nonzero for win64 output */ + unsigned int parse_scnum; /* sect numbering in parser */ + int win32; /* nonzero for win32/64 output */ + int win64; /* nonzero for win64 output */ - unsigned int machine; /* COFF machine to use */ + unsigned int machine; /* COFF machine to use */ - coff_symrec_data *filesym_data; /* Data for .file symbol */ - - /* data for .def/.endef and related directives */ - coff_symrec_data *def_sym; /* symbol specified by .def */ + coff_symrec_data *filesym_data; /* Data for .file symbol */ /* data for win64 proc_frame and related directives */ - unsigned long proc_frame; /* Line number of start of proc, or 0 */ - unsigned long done_prolog; /* Line number of end of prologue, or 0 */ - /*@null@*/ coff_unwind_info *unwind; /* Unwind info */ - - yasm_symrec *ssym_imagebase; /* ..imagebase symbol for win64 */ + unsigned long proc_frame; /* Line number of start of proc, or 0 */ + unsigned long done_prolog; /* Line number of end of prologue, or 0 */ + /*@null@*/ coff_unwind_info *unwind; /* Unwind info */ } yasm_objfmt_coff; typedef struct coff_objfmt_output_info { @@ -192,11 +198,11 @@ typedef struct coff_objfmt_output_info { /*@only@*/ unsigned char *buf; yasm_section *sect; /*@dependent@*/ coff_section_data *csd; - unsigned long addr; /* start of next section */ + unsigned long addr; /* start of next section */ - unsigned long indx; /* current symbol index */ - int all_syms; /* outputting all symbols? */ - unsigned long strtab_offset; /* current string table offset */ + unsigned long indx; /* current symbol index */ + int all_syms; /* outputting all symbols? */ + unsigned long strtab_offset; /* current string table offset */ } coff_objfmt_output_info; static void coff_section_data_destroy(/*@only@*/ void *d); @@ -215,29 +221,6 @@ static const yasm_assoc_data_callback coff_symrec_data_cb = { coff_symrec_data_print }; -/* Bytecode callback function prototypes */ -static void win32_sxdata_bc_destroy(void *contents); -static void win32_sxdata_bc_print(const void *contents, FILE *f, - int indent_level); -static int win32_sxdata_bc_calc_len - (yasm_bytecode *bc, yasm_bc_add_span_func add_span, void *add_span_data); -static int win32_sxdata_bc_tobytes - (yasm_bytecode *bc, unsigned char **bufp, unsigned char *bufstart, void *d, - yasm_output_value_func output_value, - /*@null@*/ yasm_output_reloc_func output_reloc); - -/* Bytecode callback structures */ -static const yasm_bytecode_callback win32_sxdata_bc_callback = { - win32_sxdata_bc_destroy, - win32_sxdata_bc_print, - yasm_bc_finalize_common, - NULL, - win32_sxdata_bc_calc_len, - yasm_bc_expand_common, - win32_sxdata_bc_tobytes, - 0 -}; - yasm_objfmt_module yasm_coff_LTX_objfmt; yasm_objfmt_module yasm_win32_LTX_objfmt; yasm_objfmt_module yasm_win64_LTX_objfmt; @@ -245,15 +228,13 @@ yasm_objfmt_module yasm_win64_LTX_objfmt; static /*@dependent@*/ coff_symrec_data * coff_objfmt_sym_set_data(yasm_symrec *sym, coff_symrec_sclass sclass, - int numaux, coff_symtab_auxtype auxtype) + int numaux, coff_symtab_auxtype auxtype) { coff_symrec_data *sym_data; sym_data = yasm_xmalloc(sizeof(coff_symrec_data) + - (numaux-1)*sizeof(coff_symtab_auxent)); - sym_data->forcevis = 0; + (numaux-1)*sizeof(coff_symtab_auxent)); sym_data->index = 0; - sym_data->type = 0; sym_data->sclass = sclass; sym_data->numaux = numaux; sym_data->auxtype = auxtype; @@ -271,26 +252,24 @@ coff_common_create(yasm_object *object) /* Only support x86 arch */ if (yasm__strcasecmp(yasm_arch_keyword(object->arch), "x86") != 0) { - yasm_xfree(objfmt_coff); - return NULL; + yasm_xfree(objfmt_coff); + return NULL; } objfmt_coff->parse_scnum = 1; /* section numbering starts at 1 */ /* FIXME: misuse of NULL bytecode here; it works, but only barely. */ filesym = yasm_symtab_define_special(object->symtab, ".file", - YASM_SYM_GLOBAL); + YASM_SYM_GLOBAL); objfmt_coff->filesym_data = - coff_objfmt_sym_set_data(filesym, COFF_SCL_FILE, 1, - COFF_SYMTAB_AUX_FILE); + coff_objfmt_sym_set_data(filesym, COFF_SCL_FILE, 1, + COFF_SYMTAB_AUX_FILE); /* Filename is set in coff_objfmt_output */ objfmt_coff->filesym_data->aux[0].fname = NULL; objfmt_coff->proc_frame = 0; objfmt_coff->done_prolog = 0; objfmt_coff->unwind = NULL; - objfmt_coff->ssym_imagebase = NULL; - objfmt_coff->def_sym = NULL; return objfmt_coff; } @@ -301,20 +280,20 @@ coff_objfmt_create(yasm_object *object) yasm_objfmt_coff *objfmt_coff = coff_common_create(object); if (objfmt_coff) { - /* Support x86 and amd64 machines of x86 arch */ - if (yasm__strcasecmp(yasm_arch_get_machine(object->arch), "x86") == 0) - objfmt_coff->machine = COFF_MACHINE_I386; - else if (yasm__strcasecmp(yasm_arch_get_machine(object->arch), - "amd64") == 0) - objfmt_coff->machine = COFF_MACHINE_AMD64; - else { - yasm_xfree(objfmt_coff); - return NULL; - } + /* Support x86 and amd64 machines of x86 arch */ + if (yasm__strcasecmp(yasm_arch_get_machine(object->arch), "x86") == 0) + objfmt_coff->machine = COFF_MACHINE_I386; + else if (yasm__strcasecmp(yasm_arch_get_machine(object->arch), + "amd64") == 0) + objfmt_coff->machine = COFF_MACHINE_AMD64; + else { + yasm_xfree(objfmt_coff); + return NULL; + } - objfmt_coff->objfmt.module = &yasm_coff_LTX_objfmt; - objfmt_coff->win32 = 0; - objfmt_coff->win64 = 0; + objfmt_coff->objfmt.module = &yasm_coff_LTX_objfmt; + objfmt_coff->win32 = 0; + objfmt_coff->win64 = 0; } return (yasm_objfmt *)objfmt_coff; } @@ -325,36 +304,25 @@ win32_objfmt_create(yasm_object *object) yasm_objfmt_coff *objfmt_coff = coff_common_create(object); if (objfmt_coff) { - /* Support x86 and amd64 machines of x86 arch. - * (amd64 machine supported for backwards compatibility) - */ - if (yasm__strcasecmp(yasm_arch_get_machine(object->arch), - "x86") == 0) { - objfmt_coff->machine = COFF_MACHINE_I386; - objfmt_coff->objfmt.module = &yasm_win32_LTX_objfmt; + /* Support x86 and amd64 machines of x86 arch. + * (amd64 machine supported for backwards compatibility) + */ + if (yasm__strcasecmp(yasm_arch_get_machine(object->arch), + "x86") == 0) { + objfmt_coff->machine = COFF_MACHINE_I386; + objfmt_coff->objfmt.module = &yasm_win32_LTX_objfmt; objfmt_coff->win64 = 0; - } else if (yasm__strcasecmp(yasm_arch_get_machine(object->arch), - "amd64") == 0) { - objfmt_coff->machine = COFF_MACHINE_AMD64; - objfmt_coff->objfmt.module = &yasm_win64_LTX_objfmt; - objfmt_coff->win64 = 1; - } else { - yasm_xfree(objfmt_coff); - return NULL; - } + } else if (yasm__strcasecmp(yasm_arch_get_machine(object->arch), + "amd64") == 0) { + objfmt_coff->machine = COFF_MACHINE_AMD64; + objfmt_coff->objfmt.module = &yasm_win64_LTX_objfmt; + objfmt_coff->win64 = 1; + } else { + yasm_xfree(objfmt_coff); + return NULL; + } - objfmt_coff->win32 = 1; - /* Define a @feat.00 symbol for win32 safeseh handling */ - if (!objfmt_coff->win64) { - yasm_symrec *feat00; - coff_symrec_data *sym_data; - feat00 = yasm_symtab_define_equ(object->symtab, "@feat.00", - yasm_expr_create_ident(yasm_expr_int( - yasm_intnum_create_uint(1)), 0), 0); - sym_data = coff_objfmt_sym_set_data(feat00, COFF_SCL_STAT, 0, - COFF_SYMTAB_AUX_NONE); - sym_data->forcevis = 1; - } + objfmt_coff->win32 = 1; } return (yasm_objfmt *)objfmt_coff; } @@ -365,29 +333,26 @@ win64_objfmt_create(yasm_object *object) yasm_objfmt_coff *objfmt_coff = coff_common_create(object); if (objfmt_coff) { - /* Support amd64 machine of x86 arch */ - if (yasm__strcasecmp(yasm_arch_get_machine(object->arch), - "amd64") == 0) { - objfmt_coff->machine = COFF_MACHINE_AMD64; - } else { - yasm_xfree(objfmt_coff); - return NULL; - } + /* Support amd64 machine of x86 arch */ + if (yasm__strcasecmp(yasm_arch_get_machine(object->arch), + "amd64") == 0) { + objfmt_coff->machine = COFF_MACHINE_AMD64; + } else { + yasm_xfree(objfmt_coff); + return NULL; + } - objfmt_coff->objfmt.module = &yasm_win64_LTX_objfmt; - objfmt_coff->win32 = 1; - objfmt_coff->win64 = 1; - objfmt_coff->ssym_imagebase = - yasm_symtab_define_label(object->symtab, "..imagebase", NULL, 0, 0); + objfmt_coff->objfmt.module = &yasm_win64_LTX_objfmt; + objfmt_coff->win32 = 1; + objfmt_coff->win64 = 1; } return (yasm_objfmt *)objfmt_coff; } -static void -coff_objfmt_init_new_section(yasm_section *sect, unsigned long line) +static coff_section_data * +coff_objfmt_init_new_section(yasm_object *object, yasm_section *sect, + const char *sectname, unsigned long line) { - yasm_object *object = yasm_section_get_object(sect); - const char *sectname = yasm_section_get_name(sect); yasm_objfmt_coff *objfmt_coff = (yasm_objfmt_coff *)object->objfmt; coff_section_data *data; yasm_symrec *sym; @@ -403,28 +368,60 @@ coff_objfmt_init_new_section(yasm_section *sect, unsigned long line) data->flags2 = 0; data->strtab_name = 0; data->isdebug = 0; - - if (yasm__strncasecmp(sectname, ".debug", 6)==0) { - data->flags = COFF_STYP_DATA; - if (objfmt_coff->win32) - data->flags |= COFF_STYP_DISCARD|COFF_STYP_READ; - data->isdebug = 1; - } else - data->flags = COFF_STYP_TEXT; - yasm_section_add_data(sect, &coff_section_data_cb, data); sym = yasm_symtab_define_label(object->symtab, sectname, - yasm_section_bcs_first(sect), 1, line); + yasm_section_bcs_first(sect), 1, line); yasm_symrec_declare(sym, YASM_SYM_GLOBAL, line); coff_objfmt_sym_set_data(sym, COFF_SCL_STAT, 1, COFF_SYMTAB_AUX_SECT); data->sym = sym; + return data; +} + +static int +coff_objfmt_init_remaining_section(yasm_section *sect, /*@null@*/ void *d) +{ + /*@null@*/ coff_objfmt_output_info *info = (coff_objfmt_output_info *)d; + /*@dependent@*/ /*@null@*/ coff_section_data *csd; + + assert(info != NULL); + csd = yasm_section_get_data(sect, &coff_section_data_cb); + if (!csd) { + /* Initialize new one */ + const char *sectname = yasm_section_get_name(sect); + csd = coff_objfmt_init_new_section(info->object, sect, sectname, 0); + if (yasm__strncasecmp(sectname, ".debug", 6)==0) { + csd->flags = COFF_STYP_DATA; + if (info->objfmt_coff->win32) + csd->flags |= COFF_STYP_DISCARD|COFF_STYP_READ; + csd->isdebug = 1; + } else + csd->flags = COFF_STYP_TEXT; + } + + return 0; +} + +static int +coff_objfmt_set_section_addr(yasm_section *sect, /*@null@*/ void *d) +{ + /*@null@*/ coff_objfmt_output_info *info = (coff_objfmt_output_info *)d; + /*@dependent@*/ /*@null@*/ coff_section_data *csd; + + assert(info != NULL); + csd = yasm_section_get_data(sect, &coff_section_data_cb); + assert(csd != NULL); + + csd->addr = info->addr; + info->addr += yasm_bc_next_offset(yasm_section_bcs_last(sect)); + + return 0; } static int coff_objfmt_output_value(yasm_value *value, unsigned char *buf, - unsigned int destsize, unsigned long offset, - yasm_bytecode *bc, int warn, /*@null@*/ void *d) + unsigned int destsize, unsigned long offset, + yasm_bytecode *bc, int warn, /*@null@*/ void *d) { /*@null@*/ coff_objfmt_output_info *info = (coff_objfmt_output_info *)d; yasm_objfmt_coff *objfmt_coff; @@ -438,212 +435,215 @@ coff_objfmt_output_value(yasm_value *value, unsigned char *buf, objfmt_coff = info->objfmt_coff; if (value->abs) - value->abs = yasm_expr_simplify(value->abs, 1); + value->abs = yasm_expr_simplify(value->abs, 1); /* Try to output constant and PC-relative section-local first. * Note this does NOT output any value with a SEG, WRT, external, * cross-section, or non-PC-relative reference (those are handled below). */ switch (yasm_value_output_basic(value, buf, destsize, bc, warn, - info->object->arch)) { - case -1: - return 1; - case 0: - break; - default: - return 0; + info->object->arch)) { + case -1: + return 1; + case 0: + break; + default: + return 0; } /* Handle other expressions, with relocation if necessary */ if (value->rshift > 0 - || (value->seg_of && (value->wrt || value->curpos_rel)) - || (value->section_rel && (value->wrt || value->curpos_rel))) { - yasm_error_set(YASM_ERROR_TOO_COMPLEX, - N_("coff: relocation too complex")); - return 1; + || (value->seg_of && (value->wrt || value->curpos_rel)) + || (value->section_rel && (value->wrt || value->curpos_rel))) { + yasm_error_set(YASM_ERROR_TOO_COMPLEX, + N_("coff: relocation too complex")); + return 1; } intn_val = 0; intn_minus = 0; if (value->rel) { - yasm_sym_vis vis = yasm_symrec_get_visibility(value->rel); - /*@dependent@*/ /*@null@*/ yasm_symrec *sym = value->rel; - unsigned long addr; - coff_reloc *reloc; - int nobase = info->csd->flags2 & COFF_FLAG_NOBASE; + yasm_sym_vis vis = yasm_symrec_get_visibility(value->rel); + /*@dependent@*/ /*@null@*/ yasm_symrec *sym = value->rel; + unsigned long addr; + coff_reloc *reloc; - /* Sometimes we want the relocation to be generated against one - * symbol but the value generated correspond to a different symbol. - * This is done through (sym being referenced) WRT (sym used for - * reloc). Note both syms need to be in the same section! - */ - if (value->wrt && value->wrt == objfmt_coff->ssym_imagebase) - nobase = 1; - else if (value->wrt) { - /*@dependent@*/ /*@null@*/ yasm_bytecode *rel_precbc, *wrt_precbc; + /* Sometimes we want the relocation to be generated against one + * symbol but the value generated correspond to a different symbol. + * This is done through (sym being referenced) WRT (sym used for + * reloc). Note both syms need to be in the same section! + */ + if (value->wrt) { + /*@dependent@*/ /*@null@*/ yasm_bytecode *rel_precbc, *wrt_precbc; + if (!yasm_symrec_get_label(sym, &rel_precbc) + || !yasm_symrec_get_label(value->wrt, &wrt_precbc)) { + yasm_error_set(YASM_ERROR_TOO_COMPLEX, + N_("coff: wrt expression too complex")); + return 1; + } + dist = yasm_calc_bc_dist(wrt_precbc, rel_precbc); + if (!dist) { + yasm_error_set(YASM_ERROR_TOO_COMPLEX, + N_("coff: cannot wrt across sections")); + return 1; + } + sym = value->wrt; + } - if (!yasm_symrec_get_label(sym, &rel_precbc) - || !yasm_symrec_get_label(value->wrt, &wrt_precbc)) { - yasm_error_set(YASM_ERROR_TOO_COMPLEX, - N_("coff: wrt expression too complex")); - return 1; - } - dist = yasm_calc_bc_dist(wrt_precbc, rel_precbc); - if (!dist) { - yasm_error_set(YASM_ERROR_TOO_COMPLEX, - N_("coff: cannot wrt across sections")); - return 1; - } - sym = value->wrt; - } + if (vis & YASM_SYM_COMMON) { + /* In standard COFF, COMMON symbols have their length added in */ + if (!objfmt_coff->win32) { + /*@dependent@*/ /*@null@*/ coff_symrec_data *csymd; + /*@dependent@*/ /*@null@*/ yasm_expr **csize_expr; + /*@dependent@*/ /*@null@*/ yasm_intnum *common_size; - if (vis & YASM_SYM_COMMON) { - /* In standard COFF, COMMON symbols have their length added in */ - if (!objfmt_coff->win32) { - /*@dependent@*/ /*@null@*/ yasm_expr **csize_expr; - /*@dependent@*/ /*@null@*/ yasm_intnum *common_size; + csymd = yasm_symrec_get_data(sym, &coff_symrec_data_cb); + assert(csymd != NULL); + csize_expr = yasm_symrec_get_common_size(sym); + assert(csize_expr != NULL); + common_size = yasm_expr_get_intnum(csize_expr, 1); + if (!common_size) { + yasm_error_set(YASM_ERROR_TOO_COMPLEX, + N_("coff: common size too complex")); + return 1; + } - csize_expr = yasm_symrec_get_common_size(sym); - assert(csize_expr != NULL); - common_size = yasm_expr_get_intnum(csize_expr, 1); - if (!common_size) { - yasm_error_set(YASM_ERROR_TOO_COMPLEX, - N_("coff: common size too complex")); - return 1; - } + if (yasm_intnum_sign(common_size) < 0) { + yasm_error_set(YASM_ERROR_VALUE, + N_("coff: common size is negative")); + return 1; + } - if (yasm_intnum_sign(common_size) < 0) { - yasm_error_set(YASM_ERROR_VALUE, - N_("coff: common size is negative")); - return 1; - } + intn_val += yasm_intnum_get_uint(common_size); + } + } else if (!(vis & YASM_SYM_EXTERN) && !objfmt_coff->win64) { + /*@dependent@*/ /*@null@*/ yasm_bytecode *sym_precbc; - intn_val += yasm_intnum_get_uint(common_size); - } - } else if (!(vis & YASM_SYM_EXTERN) && !objfmt_coff->win64) { - /*@dependent@*/ /*@null@*/ yasm_bytecode *sym_precbc; + /* Local symbols need relocation to their section's start */ + if (yasm_symrec_get_label(sym, &sym_precbc)) { + yasm_section *sym_sect = yasm_bc_get_section(sym_precbc); + /*@null@*/ coff_section_data *sym_csd; + sym_csd = yasm_section_get_data(sym_sect, + &coff_section_data_cb); + assert(sym_csd != NULL); + sym = sym_csd->sym; + intn_val = yasm_bc_next_offset(sym_precbc); + if (COFF_SET_VMA) + intn_val += sym_csd->addr; + } + } - /* Local symbols need relocation to their section's start */ - if (yasm_symrec_get_label(sym, &sym_precbc)) { - yasm_section *sym_sect = yasm_bc_get_section(sym_precbc); - /*@null@*/ coff_section_data *sym_csd; - sym_csd = yasm_section_get_data(sym_sect, - &coff_section_data_cb); - assert(sym_csd != NULL); - sym = sym_csd->sym; - intn_val = yasm_bc_next_offset(sym_precbc); - } - } + if (value->curpos_rel) { + /* For standard COFF, need to adjust to start of section, e.g. + * subtract out the bytecode offset. + * For Win32 COFF, need to adjust based on value size and position. + * For Win64 COFF that's IP-relative, adjust to next bytecode; + * the difference between the offset+destsize and BC length is + * taken care of by special relocation types. + */ + if (objfmt_coff->win64 && value->ip_rel) + intn_val += bc->len*bc->mult_int; + else if (objfmt_coff->win32) + intn_val += offset+destsize; + else + intn_minus = bc->offset; + } - if (value->curpos_rel) { - /* For standard COFF, need to adjust to start of section, e.g. - * subtract out the bytecode offset. - * For Win32 COFF, need to adjust based on value size and position. - * For Win64 COFF that's IP-relative, adjust to next bytecode; - * the difference between the offset+destsize and BC length is - * taken care of by special relocation types. - */ - if (objfmt_coff->win64 && value->ip_rel) - intn_val += bc->len*bc->mult_int; - else if (objfmt_coff->win32) - intn_val += offset+destsize; - else - intn_minus = bc->offset; - } + if (value->seg_of || value->section_rel) { + /* Segment or section-relative generation; zero value. */ + intn_val = 0; + intn_minus = 0; + } - if (value->seg_of) { - /* Segment generation; zero value. */ - intn_val = 0; - intn_minus = 0; - } + /* Generate reloc */ + reloc = yasm_xmalloc(sizeof(coff_reloc)); + addr = bc->offset + offset; + if (COFF_SET_VMA) + addr += info->addr; + reloc->reloc.addr = yasm_intnum_create_uint(addr); + reloc->reloc.sym = sym; - /* Generate reloc */ - reloc = yasm_xmalloc(sizeof(coff_reloc)); - addr = bc->offset + offset; - reloc->reloc.addr = yasm_intnum_create_uint(addr); - reloc->reloc.sym = sym; - - if (value->curpos_rel) { - if (objfmt_coff->machine == COFF_MACHINE_I386) { - if (valsize == 32) - reloc->type = COFF_RELOC_I386_REL32; - else { - yasm_error_set(YASM_ERROR_TYPE, - N_("coff: invalid relocation size")); - return 1; - } - } else if (objfmt_coff->machine == COFF_MACHINE_AMD64) { - if (valsize != 32) { - yasm_error_set(YASM_ERROR_TYPE, - N_("coff: invalid relocation size")); - return 1; - } - if (!value->ip_rel) - reloc->type = COFF_RELOC_AMD64_REL32; - else switch (bc->len*bc->mult_int - (offset+destsize)) { - case 0: - reloc->type = COFF_RELOC_AMD64_REL32; - break; - case 1: - reloc->type = COFF_RELOC_AMD64_REL32_1; - break; - case 2: - reloc->type = COFF_RELOC_AMD64_REL32_2; - break; - case 3: - reloc->type = COFF_RELOC_AMD64_REL32_3; - break; - case 4: - reloc->type = COFF_RELOC_AMD64_REL32_4; - break; - case 5: - reloc->type = COFF_RELOC_AMD64_REL32_5; - break; - default: - yasm_error_set(YASM_ERROR_TYPE, - N_("coff: invalid relocation size")); - return 1; - } - } else - yasm_internal_error(N_("coff objfmt: unrecognized machine")); - } else if (value->seg_of) { - if (objfmt_coff->machine == COFF_MACHINE_I386) - reloc->type = COFF_RELOC_I386_SECTION; - else if (objfmt_coff->machine == COFF_MACHINE_AMD64) - reloc->type = COFF_RELOC_AMD64_SECTION; - else - yasm_internal_error(N_("coff objfmt: unrecognized machine")); - } else if (value->section_rel) { - if (objfmt_coff->machine == COFF_MACHINE_I386) - reloc->type = COFF_RELOC_I386_SECREL; - else if (objfmt_coff->machine == COFF_MACHINE_AMD64) - reloc->type = COFF_RELOC_AMD64_SECREL; - else - yasm_internal_error(N_("coff objfmt: unrecognized machine")); - } else { - if (objfmt_coff->machine == COFF_MACHINE_I386) { - if (nobase) - reloc->type = COFF_RELOC_I386_ADDR32NB; - else - reloc->type = COFF_RELOC_I386_ADDR32; - } else if (objfmt_coff->machine == COFF_MACHINE_AMD64) { - if (valsize == 32) { - if (nobase) - reloc->type = COFF_RELOC_AMD64_ADDR32NB; - else - reloc->type = COFF_RELOC_AMD64_ADDR32; - } else if (valsize == 64) - reloc->type = COFF_RELOC_AMD64_ADDR64; - else { - yasm_error_set(YASM_ERROR_TYPE, - N_("coff: invalid relocation size")); - return 1; - } - } else - yasm_internal_error(N_("coff objfmt: unrecognized machine")); - } - info->csd->nreloc++; - yasm_section_add_reloc(info->sect, (yasm_reloc *)reloc, yasm_xfree); + if (value->curpos_rel) { + if (objfmt_coff->machine == COFF_MACHINE_I386) { + if (valsize == 32) + reloc->type = COFF_RELOC_I386_REL32; + else { + yasm_error_set(YASM_ERROR_TYPE, + N_("coff: invalid relocation size")); + return 1; + } + } else if (objfmt_coff->machine == COFF_MACHINE_AMD64) { + if (valsize != 32) { + yasm_error_set(YASM_ERROR_TYPE, + N_("coff: invalid relocation size")); + return 1; + } + if (!value->ip_rel) + reloc->type = COFF_RELOC_AMD64_REL32; + else switch (bc->len*bc->mult_int - (offset+destsize)) { + case 0: + reloc->type = COFF_RELOC_AMD64_REL32; + break; + case 1: + reloc->type = COFF_RELOC_AMD64_REL32_1; + break; + case 2: + reloc->type = COFF_RELOC_AMD64_REL32_2; + break; + case 3: + reloc->type = COFF_RELOC_AMD64_REL32_3; + break; + case 4: + reloc->type = COFF_RELOC_AMD64_REL32_4; + break; + case 5: + reloc->type = COFF_RELOC_AMD64_REL32_5; + break; + default: + yasm_error_set(YASM_ERROR_TYPE, + N_("coff: invalid relocation size")); + return 1; + } + } else + yasm_internal_error(N_("coff objfmt: unrecognized machine")); + } else if (value->seg_of) { + if (objfmt_coff->machine == COFF_MACHINE_I386) + reloc->type = COFF_RELOC_I386_SECTION; + else if (objfmt_coff->machine == COFF_MACHINE_AMD64) + reloc->type = COFF_RELOC_AMD64_SECTION; + else + yasm_internal_error(N_("coff objfmt: unrecognized machine")); + } else if (value->section_rel) { + if (objfmt_coff->machine == COFF_MACHINE_I386) + reloc->type = COFF_RELOC_I386_SECREL; + else if (objfmt_coff->machine == COFF_MACHINE_AMD64) + reloc->type = COFF_RELOC_AMD64_SECREL; + else + yasm_internal_error(N_("coff objfmt: unrecognized machine")); + } else { + if (objfmt_coff->machine == COFF_MACHINE_I386) { + if (info->csd->flags2 & COFF_FLAG_NOBASE) + reloc->type = COFF_RELOC_I386_ADDR32NB; + else + reloc->type = COFF_RELOC_I386_ADDR32; + } else if (objfmt_coff->machine == COFF_MACHINE_AMD64) { + if (valsize == 32) { + if (info->csd->flags2 & COFF_FLAG_NOBASE) + reloc->type = COFF_RELOC_AMD64_ADDR32NB; + else + reloc->type = COFF_RELOC_AMD64_ADDR32; + } else if (valsize == 64) + reloc->type = COFF_RELOC_AMD64_ADDR64; + else { + yasm_error_set(YASM_ERROR_TYPE, + N_("coff: invalid relocation size")); + return 1; + } + } else + yasm_internal_error(N_("coff objfmt: unrecognized machine")); + } + info->csd->nreloc++; + yasm_section_add_reloc(info->sect, (yasm_reloc *)reloc, yasm_xfree); } /* Build up final integer output from intn_val, intn_minus, value->abs, @@ -651,32 +651,32 @@ coff_objfmt_output_value(yasm_value *value, unsigned char *buf, * intnums above (except for dist). */ if (intn_minus <= intn_val) - intn = yasm_intnum_create_uint(intn_val-intn_minus); + intn = yasm_intnum_create_uint(intn_val-intn_minus); else { - intn = yasm_intnum_create_uint(intn_minus-intn_val); - yasm_intnum_calc(intn, YASM_EXPR_NEG, NULL); + intn = yasm_intnum_create_uint(intn_minus-intn_val); + yasm_intnum_calc(intn, YASM_EXPR_NEG, NULL); } if (value->abs) { - yasm_intnum *intn2 = yasm_expr_get_intnum(&value->abs, 0); - if (!intn2) { - yasm_error_set(YASM_ERROR_TOO_COMPLEX, - N_("coff: relocation too complex")); - yasm_intnum_destroy(intn); - if (dist) - yasm_intnum_destroy(dist); - return 1; - } - yasm_intnum_calc(intn, YASM_EXPR_ADD, intn2); + yasm_intnum *intn2 = yasm_expr_get_intnum(&value->abs, 0); + if (!intn2) { + yasm_error_set(YASM_ERROR_TOO_COMPLEX, + N_("coff: relocation too complex")); + yasm_intnum_destroy(intn); + if (dist) + yasm_intnum_destroy(dist); + return 1; + } + yasm_intnum_calc(intn, YASM_EXPR_ADD, intn2); } if (dist) { - yasm_intnum_calc(intn, YASM_EXPR_ADD, dist); - yasm_intnum_destroy(dist); + yasm_intnum_calc(intn, YASM_EXPR_ADD, dist); + yasm_intnum_destroy(dist); } retval = yasm_arch_intnum_tobytes(info->object->arch, intn, buf, destsize, - valsize, 0, bc, warn); + valsize, 0, bc, warn); yasm_intnum_destroy(intn); return retval; } @@ -692,38 +692,38 @@ coff_objfmt_output_bytecode(yasm_bytecode *bc, /*@null@*/ void *d) assert(info != NULL); bigbuf = yasm_bc_tobytes(bc, info->buf, &size, &gap, info, - coff_objfmt_output_value, NULL); + coff_objfmt_output_value, NULL); /* Don't bother doing anything else if size ended up being 0. */ if (size == 0) { - if (bigbuf) - yasm_xfree(bigbuf); - return 0; + if (bigbuf) + yasm_xfree(bigbuf); + return 0; } info->csd->size += size; /* Warn that gaps are converted to 0 and write out the 0's. */ if (gap) { - unsigned long left; - yasm_warn_set(YASM_WARN_UNINIT_CONTENTS, - N_("uninitialized space declared in code/data section: zeroing")); - /* Write out in chunks */ - memset(info->buf, 0, REGULAR_OUTBUF_SIZE); - left = size; - while (left > REGULAR_OUTBUF_SIZE) { - fwrite(info->buf, REGULAR_OUTBUF_SIZE, 1, info->f); - left -= REGULAR_OUTBUF_SIZE; - } - fwrite(info->buf, left, 1, info->f); + unsigned long left; + yasm_warn_set(YASM_WARN_UNINIT_CONTENTS, + N_("uninitialized space declared in code/data section: zeroing")); + /* Write out in chunks */ + memset(info->buf, 0, REGULAR_OUTBUF_SIZE); + left = size; + while (left > REGULAR_OUTBUF_SIZE) { + fwrite(info->buf, REGULAR_OUTBUF_SIZE, 1, info->f); + left -= REGULAR_OUTBUF_SIZE; + } + fwrite(info->buf, left, 1, info->f); } else { - /* Output buf (or bigbuf if non-NULL) to file */ - fwrite(bigbuf ? bigbuf : info->buf, (size_t)size, 1, info->f); + /* Output buf (or bigbuf if non-NULL) to file */ + fwrite(bigbuf ? bigbuf : info->buf, (size_t)size, 1, info->f); } /* If bigbuf was allocated, free it */ if (bigbuf) - yasm_xfree(bigbuf); + yasm_xfree(bigbuf); return 0; } @@ -743,59 +743,58 @@ coff_objfmt_output_section(yasm_section *sect, /*@null@*/ void *d) /* Add to strtab if in win32 format and name > 8 chars */ if (info->objfmt_coff->win32) { - size_t namelen = strlen(yasm_section_get_name(sect)); - if (namelen > 8) { - csd->strtab_name = info->strtab_offset; - info->strtab_offset += (unsigned long)(namelen + 1); - } + size_t namelen = strlen(yasm_section_get_name(sect)); + if (namelen > 8) { + csd->strtab_name = info->strtab_offset; + info->strtab_offset += (unsigned long)(namelen + 1); + } } if (!csd->isdebug) - csd->addr = info->addr; + csd->addr = info->addr; if ((csd->flags & COFF_STYP_STD_MASK) == COFF_STYP_BSS) { - /* Don't output BSS sections. - * TODO: Check for non-reserve bytecodes? - */ - pos = 0; /* position = 0 because it's not in the file */ - csd->size = yasm_bc_next_offset(yasm_section_bcs_last(sect)); + /* Don't output BSS sections. + * TODO: Check for non-reserve bytecodes? + */ + pos = 0; /* position = 0 because it's not in the file */ + csd->size = yasm_bc_next_offset(yasm_section_bcs_last(sect)); } else { - pos = ftell(info->f); - if (pos == -1) { - yasm__fatal(N_("could not get file position on output file")); - /*@notreached@*/ - return 1; - } + pos = ftell(info->f); + if (pos == -1) { + yasm__fatal(N_("could not get file position on output file")); + /*@notreached@*/ + return 1; + } - info->sect = sect; - info->csd = csd; - yasm_section_bcs_traverse(sect, info->errwarns, info, - coff_objfmt_output_bytecode); + info->sect = sect; + info->csd = csd; + yasm_section_bcs_traverse(sect, info->errwarns, info, + coff_objfmt_output_bytecode); - /* Sanity check final section size */ - if (yasm_errwarns_num_errors(info->errwarns, 0) == 0 && - csd->size != yasm_bc_next_offset(yasm_section_bcs_last(sect))) - yasm_internal_error( - N_("coff: section computed size did not match actual size")); + /* Sanity check final section size */ + if (csd->size != yasm_bc_next_offset(yasm_section_bcs_last(sect))) + yasm_internal_error( + N_("coff: section computed size did not match actual size")); } /* Empty? Go on to next section */ if (csd->size == 0) - return 0; + return 0; if (!csd->isdebug) - info->addr += csd->size; + info->addr += csd->size; csd->scnptr = (unsigned long)pos; /* No relocations to output? Go on to next section */ if (csd->nreloc == 0) - return 0; + return 0; pos = ftell(info->f); if (pos == -1) { - yasm__fatal(N_("could not get file position on output file")); - /*@notreached@*/ - return 1; + yasm__fatal(N_("could not get file position on output file")); + /*@notreached@*/ + return 1; } csd->relptr = (unsigned long)pos; @@ -803,30 +802,30 @@ coff_objfmt_output_section(yasm_section *sect, /*@null@*/ void *d) * (NRELOC_OVFL) and the first relocation contains the number of relocs. */ if (csd->nreloc >= 64*1024 && info->objfmt_coff->win32) { - localbuf = info->buf; - YASM_WRITE_32_L(localbuf, csd->nreloc+1); /* address of relocation */ - YASM_WRITE_32_L(localbuf, 0); /* relocated symbol */ - YASM_WRITE_16_L(localbuf, 0); /* type of relocation */ - fwrite(info->buf, 10, 1, info->f); + localbuf = info->buf; + YASM_WRITE_32_L(localbuf, csd->nreloc+1); /* address of relocation */ + YASM_WRITE_32_L(localbuf, 0); /* relocated symbol */ + YASM_WRITE_16_L(localbuf, 0); /* type of relocation */ + fwrite(info->buf, 10, 1, info->f); } reloc = (coff_reloc *)yasm_section_relocs_first(sect); while (reloc) { - /*@null@*/ coff_symrec_data *csymd; - localbuf = info->buf; + /*@null@*/ coff_symrec_data *csymd; + localbuf = info->buf; - csymd = yasm_symrec_get_data(reloc->reloc.sym, &coff_symrec_data_cb); - if (!csymd) - yasm_internal_error( - N_("coff: no symbol data for relocated symbol")); + csymd = yasm_symrec_get_data(reloc->reloc.sym, &coff_symrec_data_cb); + if (!csymd) + yasm_internal_error( + N_("coff: no symbol data for relocated symbol")); - yasm_intnum_get_sized(reloc->reloc.addr, localbuf, 4, 32, 0, 0, 0); - localbuf += 4; /* address of relocation */ - YASM_WRITE_32_L(localbuf, csymd->index); /* relocated symbol */ - YASM_WRITE_16_L(localbuf, reloc->type); /* type of relocation */ - fwrite(info->buf, 10, 1, info->f); + yasm_intnum_get_sized(reloc->reloc.addr, localbuf, 4, 32, 0, 0, 0); + localbuf += 4; /* address of relocation */ + YASM_WRITE_32_L(localbuf, csymd->index); /* relocated symbol */ + YASM_WRITE_16_L(localbuf, reloc->type); /* type of relocation */ + fwrite(info->buf, 10, 1, info->f); - reloc = (coff_reloc *)yasm_section_reloc_next((yasm_reloc *)reloc); + reloc = (coff_reloc *)yasm_section_reloc_next((yasm_reloc *)reloc); } return 0; @@ -846,7 +845,7 @@ coff_objfmt_output_sectstr(yasm_section *sect, /*@null@*/ void *d) name = yasm_section_get_name(sect); len = strlen(name); if (len > 8) - fwrite(name, len+1, 1, info->f); + fwrite(name, len+1, 1, info->f); return 0; } @@ -866,45 +865,53 @@ coff_objfmt_output_secthead(yasm_section *sect, /*@null@*/ void *d) /* Check to see if alignment is supported size */ if (align > 8192) - align = 8192; + align = 8192; /* Convert alignment into flags setting */ csd->flags &= ~COFF_STYP_ALIGN_MASK; while (align != 0) { - csd->flags += 1<>= 1; + csd->flags += 1<>= 1; } /* section name */ localbuf = info->buf; if (strlen(yasm_section_get_name(sect)) > 8) { - char namenum[30]; - sprintf(namenum, "/%ld", csd->strtab_name); - strncpy((char *)localbuf, namenum, 8); + char namenum[30]; + sprintf(namenum, "/%ld", csd->strtab_name); + strncpy((char *)localbuf, namenum, 8); } else - strncpy((char *)localbuf, yasm_section_get_name(sect), 8); + strncpy((char *)localbuf, yasm_section_get_name(sect), 8); localbuf += 8; - YASM_WRITE_32_L(localbuf, 0); /* physical address */ - YASM_WRITE_32_L(localbuf, 0); /* virtual address */ - YASM_WRITE_32_L(localbuf, csd->size); /* section size */ - YASM_WRITE_32_L(localbuf, csd->scnptr); /* file ptr to data */ - YASM_WRITE_32_L(localbuf, csd->relptr); /* file ptr to relocs */ - YASM_WRITE_32_L(localbuf, 0); /* file ptr to line nums */ + if (csd->isdebug) { + YASM_WRITE_32_L(localbuf, 0); /* physical address */ + YASM_WRITE_32_L(localbuf, 0); /* virtual address */ + } else { + YASM_WRITE_32_L(localbuf, csd->addr); /* physical address */ + if (COFF_SET_VMA) + YASM_WRITE_32_L(localbuf, csd->addr);/* virtual address */ + else + YASM_WRITE_32_L(localbuf, 0); /* virtual address */ + } + YASM_WRITE_32_L(localbuf, csd->size); /* section size */ + YASM_WRITE_32_L(localbuf, csd->scnptr); /* file ptr to data */ + YASM_WRITE_32_L(localbuf, csd->relptr); /* file ptr to relocs */ + YASM_WRITE_32_L(localbuf, 0); /* file ptr to line nums */ if (csd->nreloc >= 64*1024) { - /* Win32/64 has special handling for this case. */ - if (objfmt_coff->win32) - csd->flags |= COFF_STYP_NRELOC_OVFL; - else { - yasm_warn_set(YASM_WARN_GENERAL, - N_("too many relocations in section `%s'"), - yasm_section_get_name(sect)); - yasm_errwarn_propagate(info->errwarns, 0); - } - YASM_WRITE_16_L(localbuf, 0xFFFF); /* max out */ + /* Win32/64 has special handling for this case. */ + if (objfmt_coff->win32) + csd->flags |= COFF_STYP_NRELOC_OVFL; + else { + yasm_warn_set(YASM_WARN_GENERAL, + N_("too many relocations in section `%s'"), + yasm_section_get_name(sect)); + yasm_errwarn_propagate(info->errwarns, 0); + } + YASM_WRITE_16_L(localbuf, 0xFFFF); /* max out */ } else - YASM_WRITE_16_L(localbuf, csd->nreloc); /* num of relocation entries */ - YASM_WRITE_16_L(localbuf, 0); /* num of line number entries */ - YASM_WRITE_32_L(localbuf, csd->flags); /* flags */ + YASM_WRITE_16_L(localbuf, csd->nreloc); /* num of relocation entries */ + YASM_WRITE_16_L(localbuf, 0); /* num of line number entries */ + YASM_WRITE_32_L(localbuf, csd->flags); /* flags */ fwrite(info->buf, 40, 1, info->f); return 0; @@ -920,24 +927,19 @@ coff_objfmt_count_sym(yasm_symrec *sym, /*@null@*/ void *d) assert(info != NULL); sym_data = yasm_symrec_get_data(sym, &coff_symrec_data_cb); + if ((vis & (YASM_SYM_EXTERN|YASM_SYM_GLOBAL|YASM_SYM_COMMON)) && !sym_data) + sym_data = coff_objfmt_sym_set_data(sym, COFF_SCL_EXT, 0, + COFF_SYMTAB_AUX_NONE); - if (info->all_syms || vis != YASM_SYM_LOCAL || yasm_symrec_is_abs(sym) || - (sym_data && sym_data->forcevis)) { - /* Save index in symrec data */ - if (!sym_data) - sym_data = coff_objfmt_sym_set_data(sym, COFF_SCL_NULL, 0, - COFF_SYMTAB_AUX_NONE); - /* Set storage class based on visibility if not already set */ - if (sym_data->sclass == COFF_SCL_NULL) { - if (vis & (YASM_SYM_EXTERN|YASM_SYM_GLOBAL|YASM_SYM_COMMON)) - sym_data->sclass = COFF_SCL_EXT; - else - sym_data->sclass = COFF_SCL_STAT; - } + if (info->all_syms || vis != YASM_SYM_LOCAL) { + /* Save index in symrec data */ + if (!sym_data) { + sym_data = coff_objfmt_sym_set_data(sym, COFF_SCL_STAT, 0, + COFF_SYMTAB_AUX_NONE); + } + sym_data->index = info->indx; - sym_data->index = info->indx; - - info->indx += sym_data->numaux + 1; + info->indx += sym_data->numaux + 1; } return 0; } @@ -947,146 +949,129 @@ coff_objfmt_output_sym(yasm_symrec *sym, /*@null@*/ void *d) { /*@null@*/ coff_objfmt_output_info *info = (coff_objfmt_output_info *)d; yasm_sym_vis vis = yasm_symrec_get_visibility(sym); - int is_abs = yasm_symrec_is_abs(sym); - /*@dependent@*/ /*@null@*/ coff_symrec_data *csymd; - yasm_valparamhead *objext_valparams = - yasm_symrec_get_objext_valparams(sym); - csymd = yasm_symrec_get_data(sym, &coff_symrec_data_cb); assert(info != NULL); - /* Look for "function" flag on global syms */ - if (csymd && csymd->type == 0 && (vis & YASM_SYM_GLOBAL) != 0) { - if (objext_valparams) { - const char *id = yasm_vp_id(yasm_vps_first(objext_valparams)); - if (yasm__strcasecmp(id, "function") == 0) - csymd->type = 0x20; - } - } - /* Don't output local syms unless outputting all syms */ - if (info->all_syms || vis != YASM_SYM_LOCAL || is_abs || - (csymd && csymd->forcevis)) { - /*@only*/ char *name; - const yasm_expr *equ_val; - const yasm_intnum *intn; - unsigned char *localbuf; - size_t len; - int aux; - unsigned long value = 0; - unsigned int scnum = 0xfffe; /* -2 = debugging symbol */ - /*@dependent@*/ /*@null@*/ yasm_section *sect; - /*@dependent@*/ /*@null@*/ yasm_bytecode *precbc; - unsigned long scnlen = 0; /* for sect auxent */ - unsigned long nreloc = 0; /* for sect auxent */ + if (info->all_syms || vis != YASM_SYM_LOCAL) { + const char *name = yasm_symrec_get_name(sym); + const yasm_expr *equ_val; + const yasm_intnum *intn; + unsigned char *localbuf; + size_t len = strlen(name); + int aux; + /*@dependent@*/ /*@null@*/ coff_symrec_data *csymd; + unsigned long value = 0; + unsigned int scnum = 0xfffe; /* -2 = debugging symbol */ + /*@dependent@*/ /*@null@*/ yasm_section *sect; + /*@dependent@*/ /*@null@*/ yasm_bytecode *precbc; + unsigned long scnlen = 0; /* for sect auxent */ + unsigned long nreloc = 0; /* for sect auxent */ + yasm_objfmt_coff *objfmt_coff = info->objfmt_coff; - if (is_abs) - name = yasm__xstrdup(".absolut"); - else - name = yasm_symrec_get_global_name(sym, info->object); - len = strlen(name); + /* Get symrec's of_data (needed for storage class) */ + csymd = yasm_symrec_get_data(sym, &coff_symrec_data_cb); + if (!csymd) + yasm_internal_error(N_("coff: expected sym data to be present")); - /* Get symrec's of_data (needed for storage class) */ - if (!csymd) - yasm_internal_error(N_("coff: expected sym data to be present")); + /* Look at symrec for value/scnum/etc. */ + if (yasm_symrec_get_label(sym, &precbc)) { + if (precbc) + sect = yasm_bc_get_section(precbc); + else + sect = NULL; + /* it's a label: get value and offset. + * If there is not a section, leave as debugging symbol. + */ + if (sect) { + /*@dependent@*/ /*@null@*/ coff_section_data *csectd; + csectd = yasm_section_get_data(sect, &coff_section_data_cb); + if (csectd) { + scnum = csectd->scnum; + scnlen = csectd->size; + nreloc = csectd->nreloc; + if (COFF_SET_VMA) + value = csectd->addr; + } else + yasm_internal_error(N_("didn't understand section")); + if (precbc) + value += yasm_bc_next_offset(precbc); + } + } else if ((equ_val = yasm_symrec_get_equ(sym))) { + yasm_expr *equ_val_copy = yasm_expr_copy(equ_val); + intn = yasm_expr_get_intnum(&equ_val_copy, 1); + if (!intn) { + if (vis & YASM_SYM_GLOBAL) { + yasm_error_set(YASM_ERROR_NOT_CONSTANT, + N_("global EQU value not an integer expression")); + yasm_errwarn_propagate(info->errwarns, equ_val->line); + } + } else + value = yasm_intnum_get_uint(intn); + yasm_expr_destroy(equ_val_copy); - /* Look at symrec for value/scnum/etc. */ - if (yasm_symrec_get_label(sym, &precbc)) { - if (precbc) - sect = yasm_bc_get_section(precbc); - else - sect = NULL; - /* it's a label: get value and offset. - * If there is not a section, leave as debugging symbol. - */ - if (sect) { - /*@dependent@*/ /*@null@*/ coff_section_data *csectd; - csectd = yasm_section_get_data(sect, &coff_section_data_cb); - if (csectd) { - scnum = csectd->scnum; - scnlen = csectd->size; - nreloc = csectd->nreloc; - } else - yasm_internal_error(N_("didn't understand section")); - if (precbc) - value += yasm_bc_next_offset(precbc); - } - } else if ((equ_val = yasm_symrec_get_equ(sym))) { - yasm_expr *equ_val_copy = yasm_expr_copy(equ_val); - intn = yasm_expr_get_intnum(&equ_val_copy, 1); - if (!intn) { - if (vis & YASM_SYM_GLOBAL) { - yasm_error_set(YASM_ERROR_NOT_CONSTANT, - N_("global EQU value not an integer expression")); - yasm_errwarn_propagate(info->errwarns, equ_val->line); - } - } else - value = yasm_intnum_get_uint(intn); - yasm_expr_destroy(equ_val_copy); + scnum = 0xffff; /* -1 = absolute symbol */ + } else { + if (vis & YASM_SYM_COMMON) { + /*@dependent@*/ /*@null@*/ yasm_expr **csize_expr; + csize_expr = yasm_symrec_get_common_size(sym); + assert(csize_expr != NULL); + intn = yasm_expr_get_intnum(csize_expr, 1); + if (!intn) { + yasm_error_set(YASM_ERROR_NOT_CONSTANT, + N_("COMMON data size not an integer expression")); + yasm_errwarn_propagate(info->errwarns, + (*csize_expr)->line); + } else + value = yasm_intnum_get_uint(intn); + scnum = 0; + } + if (vis & YASM_SYM_EXTERN) + scnum = 0; + } - scnum = 0xffff; /* -1 = absolute symbol */ - } else { - if (vis & YASM_SYM_COMMON) { - /*@dependent@*/ /*@null@*/ yasm_expr **csize_expr; - csize_expr = yasm_symrec_get_common_size(sym); - assert(csize_expr != NULL); - intn = yasm_expr_get_intnum(csize_expr, 1); - if (!intn) { - yasm_error_set(YASM_ERROR_NOT_CONSTANT, - N_("COMMON data size not an integer expression")); - yasm_errwarn_propagate(info->errwarns, - (*csize_expr)->line); - } else - value = yasm_intnum_get_uint(intn); - scnum = 0; - } - if (vis & YASM_SYM_EXTERN) - scnum = 0; - } - - localbuf = info->buf; - if (len > 8) { - YASM_WRITE_32_L(localbuf, 0); /* "zeros" field */ - YASM_WRITE_32_L(localbuf, info->strtab_offset); /* strtab offset */ - info->strtab_offset += (unsigned long)(len+1); - } else { - /* <8 chars, so no string table entry needed */ - strncpy((char *)localbuf, name, 8); - localbuf += 8; - } - YASM_WRITE_32_L(localbuf, value); /* value */ - YASM_WRITE_16_L(localbuf, scnum); /* section number */ - YASM_WRITE_16_L(localbuf, csymd->type); /* type */ - YASM_WRITE_8(localbuf, csymd->sclass); /* storage class */ - YASM_WRITE_8(localbuf, csymd->numaux); /* number of aux entries */ - fwrite(info->buf, 18, 1, info->f); - for (aux=0; auxnumaux; aux++) { - localbuf = info->buf; - memset(localbuf, 0, 18); - switch (csymd->auxtype) { - case COFF_SYMTAB_AUX_NONE: - break; - case COFF_SYMTAB_AUX_SECT: - YASM_WRITE_32_L(localbuf, scnlen); /* section length */ - YASM_WRITE_16_L(localbuf, nreloc); /* number relocs */ - YASM_WRITE_16_L(localbuf, 0); /* number line nums */ - break; - case COFF_SYMTAB_AUX_FILE: - len = strlen(csymd->aux[0].fname); - if (len > 14) { - YASM_WRITE_32_L(localbuf, 0); - YASM_WRITE_32_L(localbuf, info->strtab_offset); - info->strtab_offset += (unsigned long)(len+1); - } else - strncpy((char *)localbuf, csymd->aux[0].fname, 14); - break; - default: - yasm_internal_error( - N_("coff: unrecognized aux symtab type")); - } - fwrite(info->buf, 18, 1, info->f); - } - yasm_xfree(name); + localbuf = info->buf; + if (len > 8) { + YASM_WRITE_32_L(localbuf, 0); /* "zeros" field */ + YASM_WRITE_32_L(localbuf, info->strtab_offset); /* strtab offset */ + info->strtab_offset += (unsigned long)(len+1); + } else { + /* <8 chars, so no string table entry needed */ + strncpy((char *)localbuf, name, 8); + localbuf += 8; + } + YASM_WRITE_32_L(localbuf, value); /* value */ + YASM_WRITE_16_L(localbuf, scnum); /* section number */ + YASM_WRITE_16_L(localbuf, 0); /* type is always zero (for now) */ + YASM_WRITE_8(localbuf, csymd->sclass); /* storage class */ + YASM_WRITE_8(localbuf, csymd->numaux); /* number of aux entries */ + fwrite(info->buf, 18, 1, info->f); + for (aux=0; auxnumaux; aux++) { + localbuf = info->buf; + memset(localbuf, 0, 18); + switch (csymd->auxtype) { + case COFF_SYMTAB_AUX_NONE: + break; + case COFF_SYMTAB_AUX_SECT: + YASM_WRITE_32_L(localbuf, scnlen); /* section length */ + YASM_WRITE_16_L(localbuf, nreloc); /* number relocs */ + YASM_WRITE_16_L(localbuf, 0); /* number line nums */ + break; + case COFF_SYMTAB_AUX_FILE: + len = strlen(csymd->aux[0].fname); + if (len > 14) { + YASM_WRITE_32_L(localbuf, 0); + YASM_WRITE_32_L(localbuf, info->strtab_offset); + info->strtab_offset += (unsigned long)(len+1); + } else + strncpy((char *)localbuf, csymd->aux[0].fname, 14); + break; + default: + yasm_internal_error( + N_("coff: unrecognized aux symtab type")); + } + fwrite(info->buf, 18, 1, info->f); + } } return 0; } @@ -1096,42 +1081,40 @@ coff_objfmt_output_str(yasm_symrec *sym, /*@null@*/ void *d) { /*@null@*/ coff_objfmt_output_info *info = (coff_objfmt_output_info *)d; yasm_sym_vis vis = yasm_symrec_get_visibility(sym); - /*@dependent@*/ /*@null@*/ coff_symrec_data *csymd; - csymd = yasm_symrec_get_data(sym, &coff_symrec_data_cb); assert(info != NULL); /* Don't output local syms unless outputting all syms */ - if (info->all_syms || vis != YASM_SYM_LOCAL || - (csymd && csymd->forcevis)) { - /*@only@*/ char *name = yasm_symrec_get_global_name(sym, info->object); - size_t len = strlen(name); - int aux; + if (info->all_syms || vis != YASM_SYM_LOCAL) { + const char *name = yasm_symrec_get_name(sym); + /*@dependent@*/ /*@null@*/ coff_symrec_data *csymd; + size_t len = strlen(name); + int aux; - if (!csymd) - yasm_internal_error(N_("coff: expected sym data to be present")); + csymd = yasm_symrec_get_data(sym, &coff_symrec_data_cb); + if (!csymd) + yasm_internal_error(N_("coff: expected sym data to be present")); - if (len > 8) - fwrite(name, len+1, 1, info->f); - for (aux=0; auxnumaux; aux++) { - switch (csymd->auxtype) { - case COFF_SYMTAB_AUX_FILE: - len = strlen(csymd->aux[0].fname); - if (len > 14) - fwrite(csymd->aux[0].fname, len+1, 1, info->f); - break; - default: - break; - } - } - yasm_xfree(name); + if (len > 8) + fwrite(name, len+1, 1, info->f); + for (aux=0; auxnumaux; aux++) { + switch (csymd->auxtype) { + case COFF_SYMTAB_AUX_FILE: + len = strlen(csymd->aux[0].fname); + if (len > 14) + fwrite(csymd->aux[0].fname, len+1, 1, info->f); + break; + default: + break; + } + } } return 0; } static void coff_objfmt_output(yasm_object *object, FILE *f, int all_syms, - yasm_errwarns *errwarns) + yasm_errwarns *errwarns) { yasm_objfmt_coff *objfmt_coff = (yasm_objfmt_coff *)object->objfmt; coff_objfmt_output_info info; @@ -1143,18 +1126,18 @@ coff_objfmt_output(yasm_object *object, FILE *f, int all_syms, unsigned long ts; if (objfmt_coff->proc_frame) { - yasm_error_set_xref(objfmt_coff->proc_frame, - N_("procedure started here")); - yasm_error_set(YASM_ERROR_GENERAL, - N_("end of file in procedure frame")); - yasm_errwarn_propagate(errwarns, 0); - return; + yasm_error_set_xref(objfmt_coff->proc_frame, + N_("procedure started here")); + yasm_error_set(YASM_ERROR_GENERAL, + N_("end of file in procedure frame")); + yasm_errwarn_propagate(errwarns, 0); + return; } if (objfmt_coff->filesym_data->aux[0].fname) - yasm_xfree(objfmt_coff->filesym_data->aux[0].fname); + yasm_xfree(objfmt_coff->filesym_data->aux[0].fname); objfmt_coff->filesym_data->aux[0].fname = - yasm__xstrdup(object->src_filename); + yasm__xstrdup(object->src_filename); /* Force all syms for win64 because they're needed for relocations. * FIXME: Not *all* syms need to be output, only the ones needed for @@ -1169,11 +1152,17 @@ coff_objfmt_output(yasm_object *object, FILE *f, int all_syms, info.f = f; info.buf = yasm_xmalloc(REGULAR_OUTBUF_SIZE); + /* Initialize section data (and count in parse_scnum) any sections that + * we've not initialized so far. + */ + yasm_object_sections_traverse(object, &info, + coff_objfmt_init_remaining_section); + /* Allocate space for headers by seeking forward */ if (fseek(f, (long)(20+40*(objfmt_coff->parse_scnum-1)), SEEK_SET) < 0) { - yasm__fatal(N_("could not seek on output file")); - /*@notreached@*/ - return; + yasm__fatal(N_("could not seek on output file")); + /*@notreached@*/ + return; } /* Finalize symbol table (assign index to each symbol) */ @@ -1183,17 +1172,28 @@ coff_objfmt_output(yasm_object *object, FILE *f, int all_syms, symtab_count = info.indx; /* Section data/relocs */ + if (COFF_SET_VMA) { + /* If we're setting the VMA, we need to do a first section pass to + * determine each section's addr value before actually outputting + * relocations, as a relocation's section address is added into the + * addends in the generated code. + */ + info.addr = 0; + if (yasm_object_sections_traverse(object, &info, + coff_objfmt_set_section_addr)) + return; + } info.addr = 0; if (yasm_object_sections_traverse(object, &info, - coff_objfmt_output_section)) - return; + coff_objfmt_output_section)) + return; /* Symbol table */ pos = ftell(f); if (pos == -1) { - yasm__fatal(N_("could not get file position on output file")); - /*@notreached@*/ - return; + yasm__fatal(N_("could not get file position on output file")); + /*@notreached@*/ + return; } symtab_pos = (unsigned long)pos; yasm_symtab_traverse(object->symtab, &info, coff_objfmt_output_sym); @@ -1205,30 +1205,30 @@ coff_objfmt_output(yasm_object *object, FILE *f, int all_syms, /* Write headers */ if (fseek(f, 0, SEEK_SET) < 0) { - yasm__fatal(N_("could not seek on output file")); - /*@notreached@*/ - return; + yasm__fatal(N_("could not seek on output file")); + /*@notreached@*/ + return; } localbuf = info.buf; - YASM_WRITE_16_L(localbuf, objfmt_coff->machine); /* magic number */ + YASM_WRITE_16_L(localbuf, objfmt_coff->machine); /* magic number */ YASM_WRITE_16_L(localbuf, objfmt_coff->parse_scnum-1);/* number of sects */ if (getenv("YASM_TEST_SUITE")) - ts = 0; + ts = 0; else - ts = (unsigned long)time(NULL); - YASM_WRITE_32_L(localbuf, ts); /* time/date stamp */ - YASM_WRITE_32_L(localbuf, symtab_pos); /* file ptr to symtab */ - YASM_WRITE_32_L(localbuf, symtab_count); /* number of symtabs */ - YASM_WRITE_16_L(localbuf, 0); /* size of optional header (none) */ + ts = (unsigned long)time(NULL); + YASM_WRITE_32_L(localbuf, ts); /* time/date stamp */ + YASM_WRITE_32_L(localbuf, symtab_pos); /* file ptr to symtab */ + YASM_WRITE_32_L(localbuf, symtab_count); /* number of symtabs */ + YASM_WRITE_16_L(localbuf, 0); /* size of optional header (none) */ /* flags */ flags = 0; if (strcmp(yasm_dbgfmt_keyword(object->dbgfmt), "null")==0) - flags = COFF_F_LNNO; + flags = COFF_F_LNNO; if (!all_syms) - flags |= COFF_F_LSYMS; + flags |= COFF_F_LSYMS; if (objfmt_coff->machine != COFF_MACHINE_AMD64) - flags |= COFF_F_AR32WR; + flags |= COFF_F_AR32WR; YASM_WRITE_16_L(localbuf, flags); fwrite(info.buf, 20, 1, f); @@ -1242,9 +1242,9 @@ coff_objfmt_destroy(yasm_objfmt *objfmt) { yasm_objfmt_coff *objfmt_coff = (yasm_objfmt_coff *)objfmt; if (objfmt_coff->filesym_data->aux[0].fname) - yasm_xfree(objfmt_coff->filesym_data->aux[0].fname); + yasm_xfree(objfmt_coff->filesym_data->aux[0].fname); if (objfmt_coff->unwind) - yasm_win64__uwinfo_destroy(objfmt_coff->unwind); + yasm_win64__uwinfo_destroy(objfmt_coff->unwind); yasm_xfree(objfmt); } @@ -1256,13 +1256,13 @@ coff_objfmt_add_default_section(yasm_object *object) coff_section_data *csd; int isnew; - retval = yasm_object_get_general(object, ".text", 16, 1, 0, &isnew, 0); + retval = yasm_object_get_general(object, ".text", 0, 16, 1, 0, &isnew, 0); if (isnew) { - csd = yasm_section_get_data(retval, &coff_section_data_cb); - csd->flags = COFF_STYP_TEXT; - if (objfmt_coff->win32) - csd->flags |= COFF_STYP_EXECUTE | COFF_STYP_READ; - yasm_section_set_default(retval, 1); + csd = coff_objfmt_init_new_section(object, retval, ".text", 0); + csd->flags = COFF_STYP_TEXT; + if (objfmt_coff->win32) + csd->flags |= COFF_STYP_EXECUTE | COFF_STYP_READ; + yasm_section_set_default(retval, 1); } return retval; } @@ -1314,7 +1314,6 @@ coff_helper_gasflags(void *obj, yasm_valparam *vp, unsigned long line, void *d, datasect = 1; load = 1; readonly = 0; - break; case 'x': code = 1; load = 1; @@ -1354,9 +1353,9 @@ coff_helper_gasflags(void *obj, yasm_valparam *vp, unsigned long line, void *d, static /*@observer@*/ /*@null@*/ yasm_section * coff_objfmt_section_switch(yasm_object *object, yasm_valparamhead *valparams, - /*@unused@*/ /*@null@*/ - yasm_valparamhead *objext_valparams, - unsigned long line) + /*@unused@*/ /*@null@*/ + yasm_valparamhead *objext_valparams, + unsigned long line) { yasm_objfmt_coff *objfmt_coff = (yasm_objfmt_coff *)object->objfmt; yasm_valparam *vp; @@ -1432,7 +1431,7 @@ coff_objfmt_section_switch(yasm_object *object, yasm_valparamhead *valparams, vp = yasm_vps_first(valparams); sectname = yasm_vp_string(vp); if (!sectname) - return NULL; + return NULL; vp = yasm_vps_next(vp); data.isdefault = 0; @@ -1443,53 +1442,50 @@ coff_objfmt_section_switch(yasm_object *object, yasm_valparamhead *valparams, if (strcmp(sectname, ".data") == 0) { data.flags = COFF_STYP_DATA | COFF_STYP_READ | COFF_STYP_WRITE; - if (objfmt_coff->win32) { - if (objfmt_coff->machine == COFF_MACHINE_AMD64) - align = 16; - else - align = 4; - } + if (objfmt_coff->win32) { + if (objfmt_coff->machine == COFF_MACHINE_AMD64) + align = 16; + else + align = 4; + } } else if (strcmp(sectname, ".bss") == 0) { data.flags = COFF_STYP_BSS | COFF_STYP_READ | COFF_STYP_WRITE; - if (objfmt_coff->win32) { - if (objfmt_coff->machine == COFF_MACHINE_AMD64) - align = 16; - else - align = 4; - } - resonly = 1; + if (objfmt_coff->win32) { + if (objfmt_coff->machine == COFF_MACHINE_AMD64) + align = 16; + else + align = 4; + } + resonly = 1; } else if (strcmp(sectname, ".text") == 0) { data.flags = COFF_STYP_TEXT | COFF_STYP_EXECUTE | COFF_STYP_READ; if (objfmt_coff->win32) - align = 16; + align = 16; } else if (strcmp(sectname, ".rdata") == 0 - || strncmp(sectname, ".rodata", 7) == 0 - || strncmp(sectname, ".rdata$", 7) == 0) { + || strncmp(sectname, ".rodata", 7) == 0 + || strncmp(sectname, ".rdata$", 7) == 0) { data.flags = COFF_STYP_DATA | COFF_STYP_READ; if (objfmt_coff->win32) - align = 8; + align = 8; else - yasm_warn_set(YASM_WARN_GENERAL, - N_("Standard COFF does not support read-only data sections")); + yasm_warn_set(YASM_WARN_GENERAL, + N_("Standard COFF does not support read-only data sections")); } else if (strcmp(sectname, ".drectve") == 0) { data.flags = COFF_STYP_INFO; - if (objfmt_coff->win32) + if (objfmt_coff->win32) data.flags |= COFF_STYP_DISCARD | COFF_STYP_READ; } else if (objfmt_coff->win64 && strcmp(sectname, ".pdata") == 0) { data.flags = COFF_STYP_DATA | COFF_STYP_READ; - align = 4; + align = 4; data.flags2 = COFF_FLAG_NOBASE; } else if (objfmt_coff->win64 && strcmp(sectname, ".xdata") == 0) { data.flags = COFF_STYP_DATA | COFF_STYP_READ; - align = 8; - data.flags2 = COFF_FLAG_NOBASE; - } else if (objfmt_coff->win32 && strcmp(sectname, ".sxdata") == 0) { - data.flags = COFF_STYP_INFO; + align = 8; } else if (strcmp(sectname, ".comment") == 0) { data.flags = COFF_STYP_INFO | COFF_STYP_DISCARD | COFF_STYP_READ; } else if (yasm__strncasecmp(sectname, ".debug", 6)==0) { data.flags = COFF_STYP_DATA | COFF_STYP_DISCARD | COFF_STYP_READ; - align = 1; + align = 1; } else { /* Default to code, but set a flag so if we get gasflags we can * change it (NASM and GAS have different defaults). @@ -1505,7 +1501,7 @@ coff_objfmt_section_switch(yasm_object *object, yasm_valparamhead *valparams, return NULL; /* error occurred */ if (data.flags & COFF_STYP_EXECUTE) - iscode = 1; + iscode = 1; if (!objfmt_coff->win32) data.flags &= ~COFF_STYP_WIN32_MASK; @@ -1514,20 +1510,20 @@ coff_objfmt_section_switch(yasm_object *object, yasm_valparamhead *valparams, align = yasm_intnum_get_uint(data.align_intn); yasm_intnum_destroy(data.align_intn); - /* Alignments must be a power of two. */ - if (!is_exp2(align)) { - yasm_error_set(YASM_ERROR_VALUE, - N_("argument to `%s' is not a power of two"), + /* Alignments must be a power of two. */ + if (!is_exp2(align)) { + yasm_error_set(YASM_ERROR_VALUE, + N_("argument to `%s' is not a power of two"), "align"); - return NULL; - } + return NULL; + } - /* Check to see if alignment is supported size */ - if (align > 8192) { - yasm_error_set(YASM_ERROR_VALUE, - N_("Win32 does not support alignments > 8192")); - return NULL; - } + /* Check to see if alignment is supported size */ + if (align > 8192) { + yasm_error_set(YASM_ERROR_VALUE, + N_("Win32 does not support alignments > 8192")); + return NULL; + } } realname = yasm__xstrdup(sectname); @@ -1536,46 +1532,32 @@ coff_objfmt_section_switch(yasm_object *object, yasm_valparamhead *valparams, * files via "/nnnn" (where nnnn is decimal offset into string table), * so only warn for regular COFF. */ - yasm_warn_set(YASM_WARN_GENERAL, + yasm_warn_set(YASM_WARN_GENERAL, N_("COFF section names limited to 8 characters: truncating")); realname[8] = '\0'; } - retval = yasm_object_get_general(object, realname, align, iscode, - resonly, &isnew, line); + retval = yasm_object_get_general(object, realname, 0, align, iscode, + resonly, &isnew, line); + + if (isnew) + csd = coff_objfmt_init_new_section(object, retval, realname, line); + else + csd = yasm_section_get_data(retval, &coff_section_data_cb); + yasm_xfree(realname); - csd = yasm_section_get_data(retval, &coff_section_data_cb); - if (isnew || yasm_section_is_default(retval)) { - yasm_section_set_default(retval, 0); + yasm_section_set_default(retval, 0); csd->flags = data.flags; csd->flags2 = data.flags2; - yasm_section_set_align(retval, align, line); + yasm_section_set_align(retval, align, line); } else if (flags_override && !data.gasflags) - yasm_warn_set(YASM_WARN_GENERAL, - N_("section flags ignored on section redeclaration")); + yasm_warn_set(YASM_WARN_GENERAL, + N_("section flags ignored on section redeclaration")); return retval; } -static /*@observer@*/ /*@null@*/ yasm_symrec * -coff_objfmt_get_special_sym(yasm_object *object, const char *name, - const char *parser) -{ - return NULL; -} - -static /*@observer@*/ /*@null@*/ yasm_symrec * -win64_objfmt_get_special_sym(yasm_object *object, const char *name, - const char *parser) -{ - if (yasm__strcasecmp(name, "imagebase") == 0) { - yasm_objfmt_coff *objfmt_coff = (yasm_objfmt_coff *)object->objfmt; - return objfmt_coff->ssym_imagebase; - } - return NULL; -} - static void coff_section_data_destroy(void *data) { @@ -1592,18 +1574,18 @@ coff_section_data_print(void *data, FILE *f, int indent_level) fprintf(f, "%*sscnum=%d\n", indent_level, "", csd->scnum); fprintf(f, "%*sflags=", indent_level, ""); switch (csd->flags & COFF_STYP_STD_MASK) { - case COFF_STYP_TEXT: - fprintf(f, "TEXT"); - break; - case COFF_STYP_DATA: - fprintf(f, "DATA"); - break; - case COFF_STYP_BSS: - fprintf(f, "BSS"); - break; - default: - fprintf(f, "UNKNOWN"); - break; + case COFF_STYP_TEXT: + fprintf(f, "TEXT"); + break; + case COFF_STYP_DATA: + fprintf(f, "DATA"); + break; + case COFF_STYP_BSS: + fprintf(f, "BSS"); + break; + default: + fprintf(f, "UNKNOWN"); + break; } fprintf(f, "\n%*saddr=0x%lx\n", indent_level, "", csd->addr); fprintf(f, "%*sscnptr=0x%lx\n", indent_level, "", csd->scnptr); @@ -1630,7 +1612,7 @@ coff_symrec_data_print(void *data, FILE *f, int indent_level) static void dir_export(yasm_object *object, yasm_valparamhead *valparams, - yasm_valparamhead *objext_valparams, unsigned long line) + yasm_valparamhead *objext_valparams, unsigned long line) { yasm_valparam *vp; /*@null@*/ const char *symname; @@ -1644,124 +1626,36 @@ dir_export(yasm_object *object, yasm_valparamhead *valparams, if (symname) yasm_symtab_use(object->symtab, symname, line); else { - yasm_error_set(YASM_ERROR_SYNTAX, - N_("argument to EXPORT must be symbol name")); - return; + yasm_error_set(YASM_ERROR_SYNTAX, + N_("argument to EXPORT must be symbol name")); + return; } /* Add to end of linker directives */ - sect = yasm_object_get_general(object, ".drectve", 0, 0, 0, &isnew, line); + sect = yasm_object_get_general(object, ".drectve", 0, 0, 0, 0, &isnew, + line); /* Initialize directive section if needed */ if (isnew) { - coff_section_data *csd; - csd = yasm_section_get_data(sect, &coff_section_data_cb); - csd->flags = COFF_STYP_INFO | COFF_STYP_DISCARD | COFF_STYP_READ; + coff_section_data *csd; + csd = coff_objfmt_init_new_section(object, sect, + yasm_section_get_name(sect), line); + csd->flags = COFF_STYP_INFO | COFF_STYP_DISCARD | COFF_STYP_READ; } /* Add text as data bytecode */ yasm_dvs_initialize(&dvs); yasm_dvs_append(&dvs, yasm_dv_create_string(yasm__xstrdup("-export:"), - strlen("-export:"))); + strlen("-export:"))); yasm_dvs_append(&dvs, yasm_dv_create_string(yasm__xstrdup(symname), strlen(symname))); yasm_dvs_append(&dvs, yasm_dv_create_string(yasm__xstrdup(" "), 1)); yasm_section_bcs_append(sect, yasm_bc_create_data(&dvs, 1, 0, NULL, line)); } -static void -dir_safeseh(yasm_object *object, yasm_valparamhead *valparams, - yasm_valparamhead *objext_valparams, unsigned long line) -{ - yasm_valparam *vp; - /*@null@*/ const char *symname; - yasm_symrec *sym; - int isnew; - yasm_section *sect; - - /* Reference symbol (to generate error if not declared). - * Also, symbol must be externally visible, so force it. - */ - vp = yasm_vps_first(valparams); - symname = yasm_vp_id(vp); - if (symname) { - coff_symrec_data *sym_data; - sym = yasm_symtab_use(object->symtab, symname, line); - sym_data = yasm_symrec_get_data(sym, &coff_symrec_data_cb); - if (!sym_data) { - sym_data = coff_objfmt_sym_set_data(sym, COFF_SCL_NULL, 0, - COFF_SYMTAB_AUX_NONE); - } - sym_data->forcevis = 1; - sym_data->type = 0x20; /* function */ - } else { - yasm_error_set(YASM_ERROR_SYNTAX, - N_("argument to SAFESEH must be symbol name")); - return; - } - - /* - * Add symbol number to end of .sxdata section. - */ - - sect = yasm_object_get_general(object, ".sxdata", 0, 0, 0, &isnew, line); - - /* Initialize sxdata section if needed */ - if (isnew) { - coff_section_data *csd; - csd = yasm_section_get_data(sect, &coff_section_data_cb); - csd->flags = COFF_STYP_INFO; - } - - /* Add as sxdata bytecode */ - yasm_section_bcs_append(sect, - yasm_bc_create_common(&win32_sxdata_bc_callback, - sym, line)); -} - -static void -win32_sxdata_bc_destroy(void *contents) -{ - /* Contents is just the symbol pointer, so no need to delete */ -} - -static void -win32_sxdata_bc_print(const void *contents, FILE *f, int indent_level) -{ - /* TODO */ -} - -static int -win32_sxdata_bc_calc_len(yasm_bytecode *bc, yasm_bc_add_span_func add_span, - void *add_span_data) -{ - bc->len += 4; - return 0; -} - -static int -win32_sxdata_bc_tobytes(yasm_bytecode *bc, unsigned char **bufp, - unsigned char *bufstart, void *d, - yasm_output_value_func output_value, - yasm_output_reloc_func output_reloc) -{ - yasm_symrec *sym = (yasm_symrec *)bc->contents; - unsigned char *buf = *bufp; - coff_symrec_data *csymd; - - csymd = yasm_symrec_get_data(sym, &coff_symrec_data_cb); - if (!csymd) - yasm_internal_error(N_("coff: no symbol data for SAFESEH symbol")); - - YASM_WRITE_32_L(buf, csymd->index); - - *bufp = buf; - return 0; -} - static void dir_ident(yasm_object *object, yasm_valparamhead *valparams, - yasm_valparamhead *objext_valparams, unsigned long line) + yasm_valparamhead *objext_valparams, unsigned long line) { yasm_objfmt_coff *objfmt_coff = (yasm_objfmt_coff *)object->objfmt; yasm_valparamhead sect_vps; @@ -1772,20 +1666,20 @@ dir_ident(yasm_object *object, yasm_valparamhead *valparams, /* Accept, but do nothing with empty ident */ if (!valparams) - return; + return; vp = yasm_vps_first(valparams); if (!vp) - return; + return; if (objfmt_coff->win32) { - /* Put ident data into .comment section for COFF, or .rdata$zzz - * to be compatible with the GNU linker, which doesn't ignore - * .comment (see binutils/gas/config/obj-coff.c:476-502). - */ - sectname = ".rdata$zzz"; + /* Put ident data into .comment section for COFF, or .rdata$zzz + * to be compatible with the GNU linker, which doesn't ignore + * .comment (see binutils/gas/config/obj-coff.c:476-502). + */ + sectname = ".rdata$zzz"; } else { - sectname = ".comment"; + sectname = ".comment"; } yasm_vps_initialize(§_vps); vp2 = yasm_vp_create_id(NULL, yasm__xstrdup(sectname), '\0'); @@ -1797,12 +1691,12 @@ dir_ident(yasm_object *object, yasm_valparamhead *valparams, * initial 0 byte in the section. */ if (yasm_section_bcs_first(comment) == yasm_section_bcs_last(comment)) { - yasm_dvs_initialize(&dvs); - yasm_dvs_append(&dvs, yasm_dv_create_expr( - yasm_expr_create_ident(yasm_expr_int(yasm_intnum_create_uint(0)), - line))); - yasm_section_bcs_append(comment, - yasm_bc_create_data(&dvs, 1, 0, object->arch, line)); + yasm_dvs_initialize(&dvs); + yasm_dvs_append(&dvs, yasm_dv_create_expr( + yasm_expr_create_ident(yasm_expr_int(yasm_intnum_create_uint(0)), + line))); + yasm_section_bcs_append(comment, + yasm_bc_create_data(&dvs, 1, 0, object->arch, line)); } yasm_dvs_initialize(&dvs); @@ -1819,148 +1713,23 @@ dir_ident(yasm_object *object, yasm_valparamhead *valparams, } while ((vp = yasm_vps_next(vp))); yasm_section_bcs_append(comment, - yasm_bc_create_data(&dvs, 1, 1, object->arch, line)); -} - -static void -dir_secrel32(yasm_object *object, yasm_valparamhead *valparams, - yasm_valparamhead *objext_valparams, unsigned long line) -{ - yasm_datavalhead dvs; - yasm_valparam *vp; - - if (!object->cur_section) { - yasm_error_set(YASM_ERROR_SYNTAX, - N_(".secrel32 can only be used inside of a section")); - return; - } - - vp = yasm_vps_first(valparams); - yasm_dvs_initialize(&dvs); - do { - yasm_expr *e = yasm_vp_expr(vp, object->symtab, line); - yasm_dataval *dv; - if (!e) { - yasm_error_set(YASM_ERROR_VALUE, - N_(".secrel32 requires expressions")); - yasm_dvs_delete(&dvs); - return; - } - dv = yasm_dv_create_expr(e); - yasm_dv_get_value(dv)->section_rel = 1; - yasm_dvs_append(&dvs, dv); - } while ((vp = yasm_vps_next(vp))); - - yasm_section_bcs_append(object->cur_section, - yasm_bc_create_data(&dvs, 4, 0, object->arch, line)); -} - -static void -dir_def(yasm_object *object, yasm_valparamhead *valparams, - yasm_valparamhead *objext_valparams, unsigned long line) -{ - yasm_objfmt_coff *objfmt_coff = (yasm_objfmt_coff *)object->objfmt; - yasm_valparam *vp; - const char *symname; - yasm_symrec *sym; - coff_symrec_data *sym_data; - - if (objfmt_coff->def_sym) { - yasm_warn_set(YASM_WARN_GENERAL, - N_(".def pseudo-op used inside of .def/.endef; ignored")); - return; - } - - vp = yasm_vps_first(valparams); - symname = yasm_vp_id(vp); - if (!symname) { - yasm_error_set(YASM_ERROR_SYNTAX, - N_("argument to SAFESEH must be symbol name")); - return; - } - - sym = yasm_symtab_use(object->symtab, symname, line); - sym_data = yasm_symrec_get_data(sym, &coff_symrec_data_cb); - if (!sym_data) { - sym_data = coff_objfmt_sym_set_data(sym, COFF_SCL_NULL, 0, - COFF_SYMTAB_AUX_NONE); - } - objfmt_coff->def_sym = sym_data; -} - -static void -dir_scl(yasm_object *object, yasm_valparamhead *valparams, - yasm_valparamhead *objext_valparams, unsigned long line) -{ - yasm_objfmt_coff *objfmt_coff = (yasm_objfmt_coff *)object->objfmt; - yasm_intnum *intn = NULL; - - if (!objfmt_coff->def_sym) { - yasm_warn_set(YASM_WARN_GENERAL, - N_("%s pseudo-op used outside of .def/.endef; ignored"), - ".scl"); - return; - } - - if (yasm_dir_helper_intn(object, yasm_vps_first(valparams), line, - &intn, 0) < 0) - return; - if (!intn) - return; - objfmt_coff->def_sym->sclass = yasm_intnum_get_uint(intn); - yasm_intnum_destroy(intn); -} - -static void -dir_type(yasm_object *object, yasm_valparamhead *valparams, - yasm_valparamhead *objext_valparams, unsigned long line) -{ - yasm_objfmt_coff *objfmt_coff = (yasm_objfmt_coff *)object->objfmt; - yasm_intnum *intn = NULL; - - if (!objfmt_coff->def_sym) { - yasm_warn_set(YASM_WARN_GENERAL, - N_("%s pseudo-op used outside of .def/.endef; ignored"), - ".type"); - return; - } - - if (yasm_dir_helper_intn(object, yasm_vps_first(valparams), line, - &intn, 0) < 0) - return; - if (!intn) - return; - objfmt_coff->def_sym->type = yasm_intnum_get_uint(intn); - yasm_intnum_destroy(intn); -} - -static void -dir_endef(yasm_object *object, yasm_valparamhead *valparams, - yasm_valparamhead *objext_valparams, unsigned long line) -{ - yasm_objfmt_coff *objfmt_coff = (yasm_objfmt_coff *)object->objfmt; - if (!objfmt_coff->def_sym) { - yasm_warn_set(YASM_WARN_GENERAL, - N_(".endef pseudo-op used before .def; ignored")); - return; - } - objfmt_coff->def_sym = NULL; + yasm_bc_create_data(&dvs, 1, 1, object->arch, line)); } static void dir_proc_frame(yasm_object *object, /*@null@*/ yasm_valparamhead *valparams, - yasm_valparamhead *objext_valparams, unsigned long line) + yasm_valparamhead *objext_valparams, unsigned long line) { yasm_objfmt_coff *objfmt_coff = (yasm_objfmt_coff *)object->objfmt; yasm_valparam *vp = yasm_vps_first(valparams); const char *name = yasm_vp_id(vp); if (objfmt_coff->proc_frame) { - yasm_error_set_xref(objfmt_coff->proc_frame, - N_("previous procedure started here")); - yasm_error_set(YASM_ERROR_SYNTAX, - N_("nested procedures not supported (didn't use [ENDPROC_FRAME]?)")); - return; + yasm_error_set_xref(objfmt_coff->proc_frame, + N_("previous procedure started here")); + yasm_error_set(YASM_ERROR_SYNTAX, + N_("nested procedures not supported (didn't use [ENDPROC_FRAME]?)")); + return; } objfmt_coff->proc_frame = line; objfmt_coff->done_prolog = 0; @@ -1970,7 +1739,7 @@ dir_proc_frame(yasm_object *object, /*@null@*/ yasm_valparamhead *valparams, /* Optional error handler */ vp = yasm_vps_next(vp); if (!vp || !(name = yasm_vp_id(vp))) - return; + return; objfmt_coff->unwind->ehandler = yasm_symtab_use(object->symtab, name, line); } @@ -1979,19 +1748,19 @@ static int procframe_checkstate(yasm_objfmt_coff *objfmt_coff, const char *dirname) { if (!objfmt_coff->proc_frame) { - yasm_error_set(YASM_ERROR_SYNTAX, - N_("[%s] without preceding [PROC_FRAME]"), dirname); - return 0; + yasm_error_set(YASM_ERROR_SYNTAX, + N_("[%s] without preceding [PROC_FRAME]"), dirname); + return 0; } if (objfmt_coff->done_prolog) { - yasm_error_set_xref(objfmt_coff->done_prolog, - N_("prologue ended here")); - yasm_error_set(YASM_ERROR_SYNTAX, N_("[%s] after end of prologue"), - dirname); - return 0; + yasm_error_set_xref(objfmt_coff->done_prolog, + N_("prologue ended here")); + yasm_error_set(YASM_ERROR_SYNTAX, N_("[%s] after end of prologue"), + dirname); + return 0; } if (!objfmt_coff->unwind) - yasm_internal_error(N_("unwind info not present")); + yasm_internal_error(N_("unwind info not present")); return 1; } @@ -2008,12 +1777,12 @@ get_curpos(yasm_object *object, const char *dirname, unsigned long line) return NULL; } return yasm_symtab_define_curpos(object->symtab, "$", - yasm_section_bcs_last(object->cur_section), line); + yasm_section_bcs_last(object->cur_section), line); } static void dir_pushreg(yasm_object *object, yasm_valparamhead *valparams, - yasm_valparamhead *objext_valparams, unsigned long line) + yasm_valparamhead *objext_valparams, unsigned long line) { yasm_objfmt_coff *objfmt_coff = (yasm_objfmt_coff *)object->objfmt; yasm_valparam *vp = yasm_vps_first(valparams); @@ -2021,14 +1790,14 @@ dir_pushreg(yasm_object *object, yasm_valparamhead *valparams, const uintptr_t *reg; if (!procframe_checkstate(objfmt_coff, "PUSHREG")) - return; + return; if (vp->type != YASM_PARAM_EXPR || !(reg = yasm_expr_get_reg(&vp->param.e, 0))) { - yasm_error_set(YASM_ERROR_SYNTAX, - N_("[%s] requires a register as the first parameter"), - "PUSHREG"); - return; + yasm_error_set(YASM_ERROR_SYNTAX, + N_("[%s] requires a register as the first parameter"), + "PUSHREG"); + return; } /* Generate a PUSH_NONVOL unwind code. */ @@ -2043,7 +1812,7 @@ dir_pushreg(yasm_object *object, yasm_valparamhead *valparams, static void dir_setframe(yasm_object *object, yasm_valparamhead *valparams, - yasm_valparamhead *objext_valparams, unsigned long line) + yasm_valparamhead *objext_valparams, unsigned long line) { yasm_objfmt_coff *objfmt_coff = (yasm_objfmt_coff *)object->objfmt; yasm_valparam *vp = yasm_vps_first(valparams); @@ -2052,14 +1821,14 @@ dir_setframe(yasm_object *object, yasm_valparamhead *valparams, yasm_expr *off = NULL; if (!procframe_checkstate(objfmt_coff, "SETFRAME")) - return; + return; if (vp->type != YASM_PARAM_EXPR || !(reg = yasm_expr_get_reg(&vp->param.e, 0))) { - yasm_error_set(YASM_ERROR_SYNTAX, - N_("[%s] requires a register as the first parameter"), - "SETFRAME"); - return; + yasm_error_set(YASM_ERROR_SYNTAX, + N_("[%s] requires a register as the first parameter"), + "SETFRAME"); + return; } vp = yasm_vps_next(vp); @@ -2082,7 +1851,7 @@ dir_setframe(yasm_object *object, yasm_valparamhead *valparams, static void dir_allocstack(yasm_object *object, yasm_valparamhead *valparams, - yasm_valparamhead *objext_valparams, unsigned long line) + yasm_valparamhead *objext_valparams, unsigned long line) { yasm_objfmt_coff *objfmt_coff = (yasm_objfmt_coff *)object->objfmt; yasm_valparam *vp = yasm_vps_first(valparams); @@ -2090,13 +1859,13 @@ dir_allocstack(yasm_object *object, yasm_valparamhead *valparams, coff_unwind_code *code; if (!procframe_checkstate(objfmt_coff, "ALLOCSTACK")) - return; + return; size = yasm_vp_expr(vp, object->symtab, line); if (!size) { - yasm_error_set(YASM_ERROR_SYNTAX, N_("[%s] requires a size"), - "ALLOCSTACK"); - return; + yasm_error_set(YASM_ERROR_SYNTAX, N_("[%s] requires a size"), + "ALLOCSTACK"); + return; } /* Generate an ALLOC_SMALL unwind code; this will get enlarged to an @@ -2113,7 +1882,7 @@ dir_allocstack(yasm_object *object, yasm_valparamhead *valparams, static void dir_save_common(yasm_object *object, yasm_valparamhead *valparams, - unsigned long line, const char *name, int op) + unsigned long line, const char *name, int op) { yasm_objfmt_coff *objfmt_coff = (yasm_objfmt_coff *)object->objfmt; yasm_valparam *vp = yasm_vps_first(valparams); @@ -2122,23 +1891,23 @@ dir_save_common(yasm_object *object, yasm_valparamhead *valparams, /*@only@*/ /*@null@*/ yasm_expr *offset; if (!procframe_checkstate(objfmt_coff, name)) - return; + return; if (vp->type != YASM_PARAM_EXPR || !(reg = yasm_expr_get_reg(&vp->param.e, 0))) { - yasm_error_set(YASM_ERROR_SYNTAX, - N_("[%s] requires a register as the first parameter"), - name); - return; + yasm_error_set(YASM_ERROR_SYNTAX, + N_("[%s] requires a register as the first parameter"), + name); + return; } vp = yasm_vps_next(vp); offset = yasm_vp_expr(vp, object->symtab, line); if (!offset) { - yasm_error_set(YASM_ERROR_SYNTAX, - N_("[%s] requires an offset as the second parameter"), - name); - return; + yasm_error_set(YASM_ERROR_SYNTAX, + N_("[%s] requires an offset as the second parameter"), + name); + return; } /* Generate a SAVE_XXX unwind code; this will get enlarged to a @@ -2155,28 +1924,28 @@ dir_save_common(yasm_object *object, yasm_valparamhead *valparams, static void dir_savereg(yasm_object *object, yasm_valparamhead *valparams, - yasm_valparamhead *objext_valparams, unsigned long line) + yasm_valparamhead *objext_valparams, unsigned long line) { dir_save_common(object, valparams, line, "SAVEREG", UWOP_SAVE_NONVOL); } static void dir_savexmm128(yasm_object *object, yasm_valparamhead *valparams, - yasm_valparamhead *objext_valparams, unsigned long line) + yasm_valparamhead *objext_valparams, unsigned long line) { dir_save_common(object, valparams, line, "SAVEXMM128", UWOP_SAVE_XMM128); } static void dir_pushframe(yasm_object *object, /*@null@*/ yasm_valparamhead *valparams, - yasm_valparamhead *objext_valparams, unsigned long line) + yasm_valparamhead *objext_valparams, unsigned long line) { yasm_objfmt_coff *objfmt_coff = (yasm_objfmt_coff *)object->objfmt; yasm_valparam *vp = yasm_vps_first(valparams); coff_unwind_code *code; if (!procframe_checkstate(objfmt_coff, "PUSHFRAME")) - return; + return; /* Generate a PUSH_MACHFRAME unwind code. If there's any parameter, * we set info to 1. Otherwise we set info to 0. @@ -2192,11 +1961,11 @@ dir_pushframe(yasm_object *object, /*@null@*/ yasm_valparamhead *valparams, static void dir_endprolog(yasm_object *object, /*@null@*/ yasm_valparamhead *valparams, - yasm_valparamhead *objext_valparams, unsigned long line) + yasm_valparamhead *objext_valparams, unsigned long line) { yasm_objfmt_coff *objfmt_coff = (yasm_objfmt_coff *)object->objfmt; if (!procframe_checkstate(objfmt_coff, "ENDPROLOG")) - return; + return; objfmt_coff->done_prolog = line; objfmt_coff->unwind->prolog = get_curpos(object, "ENDPROLOG", line); @@ -2204,7 +1973,7 @@ dir_endprolog(yasm_object *object, /*@null@*/ yasm_valparamhead *valparams, static void dir_endproc_frame(yasm_object *object, /*@null@*/ yasm_valparamhead *valparams, - yasm_valparamhead *objext_valparams, unsigned long line) + yasm_valparamhead *objext_valparams, unsigned long line) { yasm_objfmt_coff *objfmt_coff = (yasm_objfmt_coff *)object->objfmt; yasm_section *sect; @@ -2214,24 +1983,24 @@ dir_endproc_frame(yasm_object *object, /*@null@*/ yasm_valparamhead *valparams, /*@dependent@*/ yasm_symrec *curpos, *unwindpos, *proc_sym, *xdata_sym; if (!objfmt_coff->proc_frame) { - yasm_error_set(YASM_ERROR_SYNTAX, - N_("[%s] without preceding [PROC_FRAME]"), - "ENDPROC_FRAME"); - return; + yasm_error_set(YASM_ERROR_SYNTAX, + N_("[%s] without preceding [PROC_FRAME]"), + "ENDPROC_FRAME"); + return; } if (!objfmt_coff->done_prolog) { - yasm_error_set_xref(objfmt_coff->proc_frame, - N_("procedure started here")); - yasm_error_set(YASM_ERROR_SYNTAX, - N_("ended procedure without ending prologue"), - "ENDPROC_FRAME"); - objfmt_coff->proc_frame = 0; - yasm_win64__uwinfo_destroy(objfmt_coff->unwind); - objfmt_coff->unwind = NULL; - return; + yasm_error_set_xref(objfmt_coff->proc_frame, + N_("procedure started here")); + yasm_error_set(YASM_ERROR_SYNTAX, + N_("ended procedure without ending prologue"), + "ENDPROC_FRAME"); + objfmt_coff->proc_frame = 0; + yasm_win64__uwinfo_destroy(objfmt_coff->unwind); + objfmt_coff->unwind = NULL; + return; } if (!objfmt_coff->unwind) - yasm_internal_error(N_("unwind info not present")); + yasm_internal_error(N_("unwind info not present")); proc_sym = objfmt_coff->unwind->proc; @@ -2241,51 +2010,51 @@ dir_endproc_frame(yasm_object *object, /*@null@*/ yasm_valparamhead *valparams, * Add unwind info to end of .xdata section. */ - sect = yasm_object_get_general(object, ".xdata", 0, 0, 0, &isnew, line); + sect = yasm_object_get_general(object, ".xdata", 0, 0, 0, 0, &isnew, line); /* Initialize xdata section if needed */ if (isnew) { - csd = yasm_section_get_data(sect, &coff_section_data_cb); - csd->flags = COFF_STYP_DATA | COFF_STYP_READ; - yasm_section_set_align(sect, 8, line); + csd = coff_objfmt_init_new_section(object, sect, ".xdata", line); + csd->flags = COFF_STYP_DATA | COFF_STYP_READ; + yasm_section_set_align(sect, 8, line); } /* Get current position in .xdata section */ unwindpos = yasm_symtab_define_curpos(object->symtab, "$", - yasm_section_bcs_last(sect), line); + yasm_section_bcs_last(sect), line); /* Get symbol for .xdata as we'll want to reference it with WRT */ csd = yasm_section_get_data(sect, &coff_section_data_cb); xdata_sym = csd->sym; /* Add unwind info. Use line number of start of procedure. */ yasm_win64__unwind_generate(sect, objfmt_coff->unwind, - objfmt_coff->proc_frame); - objfmt_coff->unwind = NULL; /* generate keeps the unwind pointer */ + objfmt_coff->proc_frame); + objfmt_coff->unwind = NULL; /* generate keeps the unwind pointer */ /* * Add function lookup to end of .pdata section. */ - sect = yasm_object_get_general(object, ".pdata", 0, 0, 0, &isnew, line); + sect = yasm_object_get_general(object, ".pdata", 0, 0, 0, 0, &isnew, line); /* Initialize pdata section if needed */ if (isnew) { - csd = yasm_section_get_data(sect, &coff_section_data_cb); - csd->flags = COFF_STYP_DATA | COFF_STYP_READ; - csd->flags2 = COFF_FLAG_NOBASE; - yasm_section_set_align(sect, 4, line); + csd = coff_objfmt_init_new_section(object, sect, ".pdata", line); + csd->flags = COFF_STYP_DATA | COFF_STYP_READ; + csd->flags2 = COFF_FLAG_NOBASE; + yasm_section_set_align(sect, 4, line); } /* Add function structure as data bytecode */ yasm_dvs_initialize(&dvs); yasm_dvs_append(&dvs, yasm_dv_create_expr( - yasm_expr_create_ident(yasm_expr_sym(proc_sym), line))); + yasm_expr_create_ident(yasm_expr_sym(proc_sym), line))); yasm_dvs_append(&dvs, yasm_dv_create_expr( - yasm_expr_create(YASM_EXPR_WRT, yasm_expr_sym(curpos), - yasm_expr_sym(proc_sym), line))); + yasm_expr_create(YASM_EXPR_WRT, yasm_expr_sym(curpos), + yasm_expr_sym(proc_sym), line))); yasm_dvs_append(&dvs, yasm_dv_create_expr( - yasm_expr_create(YASM_EXPR_WRT, yasm_expr_sym(unwindpos), - yasm_expr_sym(xdata_sym), line))); + yasm_expr_create(YASM_EXPR_WRT, yasm_expr_sym(unwindpos), + yasm_expr_sym(xdata_sym), line))); yasm_section_bcs_append(sect, yasm_bc_create_data(&dvs, 4, 0, NULL, line)); objfmt_coff->proc_frame = 0; @@ -2300,13 +2069,8 @@ static const char *coff_objfmt_dbgfmt_keywords[] = { }; static const yasm_directive coff_objfmt_directives[] = { - { ".ident", "gas", dir_ident, YASM_DIR_ANY }, - { "ident", "nasm", dir_ident, YASM_DIR_ANY }, - { ".def", "gas", dir_def, YASM_DIR_ID_REQUIRED }, - { ".endef", "gas", dir_endef, YASM_DIR_ANY }, - { ".scl", "gas", dir_scl, YASM_DIR_ARG_REQUIRED }, - { ".type", "gas", dir_type, YASM_DIR_ARG_REQUIRED }, - { ".secrel32", "gas", dir_secrel32, YASM_DIR_ARG_REQUIRED }, + { ".ident", "gas", dir_ident, YASM_DIR_ANY }, + { "ident", "nasm", dir_ident, YASM_DIR_ANY }, { NULL, NULL, NULL, 0 } }; @@ -2316,18 +2080,14 @@ yasm_objfmt_module yasm_coff_LTX_objfmt = { "coff", "o", 32, - 0, coff_objfmt_dbgfmt_keywords, "null", coff_objfmt_directives, - NULL, /* no standard macros */ coff_objfmt_create, coff_objfmt_output, coff_objfmt_destroy, coff_objfmt_add_default_section, - coff_objfmt_init_new_section, - coff_objfmt_section_switch, - coff_objfmt_get_special_sym + coff_objfmt_section_switch }; /* Define valid debug formats to use with this object format */ @@ -2339,129 +2099,72 @@ static const char *winXX_objfmt_dbgfmt_keywords[] = { }; static const yasm_directive win32_objfmt_directives[] = { - { ".ident", "gas", dir_ident, YASM_DIR_ANY }, - { "ident", "nasm", dir_ident, YASM_DIR_ANY }, - { ".def", "gas", dir_def, YASM_DIR_ID_REQUIRED }, - { ".endef", "gas", dir_endef, YASM_DIR_ANY }, - { ".scl", "gas", dir_scl, YASM_DIR_ARG_REQUIRED }, - { ".type", "gas", dir_type, YASM_DIR_ARG_REQUIRED }, - { ".secrel32", "gas", dir_secrel32, YASM_DIR_ARG_REQUIRED }, - { ".export", "gas", dir_export, YASM_DIR_ID_REQUIRED }, - { "export", "nasm", dir_export, YASM_DIR_ID_REQUIRED }, - { ".safeseh", "gas", dir_safeseh, YASM_DIR_ID_REQUIRED }, - { "safeseh", "nasm", dir_safeseh, YASM_DIR_ID_REQUIRED }, + { ".ident", "gas", dir_ident, YASM_DIR_ANY }, + { ".export", "gas", dir_export, YASM_DIR_ID_REQUIRED }, + { "ident", "nasm", dir_ident, YASM_DIR_ANY }, + { "export", "nasm", dir_export, YASM_DIR_ID_REQUIRED }, { NULL, NULL, NULL, 0 } }; -static const char *win32_nasm_stdmac[] = { - "%imacro export 1+.nolist", - "[export %1]", - "%endmacro", - "%imacro safeseh 1+.nolist", - "[safeseh %1]", - "%endmacro", - NULL -}; - -static const yasm_stdmac win32_objfmt_stdmacs[] = { - { "nasm", "nasm", win32_nasm_stdmac }, - { NULL, NULL, NULL } -}; - /* Define objfmt structure -- see objfmt.h for details */ yasm_objfmt_module yasm_win32_LTX_objfmt = { "Win32", "win32", "obj", 32, - 1, winXX_objfmt_dbgfmt_keywords, "null", win32_objfmt_directives, - win32_objfmt_stdmacs, win32_objfmt_create, coff_objfmt_output, coff_objfmt_destroy, coff_objfmt_add_default_section, - coff_objfmt_init_new_section, - coff_objfmt_section_switch, - coff_objfmt_get_special_sym + coff_objfmt_section_switch }; static const yasm_directive win64_objfmt_directives[] = { - { ".ident", "gas", dir_ident, YASM_DIR_ANY }, - { "ident", "nasm", dir_ident, YASM_DIR_ANY }, - { ".def", "gas", dir_def, YASM_DIR_ID_REQUIRED }, - { ".endef", "gas", dir_endef, YASM_DIR_ANY }, - { ".scl", "gas", dir_scl, YASM_DIR_ARG_REQUIRED }, - { ".type", "gas", dir_type, YASM_DIR_ARG_REQUIRED }, - { ".secrel32", "gas", dir_secrel32, YASM_DIR_ARG_REQUIRED }, - { ".export", "gas", dir_export, YASM_DIR_ID_REQUIRED }, - { "export", "nasm", dir_export, YASM_DIR_ID_REQUIRED }, - { ".proc_frame", "gas", dir_proc_frame, YASM_DIR_ID_REQUIRED }, + { ".ident", "gas", dir_ident, YASM_DIR_ANY }, + { "ident", "nasm", dir_ident, YASM_DIR_ANY }, + { ".export", "gas", dir_export, YASM_DIR_ID_REQUIRED }, + { "export", "nasm", dir_export, YASM_DIR_ID_REQUIRED }, { "proc_frame", "nasm", dir_proc_frame, YASM_DIR_ID_REQUIRED }, - { ".pushreg", "gas", dir_pushreg, YASM_DIR_ARG_REQUIRED }, - { "pushreg", "nasm", dir_pushreg, YASM_DIR_ARG_REQUIRED }, - { ".setframe", "gas", dir_setframe, YASM_DIR_ARG_REQUIRED }, - { "setframe", "nasm", dir_setframe, YASM_DIR_ARG_REQUIRED }, - { ".allocstack", "gas", dir_allocstack, YASM_DIR_ARG_REQUIRED }, - { "allocstack", "nasm", dir_allocstack, YASM_DIR_ARG_REQUIRED }, - { ".savereg", "gas", dir_savereg, YASM_DIR_ARG_REQUIRED }, - { "savereg", "nasm", dir_savereg, YASM_DIR_ARG_REQUIRED }, - { ".savexmm128", "gas", dir_savexmm128, YASM_DIR_ARG_REQUIRED }, - { "savexmm128", "nasm", dir_savexmm128, YASM_DIR_ARG_REQUIRED }, - { ".pushframe", "gas", dir_pushframe, YASM_DIR_ANY }, - { "pushframe", "nasm", dir_pushframe, YASM_DIR_ANY }, - { ".endprolog", "gas", dir_endprolog, YASM_DIR_ANY }, - { "endprolog", "nasm", dir_endprolog, YASM_DIR_ANY }, - { ".endproc_frame", "gas", dir_endproc_frame, YASM_DIR_ANY }, - { "endproc_frame", "nasm", dir_endproc_frame, YASM_DIR_ANY }, + { "pushreg", "nasm", dir_pushreg, YASM_DIR_ARG_REQUIRED }, + { "setframe", "nasm", dir_setframe, YASM_DIR_ARG_REQUIRED }, + { "allocstack", "nasm", dir_allocstack, YASM_DIR_ARG_REQUIRED }, + { "savereg", "nasm", dir_savereg, YASM_DIR_ARG_REQUIRED }, + { "savexmm128", "nasm", dir_savexmm128, YASM_DIR_ARG_REQUIRED }, + { "pushframe", "nasm", dir_pushframe, YASM_DIR_ANY }, + { "endprolog", "nasm", dir_endprolog, YASM_DIR_ANY }, + { "endproc_frame", "nasm", dir_endproc_frame, YASM_DIR_ANY }, { NULL, NULL, NULL, 0 } }; -#include "win64-nasm.c" -#include "win64-gas.c" - -static const yasm_stdmac win64_objfmt_stdmacs[] = { - { "nasm", "nasm", win64_nasm_stdmac }, - { "gas", "nasm", win64_gas_stdmac }, - { NULL, NULL, NULL } -}; - /* Define objfmt structure -- see objfmt.h for details */ yasm_objfmt_module yasm_win64_LTX_objfmt = { "Win64", "win64", "obj", 64, - 1, winXX_objfmt_dbgfmt_keywords, "null", win64_objfmt_directives, - win64_objfmt_stdmacs, win64_objfmt_create, coff_objfmt_output, coff_objfmt_destroy, coff_objfmt_add_default_section, - coff_objfmt_init_new_section, - coff_objfmt_section_switch, - win64_objfmt_get_special_sym + coff_objfmt_section_switch }; yasm_objfmt_module yasm_x64_LTX_objfmt = { "Win64", "x64", "obj", 64, - 1, winXX_objfmt_dbgfmt_keywords, "null", win64_objfmt_directives, - win64_objfmt_stdmacs, win64_objfmt_create, coff_objfmt_output, coff_objfmt_destroy, coff_objfmt_add_default_section, - coff_objfmt_init_new_section, - coff_objfmt_section_switch, - win64_objfmt_get_special_sym + coff_objfmt_section_switch }; diff --git a/modules/objfmts/coff/coff-objfmt.h b/modules/objfmts/coff/coff-objfmt.h index 10d88a09..f30c1192 100644 --- a/modules/objfmts/coff/coff-objfmt.h +++ b/modules/objfmts/coff/coff-objfmt.h @@ -1,4 +1,4 @@ -/* +/* $Id$ * COFF (DJGPP) object format * * Copyright (C) 2007 Peter Johnson @@ -30,32 +30,32 @@ typedef struct coff_unwind_code { SLIST_ENTRY(coff_unwind_code) link; - /*@dependent@*/ yasm_symrec *proc; /* Start of procedure */ - /*@dependent@*/ yasm_symrec *loc; /* Location of operation */ + /*@dependent@*/ yasm_symrec *proc; /* Start of procedure */ + /*@dependent@*/ yasm_symrec *loc; /* Location of operation */ /* Unwind operation code */ enum { - UWOP_PUSH_NONVOL = 0, - UWOP_ALLOC_LARGE = 1, - UWOP_ALLOC_SMALL = 2, - UWOP_SET_FPREG = 3, - UWOP_SAVE_NONVOL = 4, - UWOP_SAVE_NONVOL_FAR = 5, - UWOP_SAVE_XMM128 = 8, - UWOP_SAVE_XMM128_FAR = 9, - UWOP_PUSH_MACHFRAME = 10 + UWOP_PUSH_NONVOL = 0, + UWOP_ALLOC_LARGE = 1, + UWOP_ALLOC_SMALL = 2, + UWOP_SET_FPREG = 3, + UWOP_SAVE_NONVOL = 4, + UWOP_SAVE_NONVOL_FAR = 5, + UWOP_SAVE_XMM128 = 8, + UWOP_SAVE_XMM128_FAR = 9, + UWOP_PUSH_MACHFRAME = 10 } opcode; - unsigned int info; /* Operation info */ - yasm_value off; /* Offset expression (used for some codes) */ + unsigned int info; /* Operation info */ + yasm_value off; /* Offset expression (used for some codes) */ } coff_unwind_code; typedef struct coff_unwind_info { - /*@dependent@*/ yasm_symrec *proc; /* Start of procedure */ + /*@dependent@*/ yasm_symrec *proc; /* Start of procedure */ /*@dependent@*/ yasm_symrec *prolog; /* End of prologue */ - /*@null@*/ /*@dependent@*/ yasm_symrec *ehandler; /* Error handler */ + /*@null@*/ /*@dependent@*/ yasm_symrec *ehandler; /* Error handler */ - unsigned long framereg; /* Frame register */ - yasm_value frameoff; /* Frame offset */ + unsigned long framereg; /* Frame register */ + yasm_value frameoff; /* Frame offset */ /* Linked list of codes, in decreasing location offset order. * Inserting at the head of this list during assembly naturally results @@ -71,7 +71,7 @@ typedef struct coff_unwind_info { coff_unwind_info *yasm_win64__uwinfo_create(void); void yasm_win64__uwinfo_destroy(coff_unwind_info *info); void yasm_win64__unwind_generate(yasm_section *xdata, - /*@only@*/ coff_unwind_info *info, - unsigned long line); + /*@only@*/ coff_unwind_info *info, + unsigned long line); #endif diff --git a/modules/objfmts/coff/tests/Makefile.inc b/modules/objfmts/coff/tests/Makefile.inc index aafdfbf2..869d0f87 100644 --- a/modules/objfmts/coff/tests/Makefile.inc +++ b/modules/objfmts/coff/tests/Makefile.inc @@ -1,3 +1,5 @@ +# $Id$ + TESTS += modules/objfmts/coff/tests/coff_test.sh EXTRA_DIST += modules/objfmts/coff/tests/coff_test.sh diff --git a/modules/objfmts/coff/tests/coff_test.sh b/modules/objfmts/coff/tests/coff_test.sh index eec61beb..42f82a76 100755 --- a/modules/objfmts/coff/tests/coff_test.sh +++ b/modules/objfmts/coff/tests/coff_test.sh @@ -1,3 +1,4 @@ #! /bin/sh +# $Id$ ${srcdir}/out_test.sh coff_test modules/objfmts/coff/tests "coff objfmt" "-f coff" ".o" exit $? diff --git a/modules/objfmts/coff/tests/cofftest.c b/modules/objfmts/coff/tests/cofftest.c index fa6a552d..f7446b8a 100644 --- a/modules/objfmts/coff/tests/cofftest.c +++ b/modules/objfmts/coff/tests/cofftest.c @@ -28,7 +28,7 @@ int main(void) { greet(); printf("These pointers should be equal: %p and %p\n", - &greet, textptr); + &greet, textptr); printf("So should these: %p and %p\n", selfptr, &selfptr); } diff --git a/modules/objfmts/coff/tests/cofftest.hex b/modules/objfmts/coff/tests/cofftest.hex index 927cf9b8..c6329775 100644 --- a/modules/objfmts/coff/tests/cofftest.hex +++ b/modules/objfmts/coff/tests/cofftest.hex @@ -66,11 +66,11 @@ c9 00 00 00 +3d 00 00 00 -00 -00 +3d 00 00 00 @@ -106,11 +106,11 @@ c9 00 00 00 +7d 00 00 00 -00 -00 +7d 00 00 00 @@ -156,13 +156,13 @@ ec 5d c3 a1 -00 +7d 00 00 00 40 a3 -04 +81 00 00 00 @@ -173,7 +173,7 @@ ff 00 00 a1 -34 +71 00 00 00 @@ -181,12 +181,12 @@ ff 30 ff 35 -00 +7d 00 00 00 68 -0d +4a 00 00 00 @@ -321,7 +321,7 @@ c3 64 0a 00 -04 +81 00 00 00 @@ -329,11 +329,11 @@ c3 00 00 00 -3c +79 00 00 00 -34 +71 00 00 00 @@ -343,7 +343,7 @@ c3 00 06 00 -38 +75 00 00 00 @@ -353,7 +353,7 @@ c3 00 06 00 -3c +79 00 00 00 @@ -479,7 +479,7 @@ ff 74 72 00 -00 +3d 00 00 00 @@ -497,7 +497,7 @@ ff 70 74 72 -38 +75 00 00 00 @@ -515,7 +515,7 @@ ff 70 74 72 -3c +79 00 00 00 @@ -533,7 +533,7 @@ ff 67 65 72 -00 +7d 00 00 00 @@ -587,7 +587,7 @@ ff 00 00 00 -00 +3d 00 00 00 @@ -623,7 +623,7 @@ ff 00 00 00 -00 +7d 00 00 00 diff --git a/modules/objfmts/coff/tests/cofftimes.hex b/modules/objfmts/coff/tests/cofftimes.hex index e6779362..40cf2be1 100644 --- a/modules/objfmts/coff/tests/cofftimes.hex +++ b/modules/objfmts/coff/tests/cofftimes.hex @@ -66,11 +66,11 @@ b4 00 00 00 +04 00 00 00 -00 -00 +04 00 00 00 @@ -106,11 +106,11 @@ b8 00 00 00 +08 00 00 00 -00 -00 +08 00 00 00 @@ -146,11 +146,11 @@ bc 00 00 00 +2a 00 00 00 -00 -00 +2a 00 00 00 @@ -364,7 +364,7 @@ ff 00 00 00 -00 +04 00 00 00 @@ -400,7 +400,7 @@ ff 00 00 00 -00 +08 00 00 00 @@ -436,7 +436,7 @@ ff 00 00 00 -00 +2a 00 00 00 diff --git a/modules/objfmts/coff/tests/x86id.hex b/modules/objfmts/coff/tests/x86id.hex index 5d0af134..b75ec02a 100644 --- a/modules/objfmts/coff/tests/x86id.hex +++ b/modules/objfmts/coff/tests/x86id.hex @@ -66,12 +66,12 @@ d4 00 00 00 +e9 +d3 00 00 -00 -00 -00 -00 +e9 +d3 00 00 04 @@ -106,12 +106,12 @@ f4 74 61 00 +ed +d3 00 00 -00 -00 -00 -00 +ed +d3 00 00 24 @@ -185,9 +185,9 @@ c8 ec 04 68 -a0 -34 -00 +8d +08 +01 00 68 07 @@ -195,9 +195,9 @@ a0 00 00 68 -bb -34 -00 +a8 +08 +01 00 ff 15 @@ -331,9 +331,9 @@ ff 75 18 68 -d7 -34 -00 +c4 +08 +01 00 e8 36 @@ -495,9 +495,9 @@ e8 05 8a 80 -98 -34 -00 +85 +08 +01 00 88 45 @@ -547,8 +547,8 @@ f6 00 8b 3d -00 -00 +e9 +d3 00 00 89 @@ -950,8 +950,8 @@ fc d0 23 05 -00 -00 +e9 +d3 00 00 39 @@ -1050,9 +1050,9 @@ f8 ff 24 85 -64 -36 -00 +51 +0a +01 00 83 7f @@ -1860,9 +1860,9 @@ eb ec 04 68 -00 -35 -00 +ed +08 +01 00 68 39 @@ -1870,9 +1870,9 @@ ec 00 00 68 -bb -34 -00 +a8 +08 +01 00 ff 15 @@ -1911,9 +1911,9 @@ e8 8b 34 85 -e0 -34 -00 +cd +08 +01 00 83 7f @@ -2090,9 +2090,9 @@ eb ec 04 68 -15 -35 -00 +02 +09 +01 00 68 6b @@ -2100,9 +2100,9 @@ ec 00 00 68 -bb -34 -00 +a8 +08 +01 00 ff 15 @@ -2258,9 +2258,9 @@ eb ec 08 68 -32 -35 -00 +1f +09 +01 00 eb 08 @@ -2268,9 +2268,9 @@ eb ec 08 68 -4c -35 -00 +39 +09 +01 00 ff 75 @@ -2289,9 +2289,9 @@ d0 ec 04 68 -80 -35 -00 +6d +09 +01 00 68 8a @@ -2299,9 +2299,9 @@ ec 00 00 68 -bb -34 -00 +a8 +08 +01 00 ff 15 @@ -2318,9 +2318,9 @@ b3 ec 04 68 -80 -35 -00 +6d +09 +01 00 68 91 @@ -2336,9 +2336,9 @@ e9 ec 04 68 -a0 -35 -00 +8d +09 +01 00 68 95 @@ -2346,9 +2346,9 @@ a0 00 00 68 -bb -34 -00 +a8 +08 +01 00 ff 15 @@ -2964,9 +2964,9 @@ eb ec 04 68 -a0 -34 -00 +8d +08 +01 00 68 e9 @@ -2974,9 +2974,9 @@ e9 00 00 68 -bb -34 -00 +a8 +08 +01 00 ff 15 @@ -3047,9 +3047,9 @@ e8 ff 34 85 -e0 -34 -00 +cd +08 +01 00 ff 77 @@ -3097,9 +3097,9 @@ e8 8a 04 85 -e0 -34 -00 +cd +08 +01 00 88 45 @@ -3113,9 +3113,9 @@ cf ec 04 68 -a0 -34 -00 +8d +08 +01 00 68 fd @@ -3157,9 +3157,9 @@ e8 8a 04 85 -e0 -34 -00 +cd +08 +01 00 88 45 @@ -3177,9 +3177,9 @@ e9 ec 04 68 -a0 -34 -00 +8d +08 +01 00 68 06 @@ -3261,9 +3261,9 @@ c0 ec 08 68 -e0 -35 -00 +cd +09 +01 00 ff 75 @@ -3282,9 +3282,9 @@ f2 ec 04 68 -a0 -34 -00 +8d +08 +01 00 68 14 @@ -3356,9 +3356,9 @@ dc ec 04 68 -a0 -34 -00 +8d +08 +01 00 68 22 @@ -3394,9 +3394,9 @@ b6 ec 04 68 -a0 -34 -00 +8d +08 +01 00 68 29 @@ -3484,9 +3484,9 @@ c0 ec 08 68 -e0 -35 -00 +cd +09 +01 00 ff 75 @@ -3534,9 +3534,9 @@ e9 ec 04 68 -a0 -34 -00 +8d +08 +01 00 68 3a @@ -3549,9 +3549,9 @@ eb ec 04 68 -0b -36 -00 +f8 +09 +01 00 68 3d @@ -3559,9 +3559,9 @@ ec 00 00 68 -bb -34 -00 +a8 +08 +01 00 ff 15 @@ -3629,9 +3629,9 @@ eb ec 04 68 -40 -36 -00 +2d +0a +01 00 68 4b @@ -3639,9 +3639,9 @@ ec 00 00 68 -bb -34 -00 +a8 +08 +01 00 ff 15 @@ -3722,9 +3722,9 @@ f8 ff 24 85 -e0 -36 -00 +cd +0a +01 00 42 8a @@ -4523,9 +4523,9 @@ f7 42 52 68 -c0 -36 -00 +ad +0a +01 00 53 6a @@ -4587,8 +4587,8 @@ bf b6 81 0d -00 -00 +e9 +d3 00 00 00 @@ -4651,8 +4651,8 @@ ff ff 81 0d -00 -00 +e9 +d3 00 00 00 @@ -4693,8 +4693,8 @@ ff ff 81 0d -00 -00 +e9 +d3 00 00 00 @@ -4727,9 +4727,9 @@ ff ff 24 85 -c0 -38 -00 +ad +0c +01 00 42 8a @@ -5015,8 +5015,8 @@ ff ff 81 25 -00 -00 +e9 +d3 00 00 ff @@ -5091,8 +5091,8 @@ ff ff 81 25 -00 -00 +e9 +d3 00 00 ff @@ -5200,8 +5200,8 @@ ff ff 81 25 -00 -00 +e9 +d3 00 00 ff @@ -5225,8 +5225,8 @@ ff ff 81 25 -00 -00 +e9 +d3 00 00 ff @@ -5267,8 +5267,8 @@ ff ff 81 25 -00 -00 +e9 +d3 00 00 ff @@ -5343,8 +5343,8 @@ ff ff 81 25 -00 -00 +e9 +d3 00 00 ff @@ -5419,8 +5419,8 @@ ff ff 81 25 -00 -00 +e9 +d3 00 00 ff @@ -5486,8 +5486,8 @@ ff ff 81 25 -00 -00 +e9 +d3 00 00 ff @@ -5511,8 +5511,8 @@ ff ff 81 25 -00 -00 +e9 +d3 00 00 ff @@ -5536,8 +5536,8 @@ ff ff 81 25 -00 -00 +e9 +d3 00 00 ff @@ -5578,8 +5578,8 @@ ff ff 81 25 -00 -00 +e9 +d3 00 00 ff @@ -5620,8 +5620,8 @@ ff ff 81 25 -00 -00 +e9 +d3 00 00 ff @@ -5662,8 +5662,8 @@ ff ff 81 0d -00 -00 +e9 +d3 00 00 00 @@ -5790,8 +5790,8 @@ ff ff c7 05 -00 -00 +e9 +d3 00 00 3f @@ -5815,8 +5815,8 @@ ff ff 81 0d -00 -00 +e9 +d3 00 00 00 @@ -5964,8 +5964,8 @@ ff ff 81 0d -00 -00 +e9 +d3 00 00 00 @@ -5989,8 +5989,8 @@ ff ff 81 0d -00 -00 +e9 +d3 00 00 00 @@ -6014,8 +6014,8 @@ ff ff 81 0d -00 -00 +e9 +d3 00 00 00 @@ -6233,8 +6233,8 @@ ff ff c7 05 -00 -00 +e9 +d3 00 00 3f @@ -6281,8 +6281,8 @@ ff ff 81 0d -00 -00 +e9 +d3 00 00 00 @@ -6459,8 +6459,8 @@ ff ff c7 05 -00 -00 +e9 +d3 00 00 ff @@ -6484,8 +6484,8 @@ ff ff c7 05 -00 -00 +e9 +d3 00 00 3f @@ -6592,8 +6592,8 @@ ff ff c7 05 -00 -00 +e9 +d3 00 00 7f @@ -6629,8 +6629,8 @@ ff ff c7 05 -00 -00 +e9 +d3 00 00 3f @@ -6654,8 +6654,8 @@ ff ff c7 05 -00 -00 +e9 +d3 00 00 3f @@ -6679,8 +6679,8 @@ ff ff c7 05 -00 -00 +e9 +d3 00 00 1f @@ -6814,8 +6814,8 @@ ff ff 81 0d -00 -00 +e9 +d3 00 00 00 @@ -6839,8 +6839,8 @@ ff ff 81 0d -00 -00 +e9 +d3 00 00 00 @@ -7252,8 +7252,8 @@ ff ff c7 05 -00 -00 +e9 +d3 00 00 0f @@ -7341,8 +7341,8 @@ ff ff 81 0d -00 -00 +e9 +d3 00 00 00 @@ -7366,8 +7366,8 @@ ff ff c7 05 -00 -00 +e9 +d3 00 00 07 @@ -7403,8 +7403,8 @@ ff ff c7 05 -00 -00 +e9 +d3 00 00 03 @@ -7440,8 +7440,8 @@ ff ff c7 05 -00 -00 +e9 +d3 00 00 01 @@ -7577,8 +7577,8 @@ ff ff c7 05 -00 -00 +e9 +d3 00 00 ff @@ -7689,8 +7689,8 @@ ff ff c7 05 -00 -00 +e9 +d3 00 00 00 @@ -7737,9 +7737,9 @@ f8 ff 24 85 -00 -3b -00 +ed +0e +01 00 41 8a @@ -7826,9 +7826,9 @@ e2 ff 24 85 -e4 -3c -00 +d1 +10 +01 00 41 8a @@ -7851,9 +7851,9 @@ c9 ff 24 85 -c8 -3d -00 +b5 +11 +01 00 41 8a @@ -8051,9 +8051,9 @@ f8 ff 24 85 -e8 -3e -00 +d5 +12 +01 00 41 8a @@ -8076,9 +8076,9 @@ e8 ff 24 85 -08 -40 -00 +f5 +13 +01 00 41 8a @@ -8101,9 +8101,9 @@ cf ff 24 85 -d8 -40 -00 +c5 +14 +01 00 41 8a @@ -8126,9 +8126,9 @@ b6 ff 24 85 -e4 -41 -00 +d1 +15 +01 00 41 8a @@ -8151,9 +8151,9 @@ f8 ff 24 85 -c4 -42 -00 +b1 +16 +01 00 41 8a @@ -8176,9 +8176,9 @@ f8 ff 24 85 -a4 -43 -00 +91 +17 +01 00 41 8a @@ -8201,9 +8201,9 @@ f8 ff 24 85 -78 -44 -00 +65 +18 +01 00 41 8a @@ -8226,9 +8226,9 @@ f8 ff 24 85 -34 -45 -00 +21 +19 +01 00 41 8a @@ -8251,9 +8251,9 @@ f8 ff 24 85 -00 -46 -00 +ed +19 +01 00 41 8a @@ -8302,9 +8302,9 @@ f8 ff 24 85 -c4 -46 -00 +b1 +1a +01 00 41 8a @@ -8327,9 +8327,9 @@ ed ff 24 85 -a4 -47 -00 +91 +1b +01 00 41 8a @@ -8352,9 +8352,9 @@ d4 ff 24 85 -68 -48 -00 +55 +1c +01 00 41 8a @@ -8844,9 +8844,9 @@ ff ff c7 07 -2c -2d -00 +19 +01 +01 00 c7 47 @@ -8872,9 +8872,9 @@ ff ff c7 07 -10 -2d +fd 00 +01 00 c7 47 @@ -8950,9 +8950,9 @@ ff ff c7 07 -2c -2d -00 +19 +01 +01 00 c7 47 @@ -8978,9 +8978,9 @@ ff ff c7 07 -10 -2d +fd 00 +01 00 c7 47 @@ -9023,9 +9023,9 @@ ff ff c7 07 -a0 -33 -00 +8d +07 +01 00 c7 47 @@ -9051,8 +9051,8 @@ ff ff c7 07 -38 -00 +25 +d4 00 00 c7 @@ -9079,8 +9079,8 @@ ff ff c7 07 -38 -00 +25 +d4 00 00 c7 @@ -9207,9 +9207,9 @@ ff ff c7 07 -2c -2d -00 +19 +01 +01 00 c7 47 @@ -9235,9 +9235,9 @@ ff ff c7 07 -2c -2d -00 +19 +01 +01 00 c7 47 @@ -9417,8 +9417,8 @@ ff ff c7 07 -38 -00 +25 +d4 00 00 c7 @@ -9462,8 +9462,8 @@ ff ff c7 07 -38 -00 +25 +d4 00 00 c7 @@ -9541,8 +9541,8 @@ ff ff c7 07 -38 -00 +25 +d4 00 00 c7 @@ -9586,8 +9586,8 @@ ff ff c7 07 -1c -00 +09 +d4 00 00 c7 @@ -9681,8 +9681,8 @@ ff ff c7 07 -50 -23 +3d +f7 00 00 c7 @@ -9709,8 +9709,8 @@ ff ff c7 07 -50 -23 +3d +f7 00 00 c7 @@ -9754,8 +9754,8 @@ ff ff c7 07 -1c -00 +09 +d4 00 00 c7 @@ -10088,9 +10088,9 @@ ff ff 24 85 -50 -49 -00 +3d +1d +01 00 41 80 @@ -10104,8 +10104,8 @@ ff ff c7 07 -20 -1f +0d +f3 00 00 c7 @@ -10226,8 +10226,8 @@ ff ff c7 07 -20 -1f +0d +f3 00 00 c7 @@ -10254,8 +10254,8 @@ ff ff c7 07 -20 -1f +0d +f3 00 00 c7 @@ -10329,8 +10329,8 @@ a9 00 c7 07 -00 -20 +ed +f3 00 00 c7 @@ -10357,8 +10357,8 @@ ff ff c7 07 -20 -1f +0d +f3 00 00 c7 @@ -10385,8 +10385,8 @@ ff ff c7 07 -20 -1f +0d +f3 00 00 c7 @@ -10501,8 +10501,8 @@ ff ff c7 07 -20 -1f +0d +f3 00 00 c7 @@ -10529,8 +10529,8 @@ ff ff c7 07 -20 -1f +0d +f3 00 00 c7 @@ -10557,8 +10557,8 @@ ff ff c7 07 -20 -1f +0d +f3 00 00 c7 @@ -10658,8 +10658,8 @@ ff ff c7 07 -20 -1f +0d +f3 00 00 c7 @@ -10686,8 +10686,8 @@ ff ff c7 07 -20 -1f +0d +f3 00 00 c7 @@ -10714,8 +10714,8 @@ ff ff c7 07 -20 -1f +0d +f3 00 00 c7 @@ -10742,8 +10742,8 @@ ff ff c7 07 -20 -1f +0d +f3 00 00 c7 @@ -10770,8 +10770,8 @@ ff ff c7 07 -60 -1c +4d +f0 00 00 e9 @@ -10791,8 +10791,8 @@ ff ff c7 07 -20 -1f +0d +f3 00 00 c7 @@ -10819,8 +10819,8 @@ ff ff c7 07 -20 -1f +0d +f3 00 00 c7 @@ -10881,8 +10881,8 @@ ff ff c7 07 -00 -20 +ed +f3 00 00 c7 @@ -10926,8 +10926,8 @@ ff ff c7 07 -00 -20 +ed +f3 00 00 c7 @@ -10954,8 +10954,8 @@ ff ff c7 07 -20 -1f +0d +f3 00 00 c7 @@ -10982,8 +10982,8 @@ ff ff c7 07 -20 -1f +0d +f3 00 00 c7 @@ -11192,8 +11192,8 @@ ff ff c7 07 -a0 -0d +8d +e1 00 00 e9 @@ -11311,8 +11311,8 @@ ff ff c7 07 -1c -00 +09 +d4 00 00 c7 @@ -11339,8 +11339,8 @@ ff ff c7 07 -1c -00 +09 +d4 00 00 c7 @@ -11367,8 +11367,8 @@ ff ff c7 07 -1c -00 +09 +d4 00 00 c7 @@ -11408,8 +11408,8 @@ a5 00 c7 07 -1c -00 +09 +d4 00 00 c7 @@ -11436,8 +11436,8 @@ ff ff c7 07 -a0 -12 +8d +e6 00 00 c7 @@ -11616,8 +11616,8 @@ ff ff c7 07 -54 -22 +41 +f6 00 00 c7 @@ -11694,8 +11694,8 @@ ff ff c7 07 -38 -00 +25 +d4 00 00 c7 @@ -11753,8 +11753,8 @@ ff ff c7 07 -8c -00 +79 +d4 00 00 c7 @@ -11814,8 +11814,8 @@ a5 00 c7 07 -1c -00 +09 +d4 00 00 c7 @@ -11842,8 +11842,8 @@ ff ff c7 07 -1c -00 +09 +d4 00 00 c7 @@ -11870,8 +11870,8 @@ ff ff c7 07 -1c -00 +09 +d4 00 00 c7 @@ -11898,8 +11898,8 @@ ff ff c7 07 -1c -00 +09 +d4 00 00 c7 @@ -11926,8 +11926,8 @@ ff ff c7 07 -1c -00 +09 +d4 00 00 c7 @@ -11971,8 +11971,8 @@ ff ff c7 07 -60 -16 +4d +ea 00 00 c7 @@ -12016,8 +12016,8 @@ ff ff c7 07 -60 -13 +4d +e7 00 00 c7 @@ -12061,9 +12061,9 @@ ff ff c7 07 -60 -33 -00 +4d +07 +01 00 e9 87 @@ -12290,9 +12290,9 @@ ff ff 24 85 -38 -4a -00 +25 +1e +01 00 41 8a @@ -12608,9 +12608,9 @@ ff ff 24 85 -40 -4b -00 +2d +1f +01 00 41 8a @@ -12708,9 +12708,9 @@ ff ff c7 07 -60 -2c +4d 00 +01 00 c7 47 @@ -13142,9 +13142,9 @@ ff ff c7 07 -60 -2c +4d 00 +01 00 c7 47 @@ -13187,9 +13187,9 @@ ff ff c7 07 -2c -2d -00 +19 +01 +01 00 c7 47 @@ -13215,9 +13215,9 @@ ff ff c7 07 -60 -2c +4d 00 +01 00 c7 47 @@ -13243,9 +13243,9 @@ ff ff c7 07 -60 -2c +4d 00 +01 00 c7 47 @@ -13350,9 +13350,9 @@ ff ff c7 07 -60 -2c +4d 00 +01 00 c7 47 @@ -13395,9 +13395,9 @@ ff ff c7 07 -2c -2d -00 +19 +01 +01 00 c7 47 @@ -13423,9 +13423,9 @@ ff ff c7 07 -60 -2c +4d 00 +01 00 c7 47 @@ -13451,9 +13451,9 @@ ff ff c7 07 -60 -2c +4d 00 +01 00 c7 47 @@ -13541,8 +13541,8 @@ ff ff c7 07 -80 -06 +6d +da 00 00 c7 @@ -13651,8 +13651,8 @@ f5 00 c7 07 -1c -00 +09 +d4 00 00 c7 @@ -13743,8 +13743,8 @@ ff ff c7 07 -1c -00 +09 +d4 00 00 c7 @@ -13771,8 +13771,8 @@ ff ff c7 07 -1c -00 +09 +d4 00 00 c7 @@ -13812,8 +13812,8 @@ ff 00 c7 07 -1c -00 +09 +d4 00 00 c7 @@ -13840,8 +13840,8 @@ ff ff c7 07 -1c -00 +09 +d4 00 00 c7 @@ -13881,8 +13881,8 @@ ff 00 c7 07 -1c -00 +09 +d4 00 00 c7 @@ -13922,8 +13922,8 @@ e6 00 c7 07 -1c -00 +09 +d4 00 00 c7 @@ -14161,9 +14161,9 @@ ff ff c7 07 -ac -32 -00 +99 +06 +01 00 c7 47 @@ -14292,9 +14292,9 @@ ff ff c7 07 -9c -2d -00 +89 +01 +01 00 c7 47 @@ -14356,9 +14356,9 @@ ff ff c7 07 -58 -30 -00 +45 +04 +01 00 e9 66 @@ -14377,9 +14377,9 @@ ff ff c7 07 -9c -2d -00 +89 +01 +01 00 c7 47 @@ -14405,9 +14405,9 @@ ff ff c7 07 -9c -2d -00 +89 +01 +01 00 c7 47 @@ -14467,9 +14467,9 @@ ff ff c7 07 -60 -2c +4d 00 +01 00 c7 47 @@ -14504,9 +14504,9 @@ ff ff 24 85 -1c -4c -00 +09 +20 +01 00 41 80 @@ -14520,9 +14520,9 @@ ff ff c7 07 -60 -2c +4d 00 +01 00 c7 47 @@ -14548,9 +14548,9 @@ ff ff c7 07 -60 -2c +4d 00 +01 00 c7 47 @@ -14576,9 +14576,9 @@ ff ff c7 07 -60 -2c +4d 00 +01 00 c7 47 @@ -14604,9 +14604,9 @@ ff ff c7 07 -60 -2c +4d 00 +01 00 c7 47 @@ -14782,9 +14782,9 @@ ff ff c7 07 -60 -2c +4d 00 +01 00 c7 47 @@ -14810,9 +14810,9 @@ ff ff c7 07 -60 -2c +4d 00 +01 00 c7 47 @@ -14838,9 +14838,9 @@ ff ff c7 07 -60 -2c +4d 00 +01 00 c7 47 @@ -14884,9 +14884,9 @@ ff ff c7 07 -60 -2c +4d 00 +01 00 c7 47 @@ -14912,9 +14912,9 @@ ff ff c7 07 -c8 -32 -00 +b5 +06 +01 00 c7 47 @@ -15067,9 +15067,9 @@ ff ff c7 07 -a0 -2c +8d 00 +01 00 c7 47 @@ -15118,9 +15118,9 @@ ff ff c7 07 -a0 -2c +8d 00 +01 00 c7 47 @@ -15146,9 +15146,9 @@ ff ff c7 07 -a0 -2c +8d 00 +01 00 c7 47 @@ -15174,9 +15174,9 @@ ff ff c7 07 -90 -32 -00 +7d +06 +01 00 c7 47 @@ -15202,9 +15202,9 @@ ff ff c7 07 -a0 -2c +8d 00 +01 00 c7 47 @@ -15230,9 +15230,9 @@ ff ff c7 07 -a0 -2c +8d 00 +01 00 c7 47 @@ -15321,9 +15321,9 @@ ff ff c7 07 -a0 -2c +8d 00 +01 00 c7 47 @@ -15372,9 +15372,9 @@ ff ff c7 07 -a0 -2c +8d 00 +01 00 c7 47 @@ -15400,9 +15400,9 @@ ff ff c7 07 -a0 -2c +8d 00 +01 00 c7 47 @@ -15428,9 +15428,9 @@ ff ff c7 07 -90 -32 -00 +7d +06 +01 00 c7 47 @@ -15605,8 +15605,8 @@ ff ff c7 07 -8c -00 +79 +d4 00 00 c7 @@ -15691,8 +15691,8 @@ ff ff c7 07 -8c -00 +79 +d4 00 00 c7 @@ -15719,8 +15719,8 @@ ff ff c7 07 -8c -00 +79 +d4 00 00 c7 @@ -15747,8 +15747,8 @@ ff ff c7 07 -8c -00 +79 +d4 00 00 c7 @@ -15775,8 +15775,8 @@ ff ff c7 07 -8c -00 +79 +d4 00 00 c7 @@ -15820,8 +15820,8 @@ ff ff c7 07 -8c -00 +79 +d4 00 00 c7 @@ -15910,8 +15910,8 @@ ff ff c7 07 -a0 -09 +8d +dd 00 00 c7 @@ -15938,9 +15938,9 @@ ff ff c7 07 -60 -2c +4d 00 +01 00 c7 47 @@ -16048,8 +16048,8 @@ ff 00 c7 07 -1c -00 +09 +d4 00 00 c7 @@ -16140,8 +16140,8 @@ ff ff c7 07 -1c -00 +09 +d4 00 00 c7 @@ -16168,8 +16168,8 @@ ff ff c7 07 -1c -00 +09 +d4 00 00 c7 @@ -16196,8 +16196,8 @@ ff ff c7 07 -1c -00 +09 +d4 00 00 c7 @@ -16237,8 +16237,8 @@ e6 00 c7 07 -1c -00 +09 +d4 00 00 c7 @@ -16278,8 +16278,8 @@ b2 00 c7 07 -1c -00 +09 +d4 00 00 c7 @@ -16319,8 +16319,8 @@ ff 00 c7 07 -1c -00 +09 +d4 00 00 c7 @@ -16709,9 +16709,9 @@ ff ff c7 07 -c8 -32 -00 +b5 +06 +01 00 c7 47 @@ -16754,9 +16754,9 @@ ff ff c7 07 -c8 -32 -00 +b5 +06 +01 00 c7 47 @@ -16799,9 +16799,9 @@ ff ff c7 07 -c8 -32 -00 +b5 +06 +01 00 c7 47 @@ -16861,9 +16861,9 @@ ff ff c7 07 -c8 -32 -00 +b5 +06 +01 00 c7 47 @@ -16957,9 +16957,9 @@ ff ff c7 07 -20 -30 -00 +0d +04 +01 00 c7 47 @@ -17070,9 +17070,9 @@ ff ff c7 07 -60 -2c +4d 00 +01 00 c7 47 @@ -17098,9 +17098,9 @@ ff ff c7 07 -60 -2c +4d 00 +01 00 c7 47 @@ -17333,9 +17333,9 @@ ff ff c7 07 -60 -2c +4d 00 +01 00 c7 47 @@ -17361,9 +17361,9 @@ ff ff c7 07 -60 -2c +4d 00 +01 00 c7 47 @@ -17464,9 +17464,9 @@ ff ff c7 07 -60 -2c +4d 00 +01 00 c7 47 @@ -17492,9 +17492,9 @@ ff ff c7 07 -60 -2c +4d 00 +01 00 c7 47 @@ -17587,9 +17587,9 @@ ff ff c7 07 -c8 -32 -00 +b5 +06 +01 00 c7 47 @@ -17615,9 +17615,9 @@ ff ff c7 07 -ac -32 -00 +99 +06 +01 00 c7 47 @@ -17643,9 +17643,9 @@ ff ff c7 07 -c8 -32 -00 +b5 +06 +01 00 c7 47 @@ -17834,9 +17834,9 @@ ff ff c7 07 -60 -2c +4d 00 +01 00 c7 47 @@ -17862,9 +17862,9 @@ ff ff c7 07 -60 -2c +4d 00 +01 00 c7 47 @@ -17890,9 +17890,9 @@ ff ff c7 07 -c8 -32 -00 +b5 +06 +01 00 c7 47 @@ -17952,9 +17952,9 @@ ff ff c7 07 -60 -2c +4d 00 +01 00 c7 47 @@ -18031,9 +18031,9 @@ ff ff c7 07 -e4 -32 -00 +d1 +06 +01 00 c7 47 @@ -18152,9 +18152,9 @@ ff ff c7 07 -ac -32 -00 +99 +06 +01 00 c7 47 @@ -18180,9 +18180,9 @@ ff ff c7 07 -ac -32 -00 +99 +06 +01 00 c7 47 @@ -18242,9 +18242,9 @@ ff ff c7 07 -a0 -2f -00 +8d +03 +01 00 c7 47 @@ -18638,9 +18638,9 @@ ff ff c7 07 -ac -32 -00 +99 +06 +01 00 c7 47 @@ -18666,9 +18666,9 @@ ff ff c7 07 -ac -32 -00 +99 +06 +01 00 c7 47 @@ -18822,9 +18822,9 @@ ff ff c7 07 -ac -32 -00 +99 +06 +01 00 c7 47 @@ -18862,9 +18862,9 @@ ff ff c7 07 -ac -32 -00 +99 +06 +01 00 c7 47 @@ -18913,9 +18913,9 @@ ff ff c7 07 -ac -32 -00 +99 +06 +01 00 c7 47 @@ -18985,9 +18985,9 @@ ff ff c7 07 -ac -32 -00 +99 +06 +01 00 c7 47 @@ -19013,9 +19013,9 @@ ff ff c7 07 -ac -32 -00 +99 +06 +01 00 c7 47 @@ -19092,9 +19092,9 @@ ff ff c7 07 -ac -32 -00 +99 +06 +01 00 c7 47 @@ -19154,9 +19154,9 @@ ff ff c7 07 -ac -32 -00 +99 +06 +01 00 c7 47 @@ -19235,9 +19235,9 @@ ff ff c7 07 -ac -32 -00 +99 +06 +01 00 c7 47 @@ -19263,9 +19263,9 @@ ff ff c7 07 -ac -32 -00 +99 +06 +01 00 c7 47 @@ -19291,9 +19291,9 @@ ff ff c7 07 -ac -32 -00 +99 +06 +01 00 c7 47 @@ -19454,9 +19454,9 @@ ff ff c7 07 -ac -32 -00 +99 +06 +01 00 c7 47 @@ -19482,9 +19482,9 @@ ff ff c7 07 -ac -32 -00 +99 +06 +01 00 c7 47 @@ -19510,9 +19510,9 @@ ff ff c7 07 -ac -32 -00 +99 +06 +01 00 c7 47 @@ -19573,9 +19573,9 @@ ff ff c7 07 -ac -32 -00 +99 +06 +01 00 c7 47 @@ -19601,9 +19601,9 @@ ff ff c7 07 -ac -32 -00 +99 +06 +01 00 c7 47 @@ -19679,9 +19679,9 @@ ff ff c7 07 -ac -32 -00 +99 +06 +01 00 c7 47 @@ -19707,9 +19707,9 @@ ff ff c7 07 -ac -32 -00 +99 +06 +01 00 c7 47 @@ -19793,9 +19793,9 @@ ff ff c7 07 -60 -2f -00 +4d +03 +01 00 c7 47 @@ -19889,9 +19889,9 @@ ff ff c7 07 -c8 -32 -00 +b5 +06 +01 00 c7 47 @@ -20200,9 +20200,9 @@ ff ff c7 07 -60 -2c +4d 00 +01 00 c7 47 @@ -20228,9 +20228,9 @@ ff ff c7 07 -60 -2c +4d 00 +01 00 c7 47 @@ -20290,9 +20290,9 @@ ff ff c7 07 -ac -32 -00 +99 +06 +01 00 c7 47 @@ -20318,9 +20318,9 @@ ff ff c7 07 -c8 -32 -00 +b5 +06 +01 00 c7 47 @@ -20369,9 +20369,9 @@ ff ff c7 07 -60 -2c +4d 00 +01 00 c7 47 @@ -20397,9 +20397,9 @@ ff ff c7 07 -60 -2c +4d 00 +01 00 c7 47 @@ -20434,9 +20434,9 @@ ff ff 24 85 -f4 -4c -00 +e1 +20 +01 00 41 80 @@ -20450,9 +20450,9 @@ ff ff c7 07 -60 -2c +4d 00 +01 00 c7 47 @@ -20478,9 +20478,9 @@ ff ff c7 07 -60 -2c +4d 00 +01 00 c7 47 @@ -20506,9 +20506,9 @@ ff ff c7 07 -60 -2c +4d 00 +01 00 c7 47 @@ -20534,9 +20534,9 @@ ff ff c7 07 -60 -2c +4d 00 +01 00 c7 47 @@ -20712,9 +20712,9 @@ ff ff c7 07 -60 -2c +4d 00 +01 00 c7 47 @@ -20740,9 +20740,9 @@ ff ff c7 07 -60 -2c +4d 00 +01 00 c7 47 @@ -20768,9 +20768,9 @@ ff ff c7 07 -60 -2c +4d 00 +01 00 c7 47 @@ -20814,9 +20814,9 @@ ff ff c7 07 -60 -2c +4d 00 +01 00 c7 47 @@ -20842,9 +20842,9 @@ ff ff c7 07 -c8 -32 -00 +b5 +06 +01 00 c7 47 @@ -21116,9 +21116,9 @@ ff ff c7 07 -60 -2c +4d 00 +01 00 c7 47 @@ -21144,9 +21144,9 @@ ff ff c7 07 -60 -2c +4d 00 +01 00 c7 47 @@ -21172,9 +21172,9 @@ ff ff c7 07 -60 -2c +4d 00 +01 00 c7 47 @@ -21265,9 +21265,9 @@ ff ff c7 07 -60 -2c +4d 00 +01 00 c7 47 @@ -21293,9 +21293,9 @@ ff ff c7 07 -60 -2c +4d 00 +01 00 c7 47 @@ -21321,9 +21321,9 @@ ff ff c7 07 -60 -2c +4d 00 +01 00 c7 47 @@ -21418,9 +21418,9 @@ ff ff c7 07 -60 -2c +4d 00 +01 00 c7 47 @@ -21531,9 +21531,9 @@ ff ff c7 07 -60 -2c +4d 00 +01 00 c7 47 @@ -21559,9 +21559,9 @@ ff ff c7 07 -60 -2c +4d 00 +01 00 c7 47 @@ -21604,8 +21604,8 @@ ff ff c7 07 -38 -00 +25 +d4 00 00 c7 @@ -21919,8 +21919,8 @@ ff ff c7 07 -40 -21 +2d +f5 00 00 c7 @@ -21968,8 +21968,8 @@ ff ff c7 07 -40 -21 +2d +f5 00 00 c7 @@ -21996,8 +21996,8 @@ ff ff c7 07 -40 -21 +2d +f5 00 00 c7 @@ -22024,8 +22024,8 @@ ff ff c7 07 -40 -21 +2d +f5 00 00 c7 @@ -22052,8 +22052,8 @@ ff ff c7 07 -00 -22 +ed +f5 00 00 c7 @@ -22080,8 +22080,8 @@ ff ff c7 07 -00 -22 +ed +f5 00 00 c7 @@ -22142,8 +22142,8 @@ ff ff c7 07 -20 -29 +0d +fd 00 00 c7 @@ -22251,8 +22251,8 @@ ff 00 c7 07 -80 -22 +6d +f6 00 00 c7 @@ -22575,9 +22575,9 @@ ff 11 53 68 -e0 -39 -00 +cd +0d +01 00 56 6a @@ -22689,8 +22689,8 @@ ff ff c7 07 -f8 -1e +e5 +f2 00 00 c7 @@ -22734,8 +22734,8 @@ ff ff c7 07 -38 -00 +25 +d4 00 00 c7 @@ -23058,8 +23058,8 @@ ff ff c7 07 -00 -10 +ed +e3 00 00 c7 @@ -23135,9 +23135,9 @@ ff ff c7 07 -10 -2d +fd 00 +01 00 c7 47 @@ -23163,9 +23163,9 @@ ff ff c7 07 -2c -2d -00 +19 +01 +01 00 c7 47 @@ -23364,8 +23364,8 @@ ff ff c7 07 -1c -00 +09 +d4 00 00 c7 @@ -23420,8 +23420,8 @@ ff ff c7 07 -00 -0c +ed +df 00 00 c7 @@ -23465,9 +23465,9 @@ ff ff c7 07 -60 -34 -00 +4d +08 +01 00 c7 47 @@ -23517,8 +23517,8 @@ ff ff c7 07 -60 -29 +4d +fd 00 00 c7 @@ -23785,8 +23785,8 @@ ff ff c7 07 -60 -13 +4d +e7 00 00 c7 @@ -23922,9 +23922,9 @@ ff ff c7 07 -2c -2d -00 +19 +01 +01 00 c7 47 @@ -23950,9 +23950,9 @@ ff ff c7 07 -2c -2d -00 +19 +01 +01 00 c7 47 @@ -23978,9 +23978,9 @@ ff ff c7 07 -10 -2d +fd 00 +01 00 c7 47 @@ -24006,9 +24006,9 @@ ff ff c7 07 -2c -2d -00 +19 +01 +01 00 c7 47 @@ -24345,8 +24345,8 @@ ff ff c7 07 -c0 -00 +ad +d4 00 00 c7 @@ -24429,8 +24429,8 @@ ff ff c7 07 -e0 -2a +cd +fe 00 00 c7 @@ -24648,8 +24648,8 @@ ff ff c7 07 -c0 -2b +ad +ff 00 00 c7 @@ -24692,9 +24692,9 @@ ff ff 24 85 -cc -4d -00 +b9 +21 +01 00 41 8a @@ -24743,8 +24743,8 @@ ff ff c7 07 -c0 -05 +ad +d9 00 00 c7 @@ -24821,9 +24821,9 @@ ff ff c7 07 -c0 -30 -00 +ad +04 +01 00 c7 47 @@ -24849,9 +24849,9 @@ ff ff c7 07 -00 -2e -00 +ed +01 +01 00 c7 47 @@ -24907,8 +24907,8 @@ ff ff c7 07 -c0 -05 +ad +d9 00 00 c7 @@ -24935,8 +24935,8 @@ ff ff c7 07 -1c -00 +09 +d4 00 00 c7 @@ -24963,8 +24963,8 @@ ff ff c7 07 -1c -00 +09 +d4 00 00 c7 @@ -24991,9 +24991,9 @@ ff ff c7 07 -80 -31 -00 +6d +05 +01 00 c7 47 @@ -25032,8 +25032,8 @@ ff 00 c7 07 -1c -00 +09 +d4 00 00 c7 @@ -25060,9 +25060,9 @@ ff ff c7 07 -00 -2f -00 +ed +02 +01 00 c7 47 @@ -25101,8 +25101,8 @@ ff 00 c7 07 -4c -06 +39 +da 00 00 c7 @@ -25163,9 +25163,9 @@ ff ff c7 07 -74 -32 -00 +61 +06 +01 00 e9 63 @@ -25303,8 +25303,8 @@ ff ff c7 07 -80 -2a +6d +fe 00 00 c7 @@ -25388,9 +25388,9 @@ ff ff c7 07 -d0 -2e -00 +bd +02 +01 00 e9 94 @@ -25409,9 +25409,9 @@ ff ff c7 07 -b4 -2e -00 +a1 +02 +01 00 e9 7f @@ -25430,9 +25430,9 @@ ff ff c7 07 -54 -31 -00 +41 +05 +01 00 c7 47 @@ -25458,9 +25458,9 @@ ff ff c7 07 -54 -31 -00 +41 +05 +01 00 c7 47 @@ -25570,9 +25570,9 @@ ff ff c7 07 -38 -31 -00 +25 +05 +01 00 e9 cc @@ -25591,9 +25591,9 @@ ff ff c7 07 -98 -2e -00 +85 +02 +01 00 e9 c9 @@ -25680,9 +25680,9 @@ ff ff c7 07 -00 -31 -00 +ed +04 +01 00 c7 47 @@ -25708,9 +25708,9 @@ ff ff c7 07 -60 -2e -00 +4d +02 +01 00 c7 47 @@ -25753,9 +25753,9 @@ ff ff c7 07 -38 -2e -00 +25 +02 +01 00 c7 47 @@ -25849,9 +25849,9 @@ ff ff c7 07 -00 -31 -00 +ed +04 +01 00 c7 47 @@ -25877,9 +25877,9 @@ ff ff c7 07 -60 -2e -00 +4d +02 +01 00 c7 47 @@ -25922,9 +25922,9 @@ ff ff c7 07 -38 -2e -00 +25 +02 +01 00 c7 47 @@ -26033,9 +26033,9 @@ ff ff c7 07 -20 -32 -00 +0d +06 +01 00 c7 47 @@ -26061,9 +26061,9 @@ ff ff c7 07 -20 -32 -00 +0d +06 +01 00 c7 47 @@ -26089,9 +26089,9 @@ ff ff c7 07 -58 -32 -00 +45 +06 +01 00 e9 c5 @@ -26160,9 +26160,9 @@ ff ff c7 07 -c0 -30 -00 +ad +04 +01 00 c7 47 @@ -26188,9 +26188,9 @@ ff ff c7 07 -00 -2e -00 +ed +01 +01 00 c7 47 @@ -26400,9 +26400,9 @@ ff ff c7 07 -2c -2d -00 +19 +01 +01 00 c7 47 @@ -26428,9 +26428,9 @@ ff ff c7 07 -2c -2d -00 +19 +01 +01 00 c7 47 @@ -26456,9 +26456,9 @@ ff ff c7 07 -10 -2d +fd 00 +01 00 c7 47 @@ -26484,9 +26484,9 @@ ff ff c7 07 -2c -2d -00 +19 +01 +01 00 c7 47 @@ -26563,8 +26563,8 @@ ff ff c7 07 -54 -00 +41 +d4 00 00 c7 @@ -26776,9 +26776,9 @@ ff ff c7 07 -2c -2d -00 +19 +01 +01 00 c7 47 @@ -26804,9 +26804,9 @@ ff ff c7 07 -2c -2d -00 +19 +01 +01 00 c7 47 @@ -26832,9 +26832,9 @@ ff ff c7 07 -10 -2d +fd 00 +01 00 c7 47 @@ -26860,9 +26860,9 @@ ff ff c7 07 -2c -2d -00 +19 +01 +01 00 c7 47 @@ -27007,9 +27007,9 @@ ff ff c7 07 -d4 -2d -00 +c1 +01 +01 00 c7 47 @@ -27059,9 +27059,9 @@ ff ff c7 07 -f0 -31 -00 +dd +05 +01 00 c7 47 @@ -27340,9 +27340,9 @@ ff 11 53 68 -e0 -39 -00 +cd +0d +01 00 56 6a @@ -27515,8 +27515,8 @@ ff ff c7 07 -60 -13 +4d +e7 00 00 c7 @@ -27652,9 +27652,9 @@ ff ff c7 07 -2c -2d -00 +19 +01 +01 00 c7 47 @@ -27680,9 +27680,9 @@ ff ff c7 07 -2c -2d -00 +19 +01 +01 00 c7 47 @@ -27708,9 +27708,9 @@ ff ff c7 07 -10 -2d +fd 00 +01 00 c7 47 @@ -27736,9 +27736,9 @@ ff ff c7 07 -2c -2d -00 +19 +01 +01 00 c7 47 @@ -27764,8 +27764,8 @@ ff ff c7 07 -a0 -12 +8d +e6 00 00 c7 @@ -27805,8 +27805,8 @@ ab 00 c7 07 -1c -00 +09 +d4 00 00 c7 @@ -27846,8 +27846,8 @@ ff 00 c7 07 -1c -00 +09 +d4 00 00 c7 @@ -28483,8 +28483,8 @@ ff ff c7 07 -1c -00 +09 +d4 00 00 c7 @@ -28511,8 +28511,8 @@ ff ff c7 07 -1c -00 +09 +d4 00 00 c7 @@ -29055,9 +29055,9 @@ ff ff c7 07 -2c -2d -00 +19 +01 +01 00 c7 47 @@ -29117,9 +29117,9 @@ ff ff c7 07 -2c -2d -00 +19 +01 +01 00 c7 47 @@ -29259,9 +29259,9 @@ ff ff c7 07 -10 -2d +fd 00 +01 00 c7 47 @@ -29287,9 +29287,9 @@ ff ff c7 07 -2c -2d -00 +19 +01 +01 00 c7 47 @@ -29400,9 +29400,9 @@ ff ff c7 07 -2c -2d -00 +19 +01 +01 00 c7 47 @@ -29428,9 +29428,9 @@ ff ff c7 07 -2c -2d -00 +19 +01 +01 00 c7 47 @@ -29569,9 +29569,9 @@ ff ff c7 07 -2c -2d -00 +19 +01 +01 00 c7 47 @@ -29597,9 +29597,9 @@ ff ff c7 07 -2c -2d -00 +19 +01 +01 00 c7 47 @@ -29692,9 +29692,9 @@ ff ff c7 07 -2c -2d -00 +19 +01 +01 00 c7 47 @@ -29720,9 +29720,9 @@ ff ff c7 07 -2c -2d -00 +19 +01 +01 00 c7 47 @@ -29815,9 +29815,9 @@ ff ff c7 07 -2c -2d -00 +19 +01 +01 00 c7 47 @@ -29843,9 +29843,9 @@ ff ff c7 07 -2c -2d -00 +19 +01 +01 00 c7 47 @@ -30035,9 +30035,9 @@ ff ff c7 07 -2c -2d -00 +19 +01 +01 00 c7 47 @@ -30063,9 +30063,9 @@ ff ff c7 07 -2c -2d -00 +19 +01 +01 00 c7 47 @@ -30091,9 +30091,9 @@ ff ff c7 07 -2c -2d -00 +19 +01 +01 00 c7 47 @@ -30235,9 +30235,9 @@ ff ff c7 07 -2c -2d -00 +19 +01 +01 00 c7 47 @@ -30263,9 +30263,9 @@ ff ff c7 07 -10 -2d +fd 00 +01 00 c7 47 @@ -30291,9 +30291,9 @@ ff ff c7 07 -10 -2d +fd 00 +01 00 c7 47 @@ -30386,9 +30386,9 @@ ff ff c7 07 -2c -2d -00 +19 +01 +01 00 c7 47 @@ -30414,9 +30414,9 @@ ff ff c7 07 -10 -2d +fd 00 +01 00 c7 47 @@ -30521,9 +30521,9 @@ ff ff c7 07 -2c -2d -00 +19 +01 +01 00 c7 47 @@ -30549,9 +30549,9 @@ ff ff c7 07 -10 -2d +fd 00 +01 00 c7 47 @@ -30657,8 +30657,8 @@ ff ff c7 07 -38 -00 +25 +d4 00 00 c7 @@ -30769,9 +30769,9 @@ ff ff c7 07 -2c -2d -00 +19 +01 +01 00 c7 47 @@ -30797,9 +30797,9 @@ ff ff c7 07 -10 -2d +fd 00 +01 00 c7 47 @@ -30825,8 +30825,8 @@ ff ff c7 07 -1c -00 +09 +d4 00 00 c7 @@ -31073,8 +31073,8 @@ ff ff c7 07 -00 -10 +ed +e3 00 00 c7 @@ -31127,9 +31127,9 @@ ff ff 24 85 -a8 -4e -00 +95 +22 +01 00 41 80 @@ -31143,8 +31143,8 @@ ff ff c7 07 -00 -2a +ed +fd 00 00 c7 @@ -31180,9 +31180,9 @@ ff ff 24 85 -90 -4f -00 +7d +23 +01 00 41 8a @@ -31284,8 +31284,8 @@ ff ff c7 07 -00 -2a +ed +fd 00 00 c7 @@ -31312,8 +31312,8 @@ ff ff c7 07 -00 -2a +ed +fd 00 00 c7 @@ -31516,8 +31516,8 @@ ff ff c7 07 -00 -2a +ed +fd 00 00 c7 @@ -31586,8 +31586,8 @@ ff ff c7 07 -00 -2a +ed +fd 00 00 c7 @@ -31654,8 +31654,8 @@ ff ff c7 07 -00 -2a +ed +fd 00 00 c7 @@ -31712,8 +31712,8 @@ ff ff c7 07 -00 -2a +ed +fd 00 00 c7 @@ -31770,8 +31770,8 @@ ff ff c7 07 -00 -2a +ed +fd 00 00 c7 @@ -31798,8 +31798,8 @@ ff ff c7 07 -00 -2a +ed +fd 00 00 c7 @@ -31826,8 +31826,8 @@ ff ff c7 07 -00 -2a +ed +fd 00 00 c7 @@ -31854,8 +31854,8 @@ ff ff c7 07 -00 -2a +ed +fd 00 00 c7 @@ -31882,8 +31882,8 @@ ff ff c7 07 -00 -2a +ed +fd 00 00 c7 @@ -31910,8 +31910,8 @@ ff ff c7 07 -00 -2a +ed +fd 00 00 c7 @@ -31938,8 +31938,8 @@ ff ff c7 07 -00 -2a +ed +fd 00 00 c7 @@ -31966,8 +31966,8 @@ ff ff c7 07 -00 -2a +ed +fd 00 00 c7 @@ -31994,8 +31994,8 @@ ff ff c7 07 -00 -2a +ed +fd 00 00 c7 @@ -32275,9 +32275,9 @@ ff ff 24 85 -78 -50 -00 +65 +24 +01 00 41 8a @@ -32391,8 +32391,8 @@ ff ff c7 07 -60 -29 +4d +fd 00 00 c7 @@ -32456,8 +32456,8 @@ ff ff c7 07 -d0 -29 +bd +fd 00 00 c7 @@ -32496,8 +32496,8 @@ ff ff c7 07 -60 -29 +4d +fd 00 00 c7 @@ -32743,9 +32743,9 @@ ff ff c7 07 -64 -2d -00 +51 +01 +01 00 c7 47 @@ -32771,9 +32771,9 @@ ff ff c7 07 -64 -2d -00 +51 +01 +01 00 c7 47 @@ -32799,9 +32799,9 @@ ff ff c7 07 -64 -2d -00 +51 +01 +01 00 c7 47 @@ -32827,9 +32827,9 @@ ff ff c7 07 -48 -2d -00 +35 +01 +01 00 e9 fa @@ -32848,8 +32848,8 @@ ff ff c7 07 -1c -00 +09 +d4 00 00 c7 @@ -32876,8 +32876,8 @@ ff ff c7 07 -1c -00 +09 +d4 00 00 c7 @@ -32904,9 +32904,9 @@ ff ff c7 07 -80 -30 -00 +6d +04 +01 00 e9 cd @@ -32938,8 +32938,8 @@ a9 00 c7 07 -1c -00 +09 +d4 00 00 c7 @@ -32966,9 +32966,9 @@ ff ff c7 07 -9c -2d -00 +89 +01 +01 00 c7 47 @@ -32994,9 +32994,9 @@ ff ff c7 07 -80 -2d -00 +6d +01 +01 00 c7 47 @@ -33022,9 +33022,9 @@ ff ff c7 07 -9c -2d -00 +89 +01 +01 00 c7 47 @@ -33228,9 +33228,9 @@ ff ff c7 07 -64 -2d -00 +51 +01 +01 00 c7 47 @@ -33256,9 +33256,9 @@ ff ff c7 07 -64 -2d -00 +51 +01 +01 00 c7 47 @@ -33284,9 +33284,9 @@ ff ff c7 07 -64 -2d -00 +51 +01 +01 00 c7 47 @@ -33312,9 +33312,9 @@ ff ff c7 07 -48 -2d -00 +35 +01 +01 00 c7 47 @@ -33641,9 +33641,9 @@ ff ff c7 07 -64 -2d -00 +51 +01 +01 00 c7 47 @@ -33669,9 +33669,9 @@ ff ff c7 07 -64 -2d -00 +51 +01 +01 00 c7 47 @@ -33697,9 +33697,9 @@ ff ff c7 07 -64 -2d -00 +51 +01 +01 00 c7 47 @@ -33725,9 +33725,9 @@ ff ff c7 07 -48 -2d -00 +35 +01 +01 00 c7 47 @@ -33864,9 +33864,9 @@ ff ff c7 07 -64 -2d -00 +51 +01 +01 00 c7 47 @@ -33892,9 +33892,9 @@ ff ff c7 07 -64 -2d -00 +51 +01 +01 00 c7 47 @@ -33920,9 +33920,9 @@ ff ff c7 07 -64 -2d -00 +51 +01 +01 00 c7 47 @@ -33948,9 +33948,9 @@ ff ff c7 07 -48 -2d -00 +35 +01 +01 00 c7 47 @@ -34137,9 +34137,9 @@ ff ff c7 07 -64 -2d -00 +51 +01 +01 00 c7 47 @@ -34165,9 +34165,9 @@ ff ff c7 07 -64 -2d -00 +51 +01 +01 00 c7 47 @@ -34193,9 +34193,9 @@ ff ff c7 07 -64 -2d -00 +51 +01 +01 00 c7 47 @@ -34221,9 +34221,9 @@ ff ff c7 07 -48 -2d -00 +35 +01 +01 00 c7 47 @@ -34472,9 +34472,9 @@ ff ff c7 07 -64 -2d -00 +51 +01 +01 00 c7 47 @@ -34500,9 +34500,9 @@ ff ff c7 07 -64 -2d -00 +51 +01 +01 00 c7 47 @@ -34528,9 +34528,9 @@ ff ff c7 07 -48 -2d -00 +35 +01 +01 00 c7 47 @@ -34556,9 +34556,9 @@ ff ff c7 07 -64 -2d -00 +51 +01 +01 00 c7 47 @@ -34693,9 +34693,9 @@ ff ff c7 07 -64 -2d -00 +51 +01 +01 00 c7 47 @@ -34721,9 +34721,9 @@ ff ff c7 07 -64 -2d -00 +51 +01 +01 00 c7 47 @@ -34749,9 +34749,9 @@ ff ff c7 07 -48 -2d -00 +35 +01 +01 00 e9 98 @@ -34770,9 +34770,9 @@ ff ff c7 07 -64 -2d -00 +51 +01 +01 00 c7 47 @@ -34957,9 +34957,9 @@ ff ff c7 07 -64 -2d -00 +51 +01 +01 00 c7 47 @@ -34985,9 +34985,9 @@ ff ff c7 07 -64 -2d -00 +51 +01 +01 00 c7 47 @@ -35013,9 +35013,9 @@ ff ff c7 07 -48 -2d -00 +35 +01 +01 00 c7 47 @@ -35041,9 +35041,9 @@ ff ff c7 07 -64 -2d -00 +51 +01 +01 00 c7 47 @@ -35069,8 +35069,8 @@ ff ff c7 07 -1c -00 +09 +d4 00 00 c7 @@ -35097,8 +35097,8 @@ ff ff c7 07 -1c -00 +09 +d4 00 00 c7 @@ -35125,8 +35125,8 @@ ff ff c7 07 -1c -00 +09 +d4 00 00 c7 @@ -35239,8 +35239,8 @@ ff ff c7 07 -b8 -2a +a5 +fe 00 00 c7 @@ -35267,8 +35267,8 @@ ff ff c7 07 -38 -00 +25 +d4 00 00 c7 @@ -35318,8 +35318,8 @@ ff ff c7 07 -1c -00 +09 +d4 00 00 c7 @@ -35359,8 +35359,8 @@ ff 00 c7 07 -1c -00 +09 +d4 00 00 c7 @@ -35400,8 +35400,8 @@ ff 00 c7 07 -1c -00 +09 +d4 00 00 c7 @@ -35428,8 +35428,8 @@ ff ff c7 07 -1c -00 +09 +d4 00 00 c7 @@ -35473,8 +35473,8 @@ ff ff c7 07 -20 -1a +0d +ee 00 00 e9 @@ -35851,9 +35851,9 @@ ff ff 24 85 -50 -51 -00 +3d +25 +01 00 41 8a @@ -36030,9 +36030,9 @@ ff ff 24 85 -10 -52 -00 +fd +25 +01 00 41 80 @@ -36114,8 +36114,8 @@ ff ff c7 07 -38 -00 +25 +d4 00 00 c7 @@ -36228,9 +36228,9 @@ ff ff c7 07 -1c -33 -00 +09 +07 +01 00 c7 47 @@ -36273,9 +36273,9 @@ ff ff c7 07 -1c -33 -00 +09 +07 +01 00 c7 47 @@ -36301,9 +36301,9 @@ ff ff c7 07 -00 -33 -00 +ed +06 +01 00 e9 25 @@ -36424,9 +36424,9 @@ ff ff c7 07 -2c -2d -00 +19 +01 +01 00 c7 47 @@ -36452,9 +36452,9 @@ ff ff c7 07 -10 -2d +fd 00 +01 00 c7 47 @@ -36480,8 +36480,8 @@ ff ff c7 07 -80 -18 +6d +ec 00 00 e9 @@ -36501,8 +36501,8 @@ ff ff c7 07 -80 -18 +6d +ec 00 00 e9 @@ -36711,8 +36711,8 @@ ff ff c7 07 -c0 -1e +ad +f2 00 00 c7 @@ -36739,8 +36739,8 @@ ff ff c7 07 -c0 -1e +ad +f2 00 00 c7 @@ -37039,8 +37039,8 @@ ff ff c7 07 -38 -00 +25 +d4 00 00 c7 @@ -37091,8 +37091,8 @@ ff ff c7 07 -38 -00 +25 +d4 00 00 c7 @@ -37136,8 +37136,8 @@ ff ff c7 07 -38 -00 +25 +d4 00 00 c7 @@ -37188,8 +37188,8 @@ ff ff c7 07 -38 -00 +25 +d4 00 00 c7 @@ -37257,8 +37257,8 @@ ff ff c7 07 -80 -18 +6d +ec 00 00 e9 @@ -37278,8 +37278,8 @@ ff ff c7 07 -80 -18 +6d +ec 00 00 c7 @@ -37391,9 +37391,9 @@ ff ff c7 07 -2c -2d -00 +19 +01 +01 00 c7 47 @@ -37419,9 +37419,9 @@ ff ff c7 07 -10 -2d +fd 00 +01 00 c7 47 @@ -38448,8 +38448,8 @@ ff ff c7 07 -50 -23 +3d +f7 00 00 c7 @@ -38476,8 +38476,8 @@ ff ff c7 07 -c0 -0f +ad +e3 00 00 c7 @@ -38504,8 +38504,8 @@ ff ff c7 07 -00 -22 +ed +f5 00 00 c7 @@ -38685,8 +38685,8 @@ ff ff c7 07 -38 -00 +25 +d4 00 00 c7 @@ -38737,8 +38737,8 @@ ff ff c7 07 -38 -00 +25 +d4 00 00 c7 @@ -38862,8 +38862,8 @@ ff ff c7 07 -1c -00 +09 +d4 00 00 c7 @@ -38890,8 +38890,8 @@ ff ff c7 07 -1c -00 +09 +d4 00 00 c7 @@ -38918,8 +38918,8 @@ ff ff c7 07 -1c -00 +09 +d4 00 00 c7 @@ -38959,8 +38959,8 @@ ff 00 c7 07 -1c -00 +09 +d4 00 00 c7 @@ -39040,8 +39040,8 @@ ff ff c7 07 -40 -20 +2d +f4 00 00 c7 @@ -39068,8 +39068,8 @@ ff ff c7 07 -40 -20 +2d +f4 00 00 c7 @@ -39139,8 +39139,8 @@ ff ff c7 07 -40 -20 +2d +f4 00 00 c7 @@ -39212,8 +39212,8 @@ ff ff c7 07 -50 -23 +3d +f7 00 00 c7 @@ -39257,8 +39257,8 @@ ff ff c7 07 -50 -23 +3d +f7 00 00 c7 @@ -39309,8 +39309,8 @@ ff ff c7 07 -8c -00 +79 +d4 00 00 c7 @@ -39337,8 +39337,8 @@ ff ff c7 07 -c0 -0f +ad +e3 00 00 c7 @@ -39382,8 +39382,8 @@ ff ff c7 07 -8c -00 +79 +d4 00 00 c7 @@ -39410,8 +39410,8 @@ ff ff c7 07 -c0 -0f +ad +e3 00 00 c7 @@ -39489,8 +39489,8 @@ ff ff c7 07 -54 -00 +41 +d4 00 00 c7 @@ -39540,8 +39540,8 @@ ff ff c7 07 -20 -0f +0d +e3 00 00 c7 @@ -39581,8 +39581,8 @@ ab 00 c7 07 -80 -0f +6d +e3 00 00 c7 @@ -39626,8 +39626,8 @@ ff ff c7 07 -1c -00 +09 +d4 00 00 c7 @@ -39674,8 +39674,8 @@ ff 00 c7 07 -80 -0f +6d +e3 00 00 c7 @@ -39770,9 +39770,9 @@ ff ff c7 07 -b8 -2d -00 +a5 +01 +01 00 c7 47 @@ -39816,8 +39816,8 @@ ff ff c7 07 -00 -22 +ed +f5 00 00 c7 @@ -39857,8 +39857,8 @@ ff 00 c7 07 -1c -00 +09 +d4 00 00 c7 @@ -40239,8 +40239,8 @@ ff 00 c7 07 -b8 -22 +a5 +f6 00 00 c7 @@ -40322,8 +40322,8 @@ ff ff c7 07 -00 -10 +ed +e3 00 00 c7 @@ -40417,9 +40417,9 @@ ff ff c7 07 -10 -2d +fd 00 +01 00 c7 47 @@ -40445,9 +40445,9 @@ ff ff c7 07 -2c -2d -00 +19 +01 +01 00 c7 47 @@ -40523,9 +40523,9 @@ ff ff c7 07 -2c -2d -00 +19 +01 +01 00 c7 47 @@ -40551,9 +40551,9 @@ ff ff c7 07 -10 -2d +fd 00 +01 00 c7 47 @@ -40637,8 +40637,8 @@ ff ff c7 07 -00 -10 +ed +e3 00 00 c7 @@ -40665,8 +40665,8 @@ ff ff c7 07 -00 -10 +ed +e3 00 00 c7 @@ -40802,9 +40802,9 @@ ff ff c7 07 -2c -2d -00 +19 +01 +01 00 c7 47 @@ -40830,9 +40830,9 @@ ff ff c7 07 -2c -2d -00 +19 +01 +01 00 c7 47 @@ -40858,9 +40858,9 @@ ff ff c7 07 -10 -2d +fd 00 +01 00 c7 47 @@ -40886,9 +40886,9 @@ ff ff c7 07 -2c -2d -00 +19 +01 +01 00 c7 47 @@ -40927,8 +40927,8 @@ ff 00 c7 07 -1c -00 +09 +d4 00 00 c7 @@ -40968,8 +40968,8 @@ ff 00 c7 07 -1c -00 +09 +d4 00 00 c7 @@ -41009,8 +41009,8 @@ ff 00 c7 07 -20 -16 +0d +ea 00 00 c7 @@ -41050,8 +41050,8 @@ ee 00 c7 07 -20 -16 +0d +ea 00 00 c7 @@ -41144,9 +41144,9 @@ ff ec 08 68 -20 -3a -00 +0d +0e +01 00 56 e8 @@ -41263,8 +41263,8 @@ ff ff c7 07 -00 -10 +ed +e3 00 00 c7 @@ -41331,8 +41331,8 @@ ff ff c7 07 -60 -0e +4d +e2 00 00 c7 @@ -41424,8 +41424,8 @@ ff ff c7 07 -1c -00 +09 +d4 00 00 c7 @@ -41452,8 +41452,8 @@ ff ff c7 07 -1c -00 +09 +d4 00 00 c7 @@ -41480,8 +41480,8 @@ ff ff c7 07 -1c -00 +09 +d4 00 00 c7 @@ -41558,9 +41558,9 @@ ff ff c7 07 -2c -2d -00 +19 +01 +01 00 c7 47 @@ -41586,9 +41586,9 @@ ff ff c7 07 -10 -2d +fd 00 +01 00 c7 47 @@ -41623,9 +41623,9 @@ ff 0b 53 68 -60 -3a -00 +4d +0e +01 00 e9 b7 @@ -41821,8 +41821,8 @@ ff ff c7 07 -e0 -13 +cd +e7 00 00 c7 @@ -42257,9 +42257,9 @@ ff ff 24 85 -d4 -52 -00 +c1 +26 +01 00 41 8a @@ -43091,8 +43091,8 @@ ff ff c7 07 -38 -00 +25 +d4 00 00 c7 @@ -43131,8 +43131,8 @@ ff ff c7 07 -38 -00 +25 +d4 00 00 c7 @@ -43323,8 +43323,8 @@ ff ff c7 07 -8c -00 +79 +d4 00 00 c7 @@ -43385,8 +43385,8 @@ ff ff c7 07 -8c -00 +79 +d4 00 00 c7 @@ -43464,8 +43464,8 @@ ff ff c7 07 -38 -00 +25 +d4 00 00 c7 @@ -43492,8 +43492,8 @@ ff ff c7 07 -38 -00 +25 +d4 00 00 c7 @@ -43520,8 +43520,8 @@ ff ff c7 07 -a0 -25 +8d +f9 00 00 c7 @@ -43582,8 +43582,8 @@ ff ff c7 07 -1c -00 +09 +d4 00 00 c7 @@ -43699,8 +43699,8 @@ ff ff c7 07 -a0 -26 +8d +fa 00 00 c7 @@ -43750,8 +43750,8 @@ ff ff c7 07 -a0 -26 +8d +fa 00 00 c7 @@ -43801,8 +43801,8 @@ ff ff c7 07 -a0 -26 +8d +fa 00 00 c7 @@ -43829,8 +43829,8 @@ ff ff c7 07 -38 -00 +25 +d4 00 00 c7 @@ -43857,8 +43857,8 @@ ff ff c7 07 -a0 -26 +8d +fa 00 00 c7 @@ -43902,8 +43902,8 @@ ff ff c7 07 -38 -00 +25 +d4 00 00 c7 @@ -44054,8 +44054,8 @@ ff ff c7 07 -40 -25 +2d +f9 00 00 c7 @@ -44255,8 +44255,8 @@ ff ff c7 07 -38 -00 +25 +d4 00 00 c7 @@ -44307,8 +44307,8 @@ ff ff c7 07 -8c -00 +79 +d4 00 00 c7 @@ -44369,8 +44369,8 @@ ff ff c7 07 -38 -00 +25 +d4 00 00 c7 @@ -44420,8 +44420,8 @@ ff ff c7 07 -38 -00 +25 +d4 00 00 c7 @@ -44482,8 +44482,8 @@ ff ff c7 07 -38 -00 +25 +d4 00 00 c7 @@ -44527,8 +44527,8 @@ ff ff c7 07 -38 -00 +25 +d4 00 00 c7 @@ -44610,8 +44610,8 @@ ff ff c7 07 -e0 -26 +cd +fa 00 00 c7 @@ -44638,8 +44638,8 @@ ff ff c7 07 -a0 -27 +8d +fb 00 00 c7 @@ -44689,8 +44689,8 @@ ff ff c7 07 -e0 -26 +cd +fa 00 00 c7 @@ -44717,8 +44717,8 @@ ff ff c7 07 -a0 -27 +8d +fb 00 00 c7 @@ -44789,8 +44789,8 @@ ff ff c7 07 -40 -24 +2d +f8 00 00 c7 @@ -44834,8 +44834,8 @@ ff ff c7 07 -c0 -28 +ad +fc 00 00 e9 @@ -44872,8 +44872,8 @@ ff ff c7 07 -8c -00 +79 +d4 00 00 c7 @@ -44900,8 +44900,8 @@ ff ff c7 07 -54 -28 +41 +fc 00 00 c7 @@ -44997,8 +44997,8 @@ ff ff c7 07 -70 -00 +5d +d4 00 00 c7 @@ -45076,8 +45076,8 @@ ff ff c7 07 -38 -00 +25 +d4 00 00 c7 @@ -45189,8 +45189,8 @@ ff ff c7 07 -38 -00 +25 +d4 00 00 c7 @@ -45217,8 +45217,8 @@ ff ff c7 07 -38 -00 +25 +d4 00 00 c7 @@ -45279,8 +45279,8 @@ ff ff c7 07 -38 -00 +25 +d4 00 00 c7 @@ -45324,8 +45324,8 @@ ff ff c7 07 -38 -00 +25 +d4 00 00 c7 @@ -45477,8 +45477,8 @@ ff ff c7 07 -38 -00 +25 +d4 00 00 c7 @@ -45539,8 +45539,8 @@ ff ff c7 07 -38 -00 +25 +d4 00 00 c7 @@ -45728,8 +45728,8 @@ ff ff c7 07 -70 -00 +5d +d4 00 00 c7 @@ -45756,8 +45756,8 @@ ff ff c7 07 -80 -28 +6d +fc 00 00 c7 @@ -45784,8 +45784,8 @@ ff ff c7 07 -38 -28 +25 +fc 00 00 c7 @@ -45829,8 +45829,8 @@ ff ff c7 07 -70 -00 +5d +d4 00 00 c7 @@ -45891,8 +45891,8 @@ ff ff c7 07 -38 -00 +25 +d4 00 00 c7 @@ -45959,8 +45959,8 @@ ff ff c7 07 -e0 -26 +cd +fa 00 00 c7 @@ -45987,8 +45987,8 @@ ff ff c7 07 -a0 -27 +8d +fb 00 00 c7 @@ -46179,8 +46179,8 @@ ff ff c7 07 -40 -24 +2d +f8 00 00 c7 @@ -46207,8 +46207,8 @@ ff ff c7 07 -38 -00 +25 +d4 00 00 c7 @@ -46388,8 +46388,8 @@ ff ff c7 07 -38 -00 +25 +d4 00 00 c7 @@ -46416,8 +46416,8 @@ ff ff c7 07 -38 -00 +25 +d4 00 00 c7 @@ -46522,8 +46522,8 @@ ff ff c7 07 -38 -00 +25 +d4 00 00 c7 @@ -46550,8 +46550,8 @@ ff ff c7 07 -38 -00 +25 +d4 00 00 c7 @@ -46578,8 +46578,8 @@ ff ff c7 07 -38 -00 +25 +d4 00 00 c7 @@ -46606,8 +46606,8 @@ ff ff c7 07 -38 -00 +25 +d4 00 00 c7 @@ -46651,8 +46651,8 @@ ff ff c7 07 -70 -00 +5d +d4 00 00 c7 @@ -46679,8 +46679,8 @@ ff ff c7 07 -38 -28 +25 +fc 00 00 c7 @@ -46985,8 +46985,8 @@ ff ff c7 07 -54 -00 +41 +d4 00 00 c7 @@ -47047,8 +47047,8 @@ ff ff c7 07 -38 -00 +25 +d4 00 00 c7 @@ -47115,8 +47115,8 @@ ff ff c7 07 -00 -28 +ed +fb 00 00 c7 @@ -47143,8 +47143,8 @@ ff ff c7 07 -00 -28 +ed +fb 00 00 c7 @@ -47188,8 +47188,8 @@ ff ff c7 07 -00 -28 +ed +fb 00 00 c7 @@ -47233,8 +47233,8 @@ ff ff c7 07 -00 -28 +ed +fb 00 00 c7 @@ -47301,8 +47301,8 @@ ff ff c7 07 -00 -28 +ed +fb 00 00 c7 @@ -47329,8 +47329,8 @@ ff ff c7 07 -00 -28 +ed +fb 00 00 c7 @@ -47380,8 +47380,8 @@ ff ff c7 07 -00 -28 +ed +fb 00 00 c7 @@ -47448,8 +47448,8 @@ ff ff c7 07 -00 -28 +ed +fb 00 00 c7 @@ -47476,8 +47476,8 @@ ff ff c7 07 -00 -28 +ed +fb 00 00 c7 @@ -47504,8 +47504,8 @@ ff ff c7 07 -c0 -24 +ad +f8 00 00 c7 @@ -47532,8 +47532,8 @@ ff ff c7 07 -c0 -24 +ad +f8 00 00 c7 @@ -47617,8 +47617,8 @@ ff ff c7 07 -f8 -28 +e5 +fc 00 00 c7 @@ -47645,8 +47645,8 @@ ff ff c7 07 -f8 -28 +e5 +fc 00 00 c7 @@ -47714,8 +47714,8 @@ ff ff c7 07 -38 -00 +25 +d4 00 00 c7 @@ -47835,8 +47835,8 @@ ff ff c7 07 -38 -00 +25 +d4 00 00 c7 @@ -47918,8 +47918,8 @@ ff ff c7 07 -e0 -26 +cd +fa 00 00 c7 @@ -47946,8 +47946,8 @@ ff ff c7 07 -a0 -27 +8d +fb 00 00 c7 @@ -47997,8 +47997,8 @@ ff ff c7 07 -e0 -26 +cd +fa 00 00 c7 @@ -48025,8 +48025,8 @@ ff ff c7 07 -a0 -27 +8d +fb 00 00 c7 @@ -48330,8 +48330,8 @@ ff ff c7 07 -54 -2a +41 +fe 00 00 c7 @@ -48358,8 +48358,8 @@ ff ff c7 07 -54 -2a +41 +fe 00 00 c7 @@ -48436,8 +48436,8 @@ ff ff c7 07 -54 -2a +41 +fe 00 00 c7 @@ -48487,8 +48487,8 @@ ff ff c7 07 -54 -2a +41 +fe 00 00 c7 @@ -48515,8 +48515,8 @@ ff ff c7 07 -54 -2a +41 +fe 00 00 c7 @@ -48543,8 +48543,8 @@ ff ff c7 07 -54 -2a +41 +fe 00 00 c7 @@ -48571,8 +48571,8 @@ ff ff c7 07 -54 -2a +41 +fe 00 00 c7 @@ -48616,8 +48616,8 @@ ff ff c7 07 -54 -00 +41 +d4 00 00 c7 @@ -48644,8 +48644,8 @@ ff ff c7 07 -38 -00 +25 +d4 00 00 c7 @@ -48731,8 +48731,8 @@ ff ff c7 07 -20 -26 +0d +fa 00 00 c7 @@ -48759,8 +48759,8 @@ ff ff c7 07 -38 -00 +25 +d4 00 00 c7 @@ -48817,8 +48817,8 @@ ff ff c7 07 -20 -26 +0d +fa 00 00 c7 @@ -48868,8 +48868,8 @@ ff ff c7 07 -a0 -26 +8d +fa 00 00 c7 @@ -48893,8 +48893,8 @@ ff ff c7 07 -a0 -26 +8d +fa 00 00 c7 @@ -48928,8 +48928,8 @@ ff ff c7 07 -38 -00 +25 +d4 00 00 c7 @@ -49008,8 +49008,8 @@ ff ff c7 07 -14 -25 +01 +f9 00 00 c7 @@ -49036,8 +49036,8 @@ ff ff c7 07 -14 -25 +01 +f9 00 00 c7 @@ -49120,8 +49120,8 @@ ff ff c7 07 -38 -00 +25 +d4 00 00 c7 @@ -49168,8 +49168,8 @@ ff ff c7 07 -e0 -26 +cd +fa 00 00 c7 @@ -49193,8 +49193,8 @@ ff ff c7 07 -a0 -27 +8d +fb 00 00 c7 @@ -49247,8 +49247,8 @@ ff ff c7 07 -38 -00 +25 +d4 00 00 c7 @@ -49504,9 +49504,9 @@ ff ff 24 85 -a0 -53 -00 +8d +27 +01 00 41 8a @@ -49786,9 +49786,9 @@ ff 11 53 68 -e0 -39 -00 +cd +0d +01 00 56 6a @@ -49838,9 +49838,9 @@ ff ff 24 85 -48 -54 -00 +35 +28 +01 00 41 8a @@ -50181,8 +50181,8 @@ ff ff c7 07 -38 -00 +25 +d4 00 00 c7 @@ -50281,8 +50281,8 @@ df 00 c7 07 -38 -00 +25 +d4 00 00 c7 @@ -50363,8 +50363,8 @@ ff 00 c7 07 -38 -00 +25 +d4 00 00 c7 @@ -50432,8 +50432,8 @@ ff ff c7 07 -38 -00 +25 +d4 00 00 c7 @@ -50531,8 +50531,8 @@ f0 00 c7 07 -54 -00 +41 +d4 00 00 c7 @@ -50612,9 +50612,9 @@ ff ff c7 07 -1c -33 -00 +09 +07 +01 00 c7 47 @@ -50654,9 +50654,9 @@ ff ff c7 07 -1c -33 -00 +09 +07 +01 00 c7 47 @@ -50679,9 +50679,9 @@ ff ff c7 07 -38 -33 -00 +25 +07 +01 00 c7 47 @@ -50769,8 +50769,8 @@ ff ff c7 07 -00 -10 +ed +e3 00 00 c7 @@ -50906,9 +50906,9 @@ ff ff c7 07 -2c -2d -00 +19 +01 +01 00 c7 47 @@ -50934,9 +50934,9 @@ ff ff c7 07 -2c -2d -00 +19 +01 +01 00 c7 47 @@ -50962,9 +50962,9 @@ ff ff c7 07 -10 -2d +fd 00 +01 00 c7 47 @@ -50990,9 +50990,9 @@ ff ff c7 07 -2c -2d -00 +19 +01 +01 00 c7 47 @@ -51045,8 +51045,8 @@ ff ff c7 07 -1c -00 +09 +d4 00 00 c7 @@ -51073,8 +51073,8 @@ ff ff c7 07 -1c -00 +09 +d4 00 00 c7 @@ -51101,8 +51101,8 @@ ff ff c7 07 -1c -00 +09 +d4 00 00 c7 @@ -51155,8 +51155,8 @@ ff ff c7 07 -e0 -22 +cd +f6 00 00 c7 @@ -51258,9 +51258,9 @@ ff ff c7 07 -b8 -2d -00 +a5 +01 +01 00 c7 47 @@ -51376,8 +51376,8 @@ ff ff c7 07 -1c -00 +09 +d4 00 00 c7 @@ -51404,8 +51404,8 @@ ff ff c7 07 -1c -00 +09 +d4 00 00 c7 @@ -51432,8 +51432,8 @@ ff ff c7 07 -1c -00 +09 +d4 00 00 c7 @@ -51473,8 +51473,8 @@ ff 00 c7 07 -1c -00 +09 +d4 00 00 c7 @@ -51679,9 +51679,9 @@ ff ff c7 07 -2c -2d -00 +19 +01 +01 00 c7 47 @@ -51707,9 +51707,9 @@ ff ff c7 07 -2c -2d -00 +19 +01 +01 00 c7 47 @@ -51735,9 +51735,9 @@ ff ff c7 07 -2c -2d -00 +19 +01 +01 00 c7 47 @@ -51763,9 +51763,9 @@ ff ff c7 07 -10 -2d +fd 00 +01 00 c7 47 @@ -51874,8 +51874,8 @@ ff ff c7 07 -1c -00 +09 +d4 00 00 c7 @@ -51949,8 +51949,8 @@ ff ff c7 07 -38 -00 +25 +d4 00 00 c7 @@ -52018,8 +52018,8 @@ ff ff c7 07 -38 -00 +25 +d4 00 00 c7 @@ -52053,8 +52053,8 @@ ff ff c7 07 -80 -23 +6d +f7 00 00 c7 @@ -52095,8 +52095,8 @@ ff ff c7 07 -80 -23 +6d +f7 00 00 c7 @@ -52139,9 +52139,9 @@ ff 0b 53 68 -80 -3a -00 +6d +0e +01 00 e9 a3 @@ -52193,8 +52193,8 @@ ff ff c7 07 -8c -00 +79 +d4 00 00 c7 @@ -52321,8 +52321,8 @@ ff ff c7 07 -80 -18 +6d +ec 00 00 c7 @@ -52433,9 +52433,9 @@ ff ff c7 07 -9c -2d -00 +89 +01 +01 00 c7 47 @@ -52468,9 +52468,9 @@ ff ff c7 07 -80 -2d -00 +6d +01 +01 00 c7 47 @@ -52503,8 +52503,8 @@ ff ff c7 07 -60 -19 +4d +ed 00 00 c7 @@ -52531,8 +52531,8 @@ ff ff c7 07 -60 -19 +4d +ed 00 00 c7 @@ -52614,8 +52614,8 @@ ff ff c7 07 -8c -00 +79 +d4 00 00 c7 @@ -52700,8 +52700,8 @@ ff ff c7 07 -54 -00 +41 +d4 00 00 c7 @@ -52744,9 +52744,9 @@ ff ff 24 85 -54 -55 -00 +41 +29 +01 00 41 8a @@ -52945,9 +52945,9 @@ ff ff 24 85 -3c -56 -00 +29 +2a +01 00 41 80 @@ -52961,8 +52961,8 @@ ff ff c7 07 -20 -21 +0d +f5 00 00 c7 @@ -53055,8 +53055,8 @@ ff ff c7 07 -20 -21 +0d +f5 00 00 c7 @@ -53083,8 +53083,8 @@ ff ff c7 07 -20 -21 +0d +f5 00 00 c7 @@ -53111,8 +53111,8 @@ ff ff c7 07 -20 -21 +0d +f5 00 00 c7 @@ -53139,8 +53139,8 @@ ff ff c7 07 -20 -21 +0d +f5 00 00 c7 @@ -53255,8 +53255,8 @@ ff ff c7 07 -20 -21 +0d +f5 00 00 c7 @@ -53283,8 +53283,8 @@ ff ff c7 07 -20 -21 +0d +f5 00 00 c7 @@ -53311,8 +53311,8 @@ ff ff c7 07 -20 -21 +0d +f5 00 00 c7 @@ -53412,8 +53412,8 @@ ff ff c7 07 -20 -21 +0d +f5 00 00 c7 @@ -53440,8 +53440,8 @@ ff ff c7 07 -20 -21 +0d +f5 00 00 c7 @@ -53468,8 +53468,8 @@ ff ff c7 07 -20 -21 +0d +f5 00 00 c7 @@ -53496,8 +53496,8 @@ ff ff c7 07 -20 -21 +0d +f5 00 00 c7 @@ -53524,8 +53524,8 @@ ff ff c7 07 -20 -21 +0d +f5 00 00 c7 @@ -53552,8 +53552,8 @@ ff ff c7 07 -20 -21 +0d +f5 00 00 c7 @@ -53580,8 +53580,8 @@ ff ff c7 07 -20 -21 +0d +f5 00 00 c7 @@ -53608,8 +53608,8 @@ ff ff c7 07 -20 -21 +0d +f5 00 00 c7 @@ -53743,8 +53743,8 @@ ff ff c7 07 -1c -00 +09 +d4 00 00 c7 @@ -53771,8 +53771,8 @@ ff ff c7 07 -1c -00 +09 +d4 00 00 c7 @@ -53799,8 +53799,8 @@ ff ff c7 07 -1c -00 +09 +d4 00 00 c7 @@ -53843,9 +53843,9 @@ ff 18 53 68 -c0 -3a -00 +ad +0e +01 00 56 6a @@ -53867,8 +53867,8 @@ e9 00 c7 07 -1c -00 +09 +d4 00 00 c7 @@ -53902,8 +53902,8 @@ ff ff c7 07 -00 -10 +ed +e3 00 00 c7 @@ -53979,8 +53979,8 @@ ff ff c7 07 -80 -18 +6d +ec 00 00 c7 @@ -54007,8 +54007,8 @@ ff ff c7 07 -80 -18 +6d +ec 00 00 c7 @@ -54044,8 +54044,8 @@ ff 2c c7 07 -1c -00 +09 +d4 00 00 c7 @@ -54091,9 +54091,9 @@ ec 04 53 68 -e5 -3a -00 +d2 +0e +01 00 56 e8 @@ -54103,8 +54103,8 @@ ff ff c7 07 -00 -00 +ed +d3 00 00 c7 @@ -54131,8 +54131,8 @@ de 00 c7 07 -1c -00 +09 +d4 00 00 c7 @@ -54265,8 +54265,8 @@ ff ff c7 07 -60 -13 +4d +e7 00 00 c7 @@ -54290,8 +54290,8 @@ ff ff c7 07 -1c -00 +09 +d4 00 00 c7 @@ -54333,8 +54333,8 @@ ff ff c7 07 -60 -13 +4d +e7 00 00 c7 @@ -84829,9 +84829,9 @@ e7 cf 00 00 -64 -36 -00 +51 +0a +01 00 02 00 @@ -84839,9 +84839,9 @@ cf 00 06 00 -68 -36 -00 +55 +0a +01 00 02 00 @@ -84849,9 +84849,9 @@ cf 00 06 00 -6c -36 -00 +59 +0a +01 00 02 00 @@ -84859,9 +84859,9 @@ cf 00 06 00 -70 -36 -00 +5d +0a +01 00 02 00 @@ -84869,9 +84869,9 @@ cf 00 06 00 -74 -36 -00 +61 +0a +01 00 02 00 @@ -84879,9 +84879,9 @@ cf 00 06 00 -78 -36 -00 +65 +0a +01 00 02 00 @@ -84889,9 +84889,9 @@ cf 00 06 00 -7c -36 -00 +69 +0a +01 00 02 00 @@ -84899,9 +84899,9 @@ cf 00 06 00 -80 -36 -00 +6d +0a +01 00 02 00 @@ -84909,9 +84909,9 @@ cf 00 06 00 -84 -36 -00 +71 +0a +01 00 02 00 @@ -84919,9 +84919,9 @@ cf 00 06 00 -88 -36 -00 +75 +0a +01 00 02 00 @@ -84929,9 +84929,9 @@ cf 00 06 00 -8c -36 -00 +79 +0a +01 00 02 00 @@ -84939,9 +84939,9 @@ cf 00 06 00 -90 -36 -00 +7d +0a +01 00 02 00 @@ -84949,9 +84949,9 @@ cf 00 06 00 -94 -36 -00 +81 +0a +01 00 02 00 @@ -84959,9 +84959,9 @@ cf 00 06 00 -98 -36 -00 +85 +0a +01 00 02 00 @@ -84969,9 +84969,9 @@ cf 00 06 00 -9c -36 -00 +89 +0a +01 00 02 00 @@ -84979,9 +84979,9 @@ cf 00 06 00 -a0 -36 -00 +8d +0a +01 00 02 00 @@ -84989,9 +84989,9 @@ a0 00 06 00 -a4 -36 -00 +91 +0a +01 00 02 00 @@ -84999,9 +84999,9 @@ a4 00 06 00 -a8 -36 -00 +95 +0a +01 00 02 00 @@ -85009,9 +85009,9 @@ a8 00 06 00 -ac -36 -00 +99 +0a +01 00 02 00 @@ -85019,9 +85019,9 @@ ac 00 06 00 -b0 -36 -00 +9d +0a +01 00 02 00 @@ -85029,9 +85029,9 @@ b0 00 06 00 -b4 -36 -00 +a1 +0a +01 00 02 00 @@ -85039,9 +85039,9 @@ b4 00 06 00 -b8 -36 -00 +a5 +0a +01 00 02 00 @@ -85049,9 +85049,9 @@ b8 00 06 00 -e0 -36 -00 +cd +0a +01 00 02 00 @@ -85059,9 +85059,9 @@ e0 00 06 00 -e4 -36 -00 +d1 +0a +01 00 02 00 @@ -85069,9 +85069,9 @@ e4 00 06 00 -e8 -36 -00 +d5 +0a +01 00 02 00 @@ -85079,9 +85079,9 @@ e8 00 06 00 -ec -36 -00 +d9 +0a +01 00 02 00 @@ -85089,9 +85089,9 @@ ec 00 06 00 -f0 -36 -00 +dd +0a +01 00 02 00 @@ -85099,9 +85099,9 @@ f0 00 06 00 -f4 -36 -00 +e1 +0a +01 00 02 00 @@ -85109,9 +85109,9 @@ f4 00 06 00 -f8 -36 -00 +e5 +0a +01 00 02 00 @@ -85119,9 +85119,9 @@ f8 00 06 00 -fc -36 -00 +e9 +0a +01 00 02 00 @@ -85129,9 +85129,9 @@ fc 00 06 00 -00 -37 -00 +ed +0a +01 00 02 00 @@ -85139,9 +85139,9 @@ fc 00 06 00 -04 -37 -00 +f1 +0a +01 00 02 00 @@ -85149,9 +85149,9 @@ fc 00 06 00 -08 -37 -00 +f5 +0a +01 00 02 00 @@ -85159,9 +85159,669 @@ fc 00 06 00 +f9 +0a +01 +00 +02 +00 +00 +00 +06 +00 +fd +0a +01 +00 +02 +00 +00 +00 +06 +00 +01 +0b +01 +00 +02 +00 +00 +00 +06 +00 +05 +0b +01 +00 +02 +00 +00 +00 +06 +00 +09 +0b +01 +00 +02 +00 +00 +00 +06 +00 +0d +0b +01 +00 +02 +00 +00 +00 +06 +00 +11 +0b +01 +00 +02 +00 +00 +00 +06 +00 +15 +0b +01 +00 +02 +00 +00 +00 +06 +00 +19 +0b +01 +00 +02 +00 +00 +00 +06 +00 +1d +0b +01 +00 +02 +00 +00 +00 +06 +00 +21 +0b +01 +00 +02 +00 +00 +00 +06 +00 +25 +0b +01 +00 +02 +00 +00 +00 +06 +00 +29 +0b +01 +00 +02 +00 +00 +00 +06 +00 +2d +0b +01 +00 +02 +00 +00 +00 +06 +00 +31 +0b +01 +00 +02 +00 +00 +00 +06 +00 +35 +0b +01 +00 +02 +00 +00 +00 +06 +00 +39 +0b +01 +00 +02 +00 +00 +00 +06 +00 +3d +0b +01 +00 +02 +00 +00 +00 +06 +00 +41 +0b +01 +00 +02 +00 +00 +00 +06 +00 +45 +0b +01 +00 +02 +00 +00 +00 +06 +00 +49 +0b +01 +00 +02 +00 +00 +00 +06 +00 +4d +0b +01 +00 +02 +00 +00 +00 +06 +00 +51 +0b +01 +00 +02 +00 +00 +00 +06 +00 +55 +0b +01 +00 +02 +00 +00 +00 +06 +00 +59 +0b +01 +00 +02 +00 +00 +00 +06 +00 +5d +0b +01 +00 +02 +00 +00 +00 +06 +00 +61 +0b +01 +00 +02 +00 +00 +00 +06 +00 +65 +0b +01 +00 +02 +00 +00 +00 +06 +00 +69 +0b +01 +00 +02 +00 +00 +00 +06 +00 +6d +0b +01 +00 +02 +00 +00 +00 +06 +00 +71 +0b +01 +00 +02 +00 +00 +00 +06 +00 +75 +0b +01 +00 +02 +00 +00 +00 +06 +00 +79 +0b +01 +00 +02 +00 +00 +00 +06 +00 +7d +0b +01 +00 +02 +00 +00 +00 +06 +00 +81 +0b +01 +00 +02 +00 +00 +00 +06 +00 +85 +0b +01 +00 +02 +00 +00 +00 +06 +00 +89 +0b +01 +00 +02 +00 +00 +00 +06 +00 +8d +0b +01 +00 +02 +00 +00 +00 +06 +00 +91 +0b +01 +00 +02 +00 +00 +00 +06 +00 +95 +0b +01 +00 +02 +00 +00 +00 +06 +00 +99 +0b +01 +00 +02 +00 +00 +00 +06 +00 +9d +0b +01 +00 +02 +00 +00 +00 +06 +00 +a1 +0b +01 +00 +02 +00 +00 +00 +06 +00 +a5 +0b +01 +00 +02 +00 +00 +00 +06 +00 +a9 +0b +01 +00 +02 +00 +00 +00 +06 +00 +ad +0b +01 +00 +02 +00 +00 +00 +06 +00 +b1 +0b +01 +00 +02 +00 +00 +00 +06 +00 +b5 +0b +01 +00 +02 +00 +00 +00 +06 +00 +b9 +0b +01 +00 +02 +00 +00 +00 +06 +00 +bd +0b +01 +00 +02 +00 +00 +00 +06 +00 +c1 +0b +01 +00 +02 +00 +00 +00 +06 +00 +c5 +0b +01 +00 +02 +00 +00 +00 +06 +00 +c9 +0b +01 +00 +02 +00 +00 +00 +06 +00 +cd +0b +01 +00 +02 +00 +00 +00 +06 +00 +d1 +0b +01 +00 +02 +00 +00 +00 +06 +00 +d5 +0b +01 +00 +02 +00 +00 +00 +06 +00 +d9 +0b +01 +00 +02 +00 +00 +00 +06 +00 +dd +0b +01 +00 +02 +00 +00 +00 +06 +00 +e1 +0b +01 +00 +02 +00 +00 +00 +06 +00 +e5 +0b +01 +00 +02 +00 +00 +00 +06 +00 +e9 +0b +01 +00 +02 +00 +00 +00 +06 +00 +ed +0b +01 +00 +02 +00 +00 +00 +06 +00 +f1 +0b +01 +00 +02 +00 +00 +00 +06 +00 +f5 +0b +01 +00 +02 +00 +00 +00 +06 +00 +f9 +0b +01 +00 +02 +00 +00 +00 +06 +00 +fd +0b +01 +00 +02 +00 +00 +00 +06 +00 +01 0c -37 -00 +01 00 02 00 @@ -85169,9 +85829,1789 @@ fc 00 06 00 +05 +0c +01 +00 +02 +00 +00 +00 +06 +00 +09 +0c +01 +00 +02 +00 +00 +00 +06 +00 +0d +0c +01 +00 +02 +00 +00 +00 +06 +00 +11 +0c +01 +00 +02 +00 +00 +00 +06 +00 +15 +0c +01 +00 +02 +00 +00 +00 +06 +00 +19 +0c +01 +00 +02 +00 +00 +00 +06 +00 +1d +0c +01 +00 +02 +00 +00 +00 +06 +00 +21 +0c +01 +00 +02 +00 +00 +00 +06 +00 +25 +0c +01 +00 +02 +00 +00 +00 +06 +00 +29 +0c +01 +00 +02 +00 +00 +00 +06 +00 +2d +0c +01 +00 +02 +00 +00 +00 +06 +00 +31 +0c +01 +00 +02 +00 +00 +00 +06 +00 +35 +0c +01 +00 +02 +00 +00 +00 +06 +00 +39 +0c +01 +00 +02 +00 +00 +00 +06 +00 +3d +0c +01 +00 +02 +00 +00 +00 +06 +00 +41 +0c +01 +00 +02 +00 +00 +00 +06 +00 +45 +0c +01 +00 +02 +00 +00 +00 +06 +00 +49 +0c +01 +00 +02 +00 +00 +00 +06 +00 +4d +0c +01 +00 +02 +00 +00 +00 +06 +00 +51 +0c +01 +00 +02 +00 +00 +00 +06 +00 +55 +0c +01 +00 +02 +00 +00 +00 +06 +00 +59 +0c +01 +00 +02 +00 +00 +00 +06 +00 +5d +0c +01 +00 +02 +00 +00 +00 +06 +00 +61 +0c +01 +00 +02 +00 +00 +00 +06 +00 +65 +0c +01 +00 +02 +00 +00 +00 +06 +00 +69 +0c +01 +00 +02 +00 +00 +00 +06 +00 +6d +0c +01 +00 +02 +00 +00 +00 +06 +00 +71 +0c +01 +00 +02 +00 +00 +00 +06 +00 +75 +0c +01 +00 +02 +00 +00 +00 +06 +00 +79 +0c +01 +00 +02 +00 +00 +00 +06 +00 +7d +0c +01 +00 +02 +00 +00 +00 +06 +00 +81 +0c +01 +00 +02 +00 +00 +00 +06 +00 +85 +0c +01 +00 +02 +00 +00 +00 +06 +00 +89 +0c +01 +00 +02 +00 +00 +00 +06 +00 +8d +0c +01 +00 +02 +00 +00 +00 +06 +00 +91 +0c +01 +00 +02 +00 +00 +00 +06 +00 +95 +0c +01 +00 +02 +00 +00 +00 +06 +00 +99 +0c +01 +00 +02 +00 +00 +00 +06 +00 +9d +0c +01 +00 +02 +00 +00 +00 +06 +00 +a1 +0c +01 +00 +02 +00 +00 +00 +06 +00 +a5 +0c +01 +00 +02 +00 +00 +00 +06 +00 +a9 +0c +01 +00 +02 +00 +00 +00 +06 +00 +ad +0c +01 +00 +02 +00 +00 +00 +06 +00 +b1 +0c +01 +00 +02 +00 +00 +00 +06 +00 +b5 +0c +01 +00 +02 +00 +00 +00 +06 +00 +b9 +0c +01 +00 +02 +00 +00 +00 +06 +00 +bd +0c +01 +00 +02 +00 +00 +00 +06 +00 +c1 +0c +01 +00 +02 +00 +00 +00 +06 +00 +c5 +0c +01 +00 +02 +00 +00 +00 +06 +00 +c9 +0c +01 +00 +02 +00 +00 +00 +06 +00 +cd +0c +01 +00 +02 +00 +00 +00 +06 +00 +d1 +0c +01 +00 +02 +00 +00 +00 +06 +00 +d5 +0c +01 +00 +02 +00 +00 +00 +06 +00 +d9 +0c +01 +00 +02 +00 +00 +00 +06 +00 +dd +0c +01 +00 +02 +00 +00 +00 +06 +00 +e1 +0c +01 +00 +02 +00 +00 +00 +06 +00 +e5 +0c +01 +00 +02 +00 +00 +00 +06 +00 +e9 +0c +01 +00 +02 +00 +00 +00 +06 +00 +ed +0c +01 +00 +02 +00 +00 +00 +06 +00 +f1 +0c +01 +00 +02 +00 +00 +00 +06 +00 +f5 +0c +01 +00 +02 +00 +00 +00 +06 +00 +f9 +0c +01 +00 +02 +00 +00 +00 +06 +00 +fd +0c +01 +00 +02 +00 +00 +00 +06 +00 +01 +0d +01 +00 +02 +00 +00 +00 +06 +00 +05 +0d +01 +00 +02 +00 +00 +00 +06 +00 +09 +0d +01 +00 +02 +00 +00 +00 +06 +00 +0d +0d +01 +00 +02 +00 +00 +00 +06 +00 +11 +0d +01 +00 +02 +00 +00 +00 +06 +00 +15 +0d +01 +00 +02 +00 +00 +00 +06 +00 +19 +0d +01 +00 +02 +00 +00 +00 +06 +00 +1d +0d +01 +00 +02 +00 +00 +00 +06 +00 +21 +0d +01 +00 +02 +00 +00 +00 +06 +00 +25 +0d +01 +00 +02 +00 +00 +00 +06 +00 +29 +0d +01 +00 +02 +00 +00 +00 +06 +00 +2d +0d +01 +00 +02 +00 +00 +00 +06 +00 +31 +0d +01 +00 +02 +00 +00 +00 +06 +00 +35 +0d +01 +00 +02 +00 +00 +00 +06 +00 +39 +0d +01 +00 +02 +00 +00 +00 +06 +00 +3d +0d +01 +00 +02 +00 +00 +00 +06 +00 +41 +0d +01 +00 +02 +00 +00 +00 +06 +00 +45 +0d +01 +00 +02 +00 +00 +00 +06 +00 +49 +0d +01 +00 +02 +00 +00 +00 +06 +00 +4d +0d +01 +00 +02 +00 +00 +00 +06 +00 +51 +0d +01 +00 +02 +00 +00 +00 +06 +00 +55 +0d +01 +00 +02 +00 +00 +00 +06 +00 +59 +0d +01 +00 +02 +00 +00 +00 +06 +00 +5d +0d +01 +00 +02 +00 +00 +00 +06 +00 +61 +0d +01 +00 +02 +00 +00 +00 +06 +00 +65 +0d +01 +00 +02 +00 +00 +00 +06 +00 +69 +0d +01 +00 +02 +00 +00 +00 +06 +00 +6d +0d +01 +00 +02 +00 +00 +00 +06 +00 +71 +0d +01 +00 +02 +00 +00 +00 +06 +00 +75 +0d +01 +00 +02 +00 +00 +00 +06 +00 +79 +0d +01 +00 +02 +00 +00 +00 +06 +00 +7d +0d +01 +00 +02 +00 +00 +00 +06 +00 +81 +0d +01 +00 +02 +00 +00 +00 +06 +00 +85 +0d +01 +00 +02 +00 +00 +00 +06 +00 +89 +0d +01 +00 +02 +00 +00 +00 +06 +00 +8d +0d +01 +00 +02 +00 +00 +00 +06 +00 +91 +0d +01 +00 +02 +00 +00 +00 +06 +00 +95 +0d +01 +00 +02 +00 +00 +00 +06 +00 +99 +0d +01 +00 +02 +00 +00 +00 +06 +00 +9d +0d +01 +00 +02 +00 +00 +00 +06 +00 +a1 +0d +01 +00 +02 +00 +00 +00 +06 +00 +a5 +0d +01 +00 +02 +00 +00 +00 +06 +00 +a9 +0d +01 +00 +02 +00 +00 +00 +06 +00 +ad +0d +01 +00 +02 +00 +00 +00 +06 +00 +b1 +0d +01 +00 +02 +00 +00 +00 +06 +00 +b5 +0d +01 +00 +02 +00 +00 +00 +06 +00 +ed +0e +01 +00 +02 +00 +00 +00 +06 +00 +f1 +0e +01 +00 +02 +00 +00 +00 +06 +00 +f5 +0e +01 +00 +02 +00 +00 +00 +06 +00 +f9 +0e +01 +00 +02 +00 +00 +00 +06 +00 +fd +0e +01 +00 +02 +00 +00 +00 +06 +00 +01 +0f +01 +00 +02 +00 +00 +00 +06 +00 +05 +0f +01 +00 +02 +00 +00 +00 +06 +00 +09 +0f +01 +00 +02 +00 +00 +00 +06 +00 +0d +0f +01 +00 +02 +00 +00 +00 +06 +00 +11 +0f +01 +00 +02 +00 +00 +00 +06 +00 +15 +0f +01 +00 +02 +00 +00 +00 +06 +00 +19 +0f +01 +00 +02 +00 +00 +00 +06 +00 +1d +0f +01 +00 +02 +00 +00 +00 +06 +00 +21 +0f +01 +00 +02 +00 +00 +00 +06 +00 +25 +0f +01 +00 +02 +00 +00 +00 +06 +00 +29 +0f +01 +00 +02 +00 +00 +00 +06 +00 +2d +0f +01 +00 +02 +00 +00 +00 +06 +00 +31 +0f +01 +00 +02 +00 +00 +00 +06 +00 +35 +0f +01 +00 +02 +00 +00 +00 +06 +00 +39 +0f +01 +00 +02 +00 +00 +00 +06 +00 +3d +0f +01 +00 +02 +00 +00 +00 +06 +00 +41 +0f +01 +00 +02 +00 +00 +00 +06 +00 +45 +0f +01 +00 +02 +00 +00 +00 +06 +00 +49 +0f +01 +00 +02 +00 +00 +00 +06 +00 +4d +0f +01 +00 +02 +00 +00 +00 +06 +00 +51 +0f +01 +00 +02 +00 +00 +00 +06 +00 +55 +0f +01 +00 +02 +00 +00 +00 +06 +00 +59 +0f +01 +00 +02 +00 +00 +00 +06 +00 +5d +0f +01 +00 +02 +00 +00 +00 +06 +00 +61 +0f +01 +00 +02 +00 +00 +00 +06 +00 +65 +0f +01 +00 +02 +00 +00 +00 +06 +00 +69 +0f +01 +00 +02 +00 +00 +00 +06 +00 +6d +0f +01 +00 +02 +00 +00 +00 +06 +00 +71 +0f +01 +00 +02 +00 +00 +00 +06 +00 +75 +0f +01 +00 +02 +00 +00 +00 +06 +00 +79 +0f +01 +00 +02 +00 +00 +00 +06 +00 +7d +0f +01 +00 +02 +00 +00 +00 +06 +00 +81 +0f +01 +00 +02 +00 +00 +00 +06 +00 +85 +0f +01 +00 +02 +00 +00 +00 +06 +00 +89 +0f +01 +00 +02 +00 +00 +00 +06 +00 +8d +0f +01 +00 +02 +00 +00 +00 +06 +00 +91 +0f +01 +00 +02 +00 +00 +00 +06 +00 +95 +0f +01 +00 +02 +00 +00 +00 +06 +00 +99 +0f +01 +00 +02 +00 +00 +00 +06 +00 +9d +0f +01 +00 +02 +00 +00 +00 +06 +00 +a1 +0f +01 +00 +02 +00 +00 +00 +06 +00 +a5 +0f +01 +00 +02 +00 +00 +00 +06 +00 +a9 +0f +01 +00 +02 +00 +00 +00 +06 +00 +ad +0f +01 +00 +02 +00 +00 +00 +06 +00 +b1 +0f +01 +00 +02 +00 +00 +00 +06 +00 +b5 +0f +01 +00 +02 +00 +00 +00 +06 +00 +b9 +0f +01 +00 +02 +00 +00 +00 +06 +00 +bd +0f +01 +00 +02 +00 +00 +00 +06 +00 +c1 +0f +01 +00 +02 +00 +00 +00 +06 +00 +c5 +0f +01 +00 +02 +00 +00 +00 +06 +00 +c9 +0f +01 +00 +02 +00 +00 +00 +06 +00 +cd +0f +01 +00 +02 +00 +00 +00 +06 +00 +d1 +0f +01 +00 +02 +00 +00 +00 +06 +00 +d5 +0f +01 +00 +02 +00 +00 +00 +06 +00 +d9 +0f +01 +00 +02 +00 +00 +00 +06 +00 +dd +0f +01 +00 +02 +00 +00 +00 +06 +00 +e1 +0f +01 +00 +02 +00 +00 +00 +06 +00 +e5 +0f +01 +00 +02 +00 +00 +00 +06 +00 +e9 +0f +01 +00 +02 +00 +00 +00 +06 +00 +ed +0f +01 +00 +02 +00 +00 +00 +06 +00 +f1 +0f +01 +00 +02 +00 +00 +00 +06 +00 +f5 +0f +01 +00 +02 +00 +00 +00 +06 +00 +f9 +0f +01 +00 +02 +00 +00 +00 +06 +00 +fd +0f +01 +00 +02 +00 +00 +00 +06 +00 +01 10 -37 -00 +01 00 02 00 @@ -85179,9 +87619,2559 @@ fc 00 06 00 +05 +10 +01 +00 +02 +00 +00 +00 +06 +00 +09 +10 +01 +00 +02 +00 +00 +00 +06 +00 +0d +10 +01 +00 +02 +00 +00 +00 +06 +00 +11 +10 +01 +00 +02 +00 +00 +00 +06 +00 +15 +10 +01 +00 +02 +00 +00 +00 +06 +00 +19 +10 +01 +00 +02 +00 +00 +00 +06 +00 +1d +10 +01 +00 +02 +00 +00 +00 +06 +00 +21 +10 +01 +00 +02 +00 +00 +00 +06 +00 +25 +10 +01 +00 +02 +00 +00 +00 +06 +00 +29 +10 +01 +00 +02 +00 +00 +00 +06 +00 +2d +10 +01 +00 +02 +00 +00 +00 +06 +00 +31 +10 +01 +00 +02 +00 +00 +00 +06 +00 +35 +10 +01 +00 +02 +00 +00 +00 +06 +00 +39 +10 +01 +00 +02 +00 +00 +00 +06 +00 +3d +10 +01 +00 +02 +00 +00 +00 +06 +00 +41 +10 +01 +00 +02 +00 +00 +00 +06 +00 +45 +10 +01 +00 +02 +00 +00 +00 +06 +00 +49 +10 +01 +00 +02 +00 +00 +00 +06 +00 +4d +10 +01 +00 +02 +00 +00 +00 +06 +00 +51 +10 +01 +00 +02 +00 +00 +00 +06 +00 +55 +10 +01 +00 +02 +00 +00 +00 +06 +00 +59 +10 +01 +00 +02 +00 +00 +00 +06 +00 +5d +10 +01 +00 +02 +00 +00 +00 +06 +00 +61 +10 +01 +00 +02 +00 +00 +00 +06 +00 +65 +10 +01 +00 +02 +00 +00 +00 +06 +00 +69 +10 +01 +00 +02 +00 +00 +00 +06 +00 +6d +10 +01 +00 +02 +00 +00 +00 +06 +00 +71 +10 +01 +00 +02 +00 +00 +00 +06 +00 +75 +10 +01 +00 +02 +00 +00 +00 +06 +00 +79 +10 +01 +00 +02 +00 +00 +00 +06 +00 +7d +10 +01 +00 +02 +00 +00 +00 +06 +00 +81 +10 +01 +00 +02 +00 +00 +00 +06 +00 +85 +10 +01 +00 +02 +00 +00 +00 +06 +00 +89 +10 +01 +00 +02 +00 +00 +00 +06 +00 +8d +10 +01 +00 +02 +00 +00 +00 +06 +00 +91 +10 +01 +00 +02 +00 +00 +00 +06 +00 +95 +10 +01 +00 +02 +00 +00 +00 +06 +00 +99 +10 +01 +00 +02 +00 +00 +00 +06 +00 +9d +10 +01 +00 +02 +00 +00 +00 +06 +00 +a1 +10 +01 +00 +02 +00 +00 +00 +06 +00 +a5 +10 +01 +00 +02 +00 +00 +00 +06 +00 +a9 +10 +01 +00 +02 +00 +00 +00 +06 +00 +ad +10 +01 +00 +02 +00 +00 +00 +06 +00 +b1 +10 +01 +00 +02 +00 +00 +00 +06 +00 +b5 +10 +01 +00 +02 +00 +00 +00 +06 +00 +b9 +10 +01 +00 +02 +00 +00 +00 +06 +00 +bd +10 +01 +00 +02 +00 +00 +00 +06 +00 +c1 +10 +01 +00 +02 +00 +00 +00 +06 +00 +c5 +10 +01 +00 +02 +00 +00 +00 +06 +00 +c9 +10 +01 +00 +02 +00 +00 +00 +06 +00 +cd +10 +01 +00 +02 +00 +00 +00 +06 +00 +d1 +10 +01 +00 +02 +00 +00 +00 +06 +00 +d5 +10 +01 +00 +02 +00 +00 +00 +06 +00 +d9 +10 +01 +00 +02 +00 +00 +00 +06 +00 +dd +10 +01 +00 +02 +00 +00 +00 +06 +00 +e1 +10 +01 +00 +02 +00 +00 +00 +06 +00 +e5 +10 +01 +00 +02 +00 +00 +00 +06 +00 +e9 +10 +01 +00 +02 +00 +00 +00 +06 +00 +ed +10 +01 +00 +02 +00 +00 +00 +06 +00 +f1 +10 +01 +00 +02 +00 +00 +00 +06 +00 +f5 +10 +01 +00 +02 +00 +00 +00 +06 +00 +f9 +10 +01 +00 +02 +00 +00 +00 +06 +00 +fd +10 +01 +00 +02 +00 +00 +00 +06 +00 +01 +11 +01 +00 +02 +00 +00 +00 +06 +00 +05 +11 +01 +00 +02 +00 +00 +00 +06 +00 +09 +11 +01 +00 +02 +00 +00 +00 +06 +00 +0d +11 +01 +00 +02 +00 +00 +00 +06 +00 +11 +11 +01 +00 +02 +00 +00 +00 +06 +00 +15 +11 +01 +00 +02 +00 +00 +00 +06 +00 +19 +11 +01 +00 +02 +00 +00 +00 +06 +00 +1d +11 +01 +00 +02 +00 +00 +00 +06 +00 +21 +11 +01 +00 +02 +00 +00 +00 +06 +00 +25 +11 +01 +00 +02 +00 +00 +00 +06 +00 +29 +11 +01 +00 +02 +00 +00 +00 +06 +00 +2d +11 +01 +00 +02 +00 +00 +00 +06 +00 +31 +11 +01 +00 +02 +00 +00 +00 +06 +00 +35 +11 +01 +00 +02 +00 +00 +00 +06 +00 +39 +11 +01 +00 +02 +00 +00 +00 +06 +00 +3d +11 +01 +00 +02 +00 +00 +00 +06 +00 +41 +11 +01 +00 +02 +00 +00 +00 +06 +00 +45 +11 +01 +00 +02 +00 +00 +00 +06 +00 +49 +11 +01 +00 +02 +00 +00 +00 +06 +00 +4d +11 +01 +00 +02 +00 +00 +00 +06 +00 +51 +11 +01 +00 +02 +00 +00 +00 +06 +00 +55 +11 +01 +00 +02 +00 +00 +00 +06 +00 +59 +11 +01 +00 +02 +00 +00 +00 +06 +00 +5d +11 +01 +00 +02 +00 +00 +00 +06 +00 +61 +11 +01 +00 +02 +00 +00 +00 +06 +00 +65 +11 +01 +00 +02 +00 +00 +00 +06 +00 +69 +11 +01 +00 +02 +00 +00 +00 +06 +00 +6d +11 +01 +00 +02 +00 +00 +00 +06 +00 +71 +11 +01 +00 +02 +00 +00 +00 +06 +00 +75 +11 +01 +00 +02 +00 +00 +00 +06 +00 +79 +11 +01 +00 +02 +00 +00 +00 +06 +00 +7d +11 +01 +00 +02 +00 +00 +00 +06 +00 +81 +11 +01 +00 +02 +00 +00 +00 +06 +00 +85 +11 +01 +00 +02 +00 +00 +00 +06 +00 +89 +11 +01 +00 +02 +00 +00 +00 +06 +00 +8d +11 +01 +00 +02 +00 +00 +00 +06 +00 +91 +11 +01 +00 +02 +00 +00 +00 +06 +00 +95 +11 +01 +00 +02 +00 +00 +00 +06 +00 +99 +11 +01 +00 +02 +00 +00 +00 +06 +00 +9d +11 +01 +00 +02 +00 +00 +00 +06 +00 +a1 +11 +01 +00 +02 +00 +00 +00 +06 +00 +a5 +11 +01 +00 +02 +00 +00 +00 +06 +00 +a9 +11 +01 +00 +02 +00 +00 +00 +06 +00 +ad +11 +01 +00 +02 +00 +00 +00 +06 +00 +b1 +11 +01 +00 +02 +00 +00 +00 +06 +00 +b5 +11 +01 +00 +02 +00 +00 +00 +06 +00 +b9 +11 +01 +00 +02 +00 +00 +00 +06 +00 +bd +11 +01 +00 +02 +00 +00 +00 +06 +00 +c1 +11 +01 +00 +02 +00 +00 +00 +06 +00 +c5 +11 +01 +00 +02 +00 +00 +00 +06 +00 +c9 +11 +01 +00 +02 +00 +00 +00 +06 +00 +cd +11 +01 +00 +02 +00 +00 +00 +06 +00 +d1 +11 +01 +00 +02 +00 +00 +00 +06 +00 +d5 +11 +01 +00 +02 +00 +00 +00 +06 +00 +d9 +11 +01 +00 +02 +00 +00 +00 +06 +00 +dd +11 +01 +00 +02 +00 +00 +00 +06 +00 +e1 +11 +01 +00 +02 +00 +00 +00 +06 +00 +e5 +11 +01 +00 +02 +00 +00 +00 +06 +00 +e9 +11 +01 +00 +02 +00 +00 +00 +06 +00 +ed +11 +01 +00 +02 +00 +00 +00 +06 +00 +f1 +11 +01 +00 +02 +00 +00 +00 +06 +00 +f5 +11 +01 +00 +02 +00 +00 +00 +06 +00 +f9 +11 +01 +00 +02 +00 +00 +00 +06 +00 +fd +11 +01 +00 +02 +00 +00 +00 +06 +00 +01 +12 +01 +00 +02 +00 +00 +00 +06 +00 +05 +12 +01 +00 +02 +00 +00 +00 +06 +00 +09 +12 +01 +00 +02 +00 +00 +00 +06 +00 +0d +12 +01 +00 +02 +00 +00 +00 +06 +00 +11 +12 +01 +00 +02 +00 +00 +00 +06 +00 +15 +12 +01 +00 +02 +00 +00 +00 +06 +00 +19 +12 +01 +00 +02 +00 +00 +00 +06 +00 +1d +12 +01 +00 +02 +00 +00 +00 +06 +00 +21 +12 +01 +00 +02 +00 +00 +00 +06 +00 +25 +12 +01 +00 +02 +00 +00 +00 +06 +00 +29 +12 +01 +00 +02 +00 +00 +00 +06 +00 +2d +12 +01 +00 +02 +00 +00 +00 +06 +00 +31 +12 +01 +00 +02 +00 +00 +00 +06 +00 +35 +12 +01 +00 +02 +00 +00 +00 +06 +00 +39 +12 +01 +00 +02 +00 +00 +00 +06 +00 +3d +12 +01 +00 +02 +00 +00 +00 +06 +00 +41 +12 +01 +00 +02 +00 +00 +00 +06 +00 +45 +12 +01 +00 +02 +00 +00 +00 +06 +00 +49 +12 +01 +00 +02 +00 +00 +00 +06 +00 +4d +12 +01 +00 +02 +00 +00 +00 +06 +00 +51 +12 +01 +00 +02 +00 +00 +00 +06 +00 +55 +12 +01 +00 +02 +00 +00 +00 +06 +00 +59 +12 +01 +00 +02 +00 +00 +00 +06 +00 +5d +12 +01 +00 +02 +00 +00 +00 +06 +00 +61 +12 +01 +00 +02 +00 +00 +00 +06 +00 +65 +12 +01 +00 +02 +00 +00 +00 +06 +00 +69 +12 +01 +00 +02 +00 +00 +00 +06 +00 +6d +12 +01 +00 +02 +00 +00 +00 +06 +00 +71 +12 +01 +00 +02 +00 +00 +00 +06 +00 +75 +12 +01 +00 +02 +00 +00 +00 +06 +00 +79 +12 +01 +00 +02 +00 +00 +00 +06 +00 +7d +12 +01 +00 +02 +00 +00 +00 +06 +00 +81 +12 +01 +00 +02 +00 +00 +00 +06 +00 +85 +12 +01 +00 +02 +00 +00 +00 +06 +00 +89 +12 +01 +00 +02 +00 +00 +00 +06 +00 +8d +12 +01 +00 +02 +00 +00 +00 +06 +00 +91 +12 +01 +00 +02 +00 +00 +00 +06 +00 +95 +12 +01 +00 +02 +00 +00 +00 +06 +00 +99 +12 +01 +00 +02 +00 +00 +00 +06 +00 +9d +12 +01 +00 +02 +00 +00 +00 +06 +00 +a1 +12 +01 +00 +02 +00 +00 +00 +06 +00 +a5 +12 +01 +00 +02 +00 +00 +00 +06 +00 +a9 +12 +01 +00 +02 +00 +00 +00 +06 +00 +ad +12 +01 +00 +02 +00 +00 +00 +06 +00 +b1 +12 +01 +00 +02 +00 +00 +00 +06 +00 +b5 +12 +01 +00 +02 +00 +00 +00 +06 +00 +b9 +12 +01 +00 +02 +00 +00 +00 +06 +00 +bd +12 +01 +00 +02 +00 +00 +00 +06 +00 +c1 +12 +01 +00 +02 +00 +00 +00 +06 +00 +c5 +12 +01 +00 +02 +00 +00 +00 +06 +00 +c9 +12 +01 +00 +02 +00 +00 +00 +06 +00 +cd +12 +01 +00 +02 +00 +00 +00 +06 +00 +d1 +12 +01 +00 +02 +00 +00 +00 +06 +00 +d5 +12 +01 +00 +02 +00 +00 +00 +06 +00 +d9 +12 +01 +00 +02 +00 +00 +00 +06 +00 +dd +12 +01 +00 +02 +00 +00 +00 +06 +00 +e1 +12 +01 +00 +02 +00 +00 +00 +06 +00 +e5 +12 +01 +00 +02 +00 +00 +00 +06 +00 +e9 +12 +01 +00 +02 +00 +00 +00 +06 +00 +ed +12 +01 +00 +02 +00 +00 +00 +06 +00 +f1 +12 +01 +00 +02 +00 +00 +00 +06 +00 +f5 +12 +01 +00 +02 +00 +00 +00 +06 +00 +f9 +12 +01 +00 +02 +00 +00 +00 +06 +00 +fd +12 +01 +00 +02 +00 +00 +00 +06 +00 +01 +13 +01 +00 +02 +00 +00 +00 +06 +00 +05 +13 +01 +00 +02 +00 +00 +00 +06 +00 +09 +13 +01 +00 +02 +00 +00 +00 +06 +00 +0d +13 +01 +00 +02 +00 +00 +00 +06 +00 +11 +13 +01 +00 +02 +00 +00 +00 +06 +00 +15 +13 +01 +00 +02 +00 +00 +00 +06 +00 +19 +13 +01 +00 +02 +00 +00 +00 +06 +00 +1d +13 +01 +00 +02 +00 +00 +00 +06 +00 +21 +13 +01 +00 +02 +00 +00 +00 +06 +00 +25 +13 +01 +00 +02 +00 +00 +00 +06 +00 +29 +13 +01 +00 +02 +00 +00 +00 +06 +00 +2d +13 +01 +00 +02 +00 +00 +00 +06 +00 +31 +13 +01 +00 +02 +00 +00 +00 +06 +00 +35 +13 +01 +00 +02 +00 +00 +00 +06 +00 +39 +13 +01 +00 +02 +00 +00 +00 +06 +00 +3d +13 +01 +00 +02 +00 +00 +00 +06 +00 +41 +13 +01 +00 +02 +00 +00 +00 +06 +00 +45 +13 +01 +00 +02 +00 +00 +00 +06 +00 +49 +13 +01 +00 +02 +00 +00 +00 +06 +00 +4d +13 +01 +00 +02 +00 +00 +00 +06 +00 +51 +13 +01 +00 +02 +00 +00 +00 +06 +00 +55 +13 +01 +00 +02 +00 +00 +00 +06 +00 +59 +13 +01 +00 +02 +00 +00 +00 +06 +00 +5d +13 +01 +00 +02 +00 +00 +00 +06 +00 +61 +13 +01 +00 +02 +00 +00 +00 +06 +00 +65 +13 +01 +00 +02 +00 +00 +00 +06 +00 +69 +13 +01 +00 +02 +00 +00 +00 +06 +00 +6d +13 +01 +00 +02 +00 +00 +00 +06 +00 +71 +13 +01 +00 +02 +00 +00 +00 +06 +00 +75 +13 +01 +00 +02 +00 +00 +00 +06 +00 +79 +13 +01 +00 +02 +00 +00 +00 +06 +00 +7d +13 +01 +00 +02 +00 +00 +00 +06 +00 +81 +13 +01 +00 +02 +00 +00 +00 +06 +00 +85 +13 +01 +00 +02 +00 +00 +00 +06 +00 +89 +13 +01 +00 +02 +00 +00 +00 +06 +00 +8d +13 +01 +00 +02 +00 +00 +00 +06 +00 +91 +13 +01 +00 +02 +00 +00 +00 +06 +00 +95 +13 +01 +00 +02 +00 +00 +00 +06 +00 +99 +13 +01 +00 +02 +00 +00 +00 +06 +00 +9d +13 +01 +00 +02 +00 +00 +00 +06 +00 +a1 +13 +01 +00 +02 +00 +00 +00 +06 +00 +a5 +13 +01 +00 +02 +00 +00 +00 +06 +00 +a9 +13 +01 +00 +02 +00 +00 +00 +06 +00 +ad +13 +01 +00 +02 +00 +00 +00 +06 +00 +b1 +13 +01 +00 +02 +00 +00 +00 +06 +00 +b5 +13 +01 +00 +02 +00 +00 +00 +06 +00 +b9 +13 +01 +00 +02 +00 +00 +00 +06 +00 +bd +13 +01 +00 +02 +00 +00 +00 +06 +00 +c1 +13 +01 +00 +02 +00 +00 +00 +06 +00 +c5 +13 +01 +00 +02 +00 +00 +00 +06 +00 +c9 +13 +01 +00 +02 +00 +00 +00 +06 +00 +cd +13 +01 +00 +02 +00 +00 +00 +06 +00 +d1 +13 +01 +00 +02 +00 +00 +00 +06 +00 +d5 +13 +01 +00 +02 +00 +00 +00 +06 +00 +d9 +13 +01 +00 +02 +00 +00 +00 +06 +00 +dd +13 +01 +00 +02 +00 +00 +00 +06 +00 +e1 +13 +01 +00 +02 +00 +00 +00 +06 +00 +e5 +13 +01 +00 +02 +00 +00 +00 +06 +00 +e9 +13 +01 +00 +02 +00 +00 +00 +06 +00 +ed +13 +01 +00 +02 +00 +00 +00 +06 +00 +f1 +13 +01 +00 +02 +00 +00 +00 +06 +00 +f5 +13 +01 +00 +02 +00 +00 +00 +06 +00 +f9 +13 +01 +00 +02 +00 +00 +00 +06 +00 +fd +13 +01 +00 +02 +00 +00 +00 +06 +00 +01 14 -37 -00 +01 00 02 00 @@ -85189,9 +90179,2559 @@ fc 00 06 00 +05 +14 +01 +00 +02 +00 +00 +00 +06 +00 +09 +14 +01 +00 +02 +00 +00 +00 +06 +00 +0d +14 +01 +00 +02 +00 +00 +00 +06 +00 +11 +14 +01 +00 +02 +00 +00 +00 +06 +00 +15 +14 +01 +00 +02 +00 +00 +00 +06 +00 +19 +14 +01 +00 +02 +00 +00 +00 +06 +00 +1d +14 +01 +00 +02 +00 +00 +00 +06 +00 +21 +14 +01 +00 +02 +00 +00 +00 +06 +00 +25 +14 +01 +00 +02 +00 +00 +00 +06 +00 +29 +14 +01 +00 +02 +00 +00 +00 +06 +00 +2d +14 +01 +00 +02 +00 +00 +00 +06 +00 +31 +14 +01 +00 +02 +00 +00 +00 +06 +00 +35 +14 +01 +00 +02 +00 +00 +00 +06 +00 +39 +14 +01 +00 +02 +00 +00 +00 +06 +00 +3d +14 +01 +00 +02 +00 +00 +00 +06 +00 +41 +14 +01 +00 +02 +00 +00 +00 +06 +00 +45 +14 +01 +00 +02 +00 +00 +00 +06 +00 +49 +14 +01 +00 +02 +00 +00 +00 +06 +00 +4d +14 +01 +00 +02 +00 +00 +00 +06 +00 +51 +14 +01 +00 +02 +00 +00 +00 +06 +00 +55 +14 +01 +00 +02 +00 +00 +00 +06 +00 +59 +14 +01 +00 +02 +00 +00 +00 +06 +00 +5d +14 +01 +00 +02 +00 +00 +00 +06 +00 +61 +14 +01 +00 +02 +00 +00 +00 +06 +00 +65 +14 +01 +00 +02 +00 +00 +00 +06 +00 +69 +14 +01 +00 +02 +00 +00 +00 +06 +00 +6d +14 +01 +00 +02 +00 +00 +00 +06 +00 +71 +14 +01 +00 +02 +00 +00 +00 +06 +00 +75 +14 +01 +00 +02 +00 +00 +00 +06 +00 +79 +14 +01 +00 +02 +00 +00 +00 +06 +00 +7d +14 +01 +00 +02 +00 +00 +00 +06 +00 +81 +14 +01 +00 +02 +00 +00 +00 +06 +00 +85 +14 +01 +00 +02 +00 +00 +00 +06 +00 +89 +14 +01 +00 +02 +00 +00 +00 +06 +00 +8d +14 +01 +00 +02 +00 +00 +00 +06 +00 +91 +14 +01 +00 +02 +00 +00 +00 +06 +00 +95 +14 +01 +00 +02 +00 +00 +00 +06 +00 +99 +14 +01 +00 +02 +00 +00 +00 +06 +00 +9d +14 +01 +00 +02 +00 +00 +00 +06 +00 +a1 +14 +01 +00 +02 +00 +00 +00 +06 +00 +a5 +14 +01 +00 +02 +00 +00 +00 +06 +00 +a9 +14 +01 +00 +02 +00 +00 +00 +06 +00 +ad +14 +01 +00 +02 +00 +00 +00 +06 +00 +b1 +14 +01 +00 +02 +00 +00 +00 +06 +00 +b5 +14 +01 +00 +02 +00 +00 +00 +06 +00 +b9 +14 +01 +00 +02 +00 +00 +00 +06 +00 +bd +14 +01 +00 +02 +00 +00 +00 +06 +00 +c1 +14 +01 +00 +02 +00 +00 +00 +06 +00 +c5 +14 +01 +00 +02 +00 +00 +00 +06 +00 +c9 +14 +01 +00 +02 +00 +00 +00 +06 +00 +cd +14 +01 +00 +02 +00 +00 +00 +06 +00 +d1 +14 +01 +00 +02 +00 +00 +00 +06 +00 +d5 +14 +01 +00 +02 +00 +00 +00 +06 +00 +d9 +14 +01 +00 +02 +00 +00 +00 +06 +00 +dd +14 +01 +00 +02 +00 +00 +00 +06 +00 +e1 +14 +01 +00 +02 +00 +00 +00 +06 +00 +e5 +14 +01 +00 +02 +00 +00 +00 +06 +00 +e9 +14 +01 +00 +02 +00 +00 +00 +06 +00 +ed +14 +01 +00 +02 +00 +00 +00 +06 +00 +f1 +14 +01 +00 +02 +00 +00 +00 +06 +00 +f5 +14 +01 +00 +02 +00 +00 +00 +06 +00 +f9 +14 +01 +00 +02 +00 +00 +00 +06 +00 +fd +14 +01 +00 +02 +00 +00 +00 +06 +00 +01 +15 +01 +00 +02 +00 +00 +00 +06 +00 +05 +15 +01 +00 +02 +00 +00 +00 +06 +00 +09 +15 +01 +00 +02 +00 +00 +00 +06 +00 +0d +15 +01 +00 +02 +00 +00 +00 +06 +00 +11 +15 +01 +00 +02 +00 +00 +00 +06 +00 +15 +15 +01 +00 +02 +00 +00 +00 +06 +00 +19 +15 +01 +00 +02 +00 +00 +00 +06 +00 +1d +15 +01 +00 +02 +00 +00 +00 +06 +00 +21 +15 +01 +00 +02 +00 +00 +00 +06 +00 +25 +15 +01 +00 +02 +00 +00 +00 +06 +00 +29 +15 +01 +00 +02 +00 +00 +00 +06 +00 +2d +15 +01 +00 +02 +00 +00 +00 +06 +00 +31 +15 +01 +00 +02 +00 +00 +00 +06 +00 +35 +15 +01 +00 +02 +00 +00 +00 +06 +00 +39 +15 +01 +00 +02 +00 +00 +00 +06 +00 +3d +15 +01 +00 +02 +00 +00 +00 +06 +00 +41 +15 +01 +00 +02 +00 +00 +00 +06 +00 +45 +15 +01 +00 +02 +00 +00 +00 +06 +00 +49 +15 +01 +00 +02 +00 +00 +00 +06 +00 +4d +15 +01 +00 +02 +00 +00 +00 +06 +00 +51 +15 +01 +00 +02 +00 +00 +00 +06 +00 +55 +15 +01 +00 +02 +00 +00 +00 +06 +00 +59 +15 +01 +00 +02 +00 +00 +00 +06 +00 +5d +15 +01 +00 +02 +00 +00 +00 +06 +00 +61 +15 +01 +00 +02 +00 +00 +00 +06 +00 +65 +15 +01 +00 +02 +00 +00 +00 +06 +00 +69 +15 +01 +00 +02 +00 +00 +00 +06 +00 +6d +15 +01 +00 +02 +00 +00 +00 +06 +00 +71 +15 +01 +00 +02 +00 +00 +00 +06 +00 +75 +15 +01 +00 +02 +00 +00 +00 +06 +00 +79 +15 +01 +00 +02 +00 +00 +00 +06 +00 +7d +15 +01 +00 +02 +00 +00 +00 +06 +00 +81 +15 +01 +00 +02 +00 +00 +00 +06 +00 +85 +15 +01 +00 +02 +00 +00 +00 +06 +00 +89 +15 +01 +00 +02 +00 +00 +00 +06 +00 +8d +15 +01 +00 +02 +00 +00 +00 +06 +00 +91 +15 +01 +00 +02 +00 +00 +00 +06 +00 +95 +15 +01 +00 +02 +00 +00 +00 +06 +00 +99 +15 +01 +00 +02 +00 +00 +00 +06 +00 +9d +15 +01 +00 +02 +00 +00 +00 +06 +00 +a1 +15 +01 +00 +02 +00 +00 +00 +06 +00 +a5 +15 +01 +00 +02 +00 +00 +00 +06 +00 +a9 +15 +01 +00 +02 +00 +00 +00 +06 +00 +ad +15 +01 +00 +02 +00 +00 +00 +06 +00 +b1 +15 +01 +00 +02 +00 +00 +00 +06 +00 +b5 +15 +01 +00 +02 +00 +00 +00 +06 +00 +b9 +15 +01 +00 +02 +00 +00 +00 +06 +00 +bd +15 +01 +00 +02 +00 +00 +00 +06 +00 +c1 +15 +01 +00 +02 +00 +00 +00 +06 +00 +c5 +15 +01 +00 +02 +00 +00 +00 +06 +00 +c9 +15 +01 +00 +02 +00 +00 +00 +06 +00 +cd +15 +01 +00 +02 +00 +00 +00 +06 +00 +d1 +15 +01 +00 +02 +00 +00 +00 +06 +00 +d5 +15 +01 +00 +02 +00 +00 +00 +06 +00 +d9 +15 +01 +00 +02 +00 +00 +00 +06 +00 +dd +15 +01 +00 +02 +00 +00 +00 +06 +00 +e1 +15 +01 +00 +02 +00 +00 +00 +06 +00 +e5 +15 +01 +00 +02 +00 +00 +00 +06 +00 +e9 +15 +01 +00 +02 +00 +00 +00 +06 +00 +ed +15 +01 +00 +02 +00 +00 +00 +06 +00 +f1 +15 +01 +00 +02 +00 +00 +00 +06 +00 +f5 +15 +01 +00 +02 +00 +00 +00 +06 +00 +f9 +15 +01 +00 +02 +00 +00 +00 +06 +00 +fd +15 +01 +00 +02 +00 +00 +00 +06 +00 +01 +16 +01 +00 +02 +00 +00 +00 +06 +00 +05 +16 +01 +00 +02 +00 +00 +00 +06 +00 +09 +16 +01 +00 +02 +00 +00 +00 +06 +00 +0d +16 +01 +00 +02 +00 +00 +00 +06 +00 +11 +16 +01 +00 +02 +00 +00 +00 +06 +00 +15 +16 +01 +00 +02 +00 +00 +00 +06 +00 +19 +16 +01 +00 +02 +00 +00 +00 +06 +00 +1d +16 +01 +00 +02 +00 +00 +00 +06 +00 +21 +16 +01 +00 +02 +00 +00 +00 +06 +00 +25 +16 +01 +00 +02 +00 +00 +00 +06 +00 +29 +16 +01 +00 +02 +00 +00 +00 +06 +00 +2d +16 +01 +00 +02 +00 +00 +00 +06 +00 +31 +16 +01 +00 +02 +00 +00 +00 +06 +00 +35 +16 +01 +00 +02 +00 +00 +00 +06 +00 +39 +16 +01 +00 +02 +00 +00 +00 +06 +00 +3d +16 +01 +00 +02 +00 +00 +00 +06 +00 +41 +16 +01 +00 +02 +00 +00 +00 +06 +00 +45 +16 +01 +00 +02 +00 +00 +00 +06 +00 +49 +16 +01 +00 +02 +00 +00 +00 +06 +00 +4d +16 +01 +00 +02 +00 +00 +00 +06 +00 +51 +16 +01 +00 +02 +00 +00 +00 +06 +00 +55 +16 +01 +00 +02 +00 +00 +00 +06 +00 +59 +16 +01 +00 +02 +00 +00 +00 +06 +00 +5d +16 +01 +00 +02 +00 +00 +00 +06 +00 +61 +16 +01 +00 +02 +00 +00 +00 +06 +00 +65 +16 +01 +00 +02 +00 +00 +00 +06 +00 +69 +16 +01 +00 +02 +00 +00 +00 +06 +00 +6d +16 +01 +00 +02 +00 +00 +00 +06 +00 +71 +16 +01 +00 +02 +00 +00 +00 +06 +00 +75 +16 +01 +00 +02 +00 +00 +00 +06 +00 +79 +16 +01 +00 +02 +00 +00 +00 +06 +00 +7d +16 +01 +00 +02 +00 +00 +00 +06 +00 +81 +16 +01 +00 +02 +00 +00 +00 +06 +00 +85 +16 +01 +00 +02 +00 +00 +00 +06 +00 +89 +16 +01 +00 +02 +00 +00 +00 +06 +00 +8d +16 +01 +00 +02 +00 +00 +00 +06 +00 +91 +16 +01 +00 +02 +00 +00 +00 +06 +00 +95 +16 +01 +00 +02 +00 +00 +00 +06 +00 +99 +16 +01 +00 +02 +00 +00 +00 +06 +00 +9d +16 +01 +00 +02 +00 +00 +00 +06 +00 +a1 +16 +01 +00 +02 +00 +00 +00 +06 +00 +a5 +16 +01 +00 +02 +00 +00 +00 +06 +00 +a9 +16 +01 +00 +02 +00 +00 +00 +06 +00 +ad +16 +01 +00 +02 +00 +00 +00 +06 +00 +b1 +16 +01 +00 +02 +00 +00 +00 +06 +00 +b5 +16 +01 +00 +02 +00 +00 +00 +06 +00 +b9 +16 +01 +00 +02 +00 +00 +00 +06 +00 +bd +16 +01 +00 +02 +00 +00 +00 +06 +00 +c1 +16 +01 +00 +02 +00 +00 +00 +06 +00 +c5 +16 +01 +00 +02 +00 +00 +00 +06 +00 +c9 +16 +01 +00 +02 +00 +00 +00 +06 +00 +cd +16 +01 +00 +02 +00 +00 +00 +06 +00 +d1 +16 +01 +00 +02 +00 +00 +00 +06 +00 +d5 +16 +01 +00 +02 +00 +00 +00 +06 +00 +d9 +16 +01 +00 +02 +00 +00 +00 +06 +00 +dd +16 +01 +00 +02 +00 +00 +00 +06 +00 +e1 +16 +01 +00 +02 +00 +00 +00 +06 +00 +e5 +16 +01 +00 +02 +00 +00 +00 +06 +00 +e9 +16 +01 +00 +02 +00 +00 +00 +06 +00 +ed +16 +01 +00 +02 +00 +00 +00 +06 +00 +f1 +16 +01 +00 +02 +00 +00 +00 +06 +00 +f5 +16 +01 +00 +02 +00 +00 +00 +06 +00 +f9 +16 +01 +00 +02 +00 +00 +00 +06 +00 +fd +16 +01 +00 +02 +00 +00 +00 +06 +00 +01 +17 +01 +00 +02 +00 +00 +00 +06 +00 +05 +17 +01 +00 +02 +00 +00 +00 +06 +00 +09 +17 +01 +00 +02 +00 +00 +00 +06 +00 +0d +17 +01 +00 +02 +00 +00 +00 +06 +00 +11 +17 +01 +00 +02 +00 +00 +00 +06 +00 +15 +17 +01 +00 +02 +00 +00 +00 +06 +00 +19 +17 +01 +00 +02 +00 +00 +00 +06 +00 +1d +17 +01 +00 +02 +00 +00 +00 +06 +00 +21 +17 +01 +00 +02 +00 +00 +00 +06 +00 +25 +17 +01 +00 +02 +00 +00 +00 +06 +00 +29 +17 +01 +00 +02 +00 +00 +00 +06 +00 +2d +17 +01 +00 +02 +00 +00 +00 +06 +00 +31 +17 +01 +00 +02 +00 +00 +00 +06 +00 +35 +17 +01 +00 +02 +00 +00 +00 +06 +00 +39 +17 +01 +00 +02 +00 +00 +00 +06 +00 +3d +17 +01 +00 +02 +00 +00 +00 +06 +00 +41 +17 +01 +00 +02 +00 +00 +00 +06 +00 +45 +17 +01 +00 +02 +00 +00 +00 +06 +00 +49 +17 +01 +00 +02 +00 +00 +00 +06 +00 +4d +17 +01 +00 +02 +00 +00 +00 +06 +00 +51 +17 +01 +00 +02 +00 +00 +00 +06 +00 +55 +17 +01 +00 +02 +00 +00 +00 +06 +00 +59 +17 +01 +00 +02 +00 +00 +00 +06 +00 +5d +17 +01 +00 +02 +00 +00 +00 +06 +00 +61 +17 +01 +00 +02 +00 +00 +00 +06 +00 +65 +17 +01 +00 +02 +00 +00 +00 +06 +00 +69 +17 +01 +00 +02 +00 +00 +00 +06 +00 +6d +17 +01 +00 +02 +00 +00 +00 +06 +00 +71 +17 +01 +00 +02 +00 +00 +00 +06 +00 +75 +17 +01 +00 +02 +00 +00 +00 +06 +00 +79 +17 +01 +00 +02 +00 +00 +00 +06 +00 +7d +17 +01 +00 +02 +00 +00 +00 +06 +00 +81 +17 +01 +00 +02 +00 +00 +00 +06 +00 +85 +17 +01 +00 +02 +00 +00 +00 +06 +00 +89 +17 +01 +00 +02 +00 +00 +00 +06 +00 +8d +17 +01 +00 +02 +00 +00 +00 +06 +00 +91 +17 +01 +00 +02 +00 +00 +00 +06 +00 +95 +17 +01 +00 +02 +00 +00 +00 +06 +00 +99 +17 +01 +00 +02 +00 +00 +00 +06 +00 +9d +17 +01 +00 +02 +00 +00 +00 +06 +00 +a1 +17 +01 +00 +02 +00 +00 +00 +06 +00 +a5 +17 +01 +00 +02 +00 +00 +00 +06 +00 +a9 +17 +01 +00 +02 +00 +00 +00 +06 +00 +ad +17 +01 +00 +02 +00 +00 +00 +06 +00 +b1 +17 +01 +00 +02 +00 +00 +00 +06 +00 +b5 +17 +01 +00 +02 +00 +00 +00 +06 +00 +b9 +17 +01 +00 +02 +00 +00 +00 +06 +00 +bd +17 +01 +00 +02 +00 +00 +00 +06 +00 +c1 +17 +01 +00 +02 +00 +00 +00 +06 +00 +c5 +17 +01 +00 +02 +00 +00 +00 +06 +00 +c9 +17 +01 +00 +02 +00 +00 +00 +06 +00 +cd +17 +01 +00 +02 +00 +00 +00 +06 +00 +d1 +17 +01 +00 +02 +00 +00 +00 +06 +00 +d5 +17 +01 +00 +02 +00 +00 +00 +06 +00 +d9 +17 +01 +00 +02 +00 +00 +00 +06 +00 +dd +17 +01 +00 +02 +00 +00 +00 +06 +00 +e1 +17 +01 +00 +02 +00 +00 +00 +06 +00 +e5 +17 +01 +00 +02 +00 +00 +00 +06 +00 +e9 +17 +01 +00 +02 +00 +00 +00 +06 +00 +ed +17 +01 +00 +02 +00 +00 +00 +06 +00 +f1 +17 +01 +00 +02 +00 +00 +00 +06 +00 +f5 +17 +01 +00 +02 +00 +00 +00 +06 +00 +f9 +17 +01 +00 +02 +00 +00 +00 +06 +00 +fd +17 +01 +00 +02 +00 +00 +00 +06 +00 +01 18 -37 -00 +01 00 02 00 @@ -85199,9 +92739,2559 @@ fc 00 06 00 +05 +18 +01 +00 +02 +00 +00 +00 +06 +00 +09 +18 +01 +00 +02 +00 +00 +00 +06 +00 +0d +18 +01 +00 +02 +00 +00 +00 +06 +00 +11 +18 +01 +00 +02 +00 +00 +00 +06 +00 +15 +18 +01 +00 +02 +00 +00 +00 +06 +00 +19 +18 +01 +00 +02 +00 +00 +00 +06 +00 +1d +18 +01 +00 +02 +00 +00 +00 +06 +00 +21 +18 +01 +00 +02 +00 +00 +00 +06 +00 +25 +18 +01 +00 +02 +00 +00 +00 +06 +00 +29 +18 +01 +00 +02 +00 +00 +00 +06 +00 +2d +18 +01 +00 +02 +00 +00 +00 +06 +00 +31 +18 +01 +00 +02 +00 +00 +00 +06 +00 +35 +18 +01 +00 +02 +00 +00 +00 +06 +00 +39 +18 +01 +00 +02 +00 +00 +00 +06 +00 +3d +18 +01 +00 +02 +00 +00 +00 +06 +00 +41 +18 +01 +00 +02 +00 +00 +00 +06 +00 +45 +18 +01 +00 +02 +00 +00 +00 +06 +00 +49 +18 +01 +00 +02 +00 +00 +00 +06 +00 +4d +18 +01 +00 +02 +00 +00 +00 +06 +00 +51 +18 +01 +00 +02 +00 +00 +00 +06 +00 +55 +18 +01 +00 +02 +00 +00 +00 +06 +00 +59 +18 +01 +00 +02 +00 +00 +00 +06 +00 +5d +18 +01 +00 +02 +00 +00 +00 +06 +00 +61 +18 +01 +00 +02 +00 +00 +00 +06 +00 +65 +18 +01 +00 +02 +00 +00 +00 +06 +00 +69 +18 +01 +00 +02 +00 +00 +00 +06 +00 +6d +18 +01 +00 +02 +00 +00 +00 +06 +00 +71 +18 +01 +00 +02 +00 +00 +00 +06 +00 +75 +18 +01 +00 +02 +00 +00 +00 +06 +00 +79 +18 +01 +00 +02 +00 +00 +00 +06 +00 +7d +18 +01 +00 +02 +00 +00 +00 +06 +00 +81 +18 +01 +00 +02 +00 +00 +00 +06 +00 +85 +18 +01 +00 +02 +00 +00 +00 +06 +00 +89 +18 +01 +00 +02 +00 +00 +00 +06 +00 +8d +18 +01 +00 +02 +00 +00 +00 +06 +00 +91 +18 +01 +00 +02 +00 +00 +00 +06 +00 +95 +18 +01 +00 +02 +00 +00 +00 +06 +00 +99 +18 +01 +00 +02 +00 +00 +00 +06 +00 +9d +18 +01 +00 +02 +00 +00 +00 +06 +00 +a1 +18 +01 +00 +02 +00 +00 +00 +06 +00 +a5 +18 +01 +00 +02 +00 +00 +00 +06 +00 +a9 +18 +01 +00 +02 +00 +00 +00 +06 +00 +ad +18 +01 +00 +02 +00 +00 +00 +06 +00 +b1 +18 +01 +00 +02 +00 +00 +00 +06 +00 +b5 +18 +01 +00 +02 +00 +00 +00 +06 +00 +b9 +18 +01 +00 +02 +00 +00 +00 +06 +00 +bd +18 +01 +00 +02 +00 +00 +00 +06 +00 +c1 +18 +01 +00 +02 +00 +00 +00 +06 +00 +c5 +18 +01 +00 +02 +00 +00 +00 +06 +00 +c9 +18 +01 +00 +02 +00 +00 +00 +06 +00 +cd +18 +01 +00 +02 +00 +00 +00 +06 +00 +d1 +18 +01 +00 +02 +00 +00 +00 +06 +00 +d5 +18 +01 +00 +02 +00 +00 +00 +06 +00 +d9 +18 +01 +00 +02 +00 +00 +00 +06 +00 +dd +18 +01 +00 +02 +00 +00 +00 +06 +00 +e1 +18 +01 +00 +02 +00 +00 +00 +06 +00 +e5 +18 +01 +00 +02 +00 +00 +00 +06 +00 +e9 +18 +01 +00 +02 +00 +00 +00 +06 +00 +ed +18 +01 +00 +02 +00 +00 +00 +06 +00 +f1 +18 +01 +00 +02 +00 +00 +00 +06 +00 +f5 +18 +01 +00 +02 +00 +00 +00 +06 +00 +f9 +18 +01 +00 +02 +00 +00 +00 +06 +00 +fd +18 +01 +00 +02 +00 +00 +00 +06 +00 +01 +19 +01 +00 +02 +00 +00 +00 +06 +00 +05 +19 +01 +00 +02 +00 +00 +00 +06 +00 +09 +19 +01 +00 +02 +00 +00 +00 +06 +00 +0d +19 +01 +00 +02 +00 +00 +00 +06 +00 +11 +19 +01 +00 +02 +00 +00 +00 +06 +00 +15 +19 +01 +00 +02 +00 +00 +00 +06 +00 +19 +19 +01 +00 +02 +00 +00 +00 +06 +00 +1d +19 +01 +00 +02 +00 +00 +00 +06 +00 +21 +19 +01 +00 +02 +00 +00 +00 +06 +00 +25 +19 +01 +00 +02 +00 +00 +00 +06 +00 +29 +19 +01 +00 +02 +00 +00 +00 +06 +00 +2d +19 +01 +00 +02 +00 +00 +00 +06 +00 +31 +19 +01 +00 +02 +00 +00 +00 +06 +00 +35 +19 +01 +00 +02 +00 +00 +00 +06 +00 +39 +19 +01 +00 +02 +00 +00 +00 +06 +00 +3d +19 +01 +00 +02 +00 +00 +00 +06 +00 +41 +19 +01 +00 +02 +00 +00 +00 +06 +00 +45 +19 +01 +00 +02 +00 +00 +00 +06 +00 +49 +19 +01 +00 +02 +00 +00 +00 +06 +00 +4d +19 +01 +00 +02 +00 +00 +00 +06 +00 +51 +19 +01 +00 +02 +00 +00 +00 +06 +00 +55 +19 +01 +00 +02 +00 +00 +00 +06 +00 +59 +19 +01 +00 +02 +00 +00 +00 +06 +00 +5d +19 +01 +00 +02 +00 +00 +00 +06 +00 +61 +19 +01 +00 +02 +00 +00 +00 +06 +00 +65 +19 +01 +00 +02 +00 +00 +00 +06 +00 +69 +19 +01 +00 +02 +00 +00 +00 +06 +00 +6d +19 +01 +00 +02 +00 +00 +00 +06 +00 +71 +19 +01 +00 +02 +00 +00 +00 +06 +00 +75 +19 +01 +00 +02 +00 +00 +00 +06 +00 +79 +19 +01 +00 +02 +00 +00 +00 +06 +00 +7d +19 +01 +00 +02 +00 +00 +00 +06 +00 +81 +19 +01 +00 +02 +00 +00 +00 +06 +00 +85 +19 +01 +00 +02 +00 +00 +00 +06 +00 +89 +19 +01 +00 +02 +00 +00 +00 +06 +00 +8d +19 +01 +00 +02 +00 +00 +00 +06 +00 +91 +19 +01 +00 +02 +00 +00 +00 +06 +00 +95 +19 +01 +00 +02 +00 +00 +00 +06 +00 +99 +19 +01 +00 +02 +00 +00 +00 +06 +00 +9d +19 +01 +00 +02 +00 +00 +00 +06 +00 +a1 +19 +01 +00 +02 +00 +00 +00 +06 +00 +a5 +19 +01 +00 +02 +00 +00 +00 +06 +00 +a9 +19 +01 +00 +02 +00 +00 +00 +06 +00 +ad +19 +01 +00 +02 +00 +00 +00 +06 +00 +b1 +19 +01 +00 +02 +00 +00 +00 +06 +00 +b5 +19 +01 +00 +02 +00 +00 +00 +06 +00 +b9 +19 +01 +00 +02 +00 +00 +00 +06 +00 +bd +19 +01 +00 +02 +00 +00 +00 +06 +00 +c1 +19 +01 +00 +02 +00 +00 +00 +06 +00 +c5 +19 +01 +00 +02 +00 +00 +00 +06 +00 +c9 +19 +01 +00 +02 +00 +00 +00 +06 +00 +cd +19 +01 +00 +02 +00 +00 +00 +06 +00 +d1 +19 +01 +00 +02 +00 +00 +00 +06 +00 +d5 +19 +01 +00 +02 +00 +00 +00 +06 +00 +d9 +19 +01 +00 +02 +00 +00 +00 +06 +00 +dd +19 +01 +00 +02 +00 +00 +00 +06 +00 +e1 +19 +01 +00 +02 +00 +00 +00 +06 +00 +e5 +19 +01 +00 +02 +00 +00 +00 +06 +00 +e9 +19 +01 +00 +02 +00 +00 +00 +06 +00 +ed +19 +01 +00 +02 +00 +00 +00 +06 +00 +f1 +19 +01 +00 +02 +00 +00 +00 +06 +00 +f5 +19 +01 +00 +02 +00 +00 +00 +06 +00 +f9 +19 +01 +00 +02 +00 +00 +00 +06 +00 +fd +19 +01 +00 +02 +00 +00 +00 +06 +00 +01 +1a +01 +00 +02 +00 +00 +00 +06 +00 +05 +1a +01 +00 +02 +00 +00 +00 +06 +00 +09 +1a +01 +00 +02 +00 +00 +00 +06 +00 +0d +1a +01 +00 +02 +00 +00 +00 +06 +00 +11 +1a +01 +00 +02 +00 +00 +00 +06 +00 +15 +1a +01 +00 +02 +00 +00 +00 +06 +00 +19 +1a +01 +00 +02 +00 +00 +00 +06 +00 +1d +1a +01 +00 +02 +00 +00 +00 +06 +00 +21 +1a +01 +00 +02 +00 +00 +00 +06 +00 +25 +1a +01 +00 +02 +00 +00 +00 +06 +00 +29 +1a +01 +00 +02 +00 +00 +00 +06 +00 +2d +1a +01 +00 +02 +00 +00 +00 +06 +00 +31 +1a +01 +00 +02 +00 +00 +00 +06 +00 +35 +1a +01 +00 +02 +00 +00 +00 +06 +00 +39 +1a +01 +00 +02 +00 +00 +00 +06 +00 +3d +1a +01 +00 +02 +00 +00 +00 +06 +00 +41 +1a +01 +00 +02 +00 +00 +00 +06 +00 +45 +1a +01 +00 +02 +00 +00 +00 +06 +00 +49 +1a +01 +00 +02 +00 +00 +00 +06 +00 +4d +1a +01 +00 +02 +00 +00 +00 +06 +00 +51 +1a +01 +00 +02 +00 +00 +00 +06 +00 +55 +1a +01 +00 +02 +00 +00 +00 +06 +00 +59 +1a +01 +00 +02 +00 +00 +00 +06 +00 +5d +1a +01 +00 +02 +00 +00 +00 +06 +00 +61 +1a +01 +00 +02 +00 +00 +00 +06 +00 +65 +1a +01 +00 +02 +00 +00 +00 +06 +00 +69 +1a +01 +00 +02 +00 +00 +00 +06 +00 +6d +1a +01 +00 +02 +00 +00 +00 +06 +00 +71 +1a +01 +00 +02 +00 +00 +00 +06 +00 +75 +1a +01 +00 +02 +00 +00 +00 +06 +00 +79 +1a +01 +00 +02 +00 +00 +00 +06 +00 +7d +1a +01 +00 +02 +00 +00 +00 +06 +00 +81 +1a +01 +00 +02 +00 +00 +00 +06 +00 +85 +1a +01 +00 +02 +00 +00 +00 +06 +00 +89 +1a +01 +00 +02 +00 +00 +00 +06 +00 +8d +1a +01 +00 +02 +00 +00 +00 +06 +00 +91 +1a +01 +00 +02 +00 +00 +00 +06 +00 +95 +1a +01 +00 +02 +00 +00 +00 +06 +00 +99 +1a +01 +00 +02 +00 +00 +00 +06 +00 +9d +1a +01 +00 +02 +00 +00 +00 +06 +00 +a1 +1a +01 +00 +02 +00 +00 +00 +06 +00 +a5 +1a +01 +00 +02 +00 +00 +00 +06 +00 +a9 +1a +01 +00 +02 +00 +00 +00 +06 +00 +ad +1a +01 +00 +02 +00 +00 +00 +06 +00 +b1 +1a +01 +00 +02 +00 +00 +00 +06 +00 +b5 +1a +01 +00 +02 +00 +00 +00 +06 +00 +b9 +1a +01 +00 +02 +00 +00 +00 +06 +00 +bd +1a +01 +00 +02 +00 +00 +00 +06 +00 +c1 +1a +01 +00 +02 +00 +00 +00 +06 +00 +c5 +1a +01 +00 +02 +00 +00 +00 +06 +00 +c9 +1a +01 +00 +02 +00 +00 +00 +06 +00 +cd +1a +01 +00 +02 +00 +00 +00 +06 +00 +d1 +1a +01 +00 +02 +00 +00 +00 +06 +00 +d5 +1a +01 +00 +02 +00 +00 +00 +06 +00 +d9 +1a +01 +00 +02 +00 +00 +00 +06 +00 +dd +1a +01 +00 +02 +00 +00 +00 +06 +00 +e1 +1a +01 +00 +02 +00 +00 +00 +06 +00 +e5 +1a +01 +00 +02 +00 +00 +00 +06 +00 +e9 +1a +01 +00 +02 +00 +00 +00 +06 +00 +ed +1a +01 +00 +02 +00 +00 +00 +06 +00 +f1 +1a +01 +00 +02 +00 +00 +00 +06 +00 +f5 +1a +01 +00 +02 +00 +00 +00 +06 +00 +f9 +1a +01 +00 +02 +00 +00 +00 +06 +00 +fd +1a +01 +00 +02 +00 +00 +00 +06 +00 +01 +1b +01 +00 +02 +00 +00 +00 +06 +00 +05 +1b +01 +00 +02 +00 +00 +00 +06 +00 +09 +1b +01 +00 +02 +00 +00 +00 +06 +00 +0d +1b +01 +00 +02 +00 +00 +00 +06 +00 +11 +1b +01 +00 +02 +00 +00 +00 +06 +00 +15 +1b +01 +00 +02 +00 +00 +00 +06 +00 +19 +1b +01 +00 +02 +00 +00 +00 +06 +00 +1d +1b +01 +00 +02 +00 +00 +00 +06 +00 +21 +1b +01 +00 +02 +00 +00 +00 +06 +00 +25 +1b +01 +00 +02 +00 +00 +00 +06 +00 +29 +1b +01 +00 +02 +00 +00 +00 +06 +00 +2d +1b +01 +00 +02 +00 +00 +00 +06 +00 +31 +1b +01 +00 +02 +00 +00 +00 +06 +00 +35 +1b +01 +00 +02 +00 +00 +00 +06 +00 +39 +1b +01 +00 +02 +00 +00 +00 +06 +00 +3d +1b +01 +00 +02 +00 +00 +00 +06 +00 +41 +1b +01 +00 +02 +00 +00 +00 +06 +00 +45 +1b +01 +00 +02 +00 +00 +00 +06 +00 +49 +1b +01 +00 +02 +00 +00 +00 +06 +00 +4d +1b +01 +00 +02 +00 +00 +00 +06 +00 +51 +1b +01 +00 +02 +00 +00 +00 +06 +00 +55 +1b +01 +00 +02 +00 +00 +00 +06 +00 +59 +1b +01 +00 +02 +00 +00 +00 +06 +00 +5d +1b +01 +00 +02 +00 +00 +00 +06 +00 +61 +1b +01 +00 +02 +00 +00 +00 +06 +00 +65 +1b +01 +00 +02 +00 +00 +00 +06 +00 +69 +1b +01 +00 +02 +00 +00 +00 +06 +00 +6d +1b +01 +00 +02 +00 +00 +00 +06 +00 +71 +1b +01 +00 +02 +00 +00 +00 +06 +00 +75 +1b +01 +00 +02 +00 +00 +00 +06 +00 +79 +1b +01 +00 +02 +00 +00 +00 +06 +00 +7d +1b +01 +00 +02 +00 +00 +00 +06 +00 +81 +1b +01 +00 +02 +00 +00 +00 +06 +00 +85 +1b +01 +00 +02 +00 +00 +00 +06 +00 +89 +1b +01 +00 +02 +00 +00 +00 +06 +00 +8d +1b +01 +00 +02 +00 +00 +00 +06 +00 +91 +1b +01 +00 +02 +00 +00 +00 +06 +00 +95 +1b +01 +00 +02 +00 +00 +00 +06 +00 +99 +1b +01 +00 +02 +00 +00 +00 +06 +00 +9d +1b +01 +00 +02 +00 +00 +00 +06 +00 +a1 +1b +01 +00 +02 +00 +00 +00 +06 +00 +a5 +1b +01 +00 +02 +00 +00 +00 +06 +00 +a9 +1b +01 +00 +02 +00 +00 +00 +06 +00 +ad +1b +01 +00 +02 +00 +00 +00 +06 +00 +b1 +1b +01 +00 +02 +00 +00 +00 +06 +00 +b5 +1b +01 +00 +02 +00 +00 +00 +06 +00 +b9 +1b +01 +00 +02 +00 +00 +00 +06 +00 +bd +1b +01 +00 +02 +00 +00 +00 +06 +00 +c1 +1b +01 +00 +02 +00 +00 +00 +06 +00 +c5 +1b +01 +00 +02 +00 +00 +00 +06 +00 +c9 +1b +01 +00 +02 +00 +00 +00 +06 +00 +cd +1b +01 +00 +02 +00 +00 +00 +06 +00 +d1 +1b +01 +00 +02 +00 +00 +00 +06 +00 +d5 +1b +01 +00 +02 +00 +00 +00 +06 +00 +d9 +1b +01 +00 +02 +00 +00 +00 +06 +00 +dd +1b +01 +00 +02 +00 +00 +00 +06 +00 +e1 +1b +01 +00 +02 +00 +00 +00 +06 +00 +e5 +1b +01 +00 +02 +00 +00 +00 +06 +00 +e9 +1b +01 +00 +02 +00 +00 +00 +06 +00 +ed +1b +01 +00 +02 +00 +00 +00 +06 +00 +f1 +1b +01 +00 +02 +00 +00 +00 +06 +00 +f5 +1b +01 +00 +02 +00 +00 +00 +06 +00 +f9 +1b +01 +00 +02 +00 +00 +00 +06 +00 +fd +1b +01 +00 +02 +00 +00 +00 +06 +00 +01 1c -37 -00 +01 00 02 00 @@ -85209,9 +95299,2559 @@ fc 00 06 00 +05 +1c +01 +00 +02 +00 +00 +00 +06 +00 +09 +1c +01 +00 +02 +00 +00 +00 +06 +00 +0d +1c +01 +00 +02 +00 +00 +00 +06 +00 +11 +1c +01 +00 +02 +00 +00 +00 +06 +00 +15 +1c +01 +00 +02 +00 +00 +00 +06 +00 +19 +1c +01 +00 +02 +00 +00 +00 +06 +00 +1d +1c +01 +00 +02 +00 +00 +00 +06 +00 +21 +1c +01 +00 +02 +00 +00 +00 +06 +00 +25 +1c +01 +00 +02 +00 +00 +00 +06 +00 +29 +1c +01 +00 +02 +00 +00 +00 +06 +00 +2d +1c +01 +00 +02 +00 +00 +00 +06 +00 +31 +1c +01 +00 +02 +00 +00 +00 +06 +00 +35 +1c +01 +00 +02 +00 +00 +00 +06 +00 +39 +1c +01 +00 +02 +00 +00 +00 +06 +00 +3d +1c +01 +00 +02 +00 +00 +00 +06 +00 +41 +1c +01 +00 +02 +00 +00 +00 +06 +00 +45 +1c +01 +00 +02 +00 +00 +00 +06 +00 +49 +1c +01 +00 +02 +00 +00 +00 +06 +00 +4d +1c +01 +00 +02 +00 +00 +00 +06 +00 +51 +1c +01 +00 +02 +00 +00 +00 +06 +00 +55 +1c +01 +00 +02 +00 +00 +00 +06 +00 +59 +1c +01 +00 +02 +00 +00 +00 +06 +00 +5d +1c +01 +00 +02 +00 +00 +00 +06 +00 +61 +1c +01 +00 +02 +00 +00 +00 +06 +00 +65 +1c +01 +00 +02 +00 +00 +00 +06 +00 +69 +1c +01 +00 +02 +00 +00 +00 +06 +00 +6d +1c +01 +00 +02 +00 +00 +00 +06 +00 +71 +1c +01 +00 +02 +00 +00 +00 +06 +00 +75 +1c +01 +00 +02 +00 +00 +00 +06 +00 +79 +1c +01 +00 +02 +00 +00 +00 +06 +00 +7d +1c +01 +00 +02 +00 +00 +00 +06 +00 +81 +1c +01 +00 +02 +00 +00 +00 +06 +00 +85 +1c +01 +00 +02 +00 +00 +00 +06 +00 +89 +1c +01 +00 +02 +00 +00 +00 +06 +00 +8d +1c +01 +00 +02 +00 +00 +00 +06 +00 +91 +1c +01 +00 +02 +00 +00 +00 +06 +00 +95 +1c +01 +00 +02 +00 +00 +00 +06 +00 +99 +1c +01 +00 +02 +00 +00 +00 +06 +00 +9d +1c +01 +00 +02 +00 +00 +00 +06 +00 +a1 +1c +01 +00 +02 +00 +00 +00 +06 +00 +a5 +1c +01 +00 +02 +00 +00 +00 +06 +00 +a9 +1c +01 +00 +02 +00 +00 +00 +06 +00 +ad +1c +01 +00 +02 +00 +00 +00 +06 +00 +b1 +1c +01 +00 +02 +00 +00 +00 +06 +00 +b5 +1c +01 +00 +02 +00 +00 +00 +06 +00 +b9 +1c +01 +00 +02 +00 +00 +00 +06 +00 +bd +1c +01 +00 +02 +00 +00 +00 +06 +00 +c1 +1c +01 +00 +02 +00 +00 +00 +06 +00 +c5 +1c +01 +00 +02 +00 +00 +00 +06 +00 +c9 +1c +01 +00 +02 +00 +00 +00 +06 +00 +cd +1c +01 +00 +02 +00 +00 +00 +06 +00 +d1 +1c +01 +00 +02 +00 +00 +00 +06 +00 +d5 +1c +01 +00 +02 +00 +00 +00 +06 +00 +d9 +1c +01 +00 +02 +00 +00 +00 +06 +00 +dd +1c +01 +00 +02 +00 +00 +00 +06 +00 +e1 +1c +01 +00 +02 +00 +00 +00 +06 +00 +e5 +1c +01 +00 +02 +00 +00 +00 +06 +00 +e9 +1c +01 +00 +02 +00 +00 +00 +06 +00 +ed +1c +01 +00 +02 +00 +00 +00 +06 +00 +f1 +1c +01 +00 +02 +00 +00 +00 +06 +00 +f5 +1c +01 +00 +02 +00 +00 +00 +06 +00 +f9 +1c +01 +00 +02 +00 +00 +00 +06 +00 +fd +1c +01 +00 +02 +00 +00 +00 +06 +00 +01 +1d +01 +00 +02 +00 +00 +00 +06 +00 +05 +1d +01 +00 +02 +00 +00 +00 +06 +00 +09 +1d +01 +00 +02 +00 +00 +00 +06 +00 +0d +1d +01 +00 +02 +00 +00 +00 +06 +00 +11 +1d +01 +00 +02 +00 +00 +00 +06 +00 +15 +1d +01 +00 +02 +00 +00 +00 +06 +00 +19 +1d +01 +00 +02 +00 +00 +00 +06 +00 +1d +1d +01 +00 +02 +00 +00 +00 +06 +00 +21 +1d +01 +00 +02 +00 +00 +00 +06 +00 +25 +1d +01 +00 +02 +00 +00 +00 +06 +00 +29 +1d +01 +00 +02 +00 +00 +00 +06 +00 +2d +1d +01 +00 +02 +00 +00 +00 +06 +00 +31 +1d +01 +00 +02 +00 +00 +00 +06 +00 +35 +1d +01 +00 +02 +00 +00 +00 +06 +00 +39 +1d +01 +00 +02 +00 +00 +00 +06 +00 +3d +1d +01 +00 +02 +00 +00 +00 +06 +00 +41 +1d +01 +00 +02 +00 +00 +00 +06 +00 +45 +1d +01 +00 +02 +00 +00 +00 +06 +00 +49 +1d +01 +00 +02 +00 +00 +00 +06 +00 +4d +1d +01 +00 +02 +00 +00 +00 +06 +00 +51 +1d +01 +00 +02 +00 +00 +00 +06 +00 +55 +1d +01 +00 +02 +00 +00 +00 +06 +00 +59 +1d +01 +00 +02 +00 +00 +00 +06 +00 +5d +1d +01 +00 +02 +00 +00 +00 +06 +00 +61 +1d +01 +00 +02 +00 +00 +00 +06 +00 +65 +1d +01 +00 +02 +00 +00 +00 +06 +00 +69 +1d +01 +00 +02 +00 +00 +00 +06 +00 +6d +1d +01 +00 +02 +00 +00 +00 +06 +00 +71 +1d +01 +00 +02 +00 +00 +00 +06 +00 +75 +1d +01 +00 +02 +00 +00 +00 +06 +00 +79 +1d +01 +00 +02 +00 +00 +00 +06 +00 +7d +1d +01 +00 +02 +00 +00 +00 +06 +00 +81 +1d +01 +00 +02 +00 +00 +00 +06 +00 +85 +1d +01 +00 +02 +00 +00 +00 +06 +00 +89 +1d +01 +00 +02 +00 +00 +00 +06 +00 +8d +1d +01 +00 +02 +00 +00 +00 +06 +00 +91 +1d +01 +00 +02 +00 +00 +00 +06 +00 +95 +1d +01 +00 +02 +00 +00 +00 +06 +00 +99 +1d +01 +00 +02 +00 +00 +00 +06 +00 +9d +1d +01 +00 +02 +00 +00 +00 +06 +00 +a1 +1d +01 +00 +02 +00 +00 +00 +06 +00 +a5 +1d +01 +00 +02 +00 +00 +00 +06 +00 +a9 +1d +01 +00 +02 +00 +00 +00 +06 +00 +ad +1d +01 +00 +02 +00 +00 +00 +06 +00 +b1 +1d +01 +00 +02 +00 +00 +00 +06 +00 +b5 +1d +01 +00 +02 +00 +00 +00 +06 +00 +b9 +1d +01 +00 +02 +00 +00 +00 +06 +00 +bd +1d +01 +00 +02 +00 +00 +00 +06 +00 +c1 +1d +01 +00 +02 +00 +00 +00 +06 +00 +c5 +1d +01 +00 +02 +00 +00 +00 +06 +00 +c9 +1d +01 +00 +02 +00 +00 +00 +06 +00 +cd +1d +01 +00 +02 +00 +00 +00 +06 +00 +d1 +1d +01 +00 +02 +00 +00 +00 +06 +00 +d5 +1d +01 +00 +02 +00 +00 +00 +06 +00 +d9 +1d +01 +00 +02 +00 +00 +00 +06 +00 +dd +1d +01 +00 +02 +00 +00 +00 +06 +00 +e1 +1d +01 +00 +02 +00 +00 +00 +06 +00 +e5 +1d +01 +00 +02 +00 +00 +00 +06 +00 +e9 +1d +01 +00 +02 +00 +00 +00 +06 +00 +ed +1d +01 +00 +02 +00 +00 +00 +06 +00 +f1 +1d +01 +00 +02 +00 +00 +00 +06 +00 +f5 +1d +01 +00 +02 +00 +00 +00 +06 +00 +f9 +1d +01 +00 +02 +00 +00 +00 +06 +00 +fd +1d +01 +00 +02 +00 +00 +00 +06 +00 +01 +1e +01 +00 +02 +00 +00 +00 +06 +00 +05 +1e +01 +00 +02 +00 +00 +00 +06 +00 +09 +1e +01 +00 +02 +00 +00 +00 +06 +00 +0d +1e +01 +00 +02 +00 +00 +00 +06 +00 +11 +1e +01 +00 +02 +00 +00 +00 +06 +00 +15 +1e +01 +00 +02 +00 +00 +00 +06 +00 +19 +1e +01 +00 +02 +00 +00 +00 +06 +00 +1d +1e +01 +00 +02 +00 +00 +00 +06 +00 +21 +1e +01 +00 +02 +00 +00 +00 +06 +00 +25 +1e +01 +00 +02 +00 +00 +00 +06 +00 +29 +1e +01 +00 +02 +00 +00 +00 +06 +00 +2d +1e +01 +00 +02 +00 +00 +00 +06 +00 +31 +1e +01 +00 +02 +00 +00 +00 +06 +00 +35 +1e +01 +00 +02 +00 +00 +00 +06 +00 +39 +1e +01 +00 +02 +00 +00 +00 +06 +00 +3d +1e +01 +00 +02 +00 +00 +00 +06 +00 +41 +1e +01 +00 +02 +00 +00 +00 +06 +00 +45 +1e +01 +00 +02 +00 +00 +00 +06 +00 +49 +1e +01 +00 +02 +00 +00 +00 +06 +00 +4d +1e +01 +00 +02 +00 +00 +00 +06 +00 +51 +1e +01 +00 +02 +00 +00 +00 +06 +00 +55 +1e +01 +00 +02 +00 +00 +00 +06 +00 +59 +1e +01 +00 +02 +00 +00 +00 +06 +00 +5d +1e +01 +00 +02 +00 +00 +00 +06 +00 +61 +1e +01 +00 +02 +00 +00 +00 +06 +00 +65 +1e +01 +00 +02 +00 +00 +00 +06 +00 +69 +1e +01 +00 +02 +00 +00 +00 +06 +00 +6d +1e +01 +00 +02 +00 +00 +00 +06 +00 +71 +1e +01 +00 +02 +00 +00 +00 +06 +00 +75 +1e +01 +00 +02 +00 +00 +00 +06 +00 +79 +1e +01 +00 +02 +00 +00 +00 +06 +00 +7d +1e +01 +00 +02 +00 +00 +00 +06 +00 +81 +1e +01 +00 +02 +00 +00 +00 +06 +00 +85 +1e +01 +00 +02 +00 +00 +00 +06 +00 +89 +1e +01 +00 +02 +00 +00 +00 +06 +00 +8d +1e +01 +00 +02 +00 +00 +00 +06 +00 +91 +1e +01 +00 +02 +00 +00 +00 +06 +00 +95 +1e +01 +00 +02 +00 +00 +00 +06 +00 +99 +1e +01 +00 +02 +00 +00 +00 +06 +00 +9d +1e +01 +00 +02 +00 +00 +00 +06 +00 +a1 +1e +01 +00 +02 +00 +00 +00 +06 +00 +a5 +1e +01 +00 +02 +00 +00 +00 +06 +00 +a9 +1e +01 +00 +02 +00 +00 +00 +06 +00 +ad +1e +01 +00 +02 +00 +00 +00 +06 +00 +b1 +1e +01 +00 +02 +00 +00 +00 +06 +00 +b5 +1e +01 +00 +02 +00 +00 +00 +06 +00 +b9 +1e +01 +00 +02 +00 +00 +00 +06 +00 +bd +1e +01 +00 +02 +00 +00 +00 +06 +00 +c1 +1e +01 +00 +02 +00 +00 +00 +06 +00 +c5 +1e +01 +00 +02 +00 +00 +00 +06 +00 +c9 +1e +01 +00 +02 +00 +00 +00 +06 +00 +cd +1e +01 +00 +02 +00 +00 +00 +06 +00 +d1 +1e +01 +00 +02 +00 +00 +00 +06 +00 +d5 +1e +01 +00 +02 +00 +00 +00 +06 +00 +d9 +1e +01 +00 +02 +00 +00 +00 +06 +00 +dd +1e +01 +00 +02 +00 +00 +00 +06 +00 +e1 +1e +01 +00 +02 +00 +00 +00 +06 +00 +e5 +1e +01 +00 +02 +00 +00 +00 +06 +00 +e9 +1e +01 +00 +02 +00 +00 +00 +06 +00 +ed +1e +01 +00 +02 +00 +00 +00 +06 +00 +f1 +1e +01 +00 +02 +00 +00 +00 +06 +00 +f5 +1e +01 +00 +02 +00 +00 +00 +06 +00 +f9 +1e +01 +00 +02 +00 +00 +00 +06 +00 +fd +1e +01 +00 +02 +00 +00 +00 +06 +00 +01 +1f +01 +00 +02 +00 +00 +00 +06 +00 +05 +1f +01 +00 +02 +00 +00 +00 +06 +00 +09 +1f +01 +00 +02 +00 +00 +00 +06 +00 +0d +1f +01 +00 +02 +00 +00 +00 +06 +00 +11 +1f +01 +00 +02 +00 +00 +00 +06 +00 +15 +1f +01 +00 +02 +00 +00 +00 +06 +00 +19 +1f +01 +00 +02 +00 +00 +00 +06 +00 +1d +1f +01 +00 +02 +00 +00 +00 +06 +00 +21 +1f +01 +00 +02 +00 +00 +00 +06 +00 +25 +1f +01 +00 +02 +00 +00 +00 +06 +00 +29 +1f +01 +00 +02 +00 +00 +00 +06 +00 +2d +1f +01 +00 +02 +00 +00 +00 +06 +00 +31 +1f +01 +00 +02 +00 +00 +00 +06 +00 +35 +1f +01 +00 +02 +00 +00 +00 +06 +00 +39 +1f +01 +00 +02 +00 +00 +00 +06 +00 +3d +1f +01 +00 +02 +00 +00 +00 +06 +00 +41 +1f +01 +00 +02 +00 +00 +00 +06 +00 +45 +1f +01 +00 +02 +00 +00 +00 +06 +00 +49 +1f +01 +00 +02 +00 +00 +00 +06 +00 +4d +1f +01 +00 +02 +00 +00 +00 +06 +00 +51 +1f +01 +00 +02 +00 +00 +00 +06 +00 +55 +1f +01 +00 +02 +00 +00 +00 +06 +00 +59 +1f +01 +00 +02 +00 +00 +00 +06 +00 +5d +1f +01 +00 +02 +00 +00 +00 +06 +00 +61 +1f +01 +00 +02 +00 +00 +00 +06 +00 +65 +1f +01 +00 +02 +00 +00 +00 +06 +00 +69 +1f +01 +00 +02 +00 +00 +00 +06 +00 +6d +1f +01 +00 +02 +00 +00 +00 +06 +00 +71 +1f +01 +00 +02 +00 +00 +00 +06 +00 +75 +1f +01 +00 +02 +00 +00 +00 +06 +00 +79 +1f +01 +00 +02 +00 +00 +00 +06 +00 +7d +1f +01 +00 +02 +00 +00 +00 +06 +00 +81 +1f +01 +00 +02 +00 +00 +00 +06 +00 +85 +1f +01 +00 +02 +00 +00 +00 +06 +00 +89 +1f +01 +00 +02 +00 +00 +00 +06 +00 +8d +1f +01 +00 +02 +00 +00 +00 +06 +00 +91 +1f +01 +00 +02 +00 +00 +00 +06 +00 +95 +1f +01 +00 +02 +00 +00 +00 +06 +00 +99 +1f +01 +00 +02 +00 +00 +00 +06 +00 +9d +1f +01 +00 +02 +00 +00 +00 +06 +00 +a1 +1f +01 +00 +02 +00 +00 +00 +06 +00 +a5 +1f +01 +00 +02 +00 +00 +00 +06 +00 +a9 +1f +01 +00 +02 +00 +00 +00 +06 +00 +ad +1f +01 +00 +02 +00 +00 +00 +06 +00 +b1 +1f +01 +00 +02 +00 +00 +00 +06 +00 +b5 +1f +01 +00 +02 +00 +00 +00 +06 +00 +b9 +1f +01 +00 +02 +00 +00 +00 +06 +00 +bd +1f +01 +00 +02 +00 +00 +00 +06 +00 +c1 +1f +01 +00 +02 +00 +00 +00 +06 +00 +c5 +1f +01 +00 +02 +00 +00 +00 +06 +00 +c9 +1f +01 +00 +02 +00 +00 +00 +06 +00 +cd +1f +01 +00 +02 +00 +00 +00 +06 +00 +d1 +1f +01 +00 +02 +00 +00 +00 +06 +00 +d5 +1f +01 +00 +02 +00 +00 +00 +06 +00 +d9 +1f +01 +00 +02 +00 +00 +00 +06 +00 +dd +1f +01 +00 +02 +00 +00 +00 +06 +00 +e1 +1f +01 +00 +02 +00 +00 +00 +06 +00 +e5 +1f +01 +00 +02 +00 +00 +00 +06 +00 +e9 +1f +01 +00 +02 +00 +00 +00 +06 +00 +ed +1f +01 +00 +02 +00 +00 +00 +06 +00 +f1 +1f +01 +00 +02 +00 +00 +00 +06 +00 +f5 +1f +01 +00 +02 +00 +00 +00 +06 +00 +f9 +1f +01 +00 +02 +00 +00 +00 +06 +00 +fd +1f +01 +00 +02 +00 +00 +00 +06 +00 +01 20 -37 -00 +01 00 02 00 @@ -85219,639 +97859,2559 @@ fc 00 06 00 +05 +20 +01 +00 +02 +00 +00 +00 +06 +00 +09 +20 +01 +00 +02 +00 +00 +00 +06 +00 +0d +20 +01 +00 +02 +00 +00 +00 +06 +00 +11 +20 +01 +00 +02 +00 +00 +00 +06 +00 +15 +20 +01 +00 +02 +00 +00 +00 +06 +00 +19 +20 +01 +00 +02 +00 +00 +00 +06 +00 +1d +20 +01 +00 +02 +00 +00 +00 +06 +00 +21 +20 +01 +00 +02 +00 +00 +00 +06 +00 +25 +20 +01 +00 +02 +00 +00 +00 +06 +00 +29 +20 +01 +00 +02 +00 +00 +00 +06 +00 +2d +20 +01 +00 +02 +00 +00 +00 +06 +00 +31 +20 +01 +00 +02 +00 +00 +00 +06 +00 +35 +20 +01 +00 +02 +00 +00 +00 +06 +00 +39 +20 +01 +00 +02 +00 +00 +00 +06 +00 +3d +20 +01 +00 +02 +00 +00 +00 +06 +00 +41 +20 +01 +00 +02 +00 +00 +00 +06 +00 +45 +20 +01 +00 +02 +00 +00 +00 +06 +00 +49 +20 +01 +00 +02 +00 +00 +00 +06 +00 +4d +20 +01 +00 +02 +00 +00 +00 +06 +00 +51 +20 +01 +00 +02 +00 +00 +00 +06 +00 +55 +20 +01 +00 +02 +00 +00 +00 +06 +00 +59 +20 +01 +00 +02 +00 +00 +00 +06 +00 +5d +20 +01 +00 +02 +00 +00 +00 +06 +00 +61 +20 +01 +00 +02 +00 +00 +00 +06 +00 +65 +20 +01 +00 +02 +00 +00 +00 +06 +00 +69 +20 +01 +00 +02 +00 +00 +00 +06 +00 +6d +20 +01 +00 +02 +00 +00 +00 +06 +00 +71 +20 +01 +00 +02 +00 +00 +00 +06 +00 +75 +20 +01 +00 +02 +00 +00 +00 +06 +00 +79 +20 +01 +00 +02 +00 +00 +00 +06 +00 +7d +20 +01 +00 +02 +00 +00 +00 +06 +00 +81 +20 +01 +00 +02 +00 +00 +00 +06 +00 +85 +20 +01 +00 +02 +00 +00 +00 +06 +00 +89 +20 +01 +00 +02 +00 +00 +00 +06 +00 +8d +20 +01 +00 +02 +00 +00 +00 +06 +00 +91 +20 +01 +00 +02 +00 +00 +00 +06 +00 +95 +20 +01 +00 +02 +00 +00 +00 +06 +00 +99 +20 +01 +00 +02 +00 +00 +00 +06 +00 +9d +20 +01 +00 +02 +00 +00 +00 +06 +00 +a1 +20 +01 +00 +02 +00 +00 +00 +06 +00 +a5 +20 +01 +00 +02 +00 +00 +00 +06 +00 +a9 +20 +01 +00 +02 +00 +00 +00 +06 +00 +ad +20 +01 +00 +02 +00 +00 +00 +06 +00 +b1 +20 +01 +00 +02 +00 +00 +00 +06 +00 +b5 +20 +01 +00 +02 +00 +00 +00 +06 +00 +b9 +20 +01 +00 +02 +00 +00 +00 +06 +00 +bd +20 +01 +00 +02 +00 +00 +00 +06 +00 +c1 +20 +01 +00 +02 +00 +00 +00 +06 +00 +c5 +20 +01 +00 +02 +00 +00 +00 +06 +00 +c9 +20 +01 +00 +02 +00 +00 +00 +06 +00 +cd +20 +01 +00 +02 +00 +00 +00 +06 +00 +d1 +20 +01 +00 +02 +00 +00 +00 +06 +00 +d5 +20 +01 +00 +02 +00 +00 +00 +06 +00 +d9 +20 +01 +00 +02 +00 +00 +00 +06 +00 +dd +20 +01 +00 +02 +00 +00 +00 +06 +00 +e1 +20 +01 +00 +02 +00 +00 +00 +06 +00 +e5 +20 +01 +00 +02 +00 +00 +00 +06 +00 +e9 +20 +01 +00 +02 +00 +00 +00 +06 +00 +ed +20 +01 +00 +02 +00 +00 +00 +06 +00 +f1 +20 +01 +00 +02 +00 +00 +00 +06 +00 +f5 +20 +01 +00 +02 +00 +00 +00 +06 +00 +f9 +20 +01 +00 +02 +00 +00 +00 +06 +00 +fd +20 +01 +00 +02 +00 +00 +00 +06 +00 +01 +21 +01 +00 +02 +00 +00 +00 +06 +00 +05 +21 +01 +00 +02 +00 +00 +00 +06 +00 +09 +21 +01 +00 +02 +00 +00 +00 +06 +00 +0d +21 +01 +00 +02 +00 +00 +00 +06 +00 +11 +21 +01 +00 +02 +00 +00 +00 +06 +00 +15 +21 +01 +00 +02 +00 +00 +00 +06 +00 +19 +21 +01 +00 +02 +00 +00 +00 +06 +00 +1d +21 +01 +00 +02 +00 +00 +00 +06 +00 +21 +21 +01 +00 +02 +00 +00 +00 +06 +00 +25 +21 +01 +00 +02 +00 +00 +00 +06 +00 +29 +21 +01 +00 +02 +00 +00 +00 +06 +00 +2d +21 +01 +00 +02 +00 +00 +00 +06 +00 +31 +21 +01 +00 +02 +00 +00 +00 +06 +00 +35 +21 +01 +00 +02 +00 +00 +00 +06 +00 +39 +21 +01 +00 +02 +00 +00 +00 +06 +00 +3d +21 +01 +00 +02 +00 +00 +00 +06 +00 +41 +21 +01 +00 +02 +00 +00 +00 +06 +00 +45 +21 +01 +00 +02 +00 +00 +00 +06 +00 +49 +21 +01 +00 +02 +00 +00 +00 +06 +00 +4d +21 +01 +00 +02 +00 +00 +00 +06 +00 +51 +21 +01 +00 +02 +00 +00 +00 +06 +00 +55 +21 +01 +00 +02 +00 +00 +00 +06 +00 +59 +21 +01 +00 +02 +00 +00 +00 +06 +00 +5d +21 +01 +00 +02 +00 +00 +00 +06 +00 +61 +21 +01 +00 +02 +00 +00 +00 +06 +00 +65 +21 +01 +00 +02 +00 +00 +00 +06 +00 +69 +21 +01 +00 +02 +00 +00 +00 +06 +00 +6d +21 +01 +00 +02 +00 +00 +00 +06 +00 +71 +21 +01 +00 +02 +00 +00 +00 +06 +00 +75 +21 +01 +00 +02 +00 +00 +00 +06 +00 +79 +21 +01 +00 +02 +00 +00 +00 +06 +00 +7d +21 +01 +00 +02 +00 +00 +00 +06 +00 +81 +21 +01 +00 +02 +00 +00 +00 +06 +00 +85 +21 +01 +00 +02 +00 +00 +00 +06 +00 +89 +21 +01 +00 +02 +00 +00 +00 +06 +00 +8d +21 +01 +00 +02 +00 +00 +00 +06 +00 +91 +21 +01 +00 +02 +00 +00 +00 +06 +00 +95 +21 +01 +00 +02 +00 +00 +00 +06 +00 +99 +21 +01 +00 +02 +00 +00 +00 +06 +00 +9d +21 +01 +00 +02 +00 +00 +00 +06 +00 +a1 +21 +01 +00 +02 +00 +00 +00 +06 +00 +a5 +21 +01 +00 +02 +00 +00 +00 +06 +00 +a9 +21 +01 +00 +02 +00 +00 +00 +06 +00 +ad +21 +01 +00 +02 +00 +00 +00 +06 +00 +b1 +21 +01 +00 +02 +00 +00 +00 +06 +00 +b5 +21 +01 +00 +02 +00 +00 +00 +06 +00 +b9 +21 +01 +00 +02 +00 +00 +00 +06 +00 +bd +21 +01 +00 +02 +00 +00 +00 +06 +00 +c1 +21 +01 +00 +02 +00 +00 +00 +06 +00 +c5 +21 +01 +00 +02 +00 +00 +00 +06 +00 +c9 +21 +01 +00 +02 +00 +00 +00 +06 +00 +cd +21 +01 +00 +02 +00 +00 +00 +06 +00 +d1 +21 +01 +00 +02 +00 +00 +00 +06 +00 +d5 +21 +01 +00 +02 +00 +00 +00 +06 +00 +d9 +21 +01 +00 +02 +00 +00 +00 +06 +00 +dd +21 +01 +00 +02 +00 +00 +00 +06 +00 +e1 +21 +01 +00 +02 +00 +00 +00 +06 +00 +e5 +21 +01 +00 +02 +00 +00 +00 +06 +00 +e9 +21 +01 +00 +02 +00 +00 +00 +06 +00 +ed +21 +01 +00 +02 +00 +00 +00 +06 +00 +f1 +21 +01 +00 +02 +00 +00 +00 +06 +00 +f5 +21 +01 +00 +02 +00 +00 +00 +06 +00 +f9 +21 +01 +00 +02 +00 +00 +00 +06 +00 +fd +21 +01 +00 +02 +00 +00 +00 +06 +00 +01 +22 +01 +00 +02 +00 +00 +00 +06 +00 +05 +22 +01 +00 +02 +00 +00 +00 +06 +00 +09 +22 +01 +00 +02 +00 +00 +00 +06 +00 +0d +22 +01 +00 +02 +00 +00 +00 +06 +00 +11 +22 +01 +00 +02 +00 +00 +00 +06 +00 +15 +22 +01 +00 +02 +00 +00 +00 +06 +00 +19 +22 +01 +00 +02 +00 +00 +00 +06 +00 +1d +22 +01 +00 +02 +00 +00 +00 +06 +00 +21 +22 +01 +00 +02 +00 +00 +00 +06 +00 +25 +22 +01 +00 +02 +00 +00 +00 +06 +00 +29 +22 +01 +00 +02 +00 +00 +00 +06 +00 +2d +22 +01 +00 +02 +00 +00 +00 +06 +00 +31 +22 +01 +00 +02 +00 +00 +00 +06 +00 +35 +22 +01 +00 +02 +00 +00 +00 +06 +00 +39 +22 +01 +00 +02 +00 +00 +00 +06 +00 +3d +22 +01 +00 +02 +00 +00 +00 +06 +00 +41 +22 +01 +00 +02 +00 +00 +00 +06 +00 +45 +22 +01 +00 +02 +00 +00 +00 +06 +00 +49 +22 +01 +00 +02 +00 +00 +00 +06 +00 +4d +22 +01 +00 +02 +00 +00 +00 +06 +00 +51 +22 +01 +00 +02 +00 +00 +00 +06 +00 +55 +22 +01 +00 +02 +00 +00 +00 +06 +00 +59 +22 +01 +00 +02 +00 +00 +00 +06 +00 +5d +22 +01 +00 +02 +00 +00 +00 +06 +00 +61 +22 +01 +00 +02 +00 +00 +00 +06 +00 +65 +22 +01 +00 +02 +00 +00 +00 +06 +00 +69 +22 +01 +00 +02 +00 +00 +00 +06 +00 +6d +22 +01 +00 +02 +00 +00 +00 +06 +00 +71 +22 +01 +00 +02 +00 +00 +00 +06 +00 +75 +22 +01 +00 +02 +00 +00 +00 +06 +00 +79 +22 +01 +00 +02 +00 +00 +00 +06 +00 +7d +22 +01 +00 +02 +00 +00 +00 +06 +00 +81 +22 +01 +00 +02 +00 +00 +00 +06 +00 +85 +22 +01 +00 +02 +00 +00 +00 +06 +00 +89 +22 +01 +00 +02 +00 +00 +00 +06 +00 +8d +22 +01 +00 +02 +00 +00 +00 +06 +00 +91 +22 +01 +00 +02 +00 +00 +00 +06 +00 +95 +22 +01 +00 +02 +00 +00 +00 +06 +00 +99 +22 +01 +00 +02 +00 +00 +00 +06 +00 +9d +22 +01 +00 +02 +00 +00 +00 +06 +00 +a1 +22 +01 +00 +02 +00 +00 +00 +06 +00 +a5 +22 +01 +00 +02 +00 +00 +00 +06 +00 +a9 +22 +01 +00 +02 +00 +00 +00 +06 +00 +ad +22 +01 +00 +02 +00 +00 +00 +06 +00 +b1 +22 +01 +00 +02 +00 +00 +00 +06 +00 +b5 +22 +01 +00 +02 +00 +00 +00 +06 +00 +b9 +22 +01 +00 +02 +00 +00 +00 +06 +00 +bd +22 +01 +00 +02 +00 +00 +00 +06 +00 +c1 +22 +01 +00 +02 +00 +00 +00 +06 +00 +c5 +22 +01 +00 +02 +00 +00 +00 +06 +00 +c9 +22 +01 +00 +02 +00 +00 +00 +06 +00 +cd +22 +01 +00 +02 +00 +00 +00 +06 +00 +d1 +22 +01 +00 +02 +00 +00 +00 +06 +00 +d5 +22 +01 +00 +02 +00 +00 +00 +06 +00 +d9 +22 +01 +00 +02 +00 +00 +00 +06 +00 +dd +22 +01 +00 +02 +00 +00 +00 +06 +00 +e1 +22 +01 +00 +02 +00 +00 +00 +06 +00 +e5 +22 +01 +00 +02 +00 +00 +00 +06 +00 +e9 +22 +01 +00 +02 +00 +00 +00 +06 +00 +ed +22 +01 +00 +02 +00 +00 +00 +06 +00 +f1 +22 +01 +00 +02 +00 +00 +00 +06 +00 +f5 +22 +01 +00 +02 +00 +00 +00 +06 +00 +f9 +22 +01 +00 +02 +00 +00 +00 +06 +00 +fd +22 +01 +00 +02 +00 +00 +00 +06 +00 +01 +23 +01 +00 +02 +00 +00 +00 +06 +00 +05 +23 +01 +00 +02 +00 +00 +00 +06 +00 +09 +23 +01 +00 +02 +00 +00 +00 +06 +00 +0d +23 +01 +00 +02 +00 +00 +00 +06 +00 +11 +23 +01 +00 +02 +00 +00 +00 +06 +00 +15 +23 +01 +00 +02 +00 +00 +00 +06 +00 +19 +23 +01 +00 +02 +00 +00 +00 +06 +00 +1d +23 +01 +00 +02 +00 +00 +00 +06 +00 +21 +23 +01 +00 +02 +00 +00 +00 +06 +00 +25 +23 +01 +00 +02 +00 +00 +00 +06 +00 +29 +23 +01 +00 +02 +00 +00 +00 +06 +00 +2d +23 +01 +00 +02 +00 +00 +00 +06 +00 +31 +23 +01 +00 +02 +00 +00 +00 +06 +00 +35 +23 +01 +00 +02 +00 +00 +00 +06 +00 +39 +23 +01 +00 +02 +00 +00 +00 +06 +00 +3d +23 +01 +00 +02 +00 +00 +00 +06 +00 +41 +23 +01 +00 +02 +00 +00 +00 +06 +00 +45 +23 +01 +00 +02 +00 +00 +00 +06 +00 +49 +23 +01 +00 +02 +00 +00 +00 +06 +00 +4d +23 +01 +00 +02 +00 +00 +00 +06 +00 +51 +23 +01 +00 +02 +00 +00 +00 +06 +00 +55 +23 +01 +00 +02 +00 +00 +00 +06 +00 +59 +23 +01 +00 +02 +00 +00 +00 +06 +00 +5d +23 +01 +00 +02 +00 +00 +00 +06 +00 +61 +23 +01 +00 +02 +00 +00 +00 +06 +00 +65 +23 +01 +00 +02 +00 +00 +00 +06 +00 +69 +23 +01 +00 +02 +00 +00 +00 +06 +00 +6d +23 +01 +00 +02 +00 +00 +00 +06 +00 +71 +23 +01 +00 +02 +00 +00 +00 +06 +00 +75 +23 +01 +00 +02 +00 +00 +00 +06 +00 +79 +23 +01 +00 +02 +00 +00 +00 +06 +00 +7d +23 +01 +00 +02 +00 +00 +00 +06 +00 +81 +23 +01 +00 +02 +00 +00 +00 +06 +00 +85 +23 +01 +00 +02 +00 +00 +00 +06 +00 +89 +23 +01 +00 +02 +00 +00 +00 +06 +00 +8d +23 +01 +00 +02 +00 +00 +00 +06 +00 +91 +23 +01 +00 +02 +00 +00 +00 +06 +00 +95 +23 +01 +00 +02 +00 +00 +00 +06 +00 +99 +23 +01 +00 +02 +00 +00 +00 +06 +00 +9d +23 +01 +00 +02 +00 +00 +00 +06 +00 +a1 +23 +01 +00 +02 +00 +00 +00 +06 +00 +a5 +23 +01 +00 +02 +00 +00 +00 +06 +00 +a9 +23 +01 +00 +02 +00 +00 +00 +06 +00 +ad +23 +01 +00 +02 +00 +00 +00 +06 +00 +b1 +23 +01 +00 +02 +00 +00 +00 +06 +00 +b5 +23 +01 +00 +02 +00 +00 +00 +06 +00 +b9 +23 +01 +00 +02 +00 +00 +00 +06 +00 +bd +23 +01 +00 +02 +00 +00 +00 +06 +00 +c1 +23 +01 +00 +02 +00 +00 +00 +06 +00 +c5 +23 +01 +00 +02 +00 +00 +00 +06 +00 +c9 +23 +01 +00 +02 +00 +00 +00 +06 +00 +cd +23 +01 +00 +02 +00 +00 +00 +06 +00 +d1 +23 +01 +00 +02 +00 +00 +00 +06 +00 +d5 +23 +01 +00 +02 +00 +00 +00 +06 +00 +d9 +23 +01 +00 +02 +00 +00 +00 +06 +00 +dd +23 +01 +00 +02 +00 +00 +00 +06 +00 +e1 +23 +01 +00 +02 +00 +00 +00 +06 +00 +e5 +23 +01 +00 +02 +00 +00 +00 +06 +00 +e9 +23 +01 +00 +02 +00 +00 +00 +06 +00 +ed +23 +01 +00 +02 +00 +00 +00 +06 +00 +f1 +23 +01 +00 +02 +00 +00 +00 +06 +00 +f5 +23 +01 +00 +02 +00 +00 +00 +06 +00 +f9 +23 +01 +00 +02 +00 +00 +00 +06 +00 +fd +23 +01 +00 +02 +00 +00 +00 +06 +00 +01 24 -37 -00 -00 -02 -00 -00 -00 -06 -00 -28 -37 -00 -00 -02 -00 -00 -00 -06 -00 -2c -37 -00 -00 -02 -00 -00 -00 -06 -00 -30 -37 -00 -00 -02 -00 -00 -00 -06 -00 -34 -37 -00 -00 -02 -00 -00 -00 -06 -00 -38 -37 -00 -00 -02 -00 -00 -00 -06 -00 -3c -37 -00 -00 -02 -00 -00 -00 -06 -00 -40 -37 -00 -00 -02 -00 -00 -00 -06 -00 -44 -37 -00 -00 -02 -00 -00 -00 -06 -00 -48 -37 -00 -00 -02 -00 -00 -00 -06 -00 -4c -37 -00 -00 -02 -00 -00 -00 -06 -00 -50 -37 -00 -00 -02 -00 -00 -00 -06 -00 -54 -37 -00 -00 -02 -00 -00 -00 -06 -00 -58 -37 -00 -00 -02 -00 -00 -00 -06 -00 -5c -37 -00 -00 -02 -00 -00 -00 -06 -00 -60 -37 -00 -00 -02 -00 -00 -00 -06 -00 -64 -37 -00 -00 -02 -00 -00 -00 -06 -00 -68 -37 -00 -00 -02 -00 -00 -00 -06 -00 -6c -37 -00 -00 -02 -00 -00 -00 -06 -00 -70 -37 -00 -00 -02 -00 -00 -00 -06 -00 -74 -37 -00 -00 -02 -00 -00 -00 -06 -00 -78 -37 -00 -00 -02 -00 -00 -00 -06 -00 -7c -37 -00 -00 -02 -00 -00 -00 -06 -00 -80 -37 -00 -00 -02 -00 -00 -00 -06 -00 -84 -37 -00 -00 -02 -00 -00 -00 -06 -00 -88 -37 -00 -00 -02 -00 -00 -00 -06 -00 -8c -37 -00 -00 -02 -00 -00 -00 -06 -00 -90 -37 -00 -00 -02 -00 -00 -00 -06 -00 -94 -37 -00 -00 -02 -00 -00 -00 -06 -00 -98 -37 -00 -00 -02 -00 -00 -00 -06 -00 -9c -37 -00 -00 -02 -00 -00 -00 -06 -00 -a0 -37 -00 -00 -02 -00 -00 -00 -06 -00 -a4 -37 -00 -00 -02 -00 -00 -00 -06 -00 -a8 -37 -00 -00 -02 -00 -00 -00 -06 -00 -ac -37 -00 -00 -02 -00 -00 -00 -06 -00 -b0 -37 -00 -00 -02 -00 -00 -00 -06 -00 -b4 -37 -00 -00 -02 -00 -00 -00 -06 -00 -b8 -37 -00 -00 -02 -00 -00 -00 -06 -00 -bc -37 -00 -00 -02 -00 -00 -00 -06 -00 -c0 -37 -00 -00 -02 -00 -00 -00 -06 -00 -c4 -37 -00 -00 -02 -00 -00 -00 -06 -00 -c8 -37 -00 -00 -02 -00 -00 -00 -06 -00 -cc -37 -00 -00 -02 -00 -00 -00 -06 -00 -d0 -37 -00 -00 -02 -00 -00 -00 -06 -00 -d4 -37 -00 -00 -02 -00 -00 -00 -06 -00 -d8 -37 -00 -00 -02 -00 -00 -00 -06 -00 -dc -37 -00 -00 -02 -00 -00 -00 -06 -00 -e0 -37 -00 -00 -02 -00 -00 -00 -06 -00 -e4 -37 -00 -00 -02 -00 -00 -00 -06 -00 -e8 -37 -00 -00 -02 -00 -00 -00 -06 -00 -ec -37 -00 -00 -02 -00 -00 -00 -06 -00 -f0 -37 -00 -00 -02 -00 -00 -00 -06 -00 -f4 -37 -00 -00 -02 -00 -00 -00 -06 -00 -f8 -37 -00 -00 -02 -00 -00 -00 -06 -00 -fc -37 -00 -00 -02 -00 -00 -00 -06 -00 -00 -38 -00 -00 -02 -00 -00 -00 -06 -00 -04 -38 -00 -00 -02 -00 -00 -00 -06 -00 -08 -38 -00 -00 -02 -00 -00 -00 -06 -00 -0c -38 -00 -00 -02 -00 -00 -00 -06 -00 -10 -38 -00 -00 -02 -00 -00 -00 -06 -00 -14 -38 -00 -00 -02 -00 -00 -00 -06 -00 -18 -38 -00 -00 -02 -00 -00 -00 -06 -00 -1c -38 -00 -00 -02 -00 -00 -00 -06 -00 -20 -38 -00 +01 00 02 00 @@ -85859,639 +100419,9 @@ fc 00 06 00 +05 24 -38 -00 -00 -02 -00 -00 -00 -06 -00 -28 -38 -00 -00 -02 -00 -00 -00 -06 -00 -2c -38 -00 -00 -02 -00 -00 -00 -06 -00 -30 -38 -00 -00 -02 -00 -00 -00 -06 -00 -34 -38 -00 -00 -02 -00 -00 -00 -06 -00 -38 -38 -00 -00 -02 -00 -00 -00 -06 -00 -3c -38 -00 -00 -02 -00 -00 -00 -06 -00 -40 -38 -00 -00 -02 -00 -00 -00 -06 -00 -44 -38 -00 -00 -02 -00 -00 -00 -06 -00 -48 -38 -00 -00 -02 -00 -00 -00 -06 -00 -4c -38 -00 -00 -02 -00 -00 -00 -06 -00 -50 -38 -00 -00 -02 -00 -00 -00 -06 -00 -54 -38 -00 -00 -02 -00 -00 -00 -06 -00 -58 -38 -00 -00 -02 -00 -00 -00 -06 -00 -5c -38 -00 -00 -02 -00 -00 -00 -06 -00 -60 -38 -00 -00 -02 -00 -00 -00 -06 -00 -64 -38 -00 -00 -02 -00 -00 -00 -06 -00 -68 -38 -00 -00 -02 -00 -00 -00 -06 -00 -6c -38 -00 -00 -02 -00 -00 -00 -06 -00 -70 -38 -00 -00 -02 -00 -00 -00 -06 -00 -74 -38 -00 -00 -02 -00 -00 -00 -06 -00 -78 -38 -00 -00 -02 -00 -00 -00 -06 -00 -7c -38 -00 -00 -02 -00 -00 -00 -06 -00 -80 -38 -00 -00 -02 -00 -00 -00 -06 -00 -84 -38 -00 -00 -02 -00 -00 -00 -06 -00 -88 -38 -00 -00 -02 -00 -00 -00 -06 -00 -8c -38 -00 -00 -02 -00 -00 -00 -06 -00 -90 -38 -00 -00 -02 -00 -00 -00 -06 -00 -94 -38 -00 -00 -02 -00 -00 -00 -06 -00 -98 -38 -00 -00 -02 -00 -00 -00 -06 -00 -9c -38 -00 -00 -02 -00 -00 -00 -06 -00 -a0 -38 -00 -00 -02 -00 -00 -00 -06 -00 -a4 -38 -00 -00 -02 -00 -00 -00 -06 -00 -a8 -38 -00 -00 -02 -00 -00 -00 -06 -00 -ac -38 -00 -00 -02 -00 -00 -00 -06 -00 -b0 -38 -00 -00 -02 -00 -00 -00 -06 -00 -b4 -38 -00 -00 -02 -00 -00 -00 -06 -00 -b8 -38 -00 -00 -02 -00 -00 -00 -06 -00 -bc -38 -00 -00 -02 -00 -00 -00 -06 -00 -c0 -38 -00 -00 -02 -00 -00 -00 -06 -00 -c4 -38 -00 -00 -02 -00 -00 -00 -06 -00 -c8 -38 -00 -00 -02 -00 -00 -00 -06 -00 -cc -38 -00 -00 -02 -00 -00 -00 -06 -00 -d0 -38 -00 -00 -02 -00 -00 -00 -06 -00 -d4 -38 -00 -00 -02 -00 -00 -00 -06 -00 -d8 -38 -00 -00 -02 -00 -00 -00 -06 -00 -dc -38 -00 -00 -02 -00 -00 -00 -06 -00 -e0 -38 -00 -00 -02 -00 -00 -00 -06 -00 -e4 -38 -00 -00 -02 -00 -00 -00 -06 -00 -e8 -38 -00 -00 -02 -00 -00 -00 -06 -00 -ec -38 -00 -00 -02 -00 -00 -00 -06 -00 -f0 -38 -00 -00 -02 -00 -00 -00 -06 -00 -f4 -38 -00 -00 -02 -00 -00 -00 -06 -00 -f8 -38 -00 -00 -02 -00 -00 -00 -06 -00 -fc -38 -00 -00 -02 -00 -00 -00 -06 -00 -00 -39 -00 -00 -02 -00 -00 -00 -06 -00 -04 -39 -00 -00 -02 -00 -00 -00 -06 -00 -08 -39 -00 -00 -02 -00 -00 -00 -06 -00 -0c -39 -00 -00 -02 -00 -00 -00 -06 -00 -10 -39 -00 -00 -02 -00 -00 -00 -06 -00 -14 -39 -00 -00 -02 -00 -00 -00 -06 -00 -18 -39 -00 -00 -02 -00 -00 -00 -06 -00 -1c -39 -00 -00 -02 -00 -00 -00 -06 -00 -20 -39 -00 +01 00 02 00 @@ -86499,509 +100429,9 @@ fc 00 06 00 +09 24 -39 -00 -00 -02 -00 -00 -00 -06 -00 -28 -39 -00 -00 -02 -00 -00 -00 -06 -00 -2c -39 -00 -00 -02 -00 -00 -00 -06 -00 -30 -39 -00 -00 -02 -00 -00 -00 -06 -00 -34 -39 -00 -00 -02 -00 -00 -00 -06 -00 -38 -39 -00 -00 -02 -00 -00 -00 -06 -00 -3c -39 -00 -00 -02 -00 -00 -00 -06 -00 -40 -39 -00 -00 -02 -00 -00 -00 -06 -00 -44 -39 -00 -00 -02 -00 -00 -00 -06 -00 -48 -39 -00 -00 -02 -00 -00 -00 -06 -00 -4c -39 -00 -00 -02 -00 -00 -00 -06 -00 -50 -39 -00 -00 -02 -00 -00 -00 -06 -00 -54 -39 -00 -00 -02 -00 -00 -00 -06 -00 -58 -39 -00 -00 -02 -00 -00 -00 -06 -00 -5c -39 -00 -00 -02 -00 -00 -00 -06 -00 -60 -39 -00 -00 -02 -00 -00 -00 -06 -00 -64 -39 -00 -00 -02 -00 -00 -00 -06 -00 -68 -39 -00 -00 -02 -00 -00 -00 -06 -00 -6c -39 -00 -00 -02 -00 -00 -00 -06 -00 -70 -39 -00 -00 -02 -00 -00 -00 -06 -00 -74 -39 -00 -00 -02 -00 -00 -00 -06 -00 -78 -39 -00 -00 -02 -00 -00 -00 -06 -00 -7c -39 -00 -00 -02 -00 -00 -00 -06 -00 -80 -39 -00 -00 -02 -00 -00 -00 -06 -00 -84 -39 -00 -00 -02 -00 -00 -00 -06 -00 -88 -39 -00 -00 -02 -00 -00 -00 -06 -00 -8c -39 -00 -00 -02 -00 -00 -00 -06 -00 -90 -39 -00 -00 -02 -00 -00 -00 -06 -00 -94 -39 -00 -00 -02 -00 -00 -00 -06 -00 -98 -39 -00 -00 -02 -00 -00 -00 -06 -00 -9c -39 -00 -00 -02 -00 -00 -00 -06 -00 -a0 -39 -00 -00 -02 -00 -00 -00 -06 -00 -a4 -39 -00 -00 -02 -00 -00 -00 -06 -00 -a8 -39 -00 -00 -02 -00 -00 -00 -06 -00 -ac -39 -00 -00 -02 -00 -00 -00 -06 -00 -b0 -39 -00 -00 -02 -00 -00 -00 -06 -00 -b4 -39 -00 -00 -02 -00 -00 -00 -06 -00 -b8 -39 -00 -00 -02 -00 -00 -00 -06 -00 -bc -39 -00 -00 -02 -00 -00 -00 -06 -00 -c0 -39 -00 -00 -02 -00 -00 -00 -06 -00 -c4 -39 -00 -00 -02 -00 -00 -00 -06 -00 -c8 -39 -00 -00 -02 -00 -00 -00 -06 -00 -00 -3b -00 -00 -02 -00 -00 -00 -06 -00 -04 -3b -00 -00 -02 -00 -00 -00 -06 -00 -08 -3b -00 -00 -02 -00 -00 -00 -06 -00 -0c -3b -00 -00 -02 -00 -00 -00 -06 -00 -10 -3b -00 -00 -02 -00 -00 -00 -06 -00 -14 -3b -00 -00 -02 -00 -00 -00 -06 -00 -18 -3b -00 -00 -02 -00 -00 -00 -06 -00 -1c -3b -00 -00 -02 -00 -00 -00 -06 -00 -20 -3b -00 +01 00 02 00 @@ -87009,639 +100439,9 @@ c8 00 06 00 +0d 24 -3b -00 -00 -02 -00 -00 -00 -06 -00 -28 -3b -00 -00 -02 -00 -00 -00 -06 -00 -2c -3b -00 -00 -02 -00 -00 -00 -06 -00 -30 -3b -00 -00 -02 -00 -00 -00 -06 -00 -34 -3b -00 -00 -02 -00 -00 -00 -06 -00 -38 -3b -00 -00 -02 -00 -00 -00 -06 -00 -3c -3b -00 -00 -02 -00 -00 -00 -06 -00 -40 -3b -00 -00 -02 -00 -00 -00 -06 -00 -44 -3b -00 -00 -02 -00 -00 -00 -06 -00 -48 -3b -00 -00 -02 -00 -00 -00 -06 -00 -4c -3b -00 -00 -02 -00 -00 -00 -06 -00 -50 -3b -00 -00 -02 -00 -00 -00 -06 -00 -54 -3b -00 -00 -02 -00 -00 -00 -06 -00 -58 -3b -00 -00 -02 -00 -00 -00 -06 -00 -5c -3b -00 -00 -02 -00 -00 -00 -06 -00 -60 -3b -00 -00 -02 -00 -00 -00 -06 -00 -64 -3b -00 -00 -02 -00 -00 -00 -06 -00 -68 -3b -00 -00 -02 -00 -00 -00 -06 -00 -6c -3b -00 -00 -02 -00 -00 -00 -06 -00 -70 -3b -00 -00 -02 -00 -00 -00 -06 -00 -74 -3b -00 -00 -02 -00 -00 -00 -06 -00 -78 -3b -00 -00 -02 -00 -00 -00 -06 -00 -7c -3b -00 -00 -02 -00 -00 -00 -06 -00 -80 -3b -00 -00 -02 -00 -00 -00 -06 -00 -84 -3b -00 -00 -02 -00 -00 -00 -06 -00 -88 -3b -00 -00 -02 -00 -00 -00 -06 -00 -8c -3b -00 -00 -02 -00 -00 -00 -06 -00 -90 -3b -00 -00 -02 -00 -00 -00 -06 -00 -94 -3b -00 -00 -02 -00 -00 -00 -06 -00 -98 -3b -00 -00 -02 -00 -00 -00 -06 -00 -9c -3b -00 -00 -02 -00 -00 -00 -06 -00 -a0 -3b -00 -00 -02 -00 -00 -00 -06 -00 -a4 -3b -00 -00 -02 -00 -00 -00 -06 -00 -a8 -3b -00 -00 -02 -00 -00 -00 -06 -00 -ac -3b -00 -00 -02 -00 -00 -00 -06 -00 -b0 -3b -00 -00 -02 -00 -00 -00 -06 -00 -b4 -3b -00 -00 -02 -00 -00 -00 -06 -00 -b8 -3b -00 -00 -02 -00 -00 -00 -06 -00 -bc -3b -00 -00 -02 -00 -00 -00 -06 -00 -c0 -3b -00 -00 -02 -00 -00 -00 -06 -00 -c4 -3b -00 -00 -02 -00 -00 -00 -06 -00 -c8 -3b -00 -00 -02 -00 -00 -00 -06 -00 -cc -3b -00 -00 -02 -00 -00 -00 -06 -00 -d0 -3b -00 -00 -02 -00 -00 -00 -06 -00 -d4 -3b -00 -00 -02 -00 -00 -00 -06 -00 -d8 -3b -00 -00 -02 -00 -00 -00 -06 -00 -dc -3b -00 -00 -02 -00 -00 -00 -06 -00 -e0 -3b -00 -00 -02 -00 -00 -00 -06 -00 -e4 -3b -00 -00 -02 -00 -00 -00 -06 -00 -e8 -3b -00 -00 -02 -00 -00 -00 -06 -00 -ec -3b -00 -00 -02 -00 -00 -00 -06 -00 -f0 -3b -00 -00 -02 -00 -00 -00 -06 -00 -f4 -3b -00 -00 -02 -00 -00 -00 -06 -00 -f8 -3b -00 -00 -02 -00 -00 -00 -06 -00 -fc -3b -00 -00 -02 -00 -00 -00 -06 -00 -00 -3c -00 -00 -02 -00 -00 -00 -06 -00 -04 -3c -00 -00 -02 -00 -00 -00 -06 -00 -08 -3c -00 -00 -02 -00 -00 -00 -06 -00 -0c -3c -00 -00 -02 -00 -00 -00 -06 -00 -10 -3c -00 -00 -02 -00 -00 -00 -06 -00 -14 -3c -00 -00 -02 -00 -00 -00 -06 -00 -18 -3c -00 -00 -02 -00 -00 -00 -06 -00 -1c -3c -00 -00 -02 -00 -00 -00 -06 -00 -20 -3c -00 +01 00 02 00 @@ -87649,639 +100449,9 @@ fc 00 06 00 +11 24 -3c -00 -00 -02 -00 -00 -00 -06 -00 -28 -3c -00 -00 -02 -00 -00 -00 -06 -00 -2c -3c -00 -00 -02 -00 -00 -00 -06 -00 -30 -3c -00 -00 -02 -00 -00 -00 -06 -00 -34 -3c -00 -00 -02 -00 -00 -00 -06 -00 -38 -3c -00 -00 -02 -00 -00 -00 -06 -00 -3c -3c -00 -00 -02 -00 -00 -00 -06 -00 -40 -3c -00 -00 -02 -00 -00 -00 -06 -00 -44 -3c -00 -00 -02 -00 -00 -00 -06 -00 -48 -3c -00 -00 -02 -00 -00 -00 -06 -00 -4c -3c -00 -00 -02 -00 -00 -00 -06 -00 -50 -3c -00 -00 -02 -00 -00 -00 -06 -00 -54 -3c -00 -00 -02 -00 -00 -00 -06 -00 -58 -3c -00 -00 -02 -00 -00 -00 -06 -00 -5c -3c -00 -00 -02 -00 -00 -00 -06 -00 -60 -3c -00 -00 -02 -00 -00 -00 -06 -00 -64 -3c -00 -00 -02 -00 -00 -00 -06 -00 -68 -3c -00 -00 -02 -00 -00 -00 -06 -00 -6c -3c -00 -00 -02 -00 -00 -00 -06 -00 -70 -3c -00 -00 -02 -00 -00 -00 -06 -00 -74 -3c -00 -00 -02 -00 -00 -00 -06 -00 -78 -3c -00 -00 -02 -00 -00 -00 -06 -00 -7c -3c -00 -00 -02 -00 -00 -00 -06 -00 -80 -3c -00 -00 -02 -00 -00 -00 -06 -00 -84 -3c -00 -00 -02 -00 -00 -00 -06 -00 -88 -3c -00 -00 -02 -00 -00 -00 -06 -00 -8c -3c -00 -00 -02 -00 -00 -00 -06 -00 -90 -3c -00 -00 -02 -00 -00 -00 -06 -00 -94 -3c -00 -00 -02 -00 -00 -00 -06 -00 -98 -3c -00 -00 -02 -00 -00 -00 -06 -00 -9c -3c -00 -00 -02 -00 -00 -00 -06 -00 -a0 -3c -00 -00 -02 -00 -00 -00 -06 -00 -a4 -3c -00 -00 -02 -00 -00 -00 -06 -00 -a8 -3c -00 -00 -02 -00 -00 -00 -06 -00 -ac -3c -00 -00 -02 -00 -00 -00 -06 -00 -b0 -3c -00 -00 -02 -00 -00 -00 -06 -00 -b4 -3c -00 -00 -02 -00 -00 -00 -06 -00 -b8 -3c -00 -00 -02 -00 -00 -00 -06 -00 -bc -3c -00 -00 -02 -00 -00 -00 -06 -00 -c0 -3c -00 -00 -02 -00 -00 -00 -06 -00 -c4 -3c -00 -00 -02 -00 -00 -00 -06 -00 -c8 -3c -00 -00 -02 -00 -00 -00 -06 -00 -cc -3c -00 -00 -02 -00 -00 -00 -06 -00 -d0 -3c -00 -00 -02 -00 -00 -00 -06 -00 -d4 -3c -00 -00 -02 -00 -00 -00 -06 -00 -d8 -3c -00 -00 -02 -00 -00 -00 -06 -00 -dc -3c -00 -00 -02 -00 -00 -00 -06 -00 -e0 -3c -00 -00 -02 -00 -00 -00 -06 -00 -e4 -3c -00 -00 -02 -00 -00 -00 -06 -00 -e8 -3c -00 -00 -02 -00 -00 -00 -06 -00 -ec -3c -00 -00 -02 -00 -00 -00 -06 -00 -f0 -3c -00 -00 -02 -00 -00 -00 -06 -00 -f4 -3c -00 -00 -02 -00 -00 -00 -06 -00 -f8 -3c -00 -00 -02 -00 -00 -00 -06 -00 -fc -3c -00 -00 -02 -00 -00 -00 -06 -00 -00 -3d -00 -00 -02 -00 -00 -00 -06 -00 -04 -3d -00 -00 -02 -00 -00 -00 -06 -00 -08 -3d -00 -00 -02 -00 -00 -00 -06 -00 -0c -3d -00 -00 -02 -00 -00 -00 -06 -00 -10 -3d -00 -00 -02 -00 -00 -00 -06 -00 -14 -3d -00 -00 -02 -00 -00 -00 -06 -00 -18 -3d -00 -00 -02 -00 -00 -00 -06 -00 -1c -3d -00 -00 -02 -00 -00 -00 -06 -00 -20 -3d -00 +01 00 02 00 @@ -88289,639 +100459,9 @@ fc 00 06 00 +15 24 -3d -00 -00 -02 -00 -00 -00 -06 -00 -28 -3d -00 -00 -02 -00 -00 -00 -06 -00 -2c -3d -00 -00 -02 -00 -00 -00 -06 -00 -30 -3d -00 -00 -02 -00 -00 -00 -06 -00 -34 -3d -00 -00 -02 -00 -00 -00 -06 -00 -38 -3d -00 -00 -02 -00 -00 -00 -06 -00 -3c -3d -00 -00 -02 -00 -00 -00 -06 -00 -40 -3d -00 -00 -02 -00 -00 -00 -06 -00 -44 -3d -00 -00 -02 -00 -00 -00 -06 -00 -48 -3d -00 -00 -02 -00 -00 -00 -06 -00 -4c -3d -00 -00 -02 -00 -00 -00 -06 -00 -50 -3d -00 -00 -02 -00 -00 -00 -06 -00 -54 -3d -00 -00 -02 -00 -00 -00 -06 -00 -58 -3d -00 -00 -02 -00 -00 -00 -06 -00 -5c -3d -00 -00 -02 -00 -00 -00 -06 -00 -60 -3d -00 -00 -02 -00 -00 -00 -06 -00 -64 -3d -00 -00 -02 -00 -00 -00 -06 -00 -68 -3d -00 -00 -02 -00 -00 -00 -06 -00 -6c -3d -00 -00 -02 -00 -00 -00 -06 -00 -70 -3d -00 -00 -02 -00 -00 -00 -06 -00 -74 -3d -00 -00 -02 -00 -00 -00 -06 -00 -78 -3d -00 -00 -02 -00 -00 -00 -06 -00 -7c -3d -00 -00 -02 -00 -00 -00 -06 -00 -80 -3d -00 -00 -02 -00 -00 -00 -06 -00 -84 -3d -00 -00 -02 -00 -00 -00 -06 -00 -88 -3d -00 -00 -02 -00 -00 -00 -06 -00 -8c -3d -00 -00 -02 -00 -00 -00 -06 -00 -90 -3d -00 -00 -02 -00 -00 -00 -06 -00 -94 -3d -00 -00 -02 -00 -00 -00 -06 -00 -98 -3d -00 -00 -02 -00 -00 -00 -06 -00 -9c -3d -00 -00 -02 -00 -00 -00 -06 -00 -a0 -3d -00 -00 -02 -00 -00 -00 -06 -00 -a4 -3d -00 -00 -02 -00 -00 -00 -06 -00 -a8 -3d -00 -00 -02 -00 -00 -00 -06 -00 -ac -3d -00 -00 -02 -00 -00 -00 -06 -00 -b0 -3d -00 -00 -02 -00 -00 -00 -06 -00 -b4 -3d -00 -00 -02 -00 -00 -00 -06 -00 -b8 -3d -00 -00 -02 -00 -00 -00 -06 -00 -bc -3d -00 -00 -02 -00 -00 -00 -06 -00 -c0 -3d -00 -00 -02 -00 -00 -00 -06 -00 -c4 -3d -00 -00 -02 -00 -00 -00 -06 -00 -c8 -3d -00 -00 -02 -00 -00 -00 -06 -00 -cc -3d -00 -00 -02 -00 -00 -00 -06 -00 -d0 -3d -00 -00 -02 -00 -00 -00 -06 -00 -d4 -3d -00 -00 -02 -00 -00 -00 -06 -00 -d8 -3d -00 -00 -02 -00 -00 -00 -06 -00 -dc -3d -00 -00 -02 -00 -00 -00 -06 -00 -e0 -3d -00 -00 -02 -00 -00 -00 -06 -00 -e4 -3d -00 -00 -02 -00 -00 -00 -06 -00 -e8 -3d -00 -00 -02 -00 -00 -00 -06 -00 -ec -3d -00 -00 -02 -00 -00 -00 -06 -00 -f0 -3d -00 -00 -02 -00 -00 -00 -06 -00 -f4 -3d -00 -00 -02 -00 -00 -00 -06 -00 -f8 -3d -00 -00 -02 -00 -00 -00 -06 -00 -fc -3d -00 -00 -02 -00 -00 -00 -06 -00 -00 -3e -00 -00 -02 -00 -00 -00 -06 -00 -04 -3e -00 -00 -02 -00 -00 -00 -06 -00 -08 -3e -00 -00 -02 -00 -00 -00 -06 -00 -0c -3e -00 -00 -02 -00 -00 -00 -06 -00 -10 -3e -00 -00 -02 -00 -00 -00 -06 -00 -14 -3e -00 -00 -02 -00 -00 -00 -06 -00 -18 -3e -00 -00 -02 -00 -00 -00 -06 -00 -1c -3e -00 -00 -02 -00 -00 -00 -06 -00 -20 -3e -00 +01 00 02 00 @@ -88929,639 +100469,9 @@ fc 00 06 00 +19 24 -3e -00 -00 -02 -00 -00 -00 -06 -00 -28 -3e -00 -00 -02 -00 -00 -00 -06 -00 -2c -3e -00 -00 -02 -00 -00 -00 -06 -00 -30 -3e -00 -00 -02 -00 -00 -00 -06 -00 -34 -3e -00 -00 -02 -00 -00 -00 -06 -00 -38 -3e -00 -00 -02 -00 -00 -00 -06 -00 -3c -3e -00 -00 -02 -00 -00 -00 -06 -00 -40 -3e -00 -00 -02 -00 -00 -00 -06 -00 -44 -3e -00 -00 -02 -00 -00 -00 -06 -00 -48 -3e -00 -00 -02 -00 -00 -00 -06 -00 -4c -3e -00 -00 -02 -00 -00 -00 -06 -00 -50 -3e -00 -00 -02 -00 -00 -00 -06 -00 -54 -3e -00 -00 -02 -00 -00 -00 -06 -00 -58 -3e -00 -00 -02 -00 -00 -00 -06 -00 -5c -3e -00 -00 -02 -00 -00 -00 -06 -00 -60 -3e -00 -00 -02 -00 -00 -00 -06 -00 -64 -3e -00 -00 -02 -00 -00 -00 -06 -00 -68 -3e -00 -00 -02 -00 -00 -00 -06 -00 -6c -3e -00 -00 -02 -00 -00 -00 -06 -00 -70 -3e -00 -00 -02 -00 -00 -00 -06 -00 -74 -3e -00 -00 -02 -00 -00 -00 -06 -00 -78 -3e -00 -00 -02 -00 -00 -00 -06 -00 -7c -3e -00 -00 -02 -00 -00 -00 -06 -00 -80 -3e -00 -00 -02 -00 -00 -00 -06 -00 -84 -3e -00 -00 -02 -00 -00 -00 -06 -00 -88 -3e -00 -00 -02 -00 -00 -00 -06 -00 -8c -3e -00 -00 -02 -00 -00 -00 -06 -00 -90 -3e -00 -00 -02 -00 -00 -00 -06 -00 -94 -3e -00 -00 -02 -00 -00 -00 -06 -00 -98 -3e -00 -00 -02 -00 -00 -00 -06 -00 -9c -3e -00 -00 -02 -00 -00 -00 -06 -00 -a0 -3e -00 -00 -02 -00 -00 -00 -06 -00 -a4 -3e -00 -00 -02 -00 -00 -00 -06 -00 -a8 -3e -00 -00 -02 -00 -00 -00 -06 -00 -ac -3e -00 -00 -02 -00 -00 -00 -06 -00 -b0 -3e -00 -00 -02 -00 -00 -00 -06 -00 -b4 -3e -00 -00 -02 -00 -00 -00 -06 -00 -b8 -3e -00 -00 -02 -00 -00 -00 -06 -00 -bc -3e -00 -00 -02 -00 -00 -00 -06 -00 -c0 -3e -00 -00 -02 -00 -00 -00 -06 -00 -c4 -3e -00 -00 -02 -00 -00 -00 -06 -00 -c8 -3e -00 -00 -02 -00 -00 -00 -06 -00 -cc -3e -00 -00 -02 -00 -00 -00 -06 -00 -d0 -3e -00 -00 -02 -00 -00 -00 -06 -00 -d4 -3e -00 -00 -02 -00 -00 -00 -06 -00 -d8 -3e -00 -00 -02 -00 -00 -00 -06 -00 -dc -3e -00 -00 -02 -00 -00 -00 -06 -00 -e0 -3e -00 -00 -02 -00 -00 -00 -06 -00 -e4 -3e -00 -00 -02 -00 -00 -00 -06 -00 -e8 -3e -00 -00 -02 -00 -00 -00 -06 -00 -ec -3e -00 -00 -02 -00 -00 -00 -06 -00 -f0 -3e -00 -00 -02 -00 -00 -00 -06 -00 -f4 -3e -00 -00 -02 -00 -00 -00 -06 -00 -f8 -3e -00 -00 -02 -00 -00 -00 -06 -00 -fc -3e -00 -00 -02 -00 -00 -00 -06 -00 -00 -3f -00 -00 -02 -00 -00 -00 -06 -00 -04 -3f -00 -00 -02 -00 -00 -00 -06 -00 -08 -3f -00 -00 -02 -00 -00 -00 -06 -00 -0c -3f -00 -00 -02 -00 -00 -00 -06 -00 -10 -3f -00 -00 -02 -00 -00 -00 -06 -00 -14 -3f -00 -00 -02 -00 -00 -00 -06 -00 -18 -3f -00 -00 -02 -00 -00 -00 -06 -00 -1c -3f -00 -00 -02 -00 -00 -00 -06 -00 -20 -3f -00 +01 00 02 00 @@ -89569,639 +100479,9 @@ fc 00 06 00 +1d 24 -3f -00 -00 -02 -00 -00 -00 -06 -00 -28 -3f -00 -00 -02 -00 -00 -00 -06 -00 -2c -3f -00 -00 -02 -00 -00 -00 -06 -00 -30 -3f -00 -00 -02 -00 -00 -00 -06 -00 -34 -3f -00 -00 -02 -00 -00 -00 -06 -00 -38 -3f -00 -00 -02 -00 -00 -00 -06 -00 -3c -3f -00 -00 -02 -00 -00 -00 -06 -00 -40 -3f -00 -00 -02 -00 -00 -00 -06 -00 -44 -3f -00 -00 -02 -00 -00 -00 -06 -00 -48 -3f -00 -00 -02 -00 -00 -00 -06 -00 -4c -3f -00 -00 -02 -00 -00 -00 -06 -00 -50 -3f -00 -00 -02 -00 -00 -00 -06 -00 -54 -3f -00 -00 -02 -00 -00 -00 -06 -00 -58 -3f -00 -00 -02 -00 -00 -00 -06 -00 -5c -3f -00 -00 -02 -00 -00 -00 -06 -00 -60 -3f -00 -00 -02 -00 -00 -00 -06 -00 -64 -3f -00 -00 -02 -00 -00 -00 -06 -00 -68 -3f -00 -00 -02 -00 -00 -00 -06 -00 -6c -3f -00 -00 -02 -00 -00 -00 -06 -00 -70 -3f -00 -00 -02 -00 -00 -00 -06 -00 -74 -3f -00 -00 -02 -00 -00 -00 -06 -00 -78 -3f -00 -00 -02 -00 -00 -00 -06 -00 -7c -3f -00 -00 -02 -00 -00 -00 -06 -00 -80 -3f -00 -00 -02 -00 -00 -00 -06 -00 -84 -3f -00 -00 -02 -00 -00 -00 -06 -00 -88 -3f -00 -00 -02 -00 -00 -00 -06 -00 -8c -3f -00 -00 -02 -00 -00 -00 -06 -00 -90 -3f -00 -00 -02 -00 -00 -00 -06 -00 -94 -3f -00 -00 -02 -00 -00 -00 -06 -00 -98 -3f -00 -00 -02 -00 -00 -00 -06 -00 -9c -3f -00 -00 -02 -00 -00 -00 -06 -00 -a0 -3f -00 -00 -02 -00 -00 -00 -06 -00 -a4 -3f -00 -00 -02 -00 -00 -00 -06 -00 -a8 -3f -00 -00 -02 -00 -00 -00 -06 -00 -ac -3f -00 -00 -02 -00 -00 -00 -06 -00 -b0 -3f -00 -00 -02 -00 -00 -00 -06 -00 -b4 -3f -00 -00 -02 -00 -00 -00 -06 -00 -b8 -3f -00 -00 -02 -00 -00 -00 -06 -00 -bc -3f -00 -00 -02 -00 -00 -00 -06 -00 -c0 -3f -00 -00 -02 -00 -00 -00 -06 -00 -c4 -3f -00 -00 -02 -00 -00 -00 -06 -00 -c8 -3f -00 -00 -02 -00 -00 -00 -06 -00 -cc -3f -00 -00 -02 -00 -00 -00 -06 -00 -d0 -3f -00 -00 -02 -00 -00 -00 -06 -00 -d4 -3f -00 -00 -02 -00 -00 -00 -06 -00 -d8 -3f -00 -00 -02 -00 -00 -00 -06 -00 -dc -3f -00 -00 -02 -00 -00 -00 -06 -00 -e0 -3f -00 -00 -02 -00 -00 -00 -06 -00 -e4 -3f -00 -00 -02 -00 -00 -00 -06 -00 -e8 -3f -00 -00 -02 -00 -00 -00 -06 -00 -ec -3f -00 -00 -02 -00 -00 -00 -06 -00 -f0 -3f -00 -00 -02 -00 -00 -00 -06 -00 -f4 -3f -00 -00 -02 -00 -00 -00 -06 -00 -f8 -3f -00 -00 -02 -00 -00 -00 -06 -00 -fc -3f -00 -00 -02 -00 -00 -00 -06 -00 -00 -40 -00 -00 -02 -00 -00 -00 -06 -00 -04 -40 -00 -00 -02 -00 -00 -00 -06 -00 -08 -40 -00 -00 -02 -00 -00 -00 -06 -00 -0c -40 -00 -00 -02 -00 -00 -00 -06 -00 -10 -40 -00 -00 -02 -00 -00 -00 -06 -00 -14 -40 -00 -00 -02 -00 -00 -00 -06 -00 -18 -40 -00 -00 -02 -00 -00 -00 -06 -00 -1c -40 -00 -00 -02 -00 -00 -00 -06 -00 -20 -40 -00 +01 00 02 00 @@ -90209,639 +100489,9 @@ fc 00 06 00 +21 24 -40 -00 -00 -02 -00 -00 -00 -06 -00 -28 -40 -00 -00 -02 -00 -00 -00 -06 -00 -2c -40 -00 -00 -02 -00 -00 -00 -06 -00 -30 -40 -00 -00 -02 -00 -00 -00 -06 -00 -34 -40 -00 -00 -02 -00 -00 -00 -06 -00 -38 -40 -00 -00 -02 -00 -00 -00 -06 -00 -3c -40 -00 -00 -02 -00 -00 -00 -06 -00 -40 -40 -00 -00 -02 -00 -00 -00 -06 -00 -44 -40 -00 -00 -02 -00 -00 -00 -06 -00 -48 -40 -00 -00 -02 -00 -00 -00 -06 -00 -4c -40 -00 -00 -02 -00 -00 -00 -06 -00 -50 -40 -00 -00 -02 -00 -00 -00 -06 -00 -54 -40 -00 -00 -02 -00 -00 -00 -06 -00 -58 -40 -00 -00 -02 -00 -00 -00 -06 -00 -5c -40 -00 -00 -02 -00 -00 -00 -06 -00 -60 -40 -00 -00 -02 -00 -00 -00 -06 -00 -64 -40 -00 -00 -02 -00 -00 -00 -06 -00 -68 -40 -00 -00 -02 -00 -00 -00 -06 -00 -6c -40 -00 -00 -02 -00 -00 -00 -06 -00 -70 -40 -00 -00 -02 -00 -00 -00 -06 -00 -74 -40 -00 -00 -02 -00 -00 -00 -06 -00 -78 -40 -00 -00 -02 -00 -00 -00 -06 -00 -7c -40 -00 -00 -02 -00 -00 -00 -06 -00 -80 -40 -00 -00 -02 -00 -00 -00 -06 -00 -84 -40 -00 -00 -02 -00 -00 -00 -06 -00 -88 -40 -00 -00 -02 -00 -00 -00 -06 -00 -8c -40 -00 -00 -02 -00 -00 -00 -06 -00 -90 -40 -00 -00 -02 -00 -00 -00 -06 -00 -94 -40 -00 -00 -02 -00 -00 -00 -06 -00 -98 -40 -00 -00 -02 -00 -00 -00 -06 -00 -9c -40 -00 -00 -02 -00 -00 -00 -06 -00 -a0 -40 -00 -00 -02 -00 -00 -00 -06 -00 -a4 -40 -00 -00 -02 -00 -00 -00 -06 -00 -a8 -40 -00 -00 -02 -00 -00 -00 -06 -00 -ac -40 -00 -00 -02 -00 -00 -00 -06 -00 -b0 -40 -00 -00 -02 -00 -00 -00 -06 -00 -b4 -40 -00 -00 -02 -00 -00 -00 -06 -00 -b8 -40 -00 -00 -02 -00 -00 -00 -06 -00 -bc -40 -00 -00 -02 -00 -00 -00 -06 -00 -c0 -40 -00 -00 -02 -00 -00 -00 -06 -00 -c4 -40 -00 -00 -02 -00 -00 -00 -06 -00 -c8 -40 -00 -00 -02 -00 -00 -00 -06 -00 -cc -40 -00 -00 -02 -00 -00 -00 -06 -00 -d0 -40 -00 -00 -02 -00 -00 -00 -06 -00 -d4 -40 -00 -00 -02 -00 -00 -00 -06 -00 -d8 -40 -00 -00 -02 -00 -00 -00 -06 -00 -dc -40 -00 -00 -02 -00 -00 -00 -06 -00 -e0 -40 -00 -00 -02 -00 -00 -00 -06 -00 -e4 -40 -00 -00 -02 -00 -00 -00 -06 -00 -e8 -40 -00 -00 -02 -00 -00 -00 -06 -00 -ec -40 -00 -00 -02 -00 -00 -00 -06 -00 -f0 -40 -00 -00 -02 -00 -00 -00 -06 -00 -f4 -40 -00 -00 -02 -00 -00 -00 -06 -00 -f8 -40 -00 -00 -02 -00 -00 -00 -06 -00 -fc -40 -00 -00 -02 -00 -00 -00 -06 -00 -00 -41 -00 -00 -02 -00 -00 -00 -06 -00 -04 -41 -00 -00 -02 -00 -00 -00 -06 -00 -08 -41 -00 -00 -02 -00 -00 -00 -06 -00 -0c -41 -00 -00 -02 -00 -00 -00 -06 -00 -10 -41 -00 -00 -02 -00 -00 -00 -06 -00 -14 -41 -00 -00 -02 -00 -00 -00 -06 -00 -18 -41 -00 -00 -02 -00 -00 -00 -06 -00 -1c -41 -00 -00 -02 -00 -00 -00 -06 -00 -20 -41 -00 +01 00 02 00 @@ -90849,639 +100499,9 @@ fc 00 06 00 +25 24 -41 -00 -00 -02 -00 -00 -00 -06 -00 -28 -41 -00 -00 -02 -00 -00 -00 -06 -00 -2c -41 -00 -00 -02 -00 -00 -00 -06 -00 -30 -41 -00 -00 -02 -00 -00 -00 -06 -00 -34 -41 -00 -00 -02 -00 -00 -00 -06 -00 -38 -41 -00 -00 -02 -00 -00 -00 -06 -00 -3c -41 -00 -00 -02 -00 -00 -00 -06 -00 -40 -41 -00 -00 -02 -00 -00 -00 -06 -00 -44 -41 -00 -00 -02 -00 -00 -00 -06 -00 -48 -41 -00 -00 -02 -00 -00 -00 -06 -00 -4c -41 -00 -00 -02 -00 -00 -00 -06 -00 -50 -41 -00 -00 -02 -00 -00 -00 -06 -00 -54 -41 -00 -00 -02 -00 -00 -00 -06 -00 -58 -41 -00 -00 -02 -00 -00 -00 -06 -00 -5c -41 -00 -00 -02 -00 -00 -00 -06 -00 -60 -41 -00 -00 -02 -00 -00 -00 -06 -00 -64 -41 -00 -00 -02 -00 -00 -00 -06 -00 -68 -41 -00 -00 -02 -00 -00 -00 -06 -00 -6c -41 -00 -00 -02 -00 -00 -00 -06 -00 -70 -41 -00 -00 -02 -00 -00 -00 -06 -00 -74 -41 -00 -00 -02 -00 -00 -00 -06 -00 -78 -41 -00 -00 -02 -00 -00 -00 -06 -00 -7c -41 -00 -00 -02 -00 -00 -00 -06 -00 -80 -41 -00 -00 -02 -00 -00 -00 -06 -00 -84 -41 -00 -00 -02 -00 -00 -00 -06 -00 -88 -41 -00 -00 -02 -00 -00 -00 -06 -00 -8c -41 -00 -00 -02 -00 -00 -00 -06 -00 -90 -41 -00 -00 -02 -00 -00 -00 -06 -00 -94 -41 -00 -00 -02 -00 -00 -00 -06 -00 -98 -41 -00 -00 -02 -00 -00 -00 -06 -00 -9c -41 -00 -00 -02 -00 -00 -00 -06 -00 -a0 -41 -00 -00 -02 -00 -00 -00 -06 -00 -a4 -41 -00 -00 -02 -00 -00 -00 -06 -00 -a8 -41 -00 -00 -02 -00 -00 -00 -06 -00 -ac -41 -00 -00 -02 -00 -00 -00 -06 -00 -b0 -41 -00 -00 -02 -00 -00 -00 -06 -00 -b4 -41 -00 -00 -02 -00 -00 -00 -06 -00 -b8 -41 -00 -00 -02 -00 -00 -00 -06 -00 -bc -41 -00 -00 -02 -00 -00 -00 -06 -00 -c0 -41 -00 -00 -02 -00 -00 -00 -06 -00 -c4 -41 -00 -00 -02 -00 -00 -00 -06 -00 -c8 -41 -00 -00 -02 -00 -00 -00 -06 -00 -cc -41 -00 -00 -02 -00 -00 -00 -06 -00 -d0 -41 -00 -00 -02 -00 -00 -00 -06 -00 -d4 -41 -00 -00 -02 -00 -00 -00 -06 -00 -d8 -41 -00 -00 -02 -00 -00 -00 -06 -00 -dc -41 -00 -00 -02 -00 -00 -00 -06 -00 -e0 -41 -00 -00 -02 -00 -00 -00 -06 -00 -e4 -41 -00 -00 -02 -00 -00 -00 -06 -00 -e8 -41 -00 -00 -02 -00 -00 -00 -06 -00 -ec -41 -00 -00 -02 -00 -00 -00 -06 -00 -f0 -41 -00 -00 -02 -00 -00 -00 -06 -00 -f4 -41 -00 -00 -02 -00 -00 -00 -06 -00 -f8 -41 -00 -00 -02 -00 -00 -00 -06 -00 -fc -41 -00 -00 -02 -00 -00 -00 -06 -00 -00 -42 -00 -00 -02 -00 -00 -00 -06 -00 -04 -42 -00 -00 -02 -00 -00 -00 -06 -00 -08 -42 -00 -00 -02 -00 -00 -00 -06 -00 -0c -42 -00 -00 -02 -00 -00 -00 -06 -00 -10 -42 -00 -00 -02 -00 -00 -00 -06 -00 -14 -42 -00 -00 -02 -00 -00 -00 -06 -00 -18 -42 -00 -00 -02 -00 -00 -00 -06 -00 -1c -42 -00 -00 -02 -00 -00 -00 -06 -00 -20 -42 -00 +01 00 02 00 @@ -91489,639 +100509,9 @@ fc 00 06 00 +29 24 -42 -00 -00 -02 -00 -00 -00 -06 -00 -28 -42 -00 -00 -02 -00 -00 -00 -06 -00 -2c -42 -00 -00 -02 -00 -00 -00 -06 -00 -30 -42 -00 -00 -02 -00 -00 -00 -06 -00 -34 -42 -00 -00 -02 -00 -00 -00 -06 -00 -38 -42 -00 -00 -02 -00 -00 -00 -06 -00 -3c -42 -00 -00 -02 -00 -00 -00 -06 -00 -40 -42 -00 -00 -02 -00 -00 -00 -06 -00 -44 -42 -00 -00 -02 -00 -00 -00 -06 -00 -48 -42 -00 -00 -02 -00 -00 -00 -06 -00 -4c -42 -00 -00 -02 -00 -00 -00 -06 -00 -50 -42 -00 -00 -02 -00 -00 -00 -06 -00 -54 -42 -00 -00 -02 -00 -00 -00 -06 -00 -58 -42 -00 -00 -02 -00 -00 -00 -06 -00 -5c -42 -00 -00 -02 -00 -00 -00 -06 -00 -60 -42 -00 -00 -02 -00 -00 -00 -06 -00 -64 -42 -00 -00 -02 -00 -00 -00 -06 -00 -68 -42 -00 -00 -02 -00 -00 -00 -06 -00 -6c -42 -00 -00 -02 -00 -00 -00 -06 -00 -70 -42 -00 -00 -02 -00 -00 -00 -06 -00 -74 -42 -00 -00 -02 -00 -00 -00 -06 -00 -78 -42 -00 -00 -02 -00 -00 -00 -06 -00 -7c -42 -00 -00 -02 -00 -00 -00 -06 -00 -80 -42 -00 -00 -02 -00 -00 -00 -06 -00 -84 -42 -00 -00 -02 -00 -00 -00 -06 -00 -88 -42 -00 -00 -02 -00 -00 -00 -06 -00 -8c -42 -00 -00 -02 -00 -00 -00 -06 -00 -90 -42 -00 -00 -02 -00 -00 -00 -06 -00 -94 -42 -00 -00 -02 -00 -00 -00 -06 -00 -98 -42 -00 -00 -02 -00 -00 -00 -06 -00 -9c -42 -00 -00 -02 -00 -00 -00 -06 -00 -a0 -42 -00 -00 -02 -00 -00 -00 -06 -00 -a4 -42 -00 -00 -02 -00 -00 -00 -06 -00 -a8 -42 -00 -00 -02 -00 -00 -00 -06 -00 -ac -42 -00 -00 -02 -00 -00 -00 -06 -00 -b0 -42 -00 -00 -02 -00 -00 -00 -06 -00 -b4 -42 -00 -00 -02 -00 -00 -00 -06 -00 -b8 -42 -00 -00 -02 -00 -00 -00 -06 -00 -bc -42 -00 -00 -02 -00 -00 -00 -06 -00 -c0 -42 -00 -00 -02 -00 -00 -00 -06 -00 -c4 -42 -00 -00 -02 -00 -00 -00 -06 -00 -c8 -42 -00 -00 -02 -00 -00 -00 -06 -00 -cc -42 -00 -00 -02 -00 -00 -00 -06 -00 -d0 -42 -00 -00 -02 -00 -00 -00 -06 -00 -d4 -42 -00 -00 -02 -00 -00 -00 -06 -00 -d8 -42 -00 -00 -02 -00 -00 -00 -06 -00 -dc -42 -00 -00 -02 -00 -00 -00 -06 -00 -e0 -42 -00 -00 -02 -00 -00 -00 -06 -00 -e4 -42 -00 -00 -02 -00 -00 -00 -06 -00 -e8 -42 -00 -00 -02 -00 -00 -00 -06 -00 -ec -42 -00 -00 -02 -00 -00 -00 -06 -00 -f0 -42 -00 -00 -02 -00 -00 -00 -06 -00 -f4 -42 -00 -00 -02 -00 -00 -00 -06 -00 -f8 -42 -00 -00 -02 -00 -00 -00 -06 -00 -fc -42 -00 -00 -02 -00 -00 -00 -06 -00 -00 -43 -00 -00 -02 -00 -00 -00 -06 -00 -04 -43 -00 -00 -02 -00 -00 -00 -06 -00 -08 -43 -00 -00 -02 -00 -00 -00 -06 -00 -0c -43 -00 -00 -02 -00 -00 -00 -06 -00 -10 -43 -00 -00 -02 -00 -00 -00 -06 -00 -14 -43 -00 -00 -02 -00 -00 -00 -06 -00 -18 -43 -00 -00 -02 -00 -00 -00 -06 -00 -1c -43 -00 -00 -02 -00 -00 -00 -06 -00 -20 -43 -00 +01 00 02 00 @@ -92129,639 +100519,9 @@ fc 00 06 00 +2d 24 -43 -00 -00 -02 -00 -00 -00 -06 -00 -28 -43 -00 -00 -02 -00 -00 -00 -06 -00 -2c -43 -00 -00 -02 -00 -00 -00 -06 -00 -30 -43 -00 -00 -02 -00 -00 -00 -06 -00 -34 -43 -00 -00 -02 -00 -00 -00 -06 -00 -38 -43 -00 -00 -02 -00 -00 -00 -06 -00 -3c -43 -00 -00 -02 -00 -00 -00 -06 -00 -40 -43 -00 -00 -02 -00 -00 -00 -06 -00 -44 -43 -00 -00 -02 -00 -00 -00 -06 -00 -48 -43 -00 -00 -02 -00 -00 -00 -06 -00 -4c -43 -00 -00 -02 -00 -00 -00 -06 -00 -50 -43 -00 -00 -02 -00 -00 -00 -06 -00 -54 -43 -00 -00 -02 -00 -00 -00 -06 -00 -58 -43 -00 -00 -02 -00 -00 -00 -06 -00 -5c -43 -00 -00 -02 -00 -00 -00 -06 -00 -60 -43 -00 -00 -02 -00 -00 -00 -06 -00 -64 -43 -00 -00 -02 -00 -00 -00 -06 -00 -68 -43 -00 -00 -02 -00 -00 -00 -06 -00 -6c -43 -00 -00 -02 -00 -00 -00 -06 -00 -70 -43 -00 -00 -02 -00 -00 -00 -06 -00 -74 -43 -00 -00 -02 -00 -00 -00 -06 -00 -78 -43 -00 -00 -02 -00 -00 -00 -06 -00 -7c -43 -00 -00 -02 -00 -00 -00 -06 -00 -80 -43 -00 -00 -02 -00 -00 -00 -06 -00 -84 -43 -00 -00 -02 -00 -00 -00 -06 -00 -88 -43 -00 -00 -02 -00 -00 -00 -06 -00 -8c -43 -00 -00 -02 -00 -00 -00 -06 -00 -90 -43 -00 -00 -02 -00 -00 -00 -06 -00 -94 -43 -00 -00 -02 -00 -00 -00 -06 -00 -98 -43 -00 -00 -02 -00 -00 -00 -06 -00 -9c -43 -00 -00 -02 -00 -00 -00 -06 -00 -a0 -43 -00 -00 -02 -00 -00 -00 -06 -00 -a4 -43 -00 -00 -02 -00 -00 -00 -06 -00 -a8 -43 -00 -00 -02 -00 -00 -00 -06 -00 -ac -43 -00 -00 -02 -00 -00 -00 -06 -00 -b0 -43 -00 -00 -02 -00 -00 -00 -06 -00 -b4 -43 -00 -00 -02 -00 -00 -00 -06 -00 -b8 -43 -00 -00 -02 -00 -00 -00 -06 -00 -bc -43 -00 -00 -02 -00 -00 -00 -06 -00 -c0 -43 -00 -00 -02 -00 -00 -00 -06 -00 -c4 -43 -00 -00 -02 -00 -00 -00 -06 -00 -c8 -43 -00 -00 -02 -00 -00 -00 -06 -00 -cc -43 -00 -00 -02 -00 -00 -00 -06 -00 -d0 -43 -00 -00 -02 -00 -00 -00 -06 -00 -d4 -43 -00 -00 -02 -00 -00 -00 -06 -00 -d8 -43 -00 -00 -02 -00 -00 -00 -06 -00 -dc -43 -00 -00 -02 -00 -00 -00 -06 -00 -e0 -43 -00 -00 -02 -00 -00 -00 -06 -00 -e4 -43 -00 -00 -02 -00 -00 -00 -06 -00 -e8 -43 -00 -00 -02 -00 -00 -00 -06 -00 -ec -43 -00 -00 -02 -00 -00 -00 -06 -00 -f0 -43 -00 -00 -02 -00 -00 -00 -06 -00 -f4 -43 -00 -00 -02 -00 -00 -00 -06 -00 -f8 -43 -00 -00 -02 -00 -00 -00 -06 -00 -fc -43 -00 -00 -02 -00 -00 -00 -06 -00 -00 -44 -00 -00 -02 -00 -00 -00 -06 -00 -04 -44 -00 -00 -02 -00 -00 -00 -06 -00 -08 -44 -00 -00 -02 -00 -00 -00 -06 -00 -0c -44 -00 -00 -02 -00 -00 -00 -06 -00 -10 -44 -00 -00 -02 -00 -00 -00 -06 -00 -14 -44 -00 -00 -02 -00 -00 -00 -06 -00 -18 -44 -00 -00 -02 -00 -00 -00 -06 -00 -1c -44 -00 -00 -02 -00 -00 -00 -06 -00 -20 -44 -00 +01 00 02 00 @@ -92769,639 +100529,9 @@ fc 00 06 00 +31 24 -44 -00 -00 -02 -00 -00 -00 -06 -00 -28 -44 -00 -00 -02 -00 -00 -00 -06 -00 -2c -44 -00 -00 -02 -00 -00 -00 -06 -00 -30 -44 -00 -00 -02 -00 -00 -00 -06 -00 -34 -44 -00 -00 -02 -00 -00 -00 -06 -00 -38 -44 -00 -00 -02 -00 -00 -00 -06 -00 -3c -44 -00 -00 -02 -00 -00 -00 -06 -00 -40 -44 -00 -00 -02 -00 -00 -00 -06 -00 -44 -44 -00 -00 -02 -00 -00 -00 -06 -00 -48 -44 -00 -00 -02 -00 -00 -00 -06 -00 -4c -44 -00 -00 -02 -00 -00 -00 -06 -00 -50 -44 -00 -00 -02 -00 -00 -00 -06 -00 -54 -44 -00 -00 -02 -00 -00 -00 -06 -00 -58 -44 -00 -00 -02 -00 -00 -00 -06 -00 -5c -44 -00 -00 -02 -00 -00 -00 -06 -00 -60 -44 -00 -00 -02 -00 -00 -00 -06 -00 -64 -44 -00 -00 -02 -00 -00 -00 -06 -00 -68 -44 -00 -00 -02 -00 -00 -00 -06 -00 -6c -44 -00 -00 -02 -00 -00 -00 -06 -00 -70 -44 -00 -00 -02 -00 -00 -00 -06 -00 -74 -44 -00 -00 -02 -00 -00 -00 -06 -00 -78 -44 -00 -00 -02 -00 -00 -00 -06 -00 -7c -44 -00 -00 -02 -00 -00 -00 -06 -00 -80 -44 -00 -00 -02 -00 -00 -00 -06 -00 -84 -44 -00 -00 -02 -00 -00 -00 -06 -00 -88 -44 -00 -00 -02 -00 -00 -00 -06 -00 -8c -44 -00 -00 -02 -00 -00 -00 -06 -00 -90 -44 -00 -00 -02 -00 -00 -00 -06 -00 -94 -44 -00 -00 -02 -00 -00 -00 -06 -00 -98 -44 -00 -00 -02 -00 -00 -00 -06 -00 -9c -44 -00 -00 -02 -00 -00 -00 -06 -00 -a0 -44 -00 -00 -02 -00 -00 -00 -06 -00 -a4 -44 -00 -00 -02 -00 -00 -00 -06 -00 -a8 -44 -00 -00 -02 -00 -00 -00 -06 -00 -ac -44 -00 -00 -02 -00 -00 -00 -06 -00 -b0 -44 -00 -00 -02 -00 -00 -00 -06 -00 -b4 -44 -00 -00 -02 -00 -00 -00 -06 -00 -b8 -44 -00 -00 -02 -00 -00 -00 -06 -00 -bc -44 -00 -00 -02 -00 -00 -00 -06 -00 -c0 -44 -00 -00 -02 -00 -00 -00 -06 -00 -c4 -44 -00 -00 -02 -00 -00 -00 -06 -00 -c8 -44 -00 -00 -02 -00 -00 -00 -06 -00 -cc -44 -00 -00 -02 -00 -00 -00 -06 -00 -d0 -44 -00 -00 -02 -00 -00 -00 -06 -00 -d4 -44 -00 -00 -02 -00 -00 -00 -06 -00 -d8 -44 -00 -00 -02 -00 -00 -00 -06 -00 -dc -44 -00 -00 -02 -00 -00 -00 -06 -00 -e0 -44 -00 -00 -02 -00 -00 -00 -06 -00 -e4 -44 -00 -00 -02 -00 -00 -00 -06 -00 -e8 -44 -00 -00 -02 -00 -00 -00 -06 -00 -ec -44 -00 -00 -02 -00 -00 -00 -06 -00 -f0 -44 -00 -00 -02 -00 -00 -00 -06 -00 -f4 -44 -00 -00 -02 -00 -00 -00 -06 -00 -f8 -44 -00 -00 -02 -00 -00 -00 -06 -00 -fc -44 -00 -00 -02 -00 -00 -00 -06 -00 -00 -45 -00 -00 -02 -00 -00 -00 -06 -00 -04 -45 -00 -00 -02 -00 -00 -00 -06 -00 -08 -45 -00 -00 -02 -00 -00 -00 -06 -00 -0c -45 -00 -00 -02 -00 -00 -00 -06 -00 -10 -45 -00 -00 -02 -00 -00 -00 -06 -00 -14 -45 -00 -00 -02 -00 -00 -00 -06 -00 -18 -45 -00 -00 -02 -00 -00 -00 -06 -00 -1c -45 -00 -00 -02 -00 -00 -00 -06 -00 -20 -45 -00 +01 00 02 00 @@ -93409,639 +100539,9 @@ fc 00 06 00 +35 24 -45 -00 -00 -02 -00 -00 -00 -06 -00 -28 -45 -00 -00 -02 -00 -00 -00 -06 -00 -2c -45 -00 -00 -02 -00 -00 -00 -06 -00 -30 -45 -00 -00 -02 -00 -00 -00 -06 -00 -34 -45 -00 -00 -02 -00 -00 -00 -06 -00 -38 -45 -00 -00 -02 -00 -00 -00 -06 -00 -3c -45 -00 -00 -02 -00 -00 -00 -06 -00 -40 -45 -00 -00 -02 -00 -00 -00 -06 -00 -44 -45 -00 -00 -02 -00 -00 -00 -06 -00 -48 -45 -00 -00 -02 -00 -00 -00 -06 -00 -4c -45 -00 -00 -02 -00 -00 -00 -06 -00 -50 -45 -00 -00 -02 -00 -00 -00 -06 -00 -54 -45 -00 -00 -02 -00 -00 -00 -06 -00 -58 -45 -00 -00 -02 -00 -00 -00 -06 -00 -5c -45 -00 -00 -02 -00 -00 -00 -06 -00 -60 -45 -00 -00 -02 -00 -00 -00 -06 -00 -64 -45 -00 -00 -02 -00 -00 -00 -06 -00 -68 -45 -00 -00 -02 -00 -00 -00 -06 -00 -6c -45 -00 -00 -02 -00 -00 -00 -06 -00 -70 -45 -00 -00 -02 -00 -00 -00 -06 -00 -74 -45 -00 -00 -02 -00 -00 -00 -06 -00 -78 -45 -00 -00 -02 -00 -00 -00 -06 -00 -7c -45 -00 -00 -02 -00 -00 -00 -06 -00 -80 -45 -00 -00 -02 -00 -00 -00 -06 -00 -84 -45 -00 -00 -02 -00 -00 -00 -06 -00 -88 -45 -00 -00 -02 -00 -00 -00 -06 -00 -8c -45 -00 -00 -02 -00 -00 -00 -06 -00 -90 -45 -00 -00 -02 -00 -00 -00 -06 -00 -94 -45 -00 -00 -02 -00 -00 -00 -06 -00 -98 -45 -00 -00 -02 -00 -00 -00 -06 -00 -9c -45 -00 -00 -02 -00 -00 -00 -06 -00 -a0 -45 -00 -00 -02 -00 -00 -00 -06 -00 -a4 -45 -00 -00 -02 -00 -00 -00 -06 -00 -a8 -45 -00 -00 -02 -00 -00 -00 -06 -00 -ac -45 -00 -00 -02 -00 -00 -00 -06 -00 -b0 -45 -00 -00 -02 -00 -00 -00 -06 -00 -b4 -45 -00 -00 -02 -00 -00 -00 -06 -00 -b8 -45 -00 -00 -02 -00 -00 -00 -06 -00 -bc -45 -00 -00 -02 -00 -00 -00 -06 -00 -c0 -45 -00 -00 -02 -00 -00 -00 -06 -00 -c4 -45 -00 -00 -02 -00 -00 -00 -06 -00 -c8 -45 -00 -00 -02 -00 -00 -00 -06 -00 -cc -45 -00 -00 -02 -00 -00 -00 -06 -00 -d0 -45 -00 -00 -02 -00 -00 -00 -06 -00 -d4 -45 -00 -00 -02 -00 -00 -00 -06 -00 -d8 -45 -00 -00 -02 -00 -00 -00 -06 -00 -dc -45 -00 -00 -02 -00 -00 -00 -06 -00 -e0 -45 -00 -00 -02 -00 -00 -00 -06 -00 -e4 -45 -00 -00 -02 -00 -00 -00 -06 -00 -e8 -45 -00 -00 -02 -00 -00 -00 -06 -00 -ec -45 -00 -00 -02 -00 -00 -00 -06 -00 -f0 -45 -00 -00 -02 -00 -00 -00 -06 -00 -f4 -45 -00 -00 -02 -00 -00 -00 -06 -00 -f8 -45 -00 -00 -02 -00 -00 -00 -06 -00 -fc -45 -00 -00 -02 -00 -00 -00 -06 -00 -00 -46 -00 -00 -02 -00 -00 -00 -06 -00 -04 -46 -00 -00 -02 -00 -00 -00 -06 -00 -08 -46 -00 -00 -02 -00 -00 -00 -06 -00 -0c -46 -00 -00 -02 -00 -00 -00 -06 -00 -10 -46 -00 -00 -02 -00 -00 -00 -06 -00 -14 -46 -00 -00 -02 -00 -00 -00 -06 -00 -18 -46 -00 -00 -02 -00 -00 -00 -06 -00 -1c -46 -00 -00 -02 -00 -00 -00 -06 -00 -20 -46 -00 +01 00 02 00 @@ -94049,639 +100549,9 @@ fc 00 06 00 +39 24 -46 -00 -00 -02 -00 -00 -00 -06 -00 -28 -46 -00 -00 -02 -00 -00 -00 -06 -00 -2c -46 -00 -00 -02 -00 -00 -00 -06 -00 -30 -46 -00 -00 -02 -00 -00 -00 -06 -00 -34 -46 -00 -00 -02 -00 -00 -00 -06 -00 -38 -46 -00 -00 -02 -00 -00 -00 -06 -00 -3c -46 -00 -00 -02 -00 -00 -00 -06 -00 -40 -46 -00 -00 -02 -00 -00 -00 -06 -00 -44 -46 -00 -00 -02 -00 -00 -00 -06 -00 -48 -46 -00 -00 -02 -00 -00 -00 -06 -00 -4c -46 -00 -00 -02 -00 -00 -00 -06 -00 -50 -46 -00 -00 -02 -00 -00 -00 -06 -00 -54 -46 -00 -00 -02 -00 -00 -00 -06 -00 -58 -46 -00 -00 -02 -00 -00 -00 -06 -00 -5c -46 -00 -00 -02 -00 -00 -00 -06 -00 -60 -46 -00 -00 -02 -00 -00 -00 -06 -00 -64 -46 -00 -00 -02 -00 -00 -00 -06 -00 -68 -46 -00 -00 -02 -00 -00 -00 -06 -00 -6c -46 -00 -00 -02 -00 -00 -00 -06 -00 -70 -46 -00 -00 -02 -00 -00 -00 -06 -00 -74 -46 -00 -00 -02 -00 -00 -00 -06 -00 -78 -46 -00 -00 -02 -00 -00 -00 -06 -00 -7c -46 -00 -00 -02 -00 -00 -00 -06 -00 -80 -46 -00 -00 -02 -00 -00 -00 -06 -00 -84 -46 -00 -00 -02 -00 -00 -00 -06 -00 -88 -46 -00 -00 -02 -00 -00 -00 -06 -00 -8c -46 -00 -00 -02 -00 -00 -00 -06 -00 -90 -46 -00 -00 -02 -00 -00 -00 -06 -00 -94 -46 -00 -00 -02 -00 -00 -00 -06 -00 -98 -46 -00 -00 -02 -00 -00 -00 -06 -00 -9c -46 -00 -00 -02 -00 -00 -00 -06 -00 -a0 -46 -00 -00 -02 -00 -00 -00 -06 -00 -a4 -46 -00 -00 -02 -00 -00 -00 -06 -00 -a8 -46 -00 -00 -02 -00 -00 -00 -06 -00 -ac -46 -00 -00 -02 -00 -00 -00 -06 -00 -b0 -46 -00 -00 -02 -00 -00 -00 -06 -00 -b4 -46 -00 -00 -02 -00 -00 -00 -06 -00 -b8 -46 -00 -00 -02 -00 -00 -00 -06 -00 -bc -46 -00 -00 -02 -00 -00 -00 -06 -00 -c0 -46 -00 -00 -02 -00 -00 -00 -06 -00 -c4 -46 -00 -00 -02 -00 -00 -00 -06 -00 -c8 -46 -00 -00 -02 -00 -00 -00 -06 -00 -cc -46 -00 -00 -02 -00 -00 -00 -06 -00 -d0 -46 -00 -00 -02 -00 -00 -00 -06 -00 -d4 -46 -00 -00 -02 -00 -00 -00 -06 -00 -d8 -46 -00 -00 -02 -00 -00 -00 -06 -00 -dc -46 -00 -00 -02 -00 -00 -00 -06 -00 -e0 -46 -00 -00 -02 -00 -00 -00 -06 -00 -e4 -46 -00 -00 -02 -00 -00 -00 -06 -00 -e8 -46 -00 -00 -02 -00 -00 -00 -06 -00 -ec -46 -00 -00 -02 -00 -00 -00 -06 -00 -f0 -46 -00 -00 -02 -00 -00 -00 -06 -00 -f4 -46 -00 -00 -02 -00 -00 -00 -06 -00 -f8 -46 -00 -00 -02 -00 -00 -00 -06 -00 -fc -46 -00 -00 -02 -00 -00 -00 -06 -00 -00 -47 -00 -00 -02 -00 -00 -00 -06 -00 -04 -47 -00 -00 -02 -00 -00 -00 -06 -00 -08 -47 -00 -00 -02 -00 -00 -00 -06 -00 -0c -47 -00 -00 -02 -00 -00 -00 -06 -00 -10 -47 -00 -00 -02 -00 -00 -00 -06 -00 -14 -47 -00 -00 -02 -00 -00 -00 -06 -00 -18 -47 -00 -00 -02 -00 -00 -00 -06 -00 -1c -47 -00 -00 -02 -00 -00 -00 -06 -00 -20 -47 -00 +01 00 02 00 @@ -94689,639 +100559,9 @@ fc 00 06 00 +3d 24 -47 -00 -00 -02 -00 -00 -00 -06 -00 -28 -47 -00 -00 -02 -00 -00 -00 -06 -00 -2c -47 -00 -00 -02 -00 -00 -00 -06 -00 -30 -47 -00 -00 -02 -00 -00 -00 -06 -00 -34 -47 -00 -00 -02 -00 -00 -00 -06 -00 -38 -47 -00 -00 -02 -00 -00 -00 -06 -00 -3c -47 -00 -00 -02 -00 -00 -00 -06 -00 -40 -47 -00 -00 -02 -00 -00 -00 -06 -00 -44 -47 -00 -00 -02 -00 -00 -00 -06 -00 -48 -47 -00 -00 -02 -00 -00 -00 -06 -00 -4c -47 -00 -00 -02 -00 -00 -00 -06 -00 -50 -47 -00 -00 -02 -00 -00 -00 -06 -00 -54 -47 -00 -00 -02 -00 -00 -00 -06 -00 -58 -47 -00 -00 -02 -00 -00 -00 -06 -00 -5c -47 -00 -00 -02 -00 -00 -00 -06 -00 -60 -47 -00 -00 -02 -00 -00 -00 -06 -00 -64 -47 -00 -00 -02 -00 -00 -00 -06 -00 -68 -47 -00 -00 -02 -00 -00 -00 -06 -00 -6c -47 -00 -00 -02 -00 -00 -00 -06 -00 -70 -47 -00 -00 -02 -00 -00 -00 -06 -00 -74 -47 -00 -00 -02 -00 -00 -00 -06 -00 -78 -47 -00 -00 -02 -00 -00 -00 -06 -00 -7c -47 -00 -00 -02 -00 -00 -00 -06 -00 -80 -47 -00 -00 -02 -00 -00 -00 -06 -00 -84 -47 -00 -00 -02 -00 -00 -00 -06 -00 -88 -47 -00 -00 -02 -00 -00 -00 -06 -00 -8c -47 -00 -00 -02 -00 -00 -00 -06 -00 -90 -47 -00 -00 -02 -00 -00 -00 -06 -00 -94 -47 -00 -00 -02 -00 -00 -00 -06 -00 -98 -47 -00 -00 -02 -00 -00 -00 -06 -00 -9c -47 -00 -00 -02 -00 -00 -00 -06 -00 -a0 -47 -00 -00 -02 -00 -00 -00 -06 -00 -a4 -47 -00 -00 -02 -00 -00 -00 -06 -00 -a8 -47 -00 -00 -02 -00 -00 -00 -06 -00 -ac -47 -00 -00 -02 -00 -00 -00 -06 -00 -b0 -47 -00 -00 -02 -00 -00 -00 -06 -00 -b4 -47 -00 -00 -02 -00 -00 -00 -06 -00 -b8 -47 -00 -00 -02 -00 -00 -00 -06 -00 -bc -47 -00 -00 -02 -00 -00 -00 -06 -00 -c0 -47 -00 -00 -02 -00 -00 -00 -06 -00 -c4 -47 -00 -00 -02 -00 -00 -00 -06 -00 -c8 -47 -00 -00 -02 -00 -00 -00 -06 -00 -cc -47 -00 -00 -02 -00 -00 -00 -06 -00 -d0 -47 -00 -00 -02 -00 -00 -00 -06 -00 -d4 -47 -00 -00 -02 -00 -00 -00 -06 -00 -d8 -47 -00 -00 -02 -00 -00 -00 -06 -00 -dc -47 -00 -00 -02 -00 -00 -00 -06 -00 -e0 -47 -00 -00 -02 -00 -00 -00 -06 -00 -e4 -47 -00 -00 -02 -00 -00 -00 -06 -00 -e8 -47 -00 -00 -02 -00 -00 -00 -06 -00 -ec -47 -00 -00 -02 -00 -00 -00 -06 -00 -f0 -47 -00 -00 -02 -00 -00 -00 -06 -00 -f4 -47 -00 -00 -02 -00 -00 -00 -06 -00 -f8 -47 -00 -00 -02 -00 -00 -00 -06 -00 -fc -47 -00 -00 -02 -00 -00 -00 -06 -00 -00 -48 -00 -00 -02 -00 -00 -00 -06 -00 -04 -48 -00 -00 -02 -00 -00 -00 -06 -00 -08 -48 -00 -00 -02 -00 -00 -00 -06 -00 -0c -48 -00 -00 -02 -00 -00 -00 -06 -00 -10 -48 -00 -00 -02 -00 -00 -00 -06 -00 -14 -48 -00 -00 -02 -00 -00 -00 -06 -00 -18 -48 -00 -00 -02 -00 -00 -00 -06 -00 -1c -48 -00 -00 -02 -00 -00 -00 -06 -00 -20 -48 -00 +01 00 02 00 @@ -95329,639 +100569,9 @@ fc 00 06 00 +41 24 -48 -00 -00 -02 -00 -00 -00 -06 -00 -28 -48 -00 -00 -02 -00 -00 -00 -06 -00 -2c -48 -00 -00 -02 -00 -00 -00 -06 -00 -30 -48 -00 -00 -02 -00 -00 -00 -06 -00 -34 -48 -00 -00 -02 -00 -00 -00 -06 -00 -38 -48 -00 -00 -02 -00 -00 -00 -06 -00 -3c -48 -00 -00 -02 -00 -00 -00 -06 -00 -40 -48 -00 -00 -02 -00 -00 -00 -06 -00 -44 -48 -00 -00 -02 -00 -00 -00 -06 -00 -48 -48 -00 -00 -02 -00 -00 -00 -06 -00 -4c -48 -00 -00 -02 -00 -00 -00 -06 -00 -50 -48 -00 -00 -02 -00 -00 -00 -06 -00 -54 -48 -00 -00 -02 -00 -00 -00 -06 -00 -58 -48 -00 -00 -02 -00 -00 -00 -06 -00 -5c -48 -00 -00 -02 -00 -00 -00 -06 -00 -60 -48 -00 -00 -02 -00 -00 -00 -06 -00 -64 -48 -00 -00 -02 -00 -00 -00 -06 -00 -68 -48 -00 -00 -02 -00 -00 -00 -06 -00 -6c -48 -00 -00 -02 -00 -00 -00 -06 -00 -70 -48 -00 -00 -02 -00 -00 -00 -06 -00 -74 -48 -00 -00 -02 -00 -00 -00 -06 -00 -78 -48 -00 -00 -02 -00 -00 -00 -06 -00 -7c -48 -00 -00 -02 -00 -00 -00 -06 -00 -80 -48 -00 -00 -02 -00 -00 -00 -06 -00 -84 -48 -00 -00 -02 -00 -00 -00 -06 -00 -88 -48 -00 -00 -02 -00 -00 -00 -06 -00 -8c -48 -00 -00 -02 -00 -00 -00 -06 -00 -90 -48 -00 -00 -02 -00 -00 -00 -06 -00 -94 -48 -00 -00 -02 -00 -00 -00 -06 -00 -98 -48 -00 -00 -02 -00 -00 -00 -06 -00 -9c -48 -00 -00 -02 -00 -00 -00 -06 -00 -a0 -48 -00 -00 -02 -00 -00 -00 -06 -00 -a4 -48 -00 -00 -02 -00 -00 -00 -06 -00 -a8 -48 -00 -00 -02 -00 -00 -00 -06 -00 -ac -48 -00 -00 -02 -00 -00 -00 -06 -00 -b0 -48 -00 -00 -02 -00 -00 -00 -06 -00 -b4 -48 -00 -00 -02 -00 -00 -00 -06 -00 -b8 -48 -00 -00 -02 -00 -00 -00 -06 -00 -bc -48 -00 -00 -02 -00 -00 -00 -06 -00 -c0 -48 -00 -00 -02 -00 -00 -00 -06 -00 -c4 -48 -00 -00 -02 -00 -00 -00 -06 -00 -c8 -48 -00 -00 -02 -00 -00 -00 -06 -00 -cc -48 -00 -00 -02 -00 -00 -00 -06 -00 -d0 -48 -00 -00 -02 -00 -00 -00 -06 -00 -d4 -48 -00 -00 -02 -00 -00 -00 -06 -00 -d8 -48 -00 -00 -02 -00 -00 -00 -06 -00 -dc -48 -00 -00 -02 -00 -00 -00 -06 -00 -e0 -48 -00 -00 -02 -00 -00 -00 -06 -00 -e4 -48 -00 -00 -02 -00 -00 -00 -06 -00 -e8 -48 -00 -00 -02 -00 -00 -00 -06 -00 -ec -48 -00 -00 -02 -00 -00 -00 -06 -00 -f0 -48 -00 -00 -02 -00 -00 -00 -06 -00 -f4 -48 -00 -00 -02 -00 -00 -00 -06 -00 -f8 -48 -00 -00 -02 -00 -00 -00 -06 -00 -fc -48 -00 -00 -02 -00 -00 -00 -06 -00 -00 -49 -00 -00 -02 -00 -00 -00 -06 -00 -04 -49 -00 -00 -02 -00 -00 -00 -06 -00 -08 -49 -00 -00 -02 -00 -00 -00 -06 -00 -0c -49 -00 -00 -02 -00 -00 -00 -06 -00 -10 -49 -00 -00 -02 -00 -00 -00 -06 -00 -14 -49 -00 -00 -02 -00 -00 -00 -06 -00 -18 -49 -00 -00 -02 -00 -00 -00 -06 -00 -1c -49 -00 -00 -02 -00 -00 -00 -06 -00 -20 -49 -00 +01 00 02 00 @@ -95969,1279 +100579,19 @@ fc 00 06 00 +45 24 +01 +00 +02 +00 +00 +00 +06 +00 49 -00 -00 -02 -00 -00 -00 -06 -00 -28 -49 -00 -00 -02 -00 -00 -00 -06 -00 -2c -49 -00 -00 -02 -00 -00 -00 -06 -00 -30 -49 -00 -00 -02 -00 -00 -00 -06 -00 -34 -49 -00 -00 -02 -00 -00 -00 -06 -00 -38 -49 -00 -00 -02 -00 -00 -00 -06 -00 -3c -49 -00 -00 -02 -00 -00 -00 -06 -00 -40 -49 -00 -00 -02 -00 -00 -00 -06 -00 -44 -49 -00 -00 -02 -00 -00 -00 -06 -00 -48 -49 -00 -00 -02 -00 -00 -00 -06 -00 -4c -49 -00 -00 -02 -00 -00 -00 -06 -00 -50 -49 -00 -00 -02 -00 -00 -00 -06 -00 -54 -49 -00 -00 -02 -00 -00 -00 -06 -00 -58 -49 -00 -00 -02 -00 -00 -00 -06 -00 -5c -49 -00 -00 -02 -00 -00 -00 -06 -00 -60 -49 -00 -00 -02 -00 -00 -00 -06 -00 -64 -49 -00 -00 -02 -00 -00 -00 -06 -00 -68 -49 -00 -00 -02 -00 -00 -00 -06 -00 -6c -49 -00 -00 -02 -00 -00 -00 -06 -00 -70 -49 -00 -00 -02 -00 -00 -00 -06 -00 -74 -49 -00 -00 -02 -00 -00 -00 -06 -00 -78 -49 -00 -00 -02 -00 -00 -00 -06 -00 -7c -49 -00 -00 -02 -00 -00 -00 -06 -00 -80 -49 -00 -00 -02 -00 -00 -00 -06 -00 -84 -49 -00 -00 -02 -00 -00 -00 -06 -00 -88 -49 -00 -00 -02 -00 -00 -00 -06 -00 -8c -49 -00 -00 -02 -00 -00 -00 -06 -00 -90 -49 -00 -00 -02 -00 -00 -00 -06 -00 -94 -49 -00 -00 -02 -00 -00 -00 -06 -00 -98 -49 -00 -00 -02 -00 -00 -00 -06 -00 -9c -49 -00 -00 -02 -00 -00 -00 -06 -00 -a0 -49 -00 -00 -02 -00 -00 -00 -06 -00 -a4 -49 -00 -00 -02 -00 -00 -00 -06 -00 -a8 -49 -00 -00 -02 -00 -00 -00 -06 -00 -ac -49 -00 -00 -02 -00 -00 -00 -06 -00 -b0 -49 -00 -00 -02 -00 -00 -00 -06 -00 -b4 -49 -00 -00 -02 -00 -00 -00 -06 -00 -b8 -49 -00 -00 -02 -00 -00 -00 -06 -00 -bc -49 -00 -00 -02 -00 -00 -00 -06 -00 -c0 -49 -00 -00 -02 -00 -00 -00 -06 -00 -c4 -49 -00 -00 -02 -00 -00 -00 -06 -00 -c8 -49 -00 -00 -02 -00 -00 -00 -06 -00 -cc -49 -00 -00 -02 -00 -00 -00 -06 -00 -d0 -49 -00 -00 -02 -00 -00 -00 -06 -00 -d4 -49 -00 -00 -02 -00 -00 -00 -06 -00 -d8 -49 -00 -00 -02 -00 -00 -00 -06 -00 -dc -49 -00 -00 -02 -00 -00 -00 -06 -00 -e0 -49 -00 -00 -02 -00 -00 -00 -06 -00 -e4 -49 -00 -00 -02 -00 -00 -00 -06 -00 -e8 -49 -00 -00 -02 -00 -00 -00 -06 -00 -ec -49 -00 -00 -02 -00 -00 -00 -06 -00 -f0 -49 -00 -00 -02 -00 -00 -00 -06 -00 -f4 -49 -00 -00 -02 -00 -00 -00 -06 -00 -f8 -49 -00 -00 -02 -00 -00 -00 -06 -00 -fc -49 -00 -00 -02 -00 -00 -00 -06 -00 -00 -4a -00 -00 -02 -00 -00 -00 -06 -00 -04 -4a -00 -00 -02 -00 -00 -00 -06 -00 -08 -4a -00 -00 -02 -00 -00 -00 -06 -00 -0c -4a -00 -00 -02 -00 -00 -00 -06 -00 -10 -4a -00 -00 -02 -00 -00 -00 -06 -00 -14 -4a -00 -00 -02 -00 -00 -00 -06 -00 -18 -4a -00 -00 -02 -00 -00 -00 -06 -00 -1c -4a -00 -00 -02 -00 -00 -00 -06 -00 -20 -4a -00 -00 -02 -00 -00 -00 -06 -00 24 -4a -00 -00 -02 -00 -00 -00 -06 -00 -28 -4a -00 -00 -02 -00 -00 -00 -06 -00 -2c -4a -00 -00 -02 -00 -00 -00 -06 -00 -30 -4a -00 -00 -02 -00 -00 -00 -06 -00 -34 -4a -00 -00 -02 -00 -00 -00 -06 -00 -38 -4a -00 -00 -02 -00 -00 -00 -06 -00 -3c -4a -00 -00 -02 -00 -00 -00 -06 -00 -40 -4a -00 -00 -02 -00 -00 -00 -06 -00 -44 -4a -00 -00 -02 -00 -00 -00 -06 -00 -48 -4a -00 -00 -02 -00 -00 -00 -06 -00 -4c -4a -00 -00 -02 -00 -00 -00 -06 -00 -50 -4a -00 -00 -02 -00 -00 -00 -06 -00 -54 -4a -00 -00 -02 -00 -00 -00 -06 -00 -58 -4a -00 -00 -02 -00 -00 -00 -06 -00 -5c -4a -00 -00 -02 -00 -00 -00 -06 -00 -60 -4a -00 -00 -02 -00 -00 -00 -06 -00 -64 -4a -00 -00 -02 -00 -00 -00 -06 -00 -68 -4a -00 -00 -02 -00 -00 -00 -06 -00 -6c -4a -00 -00 -02 -00 -00 -00 -06 -00 -70 -4a -00 -00 -02 -00 -00 -00 -06 -00 -74 -4a -00 -00 -02 -00 -00 -00 -06 -00 -78 -4a -00 -00 -02 -00 -00 -00 -06 -00 -7c -4a -00 -00 -02 -00 -00 -00 -06 -00 -80 -4a -00 -00 -02 -00 -00 -00 -06 -00 -84 -4a -00 -00 -02 -00 -00 -00 -06 -00 -88 -4a -00 -00 -02 -00 -00 -00 -06 -00 -8c -4a -00 -00 -02 -00 -00 -00 -06 -00 -90 -4a -00 -00 -02 -00 -00 -00 -06 -00 -94 -4a -00 -00 -02 -00 -00 -00 -06 -00 -98 -4a -00 -00 -02 -00 -00 -00 -06 -00 -9c -4a -00 -00 -02 -00 -00 -00 -06 -00 -a0 -4a -00 -00 -02 -00 -00 -00 -06 -00 -a4 -4a -00 -00 -02 -00 -00 -00 -06 -00 -a8 -4a -00 -00 -02 -00 -00 -00 -06 -00 -ac -4a -00 -00 -02 -00 -00 -00 -06 -00 -b0 -4a -00 -00 -02 -00 -00 -00 -06 -00 -b4 -4a -00 -00 -02 -00 -00 -00 -06 -00 -b8 -4a -00 -00 -02 -00 -00 -00 -06 -00 -bc -4a -00 -00 -02 -00 -00 -00 -06 -00 -c0 -4a -00 -00 -02 -00 -00 -00 -06 -00 -c4 -4a -00 -00 -02 -00 -00 -00 -06 -00 -c8 -4a -00 -00 -02 -00 -00 -00 -06 -00 -cc -4a -00 -00 -02 -00 -00 -00 -06 -00 -d0 -4a -00 -00 -02 -00 -00 -00 -06 -00 -d4 -4a -00 -00 -02 -00 -00 -00 -06 -00 -d8 -4a -00 -00 -02 -00 -00 -00 -06 -00 -dc -4a -00 -00 -02 -00 -00 -00 -06 -00 -e0 -4a -00 -00 -02 -00 -00 -00 -06 -00 -e4 -4a -00 -00 -02 -00 -00 -00 -06 -00 -e8 -4a -00 -00 -02 -00 -00 -00 -06 -00 -ec -4a -00 -00 -02 -00 -00 -00 -06 -00 -f0 -4a -00 -00 -02 -00 -00 -00 -06 -00 -f4 -4a -00 -00 -02 -00 -00 -00 -06 -00 -f8 -4a -00 -00 -02 -00 -00 -00 -06 -00 -fc -4a -00 -00 -02 -00 -00 -00 -06 -00 -00 -4b -00 -00 -02 -00 -00 -00 -06 -00 -04 -4b -00 -00 -02 -00 -00 -00 -06 -00 -08 -4b -00 -00 -02 -00 -00 -00 -06 -00 -0c -4b -00 -00 -02 -00 -00 -00 -06 -00 -10 -4b -00 -00 -02 -00 -00 -00 -06 -00 -14 -4b -00 -00 -02 -00 -00 -00 -06 -00 -18 -4b -00 -00 -02 -00 -00 -00 -06 -00 -1c -4b -00 -00 -02 -00 -00 -00 -06 -00 -20 -4b -00 +01 00 02 00 @@ -97249,639 +100599,9 @@ fc 00 06 00 +4d 24 -4b -00 -00 -02 -00 -00 -00 -06 -00 -28 -4b -00 -00 -02 -00 -00 -00 -06 -00 -2c -4b -00 -00 -02 -00 -00 -00 -06 -00 -30 -4b -00 -00 -02 -00 -00 -00 -06 -00 -34 -4b -00 -00 -02 -00 -00 -00 -06 -00 -38 -4b -00 -00 -02 -00 -00 -00 -06 -00 -3c -4b -00 -00 -02 -00 -00 -00 -06 -00 -40 -4b -00 -00 -02 -00 -00 -00 -06 -00 -44 -4b -00 -00 -02 -00 -00 -00 -06 -00 -48 -4b -00 -00 -02 -00 -00 -00 -06 -00 -4c -4b -00 -00 -02 -00 -00 -00 -06 -00 -50 -4b -00 -00 -02 -00 -00 -00 -06 -00 -54 -4b -00 -00 -02 -00 -00 -00 -06 -00 -58 -4b -00 -00 -02 -00 -00 -00 -06 -00 -5c -4b -00 -00 -02 -00 -00 -00 -06 -00 -60 -4b -00 -00 -02 -00 -00 -00 -06 -00 -64 -4b -00 -00 -02 -00 -00 -00 -06 -00 -68 -4b -00 -00 -02 -00 -00 -00 -06 -00 -6c -4b -00 -00 -02 -00 -00 -00 -06 -00 -70 -4b -00 -00 -02 -00 -00 -00 -06 -00 -74 -4b -00 -00 -02 -00 -00 -00 -06 -00 -78 -4b -00 -00 -02 -00 -00 -00 -06 -00 -7c -4b -00 -00 -02 -00 -00 -00 -06 -00 -80 -4b -00 -00 -02 -00 -00 -00 -06 -00 -84 -4b -00 -00 -02 -00 -00 -00 -06 -00 -88 -4b -00 -00 -02 -00 -00 -00 -06 -00 -8c -4b -00 -00 -02 -00 -00 -00 -06 -00 -90 -4b -00 -00 -02 -00 -00 -00 -06 -00 -94 -4b -00 -00 -02 -00 -00 -00 -06 -00 -98 -4b -00 -00 -02 -00 -00 -00 -06 -00 -9c -4b -00 -00 -02 -00 -00 -00 -06 -00 -a0 -4b -00 -00 -02 -00 -00 -00 -06 -00 -a4 -4b -00 -00 -02 -00 -00 -00 -06 -00 -a8 -4b -00 -00 -02 -00 -00 -00 -06 -00 -ac -4b -00 -00 -02 -00 -00 -00 -06 -00 -b0 -4b -00 -00 -02 -00 -00 -00 -06 -00 -b4 -4b -00 -00 -02 -00 -00 -00 -06 -00 -b8 -4b -00 -00 -02 -00 -00 -00 -06 -00 -bc -4b -00 -00 -02 -00 -00 -00 -06 -00 -c0 -4b -00 -00 -02 -00 -00 -00 -06 -00 -c4 -4b -00 -00 -02 -00 -00 -00 -06 -00 -c8 -4b -00 -00 -02 -00 -00 -00 -06 -00 -cc -4b -00 -00 -02 -00 -00 -00 -06 -00 -d0 -4b -00 -00 -02 -00 -00 -00 -06 -00 -d4 -4b -00 -00 -02 -00 -00 -00 -06 -00 -d8 -4b -00 -00 -02 -00 -00 -00 -06 -00 -dc -4b -00 -00 -02 -00 -00 -00 -06 -00 -e0 -4b -00 -00 -02 -00 -00 -00 -06 -00 -e4 -4b -00 -00 -02 -00 -00 -00 -06 -00 -e8 -4b -00 -00 -02 -00 -00 -00 -06 -00 -ec -4b -00 -00 -02 -00 -00 -00 -06 -00 -f0 -4b -00 -00 -02 -00 -00 -00 -06 -00 -f4 -4b -00 -00 -02 -00 -00 -00 -06 -00 -f8 -4b -00 -00 -02 -00 -00 -00 -06 -00 -fc -4b -00 -00 -02 -00 -00 -00 -06 -00 -00 -4c -00 -00 -02 -00 -00 -00 -06 -00 -04 -4c -00 -00 -02 -00 -00 -00 -06 -00 -08 -4c -00 -00 -02 -00 -00 -00 -06 -00 -0c -4c -00 -00 -02 -00 -00 -00 -06 -00 -10 -4c -00 -00 -02 -00 -00 -00 -06 -00 -14 -4c -00 -00 -02 -00 -00 -00 -06 -00 -18 -4c -00 -00 -02 -00 -00 -00 -06 -00 -1c -4c -00 -00 -02 -00 -00 -00 -06 -00 -20 -4c -00 +01 00 02 00 @@ -97889,639 +100609,9 @@ fc 00 06 00 +51 24 -4c -00 -00 -02 -00 -00 -00 -06 -00 -28 -4c -00 -00 -02 -00 -00 -00 -06 -00 -2c -4c -00 -00 -02 -00 -00 -00 -06 -00 -30 -4c -00 -00 -02 -00 -00 -00 -06 -00 -34 -4c -00 -00 -02 -00 -00 -00 -06 -00 -38 -4c -00 -00 -02 -00 -00 -00 -06 -00 -3c -4c -00 -00 -02 -00 -00 -00 -06 -00 -40 -4c -00 -00 -02 -00 -00 -00 -06 -00 -44 -4c -00 -00 -02 -00 -00 -00 -06 -00 -48 -4c -00 -00 -02 -00 -00 -00 -06 -00 -4c -4c -00 -00 -02 -00 -00 -00 -06 -00 -50 -4c -00 -00 -02 -00 -00 -00 -06 -00 -54 -4c -00 -00 -02 -00 -00 -00 -06 -00 -58 -4c -00 -00 -02 -00 -00 -00 -06 -00 -5c -4c -00 -00 -02 -00 -00 -00 -06 -00 -60 -4c -00 -00 -02 -00 -00 -00 -06 -00 -64 -4c -00 -00 -02 -00 -00 -00 -06 -00 -68 -4c -00 -00 -02 -00 -00 -00 -06 -00 -6c -4c -00 -00 -02 -00 -00 -00 -06 -00 -70 -4c -00 -00 -02 -00 -00 -00 -06 -00 -74 -4c -00 -00 -02 -00 -00 -00 -06 -00 -78 -4c -00 -00 -02 -00 -00 -00 -06 -00 -7c -4c -00 -00 -02 -00 -00 -00 -06 -00 -80 -4c -00 -00 -02 -00 -00 -00 -06 -00 -84 -4c -00 -00 -02 -00 -00 -00 -06 -00 -88 -4c -00 -00 -02 -00 -00 -00 -06 -00 -8c -4c -00 -00 -02 -00 -00 -00 -06 -00 -90 -4c -00 -00 -02 -00 -00 -00 -06 -00 -94 -4c -00 -00 -02 -00 -00 -00 -06 -00 -98 -4c -00 -00 -02 -00 -00 -00 -06 -00 -9c -4c -00 -00 -02 -00 -00 -00 -06 -00 -a0 -4c -00 -00 -02 -00 -00 -00 -06 -00 -a4 -4c -00 -00 -02 -00 -00 -00 -06 -00 -a8 -4c -00 -00 -02 -00 -00 -00 -06 -00 -ac -4c -00 -00 -02 -00 -00 -00 -06 -00 -b0 -4c -00 -00 -02 -00 -00 -00 -06 -00 -b4 -4c -00 -00 -02 -00 -00 -00 -06 -00 -b8 -4c -00 -00 -02 -00 -00 -00 -06 -00 -bc -4c -00 -00 -02 -00 -00 -00 -06 -00 -c0 -4c -00 -00 -02 -00 -00 -00 -06 -00 -c4 -4c -00 -00 -02 -00 -00 -00 -06 -00 -c8 -4c -00 -00 -02 -00 -00 -00 -06 -00 -cc -4c -00 -00 -02 -00 -00 -00 -06 -00 -d0 -4c -00 -00 -02 -00 -00 -00 -06 -00 -d4 -4c -00 -00 -02 -00 -00 -00 -06 -00 -d8 -4c -00 -00 -02 -00 -00 -00 -06 -00 -dc -4c -00 -00 -02 -00 -00 -00 -06 -00 -e0 -4c -00 -00 -02 -00 -00 -00 -06 -00 -e4 -4c -00 -00 -02 -00 -00 -00 -06 -00 -e8 -4c -00 -00 -02 -00 -00 -00 -06 -00 -ec -4c -00 -00 -02 -00 -00 -00 -06 -00 -f0 -4c -00 -00 -02 -00 -00 -00 -06 -00 -f4 -4c -00 -00 -02 -00 -00 -00 -06 -00 -f8 -4c -00 -00 -02 -00 -00 -00 -06 -00 -fc -4c -00 -00 -02 -00 -00 -00 -06 -00 -00 -4d -00 -00 -02 -00 -00 -00 -06 -00 -04 -4d -00 -00 -02 -00 -00 -00 -06 -00 -08 -4d -00 -00 -02 -00 -00 -00 -06 -00 -0c -4d -00 -00 -02 -00 -00 -00 -06 -00 -10 -4d -00 -00 -02 -00 -00 -00 -06 -00 -14 -4d -00 -00 -02 -00 -00 -00 -06 -00 -18 -4d -00 -00 -02 -00 -00 -00 -06 -00 -1c -4d -00 -00 -02 -00 -00 -00 -06 -00 -20 -4d -00 +01 00 02 00 @@ -98529,639 +100619,9 @@ fc 00 06 00 +55 24 -4d -00 -00 -02 -00 -00 -00 -06 -00 -28 -4d -00 -00 -02 -00 -00 -00 -06 -00 -2c -4d -00 -00 -02 -00 -00 -00 -06 -00 -30 -4d -00 -00 -02 -00 -00 -00 -06 -00 -34 -4d -00 -00 -02 -00 -00 -00 -06 -00 -38 -4d -00 -00 -02 -00 -00 -00 -06 -00 -3c -4d -00 -00 -02 -00 -00 -00 -06 -00 -40 -4d -00 -00 -02 -00 -00 -00 -06 -00 -44 -4d -00 -00 -02 -00 -00 -00 -06 -00 -48 -4d -00 -00 -02 -00 -00 -00 -06 -00 -4c -4d -00 -00 -02 -00 -00 -00 -06 -00 -50 -4d -00 -00 -02 -00 -00 -00 -06 -00 -54 -4d -00 -00 -02 -00 -00 -00 -06 -00 -58 -4d -00 -00 -02 -00 -00 -00 -06 -00 -5c -4d -00 -00 -02 -00 -00 -00 -06 -00 -60 -4d -00 -00 -02 -00 -00 -00 -06 -00 -64 -4d -00 -00 -02 -00 -00 -00 -06 -00 -68 -4d -00 -00 -02 -00 -00 -00 -06 -00 -6c -4d -00 -00 -02 -00 -00 -00 -06 -00 -70 -4d -00 -00 -02 -00 -00 -00 -06 -00 -74 -4d -00 -00 -02 -00 -00 -00 -06 -00 -78 -4d -00 -00 -02 -00 -00 -00 -06 -00 -7c -4d -00 -00 -02 -00 -00 -00 -06 -00 -80 -4d -00 -00 -02 -00 -00 -00 -06 -00 -84 -4d -00 -00 -02 -00 -00 -00 -06 -00 -88 -4d -00 -00 -02 -00 -00 -00 -06 -00 -8c -4d -00 -00 -02 -00 -00 -00 -06 -00 -90 -4d -00 -00 -02 -00 -00 -00 -06 -00 -94 -4d -00 -00 -02 -00 -00 -00 -06 -00 -98 -4d -00 -00 -02 -00 -00 -00 -06 -00 -9c -4d -00 -00 -02 -00 -00 -00 -06 -00 -a0 -4d -00 -00 -02 -00 -00 -00 -06 -00 -a4 -4d -00 -00 -02 -00 -00 -00 -06 -00 -a8 -4d -00 -00 -02 -00 -00 -00 -06 -00 -ac -4d -00 -00 -02 -00 -00 -00 -06 -00 -b0 -4d -00 -00 -02 -00 -00 -00 -06 -00 -b4 -4d -00 -00 -02 -00 -00 -00 -06 -00 -b8 -4d -00 -00 -02 -00 -00 -00 -06 -00 -bc -4d -00 -00 -02 -00 -00 -00 -06 -00 -c0 -4d -00 -00 -02 -00 -00 -00 -06 -00 -c4 -4d -00 -00 -02 -00 -00 -00 -06 -00 -c8 -4d -00 -00 -02 -00 -00 -00 -06 -00 -cc -4d -00 -00 -02 -00 -00 -00 -06 -00 -d0 -4d -00 -00 -02 -00 -00 -00 -06 -00 -d4 -4d -00 -00 -02 -00 -00 -00 -06 -00 -d8 -4d -00 -00 -02 -00 -00 -00 -06 -00 -dc -4d -00 -00 -02 -00 -00 -00 -06 -00 -e0 -4d -00 -00 -02 -00 -00 -00 -06 -00 -e4 -4d -00 -00 -02 -00 -00 -00 -06 -00 -e8 -4d -00 -00 -02 -00 -00 -00 -06 -00 -ec -4d -00 -00 -02 -00 -00 -00 -06 -00 -f0 -4d -00 -00 -02 -00 -00 -00 -06 -00 -f4 -4d -00 -00 -02 -00 -00 -00 -06 -00 -f8 -4d -00 -00 -02 -00 -00 -00 -06 -00 -fc -4d -00 -00 -02 -00 -00 -00 -06 -00 -00 -4e -00 -00 -02 -00 -00 -00 -06 -00 -04 -4e -00 -00 -02 -00 -00 -00 -06 -00 -08 -4e -00 -00 -02 -00 -00 -00 -06 -00 -0c -4e -00 -00 -02 -00 -00 -00 -06 -00 -10 -4e -00 -00 -02 -00 -00 -00 -06 -00 -14 -4e -00 -00 -02 -00 -00 -00 -06 -00 -18 -4e -00 -00 -02 -00 -00 -00 -06 -00 -1c -4e -00 -00 -02 -00 -00 -00 -06 -00 -20 -4e -00 +01 00 02 00 @@ -99169,639 +100629,9 @@ fc 00 06 00 +59 24 -4e -00 -00 -02 -00 -00 -00 -06 -00 -28 -4e -00 -00 -02 -00 -00 -00 -06 -00 -2c -4e -00 -00 -02 -00 -00 -00 -06 -00 -30 -4e -00 -00 -02 -00 -00 -00 -06 -00 -34 -4e -00 -00 -02 -00 -00 -00 -06 -00 -38 -4e -00 -00 -02 -00 -00 -00 -06 -00 -3c -4e -00 -00 -02 -00 -00 -00 -06 -00 -40 -4e -00 -00 -02 -00 -00 -00 -06 -00 -44 -4e -00 -00 -02 -00 -00 -00 -06 -00 -48 -4e -00 -00 -02 -00 -00 -00 -06 -00 -4c -4e -00 -00 -02 -00 -00 -00 -06 -00 -50 -4e -00 -00 -02 -00 -00 -00 -06 -00 -54 -4e -00 -00 -02 -00 -00 -00 -06 -00 -58 -4e -00 -00 -02 -00 -00 -00 -06 -00 -5c -4e -00 -00 -02 -00 -00 -00 -06 -00 -60 -4e -00 -00 -02 -00 -00 -00 -06 -00 -64 -4e -00 -00 -02 -00 -00 -00 -06 -00 -68 -4e -00 -00 -02 -00 -00 -00 -06 -00 -6c -4e -00 -00 -02 -00 -00 -00 -06 -00 -70 -4e -00 -00 -02 -00 -00 -00 -06 -00 -74 -4e -00 -00 -02 -00 -00 -00 -06 -00 -78 -4e -00 -00 -02 -00 -00 -00 -06 -00 -7c -4e -00 -00 -02 -00 -00 -00 -06 -00 -80 -4e -00 -00 -02 -00 -00 -00 -06 -00 -84 -4e -00 -00 -02 -00 -00 -00 -06 -00 -88 -4e -00 -00 -02 -00 -00 -00 -06 -00 -8c -4e -00 -00 -02 -00 -00 -00 -06 -00 -90 -4e -00 -00 -02 -00 -00 -00 -06 -00 -94 -4e -00 -00 -02 -00 -00 -00 -06 -00 -98 -4e -00 -00 -02 -00 -00 -00 -06 -00 -9c -4e -00 -00 -02 -00 -00 -00 -06 -00 -a0 -4e -00 -00 -02 -00 -00 -00 -06 -00 -a4 -4e -00 -00 -02 -00 -00 -00 -06 -00 -a8 -4e -00 -00 -02 -00 -00 -00 -06 -00 -ac -4e -00 -00 -02 -00 -00 -00 -06 -00 -b0 -4e -00 -00 -02 -00 -00 -00 -06 -00 -b4 -4e -00 -00 -02 -00 -00 -00 -06 -00 -b8 -4e -00 -00 -02 -00 -00 -00 -06 -00 -bc -4e -00 -00 -02 -00 -00 -00 -06 -00 -c0 -4e -00 -00 -02 -00 -00 -00 -06 -00 -c4 -4e -00 -00 -02 -00 -00 -00 -06 -00 -c8 -4e -00 -00 -02 -00 -00 -00 -06 -00 -cc -4e -00 -00 -02 -00 -00 -00 -06 -00 -d0 -4e -00 -00 -02 -00 -00 -00 -06 -00 -d4 -4e -00 -00 -02 -00 -00 -00 -06 -00 -d8 -4e -00 -00 -02 -00 -00 -00 -06 -00 -dc -4e -00 -00 -02 -00 -00 -00 -06 -00 -e0 -4e -00 -00 -02 -00 -00 -00 -06 -00 -e4 -4e -00 -00 -02 -00 -00 -00 -06 -00 -e8 -4e -00 -00 -02 -00 -00 -00 -06 -00 -ec -4e -00 -00 -02 -00 -00 -00 -06 -00 -f0 -4e -00 -00 -02 -00 -00 -00 -06 -00 -f4 -4e -00 -00 -02 -00 -00 -00 -06 -00 -f8 -4e -00 -00 -02 -00 -00 -00 -06 -00 -fc -4e -00 -00 -02 -00 -00 -00 -06 -00 -00 -4f -00 -00 -02 -00 -00 -00 -06 -00 -04 -4f -00 -00 -02 -00 -00 -00 -06 -00 -08 -4f -00 -00 -02 -00 -00 -00 -06 -00 -0c -4f -00 -00 -02 -00 -00 -00 -06 -00 -10 -4f -00 -00 -02 -00 -00 -00 -06 -00 -14 -4f -00 -00 -02 -00 -00 -00 -06 -00 -18 -4f -00 -00 -02 -00 -00 -00 -06 -00 -1c -4f -00 -00 -02 -00 -00 -00 -06 -00 -20 -4f -00 +01 00 02 00 @@ -99809,639 +100639,9 @@ fc 00 06 00 +5d 24 -4f -00 -00 -02 -00 -00 -00 -06 -00 -28 -4f -00 -00 -02 -00 -00 -00 -06 -00 -2c -4f -00 -00 -02 -00 -00 -00 -06 -00 -30 -4f -00 -00 -02 -00 -00 -00 -06 -00 -34 -4f -00 -00 -02 -00 -00 -00 -06 -00 -38 -4f -00 -00 -02 -00 -00 -00 -06 -00 -3c -4f -00 -00 -02 -00 -00 -00 -06 -00 -40 -4f -00 -00 -02 -00 -00 -00 -06 -00 -44 -4f -00 -00 -02 -00 -00 -00 -06 -00 -48 -4f -00 -00 -02 -00 -00 -00 -06 -00 -4c -4f -00 -00 -02 -00 -00 -00 -06 -00 -50 -4f -00 -00 -02 -00 -00 -00 -06 -00 -54 -4f -00 -00 -02 -00 -00 -00 -06 -00 -58 -4f -00 -00 -02 -00 -00 -00 -06 -00 -5c -4f -00 -00 -02 -00 -00 -00 -06 -00 -60 -4f -00 -00 -02 -00 -00 -00 -06 -00 -64 -4f -00 -00 -02 -00 -00 -00 -06 -00 -68 -4f -00 -00 -02 -00 -00 -00 -06 -00 -6c -4f -00 -00 -02 -00 -00 -00 -06 -00 -70 -4f -00 -00 -02 -00 -00 -00 -06 -00 -74 -4f -00 -00 -02 -00 -00 -00 -06 -00 -78 -4f -00 -00 -02 -00 -00 -00 -06 -00 -7c -4f -00 -00 -02 -00 -00 -00 -06 -00 -80 -4f -00 -00 -02 -00 -00 -00 -06 -00 -84 -4f -00 -00 -02 -00 -00 -00 -06 -00 -88 -4f -00 -00 -02 -00 -00 -00 -06 -00 -8c -4f -00 -00 -02 -00 -00 -00 -06 -00 -90 -4f -00 -00 -02 -00 -00 -00 -06 -00 -94 -4f -00 -00 -02 -00 -00 -00 -06 -00 -98 -4f -00 -00 -02 -00 -00 -00 -06 -00 -9c -4f -00 -00 -02 -00 -00 -00 -06 -00 -a0 -4f -00 -00 -02 -00 -00 -00 -06 -00 -a4 -4f -00 -00 -02 -00 -00 -00 -06 -00 -a8 -4f -00 -00 -02 -00 -00 -00 -06 -00 -ac -4f -00 -00 -02 -00 -00 -00 -06 -00 -b0 -4f -00 -00 -02 -00 -00 -00 -06 -00 -b4 -4f -00 -00 -02 -00 -00 -00 -06 -00 -b8 -4f -00 -00 -02 -00 -00 -00 -06 -00 -bc -4f -00 -00 -02 -00 -00 -00 -06 -00 -c0 -4f -00 -00 -02 -00 -00 -00 -06 -00 -c4 -4f -00 -00 -02 -00 -00 -00 -06 -00 -c8 -4f -00 -00 -02 -00 -00 -00 -06 -00 -cc -4f -00 -00 -02 -00 -00 -00 -06 -00 -d0 -4f -00 -00 -02 -00 -00 -00 -06 -00 -d4 -4f -00 -00 -02 -00 -00 -00 -06 -00 -d8 -4f -00 -00 -02 -00 -00 -00 -06 -00 -dc -4f -00 -00 -02 -00 -00 -00 -06 -00 -e0 -4f -00 -00 -02 -00 -00 -00 -06 -00 -e4 -4f -00 -00 -02 -00 -00 -00 -06 -00 -e8 -4f -00 -00 -02 -00 -00 -00 -06 -00 -ec -4f -00 -00 -02 -00 -00 -00 -06 -00 -f0 -4f -00 -00 -02 -00 -00 -00 -06 -00 -f4 -4f -00 -00 -02 -00 -00 -00 -06 -00 -f8 -4f -00 -00 -02 -00 -00 -00 -06 -00 -fc -4f -00 -00 -02 -00 -00 -00 -06 -00 -00 -50 -00 -00 -02 -00 -00 -00 -06 -00 -04 -50 -00 -00 -02 -00 -00 -00 -06 -00 -08 -50 -00 -00 -02 -00 -00 -00 -06 -00 -0c -50 -00 -00 -02 -00 -00 -00 -06 -00 -10 -50 -00 -00 -02 -00 -00 -00 -06 -00 -14 -50 -00 -00 -02 -00 -00 -00 -06 -00 -18 -50 -00 -00 -02 -00 -00 -00 -06 -00 -1c -50 -00 -00 -02 -00 -00 -00 -06 -00 -20 -50 -00 +01 00 02 00 @@ -100449,639 +100649,9 @@ fc 00 06 00 +61 24 -50 -00 -00 -02 -00 -00 -00 -06 -00 -28 -50 -00 -00 -02 -00 -00 -00 -06 -00 -2c -50 -00 -00 -02 -00 -00 -00 -06 -00 -30 -50 -00 -00 -02 -00 -00 -00 -06 -00 -34 -50 -00 -00 -02 -00 -00 -00 -06 -00 -38 -50 -00 -00 -02 -00 -00 -00 -06 -00 -3c -50 -00 -00 -02 -00 -00 -00 -06 -00 -40 -50 -00 -00 -02 -00 -00 -00 -06 -00 -44 -50 -00 -00 -02 -00 -00 -00 -06 -00 -48 -50 -00 -00 -02 -00 -00 -00 -06 -00 -4c -50 -00 -00 -02 -00 -00 -00 -06 -00 -50 -50 -00 -00 -02 -00 -00 -00 -06 -00 -54 -50 -00 -00 -02 -00 -00 -00 -06 -00 -58 -50 -00 -00 -02 -00 -00 -00 -06 -00 -5c -50 -00 -00 -02 -00 -00 -00 -06 -00 -60 -50 -00 -00 -02 -00 -00 -00 -06 -00 -64 -50 -00 -00 -02 -00 -00 -00 -06 -00 -68 -50 -00 -00 -02 -00 -00 -00 -06 -00 -6c -50 -00 -00 -02 -00 -00 -00 -06 -00 -70 -50 -00 -00 -02 -00 -00 -00 -06 -00 -74 -50 -00 -00 -02 -00 -00 -00 -06 -00 -78 -50 -00 -00 -02 -00 -00 -00 -06 -00 -7c -50 -00 -00 -02 -00 -00 -00 -06 -00 -80 -50 -00 -00 -02 -00 -00 -00 -06 -00 -84 -50 -00 -00 -02 -00 -00 -00 -06 -00 -88 -50 -00 -00 -02 -00 -00 -00 -06 -00 -8c -50 -00 -00 -02 -00 -00 -00 -06 -00 -90 -50 -00 -00 -02 -00 -00 -00 -06 -00 -94 -50 -00 -00 -02 -00 -00 -00 -06 -00 -98 -50 -00 -00 -02 -00 -00 -00 -06 -00 -9c -50 -00 -00 -02 -00 -00 -00 -06 -00 -a0 -50 -00 -00 -02 -00 -00 -00 -06 -00 -a4 -50 -00 -00 -02 -00 -00 -00 -06 -00 -a8 -50 -00 -00 -02 -00 -00 -00 -06 -00 -ac -50 -00 -00 -02 -00 -00 -00 -06 -00 -b0 -50 -00 -00 -02 -00 -00 -00 -06 -00 -b4 -50 -00 -00 -02 -00 -00 -00 -06 -00 -b8 -50 -00 -00 -02 -00 -00 -00 -06 -00 -bc -50 -00 -00 -02 -00 -00 -00 -06 -00 -c0 -50 -00 -00 -02 -00 -00 -00 -06 -00 -c4 -50 -00 -00 -02 -00 -00 -00 -06 -00 -c8 -50 -00 -00 -02 -00 -00 -00 -06 -00 -cc -50 -00 -00 -02 -00 -00 -00 -06 -00 -d0 -50 -00 -00 -02 -00 -00 -00 -06 -00 -d4 -50 -00 -00 -02 -00 -00 -00 -06 -00 -d8 -50 -00 -00 -02 -00 -00 -00 -06 -00 -dc -50 -00 -00 -02 -00 -00 -00 -06 -00 -e0 -50 -00 -00 -02 -00 -00 -00 -06 -00 -e4 -50 -00 -00 -02 -00 -00 -00 -06 -00 -e8 -50 -00 -00 -02 -00 -00 -00 -06 -00 -ec -50 -00 -00 -02 -00 -00 -00 -06 -00 -f0 -50 -00 -00 -02 -00 -00 -00 -06 -00 -f4 -50 -00 -00 -02 -00 -00 -00 -06 -00 -f8 -50 -00 -00 -02 -00 -00 -00 -06 -00 -fc -50 -00 -00 -02 -00 -00 -00 -06 -00 -00 -51 -00 -00 -02 -00 -00 -00 -06 -00 -04 -51 -00 -00 -02 -00 -00 -00 -06 -00 -08 -51 -00 -00 -02 -00 -00 -00 -06 -00 -0c -51 -00 -00 -02 -00 -00 -00 -06 -00 -10 -51 -00 -00 -02 -00 -00 -00 -06 -00 -14 -51 -00 -00 -02 -00 -00 -00 -06 -00 -18 -51 -00 -00 -02 -00 -00 -00 -06 -00 -1c -51 -00 -00 -02 -00 -00 -00 -06 -00 -20 -51 -00 +01 00 02 00 @@ -101089,639 +100659,9 @@ fc 00 06 00 +65 24 -51 -00 -00 -02 -00 -00 -00 -06 -00 -28 -51 -00 -00 -02 -00 -00 -00 -06 -00 -2c -51 -00 -00 -02 -00 -00 -00 -06 -00 -30 -51 -00 -00 -02 -00 -00 -00 -06 -00 -34 -51 -00 -00 -02 -00 -00 -00 -06 -00 -38 -51 -00 -00 -02 -00 -00 -00 -06 -00 -3c -51 -00 -00 -02 -00 -00 -00 -06 -00 -40 -51 -00 -00 -02 -00 -00 -00 -06 -00 -44 -51 -00 -00 -02 -00 -00 -00 -06 -00 -48 -51 -00 -00 -02 -00 -00 -00 -06 -00 -4c -51 -00 -00 -02 -00 -00 -00 -06 -00 -50 -51 -00 -00 -02 -00 -00 -00 -06 -00 -54 -51 -00 -00 -02 -00 -00 -00 -06 -00 -58 -51 -00 -00 -02 -00 -00 -00 -06 -00 -5c -51 -00 -00 -02 -00 -00 -00 -06 -00 -60 -51 -00 -00 -02 -00 -00 -00 -06 -00 -64 -51 -00 -00 -02 -00 -00 -00 -06 -00 -68 -51 -00 -00 -02 -00 -00 -00 -06 -00 -6c -51 -00 -00 -02 -00 -00 -00 -06 -00 -70 -51 -00 -00 -02 -00 -00 -00 -06 -00 -74 -51 -00 -00 -02 -00 -00 -00 -06 -00 -78 -51 -00 -00 -02 -00 -00 -00 -06 -00 -7c -51 -00 -00 -02 -00 -00 -00 -06 -00 -80 -51 -00 -00 -02 -00 -00 -00 -06 -00 -84 -51 -00 -00 -02 -00 -00 -00 -06 -00 -88 -51 -00 -00 -02 -00 -00 -00 -06 -00 -8c -51 -00 -00 -02 -00 -00 -00 -06 -00 -90 -51 -00 -00 -02 -00 -00 -00 -06 -00 -94 -51 -00 -00 -02 -00 -00 -00 -06 -00 -98 -51 -00 -00 -02 -00 -00 -00 -06 -00 -9c -51 -00 -00 -02 -00 -00 -00 -06 -00 -a0 -51 -00 -00 -02 -00 -00 -00 -06 -00 -a4 -51 -00 -00 -02 -00 -00 -00 -06 -00 -a8 -51 -00 -00 -02 -00 -00 -00 -06 -00 -ac -51 -00 -00 -02 -00 -00 -00 -06 -00 -b0 -51 -00 -00 -02 -00 -00 -00 -06 -00 -b4 -51 -00 -00 -02 -00 -00 -00 -06 -00 -b8 -51 -00 -00 -02 -00 -00 -00 -06 -00 -bc -51 -00 -00 -02 -00 -00 -00 -06 -00 -c0 -51 -00 -00 -02 -00 -00 -00 -06 -00 -c4 -51 -00 -00 -02 -00 -00 -00 -06 -00 -c8 -51 -00 -00 -02 -00 -00 -00 -06 -00 -cc -51 -00 -00 -02 -00 -00 -00 -06 -00 -d0 -51 -00 -00 -02 -00 -00 -00 -06 -00 -d4 -51 -00 -00 -02 -00 -00 -00 -06 -00 -d8 -51 -00 -00 -02 -00 -00 -00 -06 -00 -dc -51 -00 -00 -02 -00 -00 -00 -06 -00 -e0 -51 -00 -00 -02 -00 -00 -00 -06 -00 -e4 -51 -00 -00 -02 -00 -00 -00 -06 -00 -e8 -51 -00 -00 -02 -00 -00 -00 -06 -00 -ec -51 -00 -00 -02 -00 -00 -00 -06 -00 -f0 -51 -00 -00 -02 -00 -00 -00 -06 -00 -f4 -51 -00 -00 -02 -00 -00 -00 -06 -00 -f8 -51 -00 -00 -02 -00 -00 -00 -06 -00 -fc -51 -00 -00 -02 -00 -00 -00 -06 -00 -00 -52 -00 -00 -02 -00 -00 -00 -06 -00 -04 -52 -00 -00 -02 -00 -00 -00 -06 -00 -08 -52 -00 -00 -02 -00 -00 -00 -06 -00 -0c -52 -00 -00 -02 -00 -00 -00 -06 -00 -10 -52 -00 -00 -02 -00 -00 -00 -06 -00 -14 -52 -00 -00 -02 -00 -00 -00 -06 -00 -18 -52 -00 -00 -02 -00 -00 -00 -06 -00 -1c -52 -00 -00 -02 -00 -00 -00 -06 -00 -20 -52 -00 +01 00 02 00 @@ -101729,639 +100669,9 @@ fc 00 06 00 +69 24 -52 -00 -00 -02 -00 -00 -00 -06 -00 -28 -52 -00 -00 -02 -00 -00 -00 -06 -00 -2c -52 -00 -00 -02 -00 -00 -00 -06 -00 -30 -52 -00 -00 -02 -00 -00 -00 -06 -00 -34 -52 -00 -00 -02 -00 -00 -00 -06 -00 -38 -52 -00 -00 -02 -00 -00 -00 -06 -00 -3c -52 -00 -00 -02 -00 -00 -00 -06 -00 -40 -52 -00 -00 -02 -00 -00 -00 -06 -00 -44 -52 -00 -00 -02 -00 -00 -00 -06 -00 -48 -52 -00 -00 -02 -00 -00 -00 -06 -00 -4c -52 -00 -00 -02 -00 -00 -00 -06 -00 -50 -52 -00 -00 -02 -00 -00 -00 -06 -00 -54 -52 -00 -00 -02 -00 -00 -00 -06 -00 -58 -52 -00 -00 -02 -00 -00 -00 -06 -00 -5c -52 -00 -00 -02 -00 -00 -00 -06 -00 -60 -52 -00 -00 -02 -00 -00 -00 -06 -00 -64 -52 -00 -00 -02 -00 -00 -00 -06 -00 -68 -52 -00 -00 -02 -00 -00 -00 -06 -00 -6c -52 -00 -00 -02 -00 -00 -00 -06 -00 -70 -52 -00 -00 -02 -00 -00 -00 -06 -00 -74 -52 -00 -00 -02 -00 -00 -00 -06 -00 -78 -52 -00 -00 -02 -00 -00 -00 -06 -00 -7c -52 -00 -00 -02 -00 -00 -00 -06 -00 -80 -52 -00 -00 -02 -00 -00 -00 -06 -00 -84 -52 -00 -00 -02 -00 -00 -00 -06 -00 -88 -52 -00 -00 -02 -00 -00 -00 -06 -00 -8c -52 -00 -00 -02 -00 -00 -00 -06 -00 -90 -52 -00 -00 -02 -00 -00 -00 -06 -00 -94 -52 -00 -00 -02 -00 -00 -00 -06 -00 -98 -52 -00 -00 -02 -00 -00 -00 -06 -00 -9c -52 -00 -00 -02 -00 -00 -00 -06 -00 -a0 -52 -00 -00 -02 -00 -00 -00 -06 -00 -a4 -52 -00 -00 -02 -00 -00 -00 -06 -00 -a8 -52 -00 -00 -02 -00 -00 -00 -06 -00 -ac -52 -00 -00 -02 -00 -00 -00 -06 -00 -b0 -52 -00 -00 -02 -00 -00 -00 -06 -00 -b4 -52 -00 -00 -02 -00 -00 -00 -06 -00 -b8 -52 -00 -00 -02 -00 -00 -00 -06 -00 -bc -52 -00 -00 -02 -00 -00 -00 -06 -00 -c0 -52 -00 -00 -02 -00 -00 -00 -06 -00 -c4 -52 -00 -00 -02 -00 -00 -00 -06 -00 -c8 -52 -00 -00 -02 -00 -00 -00 -06 -00 -cc -52 -00 -00 -02 -00 -00 -00 -06 -00 -d0 -52 -00 -00 -02 -00 -00 -00 -06 -00 -d4 -52 -00 -00 -02 -00 -00 -00 -06 -00 -d8 -52 -00 -00 -02 -00 -00 -00 -06 -00 -dc -52 -00 -00 -02 -00 -00 -00 -06 -00 -e0 -52 -00 -00 -02 -00 -00 -00 -06 -00 -e4 -52 -00 -00 -02 -00 -00 -00 -06 -00 -e8 -52 -00 -00 -02 -00 -00 -00 -06 -00 -ec -52 -00 -00 -02 -00 -00 -00 -06 -00 -f0 -52 -00 -00 -02 -00 -00 -00 -06 -00 -f4 -52 -00 -00 -02 -00 -00 -00 -06 -00 -f8 -52 -00 -00 -02 -00 -00 -00 -06 -00 -fc -52 -00 -00 -02 -00 -00 -00 -06 -00 -00 -53 -00 -00 -02 -00 -00 -00 -06 -00 -04 -53 -00 -00 -02 -00 -00 -00 -06 -00 -08 -53 -00 -00 -02 -00 -00 -00 -06 -00 -0c -53 -00 -00 -02 -00 -00 -00 -06 -00 -10 -53 -00 -00 -02 -00 -00 -00 -06 -00 -14 -53 -00 -00 -02 -00 -00 -00 -06 -00 -18 -53 -00 -00 -02 -00 -00 -00 -06 -00 -1c -53 -00 -00 -02 -00 -00 -00 -06 -00 -20 -53 -00 +01 00 02 00 @@ -102369,639 +100679,9 @@ fc 00 06 00 +6d 24 -53 -00 -00 -02 -00 -00 -00 -06 -00 -28 -53 -00 -00 -02 -00 -00 -00 -06 -00 -2c -53 -00 -00 -02 -00 -00 -00 -06 -00 -30 -53 -00 -00 -02 -00 -00 -00 -06 -00 -34 -53 -00 -00 -02 -00 -00 -00 -06 -00 -38 -53 -00 -00 -02 -00 -00 -00 -06 -00 -3c -53 -00 -00 -02 -00 -00 -00 -06 -00 -40 -53 -00 -00 -02 -00 -00 -00 -06 -00 -44 -53 -00 -00 -02 -00 -00 -00 -06 -00 -48 -53 -00 -00 -02 -00 -00 -00 -06 -00 -4c -53 -00 -00 -02 -00 -00 -00 -06 -00 -50 -53 -00 -00 -02 -00 -00 -00 -06 -00 -54 -53 -00 -00 -02 -00 -00 -00 -06 -00 -58 -53 -00 -00 -02 -00 -00 -00 -06 -00 -5c -53 -00 -00 -02 -00 -00 -00 -06 -00 -60 -53 -00 -00 -02 -00 -00 -00 -06 -00 -64 -53 -00 -00 -02 -00 -00 -00 -06 -00 -68 -53 -00 -00 -02 -00 -00 -00 -06 -00 -6c -53 -00 -00 -02 -00 -00 -00 -06 -00 -70 -53 -00 -00 -02 -00 -00 -00 -06 -00 -74 -53 -00 -00 -02 -00 -00 -00 -06 -00 -78 -53 -00 -00 -02 -00 -00 -00 -06 -00 -7c -53 -00 -00 -02 -00 -00 -00 -06 -00 -80 -53 -00 -00 -02 -00 -00 -00 -06 -00 -84 -53 -00 -00 -02 -00 -00 -00 -06 -00 -88 -53 -00 -00 -02 -00 -00 -00 -06 -00 -8c -53 -00 -00 -02 -00 -00 -00 -06 -00 -90 -53 -00 -00 -02 -00 -00 -00 -06 -00 -94 -53 -00 -00 -02 -00 -00 -00 -06 -00 -98 -53 -00 -00 -02 -00 -00 -00 -06 -00 -9c -53 -00 -00 -02 -00 -00 -00 -06 -00 -a0 -53 -00 -00 -02 -00 -00 -00 -06 -00 -a4 -53 -00 -00 -02 -00 -00 -00 -06 -00 -a8 -53 -00 -00 -02 -00 -00 -00 -06 -00 -ac -53 -00 -00 -02 -00 -00 -00 -06 -00 -b0 -53 -00 -00 -02 -00 -00 -00 -06 -00 -b4 -53 -00 -00 -02 -00 -00 -00 -06 -00 -b8 -53 -00 -00 -02 -00 -00 -00 -06 -00 -bc -53 -00 -00 -02 -00 -00 -00 -06 -00 -c0 -53 -00 -00 -02 -00 -00 -00 -06 -00 -c4 -53 -00 -00 -02 -00 -00 -00 -06 -00 -c8 -53 -00 -00 -02 -00 -00 -00 -06 -00 -cc -53 -00 -00 -02 -00 -00 -00 -06 -00 -d0 -53 -00 -00 -02 -00 -00 -00 -06 -00 -d4 -53 -00 -00 -02 -00 -00 -00 -06 -00 -d8 -53 -00 -00 -02 -00 -00 -00 -06 -00 -dc -53 -00 -00 -02 -00 -00 -00 -06 -00 -e0 -53 -00 -00 -02 -00 -00 -00 -06 -00 -e4 -53 -00 -00 -02 -00 -00 -00 -06 -00 -e8 -53 -00 -00 -02 -00 -00 -00 -06 -00 -ec -53 -00 -00 -02 -00 -00 -00 -06 -00 -f0 -53 -00 -00 -02 -00 -00 -00 -06 -00 -f4 -53 -00 -00 -02 -00 -00 -00 -06 -00 -f8 -53 -00 -00 -02 -00 -00 -00 -06 -00 -fc -53 -00 -00 -02 -00 -00 -00 -06 -00 -00 -54 -00 -00 -02 -00 -00 -00 -06 -00 -04 -54 -00 -00 -02 -00 -00 -00 -06 -00 -08 -54 -00 -00 -02 -00 -00 -00 -06 -00 -0c -54 -00 -00 -02 -00 -00 -00 -06 -00 -10 -54 -00 -00 -02 -00 -00 -00 -06 -00 -14 -54 -00 -00 -02 -00 -00 -00 -06 -00 -18 -54 -00 -00 -02 -00 -00 -00 -06 -00 -1c -54 -00 -00 -02 -00 -00 -00 -06 -00 -20 -54 -00 +01 00 02 00 @@ -103009,639 +100689,9 @@ fc 00 06 00 +71 24 -54 -00 -00 -02 -00 -00 -00 -06 -00 -28 -54 -00 -00 -02 -00 -00 -00 -06 -00 -2c -54 -00 -00 -02 -00 -00 -00 -06 -00 -30 -54 -00 -00 -02 -00 -00 -00 -06 -00 -34 -54 -00 -00 -02 -00 -00 -00 -06 -00 -38 -54 -00 -00 -02 -00 -00 -00 -06 -00 -3c -54 -00 -00 -02 -00 -00 -00 -06 -00 -40 -54 -00 -00 -02 -00 -00 -00 -06 -00 -44 -54 -00 -00 -02 -00 -00 -00 -06 -00 -48 -54 -00 -00 -02 -00 -00 -00 -06 -00 -4c -54 -00 -00 -02 -00 -00 -00 -06 -00 -50 -54 -00 -00 -02 -00 -00 -00 -06 -00 -54 -54 -00 -00 -02 -00 -00 -00 -06 -00 -58 -54 -00 -00 -02 -00 -00 -00 -06 -00 -5c -54 -00 -00 -02 -00 -00 -00 -06 -00 -60 -54 -00 -00 -02 -00 -00 -00 -06 -00 -64 -54 -00 -00 -02 -00 -00 -00 -06 -00 -68 -54 -00 -00 -02 -00 -00 -00 -06 -00 -6c -54 -00 -00 -02 -00 -00 -00 -06 -00 -70 -54 -00 -00 -02 -00 -00 -00 -06 -00 -74 -54 -00 -00 -02 -00 -00 -00 -06 -00 -78 -54 -00 -00 -02 -00 -00 -00 -06 -00 -7c -54 -00 -00 -02 -00 -00 -00 -06 -00 -80 -54 -00 -00 -02 -00 -00 -00 -06 -00 -84 -54 -00 -00 -02 -00 -00 -00 -06 -00 -88 -54 -00 -00 -02 -00 -00 -00 -06 -00 -8c -54 -00 -00 -02 -00 -00 -00 -06 -00 -90 -54 -00 -00 -02 -00 -00 -00 -06 -00 -94 -54 -00 -00 -02 -00 -00 -00 -06 -00 -98 -54 -00 -00 -02 -00 -00 -00 -06 -00 -9c -54 -00 -00 -02 -00 -00 -00 -06 -00 -a0 -54 -00 -00 -02 -00 -00 -00 -06 -00 -a4 -54 -00 -00 -02 -00 -00 -00 -06 -00 -a8 -54 -00 -00 -02 -00 -00 -00 -06 -00 -ac -54 -00 -00 -02 -00 -00 -00 -06 -00 -b0 -54 -00 -00 -02 -00 -00 -00 -06 -00 -b4 -54 -00 -00 -02 -00 -00 -00 -06 -00 -b8 -54 -00 -00 -02 -00 -00 -00 -06 -00 -bc -54 -00 -00 -02 -00 -00 -00 -06 -00 -c0 -54 -00 -00 -02 -00 -00 -00 -06 -00 -c4 -54 -00 -00 -02 -00 -00 -00 -06 -00 -c8 -54 -00 -00 -02 -00 -00 -00 -06 -00 -cc -54 -00 -00 -02 -00 -00 -00 -06 -00 -d0 -54 -00 -00 -02 -00 -00 -00 -06 -00 -d4 -54 -00 -00 -02 -00 -00 -00 -06 -00 -d8 -54 -00 -00 -02 -00 -00 -00 -06 -00 -dc -54 -00 -00 -02 -00 -00 -00 -06 -00 -e0 -54 -00 -00 -02 -00 -00 -00 -06 -00 -e4 -54 -00 -00 -02 -00 -00 -00 -06 -00 -e8 -54 -00 -00 -02 -00 -00 -00 -06 -00 -ec -54 -00 -00 -02 -00 -00 -00 -06 -00 -f0 -54 -00 -00 -02 -00 -00 -00 -06 -00 -f4 -54 -00 -00 -02 -00 -00 -00 -06 -00 -f8 -54 -00 -00 -02 -00 -00 -00 -06 -00 -fc -54 -00 -00 -02 -00 -00 -00 -06 -00 -00 -55 -00 -00 -02 -00 -00 -00 -06 -00 -04 -55 -00 -00 -02 -00 -00 -00 -06 -00 -08 -55 -00 -00 -02 -00 -00 -00 -06 -00 -0c -55 -00 -00 -02 -00 -00 -00 -06 -00 -10 -55 -00 -00 -02 -00 -00 -00 -06 -00 -14 -55 -00 -00 -02 -00 -00 -00 -06 -00 -18 -55 -00 -00 -02 -00 -00 -00 -06 -00 -1c -55 -00 -00 -02 -00 -00 -00 -06 -00 -20 -55 -00 +01 00 02 00 @@ -103649,639 +100699,9 @@ fc 00 06 00 +75 24 -55 -00 -00 -02 -00 -00 -00 -06 -00 -28 -55 -00 -00 -02 -00 -00 -00 -06 -00 -2c -55 -00 -00 -02 -00 -00 -00 -06 -00 -30 -55 -00 -00 -02 -00 -00 -00 -06 -00 -34 -55 -00 -00 -02 -00 -00 -00 -06 -00 -38 -55 -00 -00 -02 -00 -00 -00 -06 -00 -3c -55 -00 -00 -02 -00 -00 -00 -06 -00 -40 -55 -00 -00 -02 -00 -00 -00 -06 -00 -44 -55 -00 -00 -02 -00 -00 -00 -06 -00 -48 -55 -00 -00 -02 -00 -00 -00 -06 -00 -4c -55 -00 -00 -02 -00 -00 -00 -06 -00 -50 -55 -00 -00 -02 -00 -00 -00 -06 -00 -54 -55 -00 -00 -02 -00 -00 -00 -06 -00 -58 -55 -00 -00 -02 -00 -00 -00 -06 -00 -5c -55 -00 -00 -02 -00 -00 -00 -06 -00 -60 -55 -00 -00 -02 -00 -00 -00 -06 -00 -64 -55 -00 -00 -02 -00 -00 -00 -06 -00 -68 -55 -00 -00 -02 -00 -00 -00 -06 -00 -6c -55 -00 -00 -02 -00 -00 -00 -06 -00 -70 -55 -00 -00 -02 -00 -00 -00 -06 -00 -74 -55 -00 -00 -02 -00 -00 -00 -06 -00 -78 -55 -00 -00 -02 -00 -00 -00 -06 -00 -7c -55 -00 -00 -02 -00 -00 -00 -06 -00 -80 -55 -00 -00 -02 -00 -00 -00 -06 -00 -84 -55 -00 -00 -02 -00 -00 -00 -06 -00 -88 -55 -00 -00 -02 -00 -00 -00 -06 -00 -8c -55 -00 -00 -02 -00 -00 -00 -06 -00 -90 -55 -00 -00 -02 -00 -00 -00 -06 -00 -94 -55 -00 -00 -02 -00 -00 -00 -06 -00 -98 -55 -00 -00 -02 -00 -00 -00 -06 -00 -9c -55 -00 -00 -02 -00 -00 -00 -06 -00 -a0 -55 -00 -00 -02 -00 -00 -00 -06 -00 -a4 -55 -00 -00 -02 -00 -00 -00 -06 -00 -a8 -55 -00 -00 -02 -00 -00 -00 -06 -00 -ac -55 -00 -00 -02 -00 -00 -00 -06 -00 -b0 -55 -00 -00 -02 -00 -00 -00 -06 -00 -b4 -55 -00 -00 -02 -00 -00 -00 -06 -00 -b8 -55 -00 -00 -02 -00 -00 -00 -06 -00 -bc -55 -00 -00 -02 -00 -00 -00 -06 -00 -c0 -55 -00 -00 -02 -00 -00 -00 -06 -00 -c4 -55 -00 -00 -02 -00 -00 -00 -06 -00 -c8 -55 -00 -00 -02 -00 -00 -00 -06 -00 -cc -55 -00 -00 -02 -00 -00 -00 -06 -00 -d0 -55 -00 -00 -02 -00 -00 -00 -06 -00 -d4 -55 -00 -00 -02 -00 -00 -00 -06 -00 -d8 -55 -00 -00 -02 -00 -00 -00 -06 -00 -dc -55 -00 -00 -02 -00 -00 -00 -06 -00 -e0 -55 -00 -00 -02 -00 -00 -00 -06 -00 -e4 -55 -00 -00 -02 -00 -00 -00 -06 -00 -e8 -55 -00 -00 -02 -00 -00 -00 -06 -00 -ec -55 -00 -00 -02 -00 -00 -00 -06 -00 -f0 -55 -00 -00 -02 -00 -00 -00 -06 -00 -f4 -55 -00 -00 -02 -00 -00 -00 -06 -00 -f8 -55 -00 -00 -02 -00 -00 -00 -06 -00 -fc -55 -00 -00 -02 -00 -00 -00 -06 -00 -00 -56 -00 -00 -02 -00 -00 -00 -06 -00 -04 -56 -00 -00 -02 -00 -00 -00 -06 -00 -08 -56 -00 -00 -02 -00 -00 -00 -06 -00 -0c -56 -00 -00 -02 -00 -00 -00 -06 -00 -10 -56 -00 -00 -02 -00 -00 -00 -06 -00 -14 -56 -00 -00 -02 -00 -00 -00 -06 -00 -18 -56 -00 -00 -02 -00 -00 -00 -06 -00 -1c -56 -00 -00 -02 -00 -00 -00 -06 -00 -20 -56 -00 +01 00 02 00 @@ -104289,9 +100709,9 @@ fc 00 06 00 +79 24 -56 -00 +01 00 02 00 @@ -104299,9 +100719,2259 @@ fc 00 06 00 +7d +24 +01 +00 +02 +00 +00 +00 +06 +00 +81 +24 +01 +00 +02 +00 +00 +00 +06 +00 +85 +24 +01 +00 +02 +00 +00 +00 +06 +00 +89 +24 +01 +00 +02 +00 +00 +00 +06 +00 +8d +24 +01 +00 +02 +00 +00 +00 +06 +00 +91 +24 +01 +00 +02 +00 +00 +00 +06 +00 +95 +24 +01 +00 +02 +00 +00 +00 +06 +00 +99 +24 +01 +00 +02 +00 +00 +00 +06 +00 +9d +24 +01 +00 +02 +00 +00 +00 +06 +00 +a1 +24 +01 +00 +02 +00 +00 +00 +06 +00 +a5 +24 +01 +00 +02 +00 +00 +00 +06 +00 +a9 +24 +01 +00 +02 +00 +00 +00 +06 +00 +ad +24 +01 +00 +02 +00 +00 +00 +06 +00 +b1 +24 +01 +00 +02 +00 +00 +00 +06 +00 +b5 +24 +01 +00 +02 +00 +00 +00 +06 +00 +b9 +24 +01 +00 +02 +00 +00 +00 +06 +00 +bd +24 +01 +00 +02 +00 +00 +00 +06 +00 +c1 +24 +01 +00 +02 +00 +00 +00 +06 +00 +c5 +24 +01 +00 +02 +00 +00 +00 +06 +00 +c9 +24 +01 +00 +02 +00 +00 +00 +06 +00 +cd +24 +01 +00 +02 +00 +00 +00 +06 +00 +d1 +24 +01 +00 +02 +00 +00 +00 +06 +00 +d5 +24 +01 +00 +02 +00 +00 +00 +06 +00 +d9 +24 +01 +00 +02 +00 +00 +00 +06 +00 +dd +24 +01 +00 +02 +00 +00 +00 +06 +00 +e1 +24 +01 +00 +02 +00 +00 +00 +06 +00 +e5 +24 +01 +00 +02 +00 +00 +00 +06 +00 +e9 +24 +01 +00 +02 +00 +00 +00 +06 +00 +ed +24 +01 +00 +02 +00 +00 +00 +06 +00 +f1 +24 +01 +00 +02 +00 +00 +00 +06 +00 +f5 +24 +01 +00 +02 +00 +00 +00 +06 +00 +f9 +24 +01 +00 +02 +00 +00 +00 +06 +00 +fd +24 +01 +00 +02 +00 +00 +00 +06 +00 +01 +25 +01 +00 +02 +00 +00 +00 +06 +00 +05 +25 +01 +00 +02 +00 +00 +00 +06 +00 +09 +25 +01 +00 +02 +00 +00 +00 +06 +00 +0d +25 +01 +00 +02 +00 +00 +00 +06 +00 +11 +25 +01 +00 +02 +00 +00 +00 +06 +00 +15 +25 +01 +00 +02 +00 +00 +00 +06 +00 +19 +25 +01 +00 +02 +00 +00 +00 +06 +00 +1d +25 +01 +00 +02 +00 +00 +00 +06 +00 +21 +25 +01 +00 +02 +00 +00 +00 +06 +00 +25 +25 +01 +00 +02 +00 +00 +00 +06 +00 +29 +25 +01 +00 +02 +00 +00 +00 +06 +00 +2d +25 +01 +00 +02 +00 +00 +00 +06 +00 +31 +25 +01 +00 +02 +00 +00 +00 +06 +00 +35 +25 +01 +00 +02 +00 +00 +00 +06 +00 +39 +25 +01 +00 +02 +00 +00 +00 +06 +00 +3d +25 +01 +00 +02 +00 +00 +00 +06 +00 +41 +25 +01 +00 +02 +00 +00 +00 +06 +00 +45 +25 +01 +00 +02 +00 +00 +00 +06 +00 +49 +25 +01 +00 +02 +00 +00 +00 +06 +00 +4d +25 +01 +00 +02 +00 +00 +00 +06 +00 +51 +25 +01 +00 +02 +00 +00 +00 +06 +00 +55 +25 +01 +00 +02 +00 +00 +00 +06 +00 +59 +25 +01 +00 +02 +00 +00 +00 +06 +00 +5d +25 +01 +00 +02 +00 +00 +00 +06 +00 +61 +25 +01 +00 +02 +00 +00 +00 +06 +00 +65 +25 +01 +00 +02 +00 +00 +00 +06 +00 +69 +25 +01 +00 +02 +00 +00 +00 +06 +00 +6d +25 +01 +00 +02 +00 +00 +00 +06 +00 +71 +25 +01 +00 +02 +00 +00 +00 +06 +00 +75 +25 +01 +00 +02 +00 +00 +00 +06 +00 +79 +25 +01 +00 +02 +00 +00 +00 +06 +00 +7d +25 +01 +00 +02 +00 +00 +00 +06 +00 +81 +25 +01 +00 +02 +00 +00 +00 +06 +00 +85 +25 +01 +00 +02 +00 +00 +00 +06 +00 +89 +25 +01 +00 +02 +00 +00 +00 +06 +00 +8d +25 +01 +00 +02 +00 +00 +00 +06 +00 +91 +25 +01 +00 +02 +00 +00 +00 +06 +00 +95 +25 +01 +00 +02 +00 +00 +00 +06 +00 +99 +25 +01 +00 +02 +00 +00 +00 +06 +00 +9d +25 +01 +00 +02 +00 +00 +00 +06 +00 +a1 +25 +01 +00 +02 +00 +00 +00 +06 +00 +a5 +25 +01 +00 +02 +00 +00 +00 +06 +00 +a9 +25 +01 +00 +02 +00 +00 +00 +06 +00 +ad +25 +01 +00 +02 +00 +00 +00 +06 +00 +b1 +25 +01 +00 +02 +00 +00 +00 +06 +00 +b5 +25 +01 +00 +02 +00 +00 +00 +06 +00 +b9 +25 +01 +00 +02 +00 +00 +00 +06 +00 +bd +25 +01 +00 +02 +00 +00 +00 +06 +00 +c1 +25 +01 +00 +02 +00 +00 +00 +06 +00 +c5 +25 +01 +00 +02 +00 +00 +00 +06 +00 +c9 +25 +01 +00 +02 +00 +00 +00 +06 +00 +cd +25 +01 +00 +02 +00 +00 +00 +06 +00 +d1 +25 +01 +00 +02 +00 +00 +00 +06 +00 +d5 +25 +01 +00 +02 +00 +00 +00 +06 +00 +d9 +25 +01 +00 +02 +00 +00 +00 +06 +00 +dd +25 +01 +00 +02 +00 +00 +00 +06 +00 +e1 +25 +01 +00 +02 +00 +00 +00 +06 +00 +e5 +25 +01 +00 +02 +00 +00 +00 +06 +00 +e9 +25 +01 +00 +02 +00 +00 +00 +06 +00 +ed +25 +01 +00 +02 +00 +00 +00 +06 +00 +f1 +25 +01 +00 +02 +00 +00 +00 +06 +00 +f5 +25 +01 +00 +02 +00 +00 +00 +06 +00 +f9 +25 +01 +00 +02 +00 +00 +00 +06 +00 +fd +25 +01 +00 +02 +00 +00 +00 +06 +00 +01 +26 +01 +00 +02 +00 +00 +00 +06 +00 +05 +26 +01 +00 +02 +00 +00 +00 +06 +00 +09 +26 +01 +00 +02 +00 +00 +00 +06 +00 +0d +26 +01 +00 +02 +00 +00 +00 +06 +00 +11 +26 +01 +00 +02 +00 +00 +00 +06 +00 +15 +26 +01 +00 +02 +00 +00 +00 +06 +00 +19 +26 +01 +00 +02 +00 +00 +00 +06 +00 +1d +26 +01 +00 +02 +00 +00 +00 +06 +00 +21 +26 +01 +00 +02 +00 +00 +00 +06 +00 +25 +26 +01 +00 +02 +00 +00 +00 +06 +00 +29 +26 +01 +00 +02 +00 +00 +00 +06 +00 +2d +26 +01 +00 +02 +00 +00 +00 +06 +00 +31 +26 +01 +00 +02 +00 +00 +00 +06 +00 +35 +26 +01 +00 +02 +00 +00 +00 +06 +00 +39 +26 +01 +00 +02 +00 +00 +00 +06 +00 +3d +26 +01 +00 +02 +00 +00 +00 +06 +00 +41 +26 +01 +00 +02 +00 +00 +00 +06 +00 +45 +26 +01 +00 +02 +00 +00 +00 +06 +00 +49 +26 +01 +00 +02 +00 +00 +00 +06 +00 +4d +26 +01 +00 +02 +00 +00 +00 +06 +00 +51 +26 +01 +00 +02 +00 +00 +00 +06 +00 +55 +26 +01 +00 +02 +00 +00 +00 +06 +00 +59 +26 +01 +00 +02 +00 +00 +00 +06 +00 +5d +26 +01 +00 +02 +00 +00 +00 +06 +00 +61 +26 +01 +00 +02 +00 +00 +00 +06 +00 +65 +26 +01 +00 +02 +00 +00 +00 +06 +00 +69 +26 +01 +00 +02 +00 +00 +00 +06 +00 +6d +26 +01 +00 +02 +00 +00 +00 +06 +00 +71 +26 +01 +00 +02 +00 +00 +00 +06 +00 +75 +26 +01 +00 +02 +00 +00 +00 +06 +00 +79 +26 +01 +00 +02 +00 +00 +00 +06 +00 +7d +26 +01 +00 +02 +00 +00 +00 +06 +00 +81 +26 +01 +00 +02 +00 +00 +00 +06 +00 +85 +26 +01 +00 +02 +00 +00 +00 +06 +00 +89 +26 +01 +00 +02 +00 +00 +00 +06 +00 +8d +26 +01 +00 +02 +00 +00 +00 +06 +00 +91 +26 +01 +00 +02 +00 +00 +00 +06 +00 +95 +26 +01 +00 +02 +00 +00 +00 +06 +00 +99 +26 +01 +00 +02 +00 +00 +00 +06 +00 +9d +26 +01 +00 +02 +00 +00 +00 +06 +00 +a1 +26 +01 +00 +02 +00 +00 +00 +06 +00 +a5 +26 +01 +00 +02 +00 +00 +00 +06 +00 +a9 +26 +01 +00 +02 +00 +00 +00 +06 +00 +ad +26 +01 +00 +02 +00 +00 +00 +06 +00 +b1 +26 +01 +00 +02 +00 +00 +00 +06 +00 +b5 +26 +01 +00 +02 +00 +00 +00 +06 +00 +b9 +26 +01 +00 +02 +00 +00 +00 +06 +00 +bd +26 +01 +00 +02 +00 +00 +00 +06 +00 +c1 +26 +01 +00 +02 +00 +00 +00 +06 +00 +c5 +26 +01 +00 +02 +00 +00 +00 +06 +00 +c9 +26 +01 +00 +02 +00 +00 +00 +06 +00 +cd +26 +01 +00 +02 +00 +00 +00 +06 +00 +d1 +26 +01 +00 +02 +00 +00 +00 +06 +00 +d5 +26 +01 +00 +02 +00 +00 +00 +06 +00 +d9 +26 +01 +00 +02 +00 +00 +00 +06 +00 +dd +26 +01 +00 +02 +00 +00 +00 +06 +00 +e1 +26 +01 +00 +02 +00 +00 +00 +06 +00 +e5 +26 +01 +00 +02 +00 +00 +00 +06 +00 +e9 +26 +01 +00 +02 +00 +00 +00 +06 +00 +ed +26 +01 +00 +02 +00 +00 +00 +06 +00 +f1 +26 +01 +00 +02 +00 +00 +00 +06 +00 +f5 +26 +01 +00 +02 +00 +00 +00 +06 +00 +f9 +26 +01 +00 +02 +00 +00 +00 +06 +00 +fd +26 +01 +00 +02 +00 +00 +00 +06 +00 +01 +27 +01 +00 +02 +00 +00 +00 +06 +00 +05 +27 +01 +00 +02 +00 +00 +00 +06 +00 +09 +27 +01 +00 +02 +00 +00 +00 +06 +00 +0d +27 +01 +00 +02 +00 +00 +00 +06 +00 +11 +27 +01 +00 +02 +00 +00 +00 +06 +00 +15 +27 +01 +00 +02 +00 +00 +00 +06 +00 +19 +27 +01 +00 +02 +00 +00 +00 +06 +00 +1d +27 +01 +00 +02 +00 +00 +00 +06 +00 +21 +27 +01 +00 +02 +00 +00 +00 +06 +00 +25 +27 +01 +00 +02 +00 +00 +00 +06 +00 +29 +27 +01 +00 +02 +00 +00 +00 +06 +00 +2d +27 +01 +00 +02 +00 +00 +00 +06 +00 +31 +27 +01 +00 +02 +00 +00 +00 +06 +00 +35 +27 +01 +00 +02 +00 +00 +00 +06 +00 +39 +27 +01 +00 +02 +00 +00 +00 +06 +00 +3d +27 +01 +00 +02 +00 +00 +00 +06 +00 +41 +27 +01 +00 +02 +00 +00 +00 +06 +00 +45 +27 +01 +00 +02 +00 +00 +00 +06 +00 +49 +27 +01 +00 +02 +00 +00 +00 +06 +00 +4d +27 +01 +00 +02 +00 +00 +00 +06 +00 +51 +27 +01 +00 +02 +00 +00 +00 +06 +00 +55 +27 +01 +00 +02 +00 +00 +00 +06 +00 +59 +27 +01 +00 +02 +00 +00 +00 +06 +00 +5d +27 +01 +00 +02 +00 +00 +00 +06 +00 +61 +27 +01 +00 +02 +00 +00 +00 +06 +00 +65 +27 +01 +00 +02 +00 +00 +00 +06 +00 +69 +27 +01 +00 +02 +00 +00 +00 +06 +00 +6d +27 +01 +00 +02 +00 +00 +00 +06 +00 +71 +27 +01 +00 +02 +00 +00 +00 +06 +00 +75 +27 +01 +00 +02 +00 +00 +00 +06 +00 +79 +27 +01 +00 +02 +00 +00 +00 +06 +00 +7d +27 +01 +00 +02 +00 +00 +00 +06 +00 +81 +27 +01 +00 +02 +00 +00 +00 +06 +00 +85 +27 +01 +00 +02 +00 +00 +00 +06 +00 +89 +27 +01 +00 +02 +00 +00 +00 +06 +00 +8d +27 +01 +00 +02 +00 +00 +00 +06 +00 +91 +27 +01 +00 +02 +00 +00 +00 +06 +00 +95 +27 +01 +00 +02 +00 +00 +00 +06 +00 +99 +27 +01 +00 +02 +00 +00 +00 +06 +00 +9d +27 +01 +00 +02 +00 +00 +00 +06 +00 +a1 +27 +01 +00 +02 +00 +00 +00 +06 +00 +a5 +27 +01 +00 +02 +00 +00 +00 +06 +00 +a9 +27 +01 +00 +02 +00 +00 +00 +06 +00 +ad +27 +01 +00 +02 +00 +00 +00 +06 +00 +b1 +27 +01 +00 +02 +00 +00 +00 +06 +00 +b5 +27 +01 +00 +02 +00 +00 +00 +06 +00 +b9 +27 +01 +00 +02 +00 +00 +00 +06 +00 +bd +27 +01 +00 +02 +00 +00 +00 +06 +00 +c1 +27 +01 +00 +02 +00 +00 +00 +06 +00 +c5 +27 +01 +00 +02 +00 +00 +00 +06 +00 +c9 +27 +01 +00 +02 +00 +00 +00 +06 +00 +cd +27 +01 +00 +02 +00 +00 +00 +06 +00 +d1 +27 +01 +00 +02 +00 +00 +00 +06 +00 +d5 +27 +01 +00 +02 +00 +00 +00 +06 +00 +d9 +27 +01 +00 +02 +00 +00 +00 +06 +00 +dd +27 +01 +00 +02 +00 +00 +00 +06 +00 +e1 +27 +01 +00 +02 +00 +00 +00 +06 +00 +e5 +27 +01 +00 +02 +00 +00 +00 +06 +00 +e9 +27 +01 +00 +02 +00 +00 +00 +06 +00 +ed +27 +01 +00 +02 +00 +00 +00 +06 +00 +f1 +27 +01 +00 +02 +00 +00 +00 +06 +00 +f5 +27 +01 +00 +02 +00 +00 +00 +06 +00 +f9 +27 +01 +00 +02 +00 +00 +00 +06 +00 +fd +27 +01 +00 +02 +00 +00 +00 +06 +00 +01 28 -56 -00 +01 00 02 00 @@ -104309,9 +102979,9 @@ fc 00 06 00 -2c -56 -00 +05 +28 +01 00 02 00 @@ -104319,9 +102989,9 @@ fc 00 06 00 -30 -56 -00 +09 +28 +01 00 02 00 @@ -104329,9 +102999,9 @@ fc 00 06 00 -34 -56 -00 +0d +28 +01 00 02 00 @@ -104339,9 +103009,9 @@ fc 00 06 00 -38 -56 -00 +11 +28 +01 00 02 00 @@ -104349,9 +103019,9 @@ fc 00 06 00 -3c -56 -00 +15 +28 +01 00 02 00 @@ -104359,9 +103029,9 @@ fc 00 06 00 -40 -56 -00 +19 +28 +01 00 02 00 @@ -104369,9 +103039,9 @@ fc 00 06 00 -44 -56 -00 +1d +28 +01 00 02 00 @@ -104379,9 +103049,9 @@ fc 00 06 00 -48 -56 -00 +21 +28 +01 00 02 00 @@ -104389,9 +103059,9 @@ fc 00 06 00 -4c -56 -00 +25 +28 +01 00 02 00 @@ -104399,9 +103069,9 @@ fc 00 06 00 -50 -56 -00 +29 +28 +01 00 02 00 @@ -104409,9 +103079,9 @@ fc 00 06 00 -54 -56 -00 +2d +28 +01 00 02 00 @@ -104419,9 +103089,9 @@ fc 00 06 00 -58 -56 -00 +31 +28 +01 00 02 00 @@ -104429,9 +103099,9 @@ fc 00 06 00 -5c -56 -00 +35 +28 +01 00 02 00 @@ -104439,9 +103109,9 @@ fc 00 06 00 -60 -56 -00 +39 +28 +01 00 02 00 @@ -104449,9 +103119,9 @@ fc 00 06 00 -64 -56 -00 +3d +28 +01 00 02 00 @@ -104459,9 +103129,9 @@ fc 00 06 00 -68 -56 -00 +41 +28 +01 00 02 00 @@ -104469,9 +103139,9 @@ fc 00 06 00 -6c -56 -00 +45 +28 +01 00 02 00 @@ -104479,9 +103149,9 @@ fc 00 06 00 -70 -56 -00 +49 +28 +01 00 02 00 @@ -104489,9 +103159,9 @@ fc 00 06 00 -74 -56 -00 +4d +28 +01 00 02 00 @@ -104499,9 +103169,9 @@ fc 00 06 00 -78 -56 -00 +51 +28 +01 00 02 00 @@ -104509,9 +103179,9 @@ fc 00 06 00 -7c -56 -00 +55 +28 +01 00 02 00 @@ -104519,9 +103189,9 @@ fc 00 06 00 -80 -56 -00 +59 +28 +01 00 02 00 @@ -104529,9 +103199,9 @@ fc 00 06 00 -84 -56 -00 +5d +28 +01 00 02 00 @@ -104539,9 +103209,9 @@ fc 00 06 00 -88 -56 -00 +61 +28 +01 00 02 00 @@ -104549,9 +103219,9 @@ fc 00 06 00 -8c -56 -00 +65 +28 +01 00 02 00 @@ -104559,9 +103229,9 @@ fc 00 06 00 -90 -56 -00 +69 +28 +01 00 02 00 @@ -104569,9 +103239,9 @@ fc 00 06 00 -94 -56 -00 +6d +28 +01 00 02 00 @@ -104579,9 +103249,9 @@ fc 00 06 00 -98 -56 -00 +71 +28 +01 00 02 00 @@ -104589,9 +103259,9 @@ fc 00 06 00 -9c -56 -00 +75 +28 +01 00 02 00 @@ -104599,9 +103269,9 @@ fc 00 06 00 -a0 -56 -00 +79 +28 +01 00 02 00 @@ -104609,9 +103279,9 @@ a0 00 06 00 -a4 -56 -00 +7d +28 +01 00 02 00 @@ -104619,9 +103289,9 @@ a4 00 06 00 -a8 -56 -00 +81 +28 +01 00 02 00 @@ -104629,9 +103299,9 @@ a8 00 06 00 -ac -56 -00 +85 +28 +01 00 02 00 @@ -104639,9 +103309,9 @@ ac 00 06 00 -b0 -56 -00 +89 +28 +01 00 02 00 @@ -104649,9 +103319,9 @@ b0 00 06 00 -b4 -56 -00 +8d +28 +01 00 02 00 @@ -104659,9 +103329,9 @@ b4 00 06 00 -b8 -56 -00 +91 +28 +01 00 02 00 @@ -104669,9 +103339,9 @@ b8 00 06 00 -bc -56 -00 +95 +28 +01 00 02 00 @@ -104679,9 +103349,9 @@ bc 00 06 00 -c0 -56 -00 +99 +28 +01 00 02 00 @@ -104689,9 +103359,9 @@ c0 00 06 00 -c4 -56 -00 +9d +28 +01 00 02 00 @@ -104699,9 +103369,9 @@ c4 00 06 00 -c8 -56 -00 +a1 +28 +01 00 02 00 @@ -104709,9 +103379,9 @@ c8 00 06 00 -cc -56 -00 +a5 +28 +01 00 02 00 @@ -104719,9 +103389,9 @@ cc 00 06 00 -d0 -56 -00 +a9 +28 +01 00 02 00 @@ -104729,9 +103399,9 @@ d0 00 06 00 -d4 -56 -00 +ad +28 +01 00 02 00 @@ -104739,9 +103409,9 @@ d4 00 06 00 -d8 -56 -00 +b1 +28 +01 00 02 00 @@ -104749,9 +103419,9 @@ d8 00 06 00 -dc -56 -00 +b5 +28 +01 00 02 00 @@ -104759,9 +103429,9 @@ dc 00 06 00 -e0 -56 -00 +b9 +28 +01 00 02 00 @@ -104769,9 +103439,9 @@ e0 00 06 00 -e4 -56 -00 +bd +28 +01 00 02 00 @@ -104779,9 +103449,9 @@ e4 00 06 00 -e8 -56 -00 +c1 +28 +01 00 02 00 @@ -104789,9 +103459,9 @@ e8 00 06 00 -ec -56 -00 +c5 +28 +01 00 02 00 @@ -104799,9 +103469,9 @@ ec 00 06 00 -f0 -56 -00 +c9 +28 +01 00 02 00 @@ -104809,9 +103479,9 @@ f0 00 06 00 -f4 -56 -00 +cd +28 +01 00 02 00 @@ -104819,9 +103489,9 @@ f4 00 06 00 -f8 -56 -00 +d1 +28 +01 00 02 00 @@ -104829,9 +103499,9 @@ f8 00 06 00 -fc -56 -00 +d5 +28 +01 00 02 00 @@ -104839,9 +103509,9 @@ fc 00 06 00 -00 -57 -00 +d9 +28 +01 00 02 00 @@ -104849,9 +103519,9 @@ fc 00 06 00 -04 -57 -00 +dd +28 +01 00 02 00 @@ -104859,9 +103529,9 @@ fc 00 06 00 -08 -57 -00 +e1 +28 +01 00 02 00 @@ -104869,9 +103539,9 @@ fc 00 06 00 -0c -57 -00 +e5 +28 +01 00 02 00 @@ -104879,9 +103549,9 @@ fc 00 06 00 -10 -57 -00 +e9 +28 +01 00 02 00 @@ -104889,9 +103559,9 @@ fc 00 06 00 -14 -57 -00 +ed +28 +01 00 02 00 @@ -104899,9 +103569,9 @@ fc 00 06 00 -18 -57 -00 +f1 +28 +01 00 02 00 @@ -104909,9 +103579,9 @@ fc 00 06 00 -1c -57 -00 +f5 +28 +01 00 02 00 @@ -104919,9 +103589,1339 @@ fc 00 06 00 -20 -57 +f9 +28 +01 00 +02 +00 +00 +00 +06 +00 +fd +28 +01 +00 +02 +00 +00 +00 +06 +00 +01 +29 +01 +00 +02 +00 +00 +00 +06 +00 +05 +29 +01 +00 +02 +00 +00 +00 +06 +00 +09 +29 +01 +00 +02 +00 +00 +00 +06 +00 +0d +29 +01 +00 +02 +00 +00 +00 +06 +00 +11 +29 +01 +00 +02 +00 +00 +00 +06 +00 +15 +29 +01 +00 +02 +00 +00 +00 +06 +00 +19 +29 +01 +00 +02 +00 +00 +00 +06 +00 +1d +29 +01 +00 +02 +00 +00 +00 +06 +00 +21 +29 +01 +00 +02 +00 +00 +00 +06 +00 +25 +29 +01 +00 +02 +00 +00 +00 +06 +00 +29 +29 +01 +00 +02 +00 +00 +00 +06 +00 +2d +29 +01 +00 +02 +00 +00 +00 +06 +00 +31 +29 +01 +00 +02 +00 +00 +00 +06 +00 +35 +29 +01 +00 +02 +00 +00 +00 +06 +00 +39 +29 +01 +00 +02 +00 +00 +00 +06 +00 +3d +29 +01 +00 +02 +00 +00 +00 +06 +00 +41 +29 +01 +00 +02 +00 +00 +00 +06 +00 +45 +29 +01 +00 +02 +00 +00 +00 +06 +00 +49 +29 +01 +00 +02 +00 +00 +00 +06 +00 +4d +29 +01 +00 +02 +00 +00 +00 +06 +00 +51 +29 +01 +00 +02 +00 +00 +00 +06 +00 +55 +29 +01 +00 +02 +00 +00 +00 +06 +00 +59 +29 +01 +00 +02 +00 +00 +00 +06 +00 +5d +29 +01 +00 +02 +00 +00 +00 +06 +00 +61 +29 +01 +00 +02 +00 +00 +00 +06 +00 +65 +29 +01 +00 +02 +00 +00 +00 +06 +00 +69 +29 +01 +00 +02 +00 +00 +00 +06 +00 +6d +29 +01 +00 +02 +00 +00 +00 +06 +00 +71 +29 +01 +00 +02 +00 +00 +00 +06 +00 +75 +29 +01 +00 +02 +00 +00 +00 +06 +00 +79 +29 +01 +00 +02 +00 +00 +00 +06 +00 +7d +29 +01 +00 +02 +00 +00 +00 +06 +00 +81 +29 +01 +00 +02 +00 +00 +00 +06 +00 +85 +29 +01 +00 +02 +00 +00 +00 +06 +00 +89 +29 +01 +00 +02 +00 +00 +00 +06 +00 +8d +29 +01 +00 +02 +00 +00 +00 +06 +00 +91 +29 +01 +00 +02 +00 +00 +00 +06 +00 +95 +29 +01 +00 +02 +00 +00 +00 +06 +00 +99 +29 +01 +00 +02 +00 +00 +00 +06 +00 +9d +29 +01 +00 +02 +00 +00 +00 +06 +00 +a1 +29 +01 +00 +02 +00 +00 +00 +06 +00 +a5 +29 +01 +00 +02 +00 +00 +00 +06 +00 +a9 +29 +01 +00 +02 +00 +00 +00 +06 +00 +ad +29 +01 +00 +02 +00 +00 +00 +06 +00 +b1 +29 +01 +00 +02 +00 +00 +00 +06 +00 +b5 +29 +01 +00 +02 +00 +00 +00 +06 +00 +b9 +29 +01 +00 +02 +00 +00 +00 +06 +00 +bd +29 +01 +00 +02 +00 +00 +00 +06 +00 +c1 +29 +01 +00 +02 +00 +00 +00 +06 +00 +c5 +29 +01 +00 +02 +00 +00 +00 +06 +00 +c9 +29 +01 +00 +02 +00 +00 +00 +06 +00 +cd +29 +01 +00 +02 +00 +00 +00 +06 +00 +d1 +29 +01 +00 +02 +00 +00 +00 +06 +00 +d5 +29 +01 +00 +02 +00 +00 +00 +06 +00 +d9 +29 +01 +00 +02 +00 +00 +00 +06 +00 +dd +29 +01 +00 +02 +00 +00 +00 +06 +00 +e1 +29 +01 +00 +02 +00 +00 +00 +06 +00 +e5 +29 +01 +00 +02 +00 +00 +00 +06 +00 +e9 +29 +01 +00 +02 +00 +00 +00 +06 +00 +ed +29 +01 +00 +02 +00 +00 +00 +06 +00 +f1 +29 +01 +00 +02 +00 +00 +00 +06 +00 +f5 +29 +01 +00 +02 +00 +00 +00 +06 +00 +f9 +29 +01 +00 +02 +00 +00 +00 +06 +00 +fd +29 +01 +00 +02 +00 +00 +00 +06 +00 +01 +2a +01 +00 +02 +00 +00 +00 +06 +00 +05 +2a +01 +00 +02 +00 +00 +00 +06 +00 +09 +2a +01 +00 +02 +00 +00 +00 +06 +00 +0d +2a +01 +00 +02 +00 +00 +00 +06 +00 +11 +2a +01 +00 +02 +00 +00 +00 +06 +00 +15 +2a +01 +00 +02 +00 +00 +00 +06 +00 +19 +2a +01 +00 +02 +00 +00 +00 +06 +00 +1d +2a +01 +00 +02 +00 +00 +00 +06 +00 +21 +2a +01 +00 +02 +00 +00 +00 +06 +00 +25 +2a +01 +00 +02 +00 +00 +00 +06 +00 +29 +2a +01 +00 +02 +00 +00 +00 +06 +00 +2d +2a +01 +00 +02 +00 +00 +00 +06 +00 +31 +2a +01 +00 +02 +00 +00 +00 +06 +00 +35 +2a +01 +00 +02 +00 +00 +00 +06 +00 +39 +2a +01 +00 +02 +00 +00 +00 +06 +00 +3d +2a +01 +00 +02 +00 +00 +00 +06 +00 +41 +2a +01 +00 +02 +00 +00 +00 +06 +00 +45 +2a +01 +00 +02 +00 +00 +00 +06 +00 +49 +2a +01 +00 +02 +00 +00 +00 +06 +00 +4d +2a +01 +00 +02 +00 +00 +00 +06 +00 +51 +2a +01 +00 +02 +00 +00 +00 +06 +00 +55 +2a +01 +00 +02 +00 +00 +00 +06 +00 +59 +2a +01 +00 +02 +00 +00 +00 +06 +00 +5d +2a +01 +00 +02 +00 +00 +00 +06 +00 +61 +2a +01 +00 +02 +00 +00 +00 +06 +00 +65 +2a +01 +00 +02 +00 +00 +00 +06 +00 +69 +2a +01 +00 +02 +00 +00 +00 +06 +00 +6d +2a +01 +00 +02 +00 +00 +00 +06 +00 +71 +2a +01 +00 +02 +00 +00 +00 +06 +00 +75 +2a +01 +00 +02 +00 +00 +00 +06 +00 +79 +2a +01 +00 +02 +00 +00 +00 +06 +00 +7d +2a +01 +00 +02 +00 +00 +00 +06 +00 +81 +2a +01 +00 +02 +00 +00 +00 +06 +00 +85 +2a +01 +00 +02 +00 +00 +00 +06 +00 +89 +2a +01 +00 +02 +00 +00 +00 +06 +00 +8d +2a +01 +00 +02 +00 +00 +00 +06 +00 +91 +2a +01 +00 +02 +00 +00 +00 +06 +00 +95 +2a +01 +00 +02 +00 +00 +00 +06 +00 +99 +2a +01 +00 +02 +00 +00 +00 +06 +00 +9d +2a +01 +00 +02 +00 +00 +00 +06 +00 +a1 +2a +01 +00 +02 +00 +00 +00 +06 +00 +a5 +2a +01 +00 +02 +00 +00 +00 +06 +00 +a9 +2a +01 +00 +02 +00 +00 +00 +06 +00 +ad +2a +01 +00 +02 +00 +00 +00 +06 +00 +b1 +2a +01 +00 +02 +00 +00 +00 +06 +00 +b5 +2a +01 +00 +02 +00 +00 +00 +06 +00 +b9 +2a +01 +00 +02 +00 +00 +00 +06 +00 +bd +2a +01 +00 +02 +00 +00 +00 +06 +00 +c1 +2a +01 +00 +02 +00 +00 +00 +06 +00 +c5 +2a +01 +00 +02 +00 +00 +00 +06 +00 +c9 +2a +01 +00 +02 +00 +00 +00 +06 +00 +cd +2a +01 +00 +02 +00 +00 +00 +06 +00 +d1 +2a +01 +00 +02 +00 +00 +00 +06 +00 +d5 +2a +01 +00 +02 +00 +00 +00 +06 +00 +d9 +2a +01 +00 +02 +00 +00 +00 +06 +00 +dd +2a +01 +00 +02 +00 +00 +00 +06 +00 +e1 +2a +01 +00 +02 +00 +00 +00 +06 +00 +e5 +2a +01 +00 +02 +00 +00 +00 +06 +00 +e9 +2a +01 +00 +02 +00 +00 +00 +06 +00 +ed +2a +01 +00 +02 +00 +00 +00 +06 +00 +f1 +2a +01 +00 +02 +00 +00 +00 +06 +00 +f5 +2a +01 +00 +02 +00 +00 +00 +06 +00 +f9 +2a +01 +00 +02 +00 +00 +00 +06 +00 +fd +2a +01 +00 +02 +00 +00 +00 +06 +00 +01 +2b +01 +00 +02 +00 +00 +00 +06 +00 +05 +2b +01 +00 +02 +00 +00 +00 +06 +00 +09 +2b +01 +00 +02 +00 +00 +00 +06 +00 +0d +2b +01 00 02 00 @@ -105405,8 +105405,8 @@ f5 00 00 00 -00 -00 +e9 +d3 00 00 02 @@ -105441,8 +105441,8 @@ f5 74 61 00 -00 -00 +ed +d3 00 00 03 diff --git a/modules/objfmts/coff/win64-except.c b/modules/objfmts/coff/win64-except.c index 8c8ecbbc..f50c271d 100644 --- a/modules/objfmts/coff/win64-except.c +++ b/modules/objfmts/coff/win64-except.c @@ -25,7 +25,11 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include +/*@unused@*/ RCSID("$Id$"); +#define YASM_LIB_INTERNAL +#define YASM_BC_INTERNAL +#define YASM_EXPR_INTERNAL #include #include "coff-objfmt.h" @@ -33,36 +37,36 @@ #define UNW_FLAG_EHANDLER 0x01 #define UNW_FLAG_UHANDLER 0x02 -#define UNW_FLAG_CHAININFO 0x04 +#define UNW_FLAG_CHAININFO 0x03 /* Bytecode callback function prototypes */ static void win64_uwinfo_bc_destroy(void *contents); static void win64_uwinfo_bc_print(const void *contents, FILE *f, - int indent_level); + int indent_level); static void win64_uwinfo_bc_finalize(yasm_bytecode *bc, - yasm_bytecode *prev_bc); + yasm_bytecode *prev_bc); static int win64_uwinfo_bc_calc_len (yasm_bytecode *bc, yasm_bc_add_span_func add_span, void *add_span_data); static int win64_uwinfo_bc_expand(yasm_bytecode *bc, int span, long old_val, - long new_val, /*@out@*/ long *neg_thres, - /*@out@*/ long *pos_thres); + long new_val, /*@out@*/ long *neg_thres, + /*@out@*/ long *pos_thres); static int win64_uwinfo_bc_tobytes - (yasm_bytecode *bc, unsigned char **bufp, unsigned char *bufstart, void *d, + (yasm_bytecode *bc, unsigned char **bufp, void *d, yasm_output_value_func output_value, /*@null@*/ yasm_output_reloc_func output_reloc); static void win64_uwcode_bc_destroy(void *contents); static void win64_uwcode_bc_print(const void *contents, FILE *f, - int indent_level); + int indent_level); static void win64_uwcode_bc_finalize(yasm_bytecode *bc, - yasm_bytecode *prev_bc); + yasm_bytecode *prev_bc); static int win64_uwcode_bc_calc_len (yasm_bytecode *bc, yasm_bc_add_span_func add_span, void *add_span_data); static int win64_uwcode_bc_expand(yasm_bytecode *bc, int span, long old_val, - long new_val, /*@out@*/ long *neg_thres, - /*@out@*/ long *pos_thres); + long new_val, /*@out@*/ long *neg_thres, + /*@out@*/ long *pos_thres); static int win64_uwcode_bc_tobytes - (yasm_bytecode *bc, unsigned char **bufp, unsigned char *bufstart, void *d, + (yasm_bytecode *bc, unsigned char **bufp, void *d, yasm_output_value_func output_value, /*@null@*/ yasm_output_reloc_func output_reloc); @@ -71,7 +75,6 @@ static const yasm_bytecode_callback win64_uwinfo_bc_callback = { win64_uwinfo_bc_destroy, win64_uwinfo_bc_print, win64_uwinfo_bc_finalize, - NULL, win64_uwinfo_bc_calc_len, win64_uwinfo_bc_expand, win64_uwinfo_bc_tobytes, @@ -82,7 +85,6 @@ static const yasm_bytecode_callback win64_uwcode_bc_callback = { win64_uwcode_bc_destroy, win64_uwcode_bc_print, win64_uwcode_bc_finalize, - NULL, win64_uwcode_bc_calc_len, win64_uwcode_bc_expand, win64_uwcode_bc_tobytes, @@ -116,32 +118,32 @@ yasm_win64__uwinfo_destroy(coff_unwind_info *info) yasm_value_delete(&info->codes_count); while (!SLIST_EMPTY(&info->codes)) { - code = SLIST_FIRST(&info->codes); - SLIST_REMOVE_HEAD(&info->codes, link); - yasm_value_delete(&code->off); - yasm_xfree(code); + code = SLIST_FIRST(&info->codes); + SLIST_REMOVE_HEAD(&info->codes, link); + yasm_value_delete(&code->off); + yasm_xfree(code); } yasm_xfree(info); } void yasm_win64__unwind_generate(yasm_section *xdata, coff_unwind_info *info, - unsigned long line) + unsigned long line) { yasm_bytecode *infobc, *codebc = NULL; coff_unwind_code *code; /* 4-byte align the start of unwind info */ yasm_section_bcs_append(xdata, yasm_bc_create_align( - yasm_expr_create_ident(yasm_expr_int(yasm_intnum_create_uint(4)), - line), - NULL, NULL, NULL, line)); + yasm_expr_create_ident(yasm_expr_int(yasm_intnum_create_uint(4)), + line), + NULL, NULL, NULL, line)); /* Prolog size = end of prolog - start of procedure */ yasm_value_initialize(&info->prolog_size, - yasm_expr_create(YASM_EXPR_SUB, yasm_expr_sym(info->prolog), - yasm_expr_sym(info->proc), line), - 8); + yasm_expr_create(YASM_EXPR_SUB, yasm_expr_sym(info->prolog), + yasm_expr_sym(info->proc), line), + 8); /* Unwind info */ infobc = yasm_bc_create_common(&win64_uwinfo_bc_callback, info, line); @@ -149,9 +151,9 @@ yasm_win64__unwind_generate(yasm_section *xdata, coff_unwind_info *info, /* Code array */ SLIST_FOREACH(code, &info->codes, link) { - codebc = yasm_bc_create_common(&win64_uwcode_bc_callback, code, - yasm_symrec_get_def_line(code->loc)); - yasm_section_bcs_append(xdata, codebc); + codebc = yasm_bc_create_common(&win64_uwcode_bc_callback, code, + yasm_symrec_get_def_line(code->loc)); + yasm_section_bcs_append(xdata, codebc); } /* Avoid double-free (by code destroy and uwinfo destroy). */ @@ -159,34 +161,34 @@ yasm_win64__unwind_generate(yasm_section *xdata, coff_unwind_info *info, /* Number of codes = (Last code - end of info) >> 1 */ if (!codebc) { - yasm_value_initialize(&info->codes_count, - yasm_expr_create_ident(yasm_expr_int(yasm_intnum_create_uint(0)), - line), - 8); + yasm_value_initialize(&info->codes_count, + yasm_expr_create_ident(yasm_expr_int(yasm_intnum_create_uint(0)), + line), + 8); } else { - yasm_value_initialize(&info->codes_count, - yasm_expr_create(YASM_EXPR_SHR, yasm_expr_expr( - yasm_expr_create(YASM_EXPR_SUB, yasm_expr_precbc(codebc), - yasm_expr_precbc(infobc), line)), - yasm_expr_int(yasm_intnum_create_uint(1)), line), - 8); + yasm_value_initialize(&info->codes_count, + yasm_expr_create(YASM_EXPR_SHR, yasm_expr_expr( + yasm_expr_create(YASM_EXPR_SUB, yasm_expr_precbc(codebc), + yasm_expr_precbc(infobc), line)), + yasm_expr_int(yasm_intnum_create_uint(1)), line), + 8); } /* 4-byte align */ yasm_section_bcs_append(xdata, yasm_bc_create_align( - yasm_expr_create_ident(yasm_expr_int(yasm_intnum_create_uint(4)), - line), - NULL, NULL, NULL, line)); + yasm_expr_create_ident(yasm_expr_int(yasm_intnum_create_uint(4)), + line), + NULL, NULL, NULL, line)); /* Exception handler, if present. Use data bytecode. */ if (info->ehandler) { - yasm_datavalhead dvs; + yasm_datavalhead dvs; - yasm_dvs_initialize(&dvs); - yasm_dvs_append(&dvs, yasm_dv_create_expr( - yasm_expr_create_ident(yasm_expr_sym(info->ehandler), line))); - yasm_section_bcs_append(xdata, - yasm_bc_create_data(&dvs, 4, 0, NULL, line)); + yasm_dvs_initialize(&dvs); + yasm_dvs_append(&dvs, yasm_dv_create_expr( + yasm_expr_create_ident(yasm_expr_sym(info->ehandler), line))); + yasm_section_bcs_append(xdata, + yasm_bc_create_data(&dvs, 4, 0, NULL, line)); } } @@ -208,19 +210,19 @@ win64_uwinfo_bc_finalize(yasm_bytecode *bc, yasm_bytecode *prev_bc) coff_unwind_info *info = (coff_unwind_info *)bc->contents; if (yasm_value_finalize(&info->prolog_size, prev_bc)) - yasm_internal_error(N_("prolog size expression too complex")); + yasm_internal_error(N_("prolog size expression too complex")); if (yasm_value_finalize(&info->codes_count, prev_bc)) - yasm_internal_error(N_("codes count expression too complex")); + yasm_internal_error(N_("codes count expression too complex")); if (yasm_value_finalize(&info->frameoff, prev_bc)) - yasm_error_set(YASM_ERROR_VALUE, - N_("frame offset expression too complex")); + yasm_error_set(YASM_ERROR_VALUE, + N_("frame offset expression too complex")); } static int win64_uwinfo_bc_calc_len(yasm_bytecode *bc, yasm_bc_add_span_func add_span, - void *add_span_data) + void *add_span_data) { coff_unwind_info *info = (coff_unwind_info *)bc->contents; /*@only@*/ /*@null@*/ yasm_intnum *intn; @@ -234,17 +236,17 @@ win64_uwinfo_bc_calc_len(yasm_bytecode *bc, yasm_bc_add_span_func add_span, intn = yasm_value_get_intnum(&info->frameoff, bc, 0); if (intn) { - intv = yasm_intnum_get_int(intn); - if (intv < 0 || intv > 240) - yasm_error_set(YASM_ERROR_VALUE, - N_("frame offset of %ld bytes, must be between 0 and 240"), - intv); - else if ((intv & 0xF) != 0) - yasm_error_set(YASM_ERROR_VALUE, - N_("frame offset of %ld is not a multiple of 16"), intv); - yasm_intnum_destroy(intn); + intv = yasm_intnum_get_int(intn); + if (intv < 0 || intv > 240) + yasm_error_set(YASM_ERROR_VALUE, + N_("frame offset of %ld bytes, must be between 0 and 240"), + intv); + else if ((intv & 0xF) != 0) + yasm_error_set(YASM_ERROR_VALUE, + N_("frame offset of %ld is not a multiple of 16"), intv); + yasm_intnum_destroy(intn); } else - add_span(add_span_data, bc, 3, &info->frameoff, 0, 240); + add_span(add_span_data, bc, 3, &info->frameoff, 0, 240); bc->len += 4; return 0; @@ -252,36 +254,35 @@ win64_uwinfo_bc_calc_len(yasm_bytecode *bc, yasm_bc_add_span_func add_span, static int win64_uwinfo_bc_expand(yasm_bytecode *bc, int span, long old_val, long new_val, - /*@out@*/ long *neg_thres, /*@out@*/ long *pos_thres) + /*@out@*/ long *neg_thres, /*@out@*/ long *pos_thres) { coff_unwind_info *info = (coff_unwind_info *)bc->contents; switch (span) { - case 1: - yasm_error_set_xref(yasm_symrec_get_def_line(info->prolog), - N_("prologue ended here")); - yasm_error_set(YASM_ERROR_VALUE, - N_("prologue %ld bytes, must be <256"), new_val); - return -1; - case 2: - yasm_error_set(YASM_ERROR_VALUE, - N_("%ld unwind codes, maximum of 255"), new_val); - return -1; - case 3: - yasm_error_set(YASM_ERROR_VALUE, - N_("frame offset of %ld bytes, must be between 0 and 240"), - new_val); - return -1; - default: - yasm_internal_error(N_("unrecognized span id")); + case 1: + yasm_error_set_xref(yasm_symrec_get_def_line(info->prolog), + N_("prologue ended here")); + yasm_error_set(YASM_ERROR_VALUE, + N_("prologue %ld bytes, must be <256"), new_val); + return -1; + case 2: + yasm_error_set(YASM_ERROR_VALUE, + N_("%ld unwind codes, maximum of 255"), new_val); + return -1; + case 3: + yasm_error_set(YASM_ERROR_VALUE, + N_("frame offset of %ld bytes, must be between 0 and 240"), + new_val); + return -1; + default: + yasm_internal_error(N_("unrecognized span id")); } return 0; } static int -win64_uwinfo_bc_tobytes(yasm_bytecode *bc, unsigned char **bufp, - unsigned char *bufstart, void *d, - yasm_output_value_func output_value, - yasm_output_reloc_func output_reloc) +win64_uwinfo_bc_tobytes(yasm_bytecode *bc, unsigned char **bufp, void *d, + yasm_output_value_func output_value, + yasm_output_reloc_func output_reloc) { coff_unwind_info *info = (coff_unwind_info *)bc->contents; unsigned char *buf = *bufp; @@ -290,34 +291,34 @@ win64_uwinfo_bc_tobytes(yasm_bytecode *bc, unsigned char **bufp, /* Version and flags */ if (info->ehandler) - YASM_WRITE_8(buf, 1 | (UNW_FLAG_EHANDLER << 3)); + YASM_WRITE_8(buf, 1 | (UNW_FLAG_EHANDLER << 3)); else - YASM_WRITE_8(buf, 1); + YASM_WRITE_8(buf, 1); /* Size of prolog */ - output_value(&info->prolog_size, buf, 1, (unsigned long)(buf-bufstart), - bc, 1, d); + output_value(&info->prolog_size, buf, 1, (unsigned long)(buf-*bufp), + bc, 1, d); buf += 1; /* Count of codes */ - output_value(&info->codes_count, buf, 1, (unsigned long)(buf-bufstart), - bc, 1, d); + output_value(&info->codes_count, buf, 1, (unsigned long)(buf-*bufp), + bc, 1, d); buf += 1; /* Frame register and offset */ frameoff = yasm_value_get_intnum(&info->frameoff, bc, 1); if (!frameoff) { - yasm_error_set(YASM_ERROR_VALUE, - N_("frame offset expression too complex")); - return 1; + yasm_error_set(YASM_ERROR_VALUE, + N_("frame offset expression too complex")); + return 1; } intv = yasm_intnum_get_int(frameoff); if (intv < 0 || intv > 240) - yasm_error_set(YASM_ERROR_VALUE, - N_("frame offset of %ld bytes, must be between 0 and 240"), intv); + yasm_error_set(YASM_ERROR_VALUE, + N_("frame offset of %ld bytes, must be between 0 and 240"), intv); else if ((intv & 0xF) != 0) - yasm_error_set(YASM_ERROR_VALUE, - N_("frame offset of %ld is not a multiple of 16"), intv); + yasm_error_set(YASM_ERROR_VALUE, + N_("frame offset of %ld is not a multiple of 16"), intv); YASM_WRITE_8(buf, ((unsigned long)intv & 0xF0) | (info->framereg & 0x0F)); yasm_intnum_destroy(frameoff); @@ -345,12 +346,12 @@ win64_uwcode_bc_finalize(yasm_bytecode *bc, yasm_bytecode *prev_bc) { coff_unwind_code *code = (coff_unwind_code *)bc->contents; if (yasm_value_finalize(&code->off, prev_bc)) - yasm_error_set(YASM_ERROR_VALUE, N_("offset expression too complex")); + yasm_error_set(YASM_ERROR_VALUE, N_("offset expression too complex")); } static int win64_uwcode_bc_calc_len(yasm_bytecode *bc, yasm_bc_add_span_func add_span, - void *add_span_data) + void *add_span_data) { coff_unwind_code *code = (coff_unwind_code *)bc->contents; int span = 0; @@ -361,108 +362,107 @@ win64_uwcode_bc_calc_len(yasm_bytecode *bc, yasm_bc_add_span_func add_span, bc->len += 2; /* Prolog offset, code, and info */ switch (code->opcode) { - case UWOP_PUSH_NONVOL: - case UWOP_SET_FPREG: - case UWOP_PUSH_MACHFRAME: - /* always 1 node */ - return 0; - case UWOP_ALLOC_SMALL: - case UWOP_ALLOC_LARGE: - /* Start with smallest, then work our way up as necessary */ - code->opcode = UWOP_ALLOC_SMALL; - code->info = 0; - span = 1; low = 8; high = 128; mask = 0x7; - break; - case UWOP_SAVE_NONVOL: - case UWOP_SAVE_NONVOL_FAR: - /* Start with smallest, then work our way up as necessary */ - code->opcode = UWOP_SAVE_NONVOL; - bc->len += 2; /* Scaled offset */ - span = 2; - low = 0; - high = 8*64*1024-8; /* 16-bit field, *8 scaling */ - mask = 0x7; - break; - case UWOP_SAVE_XMM128: - case UWOP_SAVE_XMM128_FAR: - /* Start with smallest, then work our way up as necessary */ - code->opcode = UWOP_SAVE_XMM128; - bc->len += 2; /* Scaled offset */ - span = 3; - low = 0; - high = 16*64*1024-16; /* 16-bit field, *16 scaling */ - mask = 0xF; - break; - default: - yasm_internal_error(N_("unrecognied unwind opcode")); - /*@unreached@*/ - return 0; + case UWOP_PUSH_NONVOL: + case UWOP_SET_FPREG: + case UWOP_PUSH_MACHFRAME: + /* always 1 node */ + return 0; + case UWOP_ALLOC_SMALL: + case UWOP_ALLOC_LARGE: + /* Start with smallest, then work our way up as necessary */ + code->opcode = UWOP_ALLOC_SMALL; + code->info = 0; + span = 1; low = 8; high = 128; mask = 0x7; + break; + case UWOP_SAVE_NONVOL: + case UWOP_SAVE_NONVOL_FAR: + /* Start with smallest, then work our way up as necessary */ + code->opcode = UWOP_SAVE_NONVOL; + bc->len += 2; /* Scaled offset */ + span = 2; + low = 0; + high = 8*64*1024-8; /* 16-bit field, *8 scaling */ + mask = 0x7; + break; + case UWOP_SAVE_XMM128: + case UWOP_SAVE_XMM128_FAR: + /* Start with smallest, then work our way up as necessary */ + code->opcode = UWOP_SAVE_XMM128; + bc->len += 2; /* Scaled offset */ + span = 3; + low = 0; + high = 16*64*1024-16; /* 16-bit field, *16 scaling */ + mask = 0xF; + break; + default: + yasm_internal_error(N_("unrecognied unwind opcode")); + /*@unreached@*/ + return 0; } intn = yasm_value_get_intnum(&code->off, bc, 0); if (intn) { - intv = yasm_intnum_get_int(intn); - if (intv > high) { - /* Expand it ourselves here if we can and we're already larger */ - if (win64_uwcode_bc_expand(bc, span, intv, intv, &low, &high) > 0) - add_span(add_span_data, bc, span, &code->off, low, high); - } - if (intv < low) - yasm_error_set(YASM_ERROR_VALUE, - N_("negative offset not allowed")); - if ((intv & mask) != 0) - yasm_error_set(YASM_ERROR_VALUE, - N_("offset of %ld is not a multiple of %ld"), intv, mask+1); - yasm_intnum_destroy(intn); + intv = yasm_intnum_get_int(intn); + if (intv > high) { + /* Expand it ourselves here if we can and we're already larger */ + if (win64_uwcode_bc_expand(bc, span, intv, intv, &low, &high) > 0) + add_span(add_span_data, bc, span, &code->off, low, high); + } + if (intv < low) + yasm_error_set(YASM_ERROR_VALUE, + N_("negative offset not allowed")); + if ((intv & mask) != 0) + yasm_error_set(YASM_ERROR_VALUE, + N_("offset of %ld is not a multiple of %ld"), intv, mask+1); + yasm_intnum_destroy(intn); } else - add_span(add_span_data, bc, span, &code->off, low, high); + add_span(add_span_data, bc, span, &code->off, low, high); return 0; } static int win64_uwcode_bc_expand(yasm_bytecode *bc, int span, long old_val, long new_val, - /*@out@*/ long *neg_thres, /*@out@*/ long *pos_thres) + /*@out@*/ long *neg_thres, /*@out@*/ long *pos_thres) { coff_unwind_code *code = (coff_unwind_code *)bc->contents; if (new_val < 0) { - yasm_error_set(YASM_ERROR_VALUE, N_("negative offset not allowed")); - return -1; + yasm_error_set(YASM_ERROR_VALUE, N_("negative offset not allowed")); + return -1; } if (span == 1) { - /* 3 stages: SMALL, LARGE and info=0, LARGE and info=1 */ - if (code->opcode == UWOP_ALLOC_LARGE && code->info == 1) - yasm_internal_error(N_("expansion on already largest alloc")); + /* 3 stages: SMALL, LARGE and info=0, LARGE and info=1 */ + if (code->opcode == UWOP_ALLOC_LARGE && code->info == 1) + yasm_internal_error(N_("expansion on already largest alloc")); - if (code->opcode == UWOP_ALLOC_SMALL && new_val > 128) { - /* Overflowed small size */ - code->opcode = UWOP_ALLOC_LARGE; - bc->len += 2; - } - if (new_val <= 8*64*1024-8) { - /* Still can grow one more size */ - *pos_thres = 8*64*1024-8; - return 1; - } - /* We're into the largest size */ - code->info = 1; - bc->len += 2; + if (code->opcode == UWOP_ALLOC_SMALL && new_val > 128) { + /* Overflowed small size */ + code->opcode = UWOP_ALLOC_LARGE; + bc->len += 2; + } + if (new_val <= 8*64*1024-8) { + /* Still can grow one more size */ + *pos_thres = 8*64*1024-8; + return 1; + } + /* We're into the largest size */ + code->info = 1; + bc->len += 2; } else if (code->opcode == UWOP_SAVE_NONVOL && span == 2) { - code->opcode = UWOP_SAVE_NONVOL_FAR; - bc->len += 2; + code->opcode = UWOP_SAVE_NONVOL_FAR; + bc->len += 2; } else if (code->opcode == UWOP_SAVE_XMM128 && span == 3) { - code->opcode = UWOP_SAVE_XMM128_FAR; - bc->len += 2; + code->opcode = UWOP_SAVE_XMM128_FAR; + bc->len += 2; } return 0; } static int -win64_uwcode_bc_tobytes(yasm_bytecode *bc, unsigned char **bufp, - unsigned char *bufstart, void *d, - yasm_output_value_func output_value, - yasm_output_reloc_func output_reloc) +win64_uwcode_bc_tobytes(yasm_bytecode *bc, unsigned char **bufp, void *d, + yasm_output_value_func output_value, + yasm_output_reloc_func output_reloc) { coff_unwind_code *code = (coff_unwind_code *)bc->contents; unsigned char *buf = *bufp; @@ -474,82 +474,82 @@ win64_uwcode_bc_tobytes(yasm_bytecode *bc, unsigned char **bufp, /* Offset in prolog */ yasm_value_initialize(&val, - yasm_expr_create(YASM_EXPR_SUB, yasm_expr_sym(code->loc), - yasm_expr_sym(code->proc), bc->line), - 8); - output_value(&val, buf, 1, (unsigned long)(buf-bufstart), bc, 1, d); + yasm_expr_create(YASM_EXPR_SUB, yasm_expr_sym(code->loc), + yasm_expr_sym(code->proc), bc->line), + 8); + output_value(&val, buf, 1, (unsigned long)(buf-*bufp), bc, 1, d); buf += 1; yasm_value_delete(&val); /* Offset value */ switch (code->opcode) { - case UWOP_PUSH_NONVOL: - case UWOP_SET_FPREG: - case UWOP_PUSH_MACHFRAME: - /* just 1 node, no offset; write opcode and info and we're done */ - YASM_WRITE_8(buf, (code->info << 4) | (code->opcode & 0xF)); - *bufp = buf; - return 0; - case UWOP_ALLOC_SMALL: - /* 1 node, but offset stored in info */ - size = 0; low = 8; high = 128; shift = 3; mask = 0x7; - break; - case UWOP_ALLOC_LARGE: - if (code->info == 0) { - size = 2; low = 136; high = 8*64*1024-8; shift = 3; - } else { - size = 4; low = high = 0; shift = 0; - } - mask = 0x7; - break; - case UWOP_SAVE_NONVOL: - size = 2; low = 0; high = 8*64*1024-8; shift = 3; mask = 0x7; - break; - case UWOP_SAVE_XMM128: - size = 2; low = 0; high = 16*64*1024-16; shift = 4; mask = 0xF; - break; - case UWOP_SAVE_NONVOL_FAR: - size = 4; low = high = 0; shift = 0; mask = 0x7; - break; - case UWOP_SAVE_XMM128_FAR: - size = 4; low = high = 0; shift = 0; mask = 0xF; - break; - default: - yasm_internal_error(N_("unrecognied unwind opcode")); - /*@unreached@*/ - return 1; + case UWOP_PUSH_NONVOL: + case UWOP_SET_FPREG: + case UWOP_PUSH_MACHFRAME: + /* just 1 node, no offset; write opcode and info and we're done */ + YASM_WRITE_8(buf, (code->info << 4) | (code->opcode & 0xF)); + *bufp = buf; + return 0; + case UWOP_ALLOC_SMALL: + /* 1 node, but offset stored in info */ + size = 0; low = 8; high = 128; shift = 3; mask = 0x7; + break; + case UWOP_ALLOC_LARGE: + if (code->info == 0) { + size = 2; low = 136; high = 8*64*1024-8; shift = 3; + } else { + size = 4; low = high = 0; shift = 0; + } + mask = 0x7; + break; + case UWOP_SAVE_NONVOL: + size = 2; low = 0; high = 8*64*1024-8; shift = 3; mask = 0x7; + break; + case UWOP_SAVE_XMM128: + size = 2; low = 0; high = 16*64*1024-16; shift = 4; mask = 0xF; + break; + case UWOP_SAVE_NONVOL_FAR: + size = 4; low = high = 0; shift = 0; mask = 0x7; + break; + case UWOP_SAVE_XMM128_FAR: + size = 4; low = high = 0; shift = 0; mask = 0xF; + break; + default: + yasm_internal_error(N_("unrecognied unwind opcode")); + /*@unreached@*/ + return 1; } /* Check for overflow */ intn = yasm_value_get_intnum(&code->off, bc, 1); if (!intn) { - yasm_error_set(YASM_ERROR_VALUE, N_("offset expression too complex")); - return 1; + yasm_error_set(YASM_ERROR_VALUE, N_("offset expression too complex")); + return 1; } intv = yasm_intnum_get_int(intn); if (size != 4 && (intv < low || intv > high)) { - yasm_error_set(YASM_ERROR_VALUE, - N_("offset of %ld bytes, must be between %ld and %ld"), - intv, low, high); - return 1; + yasm_error_set(YASM_ERROR_VALUE, + N_("offset of %ld bytes, must be between %ld and %ld"), + intv, low, high); + return 1; } if ((intv & mask) != 0) { - yasm_error_set(YASM_ERROR_VALUE, - N_("offset of %ld is not a multiple of %ld"), - intv, mask+1); - return 1; + yasm_error_set(YASM_ERROR_VALUE, + N_("offset of %ld is not a multiple of %ld"), + intv, mask+1); + return 1; } /* Stored value in info instead of extra code space */ if (size == 0) - code->info = (yasm_intnum_get_uint(intn) >> shift)-1; + code->info = (yasm_intnum_get_uint(intn) >> shift)-1; /* Opcode and info */ YASM_WRITE_8(buf, (code->info << 4) | (code->opcode & 0xF)); if (size != 0) { - yasm_intnum_get_sized(intn, buf, size, size*8, -shift, 0, 1); - buf += size; + yasm_intnum_get_sized(intn, buf, size, size*8, -shift, 0, 1); + buf += size; } yasm_intnum_destroy(intn); diff --git a/modules/objfmts/coff/win64-gas.mac b/modules/objfmts/coff/win64-gas.mac deleted file mode 100644 index c8c36fbc..00000000 --- a/modules/objfmts/coff/win64-gas.mac +++ /dev/null @@ -1,73 +0,0 @@ -%imacro export 1+.nolist -.export %1 -%endmacro - -; Raw exception handling operations -%imacro proc_frame 1+.nolist -%1: -.proc_frame %1 -%endmacro - -%imacro endproc_frame 0.nolist -.endproc_frame -%endmacro - -; Complex (macro) exception handling operations -; Mimics many macros provided by MASM's macamd64.inc -%imacro push_reg 1 -pushq %1 -.pushreg %1 -%endmacro - -%imacro rex_push_reg 1 -.byte 0x48 -pushq %1 -.pushreg %1 -%endmacro - -%imacro push_eflags 0 -pushfq -.allocstack 8 -%endmacro - -%imacro rex_push_eflags 0 -.byte 0x48 -pushfq -.allocstack 8 -%endmacro - -%imacro alloc_stack 1 -subq $%1, %rsp -.allocstack %1 -%endmacro - -%imacro save_reg 2 -movq %1, %2(%rsp) -.savereg %1 %2 -%endmacro - -%imacro save_xmm128 2 -movdqa %1, %2(%rsp) -.savexmm128 %1, %2 -%endmacro - -%imacro push_frame 0-1.nolist -.pushframe %1 -%endmacro - -%imacro set_frame 1-2 -%if %0==1 -movq %rsp, %1 -%else -leaq %2(%rsp), %1 -%endif -.setframe %1, %2 -%endmacro - -%imacro end_prolog 0.nolist -.endprolog -%endmacro - -%imacro end_prologue 0.nolist -.endprolog -%endmacro diff --git a/modules/objfmts/coff/win64-nasm.mac b/modules/objfmts/coff/win64-nasm.mac deleted file mode 100644 index 13954b89..00000000 --- a/modules/objfmts/coff/win64-nasm.mac +++ /dev/null @@ -1,106 +0,0 @@ -%imacro export 1+.nolist -[export %1] -%endmacro - -; Raw exception handling operations -%imacro proc_frame 1+.nolist -%1: -[proc_frame %1] -%endmacro - -; Disable these as they're too closely named to the macroized ones. -; MASM needs a preceding . to use these, so it seems reasonable for -; us to similarly require the []. -; -;%imacro pushreg 1.nolist -;[pushreg %1] -;%endmacro -; -;%imacro setframe 1-2.nolist -;[setframe %1 %2] -;%endmacro -; -;%imacro allocstack 1.nolist -;[allocstack %1] -;%endmacro -; -;%imacro savereg 2.nolist -;[savereg %1 %2] -;%endmacro -; -;%imacro savexmm128 2.nolist -;[savexmm128 %1 %2] -;%endmacro -; -;%imacro pushframe 0-1.nolist -;[pushframe %1] -;%endmacro -; -;%imacro endprolog 0.nolist -;[endprolog] -;%endmacro -; - -%imacro endproc_frame 0.nolist -[endproc_frame] -%endmacro - -; Complex (macro) exception handling operations -; Mimics many macros provided by MASM's macamd64.inc -%imacro push_reg 1 -push %1 -[pushreg %1] -%endmacro - -%imacro rex_push_reg 1 -db 0x48 -push %1 -[pushreg %1] -%endmacro - -%imacro push_eflags 0 -pushfq -[allocstack 8] -%endmacro - -%imacro rex_push_eflags 0 -db 0x48 -pushfq -[allocstack 8] -%endmacro - -%imacro alloc_stack 1 -sub rsp, %1 -[allocstack %1] -%endmacro - -%imacro save_reg 2 -mov [rsp+%2], %1 -[savereg %1 %2] -%endmacro - -%imacro save_xmm128 2 -movdqa [rsp+%2], %1 -[savexmm128 %1 %2] -%endmacro - -%imacro push_frame 0-1.nolist -[pushframe %1] -%endmacro - -%imacro set_frame 1-2 -%if %0==1 -mov %1, rsp -%else -lea %1, [rsp+%2] -%endif -[setframe %1 %2] -%endmacro - -%imacro end_prolog 0.nolist -[endprolog] -%endmacro - -%imacro end_prologue 0.nolist -[endprolog] -%endmacro diff --git a/modules/objfmts/dbg/CMakeLists.txt b/modules/objfmts/dbg/CMakeLists.txt deleted file mode 100644 index ba5193fa..00000000 --- a/modules/objfmts/dbg/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -YASM_ADD_MODULE(objfmt_dbg - objfmts/dbg/dbg-objfmt.c - ) diff --git a/modules/objfmts/dbg/Makefile.inc b/modules/objfmts/dbg/Makefile.inc index cfc9b75b..4ccfb570 100644 --- a/modules/objfmts/dbg/Makefile.inc +++ b/modules/objfmts/dbg/Makefile.inc @@ -1,3 +1,5 @@ +# $Id$ + libyasm_a_SOURCES += modules/objfmts/dbg/dbg-objfmt.c YASM_MODULES += objfmt_dbg diff --git a/modules/objfmts/dbg/dbg-objfmt.c b/modules/objfmts/dbg/dbg-objfmt.c index bdf403c7..74d7a572 100644 --- a/modules/objfmts/dbg/dbg-objfmt.c +++ b/modules/objfmts/dbg/dbg-objfmt.c @@ -25,12 +25,14 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include +/*@unused@*/ RCSID("$Id$"); +#define YASM_LIB_INTERNAL #include typedef struct yasm_objfmt_dbg { - yasm_objfmt_base objfmt; /* base structure */ + yasm_objfmt_base objfmt; /* base structure */ FILE *dbgfile; } yasm_objfmt_dbg; @@ -47,8 +49,8 @@ dbg_objfmt_create(yasm_object *object) objfmt_dbg->dbgfile = tmpfile(); if (!objfmt_dbg->dbgfile) { - fprintf(stderr, N_("could not open temporary file")); - return 0; + fprintf(stderr, N_("could not open temporary file")); + return 0; } fprintf(objfmt_dbg->dbgfile, "create()\n"); return (yasm_objfmt *)objfmt_dbg; @@ -56,7 +58,7 @@ dbg_objfmt_create(yasm_object *object) static void dbg_objfmt_output(yasm_object *object, FILE *f, int all_syms, - yasm_errwarns *errwarns) + yasm_errwarns *errwarns) { yasm_objfmt_dbg *objfmt_dbg = (yasm_objfmt_dbg *)object->objfmt; char buf[1024]; @@ -65,8 +67,8 @@ dbg_objfmt_output(yasm_object *object, FILE *f, int all_syms, /* Copy temp file to real output file */ rewind(objfmt_dbg->dbgfile); while ((i = fread(buf, 1, 1024, objfmt_dbg->dbgfile))) { - if (fwrite(buf, 1, i, f) != i) - break; + if (fwrite(buf, 1, i, f) != i) + break; } /* Reassign objfmt debug file to output file */ @@ -88,17 +90,6 @@ dbg_objfmt_destroy(yasm_objfmt *objfmt) yasm_xfree(objfmt); } -static void -dbg_objfmt_init_new_section(yasm_section *sect, unsigned long line) -{ - yasm_object *object = yasm_section_get_object(sect); - yasm_objfmt_dbg *objfmt_dbg = (yasm_objfmt_dbg *)object->objfmt; - fprintf(objfmt_dbg->dbgfile, "init_new_section(\"%s\", %lu)\n", - yasm_section_get_name(sect), line); - yasm_symtab_define_label(object->symtab, ".text", - yasm_section_bcs_first(sect), 1, 0); -} - static yasm_section * dbg_objfmt_add_default_section(yasm_object *object) { @@ -106,19 +97,23 @@ dbg_objfmt_add_default_section(yasm_object *object) yasm_section *retval; int isnew; - fprintf(objfmt_dbg->dbgfile, "add_default_section()\n"); - retval = yasm_object_get_general(object, ".text", 0, 0, 0, &isnew, 0); + retval = yasm_object_get_general(object, ".text", + yasm_expr_create_ident(yasm_expr_int(yasm_intnum_create_uint(200)), 0), + 0, 0, 0, &isnew, 0); if (isnew) { - yasm_section_set_default(retval, 1); + fprintf(objfmt_dbg->dbgfile, "(new) "); + yasm_symtab_define_label(object->symtab, ".text", + yasm_section_bcs_first(retval), 1, 0); + yasm_section_set_default(retval, 1); } return retval; } static /*@observer@*/ /*@null@*/ yasm_section * dbg_objfmt_section_switch(yasm_object *object, yasm_valparamhead *valparams, - /*@unused@*/ /*@null@*/ - yasm_valparamhead *objext_valparams, - unsigned long line) + /*@unused@*/ /*@null@*/ + yasm_valparamhead *objext_valparams, + unsigned long line) { yasm_objfmt_dbg *objfmt_dbg = (yasm_objfmt_dbg *)object->objfmt; yasm_valparam *vp; @@ -136,24 +131,17 @@ dbg_objfmt_section_switch(yasm_object *object, yasm_valparamhead *valparams, fprintf(objfmt_dbg->dbgfile, "NULL\n"); return NULL; } - retval = yasm_object_get_general(object, yasm_vp_string(vp), 0, 0, 0, - &isnew, line); - if (isnew) { - fprintf(objfmt_dbg->dbgfile, "(new) "); - } - yasm_section_set_default(retval, 0); - fprintf(objfmt_dbg->dbgfile, "\"%s\" section\n", vp->val); - return retval; -} - -static /*@observer@*/ /*@null@*/ yasm_symrec * -dbg_objfmt_get_special_sym(yasm_object *object, const char *name, - const char *parser) -{ - yasm_objfmt_dbg *objfmt_dbg = (yasm_objfmt_dbg *)object->objfmt; - fprintf(objfmt_dbg->dbgfile, "get_special_sym(object, \"%s\", \"%s\")\n", - name, parser); - return NULL; + retval = yasm_object_get_general(object, yasm_vp_string(vp), + yasm_expr_create_ident(yasm_expr_int(yasm_intnum_create_uint(200)), + line), 0, 0, 0, &isnew, line); + if (isnew) { + fprintf(objfmt_dbg->dbgfile, "(new) "); + yasm_symtab_define_label(object->symtab, vp->val, + yasm_section_bcs_first(retval), 1, line); + } + yasm_section_set_default(retval, 0); + fprintf(objfmt_dbg->dbgfile, "\"%s\" section\n", vp->val); + return retval; } /* Define valid debug formats to use with this object format */ @@ -168,16 +156,12 @@ yasm_objfmt_module yasm_dbg_LTX_objfmt = { "dbg", "dbg", 32, - 0, dbg_objfmt_dbgfmt_keywords, "null", - NULL, /* no directives */ - NULL, /* no standard macros */ + NULL, /* no directives */ dbg_objfmt_create, dbg_objfmt_output, dbg_objfmt_destroy, dbg_objfmt_add_default_section, - dbg_objfmt_init_new_section, - dbg_objfmt_section_switch, - dbg_objfmt_get_special_sym + dbg_objfmt_section_switch }; diff --git a/modules/objfmts/elf/CMakeLists.txt b/modules/objfmts/elf/CMakeLists.txt deleted file mode 100644 index 444e9a8b..00000000 --- a/modules/objfmts/elf/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -YASM_ADD_MODULE(objfmt_elf - objfmts/elf/elf.c - objfmts/elf/elf-objfmt.c - objfmts/elf/elf-x86-x86.c - objfmts/elf/elf-x86-amd64.c - objfmts/elf/elf-x86-x32.c - ) -list(APPEND YASM_MODULES objfmt_elf32) -list(APPEND YASM_MODULES objfmt_elf64) -list(APPEND YASM_MODULES objfmt_elfx32) diff --git a/modules/objfmts/elf/Makefile.inc b/modules/objfmts/elf/Makefile.inc index 54657657..7e37b5ba 100644 --- a/modules/objfmts/elf/Makefile.inc +++ b/modules/objfmts/elf/Makefile.inc @@ -1,12 +1,13 @@ +# $Id$ + libyasm_a_SOURCES += modules/objfmts/elf/elf.c libyasm_a_SOURCES += modules/objfmts/elf/elf.h libyasm_a_SOURCES += modules/objfmts/elf/elf-objfmt.c libyasm_a_SOURCES += modules/objfmts/elf/elf-machine.h libyasm_a_SOURCES += modules/objfmts/elf/elf-x86-x86.c libyasm_a_SOURCES += modules/objfmts/elf/elf-x86-amd64.c -libyasm_a_SOURCES += modules/objfmts/elf/elf-x86-x32.c -YASM_MODULES += objfmt_elf objfmt_elf32 objfmt_elf64 objfmt_elfx32 +YASM_MODULES += objfmt_elf objfmt_elf32 objfmt_elf64 EXTRA_DIST += modules/objfmts/elf/tests/Makefile.inc diff --git a/modules/objfmts/elf/elf-machine.h b/modules/objfmts/elf/elf-machine.h index ea6cb4ec..8b8a8dd6 100644 --- a/modules/objfmts/elf/elf-machine.h +++ b/modules/objfmts/elf/elf-machine.h @@ -1,4 +1,4 @@ -/* +/* $Id:$ * ELF object machine specific format helpers * * Copyright (C) 2004-2007 Michael Urman @@ -42,9 +42,10 @@ YASM_WRITE_32_L(p, lo); \ YASM_WRITE_32_L(p, hi); } while (0) -#define YASM_WRITE_64Z_L(p, i) YASM_WRITE_64C_L(p, 0, i) +#define YASM_WRITE_64Z_L(p, i) YASM_WRITE_64C_L(p, 0, i) -typedef int(*func_accepts_reloc)(size_t val, yasm_symrec *wrt); +typedef int(*func_accepts_reloc)(size_t val, yasm_symrec *wrt, + yasm_symrec **ssyms); typedef void(*func_write_symtab_entry)(unsigned char *bufp, elf_symtab_entry *entry, yasm_intnum *value_intn, @@ -56,9 +57,9 @@ typedef void(*func_write_secthead_rel)(unsigned char *bufp, elf_section_index sindex); typedef void(*func_handle_reloc_addend)(yasm_intnum *intn, - elf_reloc_entry *reloc, - unsigned long offset); -typedef unsigned int(*func_map_reloc_info_to_type)(elf_reloc_entry *reloc); + elf_reloc_entry *reloc); +typedef unsigned int(*func_map_reloc_info_to_type)(elf_reloc_entry *reloc, + yasm_symrec **ssyms); typedef void(*func_write_reloc)(unsigned char *bufp, elf_reloc_entry *reloc, unsigned int r_type, @@ -68,17 +69,9 @@ typedef void (*func_write_proghead)(unsigned char **bufpp, unsigned long secthead_count, elf_section_index shstrtab_index); -enum { - ELF_SSYM_SYM_RELATIVE = 1 << 0, - ELF_SSYM_CURPOS_ADJUST = 1 << 1, - ELF_SSYM_THREAD_LOCAL = 1 << 2 -}; - typedef struct { - const char *name; /* should be something like ..name */ - const int sym_rel; /* symbol or section-relative? */ - const unsigned int reloc; /* relocation type */ - const unsigned int size; /* legal data size */ + const char *name; /* should be something like ..name */ + const int sym_rel; /* symbol or section-relative? */ } elf_machine_ssym; struct elf_machine_handler { @@ -99,10 +92,10 @@ struct elf_machine_handler { func_write_reloc write_reloc; func_write_proghead write_proghead; - elf_machine_ssym *ssyms; /* array of "special" syms */ - const size_t num_ssyms; /* size of array */ + const elf_machine_ssym *ssyms; /* array of "special" syms */ + const size_t num_ssyms; /* size of array */ - const int bits; /* usually 32 or 64 */ + const int bits; /* usually 32 or 64 */ }; #endif /* ELF_MACHINE_H_INCLUDED */ diff --git a/modules/objfmts/elf/elf-objfmt.c b/modules/objfmts/elf/elf-objfmt.c index c4360c03..bca3efd5 100644 --- a/modules/objfmts/elf/elf-objfmt.c +++ b/modules/objfmts/elf/elf-objfmt.c @@ -25,6 +25,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include +/*@unused@*/ RCSID("$Id$"); /* Notes * @@ -43,20 +44,23 @@ * Each Section is spatially disjoint, and has exactly one SHT entry. */ +#define YASM_LIB_INTERNAL +#define YASM_BC_INTERNAL +#define YASM_EXPR_INTERNAL #include #include "elf.h" #include "elf-machine.h" typedef struct yasm_objfmt_elf { - yasm_objfmt_base objfmt; /* base structure */ + yasm_objfmt_base objfmt; /* base structure */ - elf_symtab_head* elf_symtab; /* symbol table of indexed syms */ - elf_strtab_head* shstrtab; /* section name strtab */ - elf_strtab_head* strtab; /* strtab entries */ + elf_symtab_head* elf_symtab; /* symbol table of indexed syms */ + elf_strtab_head* shstrtab; /* section name strtab */ + elf_strtab_head* strtab; /* strtab entries */ elf_strtab_entry *file_strtab_entry;/* .file symbol associated string */ - yasm_symrec *dotdotsym; /* ..sym symbol */ + yasm_symrec *dotdotsym; /* ..sym symbol */ } yasm_objfmt_elf; typedef struct { @@ -67,7 +71,6 @@ typedef struct { yasm_section *sect; yasm_object *object; unsigned long sindex; - yasm_symrec *GOT_sym; } elf_objfmt_output_info; typedef struct { @@ -80,30 +83,27 @@ typedef struct { yasm_objfmt_module yasm_elf_LTX_objfmt; yasm_objfmt_module yasm_elf32_LTX_objfmt; yasm_objfmt_module yasm_elf64_LTX_objfmt; -yasm_objfmt_module yasm_elfx32_LTX_objfmt; static elf_symtab_entry * elf_objfmt_symtab_append(yasm_objfmt_elf *objfmt_elf, yasm_symrec *sym, - elf_section_index sectidx, elf_symbol_binding bind, - elf_symbol_type type, elf_symbol_vis vis, - yasm_expr *size, elf_address *value, - yasm_object *object) + elf_section_index sectidx, elf_symbol_binding bind, + elf_symbol_type type, elf_symbol_vis vis, + yasm_expr *size, elf_address *value) { elf_symtab_entry *entry = yasm_symrec_get_data(sym, &elf_symrec_data); if (!entry) { - /*@only@*/ char *symname = yasm_symrec_get_global_name(sym, object); - elf_strtab_entry *name = - elf_strtab_append_str(objfmt_elf->strtab, symname); - yasm_xfree(symname); - entry = elf_symtab_entry_create(name, sym); - yasm_symrec_add_data(sym, &elf_symrec_data, entry); + elf_strtab_entry *name = + elf_strtab_append_str(objfmt_elf->strtab, + yasm_symrec_get_name(sym)); + entry = elf_symtab_entry_create(name, sym); + yasm_symrec_add_data(sym, &elf_symrec_data, entry); } /* Only append to table if not already appended */ if (!elf_sym_in_table(entry)) - elf_symtab_append_entry(objfmt_elf->elf_symtab, entry); + elf_symtab_append_entry(objfmt_elf->elf_symtab, entry); elf_symtab_set_nonzero(entry, NULL, sectidx, bind, type, size, value); elf_sym_set_visibility(entry, vis); @@ -112,23 +112,23 @@ elf_objfmt_symtab_append(yasm_objfmt_elf *objfmt_elf, yasm_symrec *sym, } static elf_symtab_entry * -build_extern(yasm_objfmt_elf *objfmt_elf, yasm_symrec *sym, yasm_object *object) +build_extern(yasm_objfmt_elf *objfmt_elf, yasm_symrec *sym) { yasm_valparamhead *objext_valparams = - yasm_symrec_get_objext_valparams(sym); + yasm_symrec_get_objext_valparams(sym); if (objext_valparams) { - yasm_valparam *vp = yasm_vps_first(objext_valparams); - for (; vp; vp = yasm_vps_next(vp)) { + yasm_valparam *vp = yasm_vps_first(objext_valparams); + for (; vp; vp = yasm_vps_next(vp)) { if (yasm_vp_string(vp)) - yasm_error_set(YASM_ERROR_TYPE, + yasm_error_set(YASM_ERROR_TYPE, N_("unrecognized symbol type `%s'"), yasm_vp_string(vp)); - } + } } return elf_objfmt_symtab_append(objfmt_elf, sym, SHN_UNDEF, STB_GLOBAL, 0, - STV_DEFAULT, NULL, NULL, object); + STV_DEFAULT, NULL, NULL); } struct elf_build_global_data { @@ -169,10 +169,10 @@ elf_global_helper_vis(void *obj, yasm_valparam *vp, unsigned long line, static elf_symtab_entry * -build_global(yasm_objfmt_elf *objfmt_elf, yasm_symrec *sym, yasm_object *object) +build_global(yasm_objfmt_elf *objfmt_elf, yasm_symrec *sym) { yasm_valparamhead *objext_valparams = - yasm_symrec_get_objext_valparams(sym); + yasm_symrec_get_objext_valparams(sym); struct elf_build_global_data data; @@ -199,13 +199,12 @@ build_global(yasm_objfmt_elf *objfmt_elf, yasm_symrec *sym, yasm_object *object) &data, elf_global_helper_valparam); if (data.vis_overrides > 1) { - yasm_warn_set(YASM_WARN_GENERAL, - N_("More than one symbol visibility provided; using last")); - } + yasm_warn_set(YASM_WARN_GENERAL, + N_("More than one symbol visibility provided; using last")); + } return elf_objfmt_symtab_append(objfmt_elf, sym, SHN_UNDEF, STB_GLOBAL, - data.type, data.vis, data.size, NULL, - object); + data.type, data.vis, data.size, NULL); } static /*@null@*/ elf_symtab_entry * @@ -213,11 +212,11 @@ build_common(yasm_objfmt_elf *objfmt_elf, yasm_symrec *sym, yasm_object *object) { yasm_expr **size = yasm_symrec_get_common_size(sym); yasm_valparamhead *objext_valparams = - yasm_symrec_get_objext_valparams(sym); + yasm_symrec_get_objext_valparams(sym); unsigned long addralign = 0; if (objext_valparams) { - yasm_valparam *vp = yasm_vps_first(objext_valparams); + yasm_valparam *vp = yasm_vps_first(objext_valparams); for (; vp; vp = yasm_vps_next(vp)) { if (!vp->val) { /*@only@*/ /*@null@*/ yasm_expr *align_expr; @@ -227,7 +226,7 @@ build_common(yasm_objfmt_elf *objfmt_elf, yasm_symrec *sym, yasm_object *object) yasm_symrec_get_def_line(sym))) || !(align_intn = yasm_expr_get_intnum(&align_expr, 0))) { yasm_error_set(YASM_ERROR_VALUE, - N_("alignment constraint is not an integer")); + N_("alignment constraint is not an integer")); if (align_expr) yasm_expr_destroy(align_expr); return NULL; @@ -248,7 +247,7 @@ build_common(yasm_objfmt_elf *objfmt_elf, yasm_symrec *sym, yasm_object *object) } return elf_objfmt_symtab_append(objfmt_elf, sym, SHN_COMMON, STB_GLOBAL, - 0, STV_DEFAULT, *size, &addralign, object); + 0, STV_DEFAULT, *size, &addralign); } static int @@ -265,81 +264,79 @@ elf_objfmt_build_symtab(yasm_symrec *sym, /*@null@*/ void *d) assert(info != NULL); if (vis & YASM_SYM_EXTERN) { - entry = build_extern(info->objfmt_elf, sym, info->object); - yasm_errwarn_propagate(info->errwarns, - yasm_symrec_get_decl_line(sym)); - return 0; + entry = build_extern(info->objfmt_elf, sym); + yasm_errwarn_propagate(info->errwarns, + yasm_symrec_get_decl_line(sym)); + return 0; } if (vis & YASM_SYM_COMMON) { entry = build_common(info->objfmt_elf, sym, info->object); - yasm_errwarn_propagate(info->errwarns, - yasm_symrec_get_decl_line(sym)); - /* If the COMMON variable was actually defined, fall through. */ - if (!(status & YASM_SYM_DEFINED)) - return 0; + yasm_errwarn_propagate(info->errwarns, + yasm_symrec_get_decl_line(sym)); + /* If the COMMON variable was actually defined, fall through. */ + if (!(status & YASM_SYM_DEFINED)) + return 0; } /* Ignore any undefined at this point. */ if (!(status & YASM_SYM_DEFINED)) - return 0; + return 0; if (!yasm_symrec_get_label(sym, &precbc)) { - if (!yasm_symrec_get_equ(sym) && !yasm_symrec_is_abs(sym)) - return 0; - precbc = NULL; + if (!yasm_symrec_get_equ(sym) && !yasm_symrec_is_abs(sym)) + return 0; + precbc = NULL; } if (precbc) - sect = yasm_bc_get_section(precbc); + sect = yasm_bc_get_section(precbc); if (entry && elf_sym_in_table(entry)) - ; + ; else if (vis & YASM_SYM_GLOBAL) { - entry = build_global(info->objfmt_elf, sym, info->object); - yasm_errwarn_propagate(info->errwarns, yasm_symrec_get_decl_line(sym)); + entry = build_global(info->objfmt_elf, sym); + yasm_errwarn_propagate(info->errwarns, yasm_symrec_get_decl_line(sym)); } else { - int is_sect = 0; + int is_sect = 0; - /* Locals (except when debugging) do not need to be - * in the symbol table, unless they're a section. - */ - if (sect && - strcmp(yasm_symrec_get_name(sym), yasm_section_get_name(sect))==0) - is_sect = 1; + /* Locals (except when debugging) do not need to be + * in the symbol table, unless they're a section. + */ + if (sect && + strcmp(yasm_symrec_get_name(sym), yasm_section_get_name(sect))==0) + is_sect = 1; #if 0 - /* FIXME: to enable this we must have handling in place for special - * symbols. - */ - if (!info->local_names && !is_sect) - return 0; + /* FIXME: to enable this we must have handling in place for special + * symbols. + */ + if (!info->local_names && !is_sect) + return 0; #else - if (yasm_symrec_get_equ(sym) && !yasm_symrec_is_abs(sym)) - return 0; + if (yasm_symrec_get_equ(sym) && !yasm_symrec_is_abs(sym)) + return 0; #endif - entry = yasm_symrec_get_data(sym, &elf_symrec_data); - if (!entry) { - /*@only@*/ char *symname = - yasm_symrec_get_global_name(sym, info->object); - elf_strtab_entry *name = !info->local_names || is_sect ? NULL : - elf_strtab_append_str(info->objfmt_elf->strtab, symname); - yasm_xfree(symname); - entry = elf_symtab_entry_create(name, sym); - yasm_symrec_add_data(sym, &elf_symrec_data, entry); - } + entry = yasm_symrec_get_data(sym, &elf_symrec_data); + if (!entry) { + elf_strtab_entry *name = !info->local_names || is_sect ? NULL : + elf_strtab_append_str(info->objfmt_elf->strtab, + yasm_symrec_get_name(sym)); + entry = elf_symtab_entry_create(name, sym); + yasm_symrec_add_data(sym, &elf_symrec_data, entry); + } - if (!elf_sym_in_table(entry)) - elf_symtab_insert_local_sym(info->objfmt_elf->elf_symtab, entry); + if (!elf_sym_in_table(entry)) + elf_symtab_insert_local_sym(info->objfmt_elf->elf_symtab, entry); - elf_symtab_set_nonzero(entry, sect, 0, STB_LOCAL, - is_sect ? STT_SECTION : 0, NULL, 0); + elf_symtab_set_nonzero(entry, sect, 0, STB_LOCAL, + is_sect ? STT_SECTION : 0, NULL, 0); - if (is_sect) - return 0; + if (is_sect) + return 0; } if (precbc) - value = yasm_bc_next_offset(precbc); + value = yasm_bc_next_offset(precbc); elf_symtab_set_nonzero(entry, sect, 0, 0, 0, NULL, &value); return 0; @@ -347,8 +344,8 @@ elf_objfmt_build_symtab(yasm_symrec *sym, /*@null@*/ void *d) static yasm_objfmt * elf_objfmt_create_common(yasm_object *object, yasm_objfmt_module *module, - int bits_pref, - const elf_machine_handler **elf_march_out) + int bits_pref, + const elf_machine_handler **elf_march_out) { yasm_objfmt_elf *objfmt_elf = yasm_xmalloc(sizeof(yasm_objfmt_elf)); yasm_symrec *filesym; @@ -358,11 +355,11 @@ elf_objfmt_create_common(yasm_object *object, yasm_objfmt_module *module, objfmt_elf->objfmt.module = module; elf_march = elf_set_arch(object->arch, object->symtab, bits_pref); if (!elf_march) { - yasm_xfree(objfmt_elf); - return NULL; + yasm_xfree(objfmt_elf); + return NULL; } if (elf_march_out) - *elf_march_out = elf_march; + *elf_march_out = elf_march; objfmt_elf->shstrtab = elf_strtab_create(); objfmt_elf->strtab = elf_strtab_create(); @@ -372,16 +369,16 @@ elf_objfmt_create_common(yasm_object *object, yasm_objfmt_module *module, filesym = yasm_symtab_define_label(object->symtab, ".file", NULL, 0, 0); /* Put in current input filename; we'll replace it in output() */ objfmt_elf->file_strtab_entry = - elf_strtab_append_str(objfmt_elf->strtab, object->src_filename); + elf_strtab_append_str(objfmt_elf->strtab, object->src_filename); entry = elf_symtab_entry_create(objfmt_elf->file_strtab_entry, filesym); yasm_symrec_add_data(filesym, &elf_symrec_data, entry); elf_symtab_set_nonzero(entry, NULL, SHN_ABS, STB_LOCAL, STT_FILE, NULL, - NULL); + NULL); elf_symtab_append_entry(objfmt_elf->elf_symtab, entry); /* FIXME: misuse of NULL bytecode */ objfmt_elf->dotdotsym = - yasm_symtab_define_label(object->symtab, "..sym", NULL, 0, 0); + yasm_symtab_define_label(object->symtab, "..sym", NULL, 1, 0); return (yasm_objfmt *)objfmt_elf; } @@ -394,16 +391,14 @@ elf_objfmt_create(yasm_object *object) yasm_objfmt_elf *objfmt_elf; objfmt = elf_objfmt_create_common(object, &yasm_elf_LTX_objfmt, 0, - &elf_march); + &elf_march); if (objfmt) { - objfmt_elf = (yasm_objfmt_elf *)objfmt; - /* Figure out which bitness of object format to use */ - if (strcmp (elf_march->machine, "x32") == 0) - objfmt_elf->objfmt.module = &yasm_elfx32_LTX_objfmt; - else if (elf_march->bits == 32) - objfmt_elf->objfmt.module = &yasm_elf32_LTX_objfmt; - else if (elf_march->bits == 64) - objfmt_elf->objfmt.module = &yasm_elf64_LTX_objfmt; + objfmt_elf = (yasm_objfmt_elf *)objfmt; + /* Figure out which bitness of object format to use */ + if (elf_march->bits == 32) + objfmt_elf->objfmt.module = &yasm_elf32_LTX_objfmt; + else if (elf_march->bits == 64) + objfmt_elf->objfmt.module = &yasm_elf64_LTX_objfmt; } return objfmt; } @@ -420,42 +415,36 @@ elf64_objfmt_create(yasm_object *object) return elf_objfmt_create_common(object, &yasm_elf64_LTX_objfmt, 64, NULL); } -static yasm_objfmt * -elfx32_objfmt_create(yasm_object *object) -{ - return elf_objfmt_create_common(object, &yasm_elfx32_LTX_objfmt, 32, NULL); -} - static long elf_objfmt_output_align(FILE *f, unsigned int align) { long pos; unsigned long delta; if (!is_exp2(align)) - yasm_internal_error("requested alignment not a power of two"); + yasm_internal_error("requested alignment not a power of two"); pos = ftell(f); if (pos == -1) { - yasm_error_set(YASM_ERROR_IO, - N_("could not get file position on output file")); - return -1; + yasm_error_set(YASM_ERROR_IO, + N_("could not get file position on output file")); + return -1; } delta = align - (pos & (align-1)); if (delta != align) { - pos += delta; - if (fseek(f, pos, SEEK_SET) < 0) { - yasm_error_set(YASM_ERROR_IO, - N_("could not set file position on output file")); - return -1; - } + pos += delta; + if (fseek(f, pos, SEEK_SET) < 0) { + yasm_error_set(YASM_ERROR_IO, + N_("could not set file position on output file")); + return -1; + } } return pos; } static int elf_objfmt_output_reloc(yasm_symrec *sym, yasm_bytecode *bc, - unsigned char *buf, unsigned int destsize, - unsigned int valsize, int warn, void *d) + unsigned char *buf, unsigned int destsize, + unsigned int valsize, int warn, void *d) { elf_reloc_entry *reloc; elf_objfmt_output_info *info = d; @@ -463,26 +452,26 @@ elf_objfmt_output_reloc(yasm_symrec *sym, yasm_bytecode *bc, int retval; reloc = elf_reloc_entry_create(sym, NULL, - yasm_intnum_create_uint(bc->offset), 0, valsize, 0); + yasm_intnum_create_uint(bc->offset), 0, valsize); if (reloc == NULL) { - yasm_error_set(YASM_ERROR_TYPE, N_("elf: invalid relocation size")); - return 1; + yasm_error_set(YASM_ERROR_TYPE, N_("elf: invalid relocation size")); + return 1; } /* allocate .rel[a] sections on a need-basis */ elf_secthead_append_reloc(info->sect, info->shead, reloc); zero = yasm_intnum_create_uint(0); - elf_handle_reloc_addend(zero, reloc, 0); + elf_handle_reloc_addend(zero, reloc); retval = yasm_arch_intnum_tobytes(info->object->arch, zero, buf, destsize, - valsize, 0, bc, warn); + valsize, 0, bc, warn); yasm_intnum_destroy(zero); return retval; } static int elf_objfmt_output_value(yasm_value *value, unsigned char *buf, - unsigned int destsize, unsigned long offset, - yasm_bytecode *bc, int warn, /*@null@*/ void *d) + unsigned int destsize, unsigned long offset, + yasm_bytecode *bc, int warn, /*@null@*/ void *d) { /*@null@*/ elf_objfmt_output_info *info = (elf_objfmt_output_info *)d; /*@dependent@*/ /*@null@*/ yasm_intnum *intn; @@ -492,99 +481,96 @@ elf_objfmt_output_value(yasm_value *value, unsigned char *buf, unsigned int valsize = value->size; if (info == NULL) - yasm_internal_error("null info struct"); + yasm_internal_error("null info struct"); if (value->abs) - value->abs = yasm_expr_simplify(value->abs, 1); + value->abs = yasm_expr_simplify(value->abs, 1); /* Try to output constant and PC-relative section-local first. * Note this does NOT output any value with a SEG, WRT, external, * cross-section, or non-PC-relative reference (those are handled below). */ switch (yasm_value_output_basic(value, buf, destsize, bc, warn, - info->object->arch)) { - case -1: - return 1; - case 0: - break; - default: - return 0; + info->object->arch)) { + case -1: + return 1; + case 0: + break; + default: + return 0; } /* Handle other expressions, with relocation if necessary */ if (value->seg_of || value->section_rel || value->rshift > 0) { - yasm_error_set(YASM_ERROR_TOO_COMPLEX, - N_("elf: relocation too complex")); - return 1; + yasm_error_set(YASM_ERROR_TOO_COMPLEX, + N_("elf: relocation too complex")); + return 1; } intn_val = 0; if (value->rel) { - yasm_sym_vis vis = yasm_symrec_get_visibility(value->rel); - /*@dependent@*/ /*@null@*/ yasm_symrec *sym = value->rel; - /*@dependent@*/ /*@null@*/ yasm_symrec *wrt = value->wrt; + yasm_sym_vis vis = yasm_symrec_get_visibility(value->rel); + /*@dependent@*/ /*@null@*/ yasm_symrec *sym = value->rel; + /*@dependent@*/ /*@null@*/ yasm_symrec *wrt = value->wrt; - if (wrt == info->objfmt_elf->dotdotsym) - wrt = NULL; - else if (wrt && elf_is_wrt_sym_relative(wrt)) - ; - else if (wrt && elf_is_wrt_pos_adjusted(wrt)) - intn_val = offset + bc->offset; - else if (vis == YASM_SYM_LOCAL) { - yasm_bytecode *sym_precbc; - /* Local symbols need relocation to their section's start, and - * add in the offset of the bytecode (within the target section) - * into the abs portion. - * - * This is only done if the symbol is relocated against the - * section instead of the symbol itself. - */ - if (yasm_symrec_get_label(sym, &sym_precbc)) { - /* Relocate to section start */ - yasm_section *sym_sect = yasm_bc_get_section(sym_precbc); - /*@null@*/ elf_secthead *sym_shead; - sym_shead = yasm_section_get_data(sym_sect, &elf_section_data); - assert(sym_shead != NULL); - sym = elf_secthead_get_sym(sym_shead); + if (wrt == info->objfmt_elf->dotdotsym) + wrt = NULL; + else if (wrt && elf_is_wrt_sym_relative(wrt)) + ; + else if (vis == YASM_SYM_LOCAL) { + yasm_bytecode *sym_precbc; + /* Local symbols need relocation to their section's start, and + * add in the offset of the bytecode (within the target section) + * into the abs portion. + * + * This is only done if the symbol is relocated against the + * section instead of the symbol itself. + */ + if (yasm_symrec_get_label(sym, &sym_precbc)) { + /* Relocate to section start */ + yasm_section *sym_sect = yasm_bc_get_section(sym_precbc); + /*@null@*/ elf_secthead *sym_shead; + sym_shead = yasm_section_get_data(sym_sect, &elf_section_data); + assert(sym_shead != NULL); + sym = elf_secthead_get_sym(sym_shead); - intn_val = yasm_bc_next_offset(sym_precbc); - } - } - - /* For PC-relative, need to add offset of expression within bc. */ - if (value->curpos_rel) - intn_val += offset; + intn_val = yasm_bc_next_offset(sym_precbc); + } + } + + /* For PC-relative, need to add offset of expression within bc. */ + if (value->curpos_rel) + intn_val += offset; - /* Check for _GLOBAL_OFFSET_TABLE_ symbol reference */ - reloc = elf_reloc_entry_create(sym, wrt, - yasm_intnum_create_uint(bc->offset + offset), value->curpos_rel, - valsize, sym == info->GOT_sym); - if (reloc == NULL) { - yasm_error_set(YASM_ERROR_TYPE, - N_("elf: invalid relocation (WRT or size)")); - return 1; - } - /* allocate .rel[a] sections on a need-basis */ - elf_secthead_append_reloc(info->sect, info->shead, reloc); + reloc = elf_reloc_entry_create(sym, wrt, + yasm_intnum_create_uint(bc->offset + offset), value->curpos_rel, + valsize); + if (reloc == NULL) { + yasm_error_set(YASM_ERROR_TYPE, + N_("elf: invalid relocation (WRT or size)")); + return 1; + } + /* allocate .rel[a] sections on a need-basis */ + elf_secthead_append_reloc(info->sect, info->shead, reloc); } intn = yasm_intnum_create_uint(intn_val); if (value->abs) { - yasm_intnum *intn2 = yasm_expr_get_intnum(&value->abs, 0); - if (!intn2) { - yasm_error_set(YASM_ERROR_TOO_COMPLEX, - N_("elf: relocation too complex")); - yasm_intnum_destroy(intn); - return 1; - } - yasm_intnum_calc(intn, YASM_EXPR_ADD, intn2); + yasm_intnum *intn2 = yasm_expr_get_intnum(&value->abs, 0); + if (!intn2) { + yasm_error_set(YASM_ERROR_TOO_COMPLEX, + N_("elf: relocation too complex")); + yasm_intnum_destroy(intn); + return 1; + } + yasm_intnum_calc(intn, YASM_EXPR_ADD, intn2); } if (reloc) - elf_handle_reloc_addend(intn, reloc, offset); + elf_handle_reloc_addend(intn, reloc); retval = yasm_arch_intnum_tobytes(info->object->arch, intn, buf, destsize, - valsize, 0, bc, warn); + valsize, 0, bc, warn); yasm_intnum_destroy(intn); return retval; } @@ -599,44 +585,83 @@ elf_objfmt_output_bytecode(yasm_bytecode *bc, /*@null@*/ void *d) int gap; if (info == NULL) - yasm_internal_error("null info struct"); + yasm_internal_error("null info struct"); bigbuf = yasm_bc_tobytes(bc, buf, &size, &gap, info, - elf_objfmt_output_value, elf_objfmt_output_reloc); + elf_objfmt_output_value, elf_objfmt_output_reloc); /* Don't bother doing anything else if size ended up being 0. */ if (size == 0) { - if (bigbuf) - yasm_xfree(bigbuf); - return 0; + if (bigbuf) + yasm_xfree(bigbuf); + return 0; } else { - yasm_intnum *bcsize = yasm_intnum_create_uint(size); - elf_secthead_add_size(info->shead, bcsize); - yasm_intnum_destroy(bcsize); + yasm_intnum *bcsize = yasm_intnum_create_uint(size); + elf_secthead_add_size(info->shead, bcsize); + yasm_intnum_destroy(bcsize); } /* Warn that gaps are converted to 0 and write out the 0's. */ if (gap) { - unsigned long left; - yasm_warn_set(YASM_WARN_UNINIT_CONTENTS, - N_("uninitialized space declared in code/data section: zeroing")); - /* Write out in chunks */ - memset(buf, 0, 256); - left = size; - while (left > 256) { - fwrite(buf, 256, 1, info->f); - left -= 256; - } - fwrite(buf, left, 1, info->f); + unsigned long left; + yasm_warn_set(YASM_WARN_UNINIT_CONTENTS, + N_("uninitialized space declared in code/data section: zeroing")); + /* Write out in chunks */ + memset(buf, 0, 256); + left = size; + while (left > 256) { + fwrite(buf, 256, 1, info->f); + left -= 256; + } + fwrite(buf, left, 1, info->f); } else { - /* Output buf (or bigbuf if non-NULL) to file */ - fwrite(bigbuf ? bigbuf : buf, (size_t)size, 1, info->f); + /* Output buf (or bigbuf if non-NULL) to file */ + fwrite(bigbuf ? bigbuf : buf, (size_t)size, 1, info->f); } /* If bigbuf was allocated, free it */ if (bigbuf) - yasm_xfree(bigbuf); + yasm_xfree(bigbuf); + + return 0; +} + +static int +elf_objfmt_create_dbg_secthead(yasm_section *sect, /*@null@*/ void *d) +{ + /*@null@*/ elf_objfmt_output_info *info = (elf_objfmt_output_info *)d; + elf_secthead *shead; + elf_section_type type=SHT_PROGBITS; + elf_size entsize=0; + const char *sectname; + /*@dependent@*/ yasm_symrec *sym; + elf_strtab_entry *name; + + shead = yasm_section_get_data(sect, &elf_section_data); + if (shead) + return 0; /* only create new secthead if missing */ + + sectname = yasm_section_get_name(sect); + name = elf_strtab_append_str(info->objfmt_elf->shstrtab, sectname); + + if (yasm__strcasecmp(sectname, ".stab")==0) { + entsize = 12; + } else if (yasm__strcasecmp(sectname, ".stabstr")==0) { + type = SHT_STRTAB; + } else if (yasm__strncasecmp(sectname, ".debug_", 7)==0) { + ; + } else + yasm_internal_error(N_("Unrecognized section without data")); + + shead = elf_secthead_create(name, type, 0, 0, 0); + elf_secthead_set_entsize(shead, entsize); + + sym = yasm_symtab_define_label(info->object->symtab, sectname, + yasm_section_bcs_first(sect), 1, 0); + elf_secthead_set_sym(shead, sym); + + yasm_section_add_data(sect, &elf_section_data, shead); return 0; } @@ -651,50 +676,50 @@ elf_objfmt_output_section(yasm_section *sect, /*@null@*/ void *d) const char *sectname; if (info == NULL) - yasm_internal_error("null info struct"); + yasm_internal_error("null info struct"); shead = yasm_section_get_data(sect, &elf_section_data); if (shead == NULL) - yasm_internal_error("no associated data"); + yasm_internal_error("no associated data"); if (elf_secthead_get_align(shead) == 0) - elf_secthead_set_align(shead, yasm_section_get_align(sect)); + elf_secthead_set_align(shead, yasm_section_get_align(sect)); /* don't output header-only sections */ if ((elf_secthead_get_type(shead) & SHT_NOBITS) == SHT_NOBITS) { - yasm_bytecode *last = yasm_section_bcs_last(sect); - if (last) { - yasm_intnum *sectsize; - sectsize = yasm_intnum_create_uint(yasm_bc_next_offset(last)); - elf_secthead_add_size(shead, sectsize); - yasm_intnum_destroy(sectsize); - } - elf_secthead_set_index(shead, ++info->sindex); - return 0; + yasm_bytecode *last = yasm_section_bcs_last(sect); + if (last) { + yasm_intnum *sectsize; + sectsize = yasm_intnum_create_uint(yasm_bc_next_offset(last)); + elf_secthead_add_size(shead, sectsize); + yasm_intnum_destroy(sectsize); + } + elf_secthead_set_index(shead, ++info->sindex); + return 0; } if ((pos = ftell(info->f)) == -1) { - yasm_error_set(YASM_ERROR_IO, - N_("couldn't read position on output stream")); - yasm_errwarn_propagate(info->errwarns, 0); + yasm_error_set(YASM_ERROR_IO, + N_("couldn't read position on output stream")); + yasm_errwarn_propagate(info->errwarns, 0); } pos = elf_secthead_set_file_offset(shead, pos); if (fseek(info->f, pos, SEEK_SET) < 0) { - yasm_error_set(YASM_ERROR_IO, N_("couldn't seek on output stream")); - yasm_errwarn_propagate(info->errwarns, 0); + yasm_error_set(YASM_ERROR_IO, N_("couldn't seek on output stream")); + yasm_errwarn_propagate(info->errwarns, 0); } info->sect = sect; info->shead = shead; yasm_section_bcs_traverse(sect, info->errwarns, info, - elf_objfmt_output_bytecode); + elf_objfmt_output_bytecode); elf_secthead_set_index(shead, ++info->sindex); /* No relocations to output? Go on to next section */ if (elf_secthead_write_relocs_to_file(info->f, sect, shead, - info->errwarns) == 0) - return 0; + info->errwarns) == 0) + return 0; elf_secthead_set_rel_index(shead, ++info->sindex); /* name the relocation section .rel[a].foo */ @@ -714,27 +739,27 @@ elf_objfmt_output_secthead(yasm_section *sect, /*@null@*/ void *d) /*@dependent@*/ /*@null@*/ elf_secthead *shead; if (info == NULL) - yasm_internal_error("null info struct"); + yasm_internal_error("null info struct"); shead = yasm_section_get_data(sect, &elf_section_data); if (shead == NULL) - yasm_internal_error("no section header attached to section"); + yasm_internal_error("no section header attached to section"); if(elf_secthead_write_to_file(info->f, shead, info->sindex+1)) - info->sindex++; + info->sindex++; /* output strtab headers here? */ /* relocation entries for .foo are stored in section .rel[a].foo */ if(elf_secthead_write_rel_to_file(info->f, 3, sect, shead, - info->sindex+1)) - info->sindex++; + info->sindex+1)) + info->sindex++; return 0; } static void elf_objfmt_output(yasm_object *object, FILE *f, int all_syms, - yasm_errwarns *errwarns) + yasm_errwarns *errwarns) { yasm_objfmt_elf *objfmt_elf = (yasm_objfmt_elf *)object->objfmt; elf_objfmt_output_info info; @@ -751,19 +776,23 @@ elf_objfmt_output(yasm_object *object, FILE *f, int all_syms, info.objfmt_elf = objfmt_elf; info.errwarns = errwarns; info.f = f; - info.GOT_sym = yasm_symtab_get(object->symtab, "_GLOBAL_OFFSET_TABLE_"); /* Update filename strtab */ elf_strtab_entry_set_str(objfmt_elf->file_strtab_entry, - object->src_filename); + object->src_filename); /* Allocate space for Ehdr by seeking forward */ if (fseek(f, (long)(elf_proghead_get_size()), SEEK_SET) < 0) { - yasm_error_set(YASM_ERROR_IO, N_("could not seek on output file")); - yasm_errwarn_propagate(errwarns, 0); - return; + yasm_error_set(YASM_ERROR_IO, N_("could not seek on output file")); + yasm_errwarn_propagate(errwarns, 0); + return; } + /* Create missing section headers */ + if (yasm_object_sections_traverse(object, &info, + elf_objfmt_create_dbg_secthead)) + return; + /* add all (local) syms to symtab because relocation needs a symtab index * if all_syms, register them by name. if not, use strtab entry 0 */ buildsym_info.object = object; @@ -771,70 +800,70 @@ elf_objfmt_output(yasm_object *object, FILE *f, int all_syms, buildsym_info.errwarns = errwarns; buildsym_info.local_names = all_syms; yasm_symtab_traverse(object->symtab, &buildsym_info, - elf_objfmt_build_symtab); + elf_objfmt_build_symtab); elf_symtab_nlocal = elf_symtab_assign_indices(objfmt_elf->elf_symtab); /* output known sections - includes reloc sections which aren't in yasm's * list. Assign indices as we go. */ info.sindex = 3; if (yasm_object_sections_traverse(object, &info, - elf_objfmt_output_section)) - return; + elf_objfmt_output_section)) + return; /* add final sections to the shstrtab */ elf_strtab_name = elf_strtab_append_str(objfmt_elf->shstrtab, ".strtab"); elf_symtab_name = elf_strtab_append_str(objfmt_elf->shstrtab, ".symtab"); elf_shstrtab_name = elf_strtab_append_str(objfmt_elf->shstrtab, - ".shstrtab"); + ".shstrtab"); /* output .shstrtab */ if ((pos = elf_objfmt_output_align(f, 4)) == -1) { - yasm_errwarn_propagate(errwarns, 0); - return; + yasm_errwarn_propagate(errwarns, 0); + return; } elf_shstrtab_offset = (unsigned long) pos; elf_shstrtab_size = elf_strtab_output_to_file(f, objfmt_elf->shstrtab); /* output .strtab */ if ((pos = elf_objfmt_output_align(f, 4)) == -1) { - yasm_errwarn_propagate(errwarns, 0); - return; + yasm_errwarn_propagate(errwarns, 0); + return; } elf_strtab_offset = (unsigned long) pos; elf_strtab_size = elf_strtab_output_to_file(f, objfmt_elf->strtab); /* output .symtab - last section so all others have indexes */ if ((pos = elf_objfmt_output_align(f, 4)) == -1) { - yasm_errwarn_propagate(errwarns, 0); - return; + yasm_errwarn_propagate(errwarns, 0); + return; } elf_symtab_offset = (unsigned long) pos; elf_symtab_size = elf_symtab_write_to_file(f, objfmt_elf->elf_symtab, - errwarns); + errwarns); /* output section header table */ if ((pos = elf_objfmt_output_align(f, 16)) == -1) { - yasm_errwarn_propagate(errwarns, 0); - return; + yasm_errwarn_propagate(errwarns, 0); + return; } elf_shead_addr = (unsigned long) pos; /* stabs debugging support */ if (strcmp(yasm_dbgfmt_keyword(object->dbgfmt), "stabs")==0) { - yasm_section *stabsect = yasm_object_find_general(object, ".stab"); - yasm_section *stabstrsect = - yasm_object_find_general(object, ".stabstr"); - if (stabsect && stabstrsect) { - elf_secthead *stab = - yasm_section_get_data(stabsect, &elf_section_data); - elf_secthead *stabstr = - yasm_section_get_data(stabstrsect, &elf_section_data); - if (stab && stabstr) { - elf_secthead_set_link(stab, elf_secthead_get_index(stabstr)); - } - else - yasm_internal_error(N_("missing .stab or .stabstr section/data")); - } + yasm_section *stabsect = yasm_object_find_general(object, ".stab"); + yasm_section *stabstrsect = + yasm_object_find_general(object, ".stabstr"); + if (stabsect && stabstrsect) { + elf_secthead *stab = + yasm_section_get_data(stabsect, &elf_section_data); + elf_secthead *stabstr = + yasm_section_get_data(stabstrsect, &elf_section_data); + if (stab && stabstr) { + elf_secthead_set_link(stab, elf_secthead_get_index(stabstr)); + } + else + yasm_internal_error(N_("missing .stab or .stabstr section/data")); + } } /* output dummy section header - 0 */ @@ -846,22 +875,22 @@ elf_objfmt_output(yasm_object *object, FILE *f, int all_syms, elf_secthead_destroy(esdn); esdn = elf_secthead_create(elf_shstrtab_name, SHT_STRTAB, 0, - elf_shstrtab_offset, elf_shstrtab_size); + elf_shstrtab_offset, elf_shstrtab_size); elf_secthead_set_index(esdn, 1); elf_secthead_write_to_file(f, esdn, 1); elf_secthead_destroy(esdn); esdn = elf_secthead_create(elf_strtab_name, SHT_STRTAB, 0, - elf_strtab_offset, elf_strtab_size); + elf_strtab_offset, elf_strtab_size); elf_secthead_set_index(esdn, 2); elf_secthead_write_to_file(f, esdn, 2); elf_secthead_destroy(esdn); esdn = elf_secthead_create(elf_symtab_name, SHT_SYMTAB, 0, - elf_symtab_offset, elf_symtab_size); + elf_symtab_offset, elf_symtab_size); elf_secthead_set_index(esdn, 3); elf_secthead_set_info(esdn, elf_symtab_nlocal); - elf_secthead_set_link(esdn, 2); /* for .strtab, which is index 2 */ + elf_secthead_set_link(esdn, 2); /* for .strtab, which is index 2 */ elf_secthead_write_to_file(f, esdn, 3); elf_secthead_destroy(esdn); @@ -871,9 +900,9 @@ elf_objfmt_output(yasm_object *object, FILE *f, int all_syms, /* output Ehdr */ if (fseek(f, 0, SEEK_SET) < 0) { - yasm_error_set(YASM_ERROR_IO, N_("could not seek on output file")); - yasm_errwarn_propagate(errwarns, 0); - return; + yasm_error_set(YASM_ERROR_IO, N_("could not seek on output file")); + yasm_errwarn_propagate(errwarns, 0); + return; } elf_proghead_write_to_file(f, elf_shead_addr, info.sindex+1, 1); @@ -889,33 +918,25 @@ elf_objfmt_destroy(yasm_objfmt *objfmt) yasm_xfree(objfmt); } -static void -elf_objfmt_init_new_section(yasm_section *sect, unsigned long line) +static elf_secthead * +elf_objfmt_init_new_section(yasm_object *object, yasm_section *sect, + const char *sectname, unsigned long type, + unsigned long flags, unsigned long line) { - yasm_object *object = yasm_section_get_object(sect); - const char *sectname = yasm_section_get_name(sect); yasm_objfmt_elf *objfmt_elf = (yasm_objfmt_elf *)object->objfmt; elf_secthead *esd; yasm_symrec *sym; elf_strtab_entry *name = elf_strtab_append_str(objfmt_elf->shstrtab, - sectname); + sectname); - elf_section_type type=SHT_PROGBITS; - elf_size entsize=0; - - if (yasm__strcasecmp(sectname, ".stab")==0) { - entsize = 12; - } else if (yasm__strcasecmp(sectname, ".stabstr")==0) { - type = SHT_STRTAB; - } - - esd = elf_secthead_create(name, type, 0, 0, 0); - elf_secthead_set_entsize(esd, entsize); + esd = elf_secthead_create(name, type, flags, 0, 0); yasm_section_add_data(sect, &elf_section_data, esd); sym = yasm_symtab_define_label(object->symtab, sectname, - yasm_section_bcs_first(sect), 1, line); + yasm_section_bcs_first(sect), 1, line); elf_secthead_set_sym(esd, sym); + + return esd; } static yasm_section * @@ -923,15 +944,12 @@ elf_objfmt_add_default_section(yasm_object *object) { yasm_section *retval; int isnew; + elf_secthead *esd; - retval = yasm_object_get_general(object, ".text", 16, 1, 0, &isnew, 0); - if (isnew) - { - elf_secthead *esd = yasm_section_get_data(retval, &elf_section_data); - elf_secthead_set_typeflags(esd, SHT_PROGBITS, - SHF_ALLOC + SHF_EXECINSTR); - yasm_section_set_default(retval, 1); - } + retval = yasm_object_get_general(object, ".text", 0, 16, 1, 0, &isnew, 0); + esd = elf_objfmt_init_new_section(object, retval, ".text", SHT_PROGBITS, + SHF_ALLOC + SHF_EXECINSTR, 0); + yasm_section_set_default(retval, 1); return retval; } @@ -940,7 +958,6 @@ struct elf_section_switch_data { unsigned long flags; unsigned long type; int gasflags; - int stdsect; }; /* GAS-style flags */ @@ -958,11 +975,6 @@ elf_helper_gasflags(void *obj, yasm_valparam *vp, unsigned long line, void *d, return -1; } - if (data->stdsect && strlen(s) == 0) { - data->gasflags = 1; - return 0; - } - data->flags = 0; for (i=0; ival) { if (!(merge_expr = yasm_vp_expr(vp, object->symtab, line)) || !(merge_intn = yasm_expr_get_intnum(&merge_expr, 0))) - yasm_warn_set(YASM_WARN_GENERAL, - N_("invalid merge entity size")); - } else { - yasm_warn_set(YASM_WARN_GENERAL, - N_("entity size for SHF_MERGE not specified")); + yasm_warn_set(YASM_WARN_GENERAL, + N_("invalid merge entity size")); + } else { + yasm_warn_set(YASM_WARN_GENERAL, + N_("entity size for SHF_MERGE not specified")); data.flags &= ~SHF_MERGE; - } - } + } + } - retval = yasm_object_get_general(object, sectname, align, + retval = yasm_object_get_general(object, sectname, 0, align, (data.flags & SHF_EXECINSTR) != 0, resonly, &isnew, line); - esd = yasm_section_get_data(retval, &elf_section_data); + if (isnew) + esd = elf_objfmt_init_new_section(object, retval, sectname, data.type, + data.flags, line); + else + esd = yasm_section_get_data(retval, &elf_section_data); if (isnew || yasm_section_is_default(retval)) { - yasm_section_set_default(retval, 0); + yasm_section_set_default(retval, 0); elf_secthead_set_typeflags(esd, data.type, data.flags); - if (merge_intn) - elf_secthead_set_entsize(esd, yasm_intnum_get_uint(merge_intn)); - yasm_section_set_align(retval, align, line); + if (merge_intn) + elf_secthead_set_entsize(esd, yasm_intnum_get_uint(merge_intn)); + yasm_section_set_align(retval, align, line); } else if (flags_override && !data.gasflags) - yasm_warn_set(YASM_WARN_GENERAL, - N_("section flags ignored on section redeclaration")); + yasm_warn_set(YASM_WARN_GENERAL, + N_("section flags ignored on section redeclaration")); if (merge_expr) yasm_expr_destroy(merge_expr); return retval; } -static /*@observer@*/ /*@null@*/ yasm_symrec * -elf_objfmt_get_special_sym(yasm_object *object, const char *name, - const char *parser) -{ - if (yasm__strcasecmp(name, "sym") == 0) { - yasm_objfmt_elf *objfmt_elf = (yasm_objfmt_elf *)object->objfmt; - return objfmt_elf->dotdotsym; - } - return elf_get_special_sym(name, parser); -} - static void dir_type(yasm_object *object, yasm_valparamhead *valparams, - yasm_valparamhead *objext_valparams, unsigned long line) + yasm_valparamhead *objext_valparams, unsigned long line) { yasm_objfmt_elf *objfmt_elf = (yasm_objfmt_elf *)object->objfmt; yasm_valparam *vp = yasm_vps_first(valparams); @@ -1165,32 +1157,28 @@ dir_type(yasm_object *object, yasm_valparamhead *valparams, /* Create entry if necessary */ if (!entry) { - entry = elf_symtab_entry_create( - elf_strtab_append_str(objfmt_elf->strtab, symname), sym); - yasm_symrec_add_data(sym, &elf_symrec_data, entry); + entry = elf_symtab_entry_create( + elf_strtab_append_str(objfmt_elf->strtab, symname), sym); + yasm_symrec_add_data(sym, &elf_symrec_data, entry); } /* Pull new type from param */ vp = yasm_vps_next(vp); if (vp && !vp->val && (type = yasm_vp_id(vp))) { if (yasm__strcasecmp(type, "function") == 0) - elf_sym_set_type(entry, STT_FUNC); + elf_sym_set_type(entry, STT_FUNC); else if (yasm__strcasecmp(type, "object") == 0) - elf_sym_set_type(entry, STT_OBJECT); - else if (yasm__strcasecmp(type, "tls_object") == 0) - elf_sym_set_type(entry, STT_TLS); - else if (yasm__strcasecmp(type, "notype") == 0) - elf_sym_set_type(entry, STT_NOTYPE); - else - yasm_warn_set(YASM_WARN_GENERAL, + elf_sym_set_type(entry, STT_OBJECT); + else + yasm_warn_set(YASM_WARN_GENERAL, N_("unrecognized symbol type `%s'"), type); } else - yasm_error_set(YASM_ERROR_SYNTAX, N_("no type specified")); + yasm_error_set(YASM_ERROR_SYNTAX, N_("no type specified")); } static void dir_size(yasm_object *object, yasm_valparamhead *valparams, - yasm_valparamhead *objext_valparams, unsigned long line) + yasm_valparamhead *objext_valparams, unsigned long line) { yasm_objfmt_elf *objfmt_elf = (yasm_objfmt_elf *)object->objfmt; yasm_valparam *vp = yasm_vps_first(valparams); @@ -1202,9 +1190,9 @@ dir_size(yasm_object *object, yasm_valparamhead *valparams, /* Create entry if necessary */ if (!entry) { - entry = elf_symtab_entry_create( - elf_strtab_append_str(objfmt_elf->strtab, symname), sym); - yasm_symrec_add_data(sym, &elf_symrec_data, entry); + entry = elf_symtab_entry_create( + elf_strtab_append_str(objfmt_elf->strtab, symname), sym); + yasm_symrec_add_data(sym, &elf_symrec_data, entry); } /* Pull new size from param */ @@ -1212,25 +1200,25 @@ dir_size(yasm_object *object, yasm_valparamhead *valparams, if (vp && !vp->val && (size = yasm_vp_expr(vp, object->symtab, line))) elf_sym_set_size(entry, size); else - yasm_error_set(YASM_ERROR_SYNTAX, N_("no size specified")); + yasm_error_set(YASM_ERROR_SYNTAX, N_("no size specified")); } static void dir_weak(yasm_object *object, yasm_valparamhead *valparams, - yasm_valparamhead *objext_valparams, unsigned long line) + yasm_valparamhead *objext_valparams, unsigned long line) { yasm_objfmt_elf *objfmt_elf = (yasm_objfmt_elf *)object->objfmt; yasm_valparam *vp = yasm_vps_first(valparams); const char *symname = yasm_vp_id(vp); yasm_symrec *sym = yasm_symtab_declare(object->symtab, symname, - YASM_SYM_GLOBAL, line); + YASM_SYM_GLOBAL, line); elf_objfmt_symtab_append(objfmt_elf, sym, SHN_UNDEF, STB_WEAK, 0, - STV_DEFAULT, NULL, NULL, object); + STV_DEFAULT, NULL, NULL); } static void dir_ident(yasm_object *object, yasm_valparamhead *valparams, - yasm_valparamhead *objext_valparams, unsigned long line) + yasm_valparamhead *objext_valparams, unsigned long line) { yasm_valparamhead sect_vps; yasm_datavalhead dvs; @@ -1256,12 +1244,12 @@ dir_ident(yasm_object *object, yasm_valparamhead *valparams, * initial 0 byte in the section. */ if (yasm_section_bcs_first(comment) == yasm_section_bcs_last(comment)) { - yasm_dvs_initialize(&dvs); - yasm_dvs_append(&dvs, yasm_dv_create_expr( - yasm_expr_create_ident( - yasm_expr_int(yasm_intnum_create_uint(0)), line))); - yasm_section_bcs_append(comment, - yasm_bc_create_data(&dvs, 1, 0, object->arch, line)); + yasm_dvs_initialize(&dvs); + yasm_dvs_append(&dvs, yasm_dv_create_expr( + yasm_expr_create_ident( + yasm_expr_int(yasm_intnum_create_uint(0)), line))); + yasm_section_bcs_append(comment, + yasm_bc_create_data(&dvs, 1, 0, object->arch, line)); } yasm_dvs_initialize(&dvs); @@ -1278,7 +1266,7 @@ dir_ident(yasm_object *object, yasm_valparamhead *valparams, } while ((vp = yasm_vps_next(vp))); yasm_section_bcs_append(comment, - yasm_bc_create_data(&dvs, 1, 1, object->arch, line)); + yasm_bc_create_data(&dvs, 1, 1, object->arch, line)); } /* Define valid debug formats to use with this object format */ @@ -1290,53 +1278,31 @@ static const char *elf_objfmt_dbgfmt_keywords[] = { }; static const yasm_directive elf_objfmt_directives[] = { - { ".type", "gas", dir_type, YASM_DIR_ID_REQUIRED }, - { ".size", "gas", dir_size, YASM_DIR_ID_REQUIRED }, - { ".weak", "gas", dir_weak, YASM_DIR_ID_REQUIRED }, + { ".type", "gas", dir_type, YASM_DIR_ID_REQUIRED }, + { ".size", "gas", dir_size, YASM_DIR_ID_REQUIRED }, + { ".weak", "gas", dir_weak, YASM_DIR_ID_REQUIRED }, { ".ident", "gas", dir_ident, YASM_DIR_ANY }, - { "type", "nasm", dir_type, YASM_DIR_ID_REQUIRED }, - { "size", "nasm", dir_size, YASM_DIR_ID_REQUIRED }, - { "weak", "nasm", dir_weak, YASM_DIR_ID_REQUIRED }, + { "type", "nasm", dir_type, YASM_DIR_ID_REQUIRED }, + { "size", "nasm", dir_size, YASM_DIR_ID_REQUIRED }, + { "weak", "nasm", dir_weak, YASM_DIR_ID_REQUIRED }, { "ident", "nasm", dir_ident, YASM_DIR_ANY }, { NULL, NULL, NULL, 0 } }; -static const char *elf_nasm_stdmac[] = { - "%imacro type 1+.nolist", - "[type %1]", - "%endmacro", - "%imacro size 1+.nolist", - "[size %1]", - "%endmacro", - "%imacro weak 1+.nolist", - "[weak %1]", - "%endmacro", - NULL -}; - -static const yasm_stdmac elf_objfmt_stdmacs[] = { - { "nasm", "nasm", elf_nasm_stdmac }, - { NULL, NULL, NULL } -}; - /* Define objfmt structure -- see objfmt.h for details */ yasm_objfmt_module yasm_elf_LTX_objfmt = { "ELF", "elf", "o", 32, - 0, elf_objfmt_dbgfmt_keywords, "null", elf_objfmt_directives, - elf_objfmt_stdmacs, elf_objfmt_create, elf_objfmt_output, elf_objfmt_destroy, elf_objfmt_add_default_section, - elf_objfmt_init_new_section, - elf_objfmt_section_switch, - elf_objfmt_get_special_sym + elf_objfmt_section_switch }; yasm_objfmt_module yasm_elf32_LTX_objfmt = { @@ -1344,18 +1310,14 @@ yasm_objfmt_module yasm_elf32_LTX_objfmt = { "elf32", "o", 32, - 0, elf_objfmt_dbgfmt_keywords, "null", elf_objfmt_directives, - elf_objfmt_stdmacs, elf32_objfmt_create, elf_objfmt_output, elf_objfmt_destroy, elf_objfmt_add_default_section, - elf_objfmt_init_new_section, - elf_objfmt_section_switch, - elf_objfmt_get_special_sym + elf_objfmt_section_switch }; yasm_objfmt_module yasm_elf64_LTX_objfmt = { @@ -1363,35 +1325,12 @@ yasm_objfmt_module yasm_elf64_LTX_objfmt = { "elf64", "o", 64, - 0, elf_objfmt_dbgfmt_keywords, "null", elf_objfmt_directives, - elf_objfmt_stdmacs, elf64_objfmt_create, elf_objfmt_output, elf_objfmt_destroy, elf_objfmt_add_default_section, - elf_objfmt_init_new_section, - elf_objfmt_section_switch, - elf_objfmt_get_special_sym -}; - -yasm_objfmt_module yasm_elfx32_LTX_objfmt = { - "ELF (x32)", - "elfx32", - "o", - 64, - 0, - elf_objfmt_dbgfmt_keywords, - "null", - elf_objfmt_directives, - elf_objfmt_stdmacs, - elfx32_objfmt_create, - elf_objfmt_output, - elf_objfmt_destroy, - elf_objfmt_add_default_section, - elf_objfmt_init_new_section, - elf_objfmt_section_switch, - elf_objfmt_get_special_sym + elf_objfmt_section_switch }; diff --git a/modules/objfmts/elf/elf-x86-amd64.c b/modules/objfmts/elf/elf-x86-amd64.c index 3ba376af..9459beb5 100644 --- a/modules/objfmts/elf/elf-x86-amd64.c +++ b/modules/objfmts/elf/elf-x86-amd64.c @@ -26,44 +26,31 @@ */ #include +/*@unused@*/ RCSID("$Id$"); +#define YASM_LIB_INTERNAL +#define YASM_EXPR_INTERNAL #include #define YASM_OBJFMT_ELF_INTERNAL #include "elf.h" #include "elf-machine.h" -static elf_machine_ssym elf_x86_amd64_ssyms[] = { - {"pltoff", ELF_SSYM_SYM_RELATIVE, R_X86_64_PLTOFF64, 64}, - {"plt", ELF_SSYM_SYM_RELATIVE, R_X86_64_PLT32, 32}, - {"gotplt", ELF_SSYM_SYM_RELATIVE, R_X86_64_GOTPLT64, 64}, - {"gotoff", ELF_SSYM_SYM_RELATIVE, R_X86_64_GOTOFF64, 64}, - {"gotpcrel", ELF_SSYM_SYM_RELATIVE, R_X86_64_GOTPCREL, 32}, - {"tlsgd", ELF_SSYM_SYM_RELATIVE|ELF_SSYM_THREAD_LOCAL, - R_X86_64_TLSGD, 32}, - {"tlsld", ELF_SSYM_SYM_RELATIVE|ELF_SSYM_THREAD_LOCAL, - R_X86_64_TLSLD, 32}, - {"gottpoff", ELF_SSYM_SYM_RELATIVE|ELF_SSYM_THREAD_LOCAL, - R_X86_64_GOTTPOFF, 32}, - {"tpoff", ELF_SSYM_SYM_RELATIVE|ELF_SSYM_THREAD_LOCAL, - R_X86_64_TPOFF32, 32}, - {"dtpoff", ELF_SSYM_SYM_RELATIVE|ELF_SSYM_THREAD_LOCAL, - R_X86_64_DTPOFF32, 32}, - {"got", ELF_SSYM_SYM_RELATIVE, R_X86_64_GOT32, 32}, - {"tlsdesc", ELF_SSYM_SYM_RELATIVE|ELF_SSYM_THREAD_LOCAL, - R_X86_64_GOTPC32_TLSDESC, 32}, - {"tlscall", ELF_SSYM_SYM_RELATIVE|ELF_SSYM_THREAD_LOCAL, - R_X86_64_TLSDESC_CALL, 32} +enum ssym_index { + SSYM_GOTPCREL = 0, + SSYM_GOT, + SSYM_PLT }; static int -elf_x86_amd64_accepts_reloc(size_t val, yasm_symrec *wrt) +elf_x86_amd64_accepts_reloc(size_t val, yasm_symrec *wrt, yasm_symrec **ssyms) { if (wrt) { - const elf_machine_ssym *ssym = (elf_machine_ssym *) - yasm_symrec_get_data(wrt, &elf_ssym_symrec_data); - if (!ssym || val != ssym->size) - return 0; - return 1; + if ((wrt == ssyms[SSYM_GOTPCREL] && val == 32) + || (wrt == ssyms[SSYM_GOT] && val == 32) + || (wrt == ssyms[SSYM_PLT] && val == 32)) + return 1; + else + return 0; } return (val&(val-1)) ? 0 : ((val & (8|16|32|64)) != 0); } @@ -96,7 +83,7 @@ elf_x86_amd64_write_secthead(unsigned char *bufp, elf_secthead *shead) YASM_WRITE_32_L(bufp, shead->name ? shead->name->index : 0); YASM_WRITE_32_L(bufp, shead->type); YASM_WRITE_64Z_L(bufp, shead->flags); - YASM_WRITE_64Z_L(bufp, 0); /* vmem address */ + YASM_WRITE_64Z_L(bufp, 0); /* vmem address */ YASM_WRITE_64Z_L(bufp, shead->offset); YASM_WRITE_64I_L(bufp, shead->size); @@ -125,20 +112,18 @@ elf_x86_amd64_write_secthead_rel(unsigned char *bufp, nreloc = yasm_intnum_create_uint(shead->nreloc); relocsize = yasm_intnum_create_uint(RELOC64A_SIZE); yasm_intnum_calc(relocsize, YASM_EXPR_MUL, nreloc); - YASM_WRITE_64I_L(bufp, relocsize); /* size */ + YASM_WRITE_64I_L(bufp, relocsize); /* size */ yasm_intnum_destroy(nreloc); yasm_intnum_destroy(relocsize); - YASM_WRITE_32_L(bufp, symtab_idx); /* link: symtab index */ - YASM_WRITE_32_L(bufp, shead->index); /* info: relocated's index */ - YASM_WRITE_64Z_L(bufp, RELOC64_ALIGN); /* align */ - YASM_WRITE_64Z_L(bufp, RELOC64A_SIZE); /* entity size */ + YASM_WRITE_32_L(bufp, symtab_idx); /* link: symtab index */ + YASM_WRITE_32_L(bufp, shead->index); /* info: relocated's index */ + YASM_WRITE_64Z_L(bufp, RELOC64_ALIGN); /* align */ + YASM_WRITE_64Z_L(bufp, RELOC64A_SIZE); /* entity size */ } static void -elf_x86_amd64_handle_reloc_addend(yasm_intnum *intn, - elf_reloc_entry *reloc, - unsigned long offset) +elf_x86_amd64_handle_reloc_addend(yasm_intnum *intn, elf_reloc_entry *reloc) { /* .rela: copy value out as addend, replace original with 0 */ reloc->addend = yasm_intnum_copy(intn); @@ -146,36 +131,23 @@ elf_x86_amd64_handle_reloc_addend(yasm_intnum *intn, } static unsigned int -elf_x86_amd64_map_reloc_info_to_type(elf_reloc_entry *reloc) +elf_x86_amd64_map_reloc_info_to_type(elf_reloc_entry *reloc, + yasm_symrec **ssyms) { if (reloc->wrt) { - const elf_machine_ssym *ssym = (elf_machine_ssym *) - yasm_symrec_get_data(reloc->wrt, &elf_ssym_symrec_data); - if (!ssym || reloc->valsize != ssym->size) - yasm_internal_error(N_("Unsupported WRT")); - - /* Force TLS type; this is required by the linker. */ - if (ssym->sym_rel & ELF_SSYM_THREAD_LOCAL) { - elf_symtab_entry *esym; - - esym = yasm_symrec_get_data(reloc->reloc.sym, &elf_symrec_data); - if (esym) - esym->type = STT_TLS; - } - /* Map PC-relative GOT to appropriate relocation */ - if (reloc->rtype_rel && ssym->reloc == R_X86_64_GOT32) - return (unsigned char) R_X86_64_GOTPCREL; - return (unsigned char) ssym->reloc; - } else if (reloc->is_GOT_sym && reloc->valsize == 32) { - return (unsigned char) R_X86_64_GOTPC32; - } else if (reloc->is_GOT_sym && reloc->valsize == 64) { - return (unsigned char) R_X86_64_GOTPC64; + if (reloc->wrt == ssyms[SSYM_GOTPCREL] && reloc->valsize == 32) + return (unsigned char) R_X86_64_GOTPCREL; + else if (reloc->wrt == ssyms[SSYM_GOT] && reloc->valsize == 32) + return (unsigned char) R_X86_64_GOT32; + else if (reloc->wrt == ssyms[SSYM_PLT] && reloc->valsize == 32) + return (unsigned char) R_X86_64_PLT32; + else + yasm_internal_error(N_("Unsupported WRT")); } else if (reloc->rtype_rel) { switch (reloc->valsize) { case 8: return (unsigned char) R_X86_64_PC8; case 16: return (unsigned char) R_X86_64_PC16; case 32: return (unsigned char) R_X86_64_PC32; - case 64: return (unsigned char) R_X86_64_PC64; default: yasm_internal_error(N_("Unsupported relocation size")); } } else { @@ -198,10 +170,10 @@ elf_x86_amd64_write_reloc(unsigned char *bufp, elf_reloc_entry *reloc, /*YASM_WRITE_64_L(bufp, ELF64_R_INFO(r_sym, r_type));*/ YASM_WRITE_64C_L(bufp, r_sym, r_type); if (reloc->addend) - YASM_WRITE_64I_L(bufp, reloc->addend); + YASM_WRITE_64I_L(bufp, reloc->addend); else { - YASM_WRITE_32_L(bufp, 0); - YASM_WRITE_32_L(bufp, 0); + YASM_WRITE_32_L(bufp, 0); + YASM_WRITE_32_L(bufp, 0); } } @@ -213,31 +185,37 @@ elf_x86_amd64_write_proghead(unsigned char **bufpp, { unsigned char *bufp = *bufpp; unsigned char *buf = bufp-4; - YASM_WRITE_8(bufp, ELFCLASS64); /* elf class */ - YASM_WRITE_8(bufp, ELFDATA2LSB); /* data encoding :: MSB? */ - YASM_WRITE_8(bufp, EV_CURRENT); /* elf version */ - YASM_WRITE_8(bufp, ELFOSABI_SYSV); /* os/abi */ - YASM_WRITE_8(bufp, 0); /* SYSV v3 ABI=0 */ - while (bufp-buf < EI_NIDENT) /* e_ident padding */ + YASM_WRITE_8(bufp, ELFCLASS64); /* elf class */ + YASM_WRITE_8(bufp, ELFDATA2LSB); /* data encoding :: MSB? */ + YASM_WRITE_8(bufp, EV_CURRENT); /* elf version */ + YASM_WRITE_8(bufp, ELFOSABI_SYSV); /* os/abi */ + YASM_WRITE_8(bufp, 0); /* SYSV v3 ABI=0 */ + while (bufp-buf < EI_NIDENT) /* e_ident padding */ YASM_WRITE_8(bufp, 0); - YASM_WRITE_16_L(bufp, ET_REL); /* e_type - object file */ - YASM_WRITE_16_L(bufp, EM_X86_64); /* e_machine - or others */ - YASM_WRITE_32_L(bufp, EV_CURRENT); /* elf version */ - YASM_WRITE_64Z_L(bufp, 0); /* e_entry */ - YASM_WRITE_64Z_L(bufp, 0); /* e_phoff */ + YASM_WRITE_16_L(bufp, ET_REL); /* e_type - object file */ + YASM_WRITE_16_L(bufp, EM_X86_64); /* e_machine - or others */ + YASM_WRITE_32_L(bufp, EV_CURRENT); /* elf version */ + YASM_WRITE_64Z_L(bufp, 0); /* e_entry */ + YASM_WRITE_64Z_L(bufp, 0); /* e_phoff */ YASM_WRITE_64Z_L(bufp, secthead_addr); /* e_shoff secthead off */ - YASM_WRITE_32_L(bufp, 0); /* e_flags */ - YASM_WRITE_16_L(bufp, EHDR64_SIZE); /* e_ehsize */ - YASM_WRITE_16_L(bufp, 0); /* e_phentsize */ - YASM_WRITE_16_L(bufp, 0); /* e_phnum */ - YASM_WRITE_16_L(bufp, SHDR64_SIZE); /* e_shentsize */ + YASM_WRITE_32_L(bufp, 0); /* e_flags */ + YASM_WRITE_16_L(bufp, EHDR64_SIZE); /* e_ehsize */ + YASM_WRITE_16_L(bufp, 0); /* e_phentsize */ + YASM_WRITE_16_L(bufp, 0); /* e_phnum */ + YASM_WRITE_16_L(bufp, SHDR64_SIZE); /* e_shentsize */ YASM_WRITE_16_L(bufp, secthead_count); /* e_shnum */ YASM_WRITE_16_L(bufp, shstrtab_index); /* e_shstrndx */ *bufpp = bufp; } +static elf_machine_ssym elf_x86_amd64_ssyms[] = { + {"..gotpcrel", 1}, + {"..got", 1}, + {"..plt", 0} +}; + const elf_machine_handler elf_machine_handler_x86_amd64 = { "x86", "amd64", ".rela", diff --git a/modules/objfmts/elf/elf-x86-x32.c b/modules/objfmts/elf/elf-x86-x32.c deleted file mode 100644 index 40a25a12..00000000 --- a/modules/objfmts/elf/elf-x86-x32.c +++ /dev/null @@ -1,251 +0,0 @@ -/* - * ELF object format helpers - x86:x32 - * - * Copyright (C) 2012 Michael Urman and H.J. Lu - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND OTHER CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR OTHER CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -#include -#define YASM_OBJFMT_ELF_INTERNAL -#include "elf.h" -#include "elf-machine.h" - -static elf_machine_ssym elf_x86_x32_ssyms[] = { - {"plt", ELF_SSYM_SYM_RELATIVE, R_X86_64_PLT32, 32}, - {"gotpcrel", ELF_SSYM_SYM_RELATIVE, R_X86_64_GOTPCREL, 32}, - {"tlsgd", ELF_SSYM_SYM_RELATIVE|ELF_SSYM_THREAD_LOCAL, - R_X86_64_TLSGD, 32}, - {"tlsld", ELF_SSYM_SYM_RELATIVE|ELF_SSYM_THREAD_LOCAL, - R_X86_64_TLSLD, 32}, - {"gottpoff", ELF_SSYM_SYM_RELATIVE|ELF_SSYM_THREAD_LOCAL, - R_X86_64_GOTTPOFF, 32}, - {"tpoff", ELF_SSYM_SYM_RELATIVE|ELF_SSYM_THREAD_LOCAL, - R_X86_64_TPOFF32, 32}, - {"dtpoff", ELF_SSYM_SYM_RELATIVE|ELF_SSYM_THREAD_LOCAL, - R_X86_64_DTPOFF32, 32}, - {"got", ELF_SSYM_SYM_RELATIVE, R_X86_64_GOT32, 32}, - {"tlsdesc", ELF_SSYM_SYM_RELATIVE|ELF_SSYM_THREAD_LOCAL, - R_X86_64_GOTPC32_TLSDESC, 32}, - {"tlscall", ELF_SSYM_SYM_RELATIVE|ELF_SSYM_THREAD_LOCAL, - R_X86_64_TLSDESC_CALL, 32} -}; - -static int -elf_x86_x32_accepts_reloc(size_t val, yasm_symrec *wrt) -{ - if (wrt) { - const elf_machine_ssym *ssym = (elf_machine_ssym *) - yasm_symrec_get_data(wrt, &elf_ssym_symrec_data); - if (!ssym || val != ssym->size) - return 0; - return 1; - } - return (val&(val-1)) ? 0 : ((val & (8|16|32)) != 0); -} - -static void -elf_x86_x32_write_symtab_entry(unsigned char *bufp, - elf_symtab_entry *entry, - yasm_intnum *value_intn, - yasm_intnum *size_intn) -{ - YASM_WRITE_32_L(bufp, entry->name ? entry->name->index : 0); - YASM_WRITE_32I_L(bufp, value_intn); - YASM_WRITE_32I_L(bufp, size_intn); - - YASM_WRITE_8(bufp, ELF32_ST_INFO(entry->bind, entry->type)); - YASM_WRITE_8(bufp, ELF32_ST_OTHER(entry->vis)); - if (entry->sect) { - elf_secthead *shead = - yasm_section_get_data(entry->sect, &elf_section_data); - if (!shead) - yasm_internal_error(N_("symbol references section without data")); - YASM_WRITE_16_L(bufp, shead->index); - } else { - YASM_WRITE_16_L(bufp, entry->index); - } -} - -static void -elf_x86_x32_write_secthead(unsigned char *bufp, elf_secthead *shead) -{ - YASM_WRITE_32_L(bufp, shead->name ? shead->name->index : 0); - YASM_WRITE_32_L(bufp, shead->type); - YASM_WRITE_32_L(bufp, shead->flags); - YASM_WRITE_32_L(bufp, 0); /* vmem address */ - YASM_WRITE_32_L(bufp, shead->offset); - YASM_WRITE_32I_L(bufp, shead->size); - - YASM_WRITE_32_L(bufp, shead->link); - YASM_WRITE_32_L(bufp, shead->info); - - YASM_WRITE_32_L(bufp, shead->align); - YASM_WRITE_32_L(bufp, shead->entsize); -} - -static void -elf_x86_x32_write_secthead_rel(unsigned char *bufp, - elf_secthead *shead, - elf_section_index symtab_idx, - elf_section_index sindex) -{ - yasm_intnum *nreloc; - yasm_intnum *relocsize; - - YASM_WRITE_32_L(bufp, shead->rel_name ? shead->rel_name->index : 0); - YASM_WRITE_32_L(bufp, SHT_RELA); - YASM_WRITE_32_L(bufp, 0); - YASM_WRITE_32_L(bufp, 0); - YASM_WRITE_32_L(bufp, shead->rel_offset); - - nreloc = yasm_intnum_create_uint(shead->nreloc); - relocsize = yasm_intnum_create_uint(RELOC32A_SIZE); - yasm_intnum_calc(relocsize, YASM_EXPR_MUL, nreloc); - YASM_WRITE_32I_L(bufp, relocsize); /* size */ - yasm_intnum_destroy(nreloc); - yasm_intnum_destroy(relocsize); - - YASM_WRITE_32_L(bufp, symtab_idx); /* link: symtab index */ - YASM_WRITE_32_L(bufp, shead->index); /* info: relocated's index */ - YASM_WRITE_32_L(bufp, RELOC32_ALIGN); /* align */ - YASM_WRITE_32_L(bufp, RELOC32A_SIZE); /* entity size */ -} - -static void -elf_x86_x32_handle_reloc_addend(yasm_intnum *intn, - elf_reloc_entry *reloc, - unsigned long offset) -{ - /* .rela: copy value out as addend, replace original with 0 */ - reloc->addend = yasm_intnum_copy(intn); - yasm_intnum_zero(intn); -} - -static unsigned int -elf_x86_x32_map_reloc_info_to_type(elf_reloc_entry *reloc) -{ - if (reloc->wrt) { - const elf_machine_ssym *ssym = (elf_machine_ssym *) - yasm_symrec_get_data(reloc->wrt, &elf_ssym_symrec_data); - if (!ssym || reloc->valsize != ssym->size) - yasm_internal_error(N_("Unsupported WRT")); - - /* Force TLS type; this is required by the linker. */ - if (ssym->sym_rel & ELF_SSYM_THREAD_LOCAL) { - elf_symtab_entry *esym; - - esym = yasm_symrec_get_data(reloc->reloc.sym, &elf_symrec_data); - if (esym) - esym->type = STT_TLS; - } - /* Map PC-relative GOT to appropriate relocation */ - if (reloc->rtype_rel && ssym->reloc == R_X86_64_GOT32) - return (unsigned char) R_X86_64_GOTPCREL; - return (unsigned char) ssym->reloc; - } else if (reloc->is_GOT_sym && reloc->valsize == 32) { - return (unsigned char) R_X86_64_GOTPC32; - } else if (reloc->is_GOT_sym && reloc->valsize == 64) { - yasm_internal_error(N_("Unsupported relocation size")); - } else if (reloc->rtype_rel) { - switch (reloc->valsize) { - case 8: return (unsigned char) R_X86_64_PC8; - case 16: return (unsigned char) R_X86_64_PC16; - case 32: return (unsigned char) R_X86_64_PC32; - default: yasm_internal_error(N_("Unsupported relocation size")); - } - } else { - switch (reloc->valsize) { - case 8: return (unsigned char) R_X86_64_8; - case 16: return (unsigned char) R_X86_64_16; - case 32: return (unsigned char) R_X86_64_32; - case 64: return (unsigned char) R_X86_64_64; - default: yasm_internal_error(N_("Unsupported relocation size")); - } - } - return 0; -} - -static void -elf_x86_x32_write_reloc(unsigned char *bufp, elf_reloc_entry *reloc, - unsigned int r_type, unsigned int r_sym) -{ - YASM_WRITE_32I_L(bufp, reloc->reloc.addr); - YASM_WRITE_32_L(bufp, ELF32_R_INFO((unsigned long)r_sym, (unsigned char)r_type)); - if (reloc->addend) - YASM_WRITE_32I_L(bufp, reloc->addend); - else { - YASM_WRITE_32_L(bufp, 0); - } -} - -static void -elf_x86_x32_write_proghead(unsigned char **bufpp, - elf_offset secthead_addr, - unsigned long secthead_count, - elf_section_index shstrtab_index) -{ - unsigned char *bufp = *bufpp; - unsigned char *buf = bufp-4; - YASM_WRITE_8(bufp, ELFCLASS32); /* elf class */ - YASM_WRITE_8(bufp, ELFDATA2LSB); /* data encoding :: MSB? */ - YASM_WRITE_8(bufp, EV_CURRENT); /* elf version */ - YASM_WRITE_8(bufp, ELFOSABI_SYSV); /* os/abi */ - YASM_WRITE_8(bufp, 0); /* SYSV v3 ABI=0 */ - while (bufp-buf < EI_NIDENT) /* e_ident padding */ - YASM_WRITE_8(bufp, 0); - - YASM_WRITE_16_L(bufp, ET_REL); /* e_type - object file */ - YASM_WRITE_16_L(bufp, EM_X86_64); /* e_machine - or others */ - YASM_WRITE_32_L(bufp, EV_CURRENT); /* elf version */ - YASM_WRITE_32_L(bufp, 0); /* e_entry */ - YASM_WRITE_32_L(bufp, 0); /* e_phoff */ - YASM_WRITE_32_L(bufp, secthead_addr); /* e_shoff secthead off */ - - YASM_WRITE_32_L(bufp, 0); /* e_flags */ - YASM_WRITE_16_L(bufp, EHDR32_SIZE); /* e_ehsize */ - YASM_WRITE_16_L(bufp, 0); /* e_phentsize */ - YASM_WRITE_16_L(bufp, 0); /* e_phnum */ - YASM_WRITE_16_L(bufp, SHDR32_SIZE); /* e_shentsize */ - YASM_WRITE_16_L(bufp, secthead_count); /* e_shnum */ - YASM_WRITE_16_L(bufp, shstrtab_index); /* e_shstrndx */ - *bufpp = bufp; -} - -const elf_machine_handler -elf_machine_handler_x86_x32 = { - "x86", "x32", ".rela", - SYMTAB32_SIZE, SYMTAB32_ALIGN, RELOC32A_SIZE, SHDR32_SIZE, EHDR32_SIZE, - elf_x86_x32_accepts_reloc, - elf_x86_x32_write_symtab_entry, - elf_x86_x32_write_secthead, - elf_x86_x32_write_secthead_rel, - elf_x86_x32_handle_reloc_addend, - elf_x86_x32_map_reloc_info_to_type, - elf_x86_x32_write_reloc, - elf_x86_x32_write_proghead, - elf_x86_x32_ssyms, - sizeof(elf_x86_x32_ssyms)/sizeof(elf_x86_x32_ssyms[0]), - 32 -}; diff --git a/modules/objfmts/elf/elf-x86-x86.c b/modules/objfmts/elf/elf-x86-x86.c index d79ec6ea..0e006b4c 100644 --- a/modules/objfmts/elf/elf-x86-x86.c +++ b/modules/objfmts/elf/elf-x86-x86.c @@ -26,49 +26,33 @@ */ #include +/*@unused@*/ RCSID("$Id$"); +#define YASM_LIB_INTERNAL +#define YASM_EXPR_INTERNAL #include #define YASM_OBJFMT_ELF_INTERNAL #include "elf.h" #include "elf-machine.h" -static elf_machine_ssym elf_x86_x86_ssyms[] = { - {"plt", ELF_SSYM_SYM_RELATIVE, R_386_PLT32, 32}, - {"gotoff", 0, R_386_GOTOFF, 32}, - /* special one for NASM */ - {"gotpc", ELF_SSYM_CURPOS_ADJUST, R_386_GOTPC, 32}, - {"tlsgd", ELF_SSYM_SYM_RELATIVE|ELF_SSYM_THREAD_LOCAL, - R_386_TLS_GD, 32}, - {"tlsldm", ELF_SSYM_SYM_RELATIVE|ELF_SSYM_THREAD_LOCAL, - R_386_TLS_LDM, 32}, - {"gottpoff", ELF_SSYM_SYM_RELATIVE|ELF_SSYM_THREAD_LOCAL, - R_386_TLS_IE_32, 32}, - {"tpoff", ELF_SSYM_SYM_RELATIVE|ELF_SSYM_THREAD_LOCAL, - R_386_TLS_LE_32, 32}, - {"ntpoff", ELF_SSYM_SYM_RELATIVE|ELF_SSYM_THREAD_LOCAL, - R_386_TLS_LE, 32}, - {"dtpoff", ELF_SSYM_SYM_RELATIVE|ELF_SSYM_THREAD_LOCAL, - R_386_TLS_LDO_32, 32}, - {"gotntpoff", ELF_SSYM_SYM_RELATIVE|ELF_SSYM_THREAD_LOCAL, - R_386_TLS_GOTIE, 32}, - {"indntpoff", ELF_SSYM_SYM_RELATIVE|ELF_SSYM_THREAD_LOCAL, - R_386_TLS_IE, 32}, - {"got", ELF_SSYM_SYM_RELATIVE, R_386_GOT32, 32}, - {"tlsdesc", ELF_SSYM_SYM_RELATIVE|ELF_SSYM_THREAD_LOCAL, - R_386_TLS_GOTDESC, 32}, - {"tlscall", ELF_SSYM_SYM_RELATIVE|ELF_SSYM_THREAD_LOCAL, - R_386_TLS_DESC_CALL, 32} +enum ssym_index { + SSYM_GOTPC = 0, + SSYM_GOTOFF, + SSYM_GOT, + SSYM_PLT }; static int -elf_x86_x86_accepts_reloc(size_t val, yasm_symrec *wrt) +elf_x86_x86_accepts_reloc(size_t val, yasm_symrec *wrt, yasm_symrec **ssyms) { if (wrt) { - const elf_machine_ssym *ssym = (elf_machine_ssym *) - yasm_symrec_get_data(wrt, &elf_ssym_symrec_data); - if (!ssym || val != ssym->size) - return 0; - return 1; + if ((wrt == ssyms[SSYM_GOTPC] && val == 32) + || (wrt == ssyms[SSYM_GOTOFF] && val == 32) + || (wrt == ssyms[SSYM_GOT] && val == 32) + || (wrt == ssyms[SSYM_PLT] && val == 32)) + return 1; + else + return 0; } return (val&(val-1)) ? 0 : ((val & (8|16|32)) != 0); } @@ -127,47 +111,34 @@ elf_x86_x86_write_secthead_rel(unsigned char *bufp, YASM_WRITE_32_L(bufp, shead->rel_offset); YASM_WRITE_32_L(bufp, RELOC32_SIZE * shead->nreloc);/* size */ - YASM_WRITE_32_L(bufp, symtab_idx); /* link: symtab index */ - YASM_WRITE_32_L(bufp, shead->index); /* info: relocated's index */ + YASM_WRITE_32_L(bufp, symtab_idx); /* link: symtab index */ + YASM_WRITE_32_L(bufp, shead->index); /* info: relocated's index */ - YASM_WRITE_32_L(bufp, RELOC32_ALIGN); /* align */ - YASM_WRITE_32_L(bufp, RELOC32_SIZE); /* entity size */ + YASM_WRITE_32_L(bufp, RELOC32_ALIGN); /* align */ + YASM_WRITE_32_L(bufp, RELOC32_SIZE); /* entity size */ } static void -elf_x86_x86_handle_reloc_addend(yasm_intnum *intn, - elf_reloc_entry *reloc, - unsigned long offset) +elf_x86_x86_handle_reloc_addend(yasm_intnum *intn, elf_reloc_entry *reloc) { - if (!reloc->wrt && reloc->is_GOT_sym && reloc->valsize == 32 && offset != 0) - { - yasm_intnum *off_intn = yasm_intnum_create_uint(offset); - yasm_intnum_calc(intn, YASM_EXPR_ADD, off_intn); - yasm_intnum_destroy(off_intn); - } return; /* .rel: Leave addend in intn */ } static unsigned int -elf_x86_x86_map_reloc_info_to_type(elf_reloc_entry *reloc) +elf_x86_x86_map_reloc_info_to_type(elf_reloc_entry *reloc, + yasm_symrec **ssyms) { if (reloc->wrt) { - const elf_machine_ssym *ssym = (elf_machine_ssym *) - yasm_symrec_get_data(reloc->wrt, &elf_ssym_symrec_data); - if (!ssym || reloc->valsize != ssym->size) - yasm_internal_error(N_("Unsupported WRT")); - - /* Force TLS type; this is required by the linker. */ - if (ssym->sym_rel & ELF_SSYM_THREAD_LOCAL) { - elf_symtab_entry *esym; - - esym = yasm_symrec_get_data(reloc->reloc.sym, &elf_symrec_data); - if (esym) - esym->type = STT_TLS; - } - return (unsigned char) ssym->reloc; - } else if (reloc->is_GOT_sym && reloc->valsize == 32) { - return (unsigned char) R_386_GOTPC; + if (reloc->wrt == ssyms[SSYM_GOTPC] && reloc->valsize == 32) + return (unsigned char) R_386_GOTPC; + else if (reloc->wrt == ssyms[SSYM_GOTOFF] && reloc->valsize == 32) + return (unsigned char) R_386_GOTOFF; + else if (reloc->wrt == ssyms[SSYM_GOT] && reloc->valsize == 32) + return (unsigned char) R_386_GOT32; + else if (reloc->wrt == ssyms[SSYM_PLT] && reloc->valsize == 32) + return (unsigned char) R_386_PLT32; + else + yasm_internal_error(N_("Unsupported WRT")); } else if (reloc->rtype_rel) { switch (reloc->valsize) { case 8: return (unsigned char) R_386_PC8; @@ -202,28 +173,35 @@ elf_x86_x86_write_proghead(unsigned char **bufpp, { unsigned char *bufp = *bufpp; unsigned char *buf = bufp-4; - YASM_WRITE_8(bufp, ELFCLASS32); /* elf class */ - YASM_WRITE_8(bufp, ELFDATA2LSB); /* data encoding :: MSB? */ - YASM_WRITE_8(bufp, EV_CURRENT); /* elf version */ - while (bufp-buf < EI_NIDENT) /* e_ident padding */ + YASM_WRITE_8(bufp, ELFCLASS32); /* elf class */ + YASM_WRITE_8(bufp, ELFDATA2LSB); /* data encoding :: MSB? */ + YASM_WRITE_8(bufp, EV_CURRENT); /* elf version */ + while (bufp-buf < EI_NIDENT) /* e_ident padding */ YASM_WRITE_8(bufp, 0); - YASM_WRITE_16_L(bufp, ET_REL); /* e_type - object file */ - YASM_WRITE_16_L(bufp, EM_386); /* e_machine - or others */ - YASM_WRITE_32_L(bufp, EV_CURRENT); /* elf version */ - YASM_WRITE_32_L(bufp, 0); /* e_entry exection startaddr */ - YASM_WRITE_32_L(bufp, 0); /* e_phoff program header off */ + YASM_WRITE_16_L(bufp, ET_REL); /* e_type - object file */ + YASM_WRITE_16_L(bufp, EM_386); /* e_machine - or others */ + YASM_WRITE_32_L(bufp, EV_CURRENT); /* elf version */ + YASM_WRITE_32_L(bufp, 0); /* e_entry exection startaddr */ + YASM_WRITE_32_L(bufp, 0); /* e_phoff program header off */ YASM_WRITE_32_L(bufp, secthead_addr); /* e_shoff section header off */ - YASM_WRITE_32_L(bufp, 0); /* e_flags also by arch */ - YASM_WRITE_16_L(bufp, EHDR32_SIZE); /* e_ehsize */ - YASM_WRITE_16_L(bufp, 0); /* e_phentsize */ - YASM_WRITE_16_L(bufp, 0); /* e_phnum */ - YASM_WRITE_16_L(bufp, SHDR32_SIZE); /* e_shentsize */ + YASM_WRITE_32_L(bufp, 0); /* e_flags also by arch */ + YASM_WRITE_16_L(bufp, EHDR32_SIZE); /* e_ehsize */ + YASM_WRITE_16_L(bufp, 0); /* e_phentsize */ + YASM_WRITE_16_L(bufp, 0); /* e_phnum */ + YASM_WRITE_16_L(bufp, SHDR32_SIZE); /* e_shentsize */ YASM_WRITE_16_L(bufp, secthead_count); /* e_shnum */ YASM_WRITE_16_L(bufp, shstrtab_index); /* e_shstrndx */ *bufpp = bufp; } +static elf_machine_ssym elf_x86_x86_ssyms[] = { + {"..gotpc", 0}, + {"..gotoff", 0}, + {"..got", 1}, + {"..plt", 0} +}; + const elf_machine_handler elf_machine_handler_x86_x86 = { "x86", "x86", ".rel", diff --git a/modules/objfmts/elf/elf.c b/modules/objfmts/elf/elf.c index 1ee98bfd..39e06950 100644 --- a/modules/objfmts/elf/elf.c +++ b/modules/objfmts/elf/elf.c @@ -26,7 +26,10 @@ */ #include +/*@unused@*/ RCSID("$Id$"); +#define YASM_LIB_INTERNAL +#define YASM_EXPR_INTERNAL #include #define YASM_OBJFMT_ELF_INTERNAL #include "elf.h" @@ -42,33 +45,25 @@ const yasm_assoc_data_callback elf_section_data = { static void elf_symrec_data_destroy(/*@only@*/ void *d); static void elf_symtab_entry_print(void *data, FILE *f, int indent_level); -static void elf_ssym_symtab_entry_print(void *data, FILE *f, int indent_level); const yasm_assoc_data_callback elf_symrec_data = { elf_symrec_data_destroy, elf_symtab_entry_print }; -const yasm_assoc_data_callback elf_ssym_symrec_data = { - elf_symrec_data_destroy, - elf_ssym_symtab_entry_print -}; - extern elf_machine_handler elf_machine_handler_x86_x86, - elf_machine_handler_x86_amd64, - elf_machine_handler_x86_x32; + elf_machine_handler_x86_amd64; static const elf_machine_handler *elf_machine_handlers[] = { &elf_machine_handler_x86_x86, &elf_machine_handler_x86_amd64, - &elf_machine_handler_x86_x32, NULL }; static const elf_machine_handler elf_null_machine = {0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0}; + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0}; static elf_machine_handler const *elf_march = &elf_null_machine; static yasm_symrec **elf_ssyms; @@ -82,69 +77,37 @@ elf_set_arch(yasm_arch *arch, yasm_symtab *symtab, int bits_pref) elf_march != NULL; elf_march = elf_machine_handlers[++i]) { - if (yasm__strcasecmp(yasm_arch_keyword(arch), elf_march->arch)==0) { - if (yasm__strcasecmp(machine, elf_march->machine)==0) { - if (bits_pref == 0 || bits_pref == elf_march->bits) - break; - } else if (bits_pref == elf_march->bits - && yasm__strcasecmp(machine, "amd64") == 0 - && yasm__strcasecmp(elf_march->machine, "x32") == 0) - break; - } + if (yasm__strcasecmp(yasm_arch_keyword(arch), elf_march->arch)==0) + if (yasm__strcasecmp(machine, elf_march->machine)==0) + if (bits_pref == 0 || bits_pref == elf_march->bits) + break; } if (elf_march && elf_march->num_ssyms > 0) { - /* Allocate "special" syms */ - elf_ssyms = - yasm_xmalloc(elf_march->num_ssyms * sizeof(yasm_symrec *)); - for (i=0; (unsigned int)inum_ssyms; i++) - { - /* FIXME: misuse of NULL bytecode */ - elf_ssyms[i] = yasm_symtab_define_label(symtab, - elf_march->ssyms[i].name, - NULL, 0, 0); - yasm_symrec_add_data(elf_ssyms[i], &elf_ssym_symrec_data, - (void*)&elf_march->ssyms[i]); - } + /* Allocate "special" syms */ + elf_ssyms = + yasm_xmalloc(elf_march->num_ssyms * sizeof(yasm_symrec *)); + for (i=0; (unsigned int)inum_ssyms; i++) + { + /* FIXME: misuse of NULL bytecode */ + elf_ssyms[i] = yasm_symtab_define_label(symtab, + elf_march->ssyms[i].name, + NULL, 1, 0); + } } return elf_march; } -yasm_symrec * -elf_get_special_sym(const char *name, const char *parser) -{ - int i; - for (i=0; (unsigned int)inum_ssyms; i++) { - if (yasm__strcasecmp(name, elf_march->ssyms[i].name) == 0) - return elf_ssyms[i]; - } - return NULL; -} - /* reloc functions */ -int elf_ssym_has_flag(yasm_symrec *wrt, int flag); - int elf_is_wrt_sym_relative(yasm_symrec *wrt) -{ - return elf_ssym_has_flag(wrt, ELF_SSYM_SYM_RELATIVE); -} - -int -elf_is_wrt_pos_adjusted(yasm_symrec *wrt) -{ - return elf_ssym_has_flag(wrt, ELF_SSYM_CURPOS_ADJUST); -} - -int -elf_ssym_has_flag(yasm_symrec *wrt, int flag) { int i; for (i=0; (unsigned int)inum_ssyms; i++) { - if (elf_ssyms[i] == wrt) - return (elf_march->ssyms[i].sym_rel & flag) != 0; + if (elf_ssyms[i] == wrt) + return elf_march->ssyms[i].sym_rel; } return 0; } @@ -152,18 +115,17 @@ elf_ssym_has_flag(yasm_symrec *wrt, int flag) /* takes ownership of addr */ elf_reloc_entry * elf_reloc_entry_create(yasm_symrec *sym, - yasm_symrec *wrt, - yasm_intnum *addr, - int rel, - size_t valsize, - int is_GOT_sym) + yasm_symrec *wrt, + yasm_intnum *addr, + int rel, + size_t valsize) { elf_reloc_entry *entry; if (!elf_march->accepts_reloc) - yasm_internal_error(N_("Unsupported machine for ELF output")); + yasm_internal_error(N_("Unsupported machine for ELF output")); - if (!elf_march->accepts_reloc(valsize, wrt)) + if (!elf_march->accepts_reloc(valsize, wrt, elf_ssyms)) { if (addr) yasm_intnum_destroy(addr); @@ -171,7 +133,7 @@ elf_reloc_entry_create(yasm_symrec *sym, } if (sym == NULL) - yasm_internal_error("sym is null"); + yasm_internal_error("sym is null"); entry = yasm_xmalloc(sizeof(elf_reloc_entry)); entry->reloc.sym = sym; @@ -180,7 +142,6 @@ elf_reloc_entry_create(yasm_symrec *sym, entry->valsize = valsize; entry->addend = NULL; entry->wrt = wrt; - entry->is_GOT_sym = is_GOT_sym; return entry; } @@ -208,21 +169,21 @@ elf_strtab_entry_set_str(elf_strtab_entry *entry, const char *str) { elf_strtab_entry *last; if (entry->str) - yasm_xfree(entry->str); + yasm_xfree(entry->str); entry->str = yasm__xstrdup(str); /* Update all following indices since string length probably changes */ last = entry; entry = STAILQ_NEXT(last, qlink); while (entry) { - entry->index = last->index + (unsigned long)strlen(last->str) + 1; - last = entry; - entry = STAILQ_NEXT(last, qlink); + entry->index = last->index + (unsigned long)strlen(last->str) + 1; + last = entry; + entry = STAILQ_NEXT(last, qlink); } } elf_strtab_head * -elf_strtab_create(void) +elf_strtab_create() { elf_strtab_head *strtab = yasm_xmalloc(sizeof(elf_strtab_head)); elf_strtab_entry *entry = yasm_xmalloc(sizeof(elf_strtab_entry)); @@ -241,9 +202,9 @@ elf_strtab_append_str(elf_strtab_head *strtab, const char *str) elf_strtab_entry *last, *entry; if (strtab == NULL) - yasm_internal_error("strtab is null"); + yasm_internal_error("strtab is null"); if (STAILQ_EMPTY(strtab)) - yasm_internal_error("strtab is missing initial dummy entry"); + yasm_internal_error("strtab is missing initial dummy entry"); last = STAILQ_LAST(strtab, elf_strtab_entry, qlink); @@ -260,16 +221,16 @@ elf_strtab_destroy(elf_strtab_head *strtab) elf_strtab_entry *s1, *s2; if (strtab == NULL) - yasm_internal_error("strtab is null"); + yasm_internal_error("strtab is null"); if (STAILQ_EMPTY(strtab)) - yasm_internal_error("strtab is missing initial dummy entry"); + yasm_internal_error("strtab is missing initial dummy entry"); s1 = STAILQ_FIRST(strtab); while (s1 != NULL) { - s2 = STAILQ_NEXT(s1, qlink); - yasm_xfree(s1->str); - yasm_xfree(s1); - s1 = s2; + s2 = STAILQ_NEXT(s1, qlink); + yasm_xfree(s1->str); + yasm_xfree(s1); + s1 = s2; } yasm_xfree(strtab); } @@ -281,13 +242,13 @@ elf_strtab_output_to_file(FILE *f, elf_strtab_head *strtab) elf_strtab_entry *entry; if (strtab == NULL) - yasm_internal_error("strtab is null"); + yasm_internal_error("strtab is null"); /* consider optimizing tables here */ STAILQ_FOREACH(entry, strtab, qlink) { - size_t len = 1 + strlen(entry->str); - fwrite(entry->str, len, 1, f); - size += (unsigned long)len; + size_t len = 1 + strlen(entry->str); + fwrite(entry->str, len, 1, f); + size += (unsigned long)len; } return size; } @@ -297,7 +258,7 @@ elf_strtab_output_to_file(FILE *f, elf_strtab_head *strtab) /* symtab functions */ elf_symtab_entry * elf_symtab_entry_create(elf_strtab_entry *name, - yasm_symrec *sym) + yasm_symrec *sym) { elf_symtab_entry *entry = yasm_xmalloc(sizeof(elf_symtab_entry)); entry->in_table = 0; @@ -320,7 +281,7 @@ static void elf_symtab_entry_destroy(elf_symtab_entry *entry) { if (entry == NULL) - yasm_internal_error("symtab entry is null"); + yasm_internal_error("symtab entry is null"); yasm_xfree(entry); } @@ -340,40 +301,34 @@ elf_symtab_entry_print(void *data, FILE *f, int indent_level) { elf_symtab_entry *entry = data; if (entry == NULL) - yasm_internal_error("symtab entry is null"); + yasm_internal_error("symtab entry is null"); fprintf(f, "%*sbind=", indent_level, ""); switch (entry->bind) { - case STB_LOCAL: fprintf(f, "local\n"); break; - case STB_GLOBAL: fprintf(f, "global\n"); break; - case STB_WEAK: fprintf(f, "weak\n"); break; - default: fprintf(f, "undef\n"); break; + case STB_LOCAL: fprintf(f, "local\n"); break; + case STB_GLOBAL: fprintf(f, "global\n"); break; + case STB_WEAK: fprintf(f, "weak\n"); break; + default: fprintf(f, "undef\n"); break; } fprintf(f, "%*stype=", indent_level, ""); switch (entry->type) { - case STT_NOTYPE: fprintf(f, "notype\n"); break; - case STT_OBJECT: fprintf(f, "object\n"); break; - case STT_FUNC: fprintf(f, "func\n"); break; - case STT_SECTION: fprintf(f, "section\n");break; - case STT_FILE: fprintf(f, "file\n"); break; - default: fprintf(f, "undef\n"); break; + case STT_NOTYPE: fprintf(f, "notype\n"); break; + case STT_OBJECT: fprintf(f, "object\n"); break; + case STT_FUNC: fprintf(f, "func\n"); break; + case STT_SECTION: fprintf(f, "section\n");break; + case STT_FILE: fprintf(f, "file\n"); break; + default: fprintf(f, "undef\n"); break; } fprintf(f, "%*ssize=", indent_level, ""); if (entry->xsize) - yasm_expr_print(entry->xsize, f); + yasm_expr_print(entry->xsize, f); else - fprintf(f, "%ld", entry->size); + fprintf(f, "%ld", entry->size); fprintf(f, "\n"); } -static void -elf_ssym_symtab_entry_print(void *data, FILE *f, int indent_level) -{ - /* TODO */ -} - elf_symtab_head * -elf_symtab_create(void) +elf_symtab_create() { elf_symtab_head *symtab = yasm_xmalloc(sizeof(elf_symtab_head)); elf_symtab_entry *entry = yasm_xmalloc(sizeof(elf_symtab_entry)); @@ -399,11 +354,11 @@ void elf_symtab_append_entry(elf_symtab_head *symtab, elf_symtab_entry *entry) { if (symtab == NULL) - yasm_internal_error("symtab is null"); + yasm_internal_error("symtab is null"); if (entry == NULL) - yasm_internal_error("symtab entry is null"); + yasm_internal_error("symtab entry is null"); if (STAILQ_EMPTY(symtab)) - yasm_internal_error(N_("symtab is missing initial dummy entry")); + yasm_internal_error(N_("symtab is missing initial dummy entry")); STAILQ_INSERT_TAIL(symtab, entry, qlink); entry->in_table = 1; @@ -416,9 +371,9 @@ elf_symtab_insert_local_sym(elf_symtab_head *symtab, elf_symtab_entry *entry) elf_symtab_entry *before = NULL; while (after && (after->bind == STB_LOCAL)) { - before = after; - if (before->type == STT_FILE) break; - after = STAILQ_NEXT(after, qlink); + before = after; + if (before->type == STT_FILE) break; + after = STAILQ_NEXT(after, qlink); } STAILQ_INSERT_AFTER(symtab, before, entry, qlink); entry->in_table = 1; @@ -430,15 +385,15 @@ elf_symtab_destroy(elf_symtab_head *symtab) elf_symtab_entry *s1, *s2; if (symtab == NULL) - yasm_internal_error("symtab is null"); + yasm_internal_error("symtab is null"); if (STAILQ_EMPTY(symtab)) - yasm_internal_error(N_("symtab is missing initial dummy entry")); + yasm_internal_error(N_("symtab is missing initial dummy entry")); s1 = STAILQ_FIRST(symtab); while (s1 != NULL) { - s2 = STAILQ_NEXT(s1, qlink); - elf_symtab_entry_destroy(s1); - s1 = s2; + s2 = STAILQ_NEXT(s1, qlink); + elf_symtab_entry_destroy(s1); + s1 = s2; } yasm_xfree(symtab); } @@ -450,84 +405,73 @@ elf_symtab_assign_indices(elf_symtab_head *symtab) unsigned long last_local=0; if (symtab == NULL) - yasm_internal_error("symtab is null"); + yasm_internal_error("symtab is null"); if (STAILQ_EMPTY(symtab)) - yasm_internal_error(N_("symtab is missing initial dummy entry")); + yasm_internal_error(N_("symtab is missing initial dummy entry")); STAILQ_FOREACH(entry, symtab, qlink) { - if (prev) - entry->symindex = prev->symindex + 1; - if (entry->bind == STB_LOCAL) - last_local = entry->symindex; - prev = entry; + if (prev) + entry->symindex = prev->symindex + 1; + if (entry->bind == STB_LOCAL) + last_local = entry->symindex; + prev = entry; } return last_local + 1; } unsigned long elf_symtab_write_to_file(FILE *f, elf_symtab_head *symtab, - yasm_errwarns *errwarns) + yasm_errwarns *errwarns) { unsigned char buf[SYMTAB_MAXSIZE], *bufp; - elf_symtab_entry *entry; + elf_symtab_entry *entry, *prev; unsigned long size = 0; if (!symtab) - yasm_internal_error(N_("symtab is null")); + yasm_internal_error(N_("symtab is null")); + prev = NULL; STAILQ_FOREACH(entry, symtab, qlink) { - yasm_intnum *size_intn=NULL, *value_intn=NULL; - bufp = buf; + yasm_intnum *size_intn=NULL, *value_intn=NULL; + bufp = buf; - /* get size (if specified); expr overrides stored integer */ - if (entry->xsize) { - yasm_intnum *intn = yasm_expr_get_intnum(&entry->xsize, 1); - if (!intn) { - yasm_error_set(YASM_ERROR_VALUE, - N_("size specifier not an integer expression")); - yasm_errwarn_propagate(errwarns, entry->xsize->line); - } else - size_intn = yasm_intnum_copy(intn); - } - if (!size_intn) - size_intn = yasm_intnum_create_uint(entry->size); + /* get size (if specified); expr overrides stored integer */ + if (entry->xsize) { + size_intn = yasm_intnum_copy( + yasm_expr_get_intnum(&entry->xsize, 1)); + if (!size_intn) { + yasm_error_set(YASM_ERROR_VALUE, + N_("size specifier not an integer expression")); + yasm_errwarn_propagate(errwarns, entry->xsize->line); + } + } + else + size_intn = yasm_intnum_create_uint(entry->size); - /* get EQU value for constants */ - if (entry->sym) { - const yasm_expr *equ_expr_c; - equ_expr_c = yasm_symrec_get_equ(entry->sym); + /* get EQU value for constants */ + if (entry->sym) { + const yasm_expr *equ_expr_c; + equ_expr_c = yasm_symrec_get_equ(entry->sym); - if (equ_expr_c != NULL) { - const yasm_intnum *equ_intn; - yasm_expr *equ_expr = yasm_expr_copy(equ_expr_c); - equ_intn = yasm_expr_get_intnum(&equ_expr, 1); + if (equ_expr_c != NULL) { + const yasm_intnum *equ_intn; + yasm_expr *equ_expr = yasm_expr_copy(equ_expr_c); + equ_intn = yasm_expr_get_intnum(&equ_expr, 1); - if (equ_intn == NULL) { - yasm_error_set(YASM_ERROR_VALUE, - N_("EQU value not an integer expression")); - yasm_errwarn_propagate(errwarns, equ_expr->line); - } else - value_intn = yasm_intnum_copy(equ_intn); - entry->index = SHN_ABS; - yasm_expr_destroy(equ_expr); - } - } - if (value_intn == NULL) - value_intn = yasm_intnum_create_uint(entry->value); + if (equ_intn == NULL) { + yasm_error_set(YASM_ERROR_VALUE, + N_("EQU value not an integer expression")); + yasm_errwarn_propagate(errwarns, equ_expr->line); + } else + value_intn = yasm_intnum_copy(equ_intn); + entry->index = SHN_ABS; + yasm_expr_destroy(equ_expr); + } + } + if (value_intn == NULL) + value_intn = yasm_intnum_create_uint(entry->value); - /* If symbol is in a TLS section, force its type to TLS. */ - if (entry->sym) { - yasm_bytecode *precbc; - yasm_section *sect; - elf_secthead *shead; - if (yasm_symrec_get_label(entry->sym, &precbc) && - (sect = yasm_bc_get_section(precbc)) && - (shead = yasm_section_get_data(sect, &elf_section_data)) && - shead->flags & SHF_TLS) { - entry->type = STT_TLS; - } - } if (!elf_march->write_symtab_entry || !elf_march->symtab_entry_size) yasm_internal_error(N_("Unsupported machine for ELF output")); @@ -535,22 +479,24 @@ elf_symtab_write_to_file(FILE *f, elf_symtab_head *symtab, fwrite(buf, elf_march->symtab_entry_size, 1, f); size += elf_march->symtab_entry_size; - yasm_intnum_destroy(size_intn); - yasm_intnum_destroy(value_intn); + yasm_intnum_destroy(size_intn); + yasm_intnum_destroy(value_intn); + + prev = entry; } return size; } void elf_symtab_set_nonzero(elf_symtab_entry *entry, - yasm_section *sect, - elf_section_index sectidx, - elf_symbol_binding bind, - elf_symbol_type type, - yasm_expr *xsize, - elf_address *value) + yasm_section *sect, + elf_section_index sectidx, + elf_symbol_binding bind, + elf_symbol_type type, + yasm_expr *xsize, + elf_address *value) { if (!entry) - yasm_internal_error("NULL entry"); + yasm_internal_error("NULL entry"); if (sect) entry->sect = sect; if (sectidx) entry->index = sectidx; if (bind) entry->bind = bind; @@ -578,7 +524,7 @@ elf_sym_set_size(elf_symtab_entry *entry, struct yasm_expr *size) { if (entry->xsize) - yasm_expr_destroy(entry->xsize); + yasm_expr_destroy(entry->xsize); entry->xsize = size; } @@ -589,11 +535,11 @@ elf_sym_in_table(elf_symtab_entry *entry) } elf_secthead * -elf_secthead_create(elf_strtab_entry *name, - elf_section_type type, - elf_section_flags flags, - elf_address offset, - elf_size size) +elf_secthead_create(elf_strtab_entry *name, + elf_section_type type, + elf_section_flags flags, + elf_address offset, + elf_size size) { elf_secthead *esd = yasm_xmalloc(sizeof(elf_secthead)); @@ -617,7 +563,7 @@ elf_secthead_create(elf_strtab_entry *name, if (name && (strcmp(name->str, ".symtab") == 0)) { if (!elf_march->symtab_entry_size || !elf_march->symtab_entry_align) - yasm_internal_error(N_("unsupported ELF format")); + yasm_internal_error(N_("unsupported ELF format")); esd->entsize = elf_march->symtab_entry_size; esd->align = elf_march->symtab_entry_align; } @@ -629,7 +575,7 @@ void elf_secthead_destroy(elf_secthead *shead) { if (shead == NULL) - yasm_internal_error(N_("shead is null")); + yasm_internal_error(N_("shead is null")); yasm_intnum_destroy(shead->size); @@ -647,22 +593,22 @@ elf_secthead_print(void *data, FILE *f, int indent_level) { elf_secthead *sect = data; fprintf(f, "%*sname=%s\n", indent_level, "", - sect->name ? sect->name->str : ""); + sect->name ? sect->name->str : ""); fprintf(f, "%*ssym=\n", indent_level, ""); yasm_symrec_print(sect->sym, f, indent_level+1); fprintf(f, "%*sindex=0x%x\n", indent_level, "", sect->index); fprintf(f, "%*sflags=", indent_level, ""); if (sect->flags & SHF_WRITE) - fprintf(f, "WRITE "); + fprintf(f, "WRITE "); if (sect->flags & SHF_ALLOC) - fprintf(f, "ALLOC "); + fprintf(f, "ALLOC "); if (sect->flags & SHF_EXECINSTR) - fprintf(f, "EXEC "); + fprintf(f, "EXEC "); /*if (sect->flags & SHF_MASKPROC) - fprintf(f, "PROC-SPECIFIC"); */ + fprintf(f, "PROC-SPECIFIC"); */ fprintf(f, "%*soffset=0x%lx\n", indent_level, "", sect->offset); fprintf(f, "%*ssize=0x%lx\n", indent_level, "", - yasm_intnum_get_uint(sect->size)); + yasm_intnum_get_uint(sect->size)); fprintf(f, "%*slink=0x%x\n", indent_level, "", sect->link); fprintf(f, "%*salign=%lu\n", indent_level, "", sect->align); fprintf(f, "%*snreloc=%ld\n", indent_level, "", sect->nreloc); @@ -670,13 +616,13 @@ elf_secthead_print(void *data, FILE *f, int indent_level) unsigned long elf_secthead_write_to_file(FILE *f, elf_secthead *shead, - elf_section_index sindex) + elf_section_index sindex) { unsigned char buf[SHDR_MAXSIZE], *bufp = buf; shead->index = sindex; if (shead == NULL) - yasm_internal_error("shead is null"); + yasm_internal_error("shead is null"); if (!elf_march->write_secthead || !elf_march->secthead_size) yasm_internal_error(N_("Unsupported machine for ELF output")); @@ -689,14 +635,14 @@ elf_secthead_write_to_file(FILE *f, elf_secthead *shead, void elf_secthead_append_reloc(yasm_section *sect, elf_secthead *shead, - elf_reloc_entry *reloc) + elf_reloc_entry *reloc) { if (sect == NULL) - yasm_internal_error("sect is null"); + yasm_internal_error("sect is null"); if (shead == NULL) - yasm_internal_error("shead is null"); + yasm_internal_error("shead is null"); if (reloc == NULL) - yasm_internal_error("reloc is null"); + yasm_internal_error("reloc is null"); shead->nreloc++; yasm_section_add_reloc(sect, (yasm_reloc *)reloc, elf_reloc_entry_destroy); @@ -721,27 +667,25 @@ elf_secthead_name_reloc_section(const char *basesect) } void -elf_handle_reloc_addend(yasm_intnum *intn, - elf_reloc_entry *reloc, - unsigned long offset) +elf_handle_reloc_addend(yasm_intnum *intn, elf_reloc_entry *reloc) { if (!elf_march->handle_reloc_addend) yasm_internal_error(N_("Unsupported machine for ELF output")); - elf_march->handle_reloc_addend(intn, reloc, offset); + elf_march->handle_reloc_addend(intn, reloc); } unsigned long elf_secthead_write_rel_to_file(FILE *f, elf_section_index symtab_idx, - yasm_section *sect, elf_secthead *shead, - elf_section_index sindex) + yasm_section *sect, elf_secthead *shead, + elf_section_index sindex) { unsigned char buf[SHDR_MAXSIZE], *bufp = buf; if (shead == NULL) - yasm_internal_error("shead is null"); + yasm_internal_error("shead is null"); if (!yasm_section_relocs_first(sect)) - return 0; /* no relocations, no .rel.* section header */ + return 0; /* no relocations, no .rel.* section header */ shead->rel_index = sindex; @@ -756,7 +700,7 @@ elf_secthead_write_rel_to_file(FILE *f, elf_section_index symtab_idx, unsigned long elf_secthead_write_relocs_to_file(FILE *f, yasm_section *sect, - elf_secthead *shead, yasm_errwarns *errwarns) + elf_secthead *shead, yasm_errwarns *errwarns) { elf_reloc_entry *reloc; unsigned char buf[RELOC_MAXSIZE], *bufp; @@ -764,50 +708,52 @@ elf_secthead_write_relocs_to_file(FILE *f, yasm_section *sect, long pos; if (shead == NULL) - yasm_internal_error("shead is null"); + yasm_internal_error("shead is null"); reloc = (elf_reloc_entry *)yasm_section_relocs_first(sect); if (!reloc) - return 0; + return 0; /* first align section to multiple of 4 */ pos = ftell(f); if (pos == -1) { - yasm_error_set(YASM_ERROR_IO, - N_("couldn't read position on output stream")); - yasm_errwarn_propagate(errwarns, 0); + yasm_error_set(YASM_ERROR_IO, + N_("couldn't read position on output stream")); + yasm_errwarn_propagate(errwarns, 0); } pos = (pos + 3) & ~3; if (fseek(f, pos, SEEK_SET) < 0) { - yasm_error_set(YASM_ERROR_IO, N_("couldn't seek on output stream")); - yasm_errwarn_propagate(errwarns, 0); + yasm_error_set(YASM_ERROR_IO, N_("couldn't seek on output stream")); + yasm_errwarn_propagate(errwarns, 0); } shead->rel_offset = (unsigned long)pos; while (reloc) { - unsigned int r_type=0, r_sym; - elf_symtab_entry *esym; + yasm_sym_vis vis; + unsigned int r_type=0, r_sym; + elf_symtab_entry *esym; - esym = yasm_symrec_get_data(reloc->reloc.sym, &elf_symrec_data); - if (esym) - r_sym = esym->symindex; - else - r_sym = STN_UNDEF; + esym = yasm_symrec_get_data(reloc->reloc.sym, &elf_symrec_data); + if (esym) + r_sym = esym->symindex; + else + r_sym = STN_UNDEF; + vis = yasm_symrec_get_visibility(reloc->reloc.sym); if (!elf_march->map_reloc_info_to_type) yasm_internal_error(N_("Unsupported arch/machine for elf output")); - r_type = elf_march->map_reloc_info_to_type(reloc); + r_type = elf_march->map_reloc_info_to_type(reloc, elf_ssyms); - bufp = buf; + bufp = buf; if (!elf_march->write_reloc || !elf_march->reloc_entry_size) yasm_internal_error(N_("Unsupported arch/machine for elf output")); elf_march->write_reloc(bufp, reloc, r_type, r_sym); fwrite(buf, elf_march->reloc_entry_size, 1, f); size += elf_march->reloc_entry_size; - reloc = (elf_reloc_entry *) - yasm_section_reloc_next((yasm_reloc *)reloc); + reloc = (elf_reloc_entry *) + yasm_section_reloc_next((yasm_reloc *)reloc); } return size; } @@ -820,7 +766,7 @@ elf_secthead_get_type(elf_secthead *shead) void elf_secthead_set_typeflags(elf_secthead *shead, elf_section_type type, - elf_section_flags flags) + elf_section_flags flags) { shead->type = type; shead->flags = flags; @@ -902,7 +848,7 @@ void elf_secthead_add_size(elf_secthead *shead, yasm_intnum *size) { if (size) { - yasm_intnum_calc(shead->size, YASM_EXPR_ADD, size); + yasm_intnum_calc(shead->size, YASM_EXPR_ADD, size); } } @@ -912,13 +858,13 @@ elf_secthead_set_file_offset(elf_secthead *shead, long pos) unsigned long align = shead->align; if (align == 0 || align == 1) { - shead->offset = (unsigned long)pos; - return pos; + shead->offset = (unsigned long)pos; + return pos; } else if (align & (align - 1)) - yasm_internal_error( - N_("alignment %d for section `%s' is not a power of 2")); - /*, align, sect->name->str);*/ + yasm_internal_error( + N_("alignment %d for section `%s' is not a power of 2")); + /*, align, sect->name->str);*/ shead->offset = (unsigned long)((pos + align - 1) & ~(align - 1)); return (long)shead->offset; @@ -928,25 +874,25 @@ unsigned long elf_proghead_get_size(void) { if (!elf_march->proghead_size) - yasm_internal_error(N_("Unsupported ELF format for output")); + yasm_internal_error(N_("Unsupported ELF format for output")); return elf_march->proghead_size; } unsigned long elf_proghead_write_to_file(FILE *f, - elf_offset secthead_addr, - unsigned long secthead_count, - elf_section_index shstrtab_index) + elf_offset secthead_addr, + unsigned long secthead_count, + elf_section_index shstrtab_index) { unsigned char buf[EHDR_MAXSIZE], *bufp = buf; - YASM_WRITE_8(bufp, ELFMAG0); /* ELF magic number */ + YASM_WRITE_8(bufp, ELFMAG0); /* ELF magic number */ YASM_WRITE_8(bufp, ELFMAG1); YASM_WRITE_8(bufp, ELFMAG2); YASM_WRITE_8(bufp, ELFMAG3); if (!elf_march->write_proghead || !elf_march->proghead_size) - yasm_internal_error(N_("Unsupported ELF format for output")); + yasm_internal_error(N_("Unsupported ELF format for output")); elf_march->write_proghead(&bufp, secthead_addr, secthead_count, shstrtab_index); if (((unsigned)(bufp - buf)) != elf_march->proghead_size) diff --git a/modules/objfmts/elf/elf.h b/modules/objfmts/elf/elf.h index 69ed3f01..5efe859e 100644 --- a/modules/objfmts/elf/elf.h +++ b/modules/objfmts/elf/elf.h @@ -1,4 +1,4 @@ -/* +/* $Id$ * ELF object format helpers * * Copyright (C) 2003-2007 Michael Urman @@ -38,45 +38,44 @@ typedef struct elf_symtab_head elf_symtab_head; typedef struct elf_machine_handler elf_machine_handler; -typedef unsigned long elf_address; -typedef unsigned long elf_offset; -typedef unsigned long elf_size; -typedef unsigned long elf_section_info; +typedef unsigned long elf_address; +typedef unsigned long elf_offset; +typedef unsigned long elf_size; +typedef unsigned long elf_section_info; typedef enum { ET_NONE = 0, - ET_REL = 1, /* Relocatable */ - ET_EXEC = 2, /* Executable */ - ET_DYN = 3, /* Shared object */ - ET_CORE = 4, /* Core */ - ET_LOOS = 0xfe00, /* Environment specific */ + ET_REL = 1, /* Relocatable */ + ET_EXEC = 2, /* Executable */ + ET_DYN = 3, /* Shared object */ + ET_CORE = 4, /* Core */ + ET_LOOS = 0xfe00, /* Environment specific */ ET_HIOS = 0xfeff, - ET_LOPROC = 0xff00, /* Processor specific */ + ET_LOPROC = 0xff00, /* Processor specific */ ET_HIPROC = 0xffff } elf_file_type; typedef enum { EM_NONE = 0, - EM_M32 = 1, /* AT&T WE 32100 */ - EM_SPARC = 2, /* SPARC */ - EM_386 = 3, /* Intel 80386 */ - EM_68K = 4, /* Motorola 68000 */ - EM_88K = 5, /* Motorola 88000 */ - EM_860 = 7, /* Intel 80860 */ - EM_MIPS = 8, /* MIPS RS3000 */ + EM_M32 = 1, /* AT&T WE 32100 */ + EM_SPARC = 2, /* SPARC */ + EM_386 = 3, /* Intel 80386 */ + EM_68K = 4, /* Motorola 68000 */ + EM_88K = 5, /* Motorola 88000 */ + EM_860 = 7, /* Intel 80860 */ + EM_MIPS = 8, /* MIPS RS3000 */ - EM_S370 = 9, /* IBM System/370 */ - EM_MIPS_RS4_BE = 10, /* MIPS R4000 Big-Endian (dep)*/ - EM_PARISC = 15, /* HPPA */ - EM_SPARC32PLUS = 18, /* SPARC v8plus */ - EM_PPC = 20, /* PowerPC 32-bit */ - EM_PPC64 = 21, /* PowerPC 64-bit */ - EM_ARM = 40, /* ARM */ - EM_SPARCV9 = 43, /* SPARC v9 64-bit */ - EM_IA_64 = 50, /* Intel IA-64 */ - EM_X86_64 = 62, /* AMD x86-64 */ - EM_ALPHA = 0x9026, /* Alpha (no ABI) */ - EM_LOONGARCH = 258 /* loongson LoongArch */ + EM_S370 = 9, /* IBM System/370 */ + EM_MIPS_RS4_BE = 10, /* MIPS R4000 Big-Endian (dep)*/ + EM_PARISC = 15, /* HPPA */ + EM_SPARC32PLUS = 18, /* SPARC v8plus */ + EM_PPC = 20, /* PowerPC 32-bit */ + EM_PPC64 = 21, /* PowerPC 64-bit */ + EM_ARM = 40, /* ARM */ + EM_SPARCV9 = 43, /* SPARC v9 64-bit */ + EM_IA_64 = 50, /* Intel IA-64 */ + EM_X86_64 = 62, /* AMD x86-64 */ + EM_ALPHA = 0x9026 /* Alpha (no ABI) */ } elf_machine; typedef enum { @@ -87,35 +86,35 @@ typedef enum { } elf_magic; typedef enum { - EV_NONE = 0, /* invalid */ - EV_CURRENT = 1 /* current */ + EV_NONE = 0, /* invalid */ + EV_CURRENT = 1 /* current */ } elf_version; typedef enum { - EI_MAG0 = 0, /* File id */ + EI_MAG0 = 0, /* File id */ EI_MAG1 = 1, EI_MAG2 = 2, EI_MAG3 = 3, - EI_CLASS = 4, /* File class */ - EI_DATA = 5, /* Data encoding */ - EI_VERSION = 6, /* File version */ - EI_OSABI = 7, /* OS and ABI */ - EI_ABIVERSION = 8, /* version of ABI */ + EI_CLASS = 4, /* File class */ + EI_DATA = 5, /* Data encoding */ + EI_VERSION = 6, /* File version */ + EI_OSABI = 7, /* OS and ABI */ + EI_ABIVERSION = 8, /* version of ABI */ - EI_PAD = 9, /* Pad to end; start here */ - EI_NIDENT = 16 /* Sizeof e_ident[] */ + EI_PAD = 9, /* Pad to end; start here */ + EI_NIDENT = 16 /* Sizeof e_ident[] */ } elf_identification_index; typedef enum { - ELFOSABI_SYSV = 0, /* System V ABI */ - ELFOSABI_HPUX = 1, /* HP-UX os */ - ELFOSABI_STANDALONE = 255 /* Standalone / embedded app */ + ELFOSABI_SYSV = 0, /* System V ABI */ + ELFOSABI_HPUX = 1, /* HP-UX os */ + ELFOSABI_STANDALONE = 255 /* Standalone / embedded app */ } elf_osabi_index; typedef enum { - ELFCLASSNONE = 0, /* invalid */ - ELFCLASS32 = 1, /* 32-bit */ - ELFCLASS64 = 2 /* 64-bit */ + ELFCLASSNONE = 0, /* invalid */ + ELFCLASS32 = 1, /* 32-bit */ + ELFCLASS64 = 2 /* 64-bit */ } elf_class; typedef enum { @@ -126,79 +125,76 @@ typedef enum { /* elf section types - index of semantics */ typedef enum { - SHT_NULL = 0, /* inactive section - no associated data */ - SHT_PROGBITS = 1, /* defined by program for its own meaning */ - SHT_SYMTAB = 2, /* symbol table (primarily) for linking */ - SHT_STRTAB = 3, /* string table - symbols need names */ - SHT_RELA = 4, /* relocation entries w/ explicit addends */ - SHT_HASH = 5, /* symbol hash table - for dynamic linking */ - SHT_DYNAMIC = 6, /* information for dynamic linking */ - SHT_NOTE = 7, /* extra data marking the file somehow */ - SHT_NOBITS = 8, /* no stored data, but occupies runtime space */ - SHT_REL = 9, /* relocations entries w/o explicit addends */ - SHT_SHLIB = 10, /* reserved; unspecified semantics */ - SHT_DYNSYM = 11, /* like symtab, but more for dynamic linking */ + SHT_NULL = 0, /* inactive section - no associated data */ + SHT_PROGBITS = 1, /* defined by program for its own meaning */ + SHT_SYMTAB = 2, /* symbol table (primarily) for linking */ + SHT_STRTAB = 3, /* string table - symbols need names */ + SHT_RELA = 4, /* relocation entries w/ explicit addends */ + SHT_HASH = 5, /* symbol hash table - for dynamic linking */ + SHT_DYNAMIC = 6, /* information for dynamic linking */ + SHT_NOTE = 7, /* extra data marking the file somehow */ + SHT_NOBITS = 8, /* no stored data, but occupies runtime space */ + SHT_REL = 9, /* relocations entries w/o explicit addends */ + SHT_SHLIB = 10, /* reserved; unspecified semantics */ + SHT_DYNSYM = 11, /* like symtab, but more for dynamic linking */ - SHT_LOOS = 0x60000000, /* reserved for environment specific use */ + SHT_LOOS = 0x60000000, /* reserved for environment specific use */ SHT_HIOS = 0x6fffffff, - SHT_LOPROC = 0x70000000, /* reserved for processor specific semantics */ + SHT_LOPROC = 0x70000000, /* reserved for processor specific semantics */ SHT_HIPROC = 0x7fffffff/*, - SHT_LOUSER = 0x80000000,*/ /* reserved for applications; safe */ + SHT_LOUSER = 0x80000000,*/ /* reserved for applications; safe */ /*SHT_HIUSER = 0xffffffff*/ } elf_section_type; /* elf section flags - bitfield of attributes */ typedef enum { - SHF_WRITE = 0x1, /* data should be writable at runtime */ - SHF_ALLOC = 0x2, /* occupies memory at runtime */ - SHF_EXECINSTR = 0x4, /* contains machine instructions */ - SHF_MERGE = 0x10, /* data can be merged */ - SHF_STRINGS = 0x20, /* contains 0-terminated strings */ - SHF_GROUP = 0x200, /* member of a section group */ - SHF_TLS = 0x400, /* thread local storage */ + SHF_WRITE = 0x1, /* data should be writable at runtime */ + SHF_ALLOC = 0x2, /* occupies memory at runtime */ + SHF_EXECINSTR = 0x4, /* contains machine instructions */ + SHF_MERGE = 0x10, /* data can be merged */ + SHF_STRINGS = 0x20, /* contains 0-terminated strings */ + SHF_GROUP = 0x200, /* member of a section group */ + SHF_TLS = 0x400, /* thread local storage */ SHF_MASKOS = 0x0f000000/*,*//* environment specific use */ - /*SHF_MASKPROC = 0xf0000000*/ /* bits reserved for processor specific needs */ + /*SHF_MASKPROC = 0xf0000000*/ /* bits reserved for processor specific needs */ } elf_section_flags; /* elf section index - just the special ones */ typedef enum { - SHN_UNDEF = 0, /* undefined symbol; requires other global */ - SHN_LORESERVE = 0xff00, /* reserved for various semantics */ - SHN_LOPROC = 0xff00, /* reserved for processor specific semantics */ + SHN_UNDEF = 0, /* undefined symbol; requires other global */ + SHN_LORESERVE = 0xff00, /* reserved for various semantics */ + SHN_LOPROC = 0xff00, /* reserved for processor specific semantics */ SHN_HIPROC = 0xff1f, - SHN_LOOS = 0xff20, /* reserved for environment specific use */ + SHN_LOOS = 0xff20, /* reserved for environment specific use */ SHN_HIOS = 0xff3f, - SHN_ABS = 0xfff1, /* associated symbols don't change on reloc */ - SHN_COMMON = 0xfff2, /* associated symbols refer to unallocated */ + SHN_ABS = 0xfff1, /* associated symbols don't change on reloc */ + SHN_COMMON = 0xfff2, /* associated symbols refer to unallocated */ SHN_HIRESERVE = 0xffff } elf_section_index; /* elf symbol binding - index of visibility/behavior */ typedef enum { - STB_LOCAL = 0, /* invisible outside defining file */ - STB_GLOBAL = 1, /* visible to all combined object files */ - STB_WEAK = 2, /* global but lower precedence */ + STB_LOCAL = 0, /* invisible outside defining file */ + STB_GLOBAL = 1, /* visible to all combined object files */ + STB_WEAK = 2, /* global but lower precedence */ - STB_LOOS = 10, /* Environment specific use */ + STB_LOOS = 10, /* Environment specific use */ STB_HIOS = 12, - STB_LOPROC = 13, /* reserved for processor specific semantics */ + STB_LOPROC = 13, /* reserved for processor specific semantics */ STB_HIPROC = 15 } elf_symbol_binding; /* elf symbol type - index of classifications */ typedef enum { - STT_NOTYPE = 0, /* type not specified */ - STT_OBJECT = 1, /* data object such as a variable, array, etc */ - STT_FUNC = 2, /* a function or executable code */ - STT_SECTION = 3, /* a section: often for relocation, STB_LOCAL */ - STT_FILE = 4, /* often source filename: STB_LOCAL, SHN_ABS */ - STT_COMMON = 5, /* Uninitialized common block. */ - STT_TLS = 6, /* TLS object. */ - STT_NUM = 7, + STT_NOTYPE = 0, /* type not specified */ + STT_OBJECT = 1, /* data object such as a variable, array, etc */ + STT_FUNC = 2, /* a function or executable code */ + STT_SECTION = 3, /* a section: often for relocation, STB_LOCAL */ + STT_FILE = 4, /* often source filename: STB_LOCAL, SHN_ABS */ - STT_LOOS = 10, /* Environment specific use */ + STT_LOOS = 10, /* Environment specific use */ STT_HIOS = 12, - STT_LOPROC = 13, /* reserved for processor specific semantics */ + STT_LOPROC = 13, /* reserved for processor specific semantics */ STT_HIPROC = 15 } elf_symbol_type; @@ -208,25 +204,25 @@ typedef enum { /* elf symbol visibility - lower two bits of OTHER field */ typedef enum { - STV_DEFAULT = 0, /* Default symbol visibility rules */ - STV_INTERNAL = 1, /* Processor specific hidden class */ - STV_HIDDEN = 2, /* Sym unavailable in other modules */ - STV_PROTECTED = 3 /* Not preemptable, not exported */ + STV_DEFAULT = 0, /* Default symbol visibility rules */ + STV_INTERNAL = 1, /* Processor specific hidden class */ + STV_HIDDEN = 2, /* Sym unavailable in other modules */ + STV_PROTECTED = 3 /* Not preemptable, not exported */ } elf_symbol_vis; /* internal only object definitions */ #ifdef YASM_OBJFMT_ELF_INTERNAL -#define ELF_VISIBILITY_MASK 0x03 +#define ELF_VISIBILITY_MASK 0x03 #define ELF_ST_VISIBILITY(v) ((v) & ELF_VISIBILITY_MASK) -#define ELF32_ST_INFO(bind, type) (((bind) << 4) + ((type) & 0xf)) -#define ELF32_R_INFO(s,t) (((s)<<8)+(unsigned char)(t)) +#define ELF32_ST_INFO(bind, type) (((bind) << 4) + ((type) & 0xf)) +#define ELF32_R_INFO(s,t) (((s)<<8)+(unsigned char)(t)) #define ELF32_ST_OTHER(vis) ELF_ST_VISIBILITY(vis) -#define ELF64_ST_INFO(bind, type) (((bind) << 4) + ((type) & 0xf)) -#define ELF64_R_INFO(s,t) (((s)<<32) + ((t) & 0xffffffffL)) +#define ELF64_ST_INFO(bind, type) (((bind) << 4) + ((type) & 0xf)) +#define ELF64_R_INFO(s,t) (((s)<<32) + ((t) & 0xffffffffL)) #define ELF64_ST_OTHER(vis) ELF_ST_VISIBILITY(vis) #define EHDR32_SIZE 52 @@ -265,107 +261,93 @@ typedef enum { * S = Value of symbol */ typedef enum { - R_386_NONE = 0, /* none */ - R_386_32 = 1, /* word32, S + A */ - R_386_PC32 = 2, /* word32, S + A - P */ - R_386_GOT32 = 3, /* word32, G + A - P */ - R_386_PLT32 = 4, /* word32, L + A - P */ - R_386_COPY = 5, /* none */ - R_386_GLOB_DAT = 6, /* word32, S */ - R_386_JMP_SLOT = 7, /* word32, S */ - R_386_RELATIVE = 8, /* word32, B + A */ - R_386_GOTOFF = 9, /* word32, S + A - GOT */ - R_386_GOTPC = 10, /* word32, GOT + A - P */ - R_386_TLS_TPOFF = 14, /* Negative offset in static TLS block (GNU - version) */ - R_386_TLS_IE = 15, /* Absolute address of GOT entry for negative - static TLS block offset */ - R_386_TLS_GOTIE = 16, /* GOT entry for negative static TLS block - offset */ - R_386_TLS_LE = 17, /* Negative offset relative to static TLS - (GNU version) */ - R_386_TLS_GD = 18, /* Direct 32 bit for GNU version of GD TLS */ - R_386_TLS_LDM = 19, /* Direct 32 bit for GNU version of LD TLS - in LE code */ - R_386_16 = 20, /* word16, S + A (GNU extension) */ - R_386_PC16 = 21, /* word16, S + A - P (GNU extension) */ - R_386_8 = 22, /* word8, S + A (GNU extension) */ - R_386_PC8 = 23, /* word8, S + A - P (GNU extension) */ - R_386_TLS_GD_32 = 24, /* Direct 32 bit for GD TLS */ - R_386_TLS_GD_PUSH = 25, /* Tag for pushl in GD TLS code */ - R_386_TLS_GD_CALL = 26, /* Relocation for call to */ - R_386_TLS_GD_POP = 27, /* Tag for popl in GD TLS code */ - R_386_TLS_LDM_32 = 28, /* Direct 32 bit for local dynamic code */ - R_386_TLS_LDM_PUSH = 29, /* Tag for pushl in LDM TLS code */ - R_386_TLS_LDM_CALL = 30, /* Relocation for call to */ - R_386_TLS_LDM_POP = 31, /* Tag for popl in LDM TLS code */ - R_386_TLS_LDO_32 = 32, /* Offset relative to TLS block */ - R_386_TLS_IE_32 = 33, /* GOT entry for static TLS block */ - R_386_TLS_LE_32 = 34, /* Offset relative to static TLS block */ - R_386_TLS_DTPMOD32 = 35, /* ID of module containing symbol */ - R_386_TLS_DTPOFF32 = 36, /* Offset in TLS block */ - R_386_TLS_TPOFF32 = 37, /* Offset in static TLS block */ - R_386_TLS_GOTDESC = 39, - R_386_TLS_DESC_CALL = 40, - R_386_TLS_DESC = 41 + R_386_NONE = 0, /* none */ + R_386_32 = 1, /* word32, S + A */ + R_386_PC32 = 2, /* word32, S + A - P */ + R_386_GOT32 = 3, /* word32, G + A - P */ + R_386_PLT32 = 4, /* word32, L + A - P */ + R_386_COPY = 5, /* none */ + R_386_GLOB_DAT = 6, /* word32, S */ + R_386_JMP_SLOT = 7, /* word32, S */ + R_386_RELATIVE = 8, /* word32, B + A */ + R_386_GOTOFF = 9, /* word32, S + A - GOT */ + R_386_GOTPC = 10, /* word32, GOT + A - P */ + R_386_TLS_TPOFF = 14, /* Negative offset in static TLS block (GNU + version) */ + R_386_TLS_IE = 15, /* Absolute address of GOT entry for negative + static TLS block offset */ + R_386_TLS_GOTIE = 16, /* GOT entry for negative static TLS block + offset */ + R_386_TLS_LE = 17, /* Negative offset relative to static TLS + (GNU version) */ + R_386_TLS_GD = 18, /* Direct 32 bit for GNU version of GD TLS */ + R_386_TLS_LDM = 19, /* Direct 32 bit for GNU version of LD TLS + in LE code */ + R_386_16 = 20, /* word16, S + A (GNU extension) */ + R_386_PC16 = 21, /* word16, S + A - P (GNU extension) */ + R_386_8 = 22, /* word8, S + A (GNU extension) */ + R_386_PC8 = 23, /* word8, S + A - P (GNU extension) */ + R_386_TLS_GD_32 = 24, /* Direct 32 bit for GD TLS */ + R_386_TLS_GD_PUSH = 25, /* Tag for pushl in GD TLS code */ + R_386_TLS_GD_CALL = 26, /* Relocation for call to */ + R_386_TLS_GD_POP = 27, /* Tag for popl in GD TLS code */ + R_386_TLS_LDM_32 = 28, /* Direct 32 bit for local dynamic code */ + R_386_TLS_LDM_PUSH = 29, /* Tag for pushl in LDM TLS code */ + R_386_TLS_LDM_CALL = 30, /* Relocation for call to */ + R_386_TLS_LDM_POP = 31, /* Tag for popl in LDM TLS code */ + R_386_TLS_LDO_32 = 32, /* Offset relative to TLS block */ + R_386_TLS_IE_32 = 33, /* GOT entry for static TLS block */ + R_386_TLS_LE_32 = 34, /* Offset relative to static TLS block */ + R_386_TLS_DTPMOD32 = 35, /* ID of module containing symbol */ + R_386_TLS_DTPOFF32 = 36, /* Offset in TLS block */ + R_386_TLS_TPOFF32 = 37 /* Offset in static TLS block */ } elf_386_relocation_type; typedef enum { - R_X86_64_NONE = 0, /* none */ - R_X86_64_64 = 1, /* word64, S + A */ - R_X86_64_PC32 = 2, /* word32, S + A - P */ - R_X86_64_GOT32 = 3, /* word32, G + A */ - R_X86_64_PLT32 = 4, /* word32, L + A - P */ - R_X86_64_COPY = 5, /* none */ - R_X86_64_GLOB_DAT = 6, /* word64, S, set GOT entry to data address */ - R_X86_64_JMP_SLOT = 7, /* word64, S, set GOT entry to code address */ - R_X86_64_RELATIVE = 8, /* word64, B + A */ - R_X86_64_GOTPCREL = 9, /* word32, G + GOT + A - P */ - R_X86_64_32 = 10, /* word32 (zero extend), S + A */ - R_X86_64_32S = 11, /* word32 (sign extend), S + A */ - R_X86_64_16 = 12, /* word16, S + A */ - R_X86_64_PC16 = 13, /* word16, S + A - P */ - R_X86_64_8 = 14, /* word8, S + A */ - R_X86_64_PC8 = 15, /* word8, S + A - P */ - R_X86_64_DPTMOD64 = 16, /* word64, ID of module containing symbol */ - R_X86_64_DTPOFF64 = 17, /* word64, offset in TLS block */ - R_X86_64_TPOFF64 = 18, /* word64, offset in initial TLS block */ - R_X86_64_TLSGD = 19, /* word32, PC-rel offset to GD GOT block */ - R_X86_64_TLSLD = 20, /* word32, PC-rel offset to LD GOT block */ - R_X86_64_DTPOFF32 = 21, /* word32, offset to TLS block */ - R_X86_64_GOTTPOFF = 22, /* word32, PC-rel offset to IE GOT entry */ - R_X86_64_TPOFF32 = 23, /* word32, offset in initial TLS block */ - R_X86_64_PC64 = 24, /* word64, PC relative */ - R_X86_64_GOTOFF64 = 25, /* word64, offset to GOT */ - R_X86_64_GOTPC32 = 26, /* word32, signed pc relative to GOT */ - R_X86_64_GOT64 = 27, /* word64, GOT entry offset */ - R_X86_64_GOTPCREL64 = 28, /* word64, signed pc relative to GOT entry */ - R_X86_64_GOTPC64 = 29, /* word64, signed pc relative to GOT */ - R_X86_64_GOTPLT64 = 30, /* like GOT64, but indicates PLT entry needed */ - R_X86_64_PLTOFF64 = 31, /* word64, GOT relative offset to PLT entry */ - R_X86_64_GOTPC32_TLSDESC = 34, /* GOT offset for TLS descriptor */ - R_X86_64_TLSDESC_CALL = 35, /* Marker for call through TLS descriptor */ - R_X86_64_TLSDESC = 36 /* TLS descriptor */ + R_X86_64_NONE = 0, /* none */ + R_X86_64_64 = 1, /* word64, S + A */ + R_X86_64_PC32 = 2, /* word32, S + A - P */ + R_X86_64_GOT32 = 3, /* word32, G + A */ + R_X86_64_PLT32 = 4, /* word32, L + A - P */ + R_X86_64_COPY = 5, /* none */ + R_X86_64_GLOB_DAT = 6, /* word64, S, set GOT entry to data address */ + R_X86_64_JMP_SLOT = 7, /* word64, S, set GOT entry to code address */ + R_X86_64_RELATIVE = 8, /* word64, B + A */ + R_X86_64_GOTPCREL = 9, /* word32, G + GOT + A - P */ + R_X86_64_32 = 10, /* word32 (zero extend), S + A */ + R_X86_64_32S = 11, /* word32 (sign extend), S + A */ + R_X86_64_16 = 12, /* word16, S + A */ + R_X86_64_PC16 = 13, /* word16, S + A - P */ + R_X86_64_8 = 14, /* word8, S + A */ + R_X86_64_PC8 = 15, /* word8, S + A - P */ + R_X86_64_DPTMOD64 = 16, /* word64, ID of module containing symbol */ + R_X86_64_DTPOFF64 = 17, /* word64, offset in TLS block */ + R_X86_64_TPOFF64 = 18, /* word64, offset in initial TLS block */ + R_X86_64_TLSGD = 19, /* word32, PC-rel offset to GD GOT block */ + R_X86_64_TLSLD = 20, /* word32, PC-rel offset to LD GOT block */ + R_X86_64_DTPOFF32 = 21, /* word32, offset to TLS block */ + R_X86_64_GOTTPOFF = 22, /* word32, PC-rel offset to IE GOT entry */ + R_X86_64_TPOFF32 = 23 /* word32, offset in initial TLS block */ } elf_x86_64_relocation_type; struct elf_secthead { - elf_section_type type; - elf_section_flags flags; - elf_address offset; - yasm_intnum *size; - elf_section_index link; - elf_section_info info; /* see note ESD1 */ - unsigned long align; - elf_size entsize; + elf_section_type type; + elf_section_flags flags; + elf_address offset; + yasm_intnum *size; + elf_section_index link; + elf_section_info info; /* see note ESD1 */ + unsigned long align; + elf_size entsize; - yasm_symrec *sym; - elf_strtab_entry *name; - elf_section_index index; + yasm_symrec *sym; + elf_strtab_entry *name; + elf_section_index index; - elf_strtab_entry *rel_name; - elf_section_index rel_index; - elf_address rel_offset; - unsigned long nreloc; + elf_strtab_entry *rel_name; + elf_section_index rel_index; + elf_address rel_offset; + unsigned long nreloc; }; /* Note ESD1: @@ -387,60 +369,54 @@ struct elf_secthead { */ struct elf_reloc_entry { - yasm_reloc reloc; - int rtype_rel; - size_t valsize; + yasm_reloc reloc; + int rtype_rel; + size_t valsize; yasm_intnum *addend; /*@null@*/ yasm_symrec *wrt; - int is_GOT_sym; }; STAILQ_HEAD(elf_strtab_head, elf_strtab_entry); struct elf_strtab_entry { STAILQ_ENTRY(elf_strtab_entry) qlink; - unsigned long index; - char *str; + unsigned long index; + char *str; }; STAILQ_HEAD(elf_symtab_head, elf_symtab_entry); struct elf_symtab_entry { STAILQ_ENTRY(elf_symtab_entry) qlink; - int in_table; - yasm_symrec *sym; - yasm_section *sect; - elf_strtab_entry *name; - elf_address value; + int in_table; + yasm_symrec *sym; + yasm_section *sect; + elf_strtab_entry *name; + elf_address value; /*@dependent@*/ yasm_expr *xsize; - elf_size size; - elf_section_index index; - elf_symbol_binding bind; - elf_symbol_type type; + elf_size size; + elf_section_index index; + elf_symbol_binding bind; + elf_symbol_type type; elf_symbol_vis vis; - elf_symbol_index symindex; + elf_symbol_index symindex; }; #endif /* defined(YASM_OBJFMT_ELF_INTERNAL) */ extern const yasm_assoc_data_callback elf_section_data; extern const yasm_assoc_data_callback elf_symrec_data; -extern const yasm_assoc_data_callback elf_ssym_symrec_data; const elf_machine_handler *elf_set_arch(struct yasm_arch *arch, - yasm_symtab *symtab, - int bits_pref); - -yasm_symrec *elf_get_special_sym(const char *name, const char *parser); + yasm_symtab *symtab, + int bits_pref); /* reloc functions */ int elf_is_wrt_sym_relative(yasm_symrec *wrt); -int elf_is_wrt_pos_adjusted(yasm_symrec *wrt); elf_reloc_entry *elf_reloc_entry_create(yasm_symrec *sym, - /*@null@*/ yasm_symrec *wrt, - yasm_intnum *addr, - int rel, - size_t valsize, - int is_GOT_sym); + /*@null@*/ yasm_symrec *wrt, + yasm_intnum *addr, + int rel, + size_t valsize); void elf_reloc_entry_destroy(void *entry); /* strtab functions */ @@ -453,22 +429,22 @@ unsigned long elf_strtab_output_to_file(FILE *f, elf_strtab_head *head); /* symtab functions */ elf_symtab_entry *elf_symtab_entry_create(elf_strtab_entry *name, - struct yasm_symrec *sym); + struct yasm_symrec *sym); elf_symtab_head *elf_symtab_create(void); void elf_symtab_append_entry(elf_symtab_head *symtab, elf_symtab_entry *entry); void elf_symtab_insert_local_sym(elf_symtab_head *symtab, - elf_symtab_entry *entry); + elf_symtab_entry *entry); void elf_symtab_destroy(elf_symtab_head *head); unsigned long elf_symtab_assign_indices(elf_symtab_head *symtab); unsigned long elf_symtab_write_to_file(FILE *f, elf_symtab_head *symtab, - yasm_errwarns *errwarns); -void elf_symtab_set_nonzero(elf_symtab_entry *entry, - struct yasm_section *sect, - elf_section_index sectidx, - elf_symbol_binding bind, - elf_symbol_type type, - struct yasm_expr *size, - elf_address *value); + yasm_errwarns *errwarns); +void elf_symtab_set_nonzero(elf_symtab_entry *entry, + struct yasm_section *sect, + elf_section_index sectidx, + elf_symbol_binding bind, + elf_symbol_type type, + struct yasm_expr *size, + elf_address *value); void elf_sym_set_visibility(elf_symtab_entry *entry, elf_symbol_vis vis); void elf_sym_set_type(elf_symtab_entry *entry, elf_symbol_type type); @@ -476,49 +452,47 @@ void elf_sym_set_size(elf_symtab_entry *entry, struct yasm_expr *size); int elf_sym_in_table(elf_symtab_entry *entry); /* section header functions */ -elf_secthead *elf_secthead_create(elf_strtab_entry *name, - elf_section_type type, - elf_section_flags flags, - elf_address offset, - elf_size size); +elf_secthead *elf_secthead_create(elf_strtab_entry *name, + elf_section_type type, + elf_section_flags flags, + elf_address offset, + elf_size size); void elf_secthead_destroy(elf_secthead *esd); unsigned long elf_secthead_write_to_file(FILE *f, elf_secthead *esd, - elf_section_index sindex); + elf_section_index sindex); void elf_secthead_append_reloc(yasm_section *sect, elf_secthead *shead, - elf_reloc_entry *reloc); + elf_reloc_entry *reloc); elf_section_type elf_secthead_get_type(elf_secthead *shead); void elf_secthead_set_typeflags(elf_secthead *shead, elf_section_type type, - elf_section_flags flags); + elf_section_flags flags); int elf_secthead_is_empty(elf_secthead *shead); struct yasm_symrec *elf_secthead_get_sym(elf_secthead *shead); unsigned long elf_secthead_get_align(const elf_secthead *shead); unsigned long elf_secthead_set_align(elf_secthead *shead, unsigned long align); elf_section_index elf_secthead_get_index(elf_secthead *shead); elf_section_info elf_secthead_set_info(elf_secthead *shead, - elf_section_info info); + elf_section_info info); elf_section_index elf_secthead_set_index(elf_secthead *shead, - elf_section_index sectidx); + elf_section_index sectidx); elf_section_index elf_secthead_set_link(elf_secthead *shead, - elf_section_index link); + elf_section_index link); elf_section_index elf_secthead_set_rel_index(elf_secthead *shead, - elf_section_index sectidx); + elf_section_index sectidx); elf_strtab_entry *elf_secthead_set_rel_name(elf_secthead *shead, - elf_strtab_entry *entry); + elf_strtab_entry *entry); elf_size elf_secthead_set_entsize(elf_secthead *shead, elf_size size); struct yasm_symrec *elf_secthead_set_sym(elf_secthead *shead, - struct yasm_symrec *sym); + struct yasm_symrec *sym); void elf_secthead_add_size(elf_secthead *shead, yasm_intnum *size); char *elf_secthead_name_reloc_section(const char *basesect); -void elf_handle_reloc_addend(yasm_intnum *intn, - elf_reloc_entry *reloc, - unsigned long offset); +void elf_handle_reloc_addend(yasm_intnum *intn, elf_reloc_entry *reloc); unsigned long elf_secthead_write_rel_to_file(FILE *f, elf_section_index symtab, - yasm_section *sect, - elf_secthead *esd, - elf_section_index sindex); + yasm_section *sect, + elf_secthead *esd, + elf_section_index sindex); unsigned long elf_secthead_write_relocs_to_file(FILE *f, yasm_section *sect, - elf_secthead *shead, - yasm_errwarns *errwarns); + elf_secthead *shead, + yasm_errwarns *errwarns); long elf_secthead_set_file_offset(elf_secthead *shead, long pos); /* program header function */ @@ -526,8 +500,8 @@ unsigned long elf_proghead_get_size(void); unsigned long elf_proghead_write_to_file(FILE *f, - elf_offset secthead_addr, - unsigned long secthead_count, - elf_section_index shstrtab_index); + elf_offset secthead_addr, + unsigned long secthead_count, + elf_section_index shstrtab_index); #endif /* ELF_H_INCLUDED */ diff --git a/modules/objfmts/elf/tests/Makefile.inc b/modules/objfmts/elf/tests/Makefile.inc index 0980329c..bf112037 100644 --- a/modules/objfmts/elf/tests/Makefile.inc +++ b/modules/objfmts/elf/tests/Makefile.inc @@ -1,3 +1,5 @@ +# $Id$ + TESTS += modules/objfmts/elf/tests/elf_test.sh EXTRA_DIST += modules/objfmts/elf/tests/elf_test.sh @@ -47,13 +49,7 @@ EXTRA_DIST += modules/objfmts/elf/tests/nasm-forceident.asm EXTRA_DIST += modules/objfmts/elf/tests/nasm-forceident.hex EXTRA_DIST += modules/objfmts/elf/tests/amd64/Makefile.inc -EXTRA_DIST += modules/objfmts/elf/tests/x32/Makefile.inc -EXTRA_DIST += modules/objfmts/elf/tests/gas32/Makefile.inc EXTRA_DIST += modules/objfmts/elf/tests/gas64/Makefile.inc -EXTRA_DIST += modules/objfmts/elf/tests/gasx32/Makefile.inc include modules/objfmts/elf/tests/amd64/Makefile.inc -include modules/objfmts/elf/tests/x32/Makefile.inc -include modules/objfmts/elf/tests/gas32/Makefile.inc include modules/objfmts/elf/tests/gas64/Makefile.inc -include modules/objfmts/elf/tests/gasx32/Makefile.inc diff --git a/modules/objfmts/elf/tests/amd64/Makefile.inc b/modules/objfmts/elf/tests/amd64/Makefile.inc index deb54bc0..d0695926 100644 --- a/modules/objfmts/elf/tests/amd64/Makefile.inc +++ b/modules/objfmts/elf/tests/amd64/Makefile.inc @@ -1,3 +1,5 @@ +# $Id$ + TESTS += modules/objfmts/elf/tests/amd64/elf_amd64_test.sh EXTRA_DIST += modules/objfmts/elf/tests/amd64/elf_amd64_test.sh @@ -5,7 +7,3 @@ EXTRA_DIST += modules/objfmts/elf/tests/amd64/elf-rip.asm EXTRA_DIST += modules/objfmts/elf/tests/amd64/elf-rip.hex EXTRA_DIST += modules/objfmts/elf/tests/amd64/elfso64.asm EXTRA_DIST += modules/objfmts/elf/tests/amd64/elfso64.hex -EXTRA_DIST += modules/objfmts/elf/tests/amd64/gotpcrel.asm -EXTRA_DIST += modules/objfmts/elf/tests/amd64/gotpcrel.hex -EXTRA_DIST += modules/objfmts/elf/tests/amd64/multiplefixup.asm -EXTRA_DIST += modules/objfmts/elf/tests/amd64/multiplefixup.hex diff --git a/modules/objfmts/elf/tests/amd64/elf_amd64_test.sh b/modules/objfmts/elf/tests/amd64/elf_amd64_test.sh index 1f48a32a..239443da 100755 --- a/modules/objfmts/elf/tests/amd64/elf_amd64_test.sh +++ b/modules/objfmts/elf/tests/amd64/elf_amd64_test.sh @@ -1,3 +1,4 @@ #! /bin/sh +# $Id$ ${srcdir}/out_test.sh elf_amd64_test modules/objfmts/elf/tests/amd64 "elf-amd64 objfmt" "-m amd64 -f elf" ".o" exit $? diff --git a/modules/objfmts/elf/tests/amd64/elfso64.asm b/modules/objfmts/elf/tests/amd64/elfso64.asm index 931c7ffe..39dbf2ea 100644 --- a/modules/objfmts/elf/tests/amd64/elfso64.asm +++ b/modules/objfmts/elf/tests/amd64/elfso64.asm @@ -21,18 +21,18 @@ ; [16] Reference a data-section symbol in the data section ; [17] Reference a BSS-section symbol in the data section - [BITS 64] - [GLOBAL lrotate:function] ; [1] - [GLOBAL greet:function] ; [1] - [GLOBAL asmstr:data asmstr.end-asmstr] ; [2] - [GLOBAL textptr:data 4] ; [2] - [GLOBAL selfptr:data 4] ; [2] - [GLOBAL integer:data 4] ; [3] - [EXTERN printf] ; [10] - [COMMON commvar 4:4] ; [7] - [EXTERN _GLOBAL_OFFSET_TABLE_] + BITS 64 + GLOBAL lrotate:function ; [1] + GLOBAL greet:function ; [1] + GLOBAL asmstr:data asmstr.end-asmstr ; [2] + GLOBAL textptr:data 4 ; [2] + GLOBAL selfptr:data 4 ; [2] + GLOBAL integer:data 4 ; [3] + EXTERN printf ; [10] + COMMON commvar 4:4 ; [7] + EXTERN _GLOBAL_OFFSET_TABLE_ - [SECTION .text] + SECTION .text ; prototype: long lrotate(long x, int num); lrotate: ; [1] @@ -66,7 +66,7 @@ greet push rbx ; we'll use RBX for GOT, so save it pop rbx ret - [SECTION .data] + SECTION .data ; a string asmstr db 'hello, world', 0 ; [2] @@ -81,7 +81,7 @@ localptr dd localint ; [5] [17] textptr dd greet wrt ..sym ; [15] selfptr dd selfptr wrt ..sym ; [16] - [SECTION .bss] + SECTION .bss ; an integer integer resd 1 ; [3] diff --git a/modules/objfmts/elf/tests/amd64/gotpcrel.asm b/modules/objfmts/elf/tests/amd64/gotpcrel.asm deleted file mode 100644 index c3d12383..00000000 --- a/modules/objfmts/elf/tests/amd64/gotpcrel.asm +++ /dev/null @@ -1,6 +0,0 @@ -var: -mov rax, [var wrt ..got] -mov rax, [var wrt ..gotpcrel] ; should be error/warning? -mov rax, [rel var wrt ..got] ; automatic promotion to GOTPCREL -mov rax, [rel var wrt ..gotpcrel] - diff --git a/modules/objfmts/elf/tests/amd64/gotpcrel.hex b/modules/objfmts/elf/tests/amd64/gotpcrel.hex deleted file mode 100644 index 1ad94244..00000000 --- a/modules/objfmts/elf/tests/amd64/gotpcrel.hex +++ /dev/null @@ -1,720 +0,0 @@ -7f -45 -4c -46 -02 -01 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -01 -00 -3e -00 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -50 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -40 -00 -00 -00 -00 -00 -40 -00 -06 -00 -01 -00 -48 -8b -04 -25 -00 -00 -00 -00 -48 -8b -04 -25 -00 -00 -00 -00 -48 -8b -05 -00 -00 -00 -00 -48 -8b -05 -00 -00 -00 -00 -00 -00 -04 -00 -00 -00 -00 -00 -00 -00 -03 -00 -00 -00 -02 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -0c -00 -00 -00 -00 -00 -00 -00 -09 -00 -00 -00 -02 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -13 -00 -00 -00 -00 -00 -00 -00 -09 -00 -00 -00 -02 -00 -00 -00 -fc -ff -ff -ff -ff -ff -ff -ff -1a -00 -00 -00 -00 -00 -00 -00 -09 -00 -00 -00 -02 -00 -00 -00 -fc -ff -ff -ff -ff -ff -ff -ff -00 -2e -74 -65 -78 -74 -00 -2e -72 -65 -6c -61 -2e -74 -65 -78 -74 -00 -2e -73 -74 -72 -74 -61 -62 -00 -2e -73 -79 -6d -74 -61 -62 -00 -2e -73 -68 -73 -74 -72 -74 -61 -62 -00 -00 -2d -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -01 -00 -00 -00 -04 -00 -f1 -ff -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -04 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -03 -00 -04 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -22 -00 -00 -00 -03 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -c0 -00 -00 -00 -00 -00 -00 -00 -2c -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -12 -00 -00 -00 -03 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -ec -00 -00 -00 -00 -00 -00 -00 -03 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -1a -00 -00 -00 -02 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -f0 -00 -00 -00 -00 -00 -00 -00 -60 -00 -00 -00 -00 -00 -00 -00 -02 -00 -00 -00 -04 -00 -00 -00 -08 -00 -00 -00 -00 -00 -00 -00 -18 -00 -00 -00 -00 -00 -00 -00 -01 -00 -00 -00 -01 -00 -00 -00 -06 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -40 -00 -00 -00 -00 -00 -00 -00 -1e -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -10 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -07 -00 -00 -00 -04 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -60 -00 -00 -00 -00 -00 -00 -00 -60 -00 -00 -00 -00 -00 -00 -00 -03 -00 -00 -00 -04 -00 -00 -00 -08 -00 -00 -00 -00 -00 -00 -00 -18 -00 -00 -00 -00 -00 -00 -00 diff --git a/modules/objfmts/elf/tests/amd64/multiplefixup.asm b/modules/objfmts/elf/tests/amd64/multiplefixup.asm deleted file mode 100644 index ec253cbb..00000000 --- a/modules/objfmts/elf/tests/amd64/multiplefixup.asm +++ /dev/null @@ -1,8 +0,0 @@ -[section .data] -foobar: - dq 42 -[section .text] -foo: - times 4 mov rax, [rel foobar] - times 4 mov rax, [foobar] - times 4 jmp foo diff --git a/modules/objfmts/elf/tests/amd64/multiplefixup.hex b/modules/objfmts/elf/tests/amd64/multiplefixup.hex deleted file mode 100644 index 16565ff5..00000000 --- a/modules/objfmts/elf/tests/amd64/multiplefixup.hex +++ /dev/null @@ -1,992 +0,0 @@ -7f -45 -4c -46 -02 -01 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -01 -00 -3e -00 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -20 -02 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -40 -00 -00 -00 -00 -00 -40 -00 -07 -00 -01 -00 -48 -8b -05 -00 -00 -00 -00 -48 -8b -05 -00 -00 -00 -00 -48 -8b -05 -00 -00 -00 -00 -48 -8b -05 -00 -00 -00 -00 -48 -8b -04 -25 -00 -00 -00 -00 -48 -8b -04 -25 -00 -00 -00 -00 -48 -8b -04 -25 -00 -00 -00 -00 -48 -8b -04 -25 -00 -00 -00 -00 -eb -c2 -eb -c0 -eb -be -eb -bc -03 -00 -00 -00 -00 -00 -00 -00 -02 -00 -00 -00 -04 -00 -00 -00 -fc -ff -ff -ff -ff -ff -ff -ff -0a -00 -00 -00 -00 -00 -00 -00 -02 -00 -00 -00 -04 -00 -00 -00 -fc -ff -ff -ff -ff -ff -ff -ff -11 -00 -00 -00 -00 -00 -00 -00 -02 -00 -00 -00 -04 -00 -00 -00 -fc -ff -ff -ff -ff -ff -ff -ff -18 -00 -00 -00 -00 -00 -00 -00 -02 -00 -00 -00 -04 -00 -00 -00 -fc -ff -ff -ff -ff -ff -ff -ff -20 -00 -00 -00 -00 -00 -00 -00 -0a -00 -00 -00 -04 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -28 -00 -00 -00 -00 -00 -00 -00 -0a -00 -00 -00 -04 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -30 -00 -00 -00 -00 -00 -00 -00 -0a -00 -00 -00 -04 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -38 -00 -00 -00 -00 -00 -00 -00 -0a -00 -00 -00 -04 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -2a -00 -00 -00 -00 -00 -00 -00 -00 -2e -74 -65 -78 -74 -00 -2e -64 -61 -74 -61 -00 -2e -72 -65 -6c -61 -2e -74 -65 -78 -74 -00 -2e -73 -74 -72 -74 -61 -62 -00 -2e -73 -79 -6d -74 -61 -62 -00 -2e -73 -68 -73 -74 -72 -74 -61 -62 -00 -00 -00 -00 -2d -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -01 -00 -00 -00 -04 -00 -f1 -ff -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -04 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -06 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -03 -00 -06 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -03 -00 -04 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -28 -00 -00 -00 -03 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -4c -01 -00 -00 -00 -00 -00 -00 -32 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -18 -00 -00 -00 -03 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -80 -01 -00 -00 -00 -00 -00 -00 -03 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -20 -00 -00 -00 -02 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -84 -01 -00 -00 -00 -00 -00 -00 -90 -00 -00 -00 -00 -00 -00 -00 -02 -00 -00 -00 -06 -00 -00 -00 -08 -00 -00 -00 -00 -00 -00 -00 -18 -00 -00 -00 -00 -00 -00 -00 -01 -00 -00 -00 -01 -00 -00 -00 -06 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -40 -00 -00 -00 -00 -00 -00 -00 -44 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -10 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -0d -00 -00 -00 -04 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -84 -00 -00 -00 -00 -00 -00 -00 -c0 -00 -00 -00 -00 -00 -00 -00 -03 -00 -00 -00 -04 -00 -00 -00 -08 -00 -00 -00 -00 -00 -00 -00 -18 -00 -00 -00 -00 -00 -00 -00 -07 -00 -00 -00 -01 -00 -00 -00 -03 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -44 -01 -00 -00 -00 -00 -00 -00 -08 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -04 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 diff --git a/modules/objfmts/elf/tests/curpos-err.errwarn b/modules/objfmts/elf/tests/curpos-err.errwarn index efe6b093..fb6f65d7 100644 --- a/modules/objfmts/elf/tests/curpos-err.errwarn +++ b/modules/objfmts/elf/tests/curpos-err.errwarn @@ -1,2 +1,2 @@ --:15: error: data expression too complex --:21: error: data expression too complex +-:15: data expression too complex +-:21: data expression too complex diff --git a/modules/objfmts/elf/tests/elf-x86id.asm b/modules/objfmts/elf/tests/elf-x86id.asm index 04b4a039..e083fdd5 100644 --- a/modules/objfmts/elf/tests/elf-x86id.asm +++ b/modules/objfmts/elf/tests/elf-x86id.asm @@ -5,37 +5,37 @@ ;#APP ;.ident "$Id$" ;#NO_APP -[extern yasm_internal_error_] -[extern yasm_expr_copy] -[extern yasm_expr_expr] -[extern yasm_expr_new] -[extern yasm_symrec_define_label] -[extern yasm_x86_LTX_mode_bits] -[extern yasm_x86__bc_new_jmp] -[extern yasm_ea_get_disp] -[extern yasm_expr__contains] -[extern yasm_x86__get_reg_size] -[extern yasm__error] -[extern yasm_intnum_new_uint] -[extern yasm_expr_int] -[extern yasm_ea_delete] -[extern yasm_expr_delete] -[extern yasm_x86__ea_new_reg] -[extern yasm_x86__ea_set_disponly] -[extern yasm_x86__ea_new_imm] -[extern yasm_x86__set_rex_from_reg] -[extern yasm_xfree] -[extern yasm_x86__bc_new_insn] -[extern yasm__warning] +extern yasm_internal_error_ +extern yasm_expr_copy +extern yasm_expr_expr +extern yasm_expr_new +extern yasm_symrec_define_label +extern yasm_x86_LTX_mode_bits +extern yasm_x86__bc_new_jmp +extern yasm_ea_get_disp +extern yasm_expr__contains +extern yasm_x86__get_reg_size +extern yasm__error +extern yasm_intnum_new_uint +extern yasm_expr_int +extern yasm_ea_delete +extern yasm_expr_delete +extern yasm_x86__ea_new_reg +extern yasm_x86__ea_set_disponly +extern yasm_x86__ea_new_imm +extern yasm_x86__set_rex_from_reg +extern yasm_xfree +extern yasm_x86__bc_new_insn +extern yasm__warning - [section .data] - [align 4] + section .data + align 4 ;.type cpu_enabled,@object ;.size cpu_enabled,4 cpu_enabled: dd -1 - [section .rodata] - [align 4] + section .rodata + align 4 ;.type not64_insn,@object ;.size not64_insn,28 not64_insn: @@ -52,7 +52,7 @@ not64_insn: dd 0 dd 0 dd 0 - [align 4] + align 4 ;.type onebyte_insn,@object ;.size onebyte_insn,28 onebyte_insn: @@ -69,7 +69,7 @@ onebyte_insn: dd 0 dd 0 dd 0 - [align 4] + align 4 ;.type twobyte_insn,@object ;.size twobyte_insn,28 twobyte_insn: @@ -86,7 +86,7 @@ twobyte_insn: dd 0 dd 0 dd 0 - [align 4] + align 4 ;.type threebyte_insn,@object ;.size threebyte_insn,28 threebyte_insn: @@ -103,7 +103,7 @@ threebyte_insn: dd 0 dd 0 dd 0 - [align 4] + align 4 ;.type onebytemem_insn,@object ;.size onebytemem_insn,28 onebytemem_insn: @@ -120,7 +120,7 @@ onebytemem_insn: dd 4098 dd 0 dd 0 - [align 4] + align 4 ;.type twobytemem_insn,@object ;.size twobytemem_insn,28 twobytemem_insn: @@ -137,7 +137,7 @@ twobytemem_insn: dd 4098 dd 0 dd 0 - [align 32] + align 32 ;.type mov_insn,@object ;.size mov_insn,1260 mov_insn: @@ -726,7 +726,7 @@ mov_insn: dd 4225 dd 16488 dd 0 - [align 32] + align 32 ;.type movszx_insn,@object ;.size movszx_insn,140 movszx_insn: @@ -795,7 +795,7 @@ movszx_insn: dd 16513 dd 4163 dd 0 - [align 4] + align 4 ;.type movsxd_insn,@object ;.size movsxd_insn,28 movsxd_insn: @@ -812,7 +812,7 @@ movsxd_insn: dd 16513 dd 4195 dd 0 - [align 32] + align 32 ;.type push_insn,@object ;.size push_insn,784 push_insn: @@ -1180,7 +1180,7 @@ push_insn: dd 114 dd 0 dd 0 - [align 32] + align 32 ;.type pop_insn,@object ;.size pop_insn,588 pop_insn: @@ -1457,7 +1457,7 @@ pop_insn: dd 114 dd 0 dd 0 - [align 32] + align 32 ;.type xchg_insn,@object ;.size xchg_insn,392 xchg_insn: @@ -1643,7 +1643,7 @@ xchg_insn: dd 16513 dd 4483 dd 0 - [align 32] + align 32 ;.type in_insn,@object ;.size in_insn,168 in_insn: @@ -1725,7 +1725,7 @@ in_insn: dd 107 dd 77 dd 0 - [align 32] + align 32 ;.type out_insn,@object ;.size out_insn,168 out_insn: @@ -1807,7 +1807,7 @@ out_insn: dd 77 dd 107 dd 0 - [align 32] + align 32 ;.type lea_insn,@object ;.size lea_insn,84 lea_insn: @@ -1850,7 +1850,7 @@ lea_insn: dd 16513 dd 4482 dd 0 - [align 32] + align 32 ;.type ldes_insn,@object ;.size ldes_insn,56 ldes_insn: @@ -1880,7 +1880,7 @@ ldes_insn: dd 16481 dd 4098 dd 0 - [align 32] + align 32 ;.type lfgss_insn,@object ;.size lfgss_insn,56 lfgss_insn: @@ -1910,7 +1910,7 @@ lfgss_insn: dd 16481 dd 4098 dd 0 - [align 32] + align 32 ;.type arith_insn,@object ;.size arith_insn,644 arith_insn: @@ -2213,7 +2213,7 @@ arith_insn: dd 16513 dd 4483 dd 0 - [align 32] + align 32 ;.type incdec_insn,@object ;.size incdec_insn,168 incdec_insn: @@ -2295,7 +2295,7 @@ incdec_insn: dd 4227 dd 0 dd 0 - [align 32] + align 32 ;.type f6_insn,@object ;.size f6_insn,112 f6_insn: @@ -2351,7 +2351,7 @@ f6_insn: dd 4227 dd 0 dd 0 - [align 32] + align 32 ;.type test_insn,@object ;.size test_insn,560 test_insn: @@ -2615,7 +2615,7 @@ test_insn: dd 16513 dd 4483 dd 0 - [align 32] + align 32 ;.type aadm_insn,@object ;.size aadm_insn,56 aadm_insn: @@ -2645,7 +2645,7 @@ aadm_insn: dd 8480 dd 0 dd 0 - [align 32] + align 32 ;.type imul_insn,@object ;.size imul_insn,532 imul_insn: @@ -2896,7 +2896,7 @@ imul_insn: dd 28801 dd 143712 dd 0 - [align 32] + align 32 ;.type shift_insn,@object ;.size shift_insn,224 shift_insn: @@ -3004,7 +3004,7 @@ shift_insn: dd 4227 dd 74016 dd 0 - [align 32] + align 32 ;.type shlrd_insn,@object ;.size shlrd_insn,168 shlrd_insn: @@ -3086,7 +3086,7 @@ shlrd_insn: dd 4483 dd 16513 dd 44 - [align 32] + align 32 ;.type call_insn,@object ;.size call_insn,560 call_insn: @@ -3350,7 +3350,7 @@ call_insn: dd 5634 dd 0 dd 0 - [align 32] + align 32 ;.type jmp_insn,@object ;.size jmp_insn,588 jmp_insn: @@ -3627,7 +3627,7 @@ jmp_insn: dd 5634 dd 0 dd 0 - [align 32] + align 32 ;.type retnf_insn,@object ;.size retnf_insn,56 retnf_insn: @@ -3657,7 +3657,7 @@ retnf_insn: dd 8512 dd 0 dd 0 - [align 4] + align 4 ;.type enter_insn,@object ;.size enter_insn,28 enter_insn: @@ -3674,7 +3674,7 @@ enter_insn: dd 4416 dd 8480 dd 0 - [align 32] + align 32 ;.type jcc_insn,@object ;.size jcc_insn,196 jcc_insn: @@ -3769,7 +3769,7 @@ jcc_insn: dd 33280 dd 0 dd 0 - [align 32] + align 32 ;.type jcxz_insn,@object ;.size jcxz_insn,56 jcxz_insn: @@ -3799,7 +3799,7 @@ jcxz_insn: dd 33792 dd 0 dd 0 - [align 32] + align 32 ;.type loop_insn,@object ;.size loop_insn,224 loop_insn: @@ -3907,7 +3907,7 @@ loop_insn: dd 33792 dd 37004 dd 0 - [align 4] + align 4 ;.type setcc_insn,@object ;.size setcc_insn,28 setcc_insn: @@ -3924,7 +3924,7 @@ setcc_insn: dd 4387 dd 0 dd 0 - [align 32] + align 32 ;.type bittest_insn,@object ;.size bittest_insn,168 bittest_insn: @@ -4006,7 +4006,7 @@ bittest_insn: dd 4227 dd 8224 dd 0 - [align 32] + align 32 ;.type bsfr_insn,@object ;.size bsfr_insn,84 bsfr_insn: @@ -4049,7 +4049,7 @@ bsfr_insn: dd 16513 dd 4483 dd 0 - [align 4] + align 4 ;.type int_insn,@object ;.size int_insn,28 int_insn: @@ -4066,7 +4066,7 @@ int_insn: dd 8480 dd 0 dd 0 - [align 32] + align 32 ;.type bound_insn,@object ;.size bound_insn,56 bound_insn: @@ -4096,7 +4096,7 @@ bound_insn: dd 16481 dd 4450 dd 0 - [align 4] + align 4 ;.type arpl_insn,@object ;.size arpl_insn,28 arpl_insn: @@ -4113,7 +4113,7 @@ arpl_insn: dd 4419 dd 16449 dd 0 - [align 32] + align 32 ;.type str_insn,@object ;.size str_insn,112 str_insn: @@ -4169,7 +4169,7 @@ str_insn: dd 4419 dd 0 dd 0 - [align 4] + align 4 ;.type prot286_insn,@object ;.size prot286_insn,28 prot286_insn: @@ -4186,7 +4186,7 @@ prot286_insn: dd 4419 dd 0 dd 0 - [align 32] + align 32 ;.type sldtmsw_insn,@object ;.size sldtmsw_insn,168 sldtmsw_insn: @@ -4268,7 +4268,7 @@ sldtmsw_insn: dd 4225 dd 0 dd 0 - [align 32] + align 32 ;.type fldstp_insn,@object ;.size fldstp_insn,112 fldstp_insn: @@ -4324,7 +4324,7 @@ fldstp_insn: dd 24737 dd 0 dd 0 - [align 32] + align 32 ;.type fildstp_insn,@object ;.size fildstp_insn,84 fildstp_insn: @@ -4367,7 +4367,7 @@ fildstp_insn: dd 4226 dd 0 dd 0 - [align 4] + align 4 ;.type fbldstp_insn,@object ;.size fbldstp_insn,28 fbldstp_insn: @@ -4384,7 +4384,7 @@ fbldstp_insn: dd 4514 dd 0 dd 0 - [align 32] + align 32 ;.type fst_insn,@object ;.size fst_insn,84 fst_insn: @@ -4427,7 +4427,7 @@ fst_insn: dd 24737 dd 0 dd 0 - [align 32] + align 32 ;.type fxch_insn,@object ;.size fxch_insn,112 fxch_insn: @@ -4483,7 +4483,7 @@ fxch_insn: dd 0 dd 0 dd 0 - [align 32] + align 32 ;.type fcom_insn,@object ;.size fcom_insn,112 fcom_insn: @@ -4539,7 +4539,7 @@ fcom_insn: dd 170 dd 24737 dd 0 - [align 32] + align 32 ;.type fcom2_insn,@object ;.size fcom2_insn,56 fcom2_insn: @@ -4569,7 +4569,7 @@ fcom2_insn: dd 170 dd 24737 dd 0 - [align 32] + align 32 ;.type farith_insn,@object ;.size farith_insn,168 farith_insn: @@ -4651,7 +4651,7 @@ farith_insn: dd 24737 dd 170 dd 0 - [align 32] + align 32 ;.type farithp_insn,@object ;.size farithp_insn,84 farithp_insn: @@ -4694,7 +4694,7 @@ farithp_insn: dd 24737 dd 170 dd 0 - [align 32] + align 32 ;.type fiarith_insn,@object ;.size fiarith_insn,56 fiarith_insn: @@ -4724,7 +4724,7 @@ fiarith_insn: dd 4194 dd 0 dd 0 - [align 4] + align 4 ;.type fldnstcw_insn,@object ;.size fldnstcw_insn,28 fldnstcw_insn: @@ -4741,7 +4741,7 @@ fldnstcw_insn: dd 4418 dd 0 dd 0 - [align 4] + align 4 ;.type fstcw_insn,@object ;.size fstcw_insn,28 fstcw_insn: @@ -4758,7 +4758,7 @@ fstcw_insn: dd 4418 dd 0 dd 0 - [align 32] + align 32 ;.type fnstsw_insn,@object ;.size fnstsw_insn,56 fnstsw_insn: @@ -4788,7 +4788,7 @@ fnstsw_insn: dd 75 dd 0 dd 0 - [align 32] + align 32 ;.type fstsw_insn,@object ;.size fstsw_insn,56 fstsw_insn: @@ -4818,7 +4818,7 @@ fstsw_insn: dd 75 dd 0 dd 0 - [align 4] + align 4 ;.type ffree_insn,@object ;.size ffree_insn,28 ffree_insn: @@ -4835,7 +4835,7 @@ ffree_insn: dd 24737 dd 0 dd 0 - [align 32] + align 32 ;.type bswap_insn,@object ;.size bswap_insn,56 bswap_insn: @@ -4865,7 +4865,7 @@ bswap_insn: dd 24705 dd 0 dd 0 - [align 32] + align 32 ;.type cmpxchgxadd_insn,@object ;.size cmpxchgxadd_insn,112 cmpxchgxadd_insn: @@ -4921,7 +4921,7 @@ cmpxchgxadd_insn: dd 4483 dd 16513 dd 0 - [align 4] + align 4 ;.type cmpxchg8b_insn,@object ;.size cmpxchg8b_insn,28 cmpxchg8b_insn: @@ -4938,7 +4938,7 @@ cmpxchg8b_insn: dd 4482 dd 0 dd 0 - [align 32] + align 32 ;.type cmovcc_insn,@object ;.size cmovcc_insn,84 cmovcc_insn: @@ -4981,7 +4981,7 @@ cmovcc_insn: dd 16513 dd 4483 dd 0 - [align 4] + align 4 ;.type fcmovcc_insn,@object ;.size fcmovcc_insn,28 fcmovcc_insn: @@ -4998,7 +4998,7 @@ fcmovcc_insn: dd 170 dd 24737 dd 0 - [align 32] + align 32 ;.type movnti_insn,@object ;.size movnti_insn,56 movnti_insn: @@ -5028,7 +5028,7 @@ movnti_insn: dd 4482 dd 16513 dd 0 - [align 4] + align 4 ;.type clflush_insn,@object ;.size clflush_insn,28 clflush_insn: @@ -5045,7 +5045,7 @@ clflush_insn: dd 4386 dd 0 dd 0 - [align 32] + align 32 ;.type movd_insn,@object ;.size movd_insn,224 movd_insn: @@ -5153,7 +5153,7 @@ movd_insn: dd 4483 dd 16580 dd 0 - [align 32] + align 32 ;.type movq_insn,@object ;.size movq_insn,140 movq_insn: @@ -5222,7 +5222,7 @@ movq_insn: dd 4485 dd 16580 dd 0 - [align 32] + align 32 ;.type mmxsse2_insn,@object ;.size mmxsse2_insn,56 mmxsse2_insn: @@ -5252,7 +5252,7 @@ mmxsse2_insn: dd 16580 dd 4549 dd 0 - [align 32] + align 32 ;.type pshift_insn,@object ;.size pshift_insn,112 pshift_insn: @@ -5308,7 +5308,7 @@ pshift_insn: dd 4292 dd 8480 dd 0 - [align 4] + align 4 ;.type sseps_insn,@object ;.size sseps_insn,28 sseps_insn: @@ -5325,7 +5325,7 @@ sseps_insn: dd 16580 dd 4549 dd 0 - [align 4] + align 4 ;.type ssess_insn,@object ;.size ssess_insn,28 ssess_insn: @@ -5342,7 +5342,7 @@ ssess_insn: dd 16580 dd 4549 dd 0 - [align 4] + align 4 ;.type ssecmpps_insn,@object ;.size ssecmpps_insn,28 ssecmpps_insn: @@ -5359,7 +5359,7 @@ ssecmpps_insn: dd 16580 dd 4549 dd 0 - [align 4] + align 4 ;.type ssecmpss_insn,@object ;.size ssecmpss_insn,28 ssecmpss_insn: @@ -5376,7 +5376,7 @@ ssecmpss_insn: dd 16580 dd 4549 dd 0 - [align 4] + align 4 ;.type ssepsimm_insn,@object ;.size ssepsimm_insn,28 ssepsimm_insn: @@ -5393,7 +5393,7 @@ ssepsimm_insn: dd 16580 dd 4549 dd 8480 - [align 4] + align 4 ;.type ssessimm_insn,@object ;.size ssessimm_insn,28 ssessimm_insn: @@ -5410,7 +5410,7 @@ ssessimm_insn: dd 16580 dd 4549 dd 8480 - [align 4] + align 4 ;.type ldstmxcsr_insn,@object ;.size ldstmxcsr_insn,28 ldstmxcsr_insn: @@ -5427,7 +5427,7 @@ ldstmxcsr_insn: dd 4450 dd 0 dd 0 - [align 4] + align 4 ;.type maskmovq_insn,@object ;.size maskmovq_insn,28 maskmovq_insn: @@ -5444,7 +5444,7 @@ maskmovq_insn: dd 16516 dd 4228 dd 0 - [align 32] + align 32 ;.type movaups_insn,@object ;.size movaups_insn,56 movaups_insn: @@ -5474,7 +5474,7 @@ movaups_insn: dd 4549 dd 16580 dd 0 - [align 4] + align 4 ;.type movhllhps_insn,@object ;.size movhllhps_insn,28 movhllhps_insn: @@ -5491,7 +5491,7 @@ movhllhps_insn: dd 16580 dd 4292 dd 0 - [align 32] + align 32 ;.type movhlps_insn,@object ;.size movhlps_insn,56 movhlps_insn: @@ -5521,7 +5521,7 @@ movhlps_insn: dd 4482 dd 16580 dd 0 - [align 4] + align 4 ;.type movmskps_insn,@object ;.size movmskps_insn,28 movmskps_insn: @@ -5538,7 +5538,7 @@ movmskps_insn: dd 4193 dd 16580 dd 0 - [align 4] + align 4 ;.type movntps_insn,@object ;.size movntps_insn,28 movntps_insn: @@ -5555,7 +5555,7 @@ movntps_insn: dd 4546 dd 16577 dd 0 - [align 4] + align 4 ;.type movntq_insn,@object ;.size movntq_insn,28 movntq_insn: @@ -5572,7 +5572,7 @@ movntq_insn: dd 4482 dd 16580 dd 0 - [align 32] + align 32 ;.type movss_insn,@object ;.size movss_insn,84 movss_insn: @@ -5615,7 +5615,7 @@ movss_insn: dd 4482 dd 16580 dd 0 - [align 32] + align 32 ;.type pextrw_insn,@object ;.size pextrw_insn,56 pextrw_insn: @@ -5645,7 +5645,7 @@ pextrw_insn: dd 4193 dd 16580 dd 8480 - [align 32] + align 32 ;.type pinsrw_insn,@object ;.size pinsrw_insn,112 pinsrw_insn: @@ -5701,7 +5701,7 @@ pinsrw_insn: dd 16516 dd 4419 dd 8480 - [align 32] + align 32 ;.type pmovmskb_insn,@object ;.size pmovmskb_insn,56 pmovmskb_insn: @@ -5731,7 +5731,7 @@ pmovmskb_insn: dd 4193 dd 16580 dd 0 - [align 4] + align 4 ;.type pshufw_insn,@object ;.size pshufw_insn,28 pshufw_insn: @@ -5748,7 +5748,7 @@ pshufw_insn: dd 16516 dd 4485 dd 8480 - [align 32] + align 32 ;.type cmpsd_insn,@object ;.size cmpsd_insn,56 cmpsd_insn: @@ -5778,7 +5778,7 @@ cmpsd_insn: dd 16580 dd 4549 dd 8480 - [align 32] + align 32 ;.type movaupd_insn,@object ;.size movaupd_insn,56 movaupd_insn: @@ -5808,7 +5808,7 @@ movaupd_insn: dd 4549 dd 16580 dd 0 - [align 32] + align 32 ;.type movhlpd_insn,@object ;.size movhlpd_insn,56 movhlpd_insn: @@ -5838,7 +5838,7 @@ movhlpd_insn: dd 4482 dd 16580 dd 0 - [align 4] + align 4 ;.type movmskpd_insn,@object ;.size movmskpd_insn,28 movmskpd_insn: @@ -5855,7 +5855,7 @@ movmskpd_insn: dd 4193 dd 16580 dd 0 - [align 4] + align 4 ;.type movntpddq_insn,@object ;.size movntpddq_insn,28 movntpddq_insn: @@ -5872,7 +5872,7 @@ movntpddq_insn: dd 4546 dd 16580 dd 0 - [align 32] + align 32 ;.type movsd_insn,@object ;.size movsd_insn,112 movsd_insn: @@ -5928,7 +5928,7 @@ movsd_insn: dd 4482 dd 16580 dd 0 - [align 4] + align 4 ;.type maskmovdqu_insn,@object ;.size maskmovdqu_insn,28 maskmovdqu_insn: @@ -5945,7 +5945,7 @@ maskmovdqu_insn: dd 16580 dd 4292 dd 0 - [align 32] + align 32 ;.type movdqau_insn,@object ;.size movdqau_insn,56 movdqau_insn: @@ -5975,7 +5975,7 @@ movdqau_insn: dd 4549 dd 16580 dd 0 - [align 4] + align 4 ;.type movdq2q_insn,@object ;.size movdq2q_insn,28 movdq2q_insn: @@ -5992,7 +5992,7 @@ movdq2q_insn: dd 16516 dd 4292 dd 0 - [align 4] + align 4 ;.type movq2dq_insn,@object ;.size movq2dq_insn,28 movq2dq_insn: @@ -6009,7 +6009,7 @@ movq2dq_insn: dd 16580 dd 4228 dd 0 - [align 4] + align 4 ;.type pslrldq_insn,@object ;.size pslrldq_insn,28 pslrldq_insn: @@ -6026,7 +6026,7 @@ pslrldq_insn: dd 4292 dd 8480 dd 0 - [align 4] + align 4 ;.type now3d_insn,@object ;.size now3d_insn,28 now3d_insn: @@ -6043,7 +6043,7 @@ now3d_insn: dd 16516 dd 4485 dd 0 - [align 4] + align 4 ;.type cyrixmmx_insn,@object ;.size cyrixmmx_insn,28 cyrixmmx_insn: @@ -6060,7 +6060,7 @@ cyrixmmx_insn: dd 16516 dd 4485 dd 0 - [align 4] + align 4 ;.type pmachriw_insn,@object ;.size pmachriw_insn,28 pmachriw_insn: @@ -6077,7 +6077,7 @@ pmachriw_insn: dd 16516 dd 4482 dd 0 - [align 4] + align 4 ;.type rsdc_insn,@object ;.size rsdc_insn,28 rsdc_insn: @@ -6094,7 +6094,7 @@ rsdc_insn: dd 16454 dd 4514 dd 0 - [align 4] + align 4 ;.type cyrixsmm_insn,@object ;.size cyrixsmm_insn,28 cyrixsmm_insn: @@ -6111,7 +6111,7 @@ cyrixsmm_insn: dd 4514 dd 0 dd 0 - [align 4] + align 4 ;.type svdc_insn,@object ;.size svdc_insn,28 svdc_insn: @@ -6128,7 +6128,7 @@ svdc_insn: dd 4514 dd 16454 dd 0 - [align 32] + align 32 ;.type ibts_insn,@object ;.size ibts_insn,56 ibts_insn: @@ -6158,7 +6158,7 @@ ibts_insn: dd 4451 dd 16481 dd 0 - [align 32] + align 32 ;.type umov_insn,@object ;.size umov_insn,168 umov_insn: @@ -6240,7 +6240,7 @@ umov_insn: dd 16481 dd 4451 dd 0 - [align 32] + align 32 ;.type xbts_insn,@object ;.size xbts_insn,56 xbts_insn: @@ -6281,14 +6281,14 @@ size_lookup.0: db 80 db -128 db 0 - [section .rodata];.str1.1,"aMS",@progbits,1 + section .rodata;.str1.1,"aMS",@progbits,1 LC0: db "invalid operand conversion", 0 LC1: db "./modules/arch/x86/x86id.re", 0 LC2: db "$", 0 - [section .text] + section .text ;.type x86_new_jmp,@function x86_new_jmp: push ebp @@ -6524,8 +6524,8 @@ x86_new_jmp: ret .Lfe1: ;.size x86_new_jmp,.Lfe1-x86_new_jmp - [section .rodata] - [align 32] + section .rodata + align 32 ;.type size_lookup.1,@object ;.size size_lookup.1,32 size_lookup.1: @@ -6537,7 +6537,7 @@ size_lookup.1: dd 10 dd 16 dd 0 - [section .rodata];.str1.1 + section .rodata;.str1.1 LC3: db "invalid operand type", 0 LC4: @@ -6546,25 +6546,25 @@ LC6: db "mismatch in operand sizes", 0 LC7: db "operand size not specified", 0 - [section .rodata];.str1.32,"aMS",@progbits,1 - [align 32] + section .rodata;.str1.32,"aMS",@progbits,1 + align 32 LC8: db "unrecognized x86 ext mod index", 0 - [align 32] + align 32 LC9: db "unrecognized x86 extended modifier", 0 - [align 32] + align 32 LC5: db "invalid combination of opcode and operands", 0 - [section .rodata];.str1.1 + section .rodata;.str1.1 LC10: db "unknown operand action", 0 - [section .rodata];.str1.32 - [align 32] + section .rodata;.str1.32 + align 32 LC11: db "unknown operand postponed action", 0 - [section .text] -[global yasm_x86__parse_insn] + section .text +global yasm_x86__parse_insn ;.type yasm_x86__parse_insn,@function yasm_x86__parse_insn: push ebp @@ -6626,9 +6626,9 @@ yasm_x86__parse_insn: cmp eax, 21 ja .L139 jmp DWORD [.L140+eax*4] - [section .rodata] - [align 4] - [align 4] + section .rodata + align 4 + align 4 .L140: dd .L53 dd .L57 @@ -6652,7 +6652,7 @@ yasm_x86__parse_insn: dd .L130 dd .L133 dd .L136 - [section .text] + section .text .L53: cmp DWORD [edi+4], 4 jmp .L273 @@ -7496,12 +7496,12 @@ yasm_x86__parse_insn: ret .Lfe2: ;.size yasm_x86__parse_insn,.Lfe2-yasm_x86__parse_insn - [section .rodata];.str1.32 - [align 32] + section .rodata;.str1.32 + align 32 LC12: db "unrecognized CPU identifier `s'", 0 - [section .text] -[global yasm_x86__parse_cpu] + section .text +global yasm_x86__parse_cpu ;.type yasm_x86__parse_cpu,@function yasm_x86__parse_cpu: push ebp @@ -7515,9 +7515,9 @@ yasm_x86__parse_cpu: cmp eax, 119 ja .L338 jmp DWORD [.L339+eax*4] - [section .rodata] - [align 4] - [align 4] + section .rodata + align 4 + align 4 .L339: dd .L283 dd .L338 @@ -7639,7 +7639,7 @@ yasm_x86__parse_cpu: dd .L333 dd .L338 dd .L336 - [section .text] + section .text .L297: inc edx mov cl, BYTE [edx] @@ -7988,9 +7988,9 @@ yasm_x86__parse_cpu: cmp eax, 66 ja .L342 jmp DWORD [.L530+eax*4] - [section .rodata] - [align 4] - [align 4] + section .rodata + align 4 + align 4 .L530: dd .L504 dd .L342 @@ -8059,7 +8059,7 @@ yasm_x86__parse_cpu: dd .L525 dd .L342 dd .L528 - [section .text] + section .text .L513: inc edx mov cl, BYTE [edx] @@ -9102,27 +9102,27 @@ yasm_x86__parse_cpu: ret .Lfe3: ;.size yasm_x86__parse_cpu,.Lfe3-yasm_x86__parse_cpu - [section .rodata];.str1.32 - [align 32] + section .rodata;.str1.32 + align 32 LC16: db "`s' segment register ignored in 64-bit mode", 0 - [align 32] + align 32 LC18: db "Cannot override address size to 16 bits in 64-bit mode", 0 - [align 32] + align 32 LC17: db "`s' is a prefix in 64-bit mode", 0 - [align 32] + align 32 LC15: db "`s' is a register in 64-bit mode", 0 - [align 32] + align 32 LC13: db "`s' is an instruction in 64-bit mode", 0 - [section .rodata];.str1.1 + section .rodata;.str1.1 LC14: db "`s' invalid in 64-bit mode", 0 - [section .text] -[global yasm_x86__parse_check_id] + section .text +global yasm_x86__parse_check_id ;.type yasm_x86__parse_check_id,@function yasm_x86__parse_check_id: push ebp @@ -9140,9 +9140,9 @@ yasm_x86__parse_check_id: cmp eax, 120 ja .L999 jmp DWORD [.L1000+eax*4] - [section .rodata] - [align 4] - [align 4] + section .rodata + align 4 + align 4 .L1000: dd .L8702 dd .L999 @@ -9265,7 +9265,7 @@ yasm_x86__parse_check_id: dd .L991 dd .L994 dd .L997 - [section .text] + section .text .L970: inc ecx mov dl, BYTE [ecx] @@ -9295,9 +9295,9 @@ yasm_x86__parse_check_id: cmp eax, 56 ja .L1005 jmp DWORD [.L1069+eax*4] - [section .rodata] - [align 4] - [align 4] + section .rodata + align 4 + align 4 .L1069: dd .L1016 dd .L1019 @@ -9356,7 +9356,7 @@ yasm_x86__parse_check_id: dd .L1064 dd .L1005 dd .L1067 - [section .text] + section .text .L949: inc ecx mov dl, BYTE [ecx] @@ -9365,9 +9365,9 @@ yasm_x86__parse_check_id: cmp eax, 71 ja .L1005 jmp DWORD [.L1128+eax*4] - [section .rodata] - [align 4] - [align 4] + section .rodata + align 4 + align 4 .L1128: dd .L1072 dd .L1005 @@ -9441,7 +9441,7 @@ yasm_x86__parse_check_id: dd .L1120 dd .L1123 dd .L1126 - [section .text] + section .text .L985: inc ecx mov dl, BYTE [ecx] @@ -9508,9 +9508,9 @@ yasm_x86__parse_check_id: cmp eax, 71 ja .L1005 jmp DWORD [.L1191+eax*4] - [section .rodata] - [align 4] - [align 4] + section .rodata + align 4 + align 4 .L1191: dd .L1164 dd .L1005 @@ -9584,7 +9584,7 @@ yasm_x86__parse_check_id: dd .L1005 dd .L1005 dd .L1189 - [section .text] + section .text .L964: inc ecx mov dl, BYTE [ecx] @@ -9593,9 +9593,9 @@ yasm_x86__parse_check_id: cmp eax, 51 ja .L1005 jmp DWORD [.L1227+eax*4] - [section .rodata] - [align 4] - [align 4] + section .rodata + align 4 + align 4 .L1227: dd .L1195 dd .L1005 @@ -9649,7 +9649,7 @@ yasm_x86__parse_check_id: dd .L1005 dd .L1222 dd .L1225 - [section .text] + section .text .L979: inc ecx mov dl, BYTE [ecx] @@ -9658,9 +9658,9 @@ yasm_x86__parse_check_id: cmp eax, 66 ja .L1005 jmp DWORD [.L1259+eax*4] - [section .rodata] - [align 4] - [align 4] + section .rodata + align 4 + align 4 .L1259: dd .L1230 dd .L1005 @@ -9729,7 +9729,7 @@ yasm_x86__parse_check_id: dd .L1005 dd .L1005 dd .L1257 - [section .text] + section .text .L940: inc ecx mov dl, BYTE [ecx] @@ -9738,9 +9738,9 @@ yasm_x86__parse_check_id: cmp eax, 55 ja .L1005 jmp DWORD [.L1301+eax*4] - [section .rodata] - [align 4] - [align 4] + section .rodata + align 4 + align 4 .L1301: dd .L1263 dd .L1266 @@ -9798,7 +9798,7 @@ yasm_x86__parse_check_id: dd .L1293 dd .L1296 dd .L1299 - [section .text] + section .text .L943: inc ecx mov dl, BYTE [ecx] @@ -9807,9 +9807,9 @@ yasm_x86__parse_check_id: cmp eax, 55 ja .L1005 jmp DWORD [.L1328+eax*4] - [section .rodata] - [align 4] - [align 4] + section .rodata + align 4 + align 4 .L1328: dd .L1305 dd .L1005 @@ -9867,7 +9867,7 @@ yasm_x86__parse_check_id: dd .L1005 dd .L1005 dd .L1326 - [section .text] + section .text .L967: inc ecx mov dl, BYTE [ecx] @@ -9876,9 +9876,9 @@ yasm_x86__parse_check_id: cmp eax, 52 ja .L1005 jmp DWORD [.L1349+eax*4] - [section .rodata] - [align 4] - [align 4] + section .rodata + align 4 + align 4 .L1349: dd .L1332 dd .L1005 @@ -9933,7 +9933,7 @@ yasm_x86__parse_check_id: dd .L1005 dd .L1005 dd .L1347 - [section .text] + section .text .L997: inc ecx mov dl, BYTE [ecx] @@ -9942,9 +9942,9 @@ yasm_x86__parse_check_id: cmp eax, 46 ja .L1005 jmp DWORD [.L1370+eax*4] - [section .rodata] - [align 4] - [align 4] + section .rodata + align 4 + align 4 .L1370: dd .L1353 dd .L1356 @@ -9993,7 +9993,7 @@ yasm_x86__parse_check_id: dd .L1365 dd .L1005 dd .L1368 - [section .text] + section .text .L946: inc ecx mov dl, BYTE [ecx] @@ -10002,9 +10002,9 @@ yasm_x86__parse_check_id: cmp eax, 50 ja .L1005 jmp DWORD [.L1394+eax*4] - [section .rodata] - [align 4] - [align 4] + section .rodata + align 4 + align 4 .L1394: dd .L1374 dd .L1377 @@ -10057,7 +10057,7 @@ yasm_x86__parse_check_id: dd .L1005 dd .L1005 dd .L1392 - [section .text] + section .text .L937: inc ecx mov dl, BYTE [ecx] @@ -10066,9 +10066,9 @@ yasm_x86__parse_check_id: cmp eax, 48 ja .L1005 jmp DWORD [.L1418+eax*4] - [section .rodata] - [align 4] - [align 4] + section .rodata + align 4 + align 4 .L1418: dd .L1398 dd .L1005 @@ -10119,7 +10119,7 @@ yasm_x86__parse_check_id: dd .L1005 dd .L1005 dd .L1416 - [section .text] + section .text .L952: inc ecx mov dl, BYTE [ecx] @@ -10136,9 +10136,9 @@ yasm_x86__parse_check_id: cmp eax, 55 ja .L1005 jmp DWORD [.L1457+eax*4] - [section .rodata] - [align 4] - [align 4] + section .rodata + align 4 + align 4 .L1457: dd .L1425 dd .L1005 @@ -10196,7 +10196,7 @@ yasm_x86__parse_check_id: dd .L1005 dd .L1005 dd .L1455 - [section .text] + section .text .L958: inc ecx mov dl, BYTE [ecx] @@ -10205,9 +10205,9 @@ yasm_x86__parse_check_id: cmp eax, 48 ja .L1005 jmp DWORD [.L1475+eax*4] - [section .rodata] - [align 4] - [align 4] + section .rodata + align 4 + align 4 .L1475: dd .L1461 dd .L1005 @@ -10258,7 +10258,7 @@ yasm_x86__parse_check_id: dd .L1005 dd .L1005 dd .L1473 - [section .text] + section .text .L961: inc ecx mov dl, BYTE [ecx] @@ -10267,9 +10267,9 @@ yasm_x86__parse_check_id: cmp eax, 57 ja .L1005 jmp DWORD [.L1517+eax*4] - [section .rodata] - [align 4] - [align 4] + section .rodata + align 4 + align 4 .L1517: dd .L1479 dd .L1482 @@ -10329,7 +10329,7 @@ yasm_x86__parse_check_id: dd .L1005 dd .L1005 dd .L1515 - [section .text] + section .text .L955: inc ecx mov dl, BYTE [ecx] @@ -10932,9 +10932,9 @@ yasm_x86__parse_check_id: cmp eax, 57 ja .L1005 jmp DWORD [.L1830+eax*4] - [section .rodata] - [align 4] - [align 4] + section .rodata + align 4 + align 4 .L1830: dd .L1801 dd .L1804 @@ -10994,7 +10994,7 @@ yasm_x86__parse_check_id: dd .L1005 dd .L1005 dd .L1828 - [section .text] + section .text .L1503: inc ecx cmp BYTE [ecx], 0 @@ -11676,9 +11676,9 @@ yasm_x86__parse_check_id: cmp eax, 65 ja .L1005 jmp DWORD [.L2189+eax*4] - [section .rodata] - [align 4] - [align 4] + section .rodata + align 4 + align 4 .L2189: dd .L2166 dd .L1005 @@ -11746,7 +11746,7 @@ yasm_x86__parse_check_id: dd .L1005 dd .L2184 dd .L2187 - [section .text] + section .text .L1437: inc ecx mov dl, BYTE [ecx] @@ -11845,9 +11845,9 @@ yasm_x86__parse_check_id: cmp eax, 54 ja .L1005 jmp DWORD [.L2257+eax*4] - [section .rodata] - [align 4] - [align 4] + section .rodata + align 4 + align 4 .L2257: dd .L2240 dd .L1005 @@ -11904,7 +11904,7 @@ yasm_x86__parse_check_id: dd .L2252 dd .L1005 dd .L2255 - [section .text] + section .text .L1452: inc ecx mov dl, BYTE [ecx] @@ -12531,9 +12531,9 @@ yasm_x86__parse_check_id: cmp eax, 53 ja .L1005 jmp DWORD [.L2571+eax*4] - [section .rodata] - [align 4] - [align 4] + section .rodata + align 4 + align 4 .L2571: dd .L2554 dd .L1005 @@ -12589,7 +12589,7 @@ yasm_x86__parse_check_id: dd .L2566 dd .L1005 dd .L2569 - [section .text] + section .text .L2554: inc ecx cmp BYTE [ecx], 0 @@ -14530,9 +14530,9 @@ yasm_x86__parse_check_id: cmp eax, 53 ja .L1005 jmp DWORD [.L3482+eax*4] - [section .rodata] - [align 4] - [align 4] + section .rodata + align 4 + align 4 .L3482: dd .L3465 dd .L1005 @@ -14588,7 +14588,7 @@ yasm_x86__parse_check_id: dd .L3477 dd .L1005 dd .L3480 - [section .text] + section .text .L3465: inc ecx cmp BYTE [ecx], 0 @@ -15939,9 +15939,9 @@ yasm_x86__parse_check_id: cmp eax, 54 ja .L1005 jmp DWORD [.L4093+eax*4] - [section .rodata] - [align 4] - [align 4] + section .rodata + align 4 + align 4 .L4093: dd .L4076 dd .L1005 @@ -15998,7 +15998,7 @@ yasm_x86__parse_check_id: dd .L1005 dd .L4088 dd .L4091 - [section .text] + section .text .L4001: inc ecx mov dl, BYTE [ecx] @@ -18089,9 +18089,9 @@ yasm_x86__parse_check_id: cmp eax, 57 ja .L1005 jmp DWORD [.L5073+eax*4] - [section .rodata] - [align 4] - [align 4] + section .rodata + align 4 + align 4 .L5073: dd .L5041 dd .L5044 @@ -18151,7 +18151,7 @@ yasm_x86__parse_check_id: dd .L1005 dd .L1005 dd .L5071 - [section .text] + section .text .L5062: inc ecx cmp BYTE [ecx], 0 @@ -18167,9 +18167,9 @@ yasm_x86__parse_check_id: cmp eax, 57 ja .L1005 jmp DWORD [.L5109+eax*4] - [section .rodata] - [align 4] - [align 4] + section .rodata + align 4 + align 4 .L5109: dd .L5080 dd .L5083 @@ -18229,7 +18229,7 @@ yasm_x86__parse_check_id: dd .L1005 dd .L1005 dd .L5107 - [section .text] + section .text .L5044: inc ecx mov dl, BYTE [ecx] @@ -18577,9 +18577,9 @@ yasm_x86__parse_check_id: cmp eax, 53 ja .L1005 jmp DWORD [.L5310+eax*4] - [section .rodata] - [align 4] - [align 4] + section .rodata + align 4 + align 4 .L5310: dd .L5296 dd .L1005 @@ -18635,7 +18635,7 @@ yasm_x86__parse_check_id: dd .L1005 dd .L1005 dd .L5308 - [section .text] + section .text .L5015: inc ecx mov dl, BYTE [ecx] @@ -19766,9 +19766,9 @@ yasm_x86__parse_check_id: cmp eax, 47 ja .L1005 jmp DWORD [.L5855+eax*4] - [section .rodata] - [align 4] - [align 4] + section .rodata + align 4 + align 4 .L5855: dd .L5838 dd .L1005 @@ -19818,7 +19818,7 @@ yasm_x86__parse_check_id: dd .L1005 dd .L1005 dd .L5853 - [section .text] + section .text .L1248: inc ecx mov dl, BYTE [ecx] @@ -19875,9 +19875,9 @@ yasm_x86__parse_check_id: cmp eax, 48 ja .L1005 jmp DWORD [.L5902+eax*4] - [section .rodata] - [align 4] - [align 4] + section .rodata + align 4 + align 4 .L5902: dd .L5882 dd .L1005 @@ -19928,7 +19928,7 @@ yasm_x86__parse_check_id: dd .L1005 dd .L1005 dd .L5900 - [section .text] + section .text .L5894: inc ecx cmp BYTE [ecx], 0 @@ -21890,9 +21890,9 @@ yasm_x86__parse_check_id: cmp eax, 50 ja .L1005 jmp DWORD [.L6775+eax*4] - [section .rodata] - [align 4] - [align 4] + section .rodata + align 4 + align 4 .L6775: dd .L6755 dd .L1005 @@ -21945,7 +21945,7 @@ yasm_x86__parse_check_id: dd .L1005 dd .L1005 dd .L6773 - [section .text] + section .text .L1096: inc ecx mov dl, BYTE [ecx] @@ -24308,9 +24308,9 @@ yasm_x86__parse_check_id: cmp eax, 41 ja .L1005 jmp DWORD [.L7863+eax*4] - [section .rodata] - [align 4] - [align 4] + section .rodata + align 4 + align 4 .L7863: dd .L7852 dd .L1005 @@ -24354,7 +24354,7 @@ yasm_x86__parse_check_id: dd .L1005 dd .L1005 dd .L7861 - [section .text] + section .text .L1037: inc ecx mov dl, BYTE [ecx] @@ -24462,9 +24462,9 @@ yasm_x86__parse_check_id: cmp eax, 66 ja .L1005 jmp DWORD [.L7931+eax*4] - [section .rodata] - [align 4] - [align 4] + section .rodata + align 4 + align 4 .L7931: dd .L7911 dd .L7911 @@ -24533,7 +24533,7 @@ yasm_x86__parse_check_id: dd .L1005 dd .L1005 dd .L7929 - [section .text] + section .text .L1058: inc ecx mov dl, BYTE [ecx] @@ -25478,9 +25478,9 @@ yasm_x86__parse_check_id: cmp eax, 57 ja .L1005 jmp DWORD [.L8375+eax*4] - [section .rodata] - [align 4] - [align 4] + section .rodata + align 4 + align 4 .L8375: dd .L8343 dd .L8346 @@ -25540,7 +25540,7 @@ yasm_x86__parse_check_id: dd .L1005 dd .L1005 dd .L8373 - [section .text] + section .text .L8343: inc ecx mov dl, BYTE [ecx] @@ -25611,9 +25611,9 @@ yasm_x86__parse_check_id: cmp eax, 57 ja .L1005 jmp DWORD [.L8450+eax*4] - [section .rodata] - [align 4] - [align 4] + section .rodata + align 4 + align 4 .L8450: dd .L8421 dd .L8424 @@ -25673,7 +25673,7 @@ yasm_x86__parse_check_id: dd .L1005 dd .L1005 dd .L8448 - [section .text] + section .text .L8364: inc ecx cmp BYTE [ecx], 0 diff --git a/modules/objfmts/elf/tests/elf_test.sh b/modules/objfmts/elf/tests/elf_test.sh index ed3766ec..420eab36 100755 --- a/modules/objfmts/elf/tests/elf_test.sh +++ b/modules/objfmts/elf/tests/elf_test.sh @@ -1,4 +1,5 @@ #! /bin/sh +# $Id$ # copied from yasm/modules/objfmts/coff/tests/coff_test.sh ; s/coff/elf/g ${srcdir}/out_test.sh elf_test modules/objfmts/elf/tests "elf objfmt" "-f elf" ".o" exit $? diff --git a/modules/objfmts/elf/tests/elfso.hex b/modules/objfmts/elf/tests/elfso.hex index 206cce9c..9d99c0f8 100644 --- a/modules/objfmts/elf/tests/elfso.hex +++ b/modules/objfmts/elf/tests/elfso.hex @@ -88,10 +88,10 @@ e8 5b 81 c3 -03 -00 -00 -00 +e9 +ff +ff +ff 8b 83 00 diff --git a/modules/objfmts/elf/tests/elftest.c b/modules/objfmts/elf/tests/elftest.c index 69610718..73a15408 100644 --- a/modules/objfmts/elf/tests/elftest.c +++ b/modules/objfmts/elf/tests/elftest.c @@ -29,7 +29,7 @@ int main(void) { greet(); printf("These pointers should be equal: %p and %p\n", - &greet, textptr); + &greet, textptr); printf("So should these: %p and %p\n", selfptr, &selfptr); } diff --git a/modules/objfmts/elf/tests/elfvisibility.asm b/modules/objfmts/elf/tests/elfvisibility.asm index 8577b5de..32d20722 100644 --- a/modules/objfmts/elf/tests/elfvisibility.asm +++ b/modules/objfmts/elf/tests/elfvisibility.asm @@ -1,9 +1,9 @@ [section .text] -[global ghidden:hidden] -[global ginternal:internal] -[global gprotected:protected] -[global gtoomany:hidden internal] +global ghidden:hidden +global ginternal:internal +global gprotected:protected +global gtoomany:hidden internal ghidden: ginternal: diff --git a/modules/objfmts/elf/tests/gas32/Makefile.inc b/modules/objfmts/elf/tests/gas32/Makefile.inc deleted file mode 100644 index 883c2143..00000000 --- a/modules/objfmts/elf/tests/gas32/Makefile.inc +++ /dev/null @@ -1,7 +0,0 @@ -TESTS += modules/objfmts/elf/tests/gas32/elf_gas32_test.sh - -EXTRA_DIST += modules/objfmts/elf/tests/gas32/elf_gas32_test.sh -EXTRA_DIST += modules/objfmts/elf/tests/gas32/elf_gas32_ssym.asm -EXTRA_DIST += modules/objfmts/elf/tests/gas32/elf_gas32_ssym.hex -EXTRA_DIST += modules/objfmts/elf/tests/gas32/elf_gas32_got.asm -EXTRA_DIST += modules/objfmts/elf/tests/gas32/elf_gas32_got.hex diff --git a/modules/objfmts/elf/tests/gas32/elf_gas32_got.asm b/modules/objfmts/elf/tests/gas32/elf_gas32_got.asm deleted file mode 100644 index 22a60a52..00000000 --- a/modules/objfmts/elf/tests/gas32/elf_gas32_got.asm +++ /dev/null @@ -1,13 +0,0 @@ -.text - -.extern a - -.globl tst -tst: - call L1 -L1: - pop %eax - add $_GLOBAL_OFFSET_TABLE_+(.-L1), %eax - mov (a@GOT)(%eax), %eax - movl $5, (%eax) - ret diff --git a/modules/objfmts/elf/tests/gas32/elf_gas32_got.hex b/modules/objfmts/elf/tests/gas32/elf_gas32_got.hex deleted file mode 100644 index c7060e62..00000000 --- a/modules/objfmts/elf/tests/gas32/elf_gas32_got.hex +++ /dev/null @@ -1,544 +0,0 @@ -7f -45 -4c -46 -01 -01 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -01 -00 -03 -00 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -30 -01 -00 -00 -00 -00 -00 -00 -34 -00 -00 -00 -00 -00 -28 -00 -06 -00 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -e8 -00 -00 -00 -00 -58 -05 -02 -00 -00 -00 -8b -80 -00 -00 -00 -00 -c7 -00 -05 -00 -00 -00 -c3 -07 -00 -00 -00 -0a -06 -00 -00 -0d -00 -00 -00 -03 -04 -00 -00 -00 -2e -74 -65 -78 -74 -00 -2e -72 -65 -6c -2e -74 -65 -78 -74 -00 -2e -73 -74 -72 -74 -61 -62 -00 -2e -73 -79 -6d -74 -61 -62 -00 -2e -73 -68 -73 -74 -72 -74 -61 -62 -00 -00 -00 -2d -00 -61 -00 -74 -73 -74 -00 -5f -47 -4c -4f -42 -41 -4c -5f -4f -46 -46 -53 -45 -54 -5f -54 -41 -42 -4c -45 -5f -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -04 -00 -f1 -ff -00 -00 -00 -00 -05 -00 -00 -00 -00 -00 -00 -00 -00 -00 -04 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -03 -00 -04 -00 -03 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -10 -00 -00 -00 -05 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -10 -00 -04 -00 -09 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -10 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -21 -00 -00 -00 -03 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -68 -00 -00 -00 -2b -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -11 -00 -00 -00 -03 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -94 -00 -00 -00 -1f -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -19 -00 -00 -00 -02 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -b4 -00 -00 -00 -70 -00 -00 -00 -02 -00 -00 -00 -04 -00 -00 -00 -04 -00 -00 -00 -10 -00 -00 -00 -01 -00 -00 -00 -01 -00 -00 -00 -06 -00 -00 -00 -00 -00 -00 -00 -40 -00 -00 -00 -18 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -10 -00 -00 -00 -00 -00 -00 -00 -07 -00 -00 -00 -09 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -58 -00 -00 -00 -10 -00 -00 -00 -03 -00 -00 -00 -04 -00 -00 -00 -04 -00 -00 -00 -08 -00 -00 -00 diff --git a/modules/objfmts/elf/tests/gas32/elf_gas32_ssym.asm b/modules/objfmts/elf/tests/gas32/elf_gas32_ssym.asm deleted file mode 100644 index 9bd042d0..00000000 --- a/modules/objfmts/elf/tests/gas32/elf_gas32_ssym.asm +++ /dev/null @@ -1,14 +0,0 @@ -.text -foo: -movl %eax, foo@PLT -movl %eax, foo@GOTOFF -#movl %eax, foo@GOTPC -movl %eax, bar@TLSGD -movl %eax, bar@TLSLDM -movl %eax, bar@GOTTPOFF -movl %eax, bar@TPOFF -movl %eax, bar@NTPOFF -movl %eax, bar@DTPOFF -movl %eax, bar@GOTNTPOFF -movl %eax, bar@INDNTPOFF -movl %eax, foo@GOT diff --git a/modules/objfmts/elf/tests/gas32/elf_gas32_ssym.hex b/modules/objfmts/elf/tests/gas32/elf_gas32_ssym.hex deleted file mode 100644 index 61057e2f..00000000 --- a/modules/objfmts/elf/tests/gas32/elf_gas32_ssym.hex +++ /dev/null @@ -1,592 +0,0 @@ -7f -45 -4c -46 -01 -01 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -01 -00 -03 -00 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -60 -01 -00 -00 -00 -00 -00 -00 -34 -00 -00 -00 -00 -00 -28 -00 -06 -00 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -a3 -00 -00 -00 -00 -a3 -00 -00 -00 -00 -a3 -00 -00 -00 -00 -a3 -00 -00 -00 -00 -a3 -00 -00 -00 -00 -a3 -00 -00 -00 -00 -a3 -00 -00 -00 -00 -a3 -00 -00 -00 -00 -a3 -00 -00 -00 -00 -a3 -00 -00 -00 -00 -a3 -00 -00 -00 -00 -00 -01 -00 -00 -00 -04 -02 -00 -00 -06 -00 -00 -00 -09 -03 -00 -00 -0b -00 -00 -00 -12 -04 -00 -00 -10 -00 -00 -00 -13 -04 -00 -00 -15 -00 -00 -00 -21 -04 -00 -00 -1a -00 -00 -00 -22 -04 -00 -00 -1f -00 -00 -00 -11 -04 -00 -00 -24 -00 -00 -00 -20 -04 -00 -00 -29 -00 -00 -00 -10 -04 -00 -00 -2e -00 -00 -00 -0f -04 -00 -00 -33 -00 -00 -00 -03 -02 -00 -00 -00 -2e -74 -65 -78 -74 -00 -2e -72 -65 -6c -2e -74 -65 -78 -74 -00 -2e -73 -74 -72 -74 -61 -62 -00 -2e -73 -79 -6d -74 -61 -62 -00 -2e -73 -68 -73 -74 -72 -74 -61 -62 -00 -00 -00 -2d -00 -62 -61 -72 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -04 -00 -f1 -ff -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -04 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -03 -00 -04 -00 -03 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -16 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -21 -00 -00 -00 -03 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -d0 -00 -00 -00 -2b -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -11 -00 -00 -00 -03 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -fc -00 -00 -00 -07 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -19 -00 -00 -00 -02 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -04 -01 -00 -00 -50 -00 -00 -00 -02 -00 -00 -00 -04 -00 -00 -00 -04 -00 -00 -00 -10 -00 -00 -00 -01 -00 -00 -00 -01 -00 -00 -00 -06 -00 -00 -00 -00 -00 -00 -00 -40 -00 -00 -00 -37 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -10 -00 -00 -00 -00 -00 -00 -00 -07 -00 -00 -00 -09 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -78 -00 -00 -00 -58 -00 -00 -00 -03 -00 -00 -00 -04 -00 -00 -00 -04 -00 -00 -00 -08 -00 -00 -00 diff --git a/modules/objfmts/elf/tests/gas32/elf_gas32_test.sh b/modules/objfmts/elf/tests/gas32/elf_gas32_test.sh deleted file mode 100755 index 4d346911..00000000 --- a/modules/objfmts/elf/tests/gas32/elf_gas32_test.sh +++ /dev/null @@ -1,3 +0,0 @@ -#! /bin/sh -${srcdir}/out_test.sh elf_gas32_test modules/objfmts/elf/tests/gas32 "GAS elf-x86 objfmt" "-f elf32 -p gas" ".o" -exit $? diff --git a/modules/objfmts/elf/tests/gas64/Makefile.inc b/modules/objfmts/elf/tests/gas64/Makefile.inc index 382744d1..9be81625 100644 --- a/modules/objfmts/elf/tests/gas64/Makefile.inc +++ b/modules/objfmts/elf/tests/gas64/Makefile.inc @@ -1,3 +1,5 @@ +# $Id: Makefile.inc 1168 2004-10-31 01:07:52Z peter $ + TESTS += modules/objfmts/elf/tests/gas64/elf_gas64_test.sh EXTRA_DIST += modules/objfmts/elf/tests/gas64/elf_gas64_test.sh @@ -7,5 +9,3 @@ EXTRA_DIST += modules/objfmts/elf/tests/gas64/elf_gas64_curpos.asm EXTRA_DIST += modules/objfmts/elf/tests/gas64/elf_gas64_curpos.hex EXTRA_DIST += modules/objfmts/elf/tests/gas64/elf_gas64_reloc.asm EXTRA_DIST += modules/objfmts/elf/tests/gas64/elf_gas64_reloc.hex -EXTRA_DIST += modules/objfmts/elf/tests/gas64/elf_gas64_ssym.asm -EXTRA_DIST += modules/objfmts/elf/tests/gas64/elf_gas64_ssym.hex diff --git a/modules/objfmts/elf/tests/gas64/crosssect.hex b/modules/objfmts/elf/tests/gas64/crosssect.hex index dd95c79d..4e15f937 100644 --- a/modules/objfmts/elf/tests/gas64/crosssect.hex +++ b/modules/objfmts/elf/tests/gas64/crosssect.hex @@ -774,7 +774,7 @@ e4 00 00 00 -02 +00 00 00 00 diff --git a/modules/objfmts/elf/tests/gas64/elf_gas64_curpos.hex b/modules/objfmts/elf/tests/gas64/elf_gas64_curpos.hex index 80e25a8f..f1a2befa 100644 --- a/modules/objfmts/elf/tests/gas64/elf_gas64_curpos.hex +++ b/modules/objfmts/elf/tests/gas64/elf_gas64_curpos.hex @@ -870,7 +870,7 @@ c0 00 00 00 -06 +00 00 00 00 @@ -1126,7 +1126,7 @@ b4 00 00 00 -03 +00 00 00 00 diff --git a/modules/objfmts/elf/tests/gas64/elf_gas64_ssym.asm b/modules/objfmts/elf/tests/gas64/elf_gas64_ssym.asm deleted file mode 100644 index b7203f62..00000000 --- a/modules/objfmts/elf/tests/gas64/elf_gas64_ssym.asm +++ /dev/null @@ -1,10 +0,0 @@ -.text -foo: -movl %eax, foo@PLT -movl %eax, foo@GOTPCREL -movl %eax, bar@TLSGD -movl %eax, bar@TLSLD -movl %eax, bar@GOTTPOFF -movl %eax, bar@TPOFF -movl %eax, bar@DTPOFF -movl %eax, foo@GOT diff --git a/modules/objfmts/elf/tests/gas64/elf_gas64_ssym.hex b/modules/objfmts/elf/tests/gas64/elf_gas64_ssym.hex deleted file mode 100644 index 06e4c138..00000000 --- a/modules/objfmts/elf/tests/gas64/elf_gas64_ssym.hex +++ /dev/null @@ -1,880 +0,0 @@ -7f -45 -4c -46 -02 -01 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -01 -00 -3e -00 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -f0 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -40 -00 -00 -00 -00 -00 -40 -00 -06 -00 -01 -00 -89 -04 -25 -00 -00 -00 -00 -89 -04 -25 -00 -00 -00 -00 -89 -04 -25 -00 -00 -00 -00 -89 -04 -25 -00 -00 -00 -00 -89 -04 -25 -00 -00 -00 -00 -89 -04 -25 -00 -00 -00 -00 -89 -04 -25 -00 -00 -00 -00 -89 -04 -25 -00 -00 -00 -00 -03 -00 -00 -00 -00 -00 -00 -00 -04 -00 -00 -00 -02 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -0a -00 -00 -00 -00 -00 -00 -00 -09 -00 -00 -00 -02 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -11 -00 -00 -00 -00 -00 -00 -00 -13 -00 -00 -00 -04 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -18 -00 -00 -00 -00 -00 -00 -00 -14 -00 -00 -00 -04 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -1f -00 -00 -00 -00 -00 -00 -00 -16 -00 -00 -00 -04 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -26 -00 -00 -00 -00 -00 -00 -00 -17 -00 -00 -00 -04 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -2d -00 -00 -00 -00 -00 -00 -00 -15 -00 -00 -00 -04 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -34 -00 -00 -00 -00 -00 -00 -00 -03 -00 -00 -00 -02 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -2e -74 -65 -78 -74 -00 -2e -72 -65 -6c -61 -2e -74 -65 -78 -74 -00 -2e -73 -74 -72 -74 -61 -62 -00 -2e -73 -79 -6d -74 -61 -62 -00 -2e -73 -68 -73 -74 -72 -74 -61 -62 -00 -00 -2d -00 -62 -61 -72 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -01 -00 -00 -00 -04 -00 -f1 -ff -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -04 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -03 -00 -04 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -03 -00 -00 -00 -16 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -22 -00 -00 -00 -03 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -38 -01 -00 -00 -00 -00 -00 -00 -2c -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -12 -00 -00 -00 -03 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -64 -01 -00 -00 -00 -00 -00 -00 -07 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -1a -00 -00 -00 -02 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -6c -01 -00 -00 -00 -00 -00 -00 -78 -00 -00 -00 -00 -00 -00 -00 -02 -00 -00 -00 -04 -00 -00 -00 -08 -00 -00 -00 -00 -00 -00 -00 -18 -00 -00 -00 -00 -00 -00 -00 -01 -00 -00 -00 -01 -00 -00 -00 -06 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -40 -00 -00 -00 -00 -00 -00 -00 -38 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -10 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -07 -00 -00 -00 -04 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -78 -00 -00 -00 -00 -00 -00 -00 -c0 -00 -00 -00 -00 -00 -00 -00 -03 -00 -00 -00 -04 -00 -00 -00 -08 -00 -00 -00 -00 -00 -00 -00 -18 -00 -00 -00 -00 -00 -00 -00 diff --git a/modules/objfmts/elf/tests/gas64/elf_gas64_test.sh b/modules/objfmts/elf/tests/gas64/elf_gas64_test.sh index 6696ba7e..de90bc13 100755 --- a/modules/objfmts/elf/tests/gas64/elf_gas64_test.sh +++ b/modules/objfmts/elf/tests/gas64/elf_gas64_test.sh @@ -1,3 +1,4 @@ #! /bin/sh +# $Id: elf_amd64_test.sh 1137 2004-09-04 01:24:57Z peter $ ${srcdir}/out_test.sh elf_gas64_test modules/objfmts/elf/tests/gas64 "GAS elf-amd64 objfmt" "-f elf64 -p gas" ".o" exit $? diff --git a/modules/objfmts/elf/tests/gasx32/Makefile.inc b/modules/objfmts/elf/tests/gasx32/Makefile.inc deleted file mode 100644 index 6bba8bd6..00000000 --- a/modules/objfmts/elf/tests/gasx32/Makefile.inc +++ /dev/null @@ -1,11 +0,0 @@ -TESTS += modules/objfmts/elf/tests/gasx32/elf_gasx32_test.sh - -EXTRA_DIST += modules/objfmts/elf/tests/gasx32/elf_gasx32_test.sh -EXTRA_DIST += modules/objfmts/elf/tests/gasx32/crosssect.asm -EXTRA_DIST += modules/objfmts/elf/tests/gasx32/crosssect.hex -EXTRA_DIST += modules/objfmts/elf/tests/gasx32/elf_gasx32_curpos.asm -EXTRA_DIST += modules/objfmts/elf/tests/gasx32/elf_gasx32_curpos.hex -EXTRA_DIST += modules/objfmts/elf/tests/gasx32/elf_gasx32_reloc.asm -EXTRA_DIST += modules/objfmts/elf/tests/gasx32/elf_gasx32_reloc.hex -EXTRA_DIST += modules/objfmts/elf/tests/gasx32/elf_gasx32_ssym.asm -EXTRA_DIST += modules/objfmts/elf/tests/gasx32/elf_gasx32_ssym.hex diff --git a/modules/objfmts/elf/tests/gasx32/crosssect.asm b/modules/objfmts/elf/tests/gasx32/crosssect.asm deleted file mode 100644 index 41999791..00000000 --- a/modules/objfmts/elf/tests/gasx32/crosssect.asm +++ /dev/null @@ -1,18 +0,0 @@ -.section .rodata - .align 4 -_sys_srt: - .long 0 - -.text - .align 4,0x90 - .long _sys_srt-. - .long _sys_srt-_sys_info - #.long _sys_info-_sys_srt - #.long -(_sys_srt-_sys_info) - .long _sys_info-. - .long .-_sys_info - .long (_sys_srt-.)+(.-_sys_info) # GAS cannot handle this but we can - .long 0 - .long 65558 -_sys_info: - .long 0 diff --git a/modules/objfmts/elf/tests/gasx32/crosssect.hex b/modules/objfmts/elf/tests/gasx32/crosssect.hex deleted file mode 100644 index 35893c4e..00000000 --- a/modules/objfmts/elf/tests/gasx32/crosssect.hex +++ /dev/null @@ -1,568 +0,0 @@ -7f -45 -4c -46 -01 -01 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -01 -00 -3e -00 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -20 -01 -00 -00 -00 -00 -00 -00 -34 -00 -00 -00 -00 -00 -28 -00 -07 -00 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -14 -00 -00 -00 -f0 -ff -ff -ff -00 -00 -00 -00 -00 -00 -00 -00 -16 -00 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -02 -04 -00 -00 -00 -00 -00 -00 -04 -00 -00 -00 -02 -04 -00 -00 -e8 -ff -ff -ff -10 -00 -00 -00 -02 -04 -00 -00 -f4 -ff -ff -ff -00 -00 -00 -00 -00 -2e -74 -65 -78 -74 -00 -2e -72 -6f -64 -61 -74 -61 -00 -2e -72 -65 -6c -61 -2e -74 -65 -78 -74 -00 -2e -73 -74 -72 -74 -61 -62 -00 -2e -73 -79 -6d -74 -61 -62 -00 -2e -73 -68 -73 -74 -72 -74 -61 -62 -00 -00 -2d -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -04 -00 -f1 -ff -00 -00 -00 -00 -1c -00 -00 -00 -00 -00 -00 -00 -00 -00 -04 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -06 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -03 -00 -06 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -03 -00 -04 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -2a -00 -00 -00 -03 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -88 -00 -00 -00 -34 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -1a -00 -00 -00 -03 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -bc -00 -00 -00 -03 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -22 -00 -00 -00 -02 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -c0 -00 -00 -00 -60 -00 -00 -00 -02 -00 -00 -00 -06 -00 -00 -00 -04 -00 -00 -00 -10 -00 -00 -00 -01 -00 -00 -00 -01 -00 -00 -00 -06 -00 -00 -00 -00 -00 -00 -00 -40 -00 -00 -00 -20 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -10 -00 -00 -00 -00 -00 -00 -00 -0f -00 -00 -00 -04 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -60 -00 -00 -00 -24 -00 -00 -00 -03 -00 -00 -00 -04 -00 -00 -00 -04 -00 -00 -00 -0c -00 -00 -00 -07 -00 -00 -00 -01 -00 -00 -00 -02 -00 -00 -00 -00 -00 -00 -00 -84 -00 -00 -00 -04 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -04 -00 -00 -00 -00 -00 -00 -00 diff --git a/modules/objfmts/elf/tests/gasx32/elf_gasx32_curpos.asm b/modules/objfmts/elf/tests/gasx32/elf_gasx32_curpos.asm deleted file mode 100644 index 60a893b3..00000000 --- a/modules/objfmts/elf/tests/gasx32/elf_gasx32_curpos.asm +++ /dev/null @@ -1,27 +0,0 @@ -.globl bar -.globl foo - -.section .bar -bar: -.4byte foo-. -.4byte baz-. -call foo -call baz -foo: - -.section .data -baz: -.4byte foo-. -#.4byte .-foo # illegal -.4byte baz-. -.4byte .-baz -.4byte foo+4-. # with constant -.4byte .-baz+foo+4-. # both local and cross-segment (legal) -#.4byte baz+foo+4-.-. # ditto, slightly different - GAS gets confused on this -#.4byte (bar-.)+(foo-.) # illegal (too many cross-segment) -.4byte baz-.+baz-. # two from same segment - -.section .text -movl $5, foo-. -movl $(foo-.), %eax -call foo diff --git a/modules/objfmts/elf/tests/gasx32/elf_gasx32_curpos.hex b/modules/objfmts/elf/tests/gasx32/elf_gasx32_curpos.hex deleted file mode 100644 index 45cb217f..00000000 --- a/modules/objfmts/elf/tests/gasx32/elf_gasx32_curpos.hex +++ /dev/null @@ -1,848 +0,0 @@ -7f -45 -4c -46 -01 -01 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -01 -00 -3e -00 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -c0 -01 -00 -00 -00 -00 -00 -00 -34 -00 -00 -00 -00 -00 -28 -00 -0a -00 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -c7 -04 -25 -00 -00 -00 -00 -05 -00 -00 -00 -b8 -00 -00 -00 -00 -e8 -00 -00 -00 -00 -00 -00 -00 -03 -00 -00 -00 -02 -07 -00 -00 -03 -00 -00 -00 -0c -00 -00 -00 -02 -07 -00 -00 -01 -00 -00 -00 -11 -00 -00 -00 -02 -07 -00 -00 -fc -ff -ff -ff -12 -00 -00 -00 -00 -00 -00 -00 -e8 -05 -00 -00 -00 -e8 -00 -00 -00 -00 -00 -00 -04 -00 -00 -00 -02 -02 -00 -00 -00 -00 -00 -00 -0e -00 -00 -00 -02 -02 -00 -00 -fc -ff -ff -ff -00 -00 -00 -00 -fc -ff -ff -ff -08 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -d8 -ff -ff -ff -00 -00 -00 -00 -02 -07 -00 -00 -00 -00 -00 -00 -0c -00 -00 -00 -02 -07 -00 -00 -04 -00 -00 -00 -10 -00 -00 -00 -02 -07 -00 -00 -14 -00 -00 -00 -00 -2e -74 -65 -78 -74 -00 -2e -62 -61 -72 -00 -2e -64 -61 -74 -61 -00 -2e -72 -65 -6c -61 -2e -74 -65 -78 -74 -00 -2e -72 -65 -6c -61 -2e -62 -61 -72 -00 -2e -72 -65 -6c -61 -2e -64 -61 -74 -61 -00 -2e -73 -74 -72 -74 -61 -62 -00 -2e -73 -79 -6d -74 -61 -62 -00 -2e -73 -68 -73 -74 -72 -74 -61 -62 -00 -00 -2d -00 -62 -61 -72 -00 -66 -6f -6f -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -04 -00 -f1 -ff -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -03 -00 -08 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -08 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -03 -00 -06 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -03 -00 -04 -00 -03 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -10 -00 -06 -00 -07 -00 -00 -00 -12 -00 -00 -00 -00 -00 -00 -00 -10 -00 -06 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -42 -00 -00 -00 -03 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -e4 -00 -00 -00 -4c -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -32 -00 -00 -00 -03 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -30 -01 -00 -00 -0b -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -3a -00 -00 -00 -02 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -3c -01 -00 -00 -80 -00 -00 -00 -02 -00 -00 -00 -06 -00 -00 -00 -04 -00 -00 -00 -10 -00 -00 -00 -01 -00 -00 -00 -01 -00 -00 -00 -06 -00 -00 -00 -00 -00 -00 -00 -40 -00 -00 -00 -15 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -10 -00 -00 -00 -00 -00 -00 -00 -12 -00 -00 -00 -04 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -58 -00 -00 -00 -24 -00 -00 -00 -03 -00 -00 -00 -04 -00 -00 -00 -04 -00 -00 -00 -0c -00 -00 -00 -07 -00 -00 -00 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -7c -00 -00 -00 -12 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -01 -00 -00 -00 -00 -00 -00 -00 -1d -00 -00 -00 -04 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -90 -00 -00 -00 -18 -00 -00 -00 -03 -00 -00 -00 -06 -00 -00 -00 -04 -00 -00 -00 -0c -00 -00 -00 -0c -00 -00 -00 -01 -00 -00 -00 -03 -00 -00 -00 -00 -00 -00 -00 -a8 -00 -00 -00 -18 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -04 -00 -00 -00 -00 -00 -00 -00 -27 -00 -00 -00 -04 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -c0 -00 -00 -00 -24 -00 -00 -00 -03 -00 -00 -00 -08 -00 -00 -00 -04 -00 -00 -00 -0c -00 -00 -00 diff --git a/modules/objfmts/elf/tests/gasx32/elf_gasx32_reloc.asm b/modules/objfmts/elf/tests/gasx32/elf_gasx32_reloc.asm deleted file mode 100644 index e015ce4b..00000000 --- a/modules/objfmts/elf/tests/gasx32/elf_gasx32_reloc.asm +++ /dev/null @@ -1,37 +0,0 @@ -.comm _ZEROVAR, 32, 16 -.comm _VAR, 16, 16 -.data -.org 0 -_ZEROVAR: -.org 0xa0 -.globl _VAR -.type _VAR, @object -.size _VAR, 16 -_VAR: -.4byte 0 -.4byte 0 -.4byte 0 -.4byte 0 -.org 0xc0 -_VAR2: -.org 0xe0 -.globl _VAR3 -_VAR3: - -.text -movq $0, %rax -movq _VAR, %rax -movq %rax, _VAR(%rip) -movq _VAR+8(%rip), %rcx -movlpd _VAR(%rip), %xmm1 - -movq _VAR2, %rax -movq %rax, _VAR2(%rip) -movq _VAR2+8(%rip), %rcx -movlpd _VAR2(%rip), %xmm1 - -movq _VAR3, %rax -movq %rax, _VAR3(%rip) -movq _VAR3+8(%rip), %rcx -movlpd _VAR3(%rip), %xmm1 - diff --git a/modules/objfmts/elf/tests/gasx32/elf_gasx32_reloc.hex b/modules/objfmts/elf/tests/gasx32/elf_gasx32_reloc.hex deleted file mode 100644 index 1b46fa18..00000000 --- a/modules/objfmts/elf/tests/gasx32/elf_gasx32_reloc.hex +++ /dev/null @@ -1,1016 +0,0 @@ -7f -45 -4c -46 -01 -01 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -01 -00 -3e -00 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -e0 -02 -00 -00 -00 -00 -00 -00 -34 -00 -00 -00 -00 -00 -28 -00 -07 -00 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -48 -c7 -c0 -00 -00 -00 -00 -48 -8b -04 -25 -00 -00 -00 -00 -48 -89 -05 -00 -00 -00 -00 -48 -8b -0d -00 -00 -00 -00 -66 -0f -12 -0d -00 -00 -00 -00 -48 -8b -04 -25 -00 -00 -00 -00 -48 -89 -05 -00 -00 -00 -00 -48 -8b -0d -00 -00 -00 -00 -66 -0f -12 -0d -00 -00 -00 -00 -48 -8b -04 -25 -00 -00 -00 -00 -48 -89 -05 -00 -00 -00 -00 -48 -8b -0d -00 -00 -00 -00 -66 -0f -12 -0d -00 -00 -00 -00 -00 -00 -00 -0b -00 -00 -00 -0a -06 -00 -00 -00 -00 -00 -00 -12 -00 -00 -00 -02 -06 -00 -00 -fc -ff -ff -ff -19 -00 -00 -00 -02 -06 -00 -00 -04 -00 -00 -00 -21 -00 -00 -00 -02 -06 -00 -00 -fc -ff -ff -ff -29 -00 -00 -00 -0a -03 -00 -00 -c0 -00 -00 -00 -30 -00 -00 -00 -02 -03 -00 -00 -bc -00 -00 -00 -37 -00 -00 -00 -02 -03 -00 -00 -c4 -00 -00 -00 -3f -00 -00 -00 -02 -03 -00 -00 -bc -00 -00 -00 -47 -00 -00 -00 -0a -07 -00 -00 -00 -00 -00 -00 -4e -00 -00 -00 -02 -07 -00 -00 -fc -ff -ff -ff -55 -00 -00 -00 -02 -07 -00 -00 -04 -00 -00 -00 -5d -00 -00 -00 -02 -07 -00 -00 -fc -ff -ff -ff -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -2e -74 -65 -78 -74 -00 -2e -64 -61 -74 -61 -00 -2e -72 -65 -6c -61 -2e -74 -65 -78 -74 -00 -2e -73 -74 -72 -74 -61 -62 -00 -2e -73 -79 -6d -74 -61 -62 -00 -2e -73 -68 -73 -74 -72 -74 -61 -62 -00 -00 -00 -00 -2d -00 -5f -56 -41 -52 -00 -5f -5a -45 -52 -4f -56 -41 -52 -00 -5f -56 -41 -52 -33 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -04 -00 -f1 -ff -00 -00 -00 -00 -c0 -00 -00 -00 -00 -00 -00 -00 -00 -00 -06 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -03 -00 -06 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -03 -00 -04 -00 -08 -00 -00 -00 -00 -00 -00 -00 -20 -00 -00 -00 -10 -00 -06 -00 -03 -00 -00 -00 -a0 -00 -00 -00 -10 -00 -00 -00 -11 -00 -06 -00 -11 -00 -00 -00 -e0 -00 -00 -00 -00 -00 -00 -00 -10 -00 -06 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -28 -00 -00 -00 -03 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -14 -02 -00 -00 -32 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -18 -00 -00 -00 -03 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -48 -02 -00 -00 -17 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -20 -00 -00 -00 -02 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -60 -02 -00 -00 -80 -00 -00 -00 -02 -00 -00 -00 -05 -00 -00 -00 -04 -00 -00 -00 -10 -00 -00 -00 -01 -00 -00 -00 -01 -00 -00 -00 -06 -00 -00 -00 -00 -00 -00 -00 -40 -00 -00 -00 -61 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -10 -00 -00 -00 -00 -00 -00 -00 -0d -00 -00 -00 -04 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -a4 -00 -00 -00 -90 -00 -00 -00 -03 -00 -00 -00 -04 -00 -00 -00 -04 -00 -00 -00 -0c -00 -00 -00 -07 -00 -00 -00 -01 -00 -00 -00 -03 -00 -00 -00 -00 -00 -00 -00 -34 -01 -00 -00 -e0 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -04 -00 -00 -00 -00 -00 -00 -00 diff --git a/modules/objfmts/elf/tests/gasx32/elf_gasx32_ssym.asm b/modules/objfmts/elf/tests/gasx32/elf_gasx32_ssym.asm deleted file mode 100644 index b7203f62..00000000 --- a/modules/objfmts/elf/tests/gasx32/elf_gasx32_ssym.asm +++ /dev/null @@ -1,10 +0,0 @@ -.text -foo: -movl %eax, foo@PLT -movl %eax, foo@GOTPCREL -movl %eax, bar@TLSGD -movl %eax, bar@TLSLD -movl %eax, bar@GOTTPOFF -movl %eax, bar@TPOFF -movl %eax, bar@DTPOFF -movl %eax, foo@GOT diff --git a/modules/objfmts/elf/tests/gasx32/elf_gasx32_ssym.hex b/modules/objfmts/elf/tests/gasx32/elf_gasx32_ssym.hex deleted file mode 100644 index cac39900..00000000 --- a/modules/objfmts/elf/tests/gasx32/elf_gasx32_ssym.hex +++ /dev/null @@ -1,592 +0,0 @@ -7f -45 -4c -46 -01 -01 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -01 -00 -3e -00 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -60 -01 -00 -00 -00 -00 -00 -00 -34 -00 -00 -00 -00 -00 -28 -00 -06 -00 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -89 -04 -25 -00 -00 -00 -00 -89 -04 -25 -00 -00 -00 -00 -89 -04 -25 -00 -00 -00 -00 -89 -04 -25 -00 -00 -00 -00 -89 -04 -25 -00 -00 -00 -00 -89 -04 -25 -00 -00 -00 -00 -89 -04 -25 -00 -00 -00 -00 -89 -04 -25 -00 -00 -00 -00 -03 -00 -00 -00 -04 -02 -00 -00 -00 -00 -00 -00 -0a -00 -00 -00 -09 -02 -00 -00 -00 -00 -00 -00 -11 -00 -00 -00 -13 -04 -00 -00 -00 -00 -00 -00 -18 -00 -00 -00 -14 -04 -00 -00 -00 -00 -00 -00 -1f -00 -00 -00 -16 -04 -00 -00 -00 -00 -00 -00 -26 -00 -00 -00 -17 -04 -00 -00 -00 -00 -00 -00 -2d -00 -00 -00 -15 -04 -00 -00 -00 -00 -00 -00 -34 -00 -00 -00 -03 -02 -00 -00 -00 -00 -00 -00 -00 -2e -74 -65 -78 -74 -00 -2e -72 -65 -6c -61 -2e -74 -65 -78 -74 -00 -2e -73 -74 -72 -74 -61 -62 -00 -2e -73 -79 -6d -74 -61 -62 -00 -2e -73 -68 -73 -74 -72 -74 -61 -62 -00 -00 -2d -00 -62 -61 -72 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -04 -00 -f1 -ff -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -04 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -03 -00 -04 -00 -03 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -16 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -22 -00 -00 -00 -03 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -d8 -00 -00 -00 -2c -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -12 -00 -00 -00 -03 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -04 -01 -00 -00 -07 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -1a -00 -00 -00 -02 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -0c -01 -00 -00 -50 -00 -00 -00 -02 -00 -00 -00 -04 -00 -00 -00 -04 -00 -00 -00 -10 -00 -00 -00 -01 -00 -00 -00 -01 -00 -00 -00 -06 -00 -00 -00 -00 -00 -00 -00 -40 -00 -00 -00 -38 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -10 -00 -00 -00 -00 -00 -00 -00 -07 -00 -00 -00 -04 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -78 -00 -00 -00 -60 -00 -00 -00 -03 -00 -00 -00 -04 -00 -00 -00 -04 -00 -00 -00 -0c -00 -00 -00 diff --git a/modules/objfmts/elf/tests/gasx32/elf_gasx32_test.sh b/modules/objfmts/elf/tests/gasx32/elf_gasx32_test.sh deleted file mode 100755 index f5372cb5..00000000 --- a/modules/objfmts/elf/tests/gasx32/elf_gasx32_test.sh +++ /dev/null @@ -1,3 +0,0 @@ -#! /bin/sh -${srcdir}/out_test.sh elf_gasx32_test modules/objfmts/elf/tests/gasx32 "GAS elf-x32 objfmt" "-f elfx32 -p gas" ".o" -exit $? diff --git a/modules/objfmts/elf/tests/x32/Makefile.inc b/modules/objfmts/elf/tests/x32/Makefile.inc deleted file mode 100644 index 2db20525..00000000 --- a/modules/objfmts/elf/tests/x32/Makefile.inc +++ /dev/null @@ -1,11 +0,0 @@ -TESTS += modules/objfmts/elf/tests/x32/elf_x32_test.sh - -EXTRA_DIST += modules/objfmts/elf/tests/x32/elf_x32_test.sh -EXTRA_DIST += modules/objfmts/elf/tests/x32/elf-rip.asm -EXTRA_DIST += modules/objfmts/elf/tests/x32/elf-rip.hex -EXTRA_DIST += modules/objfmts/elf/tests/x32/elfsox32.asm -EXTRA_DIST += modules/objfmts/elf/tests/x32/elfsox32.hex -EXTRA_DIST += modules/objfmts/elf/tests/x32/gotpcrel.asm -EXTRA_DIST += modules/objfmts/elf/tests/x32/gotpcrel.hex -EXTRA_DIST += modules/objfmts/elf/tests/x32/multiplefixup.asm -EXTRA_DIST += modules/objfmts/elf/tests/x32/multiplefixup.hex diff --git a/modules/objfmts/elf/tests/x32/elf-rip.asm b/modules/objfmts/elf/tests/x32/elf-rip.asm deleted file mode 100644 index 5f10f096..00000000 --- a/modules/objfmts/elf/tests/x32/elf-rip.asm +++ /dev/null @@ -1,7 +0,0 @@ -[bits 64] -[extern sym] -mov eax, [rip] -mov eax, [rip+2] -mov eax, [rip+sym] -mov eax, [sym wrt rip] -call sym diff --git a/modules/objfmts/elf/tests/x32/elf-rip.hex b/modules/objfmts/elf/tests/x32/elf-rip.hex deleted file mode 100644 index be5da687..00000000 --- a/modules/objfmts/elf/tests/x32/elf-rip.hex +++ /dev/null @@ -1,496 +0,0 @@ -7f -45 -4c -46 -01 -01 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -01 -00 -3e -00 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -01 -00 -00 -00 -00 -00 -00 -34 -00 -00 -00 -00 -00 -28 -00 -06 -00 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -8b -05 -00 -00 -00 -00 -8b -05 -02 -00 -00 -00 -8b -05 -00 -00 -00 -00 -8b -05 -00 -00 -00 -00 -e8 -00 -00 -00 -00 -00 -00 -00 -0e -00 -00 -00 -0a -03 -00 -00 -00 -00 -00 -00 -14 -00 -00 -00 -02 -03 -00 -00 -fc -ff -ff -ff -19 -00 -00 -00 -02 -03 -00 -00 -fc -ff -ff -ff -00 -2e -74 -65 -78 -74 -00 -2e -72 -65 -6c -61 -2e -74 -65 -78 -74 -00 -2e -73 -74 -72 -74 -61 -62 -00 -2e -73 -79 -6d -74 -61 -62 -00 -2e -73 -68 -73 -74 -72 -74 -61 -62 -00 -00 -2d -00 -73 -79 -6d -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -04 -00 -f1 -ff -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -03 -00 -04 -00 -03 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -10 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -22 -00 -00 -00 -03 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -84 -00 -00 -00 -2c -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -12 -00 -00 -00 -03 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -b0 -00 -00 -00 -07 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -1a -00 -00 -00 -02 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -b8 -00 -00 -00 -40 -00 -00 -00 -02 -00 -00 -00 -03 -00 -00 -00 -04 -00 -00 -00 -10 -00 -00 -00 -01 -00 -00 -00 -01 -00 -00 -00 -06 -00 -00 -00 -00 -00 -00 -00 -40 -00 -00 -00 -1d -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -10 -00 -00 -00 -00 -00 -00 -00 -07 -00 -00 -00 -04 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -60 -00 -00 -00 -24 -00 -00 -00 -03 -00 -00 -00 -04 -00 -00 -00 -04 -00 -00 -00 -0c -00 -00 -00 diff --git a/modules/objfmts/elf/tests/x32/elf_x32_test.sh b/modules/objfmts/elf/tests/x32/elf_x32_test.sh deleted file mode 100755 index 39618166..00000000 --- a/modules/objfmts/elf/tests/x32/elf_x32_test.sh +++ /dev/null @@ -1,3 +0,0 @@ -#! /bin/sh -${srcdir}/out_test.sh elf_x32_test modules/objfmts/elf/tests/x32 "elf-x32 objfmt" "-f elf -m x32" ".o" -exit $? diff --git a/modules/objfmts/elf/tests/x32/elfsox32.asm b/modules/objfmts/elf/tests/x32/elfsox32.asm deleted file mode 100644 index 931c7ffe..00000000 --- a/modules/objfmts/elf/tests/x32/elfsox32.asm +++ /dev/null @@ -1,90 +0,0 @@ -; This code is UNTESTED, and almost certainly DOES NOT WORK! -; Do NOT use this as an example of how to write AMD64 shared libraries! -; This code is simply to test the AMD64 ELF WRT relocations. - -; This file should test the following: -; [1] Define and export a global text-section symbol -; [2] Define and export a global data-section symbol -; [3] Define and export a global BSS-section symbol -; [4] Define a non-global text-section symbol -; [5] Define a non-global data-section symbol -; [6] Define a non-global BSS-section symbol -; [7] Define a COMMON symbol -; [8] Define a NASM local label -; [9] Reference a NASM local label -; [10] Import an external symbol -; [11] Make a PC-relative call to an external symbol -; [12] Reference a text-section symbol in the text section -; [13] Reference a data-section symbol in the text section -; [14] Reference a BSS-section symbol in the text section -; [15] Reference a text-section symbol in the data section -; [16] Reference a data-section symbol in the data section -; [17] Reference a BSS-section symbol in the data section - - [BITS 64] - [GLOBAL lrotate:function] ; [1] - [GLOBAL greet:function] ; [1] - [GLOBAL asmstr:data asmstr.end-asmstr] ; [2] - [GLOBAL textptr:data 4] ; [2] - [GLOBAL selfptr:data 4] ; [2] - [GLOBAL integer:data 4] ; [3] - [EXTERN printf] ; [10] - [COMMON commvar 4:4] ; [7] - [EXTERN _GLOBAL_OFFSET_TABLE_] - - [SECTION .text] - -; prototype: long lrotate(long x, int num); -lrotate: ; [1] - push rbp - mov rbp,rsp - mov rax,[rbp+8] - mov rcx,[rbp+12] -.label rol rax,1 ; [4] [8] - loop .label ; [9] [12] - mov rsp,rbp - pop rbp - ret - -; prototype: void greet(void); -greet push rbx ; we'll use RBX for GOT, so save it - mov rbx,[integer wrt ..gotpcrel wrt rip] - mov rax,[rbx] ; [14] - inc rax - mov rbx,[_GLOBAL_OFFSET_TABLE_ wrt ..gotpcrel wrt rip] - mov [rbx+localint wrt ..got],eax ; [14] - mov rax,[rbx+commvar wrt ..got] - push qword [rax] - mov rax,[rbx+localptr wrt ..got] ; [13] - push qword [rax] - mov rax,[rbx+integer wrt ..got] ; [1] [14] - push qword [rax] - lea rax,[rbx+printfstr wrt ..got] - push rax ; [13] - call printf wrt ..plt ; [11] - add rsp,16 - pop rbx - ret - - [SECTION .data] - -; a string -asmstr db 'hello, world', 0 ; [2] -.end - -; a string for Printf -printfstr db "integer==%d, localint==%d, commvar=%d" - db 10, 0 - -; some pointers -localptr dd localint ; [5] [17] -textptr dd greet wrt ..sym ; [15] -selfptr dd selfptr wrt ..sym ; [16] - - [SECTION .bss] - -; an integer -integer resd 1 ; [3] - -; a local integer -localint resd 1 ; [6] diff --git a/modules/objfmts/elf/tests/x32/elfsox32.hex b/modules/objfmts/elf/tests/x32/elfsox32.hex deleted file mode 100644 index d423b2de..00000000 --- a/modules/objfmts/elf/tests/x32/elfsox32.hex +++ /dev/null @@ -1,1176 +0,0 @@ -7f -45 -4c -46 -01 -01 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -01 -00 -3e -00 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -30 -03 -00 -00 -00 -00 -00 -00 -34 -00 -00 -00 -00 -00 -28 -00 -09 -00 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -55 -48 -89 -e5 -48 -8b -45 -08 -48 -8b -4d -0c -48 -d1 -c0 -e2 -fb -48 -89 -ec -5d -c3 -53 -48 -8b -1d -00 -00 -00 -00 -48 -8b -03 -48 -ff -c0 -48 -8b -1d -00 -00 -00 -00 -89 -83 -00 -00 -00 -00 -48 -8b -83 -00 -00 -00 -00 -ff -30 -48 -8b -83 -00 -00 -00 -00 -ff -30 -48 -8b -83 -00 -00 -00 -00 -ff -30 -48 -8d -83 -00 -00 -00 -00 -50 -e8 -00 -00 -00 -00 -48 -83 -c4 -10 -5b -c3 -00 -1a -00 -00 -00 -09 -0f -00 -00 -fc -ff -ff -ff -27 -00 -00 -00 -09 -12 -00 -00 -fc -ff -ff -ff -2d -00 -00 -00 -03 -06 -00 -00 -00 -00 -00 -00 -34 -00 -00 -00 -03 -11 -00 -00 -00 -00 -00 -00 -3d -00 -00 -00 -03 -05 -00 -00 -00 -00 -00 -00 -46 -00 -00 -00 -03 -0f -00 -00 -00 -00 -00 -00 -4f -00 -00 -00 -03 -04 -00 -00 -00 -00 -00 -00 -55 -00 -00 -00 -04 -10 -00 -00 -fc -ff -ff -ff -68 -65 -6c -6c -6f -2c -20 -77 -6f -72 -6c -64 -00 -69 -6e -74 -65 -67 -65 -72 -3d -3d -25 -64 -2c -20 -6c -6f -63 -61 -6c -69 -6e -74 -3d -3d -25 -64 -2c -20 -63 -6f -6d -6d -76 -61 -72 -3d -25 -64 -0a -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -34 -00 -00 -00 -0a -02 -00 -00 -04 -00 -00 -00 -38 -00 -00 -00 -0a -0b -00 -00 -00 -00 -00 -00 -3c -00 -00 -00 -0a -0e -00 -00 -00 -00 -00 -00 -00 -2e -74 -65 -78 -74 -00 -2e -64 -61 -74 -61 -00 -2e -62 -73 -73 -00 -2e -72 -65 -6c -61 -2e -74 -65 -78 -74 -00 -2e -72 -65 -6c -61 -2e -64 -61 -74 -61 -00 -2e -73 -74 -72 -74 -61 -62 -00 -2e -73 -79 -6d -74 -61 -62 -00 -2e -73 -68 -73 -74 -72 -74 -61 -62 -00 -00 -00 -00 -2d -00 -6c -72 -6f -74 -61 -74 -65 -00 -67 -72 -65 -65 -74 -00 -61 -73 -6d -73 -74 -72 -00 -74 -65 -78 -74 -70 -74 -72 -00 -73 -65 -6c -66 -70 -74 -72 -00 -69 -6e -74 -65 -67 -65 -72 -00 -70 -72 -69 -6e -74 -66 -00 -63 -6f -6d -6d -76 -61 -72 -00 -5f -47 -4c -4f -42 -41 -4c -5f -4f -46 -46 -53 -45 -54 -5f -54 -41 -42 -4c -45 -5f -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -04 -00 -f1 -ff -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -03 -00 -08 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -03 -00 -06 -00 -00 -00 -00 -00 -0d -00 -00 -00 -00 -00 -00 -00 -00 -00 -06 -00 -00 -00 -00 -00 -34 -00 -00 -00 -00 -00 -00 -00 -00 -00 -06 -00 -00 -00 -00 -00 -04 -00 -00 -00 -00 -00 -00 -00 -00 -00 -08 -00 -00 -00 -00 -00 -0c -00 -00 -00 -00 -00 -00 -00 -00 -00 -04 -00 -00 -00 -00 -00 -0d -00 -00 -00 -00 -00 -00 -00 -00 -00 -06 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -03 -00 -04 -00 -03 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -12 -00 -04 -00 -0b -00 -00 -00 -16 -00 -00 -00 -00 -00 -00 -00 -12 -00 -04 -00 -11 -00 -00 -00 -00 -00 -00 -00 -0d -00 -00 -00 -11 -00 -06 -00 -18 -00 -00 -00 -38 -00 -00 -00 -04 -00 -00 -00 -11 -00 -06 -00 -20 -00 -00 -00 -3c -00 -00 -00 -04 -00 -00 -00 -11 -00 -06 -00 -28 -00 -00 -00 -00 -00 -00 -00 -04 -00 -00 -00 -11 -00 -08 -00 -30 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -10 -00 -00 -00 -37 -00 -00 -00 -04 -00 -00 -00 -04 -00 -00 -00 -10 -00 -f2 -ff -3f -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -10 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -38 -00 -00 -00 -03 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -64 -01 -00 -00 -42 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -28 -00 -00 -00 -03 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -a8 -01 -00 -00 -55 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -30 -00 -00 -00 -02 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -02 -00 -00 -30 -01 -00 -00 -02 -00 -00 -00 -0a -00 -00 -00 -04 -00 -00 -00 -10 -00 -00 -00 -01 -00 -00 -00 -01 -00 -00 -00 -06 -00 -00 -00 -00 -00 -00 -00 -40 -00 -00 -00 -5f -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -10 -00 -00 -00 -00 -00 -00 -00 -12 -00 -00 -00 -04 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -a0 -00 -00 -00 -60 -00 -00 -00 -03 -00 -00 -00 -04 -00 -00 -00 -04 -00 -00 -00 -0c -00 -00 -00 -07 -00 -00 -00 -01 -00 -00 -00 -03 -00 -00 -00 -00 -00 -00 -00 -00 -01 -00 -00 -40 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -04 -00 -00 -00 -00 -00 -00 -00 -1d -00 -00 -00 -04 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -40 -01 -00 -00 -24 -00 -00 -00 -03 -00 -00 -00 -06 -00 -00 -00 -04 -00 -00 -00 -0c -00 -00 -00 -0d -00 -00 -00 -08 -00 -00 -00 -03 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -08 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -04 -00 -00 -00 -00 -00 -00 -00 diff --git a/modules/objfmts/elf/tests/x32/gotpcrel.asm b/modules/objfmts/elf/tests/x32/gotpcrel.asm deleted file mode 100644 index c3d12383..00000000 --- a/modules/objfmts/elf/tests/x32/gotpcrel.asm +++ /dev/null @@ -1,6 +0,0 @@ -var: -mov rax, [var wrt ..got] -mov rax, [var wrt ..gotpcrel] ; should be error/warning? -mov rax, [rel var wrt ..got] ; automatic promotion to GOTPCREL -mov rax, [rel var wrt ..gotpcrel] - diff --git a/modules/objfmts/elf/tests/x32/gotpcrel.hex b/modules/objfmts/elf/tests/x32/gotpcrel.hex deleted file mode 100644 index 695cf7d6..00000000 --- a/modules/objfmts/elf/tests/x32/gotpcrel.hex +++ /dev/null @@ -1,496 +0,0 @@ -7f -45 -4c -46 -01 -01 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -01 -00 -3e -00 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -01 -00 -00 -00 -00 -00 -00 -34 -00 -00 -00 -00 -00 -28 -00 -06 -00 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -48 -8b -04 -25 -00 -00 -00 -00 -48 -8b -04 -25 -00 -00 -00 -00 -48 -8b -05 -00 -00 -00 -00 -48 -8b -05 -00 -00 -00 -00 -00 -00 -04 -00 -00 -00 -03 -02 -00 -00 -00 -00 -00 -00 -0c -00 -00 -00 -09 -02 -00 -00 -00 -00 -00 -00 -13 -00 -00 -00 -09 -02 -00 -00 -fc -ff -ff -ff -1a -00 -00 -00 -09 -02 -00 -00 -fc -ff -ff -ff -00 -2e -74 -65 -78 -74 -00 -2e -72 -65 -6c -61 -2e -74 -65 -78 -74 -00 -2e -73 -74 -72 -74 -61 -62 -00 -2e -73 -79 -6d -74 -61 -62 -00 -2e -73 -68 -73 -74 -72 -74 -61 -62 -00 -00 -2d -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -04 -00 -f1 -ff -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -04 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -03 -00 -04 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -22 -00 -00 -00 -03 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -90 -00 -00 -00 -2c -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -12 -00 -00 -00 -03 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -bc -00 -00 -00 -03 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -1a -00 -00 -00 -02 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -c0 -00 -00 -00 -40 -00 -00 -00 -02 -00 -00 -00 -04 -00 -00 -00 -04 -00 -00 -00 -10 -00 -00 -00 -01 -00 -00 -00 -01 -00 -00 -00 -06 -00 -00 -00 -00 -00 -00 -00 -40 -00 -00 -00 -1e -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -10 -00 -00 -00 -00 -00 -00 -00 -07 -00 -00 -00 -04 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -60 -00 -00 -00 -30 -00 -00 -00 -03 -00 -00 -00 -04 -00 -00 -00 -04 -00 -00 -00 -0c -00 -00 -00 diff --git a/modules/objfmts/elf/tests/x32/multiplefixup.asm b/modules/objfmts/elf/tests/x32/multiplefixup.asm deleted file mode 100644 index ec253cbb..00000000 --- a/modules/objfmts/elf/tests/x32/multiplefixup.asm +++ /dev/null @@ -1,8 +0,0 @@ -[section .data] -foobar: - dq 42 -[section .text] -foo: - times 4 mov rax, [rel foobar] - times 4 mov rax, [foobar] - times 4 jmp foo diff --git a/modules/objfmts/elf/tests/x32/multiplefixup.hex b/modules/objfmts/elf/tests/x32/multiplefixup.hex deleted file mode 100644 index a1874282..00000000 --- a/modules/objfmts/elf/tests/x32/multiplefixup.hex +++ /dev/null @@ -1,680 +0,0 @@ -7f -45 -4c -46 -01 -01 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -01 -00 -3e -00 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -90 -01 -00 -00 -00 -00 -00 -00 -34 -00 -00 -00 -00 -00 -28 -00 -07 -00 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -48 -8b -05 -00 -00 -00 -00 -48 -8b -05 -00 -00 -00 -00 -48 -8b -05 -00 -00 -00 -00 -48 -8b -05 -00 -00 -00 -00 -48 -8b -04 -25 -00 -00 -00 -00 -48 -8b -04 -25 -00 -00 -00 -00 -48 -8b -04 -25 -00 -00 -00 -00 -48 -8b -04 -25 -00 -00 -00 -00 -eb -c2 -eb -c0 -eb -be -eb -bc -03 -00 -00 -00 -02 -04 -00 -00 -fc -ff -ff -ff -0a -00 -00 -00 -02 -04 -00 -00 -fc -ff -ff -ff -11 -00 -00 -00 -02 -04 -00 -00 -fc -ff -ff -ff -18 -00 -00 -00 -02 -04 -00 -00 -fc -ff -ff -ff -20 -00 -00 -00 -0a -04 -00 -00 -00 -00 -00 -00 -28 -00 -00 -00 -0a -04 -00 -00 -00 -00 -00 -00 -30 -00 -00 -00 -0a -04 -00 -00 -00 -00 -00 -00 -38 -00 -00 -00 -0a -04 -00 -00 -00 -00 -00 -00 -2a -00 -00 -00 -00 -00 -00 -00 -00 -2e -74 -65 -78 -74 -00 -2e -64 -61 -74 -61 -00 -2e -72 -65 -6c -61 -2e -74 -65 -78 -74 -00 -2e -73 -74 -72 -74 -61 -62 -00 -2e -73 -79 -6d -74 -61 -62 -00 -2e -73 -68 -73 -74 -72 -74 -61 -62 -00 -00 -00 -00 -2d -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -04 -00 -f1 -ff -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -04 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -06 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -03 -00 -06 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -03 -00 -04 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -28 -00 -00 -00 -03 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -ec -00 -00 -00 -32 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -18 -00 -00 -00 -03 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -20 -01 -00 -00 -03 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -20 -00 -00 -00 -02 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -24 -01 -00 -00 -60 -00 -00 -00 -02 -00 -00 -00 -06 -00 -00 -00 -04 -00 -00 -00 -10 -00 -00 -00 -01 -00 -00 -00 -01 -00 -00 -00 -06 -00 -00 -00 -00 -00 -00 -00 -40 -00 -00 -00 -44 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -10 -00 -00 -00 -00 -00 -00 -00 -0d -00 -00 -00 -04 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -84 -00 -00 -00 -60 -00 -00 -00 -03 -00 -00 -00 -04 -00 -00 -00 -04 -00 -00 -00 -0c -00 -00 -00 -07 -00 -00 -00 -01 -00 -00 -00 -03 -00 -00 -00 -00 -00 -00 -00 -e4 -00 -00 -00 -08 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -04 -00 -00 -00 -00 -00 -00 -00 diff --git a/modules/objfmts/macho/CMakeLists.txt b/modules/objfmts/macho/CMakeLists.txt deleted file mode 100644 index cb5f4934..00000000 --- a/modules/objfmts/macho/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -YASM_ADD_MODULE(objfmt_macho - objfmts/macho/macho-objfmt.c - ) -list(APPEND YASM_MODULES objfmt_macho32) -list(APPEND YASM_MODULES objfmt_macho64) diff --git a/modules/objfmts/macho/Makefile.inc b/modules/objfmts/macho/Makefile.inc index 39eff297..be9f4bcb 100644 --- a/modules/objfmts/macho/Makefile.inc +++ b/modules/objfmts/macho/Makefile.inc @@ -1,3 +1,5 @@ +# $Id$ + libyasm_a_SOURCES += modules/objfmts/macho/macho-objfmt.c YASM_MODULES += objfmt_macho objfmt_macho32 objfmt_macho64 diff --git a/modules/objfmts/macho/macho-objfmt.c b/modules/objfmts/macho/macho-objfmt.c index 7fec0147..5a988b91 100644 --- a/modules/objfmts/macho/macho-objfmt.c +++ b/modules/objfmts/macho/macho-objfmt.c @@ -28,7 +28,7 @@ /* notes: This implementation is rather basic. There are several implementation issues to be sorted out for full compliance and error resilience. - Some examples are given below (nasm syntax). + Some examples are given below (nasm syntax). 1) section placement Mach-O requires BSS sections to be placed last in object files. This @@ -50,8 +50,8 @@ 2.2) data referencing in 64 bit mode While ELF allows 32 bit absolute relocations in 64 bit mode, Mach-O does not. Therefore code like - lea rbx,[_foo] ;48 8d 1c 25 00 00 00 00 - mov rcx,[_bar] ;48 8b 0c 25 00 00 00 00 + lea rbx,[_foo] ;48 8d 1c 25 00 00 00 00 + mov rcx,[_bar] ;48 8b 0c 25 00 00 00 00 with a 32 bit address field cannot be relocated into an address >= 0x100000000 (OSX actually uses that). @@ -62,7 +62,7 @@ not implemented in this object format. The recommended was is PC relative code (called RIP-relative in x86-64). So instead of the lines above, just write: lea rbx,[_foo wrt rip] - mov rcx,[_bar wrt rip] + mov rcx,[_bar wrt rip] 2.3) section/data alignment Normally, you specify sections with a specific alignment @@ -88,120 +88,135 @@ Will currently produce an error though the necessary means are provided by the Mach-O specification. + 3) position independend coding (64 Bit) + Mach-O provides the relocation features X86_64_RELOC_GOT_LOAD and + X86_64_RELOC_GOT for C-compatible global offset tables. This IS NOT + implemented yet, sorry. + + 4) symbol naming for global and external symbols + BSD, Windows and MacOS-X use underscores for global symbols, + where ELF/Linux does not. This file contains simple means of adding + underscores to symbols by defining "AUTO_UNDERSCORE" but that + can be considered not more than a hack. For cross-platform coding, + use two symbols for your routines and referenced data. + */ #include +/*@unused@*/ RCSID("$Id$"); +/* optional: automatically prefix underscores to global exported symbols */ +/*#define AUTO_UNDERSCORE*/ + +#define YASM_LIB_INTERNAL +#define YASM_BC_INTERNAL +#define YASM_EXPR_INTERNAL #include /* MACH-O DEFINES */ /* Mach-O in-file header structure sizes (32 BIT, see below for 64 bit defs) */ -#define MACHO_HEADER_SIZE 28 -#define MACHO_SEGCMD_SIZE 56 -#define MACHO_SECTCMD_SIZE 68 -#define MACHO_SYMCMD_SIZE 24 -#define MACHO_NLIST_SIZE 12 -#define MACHO_RELINFO_SIZE 8 -#define MACHO_BUILDVERSION_SIZE 24 +#define MACHO_HEADER_SIZE 28 +#define MACHO_SEGCMD_SIZE 56 +#define MACHO_SECTCMD_SIZE 68 +#define MACHO_SYMCMD_SIZE 24 +#define MACHO_NLIST_SIZE 12 +#define MACHO_RELINFO_SIZE 8 /* 64 bit sizes */ -#define MACHO_HEADER64_SIZE 32 -#define MACHO_SEGCMD64_SIZE 72 -#define MACHO_SECTCMD64_SIZE 80 -#define MACHO_NLIST64_SIZE 16 -#define MACHO_RELINFO64_SIZE 8 +#define MACHO_HEADER64_SIZE 32 +#define MACHO_SEGCMD64_SIZE 72 +#define MACHO_SECTCMD64_SIZE 80 +#define MACHO_NLIST64_SIZE 16 +#define MACHO_RELINFO64_SIZE 8 /* Mach-O file header values */ -#define MH_MAGIC 0xfeedface -#define MH_MAGIC_64 0xfeedfacf +#define MH_MAGIC 0xfeedface +#define MH_MAGIC_64 0xfeedfacf /* CPU machine type */ -#define CPU_TYPE_I386 7 /* x86 platform */ -#define CPU_TYPE_X86_64 (CPU_TYPE_I386|CPU_ARCH_ABI64) -#define CPU_ARCH_ABI64 0x01000000 /* 64 bit ABI */ +#define CPU_TYPE_I386 7 /* x86 platform */ +#define CPU_TYPE_X86_64 (CPU_TYPE_I386|CPU_ARCH_ABI64) +#define CPU_ARCH_ABI64 0x01000000 /* 64 bit ABI */ /* CPU machine subtype, e.g. processor */ -#define CPU_SUBTYPE_I386_ALL 3 /* all-x86 compatible */ -#define CPU_SUBTYPE_X86_64_ALL CPU_SUBTYPE_I386_ALL -#define CPU_SUBTYPE_386 3 -#define CPU_SUBTYPE_486 4 -#define CPU_SUBTYPE_486SX (4 + 128) -#define CPU_SUBTYPE_586 5 -#define CPU_SUBTYPE_INTEL(f, m) ((f) + ((m) << 4)) -#define CPU_SUBTYPE_PENT CPU_SUBTYPE_INTEL(5, 0) -#define CPU_SUBTYPE_PENTPRO CPU_SUBTYPE_INTEL(6, 1) -#define CPU_SUBTYPE_PENTII_M3 CPU_SUBTYPE_INTEL(6, 3) -#define CPU_SUBTYPE_PENTII_M5 CPU_SUBTYPE_INTEL(6, 5) -#define CPU_SUBTYPE_PENTIUM_4 CPU_SUBTYPE_INTEL(10, 0) +#define CPU_SUBTYPE_I386_ALL 3 /* all-x86 compatible */ +#define CPU_SUBTYPE_X86_64_ALL CPU_SUBTYPE_I386_ALL +#define CPU_SUBTYPE_386 3 +#define CPU_SUBTYPE_486 4 +#define CPU_SUBTYPE_486SX (4 + 128) +#define CPU_SUBTYPE_586 5 +#define CPU_SUBTYPE_INTEL(f, m) ((f) + ((m) << 4)) +#define CPU_SUBTYPE_PENT CPU_SUBTYPE_INTEL(5, 0) +#define CPU_SUBTYPE_PENTPRO CPU_SUBTYPE_INTEL(6, 1) +#define CPU_SUBTYPE_PENTII_M3 CPU_SUBTYPE_INTEL(6, 3) +#define CPU_SUBTYPE_PENTII_M5 CPU_SUBTYPE_INTEL(6, 5) +#define CPU_SUBTYPE_PENTIUM_4 CPU_SUBTYPE_INTEL(10, 0) -#define CPU_SUBTYPE_INTEL_FAMILY(x) ((x) & 15) -#define CPU_SUBTYPE_INTEL_FAMILY_MAX 15 +#define CPU_SUBTYPE_INTEL_FAMILY(x) ((x) & 15) +#define CPU_SUBTYPE_INTEL_FAMILY_MAX 15 -#define CPU_SUBTYPE_INTEL_MODEL(x) ((x) >> 4) -#define CPU_SUBTYPE_INTEL_MODEL_ALL 0 +#define CPU_SUBTYPE_INTEL_MODEL(x) ((x) >> 4) +#define CPU_SUBTYPE_INTEL_MODEL_ALL 0 -#define MH_OBJECT 0x1 /* object file */ +#define MH_OBJECT 0x1 /* object file */ -#define LC_SEGMENT 0x1 /* segment load command */ -#define LC_SYMTAB 0x2 /* symbol table load command */ -#define LC_SEGMENT_64 0x19 /* segment load command */ -#define LC_BUILD_VERSION 0x32 /* build version command */ +#define LC_SEGMENT 0x1 /* segment load command */ +#define LC_SYMTAB 0x2 /* symbol table load command */ +#define LC_SEGMENT_64 0x19 /* segment load command */ -/* Values for platform field in build version command */ -#define PLATFORM_MACOS 1 -#define VM_PROT_NONE 0x00 -#define VM_PROT_READ 0x01 -#define VM_PROT_WRITE 0x02 -#define VM_PROT_EXECUTE 0x04 +#define VM_PROT_NONE 0x00 +#define VM_PROT_READ 0x01 +#define VM_PROT_WRITE 0x02 +#define VM_PROT_EXECUTE 0x04 -#define VM_PROT_DEFAULT (VM_PROT_READ | VM_PROT_WRITE | VM_PROT_EXECUTE) -#define VM_PROT_ALL (VM_PROT_READ | VM_PROT_WRITE | VM_PROT_EXECUTE) +#define VM_PROT_DEFAULT (VM_PROT_READ | VM_PROT_WRITE | VM_PROT_EXECUTE) +#define VM_PROT_ALL (VM_PROT_READ | VM_PROT_WRITE | VM_PROT_EXECUTE) -#define SECTION_TYPE 0x000000ff /* section type mask */ +#define SECTION_TYPE 0x000000ff /* section type mask */ #define SECTION_ATTRIBUTES 0xffffff00UL/* section attributes mask */ -#define S_REGULAR 0x0 /* standard section */ -#define S_ZEROFILL 0x1 /* zerofill, in-memory only */ -#define S_CSTRING_LITERALS 0x2 /* literal C strings */ -#define S_4BYTE_LITERALS 0x3 /* only 4-byte literals */ -#define S_8BYTE_LITERALS 0x4 /* only 8-byte literals */ -#define S_LITERAL_POINTERS 0x5 /* only pointers to literals */ -#define S_NON_LAZY_SYMBOL_POINTERS 0x6 /* only non-lazy symbol pointers */ -#define S_LAZY_SYMBOL_POINTERS 0x7 /* only lazy symbol pointers */ -#define S_SYMBOL_STUBS 0x8 /* only symbol stubs; byte size of - * stub in the reserved2 field */ -#define S_MOD_INIT_FUNC_POINTERS 0x9 /* only function pointers for init */ -#define S_MOD_TERM_FUNC_POINTERS 0xa /* only function pointers for term */ -#define S_COALESCED 0xb /* symbols that are to be coalesced */ -#define S_GB_ZEROFILL 0xc /* >4GB zero fill on demand section */ -#define S_INTERPOSING 0xd /* only pairs of function pointers for - * interposing */ -#define S_16BYTE_LITERALS 0xe /* only 16 byte literals */ +#define S_REGULAR 0x0 /* standard section */ +#define S_ZEROFILL 0x1 /* zerofill, in-memory only */ +#define S_CSTRING_LITERALS 0x2 /* literal C strings */ +#define S_4BYTE_LITERALS 0x3 /* only 4-byte literals */ +#define S_8BYTE_LITERALS 0x4 /* only 8-byte literals */ +#define S_LITERAL_POINTERS 0x5 /* only pointers to literals */ +#define S_NON_LAZY_SYMBOL_POINTERS 0x6 /* only non-lazy symbol pointers */ +#define S_LAZY_SYMBOL_POINTERS 0x7 /* only lazy symbol pointers */ +#define S_SYMBOL_STUBS 0x8 /* only symbol stubs; byte size of + * stub in the reserved2 field */ +#define S_MOD_INIT_FUNC_POINTERS 0x9 /* only function pointers for init */ +#define S_MOD_TERM_FUNC_POINTERS 0xa /* only function pointers for term */ +#define S_COALESCED 0xb /* symbols that are to be coalesced */ +#define S_GB_ZEROFILL 0xc /* >4GB zero fill on demand section */ +#define S_INTERPOSING 0xd /* only pairs of function pointers for + * interposing */ +#define S_16BYTE_LITERALS 0xe /* only 16 byte literals */ -#define S_ATTR_DEBUG 0x02000000 /* a debug section */ -#define SECTION_ATTRIBUTES_SYS 0x00ffff00 /* system setable attributes */ -#define S_ATTR_SOME_INSTRUCTIONS 0x00000400 /* section contains some - * machine instructions */ -#define S_ATTR_EXT_RELOC 0x00000200 /* section has external - * relocation entries */ -#define S_ATTR_LOC_RELOC 0x00000100 /* section has local - * relocation entries */ +#define S_ATTR_DEBUG 0x02000000 /* a debug section */ +#define SECTION_ATTRIBUTES_SYS 0x00ffff00 /* system setable attributes */ +#define S_ATTR_SOME_INSTRUCTIONS 0x00000400 /* section contains some + * machine instructions */ +#define S_ATTR_EXT_RELOC 0x00000200 /* section has external + * relocation entries */ +#define S_ATTR_LOC_RELOC 0x00000100 /* section has local + * relocation entries */ -#define SECTION_ATTRIBUTES_USR 0xff000000UL /* User setable attributes */ -#define S_ATTR_PURE_INSTRUCTIONS 0x80000000UL /* only true machine insns */ -#define S_ATTR_NO_TOC 0x40000000UL /* coalesced symbols that are - * not to be in a ranlib table - * of contents */ -#define S_ATTR_STRIP_STATIC_SYMS 0x20000000UL /* ok to strip static symbols - * in this section in files - * with the MH_DYLDLINK flag */ -#define S_ATTR_NO_DEAD_STRIP 0x10000000UL /* no dead stripping */ -#define S_ATTR_LIVE_SUPPORT 0x08000000UL /* blocks are live if they - * reference live blocks */ -#define S_ATTR_SELF_MODIFYING_CODE 0x04000000UL /* Used with i386 code stubs - * written on by dyld */ +#define SECTION_ATTRIBUTES_USR 0xff000000UL /* User setable attributes */ +#define S_ATTR_PURE_INSTRUCTIONS 0x80000000UL /* only true machine insns */ +#define S_ATTR_NO_TOC 0x40000000UL /* coalesced symbols that are + * not to be in a ranlib table + * of contents */ +#define S_ATTR_STRIP_STATIC_SYMS 0x20000000UL /* ok to strip static symbols + * in this section in files + * with the MH_DYLDLINK flag */ +#define S_ATTR_NO_DEAD_STRIP 0x10000000UL /* no dead stripping */ +#define S_ATTR_LIVE_SUPPORT 0x08000000UL /* blocks are live if they + * reference live blocks */ +#define S_ATTR_SELF_MODIFYING_CODE 0x04000000UL /* Used with i386 code stubs + * written on by dyld */ /* macho references symbols in different ways whether they are linked at * runtime (LAZY, read library functions) or at link time (NON_LAZY, mostly @@ -214,27 +229,27 @@ #define REFERENCE_FLAG_UNDEFINED_LAZY 0x1 #define align(x, y) \ - (((x) + (y) - 1) & ~((y) - 1)) /* align x to multiple of y */ + (((x) + (y) - 1) & ~((y) - 1)) /* align x to multiple of y */ #define align32(x) \ - align(x, 4) /* align x to 32 bit boundary */ + align(x, 4) /* align x to 32 bit boundary */ -#define macho_MAGIC 0x87654322 +#define macho_MAGIC 0x87654322 /* Symbol table type field bit masks */ -#define N_STAB 0xe0 /* mask indicating stab entry */ -#define N_PEXT 0x10 /* private external bit */ -#define N_TYPE 0x0e /* mask for all the type bits */ -#define N_EXT 0x01 /* external (global) bit */ +#define N_STAB 0xe0 /* mask indicating stab entry */ +#define N_PEXT 0x10 /* private external bit */ +#define N_TYPE 0x0e /* mask for all the type bits */ +#define N_EXT 0x01 /* external (global) bit */ /* Symbol table type field values */ -#define N_UNDF 0x00 /* undefined */ -#define N_ABS 0x02 /* absolute address */ -#define N_SECT 0x0e /* symbol is defined in a section */ +#define N_UNDF 0x00 /* undefined */ +#define N_ABS 0x02 /* absolute address */ +#define N_SECT 0x0e /* symbol is defined in a section */ -#define NO_SECT 0 /* no section for symbol in nlist */ +#define NO_SECT 0 /* no section for symbol in nlist */ -#define REGULAR_OUTBUF_SIZE 1024 +#define REGULAR_OUTBUF_SIZE 1024 typedef struct macho_reloc { @@ -243,57 +258,53 @@ typedef struct macho_reloc { int length; int ext; enum reloc_type_x86_64 { - /* x86 relocations */ - GENERIC_RELOC_VANILLA = 0, /* generic relocation */ - GENERIC_RELOC_PAIR = 1, /* Only follows a GENERIC_RELOC_SECTDIFF */ - GENERIC_RELOC_SECTDIFF = 2, - GENERIC_RELOC_PB_LA_PTR = 3, /* prebound lazy pointer */ - GENERIC_RELOC_LOCAL_SECTDIFF = 4, + /* x86 relocations */ + GENERIC_RELOC_VANILLA = 0, /* generic relocation */ + GENERIC_RELOC_PAIR = 1, /* Only follows a GENERIC_RELOC_SECTDIFF */ + GENERIC_RELOC_SECTDIFF = 2, + GENERIC_RELOC_PB_LA_PTR = 3, /* prebound lazy pointer */ + GENERIC_RELOC_LOCAL_SECTDIFF = 4, - /* x86-64 relocations */ - X86_64_RELOC_UNSIGNED = 0, /* for absolute addresses */ - X86_64_RELOC_SIGNED = 1, /* for signed 32-bit displacement */ - X86_64_RELOC_BRANCH = 2, /* a CALL/JMP insn with 32-bit disp */ - X86_64_RELOC_GOT_LOAD = 3, /* a MOVQ load of a GOT entry */ - X86_64_RELOC_GOT = 4, /* other GOT references */ - X86_64_RELOC_SUBTRACTOR = 5, /* must be followed by a X86_64_RELOC_UNSIGNED */ - X86_64_RELOC_SIGNED_1 = 6, /* signed 32-bit disp, -1 addend */ - X86_64_RELOC_SIGNED_2 = 7, /* signed 32-bit disp, -2 addend */ - X86_64_RELOC_SIGNED_4 = 8 /* signed 32-bit disp, -4 addend */ + /* x86-64 relocations */ + X86_64_RELOC_UNSIGNED = 0, /* for absolute addresses */ + X86_64_RELOC_SIGNED = 1, /* for signed 32-bit displacement */ + X86_64_RELOC_BRANCH = 2, /* a CALL/JMP insn with 32-bit disp */ + X86_64_RELOC_GOT_LOAD = 3, /* a MOVQ load of a GOT entry */ + X86_64_RELOC_GOT = 4, /* other GOT references */ + X86_64_RELOC_SUBTRACTOR = 5, /* must be followed by a X86_64_RELOC_UNSIGNED */ + X86_64_RELOC_SIGNED_1 = 6, /* signed 32-bit disp, -1 addend */ + X86_64_RELOC_SIGNED_2 = 7, /* signed 32-bit disp, -2 addend */ + X86_64_RELOC_SIGNED_4 = 8 /* signed 32-bit disp, -4 addend */ } type; } macho_reloc; typedef struct macho_section_data { /*@dependent@*/ yasm_symrec *sym; /* symbol created for this section */ - long scnum; /* section number (0=first section) */ + long scnum; /* section number (0=first section) */ /*@only@*/ char *segname; /* segment name in file */ /*@only@*/ char *sectname; /* section name in file */ - unsigned long flags; /* S_* flags */ - unsigned long size; /* size of raw data (section data) in bytes */ - unsigned long offset; /* offset in raw data within file in bytes */ - unsigned long vmoff; /* memory offset */ - unsigned long nreloc; /* number of relocation entries */ - unsigned int extreloc; /* external relocations present (0/1) */ + unsigned long flags; /* S_* flags */ + unsigned long size; /* size of raw data (section data) in bytes */ + unsigned long offset; /* offset in raw data within file in bytes */ + unsigned long vmoff; /* memory offset */ + unsigned long nreloc; /* number of relocation entries */ + unsigned int extreloc; /* external relocations present (0/1) */ } macho_section_data; typedef struct macho_symrec_data { - unsigned long index; /* index in output order */ - yasm_intnum *value; /* valid after writing symtable to file */ - unsigned long length; /* length + 1 (plus auto underscore) */ + unsigned long index; /* index in output order */ + yasm_intnum *value; /* valid after writing symtable to file */ + unsigned long length; /* length + 1 (plus auto underscore) */ + int add_uscore; /* add underscore (0/1) */ } macho_symrec_data; typedef struct yasm_objfmt_macho { - yasm_objfmt_base objfmt; /* base structure */ + yasm_objfmt_base objfmt; /* base structure */ - long parse_scnum; /* sect numbering in parser */ - int bits; /* 32 / 64 */ - - yasm_symrec *gotpcrel_sym; /* ..gotpcrel */ - - unsigned long minos; /* minimum os version */ - unsigned long sdk; /* sdk version */ + long parse_scnum; /* sect numbering in parser */ + int bits; /* 32 / 64 */ } yasm_objfmt_macho; @@ -306,21 +317,21 @@ typedef struct macho_objfmt_output_info { yasm_section *sect; /*@dependent@ */ macho_section_data *msd; - unsigned int is_64; /* write object in 64 bit mode */ + unsigned int is_64; /* write object in 64 bit mode */ /* vmsize and filesize available after traversing section count routine */ - unsigned long vmsize; /* raw size of all sections (including BSS) */ - unsigned long filesize; /* size of sections in file (excluding BSS) */ - unsigned long offset; /* offset within file */ + unsigned long vmsize; /* raw size of all sections (including BSS) */ + unsigned long filesize; /* size of sections in file (excluding BSS) */ + unsigned long offset; /* offset within file */ /* forward offset tracking */ - unsigned long rel_base; /* first relocation in file */ - unsigned long s_reloff; /* in-file offset to relocations */ + unsigned long rel_base; /* first relocation in file */ + unsigned long s_reloff; /* in-file offset to relocations */ - unsigned long indx; /* current symbol size in bytes (name length+1) */ - unsigned long symindex; /* current symbol index in output order */ - int all_syms; /* outputting all symbols? */ - unsigned long strlength; /* length of all strings */ + unsigned long indx; /* current symbol size in bytes (name length+1) */ + unsigned long symindex; /* current symbol index in output order */ + int all_syms; /* outputting all symbols? */ + unsigned long strlength; /* length of all strings */ } macho_objfmt_output_info; @@ -346,7 +357,7 @@ yasm_objfmt_module yasm_macho64_LTX_objfmt; static yasm_objfmt * macho_objfmt_create_common(yasm_object *object, yasm_objfmt_module *module, - int bits_pref) + int bits_pref) { yasm_objfmt_macho *objfmt_macho = yasm_xmalloc(sizeof(yasm_objfmt_macho)); @@ -354,32 +365,24 @@ macho_objfmt_create_common(yasm_object *object, yasm_objfmt_module *module, /* Only support x86 arch for now */ if (yasm__strcasecmp(yasm_arch_keyword(object->arch), "x86") != 0) { - yasm_xfree(objfmt_macho); - return NULL; + yasm_xfree(objfmt_macho); + return NULL; } /* Support x86 and amd64 machines of x86 arch */ if (yasm__strcasecmp(yasm_arch_get_machine(object->arch), "x86") == 0 && - (bits_pref == 0 || bits_pref == 32)) { - objfmt_macho->bits = 32; - objfmt_macho->gotpcrel_sym = NULL; - objfmt_macho->minos = 0x000a0400; /* min OS version: 10.4 */ - objfmt_macho->sdk = 0x000a0400; /* SDK version: 10.4 */ - } else if (yasm__strcasecmp(yasm_arch_get_machine(object->arch), - "amd64") == 0 && - (bits_pref == 0 || bits_pref == 64)) { - objfmt_macho->bits = 64; - /* FIXME: misuse of NULL bytecode */ - objfmt_macho->gotpcrel_sym = - yasm_symtab_define_label(object->symtab, "..gotpcrel", NULL, 0, 0); - objfmt_macho->minos = 0x000a0500; /* min OS version: 10.5 */ - objfmt_macho->sdk = 0x000a0500; /* SDK version: 10.5 */ - } else { - yasm_xfree(objfmt_macho); - return NULL; + (bits_pref == 0 || bits_pref == 32)) + objfmt_macho->bits = 32; + else if (yasm__strcasecmp(yasm_arch_get_machine(object->arch), + "amd64") == 0 && + (bits_pref == 0 || bits_pref == 64)) + objfmt_macho->bits = 64; + else { + yasm_xfree(objfmt_macho); + return NULL; } - objfmt_macho->parse_scnum = 0; /* section numbering starts at 0 */ + objfmt_macho->parse_scnum = 0; /* section numbering starts at 0 */ return (yasm_objfmt *)objfmt_macho; } @@ -391,12 +394,12 @@ macho_objfmt_create(yasm_object *object) objfmt = macho_objfmt_create_common(object, &yasm_macho_LTX_objfmt, 0); if (objfmt) { - objfmt_macho = (yasm_objfmt_macho *)objfmt; - /* Figure out which bitness of object format to use */ - if (objfmt_macho->bits == 32) - objfmt_macho->objfmt.module = &yasm_macho32_LTX_objfmt; - else if (objfmt_macho->bits == 64) - objfmt_macho->objfmt.module = &yasm_macho64_LTX_objfmt; + objfmt_macho = (yasm_objfmt_macho *)objfmt; + /* Figure out which bitness of object format to use */ + if (objfmt_macho->bits == 32) + objfmt_macho->objfmt.module = &yasm_macho32_LTX_objfmt; + else if (objfmt_macho->bits == 64) + objfmt_macho->objfmt.module = &yasm_macho64_LTX_objfmt; } return objfmt; } @@ -415,8 +418,8 @@ macho64_objfmt_create(yasm_object *object) static int macho_objfmt_output_value(yasm_value *value, unsigned char *buf, - unsigned int destsize, unsigned long offset, - yasm_bytecode *bc, int warn, /*@null@*/ void *d) + unsigned int destsize, unsigned long offset, + yasm_bytecode *bc, int warn, /*@null@*/ void *d) { /*@null@*/ macho_objfmt_output_info *info = (macho_objfmt_output_info *)d; yasm_objfmt_macho *objfmt_macho; @@ -430,157 +433,149 @@ macho_objfmt_output_value(yasm_value *value, unsigned char *buf, objfmt_macho = info->objfmt_macho; if (value->abs) - value->abs = yasm_expr_simplify(value->abs, 1); + value->abs = yasm_expr_simplify(value->abs, 1); /* Try to output constant and PC-relative section-local first. * Note this does NOT output any value with a SEG, WRT, external, * cross-section, or non-PC-relative reference (those are handled below). */ switch (yasm_value_output_basic(value, buf, destsize, bc, warn, - info->object->arch)) { - case -1: - return 1; - case 0: - break; - default: - return 0; + info->object->arch)) { + case -1: + return 1; + case 0: + break; + default: + return 0; } if (value->section_rel) { - yasm_error_set(YASM_ERROR_TOO_COMPLEX, - N_("macho: relocation too complex for current implementation")); - return 1; + yasm_error_set(YASM_ERROR_TOO_COMPLEX, + N_("macho: relocation too complex for current implementation")); + return 1; } if (value->rel) { - yasm_sym_vis vis = yasm_symrec_get_visibility(value->rel); + yasm_sym_vis vis = yasm_symrec_get_visibility(value->rel); - reloc = yasm_xcalloc(sizeof(macho_reloc), 1); - reloc->reloc.addr = yasm_intnum_create_uint(bc->offset + offset); - reloc->reloc.sym = value->rel; - switch (valsize) { - case 64: - reloc->length = 3; - break; - case 32: - reloc->length = 2; - break; - case 16: - reloc->length = 1; - break; - case 8: - reloc->length = 0; - break; - default: - yasm_error_set(YASM_ERROR_TOO_COMPLEX, - N_("macho: relocation size unsupported")); - yasm_xfree(reloc); - return 1; - } - reloc->pcrel = 0; - reloc->ext = 0; - reloc->type = GENERIC_RELOC_VANILLA; - /* R_ABS */ + reloc = yasm_xcalloc(sizeof(macho_reloc), 1); + reloc->reloc.addr = yasm_intnum_create_uint(bc->offset + offset); + reloc->reloc.sym = value->rel; + switch (valsize) { + case 64: + reloc->length = 3; + break; + case 32: + reloc->length = 2; + break; + case 16: + reloc->length = 1; + break; + case 8: + reloc->length = 0; + break; + default: + yasm_error_set(YASM_ERROR_TOO_COMPLEX, + N_("macho: relocation size unsupported")); + yasm_xfree(reloc); + return 1; + } + reloc->pcrel = 0; + reloc->ext = 0; + reloc->type = GENERIC_RELOC_VANILLA; + /* R_ABS */ - if (value->rshift > 0) { - yasm_error_set(YASM_ERROR_TOO_COMPLEX, - N_("macho: shifted relocations not supported")); - yasm_xfree(reloc); - return 1; - } + if (value->rshift > 0) { + yasm_error_set(YASM_ERROR_TOO_COMPLEX, + N_("macho: shifted relocations not supported")); + yasm_xfree(reloc); + return 1; + } - if (value->seg_of) { - yasm_error_set(YASM_ERROR_TOO_COMPLEX, - N_("macho: SEG not supported")); - yasm_xfree(reloc); - return 1; - } + if (value->seg_of) { + yasm_error_set(YASM_ERROR_TOO_COMPLEX, + N_("macho: SEG not supported")); + yasm_xfree(reloc); + return 1; + } - if (value->curpos_rel && objfmt_macho->gotpcrel_sym && - value->wrt == objfmt_macho->gotpcrel_sym) { - reloc->type = X86_64_RELOC_GOT; - value->wrt = NULL; - } else if (value->wrt) { - yasm_error_set(YASM_ERROR_TOO_COMPLEX, - N_("macho: invalid WRT")); - yasm_xfree(reloc); - return 1; - } + if (value->wrt) { + yasm_error_set(YASM_ERROR_TOO_COMPLEX, + N_("macho: WRT not supported")); + yasm_xfree(reloc); + return 1; + } - if (value->curpos_rel) { - reloc->pcrel = 1; - if (!info->is_64) { - /* Adjust to start of section, so subtract out the bytecode - * offset. - */ - intn_minus = bc->offset; - } else { - /* Add in the offset plus value size to end up with 0. */ - intn_plus = offset+destsize; - if (reloc->type == X86_64_RELOC_GOT) { - /* XXX: This is a hack */ - if (offset >= 2 && buf[-2] == 0x8B) - reloc->type = X86_64_RELOC_GOT_LOAD; - } else if (value->jump_target) - reloc->type = X86_64_RELOC_BRANCH; - else - reloc->type = X86_64_RELOC_SIGNED; - } - } else if (info->is_64) { - if (valsize == 32) { - yasm_error_set(YASM_ERROR_NOT_CONSTANT, - N_("macho: sorry, cannot apply 32 bit absolute relocations in 64 bit mode, consider \"[_symbol wrt rip]\" for mem access, \"qword\" and \"dq _foo\" for pointers.")); - return 1; - } - reloc->type = X86_64_RELOC_UNSIGNED; - } + if (value->curpos_rel) { + reloc->pcrel = 1; + if (!info->is_64) { + /* Adjust to start of section, so subtract out the bytecode + * offset. + */ + intn_minus = bc->offset; + } else { + /* Add in the offset plus value size to end up with 0. */ + intn_plus = offset+destsize; + if (value->jump_target) + reloc->type = X86_64_RELOC_BRANCH; + else + reloc->type = X86_64_RELOC_SIGNED; + } + } else if (info->is_64) { + if (valsize == 32) { + yasm_error_set(YASM_ERROR_NOT_CONSTANT, + N_("macho: sorry, cannot apply 32 bit absolute relocations in 64 bit mode, consider \"[_symbol wrt rip]\" for mem access, \"qword\" and \"dq _foo\" for pointers.")); + return 1; + } + reloc->type = X86_64_RELOC_UNSIGNED; + } - /* It seems that x86-64 objects need to have all extern relocs? */ - if (info->is_64) - reloc->ext = 1; + /* It seems that x86-64 objects need to have all extern relocs? */ + if (info->is_64) + reloc->ext = 1; - if ((vis & YASM_SYM_EXTERN) || (vis & YASM_SYM_COMMON)) { - reloc->ext = 1; - info->msd->extreloc = 1; /* section has external relocations */ - } else if (!info->is_64) { - /*@dependent@*/ /*@null@*/ yasm_bytecode *sym_precbc; + if ((vis & YASM_SYM_EXTERN) || (vis & YASM_SYM_COMMON)) { + reloc->ext = 1; + info->msd->extreloc = 1; /* section has external relocations */ + } else if (!value->curpos_rel && !info->is_64) { + /*@dependent@*/ /*@null@*/ yasm_bytecode *sym_precbc; - /* Local symbols need valued to their actual address */ - if (yasm_symrec_get_label(value->rel, &sym_precbc)) { - yasm_section *sym_sect = yasm_bc_get_section(sym_precbc); - /*@null@*/ macho_section_data *msd; - msd = yasm_section_get_data(sym_sect, &macho_section_data_cb); - assert(msd != NULL); - intn_plus += msd->vmoff + yasm_bc_next_offset(sym_precbc); - } - } + /* Local symbols need valued to their actual address */ + if (yasm_symrec_get_label(value->rel, &sym_precbc)) { + yasm_section *sym_sect = yasm_bc_get_section(sym_precbc); + /*@null@*/ macho_section_data *msd; + msd = yasm_section_get_data(sym_sect, &macho_section_data_cb); + assert(msd != NULL); + intn_plus += msd->vmoff + yasm_bc_next_offset(sym_precbc); + } + } - info->msd->nreloc++; - /*printf("reloc %s type %d ",yasm_symrec_get_name(reloc->reloc.sym),reloc->type);*/ - yasm_section_add_reloc(info->sect, (yasm_reloc *)reloc, yasm_xfree); + info->msd->nreloc++; + /*printf("reloc %s type %d ",yasm_symrec_get_name(reloc->reloc.sym),reloc->type);*/ + yasm_section_add_reloc(info->sect, (yasm_reloc *)reloc, yasm_xfree); } if (intn_minus <= intn_plus) - intn = yasm_intnum_create_uint(intn_plus-intn_minus); + intn = yasm_intnum_create_uint(intn_plus-intn_minus); else { - intn = yasm_intnum_create_uint(intn_minus-intn_plus); - yasm_intnum_calc(intn, YASM_EXPR_NEG, NULL); + intn = yasm_intnum_create_uint(intn_minus-intn_plus); + yasm_intnum_calc(intn, YASM_EXPR_NEG, NULL); } if (value->abs) { - yasm_intnum *intn2 = yasm_expr_get_intnum(&value->abs, 0); + yasm_intnum *intn2 = yasm_expr_get_intnum(&value->abs, 0); - if (!intn2) { - yasm_error_set(YASM_ERROR_TOO_COMPLEX, - N_("macho: relocation too complex")); - yasm_intnum_destroy(intn); - return 1; - } - yasm_intnum_calc(intn, YASM_EXPR_ADD, intn2); + if (!intn2) { + yasm_error_set(YASM_ERROR_TOO_COMPLEX, + N_("macho: relocation too complex")); + yasm_intnum_destroy(intn); + return 1; + } + yasm_intnum_calc(intn, YASM_EXPR_ADD, intn2); } retval = yasm_arch_intnum_tobytes(info->object->arch, intn, buf, destsize, - valsize, 0, bc, warn); + valsize, 0, bc, warn); /*printf("val %ld\n",yasm_intnum_get_int(intn));*/ yasm_intnum_destroy(intn); return retval; @@ -597,37 +592,37 @@ macho_objfmt_output_bytecode(yasm_bytecode *bc, /*@null@*/ void *d) assert(info != NULL); bigbuf = yasm_bc_tobytes(bc, info->buf, &size, &gap, info, - macho_objfmt_output_value, NULL); + macho_objfmt_output_value, NULL); /* Don't bother doing anything else if size ended up being 0. */ if (size == 0) { - if (bigbuf) - yasm_xfree(bigbuf); - return 0; + if (bigbuf) + yasm_xfree(bigbuf); + return 0; } /* Warn that gaps are converted to 0 and write out the 0's. */ if (gap) { - unsigned long left; + unsigned long left; - yasm_warn_set(YASM_WARN_UNINIT_CONTENTS, - N_("uninitialized space: zeroing")); - /* Write out in chunks */ - memset(info->buf, 0, REGULAR_OUTBUF_SIZE); - left = size; - while (left > REGULAR_OUTBUF_SIZE) { - fwrite(info->buf, REGULAR_OUTBUF_SIZE, 1, info->f); - left -= REGULAR_OUTBUF_SIZE; - } - fwrite(info->buf, left, 1, info->f); + yasm_warn_set(YASM_WARN_UNINIT_CONTENTS, + N_("uninitialized space: zeroing")); + /* Write out in chunks */ + memset(info->buf, 0, REGULAR_OUTBUF_SIZE); + left = size; + while (left > REGULAR_OUTBUF_SIZE) { + fwrite(info->buf, REGULAR_OUTBUF_SIZE, 1, info->f); + left -= REGULAR_OUTBUF_SIZE; + } + fwrite(info->buf, left, 1, info->f); } else { - /* Output buf (or bigbuf if non-NULL) to file */ - fwrite(bigbuf ? bigbuf : info->buf, (size_t) size, 1, info->f); + /* Output buf (or bigbuf if non-NULL) to file */ + fwrite(bigbuf ? bigbuf : info->buf, (size_t) size, 1, info->f); } /* If bigbuf was allocated, free it */ if (bigbuf) - yasm_xfree(bigbuf); + yasm_xfree(bigbuf); return 0; } @@ -636,7 +631,7 @@ static int macho_objfmt_output_section(yasm_section *sect, /*@null@ */ void *d) { /*@null@ */ macho_objfmt_output_info *info = - (macho_objfmt_output_info *) d; + (macho_objfmt_output_info *) d; /*@dependent@ *//*@null@ */ macho_section_data *msd; assert(info != NULL); @@ -644,11 +639,11 @@ macho_objfmt_output_section(yasm_section *sect, /*@null@ */ void *d) assert(msd != NULL); if (!(msd->flags & S_ZEROFILL)) { - /* Output non-BSS sections */ - info->sect = sect; - info->msd = msd; - yasm_section_bcs_traverse(sect, info->errwarns, info, - macho_objfmt_output_bytecode); + /* Output non-BSS sections */ + info->sect = sect; + info->msd = msd; + yasm_section_bcs_traverse(sect, info->errwarns, info, + macho_objfmt_output_bytecode); } return 0; } @@ -662,34 +657,34 @@ macho_objfmt_output_relocs(yasm_section *sect, /*@null@*/ void *d) reloc = (macho_reloc *)yasm_section_relocs_first(sect); while (reloc) { - unsigned char *localbuf = info->buf; - /*@null@*/ macho_symrec_data *xsymd; - unsigned long symnum; + unsigned char *localbuf = info->buf; + /*@null@*/ macho_symrec_data *xsymd; + unsigned long symnum; - xsymd = yasm_symrec_get_data(reloc->reloc.sym, &macho_symrec_data_cb); - yasm_intnum_get_sized(reloc->reloc.addr, localbuf, 4, 32, 0, 0, 0); - localbuf += 4; /* address of relocation */ + xsymd = yasm_symrec_get_data(reloc->reloc.sym, &macho_symrec_data_cb); + yasm_intnum_get_sized(reloc->reloc.addr, localbuf, 4, 32, 0, 0, 0); + localbuf += 4; /* address of relocation */ - if (reloc->ext) - symnum = xsymd->index; - else { - /* find section where the symbol relates to */ - /*@dependent@*/ /*@null@*/ yasm_section *dsect; - /*@dependent@*/ /*@null@*/ yasm_bytecode *precbc; - symnum = 0; /* default to absolute */ - if (yasm_symrec_get_label(reloc->reloc.sym, &precbc) && - (dsect = yasm_bc_get_section(precbc)) && - (msd = yasm_section_get_data(dsect, &macho_section_data_cb))) - symnum = msd->scnum+1; - } - YASM_WRITE_32_L(localbuf, - (symnum & 0x00ffffff) | - (((unsigned long)reloc->pcrel & 1) << 24) | - (((unsigned long)reloc->length & 3) << 25) | - (((unsigned long)reloc->ext & 1) << 27) | - (((unsigned long)reloc->type & 0xf) << 28)); - fwrite(info->buf, 8, 1, info->f); - reloc = (macho_reloc *)yasm_section_reloc_next((yasm_reloc *)reloc); + if (reloc->ext) + symnum = xsymd->index; + else { + /* find section where the symbol relates to */ + /*@dependent@*/ /*@null@*/ yasm_section *dsect; + /*@dependent@*/ /*@null@*/ yasm_bytecode *precbc; + symnum = 0; /* default to absolute */ + if (yasm_symrec_get_label(reloc->reloc.sym, &precbc) && + (dsect = yasm_bc_get_section(precbc)) && + (msd = yasm_section_get_data(dsect, &macho_section_data_cb))) + symnum = msd->scnum+1; + } + YASM_WRITE_32_L(localbuf, + (symnum & 0x00ffffff) | + (((unsigned long)reloc->pcrel & 1) << 24) | + (((unsigned long)reloc->length & 3) << 25) | + (((unsigned long)reloc->ext & 1) << 27) | + (((unsigned long)reloc->type & 0xf) << 28)); + fwrite(info->buf, 8, 1, info->f); + reloc = (macho_reloc *)yasm_section_reloc_next((yasm_reloc *)reloc); } return 0; @@ -701,8 +696,8 @@ exp2_to_bits(unsigned long val) int ret = 0; while (val) { - val >>= 1; - ret++; + val >>= 1; + ret++; } ret = (ret > 0) ? ret - 1 : 0; @@ -717,22 +712,22 @@ macho_objfmt_is_section_label(yasm_symrec *sym) /* Look at symrec for value/scnum/etc. */ if (yasm_symrec_get_label(sym, &precbc)) { - if (precbc) - sect = yasm_bc_get_section(precbc); - else - sect = NULL; - /* it's a label: get value and offset. - * If there is not a section, leave as debugging symbol. - */ - if (sect) { + if (precbc) + sect = yasm_bc_get_section(precbc); + else + sect = NULL; + /* it's a label: get value and offset. + * If there is not a section, leave as debugging symbol. + */ + if (sect) { /*@dependent@*/ /*@null@*/ macho_section_data *msd; msd = yasm_section_get_data(sect, &macho_section_data_cb); if (msd) { if (msd->sym == sym) - return 1; /* don't store section names */ - } - } + return 1; /* don't store section names */ + } + } } return 0; } @@ -741,10 +736,12 @@ static int macho_objfmt_output_secthead(yasm_section *sect, /*@null@*/ void *d) { /*@null@*/ macho_objfmt_output_info *info = (macho_objfmt_output_info *)d; + yasm_objfmt_macho *objfmt_macho; /*@dependent@*/ /*@null@*/ macho_section_data *msd; unsigned char *localbuf; assert(info != NULL); + objfmt_macho = info->objfmt_macho; msd = yasm_section_get_data(sect, &macho_section_data_cb); assert(msd != NULL); @@ -757,45 +754,45 @@ macho_objfmt_output_secthead(yasm_section *sect, /*@null@*/ void *d) strncpy((char *)localbuf, msd->segname, 16); localbuf += 16; /* section address, size depend on 32/64 bit mode */ - YASM_WRITE_32_L(localbuf, msd->vmoff); /* address in memory */ + YASM_WRITE_32_L(localbuf, msd->vmoff); /* address in memory */ if (info->is_64) - YASM_WRITE_32_L(localbuf, 0); /* 64-bit mode: upper 32 bits = 0 */ - YASM_WRITE_32_L(localbuf, msd->size); /* size in memory */ + YASM_WRITE_32_L(localbuf, 0); /* 64-bit mode: upper 32 bits = 0 */ + YASM_WRITE_32_L(localbuf, msd->size); /* size in memory */ if (info->is_64) - YASM_WRITE_32_L(localbuf, 0); /* 64-bit mode: upper 32 bits = 0 */ + YASM_WRITE_32_L(localbuf, 0); /* 64-bit mode: upper 32 bits = 0 */ /* offset,align,reloff,nreloc,flags,reserved1,reserved2 are 32 bit */ if ((msd->flags & SECTION_TYPE) != S_ZEROFILL) { - YASM_WRITE_32_L(localbuf, msd->offset); - YASM_WRITE_32_L(localbuf, exp2_to_bits(yasm_section_get_align(sect))); - if (msd->nreloc) { - msd->flags |= S_ATTR_LOC_RELOC; - if (msd->extreloc) - msd->flags |= S_ATTR_EXT_RELOC; - YASM_WRITE_32_L(localbuf, - align32((long)(info->rel_base + info->s_reloff))); - YASM_WRITE_32_L(localbuf, msd->nreloc); /* nreloc */ - } else { - YASM_WRITE_32_L(localbuf, 0); - YASM_WRITE_32_L(localbuf, 0); - } + YASM_WRITE_32_L(localbuf, msd->offset); + YASM_WRITE_32_L(localbuf, exp2_to_bits(yasm_section_get_align(sect))); + if (msd->nreloc) { + msd->flags |= S_ATTR_LOC_RELOC; + if (msd->extreloc) + msd->flags |= S_ATTR_EXT_RELOC; + YASM_WRITE_32_L(localbuf, + align32((long)(info->rel_base + info->s_reloff))); + YASM_WRITE_32_L(localbuf, msd->nreloc); /* nreloc */ + } else { + YASM_WRITE_32_L(localbuf, 0); + YASM_WRITE_32_L(localbuf, 0); + } - info->s_reloff += msd->nreloc * MACHO_RELINFO_SIZE; /* nreloc */ + info->s_reloff += msd->nreloc * MACHO_RELINFO_SIZE; /* nreloc */ } else { - YASM_WRITE_32_L(localbuf, 0); /* these are zero in BSS */ - YASM_WRITE_32_L(localbuf, 0); - YASM_WRITE_32_L(localbuf, 0); - YASM_WRITE_32_L(localbuf, 0); + YASM_WRITE_32_L(localbuf, 0); /* these are zero in BSS */ + YASM_WRITE_32_L(localbuf, 0); + YASM_WRITE_32_L(localbuf, 0); + YASM_WRITE_32_L(localbuf, 0); } - YASM_WRITE_32_L(localbuf, msd->flags); /* flags */ - YASM_WRITE_32_L(localbuf, 0); /* reserved 1 */ - YASM_WRITE_32_L(localbuf, 0); /* reserved 2 */ + YASM_WRITE_32_L(localbuf, msd->flags); /* flags */ + YASM_WRITE_32_L(localbuf, 0); /* reserved 1 */ + YASM_WRITE_32_L(localbuf, 0); /* reserved 2 */ if (info->is_64) - fwrite(info->buf, MACHO_SECTCMD64_SIZE, 1, info->f); + fwrite(info->buf, MACHO_SECTCMD64_SIZE, 1, info->f); else - fwrite(info->buf, MACHO_SECTCMD_SIZE, 1, info->f); + fwrite(info->buf, MACHO_SECTCMD_SIZE, 1, info->f); return 0; } @@ -805,31 +802,37 @@ static int macho_objfmt_count_sym(yasm_symrec *sym, /*@null@*/ void *d) { /*@null@*/ macho_objfmt_output_info *info = (macho_objfmt_output_info *)d; - /*@only@*/ char *name; + const char *name; yasm_sym_vis vis = yasm_symrec_get_visibility(sym); assert(info != NULL); if (info->all_syms || - vis & (YASM_SYM_GLOBAL | YASM_SYM_COMMON | YASM_SYM_EXTERN)) { - if (0 == macho_objfmt_is_section_label(sym)) { - /* Save index in symrec data */ - macho_symrec_data *sym_data = - yasm_symrec_get_data(sym, &macho_symrec_data_cb); - if (!sym_data) { - sym_data = yasm_xcalloc(sizeof(macho_symrec_data), 1); - yasm_symrec_add_data(sym, &macho_symrec_data_cb, sym_data); - } - sym_data->index = info->symindex; - info->symindex++; + vis & (YASM_SYM_GLOBAL | YASM_SYM_COMMON | YASM_SYM_EXTERN)) { + if (0 == macho_objfmt_is_section_label(sym)) { + /* Save index in symrec data */ + macho_symrec_data *sym_data = + yasm_symrec_get_data(sym, &macho_symrec_data_cb); + if (!sym_data) { + sym_data = yasm_xcalloc(sizeof(macho_symrec_data), 1); + yasm_symrec_add_data(sym, &macho_symrec_data_cb, sym_data); + } + sym_data->index = info->symindex; + info->symindex++; - name = yasm_symrec_get_global_name(sym, info->object); - /*printf("%s\n",name); */ - /* name length + delimiter */ - sym_data->length = (unsigned long)strlen(name) + 1; - info->strlength += sym_data->length; - info->indx++; - yasm_xfree(name); - } + name = yasm_symrec_get_name(sym); /*printf("%s\n",name); */ + sym_data->add_uscore = 0; +#ifdef AUTO_UNDERSCORE + if (vis & (YASM_SYM_EXTERN | YASM_SYM_COMMON | YASM_SYM_GLOBAL)) { + if (name[0] != '_') + sym_data->add_uscore = 1; + } +#endif + /* name length + delimiter */ + sym_data->length = + (unsigned long)strlen(name) + sym_data->add_uscore + 1; + info->strlength += sym_data->length; + info->indx++; + } } return 0; } @@ -844,130 +847,111 @@ macho_objfmt_output_symtable(yasm_symrec *sym, /*@null@*/ void *d) assert(info != NULL); if (info->all_syms || - vis & (YASM_SYM_GLOBAL | YASM_SYM_COMMON | YASM_SYM_EXTERN)) { - const yasm_expr *equ_val; - const yasm_intnum *intn; - unsigned long value = 0; - long scnum = -3; /* -3 = debugging symbol */ - /*@dependent@*/ /*@null@*/ yasm_section *sect; - /*@dependent@*/ /*@null@*/ yasm_bytecode *precbc; - unsigned char *localbuf; - yasm_intnum *val; - unsigned int long_int_bytes = (info->is_64) ? 8 : 4; - unsigned int n_type = 0, n_sect = 0, n_desc = 0; - macho_symrec_data *symd; + vis & (YASM_SYM_GLOBAL | YASM_SYM_COMMON | YASM_SYM_EXTERN)) { + const yasm_expr *equ_val; + const yasm_intnum *intn; + unsigned long value = 0; + long scnum = -3; /* -3 = debugging symbol */ + /*@dependent@*/ /*@null@*/ yasm_section *sect; + /*@dependent@*/ /*@null@*/ yasm_bytecode *precbc; + unsigned char *localbuf; + yasm_intnum *val; + unsigned int long_int_bytes = (info->is_64) ? 8 : 4; + unsigned int n_type = 0, n_sect = 0, n_desc = 0; + macho_symrec_data *symd; - val = yasm_intnum_create_uint(0); + val = yasm_intnum_create_uint(0); - symd = yasm_symrec_get_data(sym, &macho_symrec_data_cb); + symd = yasm_symrec_get_data(sym, &macho_symrec_data_cb); - /* Look at symrec for value/scnum/etc. */ - if (yasm_symrec_get_label(sym, &precbc)) { - if (precbc) - sect = yasm_bc_get_section(precbc); - else - sect = NULL; - /* it's a label: get value and offset. - * If there is not a section, leave as debugging symbol. - */ - if (sect) { - /*@dependent@*/ /*@null@*/ macho_section_data *msd; + /* Look at symrec for value/scnum/etc. */ + if (yasm_symrec_get_label(sym, &precbc)) { + if (precbc) + sect = yasm_bc_get_section(precbc); + else + sect = NULL; + /* it's a label: get value and offset. + * If there is not a section, leave as debugging symbol. + */ + if (sect) { + /*@dependent@*/ /*@null@*/ macho_section_data *msd; msd = yasm_section_get_data(sect, &macho_section_data_cb); if (msd) { if (msd->sym == sym) { - /* don't store section names */ - yasm_intnum_destroy(val); - return 0; - } - scnum = msd->scnum; - n_type = N_SECT; - } else - yasm_internal_error(N_("didn't understand section")); - if (precbc) - value += yasm_bc_next_offset(precbc); - /* all values are subject to correction: base offset is first - * raw section, therefore add section offset - */ - if (msd) - value += msd->vmoff; - yasm_intnum_set_uint(val, value); - /*printf("%s offset %lx\n",name,value);*/ - } - } else if ((equ_val = yasm_symrec_get_equ(sym))) { - yasm_expr *equ_val_copy = yasm_expr_copy(equ_val); + /* don't store section names */ + yasm_intnum_destroy(val); + return 0; + } + scnum = msd->scnum; + n_type = N_SECT; + } else + yasm_internal_error(N_("didn't understand section")); + if (precbc) + value += yasm_bc_next_offset(precbc); + /* all values are subject to correction: base offset is first + * raw section, therefore add section offset + */ + if (msd) + value += msd->vmoff; + yasm_intnum_set_uint(val, value); + /*printf("%s offset %lx\n",name,value);*/ + } + } else if ((equ_val = yasm_symrec_get_equ(sym))) { + yasm_expr *equ_val_copy = yasm_expr_copy(equ_val); - intn = yasm_expr_get_intnum(&equ_val_copy, 1); - if (!intn) { - if (vis & YASM_SYM_GLOBAL) { - yasm_error_set(YASM_ERROR_NOT_CONSTANT, - N_("global EQU value not an integer expression")); - yasm_errwarn_propagate(info->errwarns, equ_val->line); - } - } else - value = yasm_intnum_get_uint(intn); - yasm_expr_destroy(equ_val_copy); - yasm_intnum_set_uint(val, value); - n_type = N_ABS; - scnum = -2; /* -2 = absolute symbol */ - } + intn = yasm_expr_get_intnum(&equ_val_copy, 1); + if (!intn) { + if (vis & YASM_SYM_GLOBAL) { + yasm_error_set(YASM_ERROR_NOT_CONSTANT, + N_("global EQU value not an integer expression")); + yasm_errwarn_propagate(info->errwarns, equ_val->line); + } + } else + value = yasm_intnum_get_uint(intn); + yasm_expr_destroy(equ_val_copy); + yasm_intnum_set_uint(val, value); + n_type = N_ABS; + scnum = -2; /* -2 = absolute symbol */ + } - if (vis & YASM_SYM_EXTERN) { - n_type = N_EXT; - scnum = -1; - /*n_desc = REFERENCE_FLAG_UNDEFINED_LAZY; * FIXME: see definition of REFERENCE_FLAG_* above */ - } else if (vis & YASM_SYM_COMMON) { - yasm_expr **csize = yasm_symrec_get_common_size(sym); - n_type = N_UNDF | N_EXT; - if (csize) { - intn = yasm_expr_get_intnum(csize, 1); - if (!intn) { - yasm_error_set(YASM_ERROR_NOT_CONSTANT, - N_("COMMON data size not an integer expression")); - yasm_errwarn_propagate(info->errwarns, (*csize)->line); - } else - yasm_intnum_set_uint(val, yasm_intnum_get_uint(intn)); - } - /*printf("common symbol %s val %lu\n", name, yasm_intnum_get_uint(val));*/ - } else if (vis & YASM_SYM_GLOBAL) { - yasm_valparamhead *valparams = - yasm_symrec_get_objext_valparams(sym); + if (vis & YASM_SYM_EXTERN) { + n_type = N_EXT; + scnum = -1; + /*n_desc = REFERENCE_FLAG_UNDEFINED_LAZY; * FIXME: see definition of REFERENCE_FLAG_* above */ + } else if (vis & YASM_SYM_COMMON) { + yasm_expr **csize = yasm_symrec_get_common_size(sym); + n_type = N_UNDF | N_EXT; + if (csize) { + intn = yasm_expr_get_intnum(csize, 1); + if (!intn) { + yasm_error_set(YASM_ERROR_NOT_CONSTANT, + N_("COMMON data size not an integer expression")); + yasm_errwarn_propagate(info->errwarns, (*csize)->line); + } else + yasm_intnum_set_uint(val, yasm_intnum_get_uint(intn)); + } + /*printf("common symbol %s val %lu\n", name, yasm_intnum_get_uint(val));*/ + } else if (vis & YASM_SYM_GLOBAL) { + n_type |= N_EXT; + } - struct macho_global_data { - unsigned long flag; /* N_PEXT */ - } data; + localbuf = info->buf; + YASM_WRITE_32_L(localbuf, info->indx); /* offset in string table */ + YASM_WRITE_8(localbuf, n_type); /* type of symbol entry */ + n_sect = (scnum >= 0) ? scnum + 1 : NO_SECT; + YASM_WRITE_8(localbuf, n_sect); /* referring section where symbol is found */ + YASM_WRITE_16_L(localbuf, n_desc); /* extra description */ + yasm_intnum_get_sized(val, localbuf, long_int_bytes, ((long_int_bytes) << 3), 0, 0, 0); /* value/argument */ + localbuf += long_int_bytes; + if (symd) + symd->value = val; + else + yasm_intnum_destroy(val); - data.flag = 0; + info->indx += symd->length; - if (valparams) { - static const yasm_dir_help help[] = { - { "private_extern", 0, yasm_dir_helper_flag_set, - offsetof(struct macho_global_data, flag), N_PEXT }, - }; - yasm_dir_helper(sym, yasm_vps_first(valparams), - yasm_symrec_get_decl_line(sym), help, NELEMS(help), - &data, yasm_dir_helper_valparam_warn); - } - - n_type |= N_EXT | data.flag; - } - - localbuf = info->buf; - YASM_WRITE_32_L(localbuf, info->indx); /* offset in string table */ - YASM_WRITE_8(localbuf, n_type); /* type of symbol entry */ - n_sect = (scnum >= 0) ? scnum + 1 : NO_SECT; - YASM_WRITE_8(localbuf, n_sect); /* referring section where symbol is found */ - YASM_WRITE_16_L(localbuf, n_desc); /* extra description */ - yasm_intnum_get_sized(val, localbuf, long_int_bytes, ((long_int_bytes) << 3), 0, 0, 0); /* value/argument */ - localbuf += long_int_bytes; - if (symd) - symd->value = val; - else - yasm_intnum_destroy(val); - - info->indx += symd->length; - - fwrite(info->buf, 8 + long_int_bytes, 1, info->f); + fwrite(info->buf, 8 + long_int_bytes, 1, info->f); } return 0; @@ -979,19 +963,22 @@ macho_objfmt_output_str(yasm_symrec *sym, /*@null@*/ void *d) { /*@null@*/ macho_objfmt_output_info *info = (macho_objfmt_output_info *)d; yasm_sym_vis vis = yasm_symrec_get_visibility(sym); + /*@null@*/ macho_symrec_data *xsymd; + assert(info != NULL); if (info->all_syms || - vis & (YASM_SYM_GLOBAL | YASM_SYM_COMMON | YASM_SYM_EXTERN)) { - if (0 == macho_objfmt_is_section_label(sym)) { - /*@only@*/ char *name = - yasm_symrec_get_global_name(sym, info->object); - size_t len = strlen(name); + vis & (YASM_SYM_GLOBAL | YASM_SYM_COMMON | YASM_SYM_EXTERN)) { + if (0 == macho_objfmt_is_section_label(sym)) { + const char *name = yasm_symrec_get_name(sym); + size_t len = strlen(name); - fwrite(name, len + 1, 1, info->f); - yasm_xfree(name); - } + xsymd = yasm_symrec_get_data(sym, &macho_symrec_data_cb); + if (xsymd->add_uscore) + fputc('_', info->f); + fwrite(name, len + 1, 1, info->f); + } } return 0; } @@ -1000,9 +987,8 @@ static int macho_objfmt_calc_sectsize(yasm_section *sect, /*@null@ */ void *d) { /*@null@ */ macho_objfmt_output_info *info = - (macho_objfmt_output_info *) d; + (macho_objfmt_output_info *) d; /*@dependent@ *//*@null@ */ macho_section_data *msd; - unsigned long align; assert(info != NULL); msd = yasm_section_get_data(sect, &macho_section_data_cb); @@ -1010,32 +996,22 @@ macho_objfmt_calc_sectsize(yasm_section *sect, /*@null@ */ void *d) msd->size = yasm_bc_next_offset(yasm_section_bcs_last(sect)); if (!(msd->flags & S_ZEROFILL)) { - msd->offset = info->offset; - info->offset += msd->size; - info->filesize += msd->size; + msd->offset = info->offset; + info->offset += msd->size; + info->filesize += msd->size; } /* accumulate size in memory */ msd->vmoff = info->vmsize; info->vmsize += msd->size; - /* align both start and end of section */ - align = yasm_section_get_align(sect); - if (align != 0) { - unsigned long delta = msd->vmoff % align; - if (delta > 0) { - msd->vmoff += align - delta; - info->vmsize += align - delta; - } - } - return 0; } /* write object */ static void macho_objfmt_output(yasm_object *object, FILE *f, int all_syms, - yasm_errwarns *errwarns) + yasm_errwarns *errwarns) { yasm_objfmt_macho *objfmt_macho = (yasm_objfmt_macho *)object->objfmt; macho_objfmt_output_info info; @@ -1043,7 +1019,7 @@ macho_objfmt_output(yasm_object *object, FILE *f, int all_syms, unsigned long symtab_count = 0; unsigned long headsize; unsigned int macho_segcmdsize, macho_sectcmdsize, macho_nlistsize; - unsigned int macho_segcmd; + unsigned int macho_relinfosize, macho_segcmd; unsigned int head_ncmds, head_sizeofcmds; unsigned long fileoffset, fileoff_sections; yasm_intnum *val; @@ -1057,9 +1033,9 @@ macho_objfmt_output(yasm_object *object, FILE *f, int all_syms, info.buf = yasm_xmalloc(REGULAR_OUTBUF_SIZE); if (objfmt_macho->parse_scnum == 0) { - yasm_internal_error(N_("no sections defined")); - /*@notreached@*/ - return; + yasm_internal_error(N_("no sections defined")); + /*@notreached@*/ + return; } val = yasm_intnum_create_uint(0); @@ -1069,42 +1045,44 @@ macho_objfmt_output(yasm_object *object, FILE *f, int all_syms, */ info.is_64 = (objfmt_macho->bits == 32) ? 0 : 1; if (info.is_64) { - /* this works only when SYMBOLS and SECTIONS present */ - headsize = - MACHO_HEADER64_SIZE + MACHO_SEGCMD64_SIZE + - (MACHO_SECTCMD64_SIZE * (objfmt_macho->parse_scnum)) + - MACHO_SYMCMD_SIZE + MACHO_BUILDVERSION_SIZE; - macho_segcmd = LC_SEGMENT_64; - macho_segcmdsize = MACHO_SEGCMD64_SIZE; - macho_sectcmdsize = MACHO_SECTCMD64_SIZE; - macho_nlistsize = MACHO_NLIST64_SIZE; - long_int_bytes = 8; + /* this works only when SYMBOLS and SECTIONS present */ + headsize = + MACHO_HEADER64_SIZE + MACHO_SEGCMD64_SIZE + + (MACHO_SECTCMD64_SIZE * (objfmt_macho->parse_scnum)) + + MACHO_SYMCMD_SIZE; + macho_segcmd = LC_SEGMENT_64; + macho_segcmdsize = MACHO_SEGCMD64_SIZE; + macho_sectcmdsize = MACHO_SECTCMD64_SIZE; + macho_nlistsize = MACHO_NLIST64_SIZE; + macho_relinfosize = MACHO_RELINFO64_SIZE; + long_int_bytes = 8; } else { - headsize = - MACHO_HEADER_SIZE + MACHO_SEGCMD_SIZE + - (MACHO_SECTCMD_SIZE * (objfmt_macho->parse_scnum)) + - MACHO_SYMCMD_SIZE + MACHO_BUILDVERSION_SIZE; - macho_segcmd = LC_SEGMENT; - macho_segcmdsize = MACHO_SEGCMD_SIZE; - macho_sectcmdsize = MACHO_SECTCMD_SIZE; - macho_nlistsize = MACHO_NLIST_SIZE; - long_int_bytes = 4; + headsize = + MACHO_HEADER_SIZE + MACHO_SEGCMD_SIZE + + (MACHO_SECTCMD_SIZE * (objfmt_macho->parse_scnum)) + + MACHO_SYMCMD_SIZE; + macho_segcmd = LC_SEGMENT; + macho_segcmdsize = MACHO_SEGCMD_SIZE; + macho_sectcmdsize = MACHO_SECTCMD_SIZE; + macho_nlistsize = MACHO_NLIST_SIZE; + macho_relinfosize = MACHO_RELINFO_SIZE; + long_int_bytes = 4; } /* Get number of symbols */ info.symindex = 0; info.indx = 0; - info.strlength = 1; /* string table starts with a zero byte */ + info.strlength = 1; /* string table starts with a zero byte */ info.all_syms = all_syms || info.is_64; - /*info.all_syms = 1; * force all syms into symbol table */ + /*info.all_syms = 1; * force all syms into symbol table */ yasm_symtab_traverse(object->symtab, &info, macho_objfmt_count_sym); symtab_count = info.indx; /* write raw section data first */ if (fseek(f, (long)headsize, SEEK_SET) < 0) { - yasm__fatal(N_("could not seek on output file")); - /*@notreached@ */ - return; + yasm__fatal(N_("could not seek on output file")); + /*@notreached@ */ + return; } /* get size of sections in memory (including BSS) and size of sections @@ -1122,64 +1100,56 @@ macho_objfmt_output(yasm_object *object, FILE *f, int all_syms, /* Write headers */ if (fseek(f, 0, SEEK_SET) < 0) { - yasm__fatal(N_("could not seek on output file")); - /*@notreached@*/ - return; + yasm__fatal(N_("could not seek on output file")); + /*@notreached@*/ + return; } localbuf = info.buf; /* header size is common to 32 bit and 64 bit variants */ if (info.is_64) { - YASM_WRITE_32_L(localbuf, MH_MAGIC_64); /* magic number */ - /* i386 64-bit ABI */ - YASM_WRITE_32_L(localbuf, CPU_ARCH_ABI64 | CPU_TYPE_I386); + YASM_WRITE_32_L(localbuf, MH_MAGIC_64); /* magic number */ + /* i386 64-bit ABI */ + YASM_WRITE_32_L(localbuf, CPU_ARCH_ABI64 | CPU_TYPE_I386); } else { - YASM_WRITE_32_L(localbuf, MH_MAGIC); /* magic number */ - YASM_WRITE_32_L(localbuf, CPU_TYPE_I386); /* i386 32-bit ABI */ + YASM_WRITE_32_L(localbuf, MH_MAGIC); /* magic number */ + YASM_WRITE_32_L(localbuf, CPU_TYPE_I386); /* i386 32-bit ABI */ } /* i386 all cpu subtype compatible */ YASM_WRITE_32_L(localbuf, CPU_SUBTYPE_I386_ALL); - YASM_WRITE_32_L(localbuf, MH_OBJECT); /* MACH file type */ + YASM_WRITE_32_L(localbuf, MH_OBJECT); /* MACH file type */ /* calculate number of commands and their size, put to stream */ - head_ncmds = 1; - head_sizeofcmds = MACHO_BUILDVERSION_SIZE; + head_ncmds = 0; + head_sizeofcmds = 0; if (objfmt_macho->parse_scnum > 0) { - head_ncmds++; - head_sizeofcmds += - macho_segcmdsize + macho_sectcmdsize * objfmt_macho->parse_scnum; + head_ncmds++; + head_sizeofcmds += + macho_segcmdsize + macho_sectcmdsize * objfmt_macho->parse_scnum; } if (symtab_count > 0) { - head_ncmds++; - head_sizeofcmds += MACHO_SYMCMD_SIZE; + head_ncmds++; + head_sizeofcmds += MACHO_SYMCMD_SIZE; } YASM_WRITE_32_L(localbuf, head_ncmds); YASM_WRITE_32_L(localbuf, head_sizeofcmds); - YASM_WRITE_32_L(localbuf, 0); /* no flags (yet) */ + YASM_WRITE_32_L(localbuf, 0); /* no flags (yet) */ if (info.is_64) { - YASM_WRITE_32_L(localbuf, 0); /* reserved in 64 bit */ - fileoffset = MACHO_HEADER64_SIZE + head_sizeofcmds; + YASM_WRITE_32_L(localbuf, 0); /* reserved in 64 bit */ + fileoffset = MACHO_HEADER64_SIZE + head_sizeofcmds; } else { - /* initial offset to first section */ - fileoffset = MACHO_HEADER_SIZE + head_sizeofcmds; + /* initial offset to first section */ + fileoffset = MACHO_HEADER_SIZE + head_sizeofcmds; } - /* --------------- write build version command ---------------- */ - YASM_WRITE_32_L(localbuf, LC_BUILD_VERSION); - YASM_WRITE_32_L(localbuf, MACHO_BUILDVERSION_SIZE); - YASM_WRITE_32_L(localbuf, PLATFORM_MACOS); - YASM_WRITE_32_L(localbuf, objfmt_macho->minos); - YASM_WRITE_32_L(localbuf, objfmt_macho->sdk); - YASM_WRITE_32_L(localbuf, 0); /* number of tools */ - /* --------------- write segment header command ---------------- */ - YASM_WRITE_32_L(localbuf, macho_segcmd); /* command LC_SEGMENT */ + YASM_WRITE_32_L(localbuf, macho_segcmd); /* command LC_SEGMENT */ /* size of load command including section load commands */ YASM_WRITE_32_L(localbuf, - macho_segcmdsize + - macho_sectcmdsize * objfmt_macho->parse_scnum); + macho_segcmdsize + + macho_sectcmdsize * objfmt_macho->parse_scnum); /* in an MH_OBJECT file all sections are in one unnamed (name all zeros) * segment (16x0) */ @@ -1189,50 +1159,50 @@ macho_objfmt_output(yasm_object *object, FILE *f, int all_syms, YASM_WRITE_32_L(localbuf, 0); /* in-memory offset, in-memory size */ - yasm_intnum_set_uint(val, 0); /* offset in memory (vmaddr) */ + yasm_intnum_set_uint(val, 0); /* offset in memory (vmaddr) */ yasm_intnum_get_sized(val, localbuf, long_int_bytes, - ((long_int_bytes) << 3), 0, 0, 0); + ((long_int_bytes) << 3), 0, 0, 0); localbuf += long_int_bytes; - yasm_intnum_set_uint(val, info.vmsize); /* size in memory (vmsize) */ + yasm_intnum_set_uint(val, info.vmsize); /* size in memory (vmsize) */ yasm_intnum_get_sized(val, localbuf, long_int_bytes, - ((long_int_bytes) << 3), 0, 0, 0); + ((long_int_bytes) << 3), 0, 0, 0); localbuf += long_int_bytes; /* offset in file to first section */ yasm_intnum_set_uint(val, fileoffset); yasm_intnum_get_sized(val, localbuf, long_int_bytes, - ((long_int_bytes) << 3), 0, 0, 0); + ((long_int_bytes) << 3), 0, 0, 0); localbuf += long_int_bytes; - yasm_intnum_set_uint(val, info.filesize); /* overall size in file */ + yasm_intnum_set_uint(val, info.filesize); /* overall size in file */ yasm_intnum_get_sized(val, localbuf, long_int_bytes, - ((long_int_bytes) << 3), 0, 0, 0); + ((long_int_bytes) << 3), 0, 0, 0); localbuf += long_int_bytes; - YASM_WRITE_32_L(localbuf, VM_PROT_DEFAULT); /* VM protection, maximum */ - YASM_WRITE_32_L(localbuf, VM_PROT_DEFAULT); /* VM protection, initial */ + YASM_WRITE_32_L(localbuf, VM_PROT_DEFAULT); /* VM protection, maximum */ + YASM_WRITE_32_L(localbuf, VM_PROT_DEFAULT); /* VM protection, initial */ /* number of sections */ YASM_WRITE_32_L(localbuf, objfmt_macho->parse_scnum); - YASM_WRITE_32_L(localbuf, 0); /* no flags */ + YASM_WRITE_32_L(localbuf, 0); /* no flags */ /* write MACH-O header and segment command to outfile */ fwrite(info.buf, (size_t) (localbuf - info.buf), 1, f); /* next: section headers */ /* offset to relocs for first section */ - info.rel_base = align32((long)fileoff_sections); - info.s_reloff = 0; /* offset for relocs of following sections */ + info.rel_base = align32((long)fileoffset + (long)info.filesize); + info.s_reloff = 0; /* offset for relocs of following sections */ yasm_object_sections_traverse(object, &info, macho_objfmt_output_secthead); localbuf = info.buf; /* write out symbol command */ - YASM_WRITE_32_L(localbuf, LC_SYMTAB); /* cmd == LC_SYMTAB */ + YASM_WRITE_32_L(localbuf, LC_SYMTAB); /* cmd == LC_SYMTAB */ YASM_WRITE_32_L(localbuf, MACHO_SYMCMD_SIZE); /* symbol table offset */ YASM_WRITE_32_L(localbuf, info.rel_base + info.s_reloff); - YASM_WRITE_32_L(localbuf, symtab_count); /* number of symbols */ + YASM_WRITE_32_L(localbuf, symtab_count); /* number of symbols */ YASM_WRITE_32_L(localbuf, macho_nlistsize * symtab_count + info.rel_base + - info.s_reloff); /* string table offset */ - YASM_WRITE_32_L(localbuf, info.strlength); /* string table size */ + info.s_reloff); /* string table offset */ + YASM_WRITE_32_L(localbuf, info.strlength); /* string table size */ /* write symbol command */ fwrite(info.buf, (size_t)(localbuf - info.buf), 1, f); @@ -1241,21 +1211,21 @@ macho_objfmt_output(yasm_object *object, FILE *f, int all_syms, /* get back to end of raw section data */ if (fseek(f, (long)fileoff_sections, SEEK_SET) < 0) { - yasm__fatal(N_("could not seek on output file")); - /*@notreached@*/ - return; + yasm__fatal(N_("could not seek on output file")); + /*@notreached@*/ + return; } /* padding to long boundary */ - if ((info.rel_base - fileoff_sections) > 0) { - fwrite(pad_data, info.rel_base - fileoff_sections, 1, f); + if (info.rel_base - (fileoffset + info.filesize)) { + fwrite(pad_data, info.rel_base - (fileoffset + info.filesize), 1, f); } /* relocation data */ yasm_object_sections_traverse(object, &info, macho_objfmt_output_relocs); /* symbol table (NLIST) */ - info.indx = 1; /* restart symbol table indices */ + info.indx = 1; /* restart symbol table indices */ yasm_symtab_traverse(object->symtab, &info, macho_objfmt_output_symtable); /* symbol strings */ @@ -1272,11 +1242,10 @@ macho_objfmt_destroy(yasm_objfmt *objfmt) yasm_xfree(objfmt); } -static void -macho_objfmt_init_new_section(yasm_section *sect, unsigned long line) +static macho_section_data * +macho_objfmt_init_new_section(yasm_object *object, yasm_section *sect, + const char *sectname, unsigned long line) { - yasm_object *object = yasm_section_get_object(sect); - const char *sectname = yasm_section_get_name(sect); yasm_objfmt_macho *objfmt_macho = (yasm_objfmt_macho *)object->objfmt; macho_section_data *data; yasm_symrec *sym; @@ -1294,8 +1263,9 @@ macho_objfmt_init_new_section(yasm_section *sect, unsigned long line) yasm_section_add_data(sect, &macho_section_data_cb, data); sym = yasm_symtab_define_label(object->symtab, sectname, - yasm_section_bcs_first(sect), 1, line); + yasm_section_bcs_first(sect), 1, line); data->sym = sym; + return data; } static yasm_section * @@ -1305,43 +1275,24 @@ macho_objfmt_add_default_section(yasm_object *object) macho_section_data *msd; int isnew; - /* Create a dummy __asm marker section with a single zero byte. This tells - * the Apple toolchain that the code came from assembler and has no bitcode. - */ - retval = yasm_object_get_general(object, ".llvmasm", 0, 0, 0, &isnew, 0); + retval = yasm_object_get_general(object, "LC_SEGMENT.__TEXT.__text", 0, 0, 1, 0, + &isnew, 0); if (isnew) { - yasm_datavalhead dvs; - - msd = yasm_section_get_data(retval, &macho_section_data_cb); - msd->segname = yasm__xstrdup("__LLVM"); - msd->sectname = yasm__xstrdup("__asm"); - yasm_section_set_align(retval, 0, 0); - yasm_dvs_initialize(&dvs); - yasm_dvs_append(&dvs, yasm_dv_create_expr( - yasm_expr_create_ident( - yasm_expr_int(yasm_intnum_create_uint(0)), 0))); - yasm_section_bcs_append(retval, - yasm_bc_create_data(&dvs, 1, 0, object->arch, 0)); - } - - retval = yasm_object_get_general(object, "LC_SEGMENT.__TEXT.__text", 0, 1, - 0, &isnew, 0); - if (isnew) { - msd = yasm_section_get_data(retval, &macho_section_data_cb); + msd = macho_objfmt_init_new_section(object, retval, ".text", 0); msd->segname = yasm__xstrdup("__TEXT"); msd->sectname = yasm__xstrdup("__text"); - msd->flags = S_ATTR_PURE_INSTRUCTIONS; - yasm_section_set_align(retval, 0, 0); - yasm_section_set_default(retval, 1); + msd->flags = S_ATTR_PURE_INSTRUCTIONS; + yasm_section_set_align(retval, 0, 0); + yasm_section_set_default(retval, 1); } return retval; } static /*@observer@*/ /*@null@*/ yasm_section * macho_objfmt_section_switch(yasm_object *object, yasm_valparamhead *valparams, - /*@unused@*/ /*@null@*/ - yasm_valparamhead *objext_valparams, - unsigned long line) + /*@unused@*/ /*@null@*/ + yasm_valparamhead *objext_valparams, + unsigned long line) { yasm_valparam *vp; yasm_section *retval; @@ -1357,69 +1308,68 @@ macho_objfmt_section_switch(yasm_object *object, yasm_valparamhead *valparams, size_t i; static const struct { - const char *in; - const char *seg; - const char *sect; - unsigned long flags; - unsigned long align; + const char *in; + const char *seg; + const char *sect; + unsigned long flags; + unsigned long align; } section_name_translation[] = { - {".text", "__TEXT", "__text", S_ATTR_PURE_INSTRUCTIONS, 0}, - {".const", "__TEXT", "__const", S_REGULAR, 0}, - {".static_const", "__TEXT", "__static_const", S_REGULAR, 0}, - {".cstring", "__TEXT", "__cstring", S_CSTRING_LITERALS, 0}, - {".literal4", "__TEXT", "__literal4", S_4BYTE_LITERALS, 4}, - {".literal8", "__TEXT", "__literal8", S_8BYTE_LITERALS, 8}, - {".literal16", "__TEXT", "__literal16", S_16BYTE_LITERALS, 16}, - {".constructor", "__TEXT", "__constructor", S_REGULAR, 0}, - {".destructor", "__TEXT", "__destructor", S_REGULAR, 0}, - {".fvmlib_init0", "__TEXT", "__fvmlib_init0", S_REGULAR, 0}, - {".fvmlib_init1", "__TEXT", "__fvmlib_init1", S_REGULAR, 0}, - {".mod_init_func", "__DATA", "__mod_init_func", - S_MOD_INIT_FUNC_POINTERS, 4}, - {".mod_term_func", "__DATA", "__mod_term_func", - S_MOD_TERM_FUNC_POINTERS, 4}, - {".dyld", "__DATA", "__dyld", S_REGULAR, 0}, - {".data", "__DATA", "__data", S_REGULAR, 0}, - {".static_data", "__DATA", "__static_data", S_REGULAR, 0}, - {".const_data", "__DATA", "__const", S_REGULAR, 0}, - {".rodata", "__DATA", "__const", S_REGULAR, 0}, - {".bss", "__DATA", "__bss", S_ZEROFILL, 0}, - {".llvmasm", "__LLVM", "__asm", S_REGULAR, 0}, - {".objc_class_names", "__TEXT", "__cstring", S_CSTRING_LITERALS, 0}, - {".objc_meth_var_types","__TEXT", "__cstring", S_CSTRING_LITERALS, 0}, - {".objc_meth_var_names","__TEXT", "__cstring", S_CSTRING_LITERALS, 0}, - {".objc_selector_strs", "__OBJC", "__selector_strs", - S_CSTRING_LITERALS, 0}, - {".objc_class", "__OBJC", "__class", - S_ATTR_NO_DEAD_STRIP, 0}, - {".objc_meta_class", "__OBJC", "__meta_class", - S_ATTR_NO_DEAD_STRIP, 0}, - {".objc_string_object", "__OBJC", "__string_object", - S_ATTR_NO_DEAD_STRIP, 0}, - {".objc_protocol", "__OBJC", "__protocol", - S_ATTR_NO_DEAD_STRIP, 0}, - {".objc_cat_cls_meth", "__OBJC", "__cat_cls_meth", - S_ATTR_NO_DEAD_STRIP, 0}, - {".objc_cat_inst_meth", "__OBJC", "__cat_inst_meth", - S_ATTR_NO_DEAD_STRIP, 0}, - {".objc_cls_meth", "__OBJC", "__cls_meth", - S_ATTR_NO_DEAD_STRIP, 0}, - {".objc_inst_meth", "__OBJC", "__inst_meth", - S_ATTR_NO_DEAD_STRIP, 0}, - {".objc_message_refs", "__OBJC", "__message_refs", - S_LITERAL_POINTERS|S_ATTR_NO_DEAD_STRIP, 4}, - {".objc_cls_refs", "__OBJC", "__cls_refs", - S_LITERAL_POINTERS|S_ATTR_NO_DEAD_STRIP, 4}, - {".objc_module_info", "__OBJC", "__module_info", - S_ATTR_NO_DEAD_STRIP, 0}, - {".objc_symbols", "__OBJC", "__symbols", - S_ATTR_NO_DEAD_STRIP, 0}, - {".objc_category", "__OBJC", "__category", - S_ATTR_NO_DEAD_STRIP, 0}, - {".objc_class_vars", "__OBJC", "__class_vars", - S_ATTR_NO_DEAD_STRIP, 0}, - {".objc_instance_vars", "__OBJC", "__instance_vars", - S_ATTR_NO_DEAD_STRIP, 0} + {".text", "__TEXT", "__text", S_ATTR_PURE_INSTRUCTIONS, 0}, + {".const", "__TEXT", "__const", S_REGULAR, 0}, + {".static_const", "__TEXT", "__static_const", S_REGULAR, 0}, + {".cstring", "__TEXT", "__cstring", S_CSTRING_LITERALS, 0}, + {".literal4", "__TEXT", "__literal4", S_4BYTE_LITERALS, 4}, + {".literal8", "__TEXT", "__literal8", S_8BYTE_LITERALS, 8}, + {".literal16", "__TEXT", "__literal16", S_16BYTE_LITERALS, 16}, + {".constructor", "__TEXT", "__constructor", S_REGULAR, 0}, + {".destructor", "__TEXT", "__destructor", S_REGULAR, 0}, + {".fvmlib_init0", "__TEXT", "__fvmlib_init0", S_REGULAR, 0}, + {".fvmlib_init1", "__TEXT", "__fvmlib_init1", S_REGULAR, 0}, + {".mod_init_func", "__DATA", "__mod_init_func", + S_MOD_INIT_FUNC_POINTERS, 4}, + {".mod_term_func", "__DATA", "__mod_term_func", + S_MOD_TERM_FUNC_POINTERS, 4}, + {".dyld", "__DATA", "__dyld", S_REGULAR, 0}, + {".data", "__DATA", "__data", S_REGULAR, 0}, + {".static_data", "__DATA", "__static_data", S_REGULAR, 0}, + {".const_data", "__DATA", "__const", S_REGULAR, 0}, + {".rodata", "__DATA", "__const", S_REGULAR, 0}, + {".bss", "__DATA", "__bss", S_ZEROFILL, 0}, + {".objc_class_names", "__TEXT", "__cstring", S_CSTRING_LITERALS, 0}, + {".objc_meth_var_types","__TEXT", "__cstring", S_CSTRING_LITERALS, 0}, + {".objc_meth_var_names","__TEXT", "__cstring", S_CSTRING_LITERALS, 0}, + {".objc_selector_strs", "__OBJC", "__selector_strs", + S_CSTRING_LITERALS, 0}, + {".objc_class", "__OBJC", "__class", + S_ATTR_NO_DEAD_STRIP, 0}, + {".objc_meta_class", "__OBJC", "__meta_class", + S_ATTR_NO_DEAD_STRIP, 0}, + {".objc_string_object", "__OBJC", "__string_object", + S_ATTR_NO_DEAD_STRIP, 0}, + {".objc_protocol", "__OBJC", "__protocol", + S_ATTR_NO_DEAD_STRIP, 0}, + {".objc_cat_cls_meth", "__OBJC", "__cat_cls_meth", + S_ATTR_NO_DEAD_STRIP, 0}, + {".objc_cat_inst_meth", "__OBJC", "__cat_inst_meth", + S_ATTR_NO_DEAD_STRIP, 0}, + {".objc_cls_meth", "__OBJC", "__cls_meth", + S_ATTR_NO_DEAD_STRIP, 0}, + {".objc_inst_meth", "__OBJC", "__inst_meth", + S_ATTR_NO_DEAD_STRIP, 0}, + {".objc_message_refs", "__OBJC", "__message_refs", + S_LITERAL_POINTERS|S_ATTR_NO_DEAD_STRIP, 4}, + {".objc_cls_refs", "__OBJC", "__cls_refs", + S_LITERAL_POINTERS|S_ATTR_NO_DEAD_STRIP, 4}, + {".objc_module_info", "__OBJC", "__module_info", + S_ATTR_NO_DEAD_STRIP, 0}, + {".objc_symbols", "__OBJC", "__symbols", + S_ATTR_NO_DEAD_STRIP, 0}, + {".objc_category", "__OBJC", "__category", + S_ATTR_NO_DEAD_STRIP, 0}, + {".objc_class_vars", "__OBJC", "__class_vars", + S_ATTR_NO_DEAD_STRIP, 0}, + {".objc_instance_vars", "__OBJC", "__instance_vars", + S_ATTR_NO_DEAD_STRIP, 0} }; struct macho_section_switch_data { @@ -1445,8 +1395,8 @@ macho_objfmt_section_switch(yasm_object *object, yasm_valparamhead *valparams, /* translate .text,.data,.bss to __text,__data,__bss... */ for (i=0; ival && (s = yasm_vp_string(vp))) { /* Treat as SEGNAME, SECTNAME */ if (strlen(sectname) > 16) - yasm_warn_set(YASM_WARN_GENERAL, + yasm_warn_set(YASM_WARN_GENERAL, N_("segment name is too long, max 16 chars; truncating")); data.f_segname = yasm__xstrndup(sectname, 16); if (strlen(s) > 16) @@ -1474,12 +1424,12 @@ macho_objfmt_section_switch(yasm_object *object, yasm_valparamhead *valparams, f_sectname = yasm__xstrndup(sectname, 16); flags = S_ATTR_SOME_INSTRUCTIONS; align = 0; - } + } } else { data.f_segname = yasm__xstrdup(section_name_translation[i].seg); f_sectname = yasm__xstrdup(section_name_translation[i].sect); - flags = section_name_translation[i].flags; - align = section_name_translation[i].align; + flags = section_name_translation[i].flags; + align = section_name_translation[i].align; } flags_override = yasm_dir_helper(object, vp, line, help, NELEMS(help), @@ -1491,20 +1441,20 @@ macho_objfmt_section_switch(yasm_object *object, yasm_valparamhead *valparams, align = yasm_intnum_get_uint(data.align_intn); yasm_intnum_destroy(data.align_intn); - /* Alignments must be a power of two. */ - if (!is_exp2(align)) { - yasm_error_set(YASM_ERROR_VALUE, - N_("argument to `%s' is not a power of two"), - vp->val); - return NULL; - } + /* Alignments must be a power of two. */ + if (!is_exp2(align)) { + yasm_error_set(YASM_ERROR_VALUE, + N_("argument to `%s' is not a power of two"), + vp->val); + return NULL; + } - /* Check to see if alignment is supported size */ - if (align > 16384) { - yasm_error_set(YASM_ERROR_VALUE, - N_("macho implementation does not support alignments > 16384")); - return NULL; - } + /* Check to see if alignment is supported size */ + if (align > 16384) { + yasm_error_set(YASM_ERROR_VALUE, + N_("macho implementation does not support alignments > 16384")); + return NULL; + } } if (!data.f_segname) { @@ -1517,39 +1467,27 @@ macho_objfmt_section_switch(yasm_object *object, yasm_valparamhead *valparams, realname = yasm_xmalloc(strlen("LC_SEGMENT") + 1 + strlen(data.f_segname) + 1 + strlen(f_sectname) + 1); sprintf(realname, "LC_SEGMENT.%s.%s", data.f_segname, f_sectname); - retval = yasm_object_get_general(object, realname, align, 1, resonly, - &isnew, line); + retval = yasm_object_get_general(object, realname, 0, align, 1, resonly, + &isnew, line); yasm_xfree(realname); - msd = yasm_section_get_data(retval, &macho_section_data_cb); + if (isnew) + msd = macho_objfmt_init_new_section(object, retval, sectname, line); + else + msd = yasm_section_get_data(retval, &macho_section_data_cb); if (isnew || yasm_section_is_default(retval)) { - yasm_section_set_default(retval, 0); + yasm_section_set_default(retval, 0); msd->segname = data.f_segname; - msd->sectname = f_sectname; - msd->flags = flags; - yasm_section_set_align(retval, align, line); - } else if (flags_override) { - /* align is the only value used from overrides. */ - if (yasm_section_get_align(retval) != align) { - yasm_warn_set(YASM_WARN_GENERAL, - N_("section flags ignored on section redeclaration")); - } - } + msd->sectname = f_sectname; + msd->flags = flags; + yasm_section_set_align(retval, align, line); + } else if (flags_override) + yasm_warn_set(YASM_WARN_GENERAL, + N_("section flags ignored on section redeclaration")); return retval; } -static /*@observer@*/ /*@null@*/ yasm_symrec * -macho_objfmt_get_special_sym(yasm_object *object, const char *name, - const char *parser) -{ - yasm_objfmt_macho *objfmt_macho = (yasm_objfmt_macho *)object->objfmt; - if (yasm__strcasecmp(name, "gotpcrel") == 0) { - return objfmt_macho->gotpcrel_sym; - } - return NULL; -} - static void macho_section_data_destroy(void *data) { @@ -1588,57 +1526,9 @@ macho_symrec_data_print(void *data, FILE *f, int indent_level) fprintf(f, "%*sindex=%ld\n", indent_level, "", msd->index); fprintf(f, "%*svalue=", indent_level, ""); if (msd->value) - fprintf(f, "%ld\n", yasm_intnum_get_int(msd->value)); + fprintf(f, "%ld\n", yasm_intnum_get_int(msd->value)); else - fprintf(f, "nil\n"); -} - -static void -parse_version(unsigned long *out, const yasm_valparam *vp) -{ - unsigned long major, minor, subminor; - int m; - - if (vp->type != YASM_PARAM_STRING) { - yasm_error_set(YASM_ERROR_VALUE, - N_("argument to `%s' is not a string"), vp->val); - return; - } - - subminor = 0; - m = sscanf(vp->param.str, "%lu.%lu.%lu", &major, &minor, &subminor); - if (m < 2) { - yasm_error_set(YASM_ERROR_VALUE, - N_("argument to `%s' must be `MAJOR.MINOR[.SUBMINOR]`"), - vp->val); - return; - } - - *out = ((major & 0xffff) << 16) | ((minor & 0xff) << 8) | (subminor & 0xff); -} - -static void -dir_buildversion(yasm_object *object, yasm_valparamhead *valparams, - yasm_valparamhead *objext_valparams, unsigned long line) -{ - yasm_objfmt_macho *objfmt_macho = (yasm_objfmt_macho *)object->objfmt; - yasm_valparam *vp; - - /* Accept, but do nothing with empty ident */ - if (!valparams) - return; - - vp = yasm_vps_first(valparams); - while (vp) { - if (vp->val && yasm__strcasecmp(vp->val, "minos") == 0) { - parse_version(&objfmt_macho->minos, vp); - } else if (vp->val && yasm__strcasecmp(vp->val, "sdk") == 0) { - parse_version(&objfmt_macho->sdk, vp); - } else { - yasm_dir_helper_valparam_warn(object, vp, line, NULL); - } - vp = yasm_vps_next(vp); - } + fprintf(f, "nil\n"); } @@ -1648,30 +1538,20 @@ static const char *macho_objfmt_dbgfmt_keywords[] = { NULL }; -static const yasm_directive macho_objfmt_directives[] = { - { ".buildversion", "gas", dir_buildversion, YASM_DIR_ANY }, - { "buildversion", "nasm", dir_buildversion, YASM_DIR_ANY }, - { NULL, NULL, NULL, 0 } -}; - /* Define objfmt structure -- see objfmt.h for details */ yasm_objfmt_module yasm_macho_LTX_objfmt = { "Mac OS X ABI Mach-O File Format", "macho", "o", 32, - 0, macho_objfmt_dbgfmt_keywords, "null", - macho_objfmt_directives, - NULL, /* no standard macros */ + NULL, /* no directives */ macho_objfmt_create, macho_objfmt_output, macho_objfmt_destroy, macho_objfmt_add_default_section, - macho_objfmt_init_new_section, - macho_objfmt_section_switch, - macho_objfmt_get_special_sym + macho_objfmt_section_switch }; yasm_objfmt_module yasm_macho32_LTX_objfmt = { @@ -1679,18 +1559,14 @@ yasm_objfmt_module yasm_macho32_LTX_objfmt = { "macho32", "o", 32, - 0, macho_objfmt_dbgfmt_keywords, "null", - macho_objfmt_directives, - NULL, /* no standard macros */ + NULL, /* no directives */ macho32_objfmt_create, macho_objfmt_output, macho_objfmt_destroy, macho_objfmt_add_default_section, - macho_objfmt_init_new_section, - macho_objfmt_section_switch, - macho_objfmt_get_special_sym + macho_objfmt_section_switch }; yasm_objfmt_module yasm_macho64_LTX_objfmt = { @@ -1698,16 +1574,12 @@ yasm_objfmt_module yasm_macho64_LTX_objfmt = { "macho64", "o", 64, - 0, macho_objfmt_dbgfmt_keywords, "null", - macho_objfmt_directives, - NULL, /* no standard macros */ + NULL, /* no directives */ macho64_objfmt_create, macho_objfmt_output, macho_objfmt_destroy, macho_objfmt_add_default_section, - macho_objfmt_init_new_section, - macho_objfmt_section_switch, - macho_objfmt_get_special_sym + macho_objfmt_section_switch }; diff --git a/modules/objfmts/macho/tests/Makefile.inc b/modules/objfmts/macho/tests/Makefile.inc index e8b4dc1f..bff27f5b 100644 --- a/modules/objfmts/macho/tests/Makefile.inc +++ b/modules/objfmts/macho/tests/Makefile.inc @@ -1,3 +1,5 @@ +# $Id$ + EXTRA_DIST += modules/objfmts/macho/tests/gas32/Makefile.inc EXTRA_DIST += modules/objfmts/macho/tests/gas64/Makefile.inc EXTRA_DIST += modules/objfmts/macho/tests/nasm32/Makefile.inc diff --git a/modules/objfmts/macho/tests/gas32/Makefile.inc b/modules/objfmts/macho/tests/gas32/Makefile.inc index a02b3b3e..ac36c09c 100644 --- a/modules/objfmts/macho/tests/gas32/Makefile.inc +++ b/modules/objfmts/macho/tests/gas32/Makefile.inc @@ -1,3 +1,5 @@ +# $Id$ + TESTS += modules/objfmts/macho/tests/gas32/gas_macho32_test.sh EXTRA_DIST += modules/objfmts/macho/tests/gas32/gas_macho32_test.sh diff --git a/modules/objfmts/macho/tests/gas32/gas-macho32.hex b/modules/objfmts/macho/tests/gas32/gas-macho32.hex index ba0d6c4d..72cdabde 100644 --- a/modules/objfmts/macho/tests/gas32/gas-macho32.hex +++ b/modules/objfmts/macho/tests/gas32/gas-macho32.hex @@ -14,162 +14,70 @@ fe 00 00 00 +02 +00 +00 +00 +1c +01 +00 +00 +00 +00 +00 +00 +01 +00 +00 +00 +04 +01 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +89 +00 +00 +00 +38 +01 +00 +00 +81 +00 +00 +00 +07 +00 +00 +00 +07 +00 +00 +00 03 00 00 00 -78 -01 -00 -00 -00 -00 -00 -00 -32 -00 -00 -00 -18 -00 -00 -00 -01 -00 -00 -00 -00 -04 -0a -00 -00 -04 -0a -00 -00 -00 -00 -00 -01 -00 -00 -00 -48 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -8a -00 -00 -00 -94 -01 -00 -00 -82 -00 -00 -00 -07 -00 -00 -00 -07 -00 -00 -00 -04 -00 -00 -00 -00 -00 -00 -00 -5f -5f -61 -73 -6d -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -5f -5f -4c -4c -56 -4d -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -01 -00 -00 -00 -94 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 00 00 00 @@ -206,7 +114,7 @@ fe 00 00 00 -01 +00 00 00 00 @@ -214,7 +122,7 @@ fe 00 00 00 -95 +38 01 00 00 @@ -222,8 +130,8 @@ fe 00 00 00 -18 -02 +bc +01 00 00 07 @@ -274,7 +182,7 @@ fe 00 00 00 -42 +41 00 00 00 @@ -282,7 +190,7 @@ fe 00 00 00 -d6 +79 01 00 00 @@ -290,8 +198,8 @@ d6 00 00 00 -50 -02 +f4 +01 00 00 03 @@ -342,7 +250,7 @@ d6 00 00 00 -82 +81 00 00 00 @@ -386,7 +294,7 @@ d6 00 00 00 -68 +0c 02 00 00 @@ -394,7 +302,7 @@ d6 00 00 00 -c8 +6c 02 00 00 @@ -402,7 +310,6 @@ c8 00 00 00 -00 55 89 e5 @@ -421,13 +328,13 @@ ec 5d c3 a1 -82 +81 00 00 00 40 a3 -86 +85 00 00 00 @@ -438,7 +345,7 @@ ff 00 00 a1 -76 +75 00 00 00 @@ -446,13 +353,13 @@ ff 30 ff 35 -82 +81 00 00 00 ff 35 -4f +4e 00 00 00 @@ -520,15 +427,16 @@ c3 64 0a 00 -86 +85 00 00 00 -12 +11 00 00 00 -7e +7d +00 00 00 00 @@ -538,7 +446,7 @@ c3 00 00 00 -04 +03 00 00 04 @@ -546,7 +454,7 @@ c3 00 00 00 -04 +03 00 00 04 @@ -562,7 +470,7 @@ c3 00 00 00 -03 +02 00 00 04 @@ -570,7 +478,7 @@ c3 00 00 00 -04 +03 00 00 04 @@ -578,7 +486,7 @@ c3 00 00 00 -03 +02 00 00 04 @@ -594,7 +502,7 @@ c3 00 00 00 -04 +03 00 00 04 @@ -602,7 +510,7 @@ c3 00 00 00 -02 +01 00 00 04 @@ -610,7 +518,7 @@ c3 00 00 00 -03 +02 00 00 04 @@ -619,22 +527,22 @@ c3 00 00 0f -02 -00 -00 01 00 00 00 +00 +00 +00 0a 00 00 00 0f -02 +01 00 00 -12 +11 00 00 00 @@ -643,10 +551,10 @@ c3 00 00 0f -03 +02 00 00 -42 +41 00 00 00 @@ -655,10 +563,10 @@ c3 00 00 0f -03 +02 00 00 -7a +79 00 00 00 @@ -667,10 +575,10 @@ c3 00 00 0f -03 +02 00 00 -7e +7d 00 00 00 @@ -679,10 +587,10 @@ c3 00 00 0f -04 +03 00 00 -82 +81 00 00 00 diff --git a/modules/objfmts/macho/tests/gas32/gas_macho32_test.sh b/modules/objfmts/macho/tests/gas32/gas_macho32_test.sh index 45a1e104..48f871d4 100755 --- a/modules/objfmts/macho/tests/gas32/gas_macho32_test.sh +++ b/modules/objfmts/macho/tests/gas32/gas_macho32_test.sh @@ -1,3 +1,4 @@ #! /bin/sh +# $Id$ ${srcdir}/out_test.sh macho_test modules/objfmts/macho/tests/gas32 "GAS 32-bit macho objfmt" "-f macho32 -p gas" ".o" exit $? diff --git a/modules/objfmts/macho/tests/gas64/Makefile.inc b/modules/objfmts/macho/tests/gas64/Makefile.inc index ec99a219..79d85edc 100644 --- a/modules/objfmts/macho/tests/gas64/Makefile.inc +++ b/modules/objfmts/macho/tests/gas64/Makefile.inc @@ -1,7 +1,7 @@ +# $Id$ + TESTS += modules/objfmts/macho/tests/gas64/gas_macho64_test.sh EXTRA_DIST += modules/objfmts/macho/tests/gas64/gas_macho64_test.sh EXTRA_DIST += modules/objfmts/macho/tests/gas64/gas-macho64.asm EXTRA_DIST += modules/objfmts/macho/tests/gas64/gas-macho64.hex -EXTRA_DIST += modules/objfmts/macho/tests/gas64/gas-macho64-pic.asm -EXTRA_DIST += modules/objfmts/macho/tests/gas64/gas-macho64-pic.hex diff --git a/modules/objfmts/macho/tests/gas64/gas-macho64-pic.asm b/modules/objfmts/macho/tests/gas64/gas-macho64-pic.asm deleted file mode 100644 index c44502b3..00000000 --- a/modules/objfmts/macho/tests/gas64/gas-macho64-pic.asm +++ /dev/null @@ -1,32 +0,0 @@ -call _foo -# r_type=X86_64_RELOC_BRANCH, r_length=2, r_extern=1, r_pcrel=1, r_symbolnum=_foo -# E8 00 00 00 00 - -call _foo+4 -# r_type=X86_64_RELOC_BRANCH, r_length=2, r_extern=1, r_pcrel=1, r_symbolnum=_foo -# E8 04 00 00 00 - -movq _foo@GOTPCREL(%rip), %rax -# r_type=X86_64_RELOC_GOT_LOAD, r_length=2, r_extern=1, r_pcrel=1, r_symbolnum=_foo -# 48 8B 05 00 00 00 00 - -pushq _foo@GOTPCREL(%rip) -# r_type=X86_64_RELOC_GOT, r_length=2, r_extern=1, r_pcrel=1, r_symbolnum=_foo -# FF 35 00 00 00 00 - -movl _foo(%rip), %eax -# r_type=X86_64_RELOC_SIGNED, r_length=2, r_extern=1, r_pcrel=1, r_symbolnum=_foo -# 8B 05 00 00 00 00 - -movl _foo+4(%rip), %eax -# r_type=X86_64_RELOC_SIGNED, r_length=2, r_extern=1, r_pcrel=1, r_symbolnum=_foo -# 8B 05 04 00 00 00 - -movb $0x12, _foo(%rip) -# r_type=X86_64_RELOC_SIGNED, r_length=2, r_extern=1, r_pcrel=1, r_symbolnum=_foo -# C6 05 FF FF FF FF 12 - -movl $0x12345678, _foo(%rip) -# r_type=X86_64_RELOC_SIGNED, r_length=2, r_extern=1, r_pcrel=1, r_symbolnum=_foo -# C7 05 FC FF FF FF 78 56 34 12 - diff --git a/modules/objfmts/macho/tests/gas64/gas-macho64-pic.hex b/modules/objfmts/macho/tests/gas64/gas-macho64-pic.hex deleted file mode 100644 index f84e075b..00000000 --- a/modules/objfmts/macho/tests/gas64/gas-macho64-pic.hex +++ /dev/null @@ -1,454 +0,0 @@ -cf -fa -ed -fe -07 -00 -00 -01 -03 -00 -00 -00 -01 -00 -00 -00 -03 -00 -00 -00 -18 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -32 -00 -00 -00 -18 -00 -00 -00 -01 -00 -00 -00 -00 -05 -0a -00 -00 -05 -0a -00 -00 -00 -00 -00 -19 -00 -00 -00 -e8 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -35 -00 -00 -00 -00 -00 -00 -00 -38 -01 -00 -00 -00 -00 -00 -00 -35 -00 -00 -00 -00 -00 -00 -00 -07 -00 -00 -00 -07 -00 -00 -00 -02 -00 -00 -00 -00 -00 -00 -00 -5f -5f -61 -73 -6d -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -5f -5f -4c -4c -56 -4d -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -01 -00 -00 -00 -00 -00 -00 -00 -38 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -5f -5f -74 -65 -78 -74 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -5f -5f -54 -45 -58 -54 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -01 -00 -00 -00 -00 -00 -00 -00 -34 -00 -00 -00 -00 -00 -00 -00 -39 -01 -00 -00 -00 -00 -00 -00 -70 -01 -00 -00 -08 -00 -00 -00 -00 -03 -00 -80 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -02 -00 -00 -00 -18 -00 -00 -00 -b0 -01 -00 -00 -01 -00 -00 -00 -c0 -01 -00 -00 -06 -00 -00 -00 -00 -e8 -00 -00 -00 -00 -e8 -04 -00 -00 -00 -48 -8b -05 -00 -00 -00 -00 -ff -35 -00 -00 -00 -00 -8b -05 -00 -00 -00 -00 -8b -05 -04 -00 -00 -00 -c6 -05 -ff -ff -ff -ff -12 -c7 -05 -fc -ff -ff -ff -78 -56 -34 -12 -00 -00 -00 -01 -00 -00 -00 -00 -00 -00 -2d -06 -00 -00 -00 -00 -00 -00 -2d -0d -00 -00 -00 -00 -00 -00 -3d -13 -00 -00 -00 -00 -00 -00 -4d -19 -00 -00 -00 -00 -00 -00 -1d -1f -00 -00 -00 -00 -00 -00 -1d -25 -00 -00 -00 -00 -00 -00 -1d -2c -00 -00 -00 -00 -00 -00 -1d -01 -00 -00 -00 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -5f -66 -6f -6f -00 diff --git a/modules/objfmts/macho/tests/gas64/gas-macho64.hex b/modules/objfmts/macho/tests/gas64/gas-macho64.hex index 6e281529..e4fa4882 100644 --- a/modules/objfmts/macho/tests/gas64/gas-macho64.hex +++ b/modules/objfmts/macho/tests/gas64/gas-macho64.hex @@ -14,42 +14,18 @@ fe 00 00 00 -03 +02 00 00 00 -68 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -32 -00 -00 -00 -18 -00 -00 00 01 00 00 00 00 -05 -0a 00 00 -05 -0a -00 00 00 00 @@ -58,7 +34,43 @@ fe 00 00 00 -38 +e8 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +c5 +00 +00 +00 +00 +00 +00 +00 +20 01 00 00 @@ -66,43 +78,7 @@ fe 00 00 00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -c6 -00 -00 -00 -00 -00 -00 -00 -88 -01 -00 -00 -00 -00 -00 -00 -c6 +c5 00 00 00 @@ -118,87 +94,7 @@ c6 00 00 00 -03 -00 -00 -00 -00 -00 -00 -00 -5f -5f -61 -73 -6d -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -5f -5f -4c -4c -56 -4d -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -01 -00 -00 -00 -00 -00 -00 -00 -88 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 +02 00 00 00 @@ -238,7 +134,7 @@ c6 00 00 00 -01 +00 00 00 00 @@ -254,7 +150,7 @@ c6 00 00 00 -89 +20 01 00 00 @@ -262,8 +158,8 @@ c6 00 00 00 -50 -02 +e8 +01 00 00 0c @@ -318,7 +214,7 @@ c6 00 00 00 -5e +5d 00 00 00 @@ -334,7 +230,7 @@ c6 00 00 00 -e6 +7d 01 00 00 @@ -374,7 +270,7 @@ e6 00 00 00 -b0 +48 02 00 00 @@ -382,7 +278,7 @@ b0 00 00 00 -f0 +88 02 00 00 @@ -390,7 +286,6 @@ f0 00 00 00 -00 e8 00 00 @@ -590,6 +485,7 @@ ff 00 00 00 +00 01 00 00 @@ -707,10 +603,10 @@ ff 00 00 0e -03 +02 00 00 -c6 +c5 00 00 00 @@ -723,10 +619,10 @@ c6 00 00 0e -03 +02 00 00 -b4 +b3 00 00 00 @@ -739,10 +635,10 @@ b4 00 00 0e -03 +02 00 00 -b4 +b3 00 00 00 diff --git a/modules/objfmts/macho/tests/gas64/gas_macho64_test.sh b/modules/objfmts/macho/tests/gas64/gas_macho64_test.sh index d3ead46c..577bf83f 100755 --- a/modules/objfmts/macho/tests/gas64/gas_macho64_test.sh +++ b/modules/objfmts/macho/tests/gas64/gas_macho64_test.sh @@ -1,3 +1,4 @@ #! /bin/sh +# $Id$ ${srcdir}/out_test.sh macho_test modules/objfmts/macho/tests/gas64 "GAS 64-bit macho objfmt" "-f macho64 -p gas" ".o" exit $? diff --git a/modules/objfmts/macho/tests/nasm32/Makefile.inc b/modules/objfmts/macho/tests/nasm32/Makefile.inc index 2bba5de7..1ee18be1 100644 --- a/modules/objfmts/macho/tests/nasm32/Makefile.inc +++ b/modules/objfmts/macho/tests/nasm32/Makefile.inc @@ -1,3 +1,5 @@ +# $Id$ + TESTS += modules/objfmts/macho/tests/nasm32/macho32_test.sh EXTRA_DIST += modules/objfmts/macho/tests/nasm32/macho32_test.sh @@ -6,12 +8,6 @@ EXTRA_DIST += modules/objfmts/macho/tests/nasm32/machotest.asm EXTRA_DIST += modules/objfmts/macho/tests/nasm32/machotest.hex EXTRA_DIST += modules/objfmts/macho/tests/nasm32/macho-reloc.asm EXTRA_DIST += modules/objfmts/macho/tests/nasm32/macho-reloc.hex -EXTRA_DIST += modules/objfmts/macho/tests/nasm32/macho32-pext.asm -EXTRA_DIST += modules/objfmts/macho/tests/nasm32/macho32-pext.hex -EXTRA_DIST += modules/objfmts/macho/tests/nasm32/macho32-pic.asm -EXTRA_DIST += modules/objfmts/macho/tests/nasm32/macho32-pic.hex EXTRA_DIST += modules/objfmts/macho/tests/nasm32/macho32-sect.asm EXTRA_DIST += modules/objfmts/macho/tests/nasm32/macho32-sect.errwarn EXTRA_DIST += modules/objfmts/macho/tests/nasm32/macho32-sect.hex -EXTRA_DIST += modules/objfmts/macho/tests/nasm32/macho32-size.asm -EXTRA_DIST += modules/objfmts/macho/tests/nasm32/macho32-size.hex diff --git a/modules/objfmts/macho/tests/nasm32/macho-reloc.hex b/modules/objfmts/macho/tests/nasm32/macho-reloc.hex index 8dc58940..7ef6e8a1 100644 --- a/modules/objfmts/macho/tests/nasm32/macho-reloc.hex +++ b/modules/objfmts/macho/tests/nasm32/macho-reloc.hex @@ -14,48 +14,23 @@ fe 00 00 00 -03 +02 00 00 00 -34 -01 +d8 00 00 00 00 00 00 -32 -00 -00 -00 -18 -00 -00 -00 -01 -00 -00 -00 -00 -04 -0a -00 -00 -04 -0a -00 -00 -00 -00 00 01 00 00 00 -04 -01 +c0 00 00 00 @@ -78,15 +53,16 @@ fe 00 00 00 -2c +00 +2b 00 00 00 -50 -01 +f4 00 00 -2c +00 +2b 00 00 00 @@ -98,75 +74,7 @@ fe 00 00 00 -03 -00 -00 -00 -00 -00 -00 -00 -5f -5f -61 -73 -6d -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -5f -5f -4c -4c -56 -4d -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -01 -00 -00 -00 -50 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 +02 00 00 00 @@ -206,7 +114,7 @@ fe 00 00 00 -01 +00 00 00 00 @@ -214,15 +122,15 @@ fe 00 00 00 -51 -01 +f4 00 00 00 00 00 00 -7c +00 +20 01 00 00 @@ -274,7 +182,7 @@ fe 00 00 00 -29 +28 00 00 00 @@ -282,7 +190,7 @@ fe 00 00 00 -79 +1c 01 00 00 @@ -318,7 +226,7 @@ fe 00 00 00 -b4 +58 01 00 00 @@ -326,7 +234,7 @@ b4 00 00 00 -d8 +7c 01 00 00 @@ -334,7 +242,6 @@ d8 00 00 00 -00 b8 02 00 @@ -356,17 +263,17 @@ a1 00 00 b8 -01 +00 00 00 00 b8 -1a +19 00 00 00 b8 -23 +22 00 00 00 @@ -378,6 +285,7 @@ b8 05 05 00 +00 01 00 00 @@ -414,7 +322,7 @@ b8 00 00 00 -02 +01 00 00 04 @@ -422,7 +330,7 @@ b8 00 00 00 -02 +01 00 00 04 @@ -430,7 +338,7 @@ b8 00 00 00 -02 +01 00 00 04 @@ -439,10 +347,10 @@ b8 00 00 0f -03 +02 00 00 -2a +29 00 00 00 diff --git a/modules/objfmts/macho/tests/nasm32/macho32-pext.asm b/modules/objfmts/macho/tests/nasm32/macho32-pext.asm deleted file mode 100644 index f881b4fc..00000000 --- a/modules/objfmts/macho/tests/nasm32/macho32-pext.asm +++ /dev/null @@ -1,4 +0,0 @@ -[GLOBAL function:private_extern] - -function: - ret diff --git a/modules/objfmts/macho/tests/nasm32/macho32-pext.hex b/modules/objfmts/macho/tests/nasm32/macho32-pext.hex deleted file mode 100644 index c57c549a..00000000 --- a/modules/objfmts/macho/tests/nasm32/macho32-pext.hex +++ /dev/null @@ -1,294 +0,0 @@ -ce -fa -ed -fe -07 -00 -00 -00 -03 -00 -00 -00 -01 -00 -00 -00 -03 -00 -00 -00 -f0 -00 -00 -00 -00 -00 -00 -00 -32 -00 -00 -00 -18 -00 -00 -00 -01 -00 -00 -00 -00 -04 -0a -00 -00 -04 -0a -00 -00 -00 -00 -00 -01 -00 -00 -00 -c0 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -02 -00 -00 -00 -0c -01 -00 -00 -02 -00 -00 -00 -07 -00 -00 -00 -07 -00 -00 -00 -02 -00 -00 -00 -00 -00 -00 -00 -5f -5f -61 -73 -6d -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -5f -5f -4c -4c -56 -4d -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -01 -00 -00 -00 -0c -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -5f -5f -74 -65 -78 -74 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -5f -5f -54 -45 -58 -54 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -01 -00 -00 -00 -01 -00 -00 -00 -0d -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -80 -00 -00 -00 -00 -00 -00 -00 -00 -02 -00 -00 -00 -18 -00 -00 -00 -10 -01 -00 -00 -01 -00 -00 -00 -1c -01 -00 -00 -0a -00 -00 -00 -00 -c3 -00 -00 -01 -00 -00 -00 -1f -02 -00 -00 -01 -00 -00 -00 -00 -66 -75 -6e -63 -74 -69 -6f -6e -00 diff --git a/modules/objfmts/macho/tests/nasm32/macho32-pic.asm b/modules/objfmts/macho/tests/nasm32/macho32-pic.asm deleted file mode 100644 index 438923d1..00000000 --- a/modules/objfmts/macho/tests/nasm32/macho32-pic.asm +++ /dev/null @@ -1,46 +0,0 @@ -; At present, nasm doesn't seem to support PIC generation for Mach-O. -; The PIC support code below is a little tricky. -[extern func] - SECTION .rodata -const_base: - -%define GOTOFF(got,sym) (got) + (sym) - const_base - -%imacro get_GOT 1 - ; NOTE: this macro destroys ecx resister. - call %%geteip - add ecx, byte (%%ref - $) - jmp short %%adjust -%%geteip: - mov ecx, [esp] - ret -%%adjust: - push ebp - xor ebp,ebp ; ebp = 0 -%ifidni %1,ebx ; (%1 == ebx) - ; db 0x8D,0x9C + jmp near const_base = - ; lea ebx, [ecx+ebp*8+(const_base-%%ref)] ; 8D,9C,E9,(offset32) - db 0x8D,0x9C ; 8D,9C - jmp near const_base ; E9,(const_base-%%ref) -%%ref: -%else ; (%1 != ebx) - ; db 0x8D,0x8C + jmp near const_base = - ; lea ecx, [ecx+ebp*8+(const_base-%%ref)] ; 8D,8C,E9,(offset32) - db 0x8D,0x8C ; 8D,8C - jmp strict near const_base ; E9,(const_base-%%ref) -%%ref: mov %1, ecx -%endif ; (%1 == ebx) - pop ebp -%endmacro - -SECTION .text - -jmp const_base - -get_GOT ebx - -jmp const_base - -call func - -ret diff --git a/modules/objfmts/macho/tests/nasm32/macho32-pic.hex b/modules/objfmts/macho/tests/nasm32/macho32-pic.hex deleted file mode 100644 index 9b92e0bf..00000000 --- a/modules/objfmts/macho/tests/nasm32/macho32-pic.hex +++ /dev/null @@ -1,430 +0,0 @@ -ce -fa -ed -fe -07 -00 -00 -00 -03 -00 -00 -00 -01 -00 -00 -00 -03 -00 -00 -00 -34 -01 -00 -00 -00 -00 -00 -00 -32 -00 -00 -00 -18 -00 -00 -00 -01 -00 -00 -00 -00 -04 -0a -00 -00 -04 -0a -00 -00 -00 -00 -00 -01 -00 -00 -00 -04 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -2a -00 -00 -00 -50 -01 -00 -00 -2a -00 -00 -00 -07 -00 -00 -00 -07 -00 -00 -00 -03 -00 -00 -00 -00 -00 -00 -00 -5f -5f -61 -73 -6d -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -5f -5f -4c -4c -56 -4d -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -01 -00 -00 -00 -50 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -5f -5f -74 -65 -78 -74 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -5f -5f -54 -45 -58 -54 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -01 -00 -00 -00 -29 -00 -00 -00 -51 -01 -00 -00 -00 -00 -00 -00 -7c -01 -00 -00 -04 -00 -00 -00 -00 -03 -00 -80 -00 -00 -00 -00 -00 -00 -00 -00 -5f -5f -63 -6f -6e -73 -74 -00 -00 -00 -00 -00 -00 -00 -00 -00 -5f -5f -44 -41 -54 -41 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -2a -00 -00 -00 -00 -00 -00 -00 -7a -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -02 -00 -00 -00 -18 -00 -00 -00 -9c -01 -00 -00 -01 -00 -00 -00 -a8 -01 -00 -00 -06 -00 -00 -00 -00 -e9 -25 -00 -00 -00 -e8 -05 -00 -00 -00 -83 -c1 -13 -eb -04 -8b -0c -24 -c3 -55 -31 -ed -8d -9c -e9 -0d -00 -00 -00 -5d -e9 -07 -00 -00 -00 -e8 -d8 -ff -ff -ff -c3 -00 -00 -01 -00 -00 -00 -03 -00 -00 -05 -19 -00 -00 -00 -03 -00 -00 -05 -1f -00 -00 -00 -03 -00 -00 -05 -24 -00 -00 -00 -00 -00 -00 -0d -01 -00 -00 -00 -01 -00 -00 -00 -00 -00 -00 -00 -00 -66 -75 -6e -63 -00 diff --git a/modules/objfmts/macho/tests/nasm32/macho32-sect.hex b/modules/objfmts/macho/tests/nasm32/macho32-sect.hex index d4e35f01..eff781a5 100644 --- a/modules/objfmts/macho/tests/nasm32/macho32-sect.hex +++ b/modules/objfmts/macho/tests/nasm32/macho32-sect.hex @@ -14,23 +14,15 @@ fe 00 00 00 +01 +00 +00 +00 +e0 02 00 00 00 -3c -03 -00 -00 -00 -00 -00 -00 -32 -00 -00 -00 -18 00 00 00 @@ -38,24 +30,8 @@ fe 00 00 00 -00 -04 -0a -00 -00 -04 -0a -00 -00 -00 -00 -00 -01 -00 -00 -00 -24 -03 +e0 +02 00 00 00 @@ -78,15 +54,15 @@ fe 00 00 00 -01 00 00 00 -58 -03 +00 +fc +02 +00 00 00 -01 00 00 00 @@ -98,75 +74,7 @@ fe 00 00 00 -0b -00 -00 -00 -00 -00 -00 -00 -5f -5f -61 -73 -6d -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -5f -5f -4c -4c -56 -4d -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -01 -00 -00 -00 -70 -03 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 +0a 00 00 00 @@ -206,7 +114,6 @@ fe 00 00 00 -01 00 00 00 @@ -214,7 +121,8 @@ fe 00 00 00 -71 +00 +14 03 00 00 @@ -274,7 +182,6 @@ fe 00 00 00 -01 00 00 00 @@ -282,7 +189,8 @@ fe 00 00 00 -71 +00 +14 03 00 00 @@ -342,7 +250,6 @@ fe 00 00 00 -01 00 00 00 @@ -350,7 +257,8 @@ fe 00 00 00 -71 +00 +14 03 00 00 @@ -410,7 +318,6 @@ fe 00 00 00 -01 00 00 00 @@ -418,7 +325,8 @@ fe 00 00 00 -71 +00 +14 03 00 00 @@ -478,7 +386,6 @@ fe 00 00 00 -01 00 00 00 @@ -486,7 +393,8 @@ fe 00 00 00 -71 +00 +14 03 00 00 @@ -546,7 +454,6 @@ fe 00 00 00 -01 00 00 00 @@ -554,7 +461,8 @@ fe 00 00 00 -71 +00 +14 03 00 00 @@ -614,7 +522,6 @@ fe 00 00 00 -01 00 00 00 @@ -622,7 +529,8 @@ fe 00 00 00 -71 +00 +14 03 00 00 @@ -682,7 +590,6 @@ fe 45 47 4e -01 00 00 00 @@ -690,7 +597,8 @@ fe 00 00 00 -71 +00 +14 03 00 00 @@ -750,7 +658,6 @@ fe 00 00 00 -01 00 00 00 @@ -758,7 +665,8 @@ fe 00 00 00 -71 +00 +14 03 00 00 @@ -818,7 +726,6 @@ fe 53 45 47 -01 00 00 00 @@ -826,7 +733,8 @@ fe 00 00 00 -71 +00 +14 03 00 00 @@ -862,16 +770,16 @@ fe 00 00 00 -74 -03 +fc +02 00 00 00 00 00 00 -74 -03 +fc +02 00 00 01 @@ -879,7 +787,3 @@ fe 00 00 00 -00 -00 -00 -00 diff --git a/modules/objfmts/macho/tests/nasm32/macho32-size.asm b/modules/objfmts/macho/tests/nasm32/macho32-size.asm deleted file mode 100644 index f8cd50fa..00000000 --- a/modules/objfmts/macho/tests/nasm32/macho32-size.asm +++ /dev/null @@ -1,60 +0,0 @@ - section .data align=16 - - align 16 - - mmx_yuy2_00ff dw 000ffh, 000ffh, 000ffh, 000ffh - - section .text - -; -- Import/Export ------------------------------------------------------ - - global mb_yuy2yuv_mmx - - struc macroblock_yuy2_param - .dsty: resd 1 - .dstu: resd 1 - .dstv: resd 1 - .dypitch: resd 1 - .dcpitch: resd 1 - .src: resd 1 - .spitch: resd 1 - endstruc - -; ----------------------------------------------------------------------- -; -= mb_yuy2yuv_mmx =- -; -; extern "C" int __fastcall mb_yuy2yuv_mmx( macroblock_param *param ); -; ----------------------------------------------------------------------- - - align 16 - -mb_yuy2yuv_mmx: - - push ebx - push edx - - push esi - push edi - push ebp - - mov esi, [ecx + macroblock_yuy2_param.src] - mov edx, [ecx + macroblock_yuy2_param.spitch] - - mov edi, [ecx + macroblock_yuy2_param.dsty] - mov eax, [ecx + macroblock_yuy2_param.dstu] - mov ebx, [ecx + macroblock_yuy2_param.dstv] - - mov ebp, [ecx + macroblock_yuy2_param.dypitch] - mov ecx, [ecx + macroblock_yuy2_param.dcpitch] - - movq mm6, [mmx_yuy2_00ff] - - pop ebp - pop edi - pop esi - - pop edx - pop ebx - - retn - diff --git a/modules/objfmts/macho/tests/nasm32/macho32-size.hex b/modules/objfmts/macho/tests/nasm32/macho32-size.hex deleted file mode 100644 index 3ae12b81..00000000 --- a/modules/objfmts/macho/tests/nasm32/macho32-size.hex +++ /dev/null @@ -1,420 +0,0 @@ -ce -fa -ed -fe -07 -00 -00 -00 -03 -00 -00 -00 -01 -00 -00 -00 -03 -00 -00 -00 -34 -01 -00 -00 -00 -00 -00 -00 -32 -00 -00 -00 -18 -00 -00 -00 -01 -00 -00 -00 -00 -04 -0a -00 -00 -04 -0a -00 -00 -00 -00 -00 -01 -00 -00 -00 -04 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -48 -00 -00 -00 -50 -01 -00 -00 -2f -00 -00 -00 -07 -00 -00 -00 -07 -00 -00 -00 -03 -00 -00 -00 -00 -00 -00 -00 -5f -5f -61 -73 -6d -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -5f -5f -4c -4c -56 -4d -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -01 -00 -00 -00 -50 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -5f -5f -74 -65 -78 -74 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -5f -5f -54 -45 -58 -54 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -10 -00 -00 -00 -26 -00 -00 -00 -51 -01 -00 -00 -04 -00 -00 -00 -80 -01 -00 -00 -01 -00 -00 -00 -00 -01 -00 -80 -00 -00 -00 -00 -00 -00 -00 -00 -5f -5f -64 -61 -74 -61 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -5f -5f -44 -41 -54 -41 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -40 -00 -00 -00 -08 -00 -00 -00 -77 -01 -00 -00 -04 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -02 -00 -00 -00 -18 -00 -00 -00 -88 -01 -00 -00 -01 -00 -00 -00 -94 -01 -00 -00 -10 -00 -00 -00 -00 -53 -52 -56 -57 -55 -8b -71 -14 -8b -51 -18 -8b -39 -8b -41 -04 -8b -59 -08 -8b -69 -0c -8b -49 -10 -0f -6f -35 -40 -00 -00 -00 -5d -5f -5e -5a -5b -c3 -ff -00 -ff -00 -ff -00 -ff -00 -00 -1c -00 -00 -00 -03 -00 -00 -04 -01 -00 -00 -00 -0f -02 -00 -00 -10 -00 -00 -00 -00 -6d -62 -5f -79 -75 -79 -32 -79 -75 -76 -5f -6d -6d -78 -00 diff --git a/modules/objfmts/macho/tests/nasm32/macho32_test.sh b/modules/objfmts/macho/tests/nasm32/macho32_test.sh index e5fdcc95..64d9c4a3 100755 --- a/modules/objfmts/macho/tests/nasm32/macho32_test.sh +++ b/modules/objfmts/macho/tests/nasm32/macho32_test.sh @@ -1,3 +1,4 @@ #! /bin/sh +# $Id$ ${srcdir}/out_test.sh macho_test modules/objfmts/macho/tests/nasm32 "32-bit macho objfmt" "-f macho32" ".o" exit $? diff --git a/modules/objfmts/macho/tests/nasm32/machotest.c b/modules/objfmts/macho/tests/nasm32/machotest.c index 42fc92c0..84badeed 100644 --- a/modules/objfmts/macho/tests/nasm32/machotest.c +++ b/modules/objfmts/macho/tests/nasm32/machotest.c @@ -29,7 +29,7 @@ int main(void) { greet(); printf("These pointers should be equal: %p and %p\n", - &greet, textptr); + &greet, textptr); printf("So should these: %p and %p\n", selfptr, &selfptr); } diff --git a/modules/objfmts/macho/tests/nasm32/machotest.hex b/modules/objfmts/macho/tests/nasm32/machotest.hex index e4c5442a..e6791e4e 100644 --- a/modules/objfmts/macho/tests/nasm32/machotest.hex +++ b/modules/objfmts/macho/tests/nasm32/machotest.hex @@ -14,162 +14,70 @@ fe 00 00 00 +02 +00 +00 +00 +1c +01 +00 +00 +00 +00 +00 +00 +01 +00 +00 +00 +04 +01 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +8f +00 +00 +00 +38 +01 +00 +00 +87 +00 +00 +00 +07 +00 +00 +00 +07 +00 +00 +00 03 00 00 00 -78 -01 -00 -00 -00 -00 -00 -00 -32 -00 -00 -00 -18 -00 -00 -00 -01 -00 -00 -00 -00 -04 -0a -00 -00 -04 -0a -00 -00 -00 -00 -00 -01 -00 -00 -00 -48 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -90 -00 -00 -00 -94 -01 -00 -00 -88 -00 -00 -00 -07 -00 -00 -00 -07 -00 -00 -00 -04 -00 -00 -00 -00 -00 -00 -00 -5f -5f -61 -73 -6d -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -5f -5f -4c -4c -56 -4d -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -01 -00 -00 -00 -94 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 00 00 00 @@ -206,7 +114,7 @@ fe 00 00 00 -01 +00 00 00 00 @@ -214,7 +122,7 @@ fe 00 00 00 -95 +38 01 00 00 @@ -222,8 +130,8 @@ fe 00 00 00 -1c -02 +c0 +01 00 00 07 @@ -274,7 +182,7 @@ fe 00 00 00 -48 +47 00 00 00 @@ -282,7 +190,7 @@ fe 00 00 00 -dc +7f 01 00 00 @@ -290,8 +198,8 @@ dc 00 00 00 -54 -02 +f8 +01 00 00 03 @@ -342,7 +250,7 @@ dc 00 00 00 -88 +87 00 00 00 @@ -386,7 +294,7 @@ dc 00 00 00 -6c +10 02 00 00 @@ -394,7 +302,7 @@ dc 00 00 00 -cc +70 02 00 00 @@ -402,7 +310,6 @@ cc 00 00 00 -00 55 89 e5 @@ -421,13 +328,13 @@ ec 5d c3 a1 -88 +87 00 00 00 40 a3 -8c +8b 00 00 00 @@ -438,7 +345,7 @@ ff 00 00 a1 -7c +7b 00 00 00 @@ -446,12 +353,12 @@ ff 30 ff 35 -88 +87 00 00 00 68 -55 +54 00 00 00 @@ -526,7 +433,16 @@ ff 64 0a 00 -8c +8b +00 +00 +00 +11 +00 +00 +00 +83 +00 00 00 00 @@ -534,15 +450,7 @@ ff 00 00 00 -84 -00 -00 -00 -12 -00 -00 -00 -04 +03 00 00 04 @@ -550,7 +458,7 @@ ff 00 00 00 -04 +03 00 00 04 @@ -566,7 +474,7 @@ ff 00 00 00 -03 +02 00 00 04 @@ -574,7 +482,7 @@ ff 00 00 00 -04 +03 00 00 04 @@ -582,7 +490,7 @@ ff 00 00 00 -03 +02 00 00 04 @@ -598,7 +506,7 @@ ff 00 00 00 -04 +03 00 00 04 @@ -606,7 +514,7 @@ ff 00 00 00 -02 +01 00 00 04 @@ -614,7 +522,7 @@ ff 00 00 00 -03 +02 00 00 04 @@ -623,22 +531,22 @@ ff 00 00 0f -02 -00 -00 01 00 00 00 +00 +00 +00 0a 00 00 00 0f -02 +01 00 00 -12 +11 00 00 00 @@ -647,10 +555,10 @@ ff 00 00 0f -03 +02 00 00 -48 +47 00 00 00 @@ -659,10 +567,10 @@ ff 00 00 0f -03 +02 00 00 -80 +7f 00 00 00 @@ -671,10 +579,10 @@ ff 00 00 0f -03 +02 00 00 -84 +83 00 00 00 @@ -683,10 +591,10 @@ ff 00 00 0f -04 +03 00 00 -88 +87 00 00 00 diff --git a/modules/objfmts/macho/tests/nasm64/Makefile.inc b/modules/objfmts/macho/tests/nasm64/Makefile.inc index 93ec45e9..efe5de4d 100644 --- a/modules/objfmts/macho/tests/nasm64/Makefile.inc +++ b/modules/objfmts/macho/tests/nasm64/Makefile.inc @@ -1,7 +1,7 @@ +# $Id$ + TESTS += modules/objfmts/macho/tests/nasm64/macho64_test.sh -EXTRA_DIST += modules/objfmts/macho/tests/nasm64/nasm-macho64-pic.asm -EXTRA_DIST += modules/objfmts/macho/tests/nasm64/nasm-macho64-pic.hex EXTRA_DIST += modules/objfmts/macho/tests/nasm64/macho64_test.sh EXTRA_DIST += modules/objfmts/macho/tests/nasm64/machotest64.c EXTRA_DIST += modules/objfmts/macho/tests/nasm64/machotest64.asm diff --git a/modules/objfmts/macho/tests/nasm64/macho-reloc64-err.errwarn b/modules/objfmts/macho/tests/nasm64/macho-reloc64-err.errwarn index 1a118833..3d4e5d97 100644 --- a/modules/objfmts/macho/tests/nasm64/macho-reloc64-err.errwarn +++ b/modules/objfmts/macho/tests/nasm64/macho-reloc64-err.errwarn @@ -1,8 +1,8 @@ --:20: error: macho: sorry, cannot apply 32 bit absolute relocations in 64 bit mode, consider "[_symbol wrt rip]" for mem access, "qword" and "dq _foo" for pointers. --:21: error: macho: sorry, cannot apply 32 bit absolute relocations in 64 bit mode, consider "[_symbol wrt rip]" for mem access, "qword" and "dq _foo" for pointers. --:23: error: macho: sorry, cannot apply 32 bit absolute relocations in 64 bit mode, consider "[_symbol wrt rip]" for mem access, "qword" and "dq _foo" for pointers. --:24: error: macho: sorry, cannot apply 32 bit absolute relocations in 64 bit mode, consider "[_symbol wrt rip]" for mem access, "qword" and "dq _foo" for pointers. --:25: error: macho: sorry, cannot apply 32 bit absolute relocations in 64 bit mode, consider "[_symbol wrt rip]" for mem access, "qword" and "dq _foo" for pointers. --:26: error: macho: sorry, cannot apply 32 bit absolute relocations in 64 bit mode, consider "[_symbol wrt rip]" for mem access, "qword" and "dq _foo" for pointers. --:27: error: macho: sorry, cannot apply 32 bit absolute relocations in 64 bit mode, consider "[_symbol wrt rip]" for mem access, "qword" and "dq _foo" for pointers. --:29: error: macho: invalid WRT +-:20: macho: sorry, cannot apply 32 bit absolute relocations in 64 bit mode, consider "[_symbol wrt rip]" for mem access, "qword" and "dq _foo" for pointers. +-:21: macho: sorry, cannot apply 32 bit absolute relocations in 64 bit mode, consider "[_symbol wrt rip]" for mem access, "qword" and "dq _foo" for pointers. +-:23: macho: sorry, cannot apply 32 bit absolute relocations in 64 bit mode, consider "[_symbol wrt rip]" for mem access, "qword" and "dq _foo" for pointers. +-:24: macho: sorry, cannot apply 32 bit absolute relocations in 64 bit mode, consider "[_symbol wrt rip]" for mem access, "qword" and "dq _foo" for pointers. +-:25: macho: sorry, cannot apply 32 bit absolute relocations in 64 bit mode, consider "[_symbol wrt rip]" for mem access, "qword" and "dq _foo" for pointers. +-:26: macho: sorry, cannot apply 32 bit absolute relocations in 64 bit mode, consider "[_symbol wrt rip]" for mem access, "qword" and "dq _foo" for pointers. +-:27: macho: sorry, cannot apply 32 bit absolute relocations in 64 bit mode, consider "[_symbol wrt rip]" for mem access, "qword" and "dq _foo" for pointers. +-:29: macho: WRT not supported diff --git a/modules/objfmts/macho/tests/nasm64/macho64-buildversion.asm b/modules/objfmts/macho/tests/nasm64/macho64-buildversion.asm deleted file mode 100644 index a277f7c4..00000000 --- a/modules/objfmts/macho/tests/nasm64/macho64-buildversion.asm +++ /dev/null @@ -1,2 +0,0 @@ -[buildversion minos="10.14.2" sdk="10.7"] - diff --git a/modules/objfmts/macho/tests/nasm64/macho64-buildversion.hex b/modules/objfmts/macho/tests/nasm64/macho64-buildversion.hex deleted file mode 100644 index c8ed6de9..00000000 --- a/modules/objfmts/macho/tests/nasm64/macho64-buildversion.hex +++ /dev/null @@ -1,317 +0,0 @@ -cf -fa -ed -fe -07 -00 -00 -01 -03 -00 -00 -00 -01 -00 -00 -00 -02 -00 -00 -00 -00 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -32 -00 -00 -00 -18 -00 -00 -00 -01 -00 -00 -00 -02 -0e -0a -00 -00 -07 -0a -00 -00 -00 -00 -00 -19 -00 -00 -00 -e8 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -01 -00 -00 -00 -00 -00 -00 -00 -20 -01 -00 -00 -00 -00 -00 -00 -01 -00 -00 -00 -00 -00 -00 -00 -07 -00 -00 -00 -07 -00 -00 -00 -02 -00 -00 -00 -00 -00 -00 -00 -5f -5f -61 -73 -6d -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -5f -5f -4c -4c -56 -4d -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -01 -00 -00 -00 -00 -00 -00 -00 -38 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -5f -5f -74 -65 -78 -74 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -5f -5f -54 -45 -58 -54 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -39 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -80 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -02 -00 -00 -00 -18 -00 -00 -00 -3c -01 -00 -00 -00 -00 -00 -00 -3c -01 -00 -00 -01 -00 -00 -00 -00 -00 -00 -00 -00 diff --git a/modules/objfmts/macho/tests/nasm64/macho64_test.sh b/modules/objfmts/macho/tests/nasm64/macho64_test.sh index f7c0bfbb..30e23248 100755 --- a/modules/objfmts/macho/tests/nasm64/macho64_test.sh +++ b/modules/objfmts/macho/tests/nasm64/macho64_test.sh @@ -1,3 +1,4 @@ #! /bin/sh +# $Id$ ${srcdir}/out_test.sh macho_test modules/objfmts/macho/tests/nasm64 "64-bit macho objfmt" "-f macho64" ".o" exit $? diff --git a/modules/objfmts/macho/tests/nasm64/machotest64.c b/modules/objfmts/macho/tests/nasm64/machotest64.c index c0f1e3c4..a77e5e5d 100644 --- a/modules/objfmts/macho/tests/nasm64/machotest64.c +++ b/modules/objfmts/macho/tests/nasm64/machotest64.c @@ -26,10 +26,10 @@ int main(void) { printf("This string should read `hello, world': `%s'\n", asmstr); { - long a,b; - a = (long)asmstr; - b = (long)getstr(); - printf("The pointers %lx and %lx should be equal\n",a,b); + long a,b; + a = (long)asmstr; + b = (long)getstr(); + printf("The pointers %lx and %lx should be equal\n",a,b); } printf("This string should read `hello, world': `%s'\n", getstr()); @@ -40,7 +40,7 @@ int main(void) { printf("The absolute addressing to the asm-local integer should yield in 1235:\n%ld\n",readgreet()); printf("These pointers should be equal: %p and %p\n", - &greet, textptr); + &greet, textptr); printf("So should these: %p and %p\n", selfptr, &selfptr); } diff --git a/modules/objfmts/macho/tests/nasm64/machotest64.hex b/modules/objfmts/macho/tests/nasm64/machotest64.hex index e8b38768..21395186 100644 --- a/modules/objfmts/macho/tests/nasm64/machotest64.hex +++ b/modules/objfmts/macho/tests/nasm64/machotest64.hex @@ -14,11 +14,11 @@ fe 00 00 00 -03 +02 00 00 00 -b8 +50 01 00 00 @@ -30,35 +30,11 @@ b8 00 00 00 -32 -00 -00 -00 -18 -00 -00 -00 -01 -00 -00 -00 -00 -05 -0a -00 -00 -05 -0a -00 -00 -00 -00 -00 19 00 00 00 -88 +38 01 00 00 @@ -86,7 +62,7 @@ b8 00 00 00 -d7 +d6 00 00 00 @@ -94,7 +70,7 @@ d7 00 00 00 -d8 +70 01 00 00 @@ -102,7 +78,7 @@ d8 00 00 00 -c7 +c6 00 00 00 @@ -118,87 +94,7 @@ c7 00 00 00 -04 -00 -00 -00 -00 -00 -00 -00 -5f -5f -61 -73 -6d -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -5f -5f -4c -4c -56 -4d -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -01 -00 -00 -00 -00 -00 -00 -00 -d8 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 +03 00 00 00 @@ -238,7 +134,7 @@ d8 00 00 00 -01 +00 00 00 00 @@ -254,7 +150,7 @@ d8 00 00 00 -d9 +70 01 00 00 @@ -262,7 +158,7 @@ d9 00 00 00 -a0 +38 02 00 00 @@ -318,7 +214,7 @@ a0 00 00 00 -7b +7a 00 00 00 @@ -334,15 +230,15 @@ a0 00 00 00 -53 -02 +ea +01 00 00 00 00 00 00 -f0 +88 02 00 00 @@ -398,7 +294,7 @@ f0 00 00 00 -c7 +c6 00 00 00 @@ -454,15 +350,15 @@ c7 00 00 00 -08 -03 +a0 +02 00 00 0f 00 00 00 -f8 +90 03 00 00 @@ -470,7 +366,6 @@ f8 00 00 00 -00 51 48 89 @@ -670,6 +565,7 @@ ff 64 00 00 +00 10 00 00 @@ -779,9 +675,6 @@ ff 00 00 0f -02 -00 -00 01 00 00 @@ -790,15 +683,18 @@ ff 00 00 00 +00 +00 +00 0a 00 00 00 0f -02 +01 00 00 -30 +2f 00 00 00 @@ -811,10 +707,10 @@ ff 00 00 0f -03 +02 00 00 -ba +b9 00 00 00 @@ -827,10 +723,10 @@ ba 00 00 0f -03 +02 00 00 -aa +a9 00 00 00 @@ -843,10 +739,10 @@ aa 00 00 0f -03 +02 00 00 -b2 +b1 00 00 00 @@ -859,10 +755,10 @@ b2 00 00 0f -04 +03 00 00 -c7 +c6 00 00 00 @@ -907,10 +803,10 @@ c7 00 00 0f -02 +01 00 00 -0f +0e 00 00 00 @@ -923,10 +819,10 @@ c7 00 00 0f -02 +01 00 00 -1a +19 00 00 00 @@ -939,10 +835,10 @@ c7 00 00 0e -02 +01 00 00 -08 +07 00 00 00 @@ -955,10 +851,10 @@ c7 00 00 0e -04 +03 00 00 -cf +ce 00 00 00 @@ -971,10 +867,10 @@ cf 00 00 0e -02 +01 00 00 -25 +24 00 00 00 @@ -987,10 +883,10 @@ cf 00 00 0e -03 +02 00 00 -a2 +a1 00 00 00 @@ -1003,10 +899,10 @@ a2 00 00 0e -03 +02 00 00 -7b +7a 00 00 00 diff --git a/modules/objfmts/macho/tests/nasm64/nasm-macho64-pic.asm b/modules/objfmts/macho/tests/nasm64/nasm-macho64-pic.asm deleted file mode 100644 index 7b46163e..00000000 --- a/modules/objfmts/macho/tests/nasm64/nasm-macho64-pic.asm +++ /dev/null @@ -1,34 +0,0 @@ -[extern _foo] - -call _foo -; r_type=X86_64_RELOC_BRANCH, r_length=2, r_extern=1, r_pcrel=1, r_symbolnum=_foo -; E8 00 00 00 00 - -call _foo+4 -; r_type=X86_64_RELOC_BRANCH, r_length=2, r_extern=1, r_pcrel=1, r_symbolnum=_foo -; E8 04 00 00 00 - -mov rax, [rel _foo wrt ..gotpcrel] -; r_type=X86_64_RELOC_GOT_LOAD, r_length=2, r_extern=1, r_pcrel=1, r_symbolnum=_foo -; 48 8B 05 00 00 00 00 - -push qword [rel _foo wrt ..gotpcrel] -; r_type=X86_64_RELOC_GOT, r_length=2, r_extern=1, r_pcrel=1, r_symbolnum=_foo -; FF 35 00 00 00 00 - -mov eax, [rel _foo] -; r_type=X86_64_RELOC_SIGNED, r_length=2, r_extern=1, r_pcrel=1, r_symbolnum=_foo -; 8B 05 00 00 00 00 - -mov eax, [rel _foo+4] -; r_type=X86_64_RELOC_SIGNED, r_length=2, r_extern=1, r_pcrel=1, r_symbolnum=_foo -; 8B 05 04 00 00 00 - -mov [rel _foo], byte 12h -; r_type=X86_64_RELOC_SIGNED, r_length=2, r_extern=1, r_pcrel=1, r_symbolnum=_foo -; C6 05 FF FF FF FF 12 - -mov dword [rel _foo], 0x12345678 -; r_type=X86_64_RELOC_SIGNED, r_length=2, r_extern=1, r_pcrel=1, r_symbolnum=_foo -; C7 05 FC FF FF FF 78 56 34 12 - diff --git a/modules/objfmts/macho/tests/nasm64/nasm-macho64-pic.hex b/modules/objfmts/macho/tests/nasm64/nasm-macho64-pic.hex deleted file mode 100644 index f84e075b..00000000 --- a/modules/objfmts/macho/tests/nasm64/nasm-macho64-pic.hex +++ /dev/null @@ -1,454 +0,0 @@ -cf -fa -ed -fe -07 -00 -00 -01 -03 -00 -00 -00 -01 -00 -00 -00 -03 -00 -00 -00 -18 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -32 -00 -00 -00 -18 -00 -00 -00 -01 -00 -00 -00 -00 -05 -0a -00 -00 -05 -0a -00 -00 -00 -00 -00 -19 -00 -00 -00 -e8 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -35 -00 -00 -00 -00 -00 -00 -00 -38 -01 -00 -00 -00 -00 -00 -00 -35 -00 -00 -00 -00 -00 -00 -00 -07 -00 -00 -00 -07 -00 -00 -00 -02 -00 -00 -00 -00 -00 -00 -00 -5f -5f -61 -73 -6d -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -5f -5f -4c -4c -56 -4d -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -01 -00 -00 -00 -00 -00 -00 -00 -38 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -5f -5f -74 -65 -78 -74 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -5f -5f -54 -45 -58 -54 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -01 -00 -00 -00 -00 -00 -00 -00 -34 -00 -00 -00 -00 -00 -00 -00 -39 -01 -00 -00 -00 -00 -00 -00 -70 -01 -00 -00 -08 -00 -00 -00 -00 -03 -00 -80 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -02 -00 -00 -00 -18 -00 -00 -00 -b0 -01 -00 -00 -01 -00 -00 -00 -c0 -01 -00 -00 -06 -00 -00 -00 -00 -e8 -00 -00 -00 -00 -e8 -04 -00 -00 -00 -48 -8b -05 -00 -00 -00 -00 -ff -35 -00 -00 -00 -00 -8b -05 -00 -00 -00 -00 -8b -05 -04 -00 -00 -00 -c6 -05 -ff -ff -ff -ff -12 -c7 -05 -fc -ff -ff -ff -78 -56 -34 -12 -00 -00 -00 -01 -00 -00 -00 -00 -00 -00 -2d -06 -00 -00 -00 -00 -00 -00 -2d -0d -00 -00 -00 -00 -00 -00 -3d -13 -00 -00 -00 -00 -00 -00 -4d -19 -00 -00 -00 -00 -00 -00 -1d -1f -00 -00 -00 -00 -00 -00 -1d -25 -00 -00 -00 -00 -00 -00 -1d -2c -00 -00 -00 -00 -00 -00 -1d -01 -00 -00 -00 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -5f -66 -6f -6f -00 diff --git a/modules/objfmts/rdf/CMakeLists.txt b/modules/objfmts/rdf/CMakeLists.txt deleted file mode 100644 index 6cf9157d..00000000 --- a/modules/objfmts/rdf/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -YASM_ADD_MODULE(objfmt_rdf - objfmts/rdf/rdf-objfmt.c - ) diff --git a/modules/objfmts/rdf/Makefile.inc b/modules/objfmts/rdf/Makefile.inc index f5e01e15..ef33dffb 100644 --- a/modules/objfmts/rdf/Makefile.inc +++ b/modules/objfmts/rdf/Makefile.inc @@ -1,3 +1,5 @@ +# $Id$ + libyasm_a_SOURCES += modules/objfmts/rdf/rdf-objfmt.c YASM_MODULES += objfmt_rdf diff --git a/modules/objfmts/rdf/rdf-objfmt.c b/modules/objfmts/rdf/rdf-objfmt.c index eb3c6668..4a788b81 100644 --- a/modules/objfmts/rdf/rdf-objfmt.c +++ b/modules/objfmts/rdf/rdf-objfmt.c @@ -25,78 +25,82 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include +/*@unused@*/ RCSID("$Id$"); +#define YASM_LIB_INTERNAL +#define YASM_BC_INTERNAL +#define YASM_EXPR_INTERNAL #include -#define REGULAR_OUTBUF_SIZE 1024 +#define REGULAR_OUTBUF_SIZE 1024 -#define RDF_MAGIC "RDOFF2" +#define RDF_MAGIC "RDOFF2" /* Maximum size of an import/export label (including trailing zero) */ -#define EXIM_LABEL_MAX 64 +#define EXIM_LABEL_MAX 64 /* Maximum size of library or module name (including trailing zero) */ -#define MODLIB_NAME_MAX 128 +#define MODLIB_NAME_MAX 128 /* Maximum number of segments that we can handle in one file */ -#define RDF_MAXSEGS 64 +#define RDF_MAXSEGS 64 /* Record types that may present the RDOFF header */ -#define RDFREC_GENERIC 0 -#define RDFREC_RELOC 1 -#define RDFREC_IMPORT 2 -#define RDFREC_GLOBAL 3 -#define RDFREC_DLL 4 -#define RDFREC_BSS 5 -#define RDFREC_SEGRELOC 6 -#define RDFREC_FARIMPORT 7 -#define RDFREC_MODNAME 8 -#define RDFREC_COMMON 10 +#define RDFREC_GENERIC 0 +#define RDFREC_RELOC 1 +#define RDFREC_IMPORT 2 +#define RDFREC_GLOBAL 3 +#define RDFREC_DLL 4 +#define RDFREC_BSS 5 +#define RDFREC_SEGRELOC 6 +#define RDFREC_FARIMPORT 7 +#define RDFREC_MODNAME 8 +#define RDFREC_COMMON 10 /* Flags for ExportRec/ImportRec */ -#define SYM_DATA 1 -#define SYM_FUNCTION 2 +#define SYM_DATA 1 +#define SYM_FUNCTION 2 /* Flags for ExportRec */ -#define SYM_GLOBAL 4 +#define SYM_GLOBAL 4 /* Flags for ImportRec */ -#define SYM_IMPORT 8 -#define SYM_FAR 16 +#define SYM_IMPORT 8 +#define SYM_FAR 16 typedef struct rdf_reloc { yasm_reloc reloc; enum { - RDF_RELOC_NORM, /* normal */ - RDF_RELOC_REL, /* relative to current position */ - RDF_RELOC_SEG /* segment containing symbol */ - } type; /* type of relocation */ + RDF_RELOC_NORM, /* normal */ + RDF_RELOC_REL, /* relative to current position */ + RDF_RELOC_SEG /* segment containing symbol */ + } type; /* type of relocation */ unsigned int size; unsigned int refseg; } rdf_reloc; typedef struct rdf_section_data { - /*@dependent@*/ yasm_symrec *sym; /* symbol created for this section */ - long scnum; /* section number (0=first section) */ + /*@dependent@*/ yasm_symrec *sym; /* symbol created for this section */ + long scnum; /* section number (0=first section) */ enum { - RDF_SECT_BSS = 0, - RDF_SECT_CODE = 1, - RDF_SECT_DATA = 2, - RDF_SECT_COMMENT = 3, - RDF_SECT_LCOMMENT = 4, - RDF_SECT_PCOMMENT = 5, - RDF_SECT_SYMDEBUG = 6, - RDF_SECT_LINEDEBUG = 7 - } type; /* section type */ + RDF_SECT_BSS = 0, + RDF_SECT_CODE = 1, + RDF_SECT_DATA = 2, + RDF_SECT_COMMENT = 3, + RDF_SECT_LCOMMENT = 4, + RDF_SECT_PCOMMENT = 5, + RDF_SECT_SYMDEBUG = 6, + RDF_SECT_LINEDEBUG = 7 + } type; /* section type */ unsigned int reserved; /* reserved data */ - unsigned long size; /* size of raw data (section data) in bytes */ + unsigned long size; /* size of raw data (section data) in bytes */ - unsigned char *raw_data; /* raw section data, only used during output */ + unsigned char *raw_data; /* raw section data, only used during output */ } rdf_section_data; typedef struct rdf_symrec_data { - unsigned int segment; /* assigned RDF "segment" index */ + unsigned int segment; /* assigned RDF "segment" index */ } rdf_symrec_data; typedef STAILQ_HEAD(xdf_str_head, xdf_str) xdf_str_head; @@ -106,9 +110,9 @@ typedef struct xdf_str { } xdf_str; typedef struct yasm_objfmt_rdf { - yasm_objfmt_base objfmt; /* base structure */ + yasm_objfmt_base objfmt; /* base structure */ - long parse_scnum; /* sect numbering in parser */ + long parse_scnum; /* sect numbering in parser */ /*@owned@*/ xdf_str_head module_names; /*@owned@*/ xdf_str_head library_names; @@ -123,9 +127,9 @@ typedef struct rdf_objfmt_output_info { yasm_section *sect; /*@dependent@*/ rdf_section_data *rsd; - unsigned long indx; /* symbol "segment" (extern/common only) */ + unsigned long indx; /* symbol "segment" (extern/common only) */ - unsigned long bss_size; /* total BSS size */ + unsigned long bss_size; /* total BSS size */ } rdf_objfmt_output_info; static void rdf_section_data_destroy(/*@only@*/ void *d); @@ -179,10 +183,11 @@ rdf_objfmt_create(yasm_object *object) static int rdf_objfmt_output_value(yasm_value *value, unsigned char *buf, - unsigned int destsize, unsigned long offset, - yasm_bytecode *bc, int warn, /*@null@*/ void *d) + unsigned int destsize, unsigned long offset, + yasm_bytecode *bc, int warn, /*@null@*/ void *d) { /*@null@*/ rdf_objfmt_output_info *info = (rdf_objfmt_output_info *)d; + yasm_objfmt_rdf *objfmt_rdf; /*@dependent@*/ /*@null@*/ yasm_intnum *intn; unsigned long intn_minus; unsigned long intn_plus; @@ -190,104 +195,105 @@ rdf_objfmt_output_value(yasm_value *value, unsigned char *buf, unsigned int valsize = value->size; assert(info != NULL); + objfmt_rdf = info->objfmt_rdf; if (value->abs) - value->abs = yasm_expr_simplify(value->abs, 1); + value->abs = yasm_expr_simplify(value->abs, 1); /* Try to output constant and PC-relative section-local first. * Note this does NOT output any value with a SEG, WRT, external, * cross-section, or non-PC-relative reference (those are handled below). */ switch (yasm_value_output_basic(value, buf, destsize, bc, warn, - info->object->arch)) { - case -1: - return 1; - case 0: - break; - default: - return 0; + info->object->arch)) { + case -1: + return 1; + case 0: + break; + default: + return 0; } if (value->section_rel) { - yasm_error_set(YASM_ERROR_TOO_COMPLEX, - N_("rdf: relocation too complex")); - return 1; + yasm_error_set(YASM_ERROR_TOO_COMPLEX, + N_("rdf: relocation too complex")); + return 1; } if (value->rel && value->wrt) { - yasm_error_set(YASM_ERROR_TOO_COMPLEX, - N_("rdf: WRT not supported")); - return 1; + yasm_error_set(YASM_ERROR_TOO_COMPLEX, + N_("rdf: WRT not supported")); + return 1; } intn_minus = 0; intn_plus = 0; if (value->rel) { - rdf_reloc *reloc; - /*@null@*/ rdf_symrec_data *rsymd; - /*@dependent@*/ yasm_bytecode *precbc; + rdf_reloc *reloc; + /*@null@*/ rdf_symrec_data *rsymd; + /*@dependent@*/ yasm_bytecode *precbc; - reloc = yasm_xmalloc(sizeof(rdf_reloc)); - reloc->reloc.addr = yasm_intnum_create_uint(bc->offset + offset); - reloc->reloc.sym = value->rel; - reloc->size = valsize/8; + reloc = yasm_xmalloc(sizeof(rdf_reloc)); + reloc->reloc.addr = yasm_intnum_create_uint(bc->offset + offset); + reloc->reloc.sym = value->rel; + reloc->size = valsize/8; - if (value->seg_of) - reloc->type = RDF_RELOC_SEG; - else if (value->curpos_rel) { - reloc->type = RDF_RELOC_REL; - /* Adjust to start of section, so subtract out the bytecode - * offset. - */ - intn_minus = bc->offset; - } else - reloc->type = RDF_RELOC_NORM; + if (value->seg_of) + reloc->type = RDF_RELOC_SEG; + else if (value->curpos_rel) { + reloc->type = RDF_RELOC_REL; + /* Adjust to start of section, so subtract out the bytecode + * offset. + */ + intn_minus = bc->offset; + } else + reloc->type = RDF_RELOC_NORM; - if (yasm_symrec_get_label(value->rel, &precbc)) { - /* local, set the value to be the offset, and the refseg to the - * segment number. - */ - /*@dependent@*/ /*@null@*/ rdf_section_data *csectd; - /*@dependent@*/ yasm_section *sect; + if (yasm_symrec_get_label(value->rel, &precbc)) { + /* local, set the value to be the offset, and the refseg to the + * segment number. + */ + /*@dependent@*/ /*@null@*/ rdf_section_data *csectd; + /*@dependent@*/ yasm_section *sect; - sect = yasm_bc_get_section(precbc); - csectd = yasm_section_get_data(sect, &rdf_section_data_cb); - if (!csectd) - yasm_internal_error(N_("didn't understand section")); - reloc->refseg = csectd->scnum; - intn_plus = yasm_bc_next_offset(precbc); - } else { - /* must be common/external */ - rsymd = yasm_symrec_get_data(reloc->reloc.sym, - &rdf_symrec_data_cb); - if (!rsymd) - yasm_internal_error( - N_("rdf: no symbol data for relocated symbol")); - reloc->refseg = rsymd->segment; - } + sect = yasm_bc_get_section(precbc); + csectd = yasm_section_get_data(sect, &rdf_section_data_cb); + if (!csectd) + yasm_internal_error(N_("didn't understand section")); + reloc->refseg = csectd->scnum; + intn_plus = yasm_bc_next_offset(precbc); + } else { + /* must be common/external */ + rsymd = yasm_symrec_get_data(reloc->reloc.sym, + &rdf_symrec_data_cb); + if (!rsymd) + yasm_internal_error( + N_("rdf: no symbol data for relocated symbol")); + reloc->refseg = rsymd->segment; + } - yasm_section_add_reloc(info->sect, (yasm_reloc *)reloc, yasm_xfree); + yasm_section_add_reloc(info->sect, (yasm_reloc *)reloc, yasm_xfree); } if (intn_minus > 0) { - intn = yasm_intnum_create_uint(intn_minus); - yasm_intnum_calc(intn, YASM_EXPR_NEG, NULL); + intn = yasm_intnum_create_uint(intn_minus); + yasm_intnum_calc(intn, YASM_EXPR_NEG, NULL); } else - intn = yasm_intnum_create_uint(intn_plus); + intn = yasm_intnum_create_uint(intn_plus); if (value->abs) { - yasm_intnum *intn2 = yasm_expr_get_intnum(&value->abs, 0); - if (!intn2) { - yasm_error_set(YASM_ERROR_TOO_COMPLEX, - N_("rdf: relocation too complex")); - yasm_intnum_destroy(intn); - return 1; - } - yasm_intnum_calc(intn, YASM_EXPR_ADD, intn2); + yasm_intnum *intn2 = yasm_expr_get_intnum(&value->abs, 0); + if (!intn2) { + yasm_error_set(YASM_ERROR_TOO_COMPLEX, + N_("rdf: relocation too complex")); + yasm_intnum_destroy(intn); + return 1; + } + yasm_intnum_calc(intn, YASM_EXPR_ADD, intn2); } retval = yasm_arch_intnum_tobytes(info->object->arch, intn, buf, destsize, - valsize, 0, bc, warn); + valsize, 0, bc, warn); yasm_intnum_destroy(intn); return retval; } @@ -303,32 +309,32 @@ rdf_objfmt_output_bytecode(yasm_bytecode *bc, /*@null@*/ void *d) assert(info != NULL); bigbuf = yasm_bc_tobytes(bc, info->buf, &size, &gap, info, - rdf_objfmt_output_value, NULL); + rdf_objfmt_output_value, NULL); /* Don't bother doing anything else if size ended up being 0. */ if (size == 0) { - if (bigbuf) - yasm_xfree(bigbuf); - return 0; + if (bigbuf) + yasm_xfree(bigbuf); + return 0; } /* Warn that gaps are converted to 0 and write out the 0's. */ if (gap) { - yasm_warn_set(YASM_WARN_UNINIT_CONTENTS, - N_("uninitialized space: zeroing")); - /* Write out in chunks */ - memset(&info->rsd->raw_data[info->rsd->size], 0, size); + yasm_warn_set(YASM_WARN_UNINIT_CONTENTS, + N_("uninitialized space: zeroing")); + /* Write out in chunks */ + memset(&info->rsd->raw_data[info->rsd->size], 0, size); } else { - /* Output buf (or bigbuf if non-NULL) to file */ - memcpy(&info->rsd->raw_data[info->rsd->size], - bigbuf ? bigbuf : info->buf, (size_t)size); + /* Output buf (or bigbuf if non-NULL) to file */ + memcpy(&info->rsd->raw_data[info->rsd->size], + bigbuf ? bigbuf : info->buf, (size_t)size); } info->rsd->size += size; /* If bigbuf was allocated, free it */ if (bigbuf) - yasm_xfree(bigbuf); + yasm_xfree(bigbuf); return 0; } @@ -347,16 +353,16 @@ rdf_objfmt_output_section_mem(yasm_section *sect, /*@null@*/ void *d) size = yasm_bc_next_offset(yasm_section_bcs_last(sect)); if (rsd->type == RDF_SECT_BSS) { - /* Don't output BSS sections, but remember length - * TODO: Check for non-reserve bytecodes? - */ - info->bss_size += size; - return 0; + /* Don't output BSS sections, but remember length + * TODO: Check for non-reserve bytecodes? + */ + info->bss_size += size; + return 0; } /* Empty? Go on to next section */ if (size == 0) - return 0; + return 0; /* See UGH comment in output() for why we're doing this */ rsd->raw_data = yasm_xmalloc(size); @@ -365,12 +371,12 @@ rdf_objfmt_output_section_mem(yasm_section *sect, /*@null@*/ void *d) info->sect = sect; info->rsd = rsd; yasm_section_bcs_traverse(sect, info->errwarns, info, - rdf_objfmt_output_bytecode); + rdf_objfmt_output_bytecode); /* Sanity check final section size */ if (rsd->size != size) - yasm_internal_error( - N_("rdf: section computed size did not match actual size")); + yasm_internal_error( + N_("rdf: section computed size did not match actual size")); return 0; } @@ -387,33 +393,33 @@ rdf_objfmt_output_section_reloc(yasm_section *sect, /*@null@*/ void *d) assert(rsd != NULL); if (rsd->type == RDF_SECT_BSS) { - /* Don't output BSS sections. */ - return 0; + /* Don't output BSS sections. */ + return 0; } /* Empty? Go on to next section */ if (rsd->size == 0) - return 0; + return 0; reloc = (rdf_reloc *)yasm_section_relocs_first(sect); while (reloc) { - unsigned char *localbuf = info->buf; + unsigned char *localbuf = info->buf; - if (reloc->type == RDF_RELOC_SEG) - YASM_WRITE_8(localbuf, RDFREC_SEGRELOC); - else - YASM_WRITE_8(localbuf, RDFREC_RELOC); - YASM_WRITE_8(localbuf, 8); /* record length */ - /* Section number, +0x40 if relative reloc */ - YASM_WRITE_8(localbuf, rsd->scnum + - (reloc->type == RDF_RELOC_REL ? 0x40 : 0)); - yasm_intnum_get_sized(reloc->reloc.addr, localbuf, 4, 32, 0, 0, 0); - localbuf += 4; /* offset of relocation */ - YASM_WRITE_8(localbuf, reloc->size); /* size of relocation */ - YASM_WRITE_16_L(localbuf, reloc->refseg); /* relocated symbol */ - fwrite(info->buf, 10, 1, info->f); + if (reloc->type == RDF_RELOC_SEG) + YASM_WRITE_8(localbuf, RDFREC_SEGRELOC); + else + YASM_WRITE_8(localbuf, RDFREC_RELOC); + YASM_WRITE_8(localbuf, 8); /* record length */ + /* Section number, +0x40 if relative reloc */ + YASM_WRITE_8(localbuf, rsd->scnum + + (reloc->type == RDF_RELOC_REL ? 0x40 : 0)); + yasm_intnum_get_sized(reloc->reloc.addr, localbuf, 4, 32, 0, 0, 0); + localbuf += 4; /* offset of relocation */ + YASM_WRITE_8(localbuf, reloc->size); /* size of relocation */ + YASM_WRITE_16_L(localbuf, reloc->refseg); /* relocated symbol */ + fwrite(info->buf, 10, 1, info->f); - reloc = (rdf_reloc *)yasm_section_reloc_next((yasm_reloc *)reloc); + reloc = (rdf_reloc *)yasm_section_reloc_next((yasm_reloc *)reloc); } return 0; @@ -431,20 +437,20 @@ rdf_objfmt_output_section_file(yasm_section *sect, /*@null@*/ void *d) assert(rsd != NULL); if (rsd->type == RDF_SECT_BSS) { - /* Don't output BSS sections. */ - return 0; + /* Don't output BSS sections. */ + return 0; } /* Empty? Go on to next section */ if (rsd->size == 0) - return 0; + return 0; /* Section header */ localbuf = info->buf; - YASM_WRITE_16_L(localbuf, rsd->type); /* type */ - YASM_WRITE_16_L(localbuf, rsd->scnum); /* number */ - YASM_WRITE_16_L(localbuf, rsd->reserved); /* reserved */ - YASM_WRITE_32_L(localbuf, rsd->size); /* length */ + YASM_WRITE_16_L(localbuf, rsd->type); /* type */ + YASM_WRITE_16_L(localbuf, rsd->scnum); /* number */ + YASM_WRITE_16_L(localbuf, rsd->reserved); /* reserved */ + YASM_WRITE_32_L(localbuf, rsd->size); /* length */ fwrite(info->buf, 10, 1, info->f); /* Section data */ @@ -485,7 +491,7 @@ static unsigned int rdf_parse_flags(yasm_symrec *sym) { /*@dependent@*/ /*@null@*/ yasm_valparamhead *objext_valparams = - yasm_symrec_get_objext_valparams(sym); + yasm_symrec_get_objext_valparams(sym); unsigned int flags = 0; static const yasm_dir_help help[] = { @@ -504,7 +510,7 @@ rdf_parse_flags(yasm_symrec *sym) }; if (!objext_valparams) - return 0; + return 0; yasm_dir_helper(sym, yasm_vps_first(objext_valparams), 0, help, NELEMS(help), &flags, yasm_dir_helper_valparam_warn); @@ -517,7 +523,7 @@ rdf_objfmt_output_sym(yasm_symrec *sym, /*@null@*/ void *d) { /*@null@*/ rdf_objfmt_output_info *info = (rdf_objfmt_output_info *)d; yasm_sym_vis vis = yasm_symrec_get_visibility(sym); - /*@only@*/ char *name; + const char *name; size_t len; unsigned long value = 0; unsigned int scnum = 0; @@ -528,81 +534,81 @@ rdf_objfmt_output_sym(yasm_symrec *sym, /*@null@*/ void *d) assert(info != NULL); if (vis == YASM_SYM_LOCAL || vis == YASM_SYM_DLOCAL) - return 0; /* skip local syms */ + return 0; /* skip local syms */ /* Look at symrec for value/scnum/etc. */ if (yasm_symrec_get_label(sym, &precbc)) { - /*@dependent@*/ /*@null@*/ rdf_section_data *csectd; + /*@dependent@*/ /*@null@*/ rdf_section_data *csectd; - if (precbc) - sect = yasm_bc_get_section(precbc); - else - sect = NULL; - if (!sect) - return 0; + if (precbc) + sect = yasm_bc_get_section(precbc); + else + sect = NULL; + if (!sect) + return 0; - /* it's a label: get value and offset. */ - csectd = yasm_section_get_data(sect, &rdf_section_data_cb); - if (csectd) - scnum = csectd->scnum; - else - yasm_internal_error(N_("didn't understand section")); - value = yasm_bc_next_offset(precbc); + /* it's a label: get value and offset. */ + csectd = yasm_section_get_data(sect, &rdf_section_data_cb); + if (csectd) + scnum = csectd->scnum; + else + yasm_internal_error(N_("didn't understand section")); + value = yasm_bc_next_offset(precbc); } else if (yasm_symrec_get_equ(sym)) { - yasm_warn_set(YASM_WARN_GENERAL, - N_("rdf does not support exporting EQU/absolute values")); - yasm_errwarn_propagate(info->errwarns, yasm_symrec_get_decl_line(sym)); - return 0; + yasm_warn_set(YASM_WARN_GENERAL, + N_("rdf does not support exporting EQU/absolute values")); + yasm_errwarn_propagate(info->errwarns, yasm_symrec_get_decl_line(sym)); + return 0; } - name = yasm_symrec_get_global_name(sym, info->object); + name = yasm_symrec_get_name(sym); len = strlen(name); if (len > EXIM_LABEL_MAX-1) { - yasm_warn_set(YASM_WARN_GENERAL, - N_("label name too long, truncating to %d bytes"), - EXIM_LABEL_MAX); - len = EXIM_LABEL_MAX-1; + yasm_warn_set(YASM_WARN_GENERAL, + N_("label name too long, truncating to %d bytes"), + EXIM_LABEL_MAX); + len = EXIM_LABEL_MAX-1; } localbuf = info->buf; if (vis & YASM_SYM_GLOBAL) { - YASM_WRITE_8(localbuf, RDFREC_GLOBAL); - YASM_WRITE_8(localbuf, 6+len+1); /* record length */ - YASM_WRITE_8(localbuf, rdf_parse_flags(sym)); /* flags */ - YASM_WRITE_8(localbuf, scnum); /* segment referred to */ - YASM_WRITE_32_L(localbuf, value); /* offset */ + YASM_WRITE_8(localbuf, RDFREC_GLOBAL); + YASM_WRITE_8(localbuf, 6+len+1); /* record length */ + YASM_WRITE_8(localbuf, rdf_parse_flags(sym)); /* flags */ + YASM_WRITE_8(localbuf, scnum); /* segment referred to */ + YASM_WRITE_32_L(localbuf, value); /* offset */ } else { - /* Save symbol segment in symrec data (for later reloc gen) */ - scnum = info->indx++; - rdf_objfmt_sym_set_data(sym, scnum); + /* Save symbol segment in symrec data (for later reloc gen) */ + scnum = info->indx++; + rdf_objfmt_sym_set_data(sym, scnum); - if (vis & YASM_SYM_COMMON) { - /*@dependent@*/ /*@null@*/ yasm_expr **csize_expr; - const yasm_intnum *intn; - /*@dependent@*/ /*@null@*/ yasm_valparamhead *objext_valparams = - yasm_symrec_get_objext_valparams(sym); - unsigned long addralign = 0; + if (vis & YASM_SYM_COMMON) { + /*@dependent@*/ /*@null@*/ yasm_expr **csize_expr; + const yasm_intnum *intn; + /*@dependent@*/ /*@null@*/ yasm_valparamhead *objext_valparams = + yasm_symrec_get_objext_valparams(sym); + unsigned long addralign = 0; - YASM_WRITE_8(localbuf, RDFREC_COMMON); - YASM_WRITE_8(localbuf, 8+len+1); /* record length */ - YASM_WRITE_16_L(localbuf, scnum); /* segment allocated */ + YASM_WRITE_8(localbuf, RDFREC_COMMON); + YASM_WRITE_8(localbuf, 8+len+1); /* record length */ + YASM_WRITE_16_L(localbuf, scnum); /* segment allocated */ - /* size */ - csize_expr = yasm_symrec_get_common_size(sym); - assert(csize_expr != NULL); - intn = yasm_expr_get_intnum(csize_expr, 1); - if (!intn) { - yasm_error_set(YASM_ERROR_NOT_CONSTANT, - N_("COMMON data size not an integer expression")); - } else - value = yasm_intnum_get_uint(intn); - YASM_WRITE_32_L(localbuf, value); + /* size */ + csize_expr = yasm_symrec_get_common_size(sym); + assert(csize_expr != NULL); + intn = yasm_expr_get_intnum(csize_expr, 1); + if (!intn) { + yasm_error_set(YASM_ERROR_NOT_CONSTANT, + N_("COMMON data size not an integer expression")); + } else + value = yasm_intnum_get_uint(intn); + YASM_WRITE_32_L(localbuf, value); - /* alignment */ - if (objext_valparams) { - yasm_valparam *vp = yasm_vps_first(objext_valparams); - for (; vp; vp = yasm_vps_next(vp)) { + /* alignment */ + if (objext_valparams) { + yasm_valparam *vp = yasm_vps_first(objext_valparams); + for (; vp; vp = yasm_vps_next(vp)) { if (!vp->val) { /*@only@*/ /*@null@*/ yasm_expr *align_expr; /*@dependent@*/ /*@null@*/ @@ -613,46 +619,45 @@ rdf_objfmt_output_sym(yasm_symrec *sym, /*@null@*/ void *d) yasm_symrec_get_decl_line(sym))) || !(align_intn = yasm_expr_get_intnum(&align_expr, 0))) { - yasm_error_set(YASM_ERROR_VALUE, + yasm_error_set(YASM_ERROR_VALUE, N_("argument to `%s' is not an integer"), vp->val); if (align_expr) yasm_expr_destroy(align_expr); - continue; - } + continue; + } addralign = yasm_intnum_get_uint(align_intn); yasm_expr_destroy(align_expr); - /* Alignments must be a power of two. */ - if (!is_exp2(addralign)) { - yasm_error_set(YASM_ERROR_VALUE, - N_("alignment constraint is not a power of two")); - continue; - } + /* Alignments must be a power of two. */ + if (!is_exp2(addralign)) { + yasm_error_set(YASM_ERROR_VALUE, + N_("alignment constraint is not a power of two")); + continue; + } } else - yasm_warn_set(YASM_WARN_GENERAL, + yasm_warn_set(YASM_WARN_GENERAL, N_("Unrecognized qualifier `%s'"), vp->val); - } - } - YASM_WRITE_16_L(localbuf, addralign); - } else if (vis & YASM_SYM_EXTERN) { - unsigned int flags = rdf_parse_flags(sym); - if (flags & SYM_FAR) { - YASM_WRITE_8(localbuf, RDFREC_FARIMPORT); - flags &= ~SYM_FAR; - } else - YASM_WRITE_8(localbuf, RDFREC_IMPORT); - YASM_WRITE_8(localbuf, 3+len+1); /* record length */ - YASM_WRITE_8(localbuf, flags); /* flags */ - YASM_WRITE_16_L(localbuf, scnum); /* segment allocated */ - } + } + } + YASM_WRITE_16_L(localbuf, addralign); + } else if (vis & YASM_SYM_EXTERN) { + unsigned int flags = rdf_parse_flags(sym); + if (flags & SYM_FAR) { + YASM_WRITE_8(localbuf, RDFREC_FARIMPORT); + flags &= ~SYM_FAR; + } else + YASM_WRITE_8(localbuf, RDFREC_IMPORT); + YASM_WRITE_8(localbuf, 3+len+1); /* record length */ + YASM_WRITE_8(localbuf, flags); /* flags */ + YASM_WRITE_16_L(localbuf, scnum); /* segment allocated */ + } } /* Symbol name */ memcpy(localbuf, name, len); localbuf += len; - YASM_WRITE_8(localbuf, 0); /* 0-terminated name */ - yasm_xfree(name); + YASM_WRITE_8(localbuf, 0); /* 0-terminated name */ fwrite(info->buf, (unsigned long)(localbuf-info->buf), 1, info->f); @@ -662,7 +667,7 @@ rdf_objfmt_output_sym(yasm_symrec *sym, /*@null@*/ void *d) static void rdf_objfmt_output(yasm_object *object, FILE *f, int all_syms, - yasm_errwarns *errwarns) + yasm_errwarns *errwarns) { yasm_objfmt_rdf *objfmt_rdf = (yasm_objfmt_rdf *)object->objfmt; rdf_objfmt_output_info info; @@ -680,32 +685,32 @@ rdf_objfmt_output(yasm_object *object, FILE *f, int all_syms, /* Allocate space for file header by seeking forward */ if (fseek(f, (long)strlen(RDF_MAGIC)+8, SEEK_SET) < 0) { - yasm__fatal(N_("could not seek on output file")); - /*@notreached@*/ - return; + yasm__fatal(N_("could not seek on output file")); + /*@notreached@*/ + return; } /* Output custom header records (library and module, etc) */ cur = STAILQ_FIRST(&objfmt_rdf->module_names); while (cur) { - len = strlen(cur->str)+1; - localbuf = info.buf; - YASM_WRITE_8(localbuf, RDFREC_MODNAME); /* record type */ - YASM_WRITE_8(localbuf, len); /* record length */ - fwrite(info.buf, 2, 1, f); - fwrite(cur->str, len, 1, f); - cur = STAILQ_NEXT(cur, link); + len = strlen(cur->str)+1; + localbuf = info.buf; + YASM_WRITE_8(localbuf, RDFREC_MODNAME); /* record type */ + YASM_WRITE_8(localbuf, len); /* record length */ + fwrite(info.buf, 2, 1, f); + fwrite(cur->str, len, 1, f); + cur = STAILQ_NEXT(cur, link); } cur = STAILQ_FIRST(&objfmt_rdf->library_names); while (cur) { - len = strlen(cur->str)+1; - localbuf = info.buf; - YASM_WRITE_8(localbuf, RDFREC_DLL); /* record type */ - YASM_WRITE_8(localbuf, len); /* record length */ - fwrite(info.buf, 2, 1, f); - fwrite(cur->str, len, 1, f); - cur = STAILQ_NEXT(cur, link); + len = strlen(cur->str)+1; + localbuf = info.buf; + YASM_WRITE_8(localbuf, RDFREC_DLL); /* record type */ + YASM_WRITE_8(localbuf, len); /* record length */ + fwrite(info.buf, 2, 1, f); + fwrite(cur->str, len, 1, f); + cur = STAILQ_NEXT(cur, link); } /* Output symbol table */ @@ -725,35 +730,35 @@ rdf_objfmt_output(yasm_object *object, FILE *f, int all_syms, * We also calculate the total size of all BSS sections here. */ if (yasm_object_sections_traverse(object, &info, - rdf_objfmt_output_section_mem)) - return; + rdf_objfmt_output_section_mem)) + return; /* Output all relocs */ if (yasm_object_sections_traverse(object, &info, - rdf_objfmt_output_section_reloc)) - return; + rdf_objfmt_output_section_reloc)) + return; /* Output BSS record */ if (info.bss_size > 0) { - localbuf = info.buf; - YASM_WRITE_8(localbuf, RDFREC_BSS); /* record type */ - YASM_WRITE_8(localbuf, 4); /* record length */ - YASM_WRITE_32_L(localbuf, info.bss_size); /* total BSS size */ - fwrite(info.buf, 6, 1, f); + localbuf = info.buf; + YASM_WRITE_8(localbuf, RDFREC_BSS); /* record type */ + YASM_WRITE_8(localbuf, 4); /* record length */ + YASM_WRITE_32_L(localbuf, info.bss_size); /* total BSS size */ + fwrite(info.buf, 6, 1, f); } /* Determine header length */ headerlen = ftell(f); if (headerlen == -1) { - yasm__fatal(N_("could not get file position on output file")); - /*@notreached@*/ - return; + yasm__fatal(N_("could not get file position on output file")); + /*@notreached@*/ + return; } /* Section data (to file) */ if (yasm_object_sections_traverse(object, &info, - rdf_objfmt_output_section_file)) - return; + rdf_objfmt_output_section_file)) + return; /* NULL section to end file */ memset(info.buf, 0, 10); @@ -762,22 +767,22 @@ rdf_objfmt_output(yasm_object *object, FILE *f, int all_syms, /* Determine object length */ filelen = ftell(f); if (filelen == -1) { - yasm__fatal(N_("could not get file position on output file")); - /*@notreached@*/ - return; + yasm__fatal(N_("could not get file position on output file")); + /*@notreached@*/ + return; } /* Write file header */ if (fseek(f, 0, SEEK_SET) < 0) { - yasm__fatal(N_("could not seek on output file")); - /*@notreached@*/ - return; + yasm__fatal(N_("could not seek on output file")); + /*@notreached@*/ + return; } fwrite(RDF_MAGIC, strlen(RDF_MAGIC), 1, f); localbuf = info.buf; - YASM_WRITE_32_L(localbuf, filelen-10); /* object size */ - YASM_WRITE_32_L(localbuf, headerlen-14); /* header size */ + YASM_WRITE_32_L(localbuf, filelen-10); /* object size */ + YASM_WRITE_32_L(localbuf, headerlen-14); /* header size */ fwrite(info.buf, 8, 1, f); yasm_xfree(info.buf); @@ -791,28 +796,27 @@ rdf_objfmt_destroy(yasm_objfmt *objfmt) cur = STAILQ_FIRST(&objfmt_rdf->module_names); while (cur) { - next = STAILQ_NEXT(cur, link); - yasm_xfree(cur->str); - yasm_xfree(cur); - cur = next; + next = STAILQ_NEXT(cur, link); + yasm_xfree(cur->str); + yasm_xfree(cur); + cur = next; } cur = STAILQ_FIRST(&objfmt_rdf->library_names); while (cur) { - next = STAILQ_NEXT(cur, link); - yasm_xfree(cur->str); - yasm_xfree(cur); - cur = next; + next = STAILQ_NEXT(cur, link); + yasm_xfree(cur->str); + yasm_xfree(cur); + cur = next; } yasm_xfree(objfmt); } -static void -rdf_objfmt_init_new_section(yasm_section *sect, unsigned long line) +static rdf_section_data * +rdf_objfmt_init_new_section(yasm_object *object, yasm_section *sect, + const char *sectname, unsigned long line) { - yasm_object *object = yasm_section_get_object(sect); - const char *sectname = yasm_section_get_name(sect); yasm_objfmt_rdf *objfmt_rdf = (yasm_objfmt_rdf *)object->objfmt; rdf_section_data *data; yasm_symrec *sym; @@ -826,8 +830,9 @@ rdf_objfmt_init_new_section(yasm_section *sect, unsigned long line) yasm_section_add_data(sect, &rdf_section_data_cb, data); sym = yasm_symtab_define_label(object->symtab, sectname, - yasm_section_bcs_first(sect), 1, line); + yasm_section_bcs_first(sect), 1, line); data->sym = sym; + return data; } static yasm_section * @@ -837,12 +842,12 @@ rdf_objfmt_add_default_section(yasm_object *object) rdf_section_data *rsd; int isnew; - retval = yasm_object_get_general(object, ".text", 0, 1, 0, &isnew, 0); + retval = yasm_object_get_general(object, ".text", 0, 0, 1, 0, &isnew, 0); if (isnew) { - rsd = yasm_section_get_data(retval, &rdf_section_data_cb); - rsd->type = RDF_SECT_CODE; - rsd->reserved = 0; - yasm_section_set_default(retval, 1); + rsd = rdf_objfmt_init_new_section(object, retval, ".text", 0); + rsd->type = RDF_SECT_CODE; + rsd->reserved = 0; + yasm_section_set_default(retval, 1); } return retval; } @@ -875,9 +880,9 @@ rdf_helper_set_reserved(void *obj, yasm_valparam *vp, unsigned long line, static /*@observer@*/ /*@null@*/ yasm_section * rdf_objfmt_section_switch(yasm_object *object, yasm_valparamhead *valparams, - /*@unused@*/ /*@null@*/ - yasm_valparamhead *objext_valparams, - unsigned long line) + /*@unused@*/ /*@null@*/ + yasm_valparamhead *objext_valparams, + unsigned long line) { yasm_valparam *vp = yasm_vps_first(valparams); yasm_section *retval; @@ -918,7 +923,7 @@ rdf_objfmt_section_switch(yasm_object *object, yasm_valparamhead *valparams, vp = yasm_vps_first(valparams); sectname = yasm_vp_string(vp); if (!sectname) - return NULL; + return NULL; vp = yasm_vps_next(vp); if (strcmp(sectname, ".text") == 0) @@ -934,8 +939,8 @@ rdf_objfmt_section_switch(yasm_object *object, yasm_valparamhead *valparams, return NULL; /* error occurred */ if (data.type == 0xffff) { - yasm_error_set(YASM_ERROR_VALUE, - N_("new segment declared without type code")); + yasm_error_set(YASM_ERROR_VALUE, + N_("new segment declared without type code")); data.type = RDF_SECT_DATA; } @@ -944,34 +949,30 @@ rdf_objfmt_section_switch(yasm_object *object, yasm_valparamhead *valparams, yasm_intnum_destroy(data.reserved_intn); } - retval = yasm_object_get_general(object, sectname, 0, 1, + retval = yasm_object_get_general(object, sectname, 0, 0, 1, data.type == RDF_SECT_BSS, &isnew, line); - rsd = yasm_section_get_data(retval, &rdf_section_data_cb); + if (isnew) + rsd = rdf_objfmt_init_new_section(object, retval, sectname, line); + else + rsd = yasm_section_get_data(retval, &rdf_section_data_cb); if (isnew || yasm_section_is_default(retval)) { - yasm_section_set_default(retval, 0); + yasm_section_set_default(retval, 0); rsd->type = data.type; - rsd->reserved = reserved; + rsd->reserved = reserved; } else if (flags_override) - yasm_warn_set(YASM_WARN_GENERAL, - N_("section flags ignored on section redeclaration")); + yasm_warn_set(YASM_WARN_GENERAL, + N_("section flags ignored on section redeclaration")); return retval; } -static /*@observer@*/ /*@null@*/ yasm_symrec * -rdf_objfmt_get_special_sym(yasm_object *object, const char *name, - const char *parser) -{ - return NULL; -} - static void rdf_section_data_destroy(void *data) { rdf_section_data *rsd = (rdf_section_data *)data; if (rsd->raw_data) - yasm_xfree(rsd->raw_data); + yasm_xfree(rsd->raw_data); yasm_xfree(data); } @@ -1012,21 +1013,21 @@ rdf_objfmt_add_libmodule(yasm_object *object, char *name, int lib) str = yasm_xmalloc(sizeof(xdf_str)); str->str = name; if (lib) - STAILQ_INSERT_TAIL(&objfmt_rdf->library_names, str, link); + STAILQ_INSERT_TAIL(&objfmt_rdf->library_names, str, link); else - STAILQ_INSERT_TAIL(&objfmt_rdf->module_names, str, link); + STAILQ_INSERT_TAIL(&objfmt_rdf->module_names, str, link); if (strlen(str->str) > MODLIB_NAME_MAX-1) { - yasm_warn_set(YASM_WARN_GENERAL, - N_("name too long, truncating to %d bytes"), - MODLIB_NAME_MAX); - str->str[MODLIB_NAME_MAX-1] = '\0'; + yasm_warn_set(YASM_WARN_GENERAL, + N_("name too long, truncating to %d bytes"), + MODLIB_NAME_MAX); + str->str[MODLIB_NAME_MAX-1] = '\0'; } } static void dir_library(yasm_object *object, yasm_valparamhead *valparams, - yasm_valparamhead *objext_valparams, unsigned long line) + yasm_valparamhead *objext_valparams, unsigned long line) { yasm_valparam *vp = yasm_vps_first(valparams); rdf_objfmt_add_libmodule(object, yasm__xstrdup(yasm_vp_string(vp)), 1); @@ -1034,7 +1035,7 @@ dir_library(yasm_object *object, yasm_valparamhead *valparams, static void dir_module(yasm_object *object, yasm_valparamhead *valparams, - yasm_valparamhead *objext_valparams, unsigned long line) + yasm_valparamhead *objext_valparams, unsigned long line) { yasm_valparam *vp = yasm_vps_first(valparams); rdf_objfmt_add_libmodule(object, yasm__xstrdup(yasm_vp_string(vp)), 0); @@ -1052,37 +1053,18 @@ static const yasm_directive rdf_objfmt_directives[] = { { NULL, NULL, NULL, 0 } }; -static const char *rdf_nasm_stdmac[] = { - "%imacro library 1+.nolist", - "[library %1]", - "%endmacro", - "%imacro module 1+.nolist", - "[module %1]", - "%endmacro", - NULL -}; - -static const yasm_stdmac rdf_objfmt_stdmacs[] = { - { "nasm", "nasm", rdf_nasm_stdmac }, - { NULL, NULL, NULL } -}; - /* Define objfmt structure -- see objfmt.h for details */ yasm_objfmt_module yasm_rdf_LTX_objfmt = { "Relocatable Dynamic Object File Format (RDOFF) v2.0", "rdf", "rdf", 32, - 0, rdf_objfmt_dbgfmt_keywords, "null", rdf_objfmt_directives, - rdf_objfmt_stdmacs, rdf_objfmt_create, rdf_objfmt_output, rdf_objfmt_destroy, rdf_objfmt_add_default_section, - rdf_objfmt_init_new_section, - rdf_objfmt_section_switch, - rdf_objfmt_get_special_sym + rdf_objfmt_section_switch }; diff --git a/modules/objfmts/rdf/tests/Makefile.inc b/modules/objfmts/rdf/tests/Makefile.inc index c547e8fd..39f6aab3 100644 --- a/modules/objfmts/rdf/tests/Makefile.inc +++ b/modules/objfmts/rdf/tests/Makefile.inc @@ -1,3 +1,5 @@ +# $Id$ + TESTS += modules/objfmts/rdf/tests/rdf_test.sh EXTRA_DIST += modules/objfmts/rdf/tests/rdf_test.sh diff --git a/modules/objfmts/rdf/tests/rdf_test.sh b/modules/objfmts/rdf/tests/rdf_test.sh index 46584395..9161c378 100755 --- a/modules/objfmts/rdf/tests/rdf_test.sh +++ b/modules/objfmts/rdf/tests/rdf_test.sh @@ -1,3 +1,4 @@ #! /bin/sh +# $Id$ ${srcdir}/out_test.sh rdf_test modules/objfmts/rdf/tests "rdf objfmt" "-f rdf" ".rdf" exit $? diff --git a/modules/objfmts/win32/Makefile.inc b/modules/objfmts/win32/Makefile.inc index 5b3b1626..ce4964fe 100644 --- a/modules/objfmts/win32/Makefile.inc +++ b/modules/objfmts/win32/Makefile.inc @@ -1,3 +1,5 @@ +# $Id$ + # Assume objfmt_coff is included YASM_MODULES += objfmt_win32 diff --git a/modules/objfmts/win32/tests/Makefile.inc b/modules/objfmts/win32/tests/Makefile.inc index 3f2ab943..5bb8d143 100644 --- a/modules/objfmts/win32/tests/Makefile.inc +++ b/modules/objfmts/win32/tests/Makefile.inc @@ -1,3 +1,5 @@ +# $Id$ + TESTS += modules/objfmts/win32/tests/win32_test.sh EXTRA_DIST += modules/objfmts/win32/tests/export.asm @@ -7,15 +9,8 @@ EXTRA_DIST += modules/objfmts/win32/tests/win32-curpos.asm EXTRA_DIST += modules/objfmts/win32/tests/win32-curpos.hex EXTRA_DIST += modules/objfmts/win32/tests/win32-overdef.asm EXTRA_DIST += modules/objfmts/win32/tests/win32-overdef.hex -EXTRA_DIST += modules/objfmts/win32/tests/win32-safeseh.asm -EXTRA_DIST += modules/objfmts/win32/tests/win32-safeseh.hex -EXTRA_DIST += modules/objfmts/win32/tests/win32-safeseh.masm EXTRA_DIST += modules/objfmts/win32/tests/win32-segof.asm EXTRA_DIST += modules/objfmts/win32/tests/win32-segof.hex EXTRA_DIST += modules/objfmts/win32/tests/win32test.c EXTRA_DIST += modules/objfmts/win32/tests/win32test.asm EXTRA_DIST += modules/objfmts/win32/tests/win32test.hex - -EXTRA_DIST += modules/objfmts/win32/tests/gas/Makefile.inc - -include modules/objfmts/win32/tests/gas/Makefile.inc diff --git a/modules/objfmts/win32/tests/export.hex b/modules/objfmts/win32/tests/export.hex index 33ca9ffb..bcae2219 100644 --- a/modules/objfmts/win32/tests/export.hex +++ b/modules/objfmts/win32/tests/export.hex @@ -10,7 +10,7 @@ 00 00 00 -08 +07 00 00 00 @@ -159,24 +159,6 @@ ff 00 00 00 -40 -66 -65 -61 -74 -2e -30 -30 -01 -00 -00 -00 -ff -ff -00 -00 -03 -00 2e 74 65 diff --git a/modules/objfmts/win32/tests/gas/Makefile.inc b/modules/objfmts/win32/tests/gas/Makefile.inc deleted file mode 100644 index f492cbac..00000000 --- a/modules/objfmts/win32/tests/gas/Makefile.inc +++ /dev/null @@ -1,9 +0,0 @@ -TESTS += modules/objfmts/win32/tests/gas/win32_gas_test.sh - -EXTRA_DIST += modules/objfmts/win32/tests/gas/win32_gas_test.sh -EXTRA_DIST += modules/objfmts/win32/tests/gas/win32at.asm -EXTRA_DIST += modules/objfmts/win32/tests/gas/win32at.hex -EXTRA_DIST += modules/objfmts/win32/tests/gas/win32def.asm -EXTRA_DIST += modules/objfmts/win32/tests/gas/win32def.hex -EXTRA_DIST += modules/objfmts/win32/tests/gas/win32secrel32.asm -EXTRA_DIST += modules/objfmts/win32/tests/gas/win32secrel32.hex diff --git a/modules/objfmts/win32/tests/gas/win32_gas_test.sh b/modules/objfmts/win32/tests/gas/win32_gas_test.sh deleted file mode 100755 index 4a1bbe98..00000000 --- a/modules/objfmts/win32/tests/gas/win32_gas_test.sh +++ /dev/null @@ -1,3 +0,0 @@ -#! /bin/sh -${srcdir}/out_test.sh win32_gas_test modules/objfmts/win32/tests/gas "win32 objfmt" "-f win32 -p gas" ".obj" -exit $? diff --git a/modules/objfmts/win32/tests/gas/win32at.asm b/modules/objfmts/win32/tests/gas/win32at.asm deleted file mode 100644 index f56520a2..00000000 --- a/modules/objfmts/win32/tests/gas/win32at.asm +++ /dev/null @@ -1,167 +0,0 @@ -.section .rodata -L2586: -.ascii "myWindowClass\0" -.globl _g_szClassName -_g_szClassName: -.byte 109 -.byte 121 -.byte 87 -.byte 105 -.byte 110 -.byte 100 -.byte 111 -.byte 119 -.byte 67 -.byte 108 -.byte 97 -.byte 115 -.byte 115 -.byte 0 -.text -.align 4 -.globl _WndProc@16 -_WndProc@16: -pushl %ebp -movl %esp,%ebp -subl $8,%esp -L2588: -L2590: -movl 12(%ebp),%eax -movl %eax,-4(%ebp) -jmp L2592 -L2593: -pushl 8(%ebp) -call _DestroyWindow@4 -jmp L2591 -L2594: -pushl $0 -call _PostQuitMessage@4 -jmp L2591 -L2595: -pushl 20(%ebp) -pushl 16(%ebp) -pushl 12(%ebp) -pushl 8(%ebp) -call _DefWindowProcA@16 -movl %eax,-8(%ebp) -jmp L2589 -L2592: -cmpl $2,-4(%ebp) -je L2594 -cmpl $16,-4(%ebp) -je L2593 -jmp L2595 -L2591: -movl $0,-8(%ebp) -jmp L2589 -L2589: -movl -8(%ebp),%eax -leave -ret $16 -.section .rodata -L2600: -.ascii "Window Registration Failed!\0" -L2601: -.ascii "Error!\0" -L2602: -.ascii "The title of my window\0" -L2604: -.ascii "Window Creation Failed!\0" -.text -.align 4 -.globl _WinMain@16 -_WinMain@16: -pushl %ebp -movl %esp,%ebp -subl $84,%esp -L2596: -L2598: -movl $48,-48(%ebp) -movl $0,-44(%ebp) -movl $_WndProc@16,-40(%ebp) -movl $0,-36(%ebp) -movl $0,-32(%ebp) -movl 8(%ebp),%eax -movl %eax,-28(%ebp) -pushl $32512 -pushl $0 -call _LoadIconA@8 -movl %eax,-24(%ebp) -pushl $32512 -pushl $0 -call _LoadCursorA@8 -movl %eax,-20(%ebp) -movl $6,-16(%ebp) -movl $0,-12(%ebp) -movl $_g_szClassName,-8(%ebp) -pushl $32512 -pushl $0 -call _LoadIconA@8 -movl %eax,-4(%ebp) -leal -48(%ebp),%edx -pushl %edx -call _RegisterClassExA@4 -cmpw $0,%ax -jne L2599 -pushl $48 -pushl $L2601 -pushl $L2600 -pushl $0 -call _MessageBoxA@16 -movl $0,-84(%ebp) -jmp L2597 -L2599: -pushl $0 -pushl 8(%ebp) -pushl $0 -pushl $0 -pushl $120 -pushl $240 -pushl $-2147483648 -pushl $-2147483648 -pushl $13565952 -pushl $L2602 -pushl $_g_szClassName -pushl $512 -call _CreateWindowExA@48 -movl %eax,-52(%ebp) -cmpl $0,-52(%ebp) -jne L2603 -pushl $48 -pushl $L2601 -pushl $L2604 -pushl $0 -call _MessageBoxA@16 -movl $0,-84(%ebp) -jmp L2597 -L2603: -pushl 20(%ebp) -pushl -52(%ebp) -call _ShowWindow@8 -pushl -52(%ebp) -call _UpdateWindow@4 -L2605: -pushl $0 -pushl $0 -pushl $0 -leal -80(%ebp),%edx -pushl %edx -call _GetMessageA@16 -cmpl $0,%eax -jle L2606 -leal -80(%ebp),%eax -pushl %eax -call _TranslateMessage@4 -leal -80(%ebp),%eax -pushl %eax -call _DispatchMessageA@4 -jmp L2605 -L2606: -movl -72(%ebp),%eax -movl %eax,-84(%ebp) -jmp L2597 -L2597: -movl -84(%ebp),%eax -leave -ret $16 -.ident "PCC: pcc 0.9.9 (win32)" diff --git a/modules/objfmts/win32/tests/gas/win32at.hex b/modules/objfmts/win32/tests/gas/win32at.hex deleted file mode 100644 index 21edec5c..00000000 --- a/modules/objfmts/win32/tests/gas/win32at.hex +++ /dev/null @@ -1,1653 +0,0 @@ -4c -01 -03 -00 -00 -00 -00 -00 -91 -03 -00 -00 -19 -00 -00 -00 -00 -00 -0c -01 -2e -74 -65 -78 -74 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -99 -01 -00 -00 -8c -00 -00 -00 -25 -02 -00 -00 -00 -00 -00 -00 -17 -00 -00 -00 -20 -00 -50 -60 -2e -72 -6f -64 -61 -74 -61 -00 -00 -00 -00 -00 -00 -00 -00 -00 -6e -00 -00 -00 -0b -03 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -40 -00 -40 -40 -2f -34 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -18 -00 -00 -00 -79 -03 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -40 -00 -40 -40 -55 -89 -e5 -83 -ec -08 -8b -45 -0c -89 -45 -fc -eb -29 -ff -75 -08 -e8 -00 -00 -00 -00 -eb -2d -6a -00 -e8 -00 -00 -00 -00 -eb -24 -ff -75 -14 -ff -75 -10 -ff -75 -0c -ff -75 -08 -e8 -00 -00 -00 -00 -89 -45 -f8 -eb -17 -83 -7d -fc -02 -74 -db -83 -7d -fc -10 -74 -cb -eb -dc -c7 -45 -f8 -00 -00 -00 -00 -eb -00 -8b -45 -f8 -c9 -c2 -10 -00 -8d -76 -00 -55 -89 -e5 -83 -ec -54 -c7 -45 -d0 -30 -00 -00 -00 -c7 -45 -d4 -00 -00 -00 -00 -c7 -45 -d8 -00 -00 -00 -00 -c7 -45 -dc -00 -00 -00 -00 -c7 -45 -e0 -00 -00 -00 -00 -8b -45 -08 -89 -45 -e4 -68 -00 -7f -00 -00 -6a -00 -e8 -00 -00 -00 -00 -89 -45 -e8 -68 -00 -7f -00 -00 -6a -00 -e8 -00 -00 -00 -00 -89 -45 -ec -c7 -45 -f0 -06 -00 -00 -00 -c7 -45 -f4 -00 -00 -00 -00 -c7 -45 -f8 -0e -00 -00 -00 -68 -00 -7f -00 -00 -6a -00 -e8 -00 -00 -00 -00 -89 -45 -fc -8d -55 -d0 -52 -e8 -00 -00 -00 -00 -66 -83 -f8 -00 -75 -1f -6a -30 -68 -38 -00 -00 -00 -68 -1c -00 -00 -00 -6a -00 -e8 -00 -00 -00 -00 -c7 -45 -ac -00 -00 -00 -00 -e9 -9b -00 -00 -00 -6a -00 -ff -75 -08 -6a -00 -6a -00 -6a -78 -68 -f0 -00 -00 -00 -68 -00 -00 -00 -80 -68 -00 -00 -00 -80 -68 -00 -00 -cf -00 -68 -3f -00 -00 -00 -68 -0e -00 -00 -00 -68 -00 -02 -00 -00 -e8 -00 -00 -00 -00 -89 -45 -cc -83 -7d -cc -00 -75 -1c -6a -30 -68 -38 -00 -00 -00 -68 -56 -00 -00 -00 -6a -00 -e8 -00 -00 -00 -00 -c7 -45 -ac -00 -00 -00 -00 -eb -43 -ff -75 -14 -ff -75 -cc -e8 -00 -00 -00 -00 -ff -75 -cc -e8 -00 -00 -00 -00 -6a -00 -6a -00 -6a -00 -8d -55 -b0 -52 -e8 -00 -00 -00 -00 -83 -f8 -00 -7e -14 -8d -45 -b0 -50 -e8 -00 -00 -00 -00 -8d -45 -b0 -50 -e8 -00 -00 -00 -00 -eb -d8 -8b -45 -b8 -89 -45 -ac -eb -00 -8b -45 -ac -c9 -c2 -10 -00 -12 -00 -00 -00 -09 -00 -00 -00 -14 -00 -1b -00 -00 -00 -0a -00 -00 -00 -14 -00 -2e -00 -00 -00 -0b -00 -00 -00 -14 -00 -6f -00 -00 -00 -03 -00 -00 -00 -06 -00 -8f -00 -00 -00 -0d -00 -00 -00 -14 -00 -9e -00 -00 -00 -0e -00 -00 -00 -14 -00 -b6 -00 -00 -00 -05 -00 -00 -00 -06 -00 -c2 -00 -00 -00 -0d -00 -00 -00 -14 -00 -ce -00 -00 -00 -0f -00 -00 -00 -14 -00 -db -00 -00 -00 -05 -00 -00 -00 -06 -00 -e0 -00 -00 -00 -05 -00 -00 -00 -06 -00 -e7 -00 -00 -00 -10 -00 -00 -00 -14 -00 -17 -01 -00 -00 -05 -00 -00 -00 -06 -00 -1c -01 -00 -00 -05 -00 -00 -00 -06 -00 -26 -01 -00 -00 -11 -00 -00 -00 -14 -00 -36 -01 -00 -00 -05 -00 -00 -00 -06 -00 -3b -01 -00 -00 -05 -00 -00 -00 -06 -00 -42 -01 -00 -00 -10 -00 -00 -00 -14 -00 -56 -01 -00 -00 -12 -00 -00 -00 -14 -00 -5e -01 -00 -00 -13 -00 -00 -00 -14 -00 -6d -01 -00 -00 -14 -00 -00 -00 -14 -00 -7b -01 -00 -00 -15 -00 -00 -00 -14 -00 -84 -01 -00 -00 -16 -00 -00 -00 -14 -00 -6d -79 -57 -69 -6e -64 -6f -77 -43 -6c -61 -73 -73 -00 -6d -79 -57 -69 -6e -64 -6f -77 -43 -6c -61 -73 -73 -00 -57 -69 -6e -64 -6f -77 -20 -52 -65 -67 -69 -73 -74 -72 -61 -74 -69 -6f -6e -20 -46 -61 -69 -6c -65 -64 -21 -00 -45 -72 -72 -6f -72 -21 -00 -54 -68 -65 -20 -74 -69 -74 -6c -65 -20 -6f -66 -20 -6d -79 -20 -77 -69 -6e -64 -6f -77 -00 -57 -69 -6e -64 -6f -77 -20 -43 -72 -65 -61 -74 -69 -6f -6e -20 -46 -61 -69 -6c -65 -64 -21 -00 -00 -50 -43 -43 -3a -20 -70 -63 -63 -20 -30 -2e -39 -2e -39 -20 -28 -77 -69 -6e -33 -32 -29 -00 -2e -66 -69 -6c -65 -00 -00 -00 -00 -00 -00 -00 -fe -ff -00 -00 -67 -01 -2d -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -40 -66 -65 -61 -74 -2e -30 -30 -01 -00 -00 -00 -ff -ff -00 -00 -03 -00 -2e -74 -65 -78 -74 -00 -00 -00 -00 -00 -00 -00 -01 -00 -00 -00 -03 -01 -99 -01 -00 -00 -17 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -2e -72 -6f -64 -61 -74 -61 -00 -00 -00 -00 -00 -02 -00 -00 -00 -03 -01 -6e -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -0f -00 -00 -00 -0e -00 -00 -00 -02 -00 -00 -00 -02 -00 -00 -00 -00 -00 -1e -00 -00 -00 -00 -00 -00 -00 -01 -00 -00 -00 -02 -00 -00 -00 -00 -00 -2a -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -02 -00 -00 -00 -00 -00 -3b -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -02 -00 -00 -00 -00 -00 -4e -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -02 -00 -00 -00 -00 -00 -61 -00 -00 -00 -58 -00 -00 -00 -01 -00 -00 -00 -02 -00 -00 -00 -00 -00 -6d -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -02 -00 -00 -00 -00 -00 -7a -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -02 -00 -00 -00 -00 -00 -89 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -02 -00 -00 -00 -00 -00 -9d -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -02 -00 -00 -00 -00 -00 -ad -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -02 -00 -00 -00 -00 -00 -c1 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -02 -00 -00 -00 -00 -00 -cf -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -02 -00 -00 -00 -00 -00 -df -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -02 -00 -00 -00 -00 -00 -ef -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -02 -00 -00 -00 -00 -00 -03 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -02 -00 -00 -00 -00 -00 -17 -01 -00 -00 -00 -00 -00 -00 -03 -00 -00 -00 -03 -01 -18 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -22 -01 -00 -00 -2e -72 -64 -61 -74 -61 -24 -7a -7a -7a -00 -5f -67 -5f -73 -7a -43 -6c -61 -73 -73 -4e -61 -6d -65 -00 -5f -57 -6e -64 -50 -72 -6f -63 -40 -31 -36 -00 -5f -44 -65 -73 -74 -72 -6f -79 -57 -69 -6e -64 -6f -77 -40 -34 -00 -5f -50 -6f -73 -74 -51 -75 -69 -74 -4d -65 -73 -73 -61 -67 -65 -40 -34 -00 -5f -44 -65 -66 -57 -69 -6e -64 -6f -77 -50 -72 -6f -63 -41 -40 -31 -36 -00 -5f -57 -69 -6e -4d -61 -69 -6e -40 -31 -36 -00 -5f -4c -6f -61 -64 -49 -63 -6f -6e -41 -40 -38 -00 -5f -4c -6f -61 -64 -43 -75 -72 -73 -6f -72 -41 -40 -38 -00 -5f -52 -65 -67 -69 -73 -74 -65 -72 -43 -6c -61 -73 -73 -45 -78 -41 -40 -34 -00 -5f -4d -65 -73 -73 -61 -67 -65 -42 -6f -78 -41 -40 -31 -36 -00 -5f -43 -72 -65 -61 -74 -65 -57 -69 -6e -64 -6f -77 -45 -78 -41 -40 -34 -38 -00 -5f -53 -68 -6f -77 -57 -69 -6e -64 -6f -77 -40 -38 -00 -5f -55 -70 -64 -61 -74 -65 -57 -69 -6e -64 -6f -77 -40 -34 -00 -5f -47 -65 -74 -4d -65 -73 -73 -61 -67 -65 -41 -40 -31 -36 -00 -5f -54 -72 -61 -6e -73 -6c -61 -74 -65 -4d -65 -73 -73 -61 -67 -65 -40 -34 -00 -5f -44 -69 -73 -70 -61 -74 -63 -68 -4d -65 -73 -73 -61 -67 -65 -41 -40 -34 -00 -2e -72 -64 -61 -74 -61 -24 -7a -7a -7a -00 diff --git a/modules/objfmts/win32/tests/gas/win32def.asm b/modules/objfmts/win32/tests/gas/win32def.asm deleted file mode 100644 index e4764668..00000000 --- a/modules/objfmts/win32/tests/gas/win32def.asm +++ /dev/null @@ -1,7 +0,0 @@ -.globl label -label: - -.def label -.scl 2 -.type 32 -.endef diff --git a/modules/objfmts/win32/tests/gas/win32def.hex b/modules/objfmts/win32/tests/gas/win32def.hex deleted file mode 100644 index bfedd51b..00000000 --- a/modules/objfmts/win32/tests/gas/win32def.hex +++ /dev/null @@ -1,172 +0,0 @@ -4c -01 -01 -00 -00 -00 -00 -00 -3c -00 -00 -00 -06 -00 -00 -00 -00 -00 -0c -01 -2e -74 -65 -78 -74 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -20 -00 -50 -60 -2e -66 -69 -6c -65 -00 -00 -00 -00 -00 -00 -00 -fe -ff -00 -00 -67 -01 -2d -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -40 -66 -65 -61 -74 -2e -30 -30 -01 -00 -00 -00 -ff -ff -00 -00 -03 -00 -2e -74 -65 -78 -74 -00 -00 -00 -00 -00 -00 -00 -01 -00 -00 -00 -03 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -6c -61 -62 -65 -6c -00 -00 -00 -00 -00 -00 -00 -01 -00 -20 -00 -02 -00 -04 -00 -00 -00 diff --git a/modules/objfmts/win32/tests/gas/win32secrel32.asm b/modules/objfmts/win32/tests/gas/win32secrel32.asm deleted file mode 100644 index 0e8a82f7..00000000 --- a/modules/objfmts/win32/tests/gas/win32secrel32.asm +++ /dev/null @@ -1,80 +0,0 @@ -# [oformat win32] -.text - - .ascii ">>>>" -pre04: .ascii "<<<<" - .ascii ">>>>>" -pre0d: .ascii "<<<" - .ascii ">>>>>>" -pre16: .ascii "<<" - .ascii ">>>>>>>" -pre1f: .ascii "<" - -.data - - .ascii ">>>>" -sam04: .ascii "<<<<" - .ascii ">>>>>" -sam0d: .ascii "<<<" - .ascii ">>>>>>" -sam16: .ascii "<<" - .ascii ">>>>>>>" -sam1f: .ascii "<" - - .ascii ">>>>" - .secrel32 pre04 - .byte 0x11 - .secrel32 pre0d - .byte 0x11 - .secrel32 pre16 - .byte 0x11 - .secrel32 pre1f - .byte 0x11 - .ascii "<<<<<<<<" - - .ascii ">>>>" - .secrel32 sam04 - .byte 0x11 - .secrel32 sam0d - .byte 0x11 - .secrel32 sam16 - .byte 0x11 - .secrel32 sam1f - .byte 0x11 - .ascii "<<<<<<<<" - - .ascii ">>>>" - .secrel32 nex04 - .byte 0x11 - .secrel32 nex0d - .byte 0x11 - .secrel32 nex16 - .byte 0x11 - .secrel32 nex1f - .byte 0x11 - .ascii "<<<<<<<<" - - .ascii ">>>>" - .secrel32 ext24 - .byte 0x11 - .secrel32 ext2d - .byte 0x11 - .secrel32 ext36 - .byte 0x11 - .secrel32 ext3f - .byte 0x11 - .ascii "<<<<<<<<" - -.section .rdata - - .ascii ">>>>" -nex04: .ascii "<<<<" - .ascii ">>>>>" -nex0d: .ascii "<<<" - .ascii ">>>>>>" -nex16: .ascii "<<" - .ascii ">>>>>>>" -nex1f: .ascii "<" - .ascii ">>>>" - - .p2align 4,0 diff --git a/modules/objfmts/win32/tests/gas/win32secrel32.hex b/modules/objfmts/win32/tests/gas/win32secrel32.hex deleted file mode 100644 index 89103c06..00000000 --- a/modules/objfmts/win32/tests/gas/win32secrel32.hex +++ /dev/null @@ -1,778 +0,0 @@ -4c -01 -03 -00 -00 -00 -00 -00 -1c -02 -00 -00 -0d -00 -00 -00 -00 -00 -0c -01 -2e -74 -65 -78 -74 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -20 -00 -00 -00 -8c -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -20 -00 -50 -60 -2e -64 -61 -74 -61 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -a0 -00 -00 -00 -ac -00 -00 -00 -4c -01 -00 -00 -00 -00 -00 -00 -10 -00 -00 -00 -40 -00 -30 -c0 -2e -72 -64 -61 -74 -61 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -30 -00 -00 -00 -ec -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -40 -00 -50 -40 -3e -3e -3e -3e -3c -3c -3c -3c -3e -3e -3e -3e -3e -3c -3c -3c -3e -3e -3e -3e -3e -3e -3c -3c -3e -3e -3e -3e -3e -3e -3e -3c -3e -3e -3e -3e -3c -3c -3c -3c -3e -3e -3e -3e -3e -3c -3c -3c -3e -3e -3e -3e -3e -3e -3c -3c -3e -3e -3e -3e -3e -3e -3e -3c -3e -3e -3e -3e -04 -00 -00 -00 -11 -0d -00 -00 -00 -11 -16 -00 -00 -00 -11 -1f -00 -00 -00 -11 -3c -3c -3c -3c -3c -3c -3c -3c -3e -3e -3e -3e -04 -00 -00 -00 -11 -0d -00 -00 -00 -11 -16 -00 -00 -00 -11 -1f -00 -00 -00 -11 -3c -3c -3c -3c -3c -3c -3c -3c -3e -3e -3e -3e -04 -00 -00 -00 -11 -0d -00 -00 -00 -11 -16 -00 -00 -00 -11 -1f -00 -00 -00 -11 -3c -3c -3c -3c -3c -3c -3c -3c -3e -3e -3e -3e -00 -00 -00 -00 -11 -00 -00 -00 -00 -11 -00 -00 -00 -00 -11 -00 -00 -00 -00 -11 -3c -3c -3c -3c -3c -3c -3c -3c -24 -00 -00 -00 -03 -00 -00 -00 -0b -00 -29 -00 -00 -00 -03 -00 -00 -00 -0b -00 -2e -00 -00 -00 -03 -00 -00 -00 -0b -00 -33 -00 -00 -00 -03 -00 -00 -00 -0b -00 -44 -00 -00 -00 -05 -00 -00 -00 -0b -00 -49 -00 -00 -00 -05 -00 -00 -00 -0b -00 -4e -00 -00 -00 -05 -00 -00 -00 -0b -00 -53 -00 -00 -00 -05 -00 -00 -00 -0b -00 -64 -00 -00 -00 -0b -00 -00 -00 -0b -00 -69 -00 -00 -00 -0b -00 -00 -00 -0b -00 -6e -00 -00 -00 -0b -00 -00 -00 -0b -00 -73 -00 -00 -00 -0b -00 -00 -00 -0b -00 -84 -00 -00 -00 -07 -00 -00 -00 -0b -00 -89 -00 -00 -00 -08 -00 -00 -00 -0b -00 -8e -00 -00 -00 -09 -00 -00 -00 -0b -00 -93 -00 -00 -00 -0a -00 -00 -00 -0b -00 -3e -3e -3e -3e -3c -3c -3c -3c -3e -3e -3e -3e -3e -3c -3c -3c -3e -3e -3e -3e -3e -3e -3c -3c -3e -3e -3e -3e -3e -3e -3e -3c -3e -3e -3e -3e -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -2e -66 -69 -6c -65 -00 -00 -00 -00 -00 -00 -00 -fe -ff -00 -00 -67 -01 -2d -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -40 -66 -65 -61 -74 -2e -30 -30 -01 -00 -00 -00 -ff -ff -00 -00 -03 -00 -2e -74 -65 -78 -74 -00 -00 -00 -00 -00 -00 -00 -01 -00 -00 -00 -03 -01 -20 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -2e -64 -61 -74 -61 -00 -00 -00 -00 -00 -00 -00 -02 -00 -00 -00 -03 -01 -a0 -00 -00 -00 -10 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -65 -78 -74 -32 -34 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -02 -00 -65 -78 -74 -32 -64 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -02 -00 -65 -78 -74 -33 -36 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -02 -00 -65 -78 -74 -33 -66 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -02 -00 -2e -72 -64 -61 -74 -61 -00 -00 -00 -00 -00 -00 -03 -00 -00 -00 -03 -01 -30 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -04 -00 -00 -00 diff --git a/modules/objfmts/win32/tests/win32-curpos.hex b/modules/objfmts/win32/tests/win32-curpos.hex index e8cc7d68..16b39a8f 100644 --- a/modules/objfmts/win32/tests/win32-curpos.hex +++ b/modules/objfmts/win32/tests/win32-curpos.hex @@ -10,7 +10,7 @@ 01 00 00 -0b +0a 00 00 00 @@ -66,7 +66,7 @@ a0 00 00 00 -00 +14 00 00 00 @@ -106,7 +106,7 @@ d0 00 00 00 -00 +26 00 00 00 @@ -162,7 +162,7 @@ e8 00 00 00 -07 +06 00 00 00 @@ -172,7 +172,7 @@ e8 00 00 00 -07 +06 00 00 00 @@ -182,7 +182,7 @@ e8 00 00 00 -07 +06 00 00 00 @@ -210,7 +210,7 @@ e8 00 00 00 -09 +08 00 00 00 @@ -220,7 +220,7 @@ e8 00 00 00 -09 +08 00 00 00 @@ -258,7 +258,7 @@ ff 00 00 00 -07 +06 00 00 00 @@ -268,7 +268,7 @@ ff 00 00 00 -07 +06 00 00 00 @@ -278,7 +278,7 @@ ff 00 00 00 -07 +06 00 00 00 @@ -288,7 +288,7 @@ ff 00 00 00 -07 +06 00 00 00 @@ -330,24 +330,6 @@ ff 00 00 00 -40 -66 -65 -61 -74 -2e -30 -30 -01 -00 -00 -00 -ff -ff -00 -00 -03 -00 2e 74 65 diff --git a/modules/objfmts/win32/tests/win32-longsect.hex b/modules/objfmts/win32/tests/win32-longsect.hex index fa507b16..25d4812e 100644 --- a/modules/objfmts/win32/tests/win32-longsect.hex +++ b/modules/objfmts/win32/tests/win32-longsect.hex @@ -10,7 +10,7 @@ 01 00 00 -0f +0e 00 00 00 @@ -106,7 +106,7 @@ 00 00 00 -00 +04 00 00 00 @@ -146,7 +146,7 @@ 6c 79 38 -00 +08 00 00 00 @@ -186,7 +186,7 @@ 00 00 00 -00 +0c 00 00 00 @@ -226,7 +226,7 @@ 74 37 00 -00 +10 00 00 00 @@ -314,24 +314,6 @@ ff 00 00 00 -40 -66 -65 -61 -74 -2e -30 -30 -01 -00 -00 -00 -ff -ff -00 -00 -03 -00 2e 74 65 diff --git a/modules/objfmts/win32/tests/win32-overdef.hex b/modules/objfmts/win32/tests/win32-overdef.hex index fe0d6d73..00d97cd6 100644 --- a/modules/objfmts/win32/tests/win32-overdef.hex +++ b/modules/objfmts/win32/tests/win32-overdef.hex @@ -10,7 +10,7 @@ 00 00 00 -05 +04 00 00 00 @@ -94,24 +94,6 @@ ff 00 00 00 -40 -66 -65 -61 -74 -2e -30 -30 -01 -00 -00 -00 -ff -ff -00 -00 -03 -00 2e 74 65 diff --git a/modules/objfmts/win32/tests/win32-safeseh.asm b/modules/objfmts/win32/tests/win32-safeseh.asm deleted file mode 100644 index 9edd8ede..00000000 --- a/modules/objfmts/win32/tests/win32-safeseh.asm +++ /dev/null @@ -1,5 +0,0 @@ -MyHandler: - ret -safeseh MyHandler -extern MyHandler3 -safeseh MyHandler3 diff --git a/modules/objfmts/win32/tests/win32-safeseh.hex b/modules/objfmts/win32/tests/win32-safeseh.hex deleted file mode 100644 index 4ee1dd14..00000000 --- a/modules/objfmts/win32/tests/win32-safeseh.hex +++ /dev/null @@ -1,296 +0,0 @@ -4c -01 -02 -00 -00 -00 -00 -00 -6d -00 -00 -00 -09 -00 -00 -00 -00 -00 -0c -01 -2e -74 -65 -78 -74 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -01 -00 -00 -00 -64 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -20 -00 -50 -60 -2e -73 -78 -64 -61 -74 -61 -00 -00 -00 -00 -00 -00 -00 -00 -00 -08 -00 -00 -00 -65 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -02 -00 -00 -c3 -05 -00 -00 -00 -08 -00 -00 -00 -2e -66 -69 -6c -65 -00 -00 -00 -00 -00 -00 -00 -fe -ff -00 -00 -67 -01 -2d -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -40 -66 -65 -61 -74 -2e -30 -30 -01 -00 -00 -00 -ff -ff -00 -00 -03 -00 -2e -74 -65 -78 -74 -00 -00 -00 -00 -00 -00 -00 -01 -00 -00 -00 -03 -01 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -04 -00 -00 -00 -00 -00 -00 -00 -01 -00 -20 -00 -03 -00 -2e -73 -78 -64 -61 -74 -61 -00 -00 -00 -00 -00 -02 -00 -00 -00 -03 -01 -08 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -0e -00 -00 -00 -00 -00 -00 -00 -00 -00 -20 -00 -02 -00 -19 -00 -00 -00 -4d -79 -48 -61 -6e -64 -6c -65 -72 -00 -4d -79 -48 -61 -6e -64 -6c -65 -72 -33 -00 diff --git a/modules/objfmts/win32/tests/win32-safeseh.masm b/modules/objfmts/win32/tests/win32-safeseh.masm deleted file mode 100644 index f165b9c3..00000000 --- a/modules/objfmts/win32/tests/win32-safeseh.masm +++ /dev/null @@ -1,10 +0,0 @@ -.386 -.model flat -_TEXT SEGMENT USE32 PUBLIC 'CODE' -MyHandler proc -.safeseh MyHandler -MyHandler endp -_TEXT ENDS -MyHandler3 proto -.safeseh MyHandler3 -end diff --git a/modules/objfmts/win32/tests/win32-segof.hex b/modules/objfmts/win32/tests/win32-segof.hex index 6ad6a75f..873129f1 100644 --- a/modules/objfmts/win32/tests/win32-segof.hex +++ b/modules/objfmts/win32/tests/win32-segof.hex @@ -10,7 +10,7 @@ 00 00 00 -08 +07 00 00 00 @@ -66,7 +66,7 @@ 00 00 00 -00 +0c 00 00 00 @@ -114,7 +114,7 @@ c0 00 00 00 -05 +04 00 00 00 @@ -124,7 +124,7 @@ c0 00 00 00 -06 +05 00 00 00 @@ -166,24 +166,6 @@ ff 00 00 00 -40 -66 -65 -61 -74 -2e -30 -30 -01 -00 -00 -00 -ff -ff -00 -00 -03 -00 2e 74 65 diff --git a/modules/objfmts/win32/tests/win32_test.sh b/modules/objfmts/win32/tests/win32_test.sh index 6ffb349d..cd2ab008 100755 --- a/modules/objfmts/win32/tests/win32_test.sh +++ b/modules/objfmts/win32/tests/win32_test.sh @@ -1,3 +1,4 @@ #! /bin/sh +# $Id$ ${srcdir}/out_test.sh win32_test modules/objfmts/win32/tests "win32 objfmt" "-f win32" ".obj" exit $? diff --git a/modules/objfmts/win32/tests/win32test.c b/modules/objfmts/win32/tests/win32test.c index fa6a552d..f7446b8a 100644 --- a/modules/objfmts/win32/tests/win32test.c +++ b/modules/objfmts/win32/tests/win32test.c @@ -28,7 +28,7 @@ int main(void) { greet(); printf("These pointers should be equal: %p and %p\n", - &greet, textptr); + &greet, textptr); printf("So should these: %p and %p\n", selfptr, &selfptr); } diff --git a/modules/objfmts/win32/tests/win32test.hex b/modules/objfmts/win32/tests/win32test.hex index 8e4cfa8a..339090b1 100644 --- a/modules/objfmts/win32/tests/win32test.hex +++ b/modules/objfmts/win32/tests/win32test.hex @@ -10,7 +10,7 @@ 01 00 00 -11 +10 00 00 00 @@ -66,7 +66,7 @@ c9 00 00 00 -00 +3d 00 00 00 @@ -106,7 +106,7 @@ c0 00 00 00 -00 +7d 00 00 00 @@ -203,7 +203,7 @@ c3 00 00 00 -0f +0e 00 00 00 @@ -213,7 +213,7 @@ c3 00 00 00 -0f +0e 00 00 00 @@ -223,7 +223,7 @@ c3 00 00 00 -0c +0b 00 00 00 @@ -233,7 +233,7 @@ c3 00 00 00 -0d +0c 00 00 00 @@ -243,7 +243,7 @@ c3 00 00 00 -0f +0e 00 00 00 @@ -253,7 +253,7 @@ c3 00 00 00 -0d +0c 00 00 00 @@ -263,7 +263,7 @@ c3 00 00 00 -0b +0a 00 00 00 @@ -337,7 +337,7 @@ c3 00 00 00 -0f +0e 00 00 00 @@ -347,7 +347,7 @@ c3 00 00 00 -03 +02 00 00 00 @@ -357,7 +357,7 @@ c3 00 00 00 -0d +0c 00 00 00 @@ -399,24 +399,6 @@ ff 00 00 00 -40 -66 -65 -61 -74 -2e -30 -30 -01 -00 -00 -00 -ff -ff -00 -00 -03 -00 2e 74 65 diff --git a/modules/objfmts/win64/Makefile.inc b/modules/objfmts/win64/Makefile.inc index 545c847e..72dcd716 100644 --- a/modules/objfmts/win64/Makefile.inc +++ b/modules/objfmts/win64/Makefile.inc @@ -1,3 +1,5 @@ +# $Id$ + # Assume objfmt_coff is included YASM_MODULES += objfmt_win64 objfmt_x64 diff --git a/modules/objfmts/win64/tests/Makefile.inc b/modules/objfmts/win64/tests/Makefile.inc index 4062fc33..4bc0907c 100644 --- a/modules/objfmts/win64/tests/Makefile.inc +++ b/modules/objfmts/win64/tests/Makefile.inc @@ -1,3 +1,5 @@ +# $Id$ + TESTS += modules/objfmts/win64/tests/win64_test.sh EXTRA_DIST += modules/objfmts/win64/tests/win64_test.sh @@ -17,8 +19,6 @@ EXTRA_DIST += modules/objfmts/win64/tests/sce4.hex EXTRA_DIST += modules/objfmts/win64/tests/sce4.masm EXTRA_DIST += modules/objfmts/win64/tests/sce4-err.asm EXTRA_DIST += modules/objfmts/win64/tests/sce4-err.errwarn -EXTRA_DIST += modules/objfmts/win64/tests/win64-abs.asm -EXTRA_DIST += modules/objfmts/win64/tests/win64-abs.hex EXTRA_DIST += modules/objfmts/win64/tests/win64-curpos.asm EXTRA_DIST += modules/objfmts/win64/tests/win64-curpos.hex EXTRA_DIST += modules/objfmts/win64/tests/win64-dataref.asm @@ -27,11 +27,3 @@ EXTRA_DIST += modules/objfmts/win64/tests/win64-dataref.masm EXTRA_DIST += modules/objfmts/win64/tests/win64-dataref2.asm EXTRA_DIST += modules/objfmts/win64/tests/win64-dataref2.hex EXTRA_DIST += modules/objfmts/win64/tests/win64-dataref2.masm -EXTRA_DIST += modules/objfmts/win64/tests/win64-function.asm -EXTRA_DIST += modules/objfmts/win64/tests/win64-function.hex -EXTRA_DIST += modules/objfmts/win64/tests/win64-imagebase.hex -EXTRA_DIST += modules/objfmts/win64/tests/win64-imagebase.asm - -EXTRA_DIST += modules/objfmts/win64/tests/gas/Makefile.inc - -include modules/objfmts/win64/tests/gas/Makefile.inc diff --git a/modules/objfmts/win64/tests/gas/Makefile.inc b/modules/objfmts/win64/tests/gas/Makefile.inc deleted file mode 100644 index 0faeec78..00000000 --- a/modules/objfmts/win64/tests/gas/Makefile.inc +++ /dev/null @@ -1,5 +0,0 @@ -TESTS += modules/objfmts/win64/tests/gas/win64_gas_test.sh - -EXTRA_DIST += modules/objfmts/win64/tests/gas/win64_gas_test.sh -EXTRA_DIST += modules/objfmts/win64/tests/gas/win64-gas-sce.asm -EXTRA_DIST += modules/objfmts/win64/tests/gas/win64-gas-sce.hex diff --git a/modules/objfmts/win64/tests/gas/win64-gas-sce.asm b/modules/objfmts/win64/tests/gas/win64-gas-sce.asm deleted file mode 100644 index 3a75ee4c..00000000 --- a/modules/objfmts/win64/tests/gas/win64-gas-sce.asm +++ /dev/null @@ -1,11 +0,0 @@ -PROC_FRAME sample -rex_push_reg %rbp -rex_push_eflags -alloc_stack 16 -save_reg %rsi, 0x18 -save_xmm128 %xmm7, 0x20 -push_frame 16 -set_frame %rdi -set_frame %rdi, 16 -END_PROLOGUE -ENDPROC_FRAME diff --git a/modules/objfmts/win64/tests/gas/win64-gas-sce.hex b/modules/objfmts/win64/tests/gas/win64-gas-sce.hex deleted file mode 100644 index e50d860f..00000000 --- a/modules/objfmts/win64/tests/gas/win64-gas-sce.hex +++ /dev/null @@ -1,399 +0,0 @@ -64 -86 -03 -00 -00 -00 -00 -00 -e9 -00 -00 -00 -09 -00 -00 -00 -00 -00 -04 -00 -2e -74 -65 -78 -74 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -1b -00 -00 -00 -8c -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -20 -00 -50 -60 -2e -78 -64 -61 -74 -61 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -18 -00 -00 -00 -a7 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -40 -00 -40 -40 -2e -70 -64 -61 -74 -61 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -0c -00 -00 -00 -bf -00 -00 -00 -cb -00 -00 -00 -00 -00 -00 -00 -03 -00 -00 -00 -40 -00 -30 -40 -48 -55 -48 -9c -48 -83 -ec -10 -48 -89 -74 -24 -18 -66 -0f -7f -7c -24 -20 -48 -89 -e7 -48 -8d -7c -24 -10 -01 -1b -0a -17 -1b -73 -16 -73 -13 -1a -13 -78 -02 -00 -0d -64 -03 -00 -08 -12 -04 -02 -02 -50 -00 -00 -00 -00 -1b -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -04 -00 -00 -00 -03 -00 -04 -00 -00 -00 -04 -00 -00 -00 -03 -00 -08 -00 -00 -00 -05 -00 -00 -00 -03 -00 -2e -66 -69 -6c -65 -00 -00 -00 -00 -00 -00 -00 -fe -ff -00 -00 -67 -01 -2d -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -2e -74 -65 -78 -74 -00 -00 -00 -00 -00 -00 -00 -01 -00 -00 -00 -03 -01 -1b -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -73 -61 -6d -70 -6c -65 -00 -00 -00 -00 -00 -00 -01 -00 -00 -00 -03 -00 -2e -78 -64 -61 -74 -61 -00 -00 -00 -00 -00 -00 -02 -00 -00 -00 -03 -01 -18 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -2e -70 -64 -61 -74 -61 -00 -00 -00 -00 -00 -00 -03 -00 -00 -00 -03 -01 -0c -00 -00 -00 -03 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -04 -00 -00 -00 diff --git a/modules/objfmts/win64/tests/gas/win64_gas_test.sh b/modules/objfmts/win64/tests/gas/win64_gas_test.sh deleted file mode 100755 index efc76882..00000000 --- a/modules/objfmts/win64/tests/gas/win64_gas_test.sh +++ /dev/null @@ -1,3 +0,0 @@ -#! /bin/sh -${srcdir}/out_test.sh win64_gas_test modules/objfmts/win64/tests/gas "win64 objfmt" "-f win64 -p gas -r nasm" ".obj" -exit $? diff --git a/modules/objfmts/win64/tests/sce1-err.errwarn b/modules/objfmts/win64/tests/sce1-err.errwarn index bfb88c14..f5b67933 100644 --- a/modules/objfmts/win64/tests/sce1-err.errwarn +++ b/modules/objfmts/win64/tests/sce1-err.errwarn @@ -1,8 +1,8 @@ --:9: error: ended procedure without ending prologue --:1: error: procedure started here --:20: error: nested procedures not supported (didn't use [ENDPROC_FRAME]?) --:11: error: previous procedure started here --:27: error: [SAVEREG] after end of prologue --:26: error: prologue ended here --:31: error: [ENDPROLOG] without preceding [PROC_FRAME] --:32: error: [SAVEREG] without preceding [PROC_FRAME] +-:9: ended procedure without ending prologue +-:1: procedure started here +-:20: nested procedures not supported (didn't use [ENDPROC_FRAME]?) +-:11: previous procedure started here +-:27: [SAVEREG] after end of prologue +-:26: prologue ended here +-:31: [ENDPROLOG] without preceding [PROC_FRAME] +-:32: [SAVEREG] without preceding [PROC_FRAME] diff --git a/modules/objfmts/win64/tests/sce1.hex b/modules/objfmts/win64/tests/sce1.hex index 442ef944..d6b1427c 100644 --- a/modules/objfmts/win64/tests/sce1.hex +++ b/modules/objfmts/win64/tests/sce1.hex @@ -66,7 +66,7 @@ 61 00 00 -00 +3a 00 00 00 @@ -106,7 +106,7 @@ c6 61 00 00 -00 +52 00 00 00 diff --git a/modules/objfmts/win64/tests/sce2-err.errwarn b/modules/objfmts/win64/tests/sce2-err.errwarn index 73e18652..d7f0d290 100644 --- a/modules/objfmts/win64/tests/sce2-err.errwarn +++ b/modules/objfmts/win64/tests/sce2-err.errwarn @@ -1,2 +1,2 @@ --: error: end of file in procedure frame --:1: error: procedure started here +-: end of file in procedure frame +-:1: procedure started here diff --git a/modules/objfmts/win64/tests/sce2.hex b/modules/objfmts/win64/tests/sce2.hex index 54bc0e9e..1caa10c7 100644 --- a/modules/objfmts/win64/tests/sce2.hex +++ b/modules/objfmts/win64/tests/sce2.hex @@ -66,7 +66,7 @@ e3 61 00 00 -00 +1d 00 00 00 @@ -106,7 +106,7 @@ a9 61 00 00 -00 +2d 00 00 00 diff --git a/modules/objfmts/win64/tests/sce3.hex b/modules/objfmts/win64/tests/sce3.hex index 26fdb0c8..cadf8b94 100644 --- a/modules/objfmts/win64/tests/sce3.hex +++ b/modules/objfmts/win64/tests/sce3.hex @@ -66,7 +66,7 @@ 61 00 00 -00 +57 00 00 00 @@ -106,7 +106,7 @@ e3 61 00 00 -00 +7f 00 00 00 diff --git a/modules/objfmts/win64/tests/sce4-err.errwarn b/modules/objfmts/win64/tests/sce4-err.errwarn index b477ceb7..92d9cb02 100644 --- a/modules/objfmts/win64/tests/sce4-err.errwarn +++ b/modules/objfmts/win64/tests/sce4-err.errwarn @@ -1,9 +1,9 @@ --:2: error: frame offset of -4 bytes, must be between 0 and 240 --:3: error: negative offset not allowed --:5: error: negative offset not allowed --:6: error: negative offset not allowed --:11: error: frame offset of 248 bytes, must be between 0 and 240 --:17: error: frame offset of 236 is not a multiple of 16 --:18: error: offset of 124 is not a multiple of 8 --:20: error: offset of 1032 is not a multiple of 16 --:21: error: offset of 1028 is not a multiple of 8 +-:2: frame offset of -4 bytes, must be between 0 and 240 +-:3: negative offset not allowed +-:5: negative offset not allowed +-:6: negative offset not allowed +-:11: frame offset of 248 bytes, must be between 0 and 240 +-:17: frame offset of 236 is not a multiple of 16 +-:18: offset of 124 is not a multiple of 8 +-:20: offset of 1032 is not a multiple of 16 +-:21: offset of 1028 is not a multiple of 8 diff --git a/modules/objfmts/win64/tests/sce4.hex b/modules/objfmts/win64/tests/sce4.hex index e324697e..9a57d50d 100644 --- a/modules/objfmts/win64/tests/sce4.hex +++ b/modules/objfmts/win64/tests/sce4.hex @@ -106,7 +106,7 @@ 61 00 00 -00 +40 00 00 00 diff --git a/modules/objfmts/win64/tests/win64-abs.asm b/modules/objfmts/win64/tests/win64-abs.asm deleted file mode 100644 index b5c29ea2..00000000 --- a/modules/objfmts/win64/tests/win64-abs.asm +++ /dev/null @@ -1 +0,0 @@ -mov rax, [rel 0x1000] diff --git a/modules/objfmts/win64/tests/win64-abs.hex b/modules/objfmts/win64/tests/win64-abs.hex deleted file mode 100644 index 7d4b35e9..00000000 --- a/modules/objfmts/win64/tests/win64-abs.hex +++ /dev/null @@ -1,171 +0,0 @@ -64 -86 -01 -00 -00 -00 -00 -00 -4d -00 -00 -00 -05 -00 -00 -00 -00 -00 -04 -00 -2e -74 -65 -78 -74 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -07 -00 -00 -00 -3c -00 -00 -00 -43 -00 -00 -00 -00 -00 -00 -00 -01 -00 -00 -00 -20 -00 -50 -60 -48 -8b -05 -00 -10 -00 -00 -03 -00 -00 -00 -04 -00 -00 -00 -04 -00 -2e -66 -69 -6c -65 -00 -00 -00 -00 -00 -00 -00 -fe -ff -00 -00 -67 -01 -2d -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -2e -74 -65 -78 -74 -00 -00 -00 -00 -00 -00 -00 -01 -00 -00 -00 -03 -01 -07 -00 -00 -00 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -2e -61 -62 -73 -6f -6c -75 -74 -00 -00 -00 -00 -ff -ff -00 -00 -03 -00 -04 -00 -00 -00 diff --git a/modules/objfmts/win64/tests/win64-curpos.hex b/modules/objfmts/win64/tests/win64-curpos.hex index 14032abd..d7c51b10 100644 --- a/modules/objfmts/win64/tests/win64-curpos.hex +++ b/modules/objfmts/win64/tests/win64-curpos.hex @@ -66,7 +66,7 @@ a1 00 00 00 -00 +15 00 00 00 @@ -106,7 +106,7 @@ d1 00 00 00 -00 +27 00 00 00 diff --git a/modules/objfmts/win64/tests/win64-dataref.hex b/modules/objfmts/win64/tests/win64-dataref.hex index 443727dd..3af07864 100644 --- a/modules/objfmts/win64/tests/win64-dataref.hex +++ b/modules/objfmts/win64/tests/win64-dataref.hex @@ -66,8 +66,8 @@ a4 00 00 00 -00 -00 +a0 +01 00 00 00 @@ -106,8 +106,8 @@ c0 00 00 00 -00 -00 +ec +01 00 00 00 @@ -146,8 +146,8 @@ c0 61 00 00 -00 -00 +fc +01 00 00 00 @@ -186,8 +186,8 @@ c0 61 00 00 -00 -00 +08 +02 00 00 00 @@ -226,8 +226,8 @@ c0 00 00 00 -00 -00 +10 +02 00 00 00 @@ -1364,7 +1364,7 @@ f8 00 00 00 -16 +17 00 00 00 @@ -1374,7 +1374,7 @@ f8 00 00 00 -16 +17 00 00 00 @@ -1999,24 +1999,6 @@ a0 03 00 78 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -03 -00 -00 -00 -03 -00 -78 70 74 72 @@ -2035,6 +2017,24 @@ a0 03 00 78 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +03 +00 +00 +00 +03 +00 +78 70 74 72 diff --git a/modules/objfmts/win64/tests/win64-dataref2.hex b/modules/objfmts/win64/tests/win64-dataref2.hex index 0555f0b2..1b7a430c 100644 --- a/modules/objfmts/win64/tests/win64-dataref2.hex +++ b/modules/objfmts/win64/tests/win64-dataref2.hex @@ -66,7 +66,7 @@ c3 00 00 00 -00 +29 00 00 00 diff --git a/modules/objfmts/win64/tests/win64-function.asm b/modules/objfmts/win64/tests/win64-function.asm deleted file mode 100644 index b1af165c..00000000 --- a/modules/objfmts/win64/tests/win64-function.asm +++ /dev/null @@ -1,4 +0,0 @@ -global _foo:function - -_foo: - diff --git a/modules/objfmts/win64/tests/win64-function.hex b/modules/objfmts/win64/tests/win64-function.hex deleted file mode 100644 index ad94a4dd..00000000 --- a/modules/objfmts/win64/tests/win64-function.hex +++ /dev/null @@ -1,154 +0,0 @@ -64 -86 -01 -00 -00 -00 -00 -00 -3c -00 -00 -00 -05 -00 -00 -00 -00 -00 -04 -00 -2e -74 -65 -78 -74 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -20 -00 -50 -60 -2e -66 -69 -6c -65 -00 -00 -00 -00 -00 -00 -00 -fe -ff -00 -00 -67 -01 -2d -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -2e -74 -65 -78 -74 -00 -00 -00 -00 -00 -00 -00 -01 -00 -00 -00 -03 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -5f -66 -6f -6f -00 -00 -00 -00 -00 -00 -00 -00 -01 -00 -20 -00 -02 -00 -04 -00 -00 -00 diff --git a/modules/objfmts/win64/tests/win64-imagebase.asm b/modules/objfmts/win64/tests/win64-imagebase.asm deleted file mode 100644 index bd636026..00000000 --- a/modules/objfmts/win64/tests/win64-imagebase.asm +++ /dev/null @@ -1,17 +0,0 @@ -[section .text] -handler: ret -func: ret -func_end: - -[section .pdata] - dd func - dd func_end - dd myunwnd - -[section .xdata] -myunwnd: - db 9,0,0,0 - dd handler - -[section .foo] - dd handler wrt ..imagebase diff --git a/modules/objfmts/win64/tests/win64-imagebase.hex b/modules/objfmts/win64/tests/win64-imagebase.hex deleted file mode 100644 index 04f00b80..00000000 --- a/modules/objfmts/win64/tests/win64-imagebase.hex +++ /dev/null @@ -1,512 +0,0 @@ -64 -86 -04 -00 -00 -00 -00 -00 -00 -01 -00 -00 -0e -00 -00 -00 -00 -00 -04 -00 -2e -74 -65 -78 -74 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -02 -00 -00 -00 -b4 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -20 -00 -50 -60 -2e -70 -64 -61 -74 -61 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -0c -00 -00 -00 -b6 -00 -00 -00 -c2 -00 -00 -00 -00 -00 -00 -00 -03 -00 -00 -00 -40 -00 -30 -40 -2e -78 -64 -61 -74 -61 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -08 -00 -00 -00 -e0 -00 -00 -00 -e8 -00 -00 -00 -00 -00 -00 -00 -01 -00 -00 -00 -40 -00 -40 -40 -2e -66 -6f -6f -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -04 -00 -00 -00 -f2 -00 -00 -00 -f6 -00 -00 -00 -00 -00 -00 -00 -01 -00 -00 -00 -20 -00 -00 -60 -c3 -c3 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -05 -00 -00 -00 -03 -00 -04 -00 -00 -00 -06 -00 -00 -00 -03 -00 -08 -00 -00 -00 -09 -00 -00 -00 -03 -00 -09 -00 -00 -00 -00 -00 -00 -00 -04 -00 -00 -00 -04 -00 -00 -00 -03 -00 -00 -00 -00 -00 -00 -00 -00 -00 -04 -00 -00 -00 -03 -00 -2e -66 -69 -6c -65 -00 -00 -00 -00 -00 -00 -00 -fe -ff -00 -00 -67 -01 -2d -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -2e -74 -65 -78 -74 -00 -00 -00 -00 -00 -00 -00 -01 -00 -00 -00 -03 -01 -02 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -68 -61 -6e -64 -6c -65 -72 -00 -00 -00 -00 -00 -01 -00 -00 -00 -03 -00 -66 -75 -6e -63 -00 -00 -00 -00 -01 -00 -00 -00 -01 -00 -00 -00 -03 -00 -66 -75 -6e -63 -5f -65 -6e -64 -02 -00 -00 -00 -01 -00 -00 -00 -03 -00 -2e -70 -64 -61 -74 -61 -00 -00 -00 -00 -00 -00 -02 -00 -00 -00 -03 -01 -0c -00 -00 -00 -03 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -6d -79 -75 -6e -77 -6e -64 -00 -00 -00 -00 -00 -03 -00 -00 -00 -03 -00 -2e -78 -64 -61 -74 -61 -00 -00 -00 -00 -00 -00 -03 -00 -00 -00 -03 -01 -08 -00 -00 -00 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -2e -66 -6f -6f -00 -00 -00 -00 -00 -00 -00 -00 -04 -00 -00 -00 -03 -01 -04 -00 -00 -00 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -04 -00 -00 -00 diff --git a/modules/objfmts/win64/tests/win64_test.sh b/modules/objfmts/win64/tests/win64_test.sh index 4616900f..bf7f2d3c 100755 --- a/modules/objfmts/win64/tests/win64_test.sh +++ b/modules/objfmts/win64/tests/win64_test.sh @@ -1,3 +1,4 @@ #! /bin/sh +# $Id$ ${srcdir}/out_test.sh win64_test modules/objfmts/win64/tests "win64 objfmt" "-f win64" ".obj" exit $? diff --git a/modules/objfmts/xdf/CMakeLists.txt b/modules/objfmts/xdf/CMakeLists.txt deleted file mode 100644 index 681ec2b0..00000000 --- a/modules/objfmts/xdf/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -YASM_ADD_MODULE(objfmt_xdf - objfmts/xdf/xdf-objfmt.c - ) diff --git a/modules/objfmts/xdf/Makefile.inc b/modules/objfmts/xdf/Makefile.inc index ffdc68b8..955ef218 100644 --- a/modules/objfmts/xdf/Makefile.inc +++ b/modules/objfmts/xdf/Makefile.inc @@ -1,3 +1,5 @@ +# $Id$ + libyasm_a_SOURCES += modules/objfmts/xdf/xdf-objfmt.c YASM_MODULES += objfmt_xdf diff --git a/modules/objfmts/xdf/tests/Makefile.inc b/modules/objfmts/xdf/tests/Makefile.inc index c39ba301..7bd402dc 100644 --- a/modules/objfmts/xdf/tests/Makefile.inc +++ b/modules/objfmts/xdf/tests/Makefile.inc @@ -1,3 +1,5 @@ +# $Id$ + TESTS += modules/objfmts/xdf/tests/xdf_test.sh EXTRA_DIST += modules/objfmts/xdf/tests/xdf_test.sh diff --git a/modules/objfmts/xdf/tests/xdf_test.sh b/modules/objfmts/xdf/tests/xdf_test.sh index ee9d5d5f..11640fa8 100755 --- a/modules/objfmts/xdf/tests/xdf_test.sh +++ b/modules/objfmts/xdf/tests/xdf_test.sh @@ -1,3 +1,4 @@ #! /bin/sh +# $Id$ ${srcdir}/out_test.sh xdf_test modules/objfmts/xdf/tests "xdf objfmt" "-f xdf" ".xdf" exit $? diff --git a/modules/objfmts/xdf/tests/xdfsect-err.errwarn b/modules/objfmts/xdf/tests/xdfsect-err.errwarn index 84acc4c1..4a9d5b3a 100644 --- a/modules/objfmts/xdf/tests/xdfsect-err.errwarn +++ b/modules/objfmts/xdf/tests/xdfsect-err.errwarn @@ -1,4 +1,4 @@ --:1: error: directive `section' requires an argument +-:1: directive `section' requires an argument -:2: warning: Unrecognized qualifier `use16' -:3: warning: Unrecognized qualifier `use32' -:4: warning: Unrecognized qualifier `use64' @@ -6,15 +6,15 @@ -:6: warning: Unrecognized qualifier `flat' -:7: warning: Unrecognized qualifier `foo' -:8: warning: Unrecognized qualifier `foo' --:9: error: argument to `absolute' is not an integer --:9: error: undefined symbol `foo' (first use) --:9: error: (Each undefined symbol is reported only once.) --:10: error: argument to `absolute' is not an integer +-:9: argument to `absolute' is not an integer +-:9: undefined symbol `foo' (first use) +-:9: (Each undefined symbol is reported only once.) +-:10: argument to `absolute' is not an integer -:11: warning: Unrecognized qualifier `absolute' --:12: error: argument to `virtual' is not an integer --:13: error: argument to `virtual' is not an integer +-:12: argument to `virtual' is not an integer +-:13: argument to `virtual' is not an integer -:14: warning: Unrecognized qualifier `virtual' --:15: error: argument to `align' is not an integer --:16: error: argument to `align' is not an integer +-:15: argument to `align' is not an integer +-:16: argument to `align' is not an integer -:17: warning: Unrecognized qualifier `align' -:18: warning: Unrecognized string qualifier diff --git a/modules/objfmts/xdf/xdf-objfmt.c b/modules/objfmts/xdf/xdf-objfmt.c index 9ad0e60a..4fd9a97c 100644 --- a/modules/objfmts/xdf/xdf-objfmt.c +++ b/modules/objfmts/xdf/xdf-objfmt.c @@ -25,64 +25,68 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include +/*@unused@*/ RCSID("$Id$"); +#define YASM_LIB_INTERNAL +#define YASM_BC_INTERNAL +#define YASM_EXPR_INTERNAL #include -#define REGULAR_OUTBUF_SIZE 1024 +#define REGULAR_OUTBUF_SIZE 1024 -#define XDF_MAGIC 0x87654322 +#define XDF_MAGIC 0x87654322 -#define XDF_SYM_EXTERN 1 -#define XDF_SYM_GLOBAL 2 -#define XDF_SYM_EQU 4 +#define XDF_SYM_EXTERN 1 +#define XDF_SYM_GLOBAL 2 +#define XDF_SYM_EQU 4 typedef struct xdf_reloc { yasm_reloc reloc; /*@null@*/ yasm_symrec *base; /* base symbol (for WRT) */ enum { - XDF_RELOC_REL = 1, /* relative to segment */ - XDF_RELOC_WRT = 2, /* relative to symbol */ - XDF_RELOC_RIP = 4, /* RIP-relative */ - XDF_RELOC_SEG = 8 /* segment containing symbol */ - } type; /* type of relocation */ + XDF_RELOC_REL = 1, /* relative to segment */ + XDF_RELOC_WRT = 2, /* relative to symbol */ + XDF_RELOC_RIP = 4, /* RIP-relative */ + XDF_RELOC_SEG = 8 /* segment containing symbol */ + } type; /* type of relocation */ enum { - XDF_RELOC_8 = 1, - XDF_RELOC_16 = 2, - XDF_RELOC_32 = 4, - XDF_RELOC_64 = 8 - } size; /* size of relocation */ - unsigned int shift; /* relocation shift (0,4,8,16,24,32) */ + XDF_RELOC_8 = 1, + XDF_RELOC_16 = 2, + XDF_RELOC_32 = 4, + XDF_RELOC_64 = 8 + } size; /* size of relocation */ + unsigned int shift; /* relocation shift (0,4,8,16,24,32) */ } xdf_reloc; typedef struct xdf_section_data { - /*@dependent@*/ yasm_symrec *sym; /* symbol created for this section */ - yasm_intnum *addr; /* starting memory address */ - yasm_intnum *vaddr; /* starting virtual address */ - long scnum; /* section number (0=first section) */ + /*@dependent@*/ yasm_symrec *sym; /* symbol created for this section */ + yasm_intnum *addr; /* starting memory address */ + yasm_intnum *vaddr; /* starting virtual address */ + long scnum; /* section number (0=first section) */ enum { - XDF_SECT_ABSOLUTE = 0x01, - XDF_SECT_FLAT = 0x02, - XDF_SECT_BSS = 0x04, - XDF_SECT_EQU = 0x08, - XDF_SECT_USE_16 = 0x10, - XDF_SECT_USE_32 = 0x20, - XDF_SECT_USE_64 = 0x40 - } flags; /* section flags */ + XDF_SECT_ABSOLUTE = 0x01, + XDF_SECT_FLAT = 0x02, + XDF_SECT_BSS = 0x04, + XDF_SECT_EQU = 0x08, + XDF_SECT_USE_16 = 0x10, + XDF_SECT_USE_32 = 0x20, + XDF_SECT_USE_64 = 0x40 + } flags; /* section flags */ unsigned long scnptr; /* file ptr to raw data */ - unsigned long size; /* size of raw data (section data) in bytes */ + unsigned long size; /* size of raw data (section data) in bytes */ unsigned long relptr; /* file ptr to relocation */ unsigned long nreloc; /* number of relocation entries >64k -> error */ } xdf_section_data; typedef struct xdf_symrec_data { - unsigned long index; /* assigned XDF symbol table index */ + unsigned long index; /* assigned XDF symbol table index */ } xdf_symrec_data; typedef struct yasm_objfmt_xdf { - yasm_objfmt_base objfmt; /* base structure */ + yasm_objfmt_base objfmt; /* base structure */ - long parse_scnum; /* sect numbering in parser */ + long parse_scnum; /* sect numbering in parser */ } yasm_objfmt_xdf; typedef struct xdf_objfmt_output_info { @@ -94,8 +98,8 @@ typedef struct xdf_objfmt_output_info { yasm_section *sect; /*@dependent@*/ xdf_section_data *xsd; - unsigned long indx; /* current symbol index */ - int all_syms; /* outputting all symbols? */ + unsigned long indx; /* current symbol index */ + int all_syms; /* outputting all symbols? */ unsigned long strtab_offset; /* current string table offset */ } xdf_objfmt_output_info; @@ -125,15 +129,15 @@ xdf_objfmt_create(yasm_object *object) /* Only support x86 arch */ if (yasm__strcasecmp(yasm_arch_keyword(object->arch), "x86") != 0) { - yasm_xfree(objfmt_xdf); - return NULL; + yasm_xfree(objfmt_xdf); + return NULL; } /* Support x86 and amd64 machines of x86 arch */ if (yasm__strcasecmp(yasm_arch_get_machine(object->arch), "x86") && - yasm__strcasecmp(yasm_arch_get_machine(object->arch), "amd64")) { - yasm_xfree(objfmt_xdf); - return NULL; + yasm__strcasecmp(yasm_arch_get_machine(object->arch), "amd64")) { + yasm_xfree(objfmt_xdf); + return NULL; } objfmt_xdf->parse_scnum = 0; /* section numbering starts at 0 */ @@ -145,87 +149,89 @@ xdf_objfmt_create(yasm_object *object) static int xdf_objfmt_output_value(yasm_value *value, unsigned char *buf, - unsigned int destsize, unsigned long offset, - yasm_bytecode *bc, int warn, /*@null@*/ void *d) + unsigned int destsize, unsigned long offset, + yasm_bytecode *bc, int warn, /*@null@*/ void *d) { /*@null@*/ xdf_objfmt_output_info *info = (xdf_objfmt_output_info *)d; + yasm_objfmt_xdf *objfmt_xdf; /*@dependent@*/ /*@null@*/ yasm_intnum *intn; unsigned long intn_minus; int retval; unsigned int valsize = value->size; assert(info != NULL); + objfmt_xdf = info->objfmt_xdf; if (value->abs) - value->abs = yasm_expr_simplify(value->abs, 1); + value->abs = yasm_expr_simplify(value->abs, 1); /* Try to output constant and PC-relative section-local first. * Note this does NOT output any value with a SEG, WRT, external, * cross-section, or non-PC-relative reference (those are handled below). */ switch (yasm_value_output_basic(value, buf, destsize, bc, warn, - info->object->arch)) { - case -1: - return 1; - case 0: - break; - default: - return 0; + info->object->arch)) { + case -1: + return 1; + case 0: + break; + default: + return 0; } if (value->section_rel) { - yasm_error_set(YASM_ERROR_TOO_COMPLEX, - N_("xdf: relocation too complex")); - return 1; + yasm_error_set(YASM_ERROR_TOO_COMPLEX, + N_("xdf: relocation too complex")); + return 1; } intn_minus = 0; if (value->rel) { - xdf_reloc *reloc; + xdf_reloc *reloc; - reloc = yasm_xmalloc(sizeof(xdf_reloc)); - reloc->reloc.addr = yasm_intnum_create_uint(bc->offset + offset); - reloc->reloc.sym = value->rel; - reloc->base = NULL; - reloc->size = valsize/8; - reloc->shift = value->rshift; + reloc = yasm_xmalloc(sizeof(xdf_reloc)); + reloc->reloc.addr = yasm_intnum_create_uint(bc->offset + offset); + reloc->reloc.sym = value->rel; + reloc->base = NULL; + reloc->size = valsize/8; + reloc->shift = value->rshift; - if (value->seg_of) - reloc->type = XDF_RELOC_SEG; - else if (value->wrt) { - reloc->base = value->wrt; - reloc->type = XDF_RELOC_WRT; - } else if (value->curpos_rel) { - reloc->type = XDF_RELOC_RIP; - /* Adjust to start of section, so subtract out the bytecode - * offset. - */ - intn_minus = bc->offset; - } else - reloc->type = XDF_RELOC_REL; - info->xsd->nreloc++; - yasm_section_add_reloc(info->sect, (yasm_reloc *)reloc, yasm_xfree); + if (value->seg_of) + reloc->type = XDF_RELOC_SEG; + else if (value->wrt) { + reloc->base = value->wrt; + reloc->type = XDF_RELOC_WRT; + } else if (value->curpos_rel) { + reloc->type = XDF_RELOC_RIP; + /* Adjust to start of section, so subtract out the bytecode + * offset. + */ + intn_minus = bc->offset; + } else + reloc->type = XDF_RELOC_REL; + info->xsd->nreloc++; + yasm_section_add_reloc(info->sect, (yasm_reloc *)reloc, yasm_xfree); } if (intn_minus > 0) { - intn = yasm_intnum_create_uint(intn_minus); - yasm_intnum_calc(intn, YASM_EXPR_NEG, NULL); + intn = yasm_intnum_create_uint(intn_minus); + yasm_intnum_calc(intn, YASM_EXPR_NEG, NULL); } else - intn = yasm_intnum_create_uint(0); + intn = yasm_intnum_create_uint(0); if (value->abs) { - yasm_intnum *intn2 = yasm_expr_get_intnum(&value->abs, 0); - if (!intn2) { - yasm_error_set(YASM_ERROR_TOO_COMPLEX, - N_("xdf: relocation too complex")); - yasm_intnum_destroy(intn); - return 1; - } - yasm_intnum_calc(intn, YASM_EXPR_ADD, intn2); + yasm_intnum *intn2 = yasm_expr_get_intnum(&value->abs, 0); + if (!intn2) { + yasm_error_set(YASM_ERROR_TOO_COMPLEX, + N_("xdf: relocation too complex")); + yasm_intnum_destroy(intn); + return 1; + } + yasm_intnum_calc(intn, YASM_EXPR_ADD, intn2); } retval = yasm_arch_intnum_tobytes(info->object->arch, intn, buf, destsize, - valsize, 0, bc, warn); + valsize, 0, bc, warn); yasm_intnum_destroy(intn); return retval; } @@ -241,38 +247,38 @@ xdf_objfmt_output_bytecode(yasm_bytecode *bc, /*@null@*/ void *d) assert(info != NULL); bigbuf = yasm_bc_tobytes(bc, info->buf, &size, &gap, info, - xdf_objfmt_output_value, NULL); + xdf_objfmt_output_value, NULL); /* Don't bother doing anything else if size ended up being 0. */ if (size == 0) { - if (bigbuf) - yasm_xfree(bigbuf); - return 0; + if (bigbuf) + yasm_xfree(bigbuf); + return 0; } info->xsd->size += size; /* Warn that gaps are converted to 0 and write out the 0's. */ if (gap) { - unsigned long left; - yasm_warn_set(YASM_WARN_UNINIT_CONTENTS, - N_("uninitialized space: zeroing")); - /* Write out in chunks */ - memset(info->buf, 0, REGULAR_OUTBUF_SIZE); - left = size; - while (left > REGULAR_OUTBUF_SIZE) { - fwrite(info->buf, REGULAR_OUTBUF_SIZE, 1, info->f); - left -= REGULAR_OUTBUF_SIZE; - } - fwrite(info->buf, left, 1, info->f); + unsigned long left; + yasm_warn_set(YASM_WARN_UNINIT_CONTENTS, + N_("uninitialized space: zeroing")); + /* Write out in chunks */ + memset(info->buf, 0, REGULAR_OUTBUF_SIZE); + left = size; + while (left > REGULAR_OUTBUF_SIZE) { + fwrite(info->buf, REGULAR_OUTBUF_SIZE, 1, info->f); + left -= REGULAR_OUTBUF_SIZE; + } + fwrite(info->buf, left, 1, info->f); } else { - /* Output buf (or bigbuf if non-NULL) to file */ - fwrite(bigbuf ? bigbuf : info->buf, (size_t)size, 1, info->f); + /* Output buf (or bigbuf if non-NULL) to file */ + fwrite(bigbuf ? bigbuf : info->buf, (size_t)size, 1, info->f); } /* If bigbuf was allocated, free it */ if (bigbuf) - yasm_xfree(bigbuf); + yasm_xfree(bigbuf); return 0; } @@ -290,80 +296,80 @@ xdf_objfmt_output_section(yasm_section *sect, /*@null@*/ void *d) assert(xsd != NULL); if (xsd->flags & XDF_SECT_BSS) { - /* Don't output BSS sections. - * TODO: Check for non-reserve bytecodes? - */ - pos = 0; /* position = 0 because it's not in the file */ - xsd->size = yasm_bc_next_offset(yasm_section_bcs_last(sect)); + /* Don't output BSS sections. + * TODO: Check for non-reserve bytecodes? + */ + pos = 0; /* position = 0 because it's not in the file */ + xsd->size = yasm_bc_next_offset(yasm_section_bcs_last(sect)); } else { - pos = ftell(info->f); - if (pos == -1) { - yasm__fatal(N_("could not get file position on output file")); - /*@notreached@*/ - return 1; - } + pos = ftell(info->f); + if (pos == -1) { + yasm__fatal(N_("could not get file position on output file")); + /*@notreached@*/ + return 1; + } - info->sect = sect; - info->xsd = xsd; - yasm_section_bcs_traverse(sect, info->errwarns, info, - xdf_objfmt_output_bytecode); + info->sect = sect; + info->xsd = xsd; + yasm_section_bcs_traverse(sect, info->errwarns, info, + xdf_objfmt_output_bytecode); - /* Sanity check final section size */ - if (xsd->size != yasm_bc_next_offset(yasm_section_bcs_last(sect))) - yasm_internal_error( - N_("xdf: section computed size did not match actual size")); + /* Sanity check final section size */ + if (xsd->size != yasm_bc_next_offset(yasm_section_bcs_last(sect))) + yasm_internal_error( + N_("xdf: section computed size did not match actual size")); } /* Empty? Go on to next section */ if (xsd->size == 0) - return 0; + return 0; xsd->scnptr = (unsigned long)pos; /* No relocations to output? Go on to next section */ if (xsd->nreloc == 0) - return 0; + return 0; pos = ftell(info->f); if (pos == -1) { - yasm__fatal(N_("could not get file position on output file")); - /*@notreached@*/ - return 1; + yasm__fatal(N_("could not get file position on output file")); + /*@notreached@*/ + return 1; } xsd->relptr = (unsigned long)pos; reloc = (xdf_reloc *)yasm_section_relocs_first(sect); while (reloc) { - unsigned char *localbuf = info->buf; - /*@null@*/ xdf_symrec_data *xsymd; + unsigned char *localbuf = info->buf; + /*@null@*/ xdf_symrec_data *xsymd; - xsymd = yasm_symrec_get_data(reloc->reloc.sym, &xdf_symrec_data_cb); - if (!xsymd) - yasm_internal_error( - N_("xdf: no symbol data for relocated symbol")); + xsymd = yasm_symrec_get_data(reloc->reloc.sym, &xdf_symrec_data_cb); + if (!xsymd) + yasm_internal_error( + N_("xdf: no symbol data for relocated symbol")); - yasm_intnum_get_sized(reloc->reloc.addr, localbuf, 4, 32, 0, 0, 0); - localbuf += 4; /* address of relocation */ - YASM_WRITE_32_L(localbuf, xsymd->index); /* relocated symbol */ - if (reloc->base) { - xsymd = yasm_symrec_get_data(reloc->base, &xdf_symrec_data_cb); - if (!xsymd) - yasm_internal_error( - N_("xdf: no symbol data for relocated base symbol")); - YASM_WRITE_32_L(localbuf, xsymd->index); /* base symbol */ - } else { - if (reloc->type == XDF_RELOC_WRT) - yasm_internal_error( - N_("xdf: no base symbol for WRT relocation")); - YASM_WRITE_32_L(localbuf, 0); /* no base symbol */ - } - YASM_WRITE_8(localbuf, reloc->type); /* type of relocation */ - YASM_WRITE_8(localbuf, reloc->size); /* size of relocation */ - YASM_WRITE_8(localbuf, reloc->shift); /* relocation shift */ - YASM_WRITE_8(localbuf, 0); /* flags */ - fwrite(info->buf, 16, 1, info->f); + yasm_intnum_get_sized(reloc->reloc.addr, localbuf, 4, 32, 0, 0, 0); + localbuf += 4; /* address of relocation */ + YASM_WRITE_32_L(localbuf, xsymd->index); /* relocated symbol */ + if (reloc->base) { + xsymd = yasm_symrec_get_data(reloc->base, &xdf_symrec_data_cb); + if (!xsymd) + yasm_internal_error( + N_("xdf: no symbol data for relocated base symbol")); + YASM_WRITE_32_L(localbuf, xsymd->index); /* base symbol */ + } else { + if (reloc->type == XDF_RELOC_WRT) + yasm_internal_error( + N_("xdf: no base symbol for WRT relocation")); + YASM_WRITE_32_L(localbuf, 0); /* no base symbol */ + } + YASM_WRITE_8(localbuf, reloc->type); /* type of relocation */ + YASM_WRITE_8(localbuf, reloc->size); /* size of relocation */ + YASM_WRITE_8(localbuf, reloc->shift); /* relocation shift */ + YASM_WRITE_8(localbuf, 0); /* flags */ + fwrite(info->buf, 16, 1, info->f); - reloc = (xdf_reloc *)yasm_section_reloc_next((yasm_reloc *)reloc); + reloc = (xdf_reloc *)yasm_section_reloc_next((yasm_reloc *)reloc); } return 0; @@ -373,11 +379,13 @@ static int xdf_objfmt_output_secthead(yasm_section *sect, /*@null@*/ void *d) { /*@null@*/ xdf_objfmt_output_info *info = (xdf_objfmt_output_info *)d; + yasm_objfmt_xdf *objfmt_xdf; /*@dependent@*/ /*@null@*/ xdf_section_data *xsd; /*@null@*/ xdf_symrec_data *xsymd; unsigned char *localbuf; assert(info != NULL); + objfmt_xdf = info->objfmt_xdf; xsd = yasm_section_get_data(sect, &xdf_section_data_cb); assert(xsd != NULL); @@ -385,29 +393,29 @@ xdf_objfmt_output_secthead(yasm_section *sect, /*@null@*/ void *d) xsymd = yasm_symrec_get_data(xsd->sym, &xdf_symrec_data_cb); assert(xsymd != NULL); - YASM_WRITE_32_L(localbuf, xsymd->index); /* section name symbol */ + YASM_WRITE_32_L(localbuf, xsymd->index); /* section name symbol */ if (xsd->addr) { - yasm_intnum_get_sized(xsd->addr, localbuf, 8, 64, 0, 0, 0); - localbuf += 8; /* physical address */ + yasm_intnum_get_sized(xsd->addr, localbuf, 8, 64, 0, 0, 0); + localbuf += 8; /* physical address */ } else { - YASM_WRITE_32_L(localbuf, 0); - YASM_WRITE_32_L(localbuf, 0); + YASM_WRITE_32_L(localbuf, 0); + YASM_WRITE_32_L(localbuf, 0); } if (xsd->vaddr) { - yasm_intnum_get_sized(xsd->vaddr, localbuf, 8, 64, 0, 0, 0); - localbuf += 8; /* virtual address */ + yasm_intnum_get_sized(xsd->vaddr, localbuf, 8, 64, 0, 0, 0); + localbuf += 8; /* virtual address */ } else if (xsd->addr) { - yasm_intnum_get_sized(xsd->addr, localbuf, 8, 64, 0, 0, 0); - localbuf += 8; /* VA=PA */ + yasm_intnum_get_sized(xsd->addr, localbuf, 8, 64, 0, 0, 0); + localbuf += 8; /* VA=PA */ } else { - YASM_WRITE_32_L(localbuf, 0); - YASM_WRITE_32_L(localbuf, 0); + YASM_WRITE_32_L(localbuf, 0); + YASM_WRITE_32_L(localbuf, 0); } YASM_WRITE_16_L(localbuf, yasm_section_get_align(sect)); /* alignment */ - YASM_WRITE_16_L(localbuf, xsd->flags); /* flags */ - YASM_WRITE_32_L(localbuf, xsd->scnptr); /* file ptr to data */ - YASM_WRITE_32_L(localbuf, xsd->size); /* section size */ - YASM_WRITE_32_L(localbuf, xsd->relptr); /* file ptr to relocs */ + YASM_WRITE_16_L(localbuf, xsd->flags); /* flags */ + YASM_WRITE_32_L(localbuf, xsd->scnptr); /* file ptr to data */ + YASM_WRITE_32_L(localbuf, xsd->size); /* section size */ + YASM_WRITE_32_L(localbuf, xsd->relptr); /* file ptr to relocs */ YASM_WRITE_32_L(localbuf, xsd->nreloc); /* num of relocation entries */ fwrite(info->buf, 40, 1, info->f); @@ -421,19 +429,19 @@ xdf_objfmt_count_sym(yasm_symrec *sym, /*@null@*/ void *d) yasm_sym_vis vis = yasm_symrec_get_visibility(sym); assert(info != NULL); if (vis & YASM_SYM_COMMON) { - yasm_error_set(YASM_ERROR_GENERAL, - N_("XDF object format does not support common variables")); - yasm_errwarn_propagate(info->errwarns, yasm_symrec_get_decl_line(sym)); - return 0; + yasm_error_set(YASM_ERROR_GENERAL, + N_("XDF object format does not support common variables")); + yasm_errwarn_propagate(info->errwarns, yasm_symrec_get_decl_line(sym)); + return 0; } if (info->all_syms || - (vis != YASM_SYM_LOCAL && !(vis & YASM_SYM_DLOCAL))) { - /* Save index in symrec data */ - xdf_symrec_data *sym_data = yasm_xmalloc(sizeof(xdf_symrec_data)); - sym_data->index = info->indx; - yasm_symrec_add_data(sym, &xdf_symrec_data_cb, sym_data); + (vis != YASM_SYM_LOCAL && !(vis & YASM_SYM_DLOCAL))) { + /* Save index in symrec data */ + xdf_symrec_data *sym_data = yasm_xmalloc(sizeof(xdf_symrec_data)); + sym_data->index = info->indx; + yasm_symrec_add_data(sym, &xdf_symrec_data_cb, sym_data); - info->indx++; + info->indx++; } return 0; } @@ -447,69 +455,68 @@ xdf_objfmt_output_sym(yasm_symrec *sym, /*@null@*/ void *d) assert(info != NULL); if (info->all_syms || vis != YASM_SYM_LOCAL) { - /*@only@*/ char *name = yasm_symrec_get_global_name(sym, info->object); - const yasm_expr *equ_val; - const yasm_intnum *intn; - size_t len = strlen(name); - unsigned long value = 0; - long scnum = -3; /* -3 = debugging symbol */ - /*@dependent@*/ /*@null@*/ yasm_section *sect; - /*@dependent@*/ /*@null@*/ yasm_bytecode *precbc; - unsigned long flags = 0; - unsigned char *localbuf; + const char *name = yasm_symrec_get_name(sym); + const yasm_expr *equ_val; + const yasm_intnum *intn; + size_t len = strlen(name); + unsigned long value = 0; + long scnum = -3; /* -3 = debugging symbol */ + /*@dependent@*/ /*@null@*/ yasm_section *sect; + /*@dependent@*/ /*@null@*/ yasm_bytecode *precbc; + unsigned long flags = 0; + unsigned char *localbuf; - if (vis & YASM_SYM_GLOBAL) - flags = XDF_SYM_GLOBAL; + if (vis & YASM_SYM_GLOBAL) + flags = XDF_SYM_GLOBAL; - /* Look at symrec for value/scnum/etc. */ - if (yasm_symrec_get_label(sym, &precbc)) { - if (precbc) - sect = yasm_bc_get_section(precbc); - else - sect = NULL; - /* it's a label: get value and offset. - * If there is not a section, leave as debugging symbol. - */ - if (sect) { - /*@dependent@*/ /*@null@*/ xdf_section_data *csectd; - csectd = yasm_section_get_data(sect, &xdf_section_data_cb); - if (csectd) - scnum = csectd->scnum; - else - yasm_internal_error(N_("didn't understand section")); - if (precbc) - value += yasm_bc_next_offset(precbc); - } - } else if ((equ_val = yasm_symrec_get_equ(sym))) { - yasm_expr *equ_val_copy = yasm_expr_copy(equ_val); - intn = yasm_expr_get_intnum(&equ_val_copy, 1); - if (!intn) { - if (vis & YASM_SYM_GLOBAL) { - yasm_error_set(YASM_ERROR_NOT_CONSTANT, - N_("global EQU value not an integer expression")); - yasm_errwarn_propagate(info->errwarns, equ_val->line); - } - } else - value = yasm_intnum_get_uint(intn); - yasm_expr_destroy(equ_val_copy); + /* Look at symrec for value/scnum/etc. */ + if (yasm_symrec_get_label(sym, &precbc)) { + if (precbc) + sect = yasm_bc_get_section(precbc); + else + sect = NULL; + /* it's a label: get value and offset. + * If there is not a section, leave as debugging symbol. + */ + if (sect) { + /*@dependent@*/ /*@null@*/ xdf_section_data *csectd; + csectd = yasm_section_get_data(sect, &xdf_section_data_cb); + if (csectd) + scnum = csectd->scnum; + else + yasm_internal_error(N_("didn't understand section")); + if (precbc) + value += yasm_bc_next_offset(precbc); + } + } else if ((equ_val = yasm_symrec_get_equ(sym))) { + yasm_expr *equ_val_copy = yasm_expr_copy(equ_val); + intn = yasm_expr_get_intnum(&equ_val_copy, 1); + if (!intn) { + if (vis & YASM_SYM_GLOBAL) { + yasm_error_set(YASM_ERROR_NOT_CONSTANT, + N_("global EQU value not an integer expression")); + yasm_errwarn_propagate(info->errwarns, equ_val->line); + } + } else + value = yasm_intnum_get_uint(intn); + yasm_expr_destroy(equ_val_copy); - flags |= XDF_SYM_EQU; - scnum = -2; /* -2 = absolute symbol */ - } else { - if (vis & YASM_SYM_EXTERN) { - flags = XDF_SYM_EXTERN; - scnum = -1; - } - } + flags |= XDF_SYM_EQU; + scnum = -2; /* -2 = absolute symbol */ + } else { + if (vis & YASM_SYM_EXTERN) { + flags = XDF_SYM_EXTERN; + scnum = -1; + } + } - localbuf = info->buf; - YASM_WRITE_32_L(localbuf, scnum); /* section number */ - YASM_WRITE_32_L(localbuf, value); /* value */ - YASM_WRITE_32_L(localbuf, info->strtab_offset); - info->strtab_offset += (unsigned long)(len+1); - YASM_WRITE_32_L(localbuf, flags); /* flags */ - fwrite(info->buf, 16, 1, info->f); - yasm_xfree(name); + localbuf = info->buf; + YASM_WRITE_32_L(localbuf, scnum); /* section number */ + YASM_WRITE_32_L(localbuf, value); /* value */ + YASM_WRITE_32_L(localbuf, info->strtab_offset); + info->strtab_offset += (unsigned long)(len+1); + YASM_WRITE_32_L(localbuf, flags); /* flags */ + fwrite(info->buf, 16, 1, info->f); } return 0; } @@ -523,17 +530,16 @@ xdf_objfmt_output_str(yasm_symrec *sym, /*@null@*/ void *d) assert(info != NULL); if (info->all_syms || vis != YASM_SYM_LOCAL) { - /*@only@*/ char *name = yasm_symrec_get_global_name(sym, info->object); - size_t len = strlen(name); - fwrite(name, len+1, 1, info->f); - yasm_xfree(name); + const char *name = yasm_symrec_get_name(sym); + size_t len = strlen(name); + fwrite(name, len+1, 1, info->f); } return 0; } static void xdf_objfmt_output(yasm_object *object, FILE *f, int all_syms, - yasm_errwarns *errwarns) + yasm_errwarns *errwarns) { yasm_objfmt_xdf *objfmt_xdf = (yasm_objfmt_xdf *)object->objfmt; xdf_objfmt_output_info info; @@ -548,14 +554,14 @@ xdf_objfmt_output(yasm_object *object, FILE *f, int all_syms, /* Allocate space for headers by seeking forward */ if (fseek(f, (long)(16+40*(objfmt_xdf->parse_scnum)), SEEK_SET) < 0) { - yasm__fatal(N_("could not seek on output file")); - /*@notreached@*/ - return; + yasm__fatal(N_("could not seek on output file")); + /*@notreached@*/ + return; } /* Get number of symbols */ info.indx = 0; - info.all_syms = 1; /* force all syms into symbol table */ + info.all_syms = 1; /* force all syms into symbol table */ yasm_symtab_traverse(object->symtab, &info, xdf_objfmt_count_sym); symtab_count = info.indx; @@ -570,20 +576,20 @@ xdf_objfmt_output(yasm_object *object, FILE *f, int all_syms, /* Section data/relocs */ if (yasm_object_sections_traverse(object, &info, - xdf_objfmt_output_section)) - return; + xdf_objfmt_output_section)) + return; /* Write headers */ if (fseek(f, 0, SEEK_SET) < 0) { - yasm__fatal(N_("could not seek on output file")); - /*@notreached@*/ - return; + yasm__fatal(N_("could not seek on output file")); + /*@notreached@*/ + return; } localbuf = info.buf; - YASM_WRITE_32_L(localbuf, XDF_MAGIC); /* magic number */ + YASM_WRITE_32_L(localbuf, XDF_MAGIC); /* magic number */ YASM_WRITE_32_L(localbuf, objfmt_xdf->parse_scnum); /* number of sects */ - YASM_WRITE_32_L(localbuf, symtab_count); /* number of symtabs */ + YASM_WRITE_32_L(localbuf, symtab_count); /* number of symtabs */ /* size of sect headers + symbol table + strings */ YASM_WRITE_32_L(localbuf, info.strtab_offset-16); fwrite(info.buf, 16, 1, f); @@ -599,11 +605,10 @@ xdf_objfmt_destroy(yasm_objfmt *objfmt) yasm_xfree(objfmt); } -static void -xdf_objfmt_init_new_section(yasm_section *sect, unsigned long line) +static xdf_section_data * +xdf_objfmt_init_new_section(yasm_object *object, yasm_section *sect, + const char *sectname, unsigned long line) { - yasm_object *object = yasm_section_get_object(sect); - const char *sectname = yasm_section_get_name(sect); yasm_objfmt_xdf *objfmt_xdf = (yasm_objfmt_xdf *)object->objfmt; xdf_section_data *data; yasm_symrec *sym; @@ -620,19 +625,23 @@ xdf_objfmt_init_new_section(yasm_section *sect, unsigned long line) yasm_section_add_data(sect, &xdf_section_data_cb, data); sym = yasm_symtab_define_label(object->symtab, sectname, - yasm_section_bcs_first(sect), 1, line); + yasm_section_bcs_first(sect), 1, line); data->sym = sym; + return data; } static yasm_section * xdf_objfmt_add_default_section(yasm_object *object) { yasm_section *retval; + xdf_section_data *xsd; int isnew; - retval = yasm_object_get_general(object, ".text", 0, 1, 0, &isnew, 0); - if (isnew) - yasm_section_set_default(retval, 1); + retval = yasm_object_get_general(object, ".text", 0, 0, 1, 0, &isnew, 0); + if (isnew) { + xsd = xdf_objfmt_init_new_section(object, retval, ".text", 0); + yasm_section_set_default(retval, 1); + } return retval; } @@ -654,9 +663,9 @@ xdf_helper_use(void *obj, yasm_valparam *vp, unsigned long line, void *d, static /*@observer@*/ /*@null@*/ yasm_section * xdf_objfmt_section_switch(yasm_object *object, yasm_valparamhead *valparams, - /*@unused@*/ /*@null@*/ - yasm_valparamhead *objext_valparams, - unsigned long line) + /*@unused@*/ /*@null@*/ + yasm_valparamhead *objext_valparams, + unsigned long line) { yasm_valparam *vp; yasm_section *retval; @@ -701,7 +710,7 @@ xdf_objfmt_section_switch(yasm_object *object, yasm_valparamhead *valparams, vp = yasm_vps_first(valparams); sectname = yasm_vp_string(vp); if (!sectname) - return NULL; + return NULL; vp = yasm_vps_next(vp); flags_override = yasm_dir_helper(object, vp, line, help, NELEMS(help), @@ -715,70 +724,66 @@ xdf_objfmt_section_switch(yasm_object *object, yasm_valparamhead *valparams, align = yasm_intnum_get_uint(data.align_intn); yasm_intnum_destroy(data.align_intn); - /* Alignments must be a power of two. */ - if (!is_exp2(align)) { - yasm_error_set(YASM_ERROR_VALUE, - N_("argument to `%s' is not a power of two"), + /* Alignments must be a power of two. */ + if (!is_exp2(align)) { + yasm_error_set(YASM_ERROR_VALUE, + N_("argument to `%s' is not a power of two"), "align"); if (data.vaddr) yasm_intnum_destroy(data.vaddr); if (data.absaddr) yasm_intnum_destroy(data.absaddr); - return NULL; - } + return NULL; + } - /* Check to see if alignment is supported size */ - if (align > 4096) { - yasm_error_set(YASM_ERROR_VALUE, - N_("XDF does not support alignments > 4096")); + /* Check to see if alignment is supported size */ + if (align > 4096) { + yasm_error_set(YASM_ERROR_VALUE, + N_("XDF does not support alignments > 4096")); if (data.vaddr) yasm_intnum_destroy(data.vaddr); if (data.absaddr) yasm_intnum_destroy(data.absaddr); - return NULL; - } + return NULL; + } } - retval = yasm_object_get_general(object, sectname, align, 1, resonly, - &isnew, line); + retval = yasm_object_get_general(object, sectname, 0, align, 1, resonly, + &isnew, line); - xsd = yasm_section_get_data(retval, &xdf_section_data_cb); + if (isnew) + xsd = xdf_objfmt_init_new_section(object, retval, sectname, line); + else + xsd = yasm_section_get_data(retval, &xdf_section_data_cb); if (isnew || yasm_section_is_default(retval)) { - yasm_section_set_default(retval, 0); + yasm_section_set_default(retval, 0); xsd->flags = data.flags; if (data.absaddr) { - if (xsd->addr) - yasm_intnum_destroy(xsd->addr); + if (xsd->addr) + yasm_intnum_destroy(xsd->addr); xsd->addr = data.absaddr; - } + } if (data.vaddr) { - if (xsd->vaddr) - yasm_intnum_destroy(xsd->vaddr); + if (xsd->vaddr) + yasm_intnum_destroy(xsd->vaddr); xsd->vaddr = data.vaddr; - } - yasm_section_set_align(retval, align, line); + } + yasm_section_set_align(retval, align, line); } else if (flags_override) - yasm_warn_set(YASM_WARN_GENERAL, - N_("section flags ignored on section redeclaration")); + yasm_warn_set(YASM_WARN_GENERAL, + N_("section flags ignored on section redeclaration")); return retval; } -static /*@observer@*/ /*@null@*/ yasm_symrec * -xdf_objfmt_get_special_sym(yasm_object *object, const char *name, - const char *parser) -{ - return NULL; -} - static void xdf_section_data_destroy(void *data) { xdf_section_data *xsd = (xdf_section_data *)data; if (xsd->addr) - yasm_intnum_destroy(xsd->addr); + yasm_intnum_destroy(xsd->addr); if (xsd->vaddr) - yasm_intnum_destroy(xsd->vaddr); + yasm_intnum_destroy(xsd->vaddr); yasm_xfree(data); } @@ -827,16 +832,12 @@ yasm_objfmt_module yasm_xdf_LTX_objfmt = { "xdf", "xdf", 32, - 0, xdf_objfmt_dbgfmt_keywords, "null", - NULL, /* no directives */ - NULL, /* no standard macros */ + NULL, /* no directives */ xdf_objfmt_create, xdf_objfmt_output, xdf_objfmt_destroy, xdf_objfmt_add_default_section, - xdf_objfmt_init_new_section, - xdf_objfmt_section_switch, - xdf_objfmt_get_special_sym + xdf_objfmt_section_switch }; diff --git a/modules/objfmts/yasm_objfmts.xml b/modules/objfmts/yasm_objfmts.xml index f4c9a75b..3a70fedc 100644 --- a/modules/objfmts/yasm_objfmts.xml +++ b/modules/objfmts/yasm_objfmts.xml @@ -2,6 +2,8 @@ + + @@ -96,12 +98,11 @@ elf - The ELF object format really comes in three flavors: - elf32 (for 32-bit targets), elf64 - (for 64-bit targets and elfx32 (for x32 targets). - ELF is a standard object format in common use on modern Unix and - compatible systems (e.g. Linux, FreeBSD). ELF has complex support - for relocatable and shared objects. + The ELF object format really comes in two flavors: + elf32 (for 32-bit targets) and elf64 + (for 64-bit targets). ELF is a standard object format in common + use on modern Unix and compatible systems (e.g. Linux, FreeBSD). + ELF has complex support for relocatable and shared objects. diff --git a/modules/parsers/CMakeLists.txt b/modules/parsers/CMakeLists.txt deleted file mode 100644 index db1e371f..00000000 --- a/modules/parsers/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -INCLUDE(parsers/gas/CMakeLists.txt) -INCLUDE(parsers/nasm/CMakeLists.txt) diff --git a/modules/parsers/Makefile.inc b/modules/parsers/Makefile.inc index b432fa9e..89bfd35b 100644 --- a/modules/parsers/Makefile.inc +++ b/modules/parsers/Makefile.inc @@ -1,11 +1,12 @@ +# $Id$ + EXTRA_DIST += modules/parsers/gas/Makefile.inc EXTRA_DIST += modules/parsers/nasm/Makefile.inc include modules/parsers/gas/Makefile.inc include modules/parsers/nasm/Makefile.inc -include modules/parsers/tasm/Makefile.inc -notrans_dist_man_MANS += yasm_parsers.7 +dist_man_MANS += yasm_parsers.7 if BUILD_MAN yasm_parsers.7: modules/parsers/yasm_parsers.xml diff --git a/modules/parsers/gas/CMakeLists.txt b/modules/parsers/gas/CMakeLists.txt deleted file mode 100644 index 8c59d4dd..00000000 --- a/modules/parsers/gas/CMakeLists.txt +++ /dev/null @@ -1,15 +0,0 @@ -YASM_RE2C( - ${CMAKE_CURRENT_SOURCE_DIR}/parsers/gas/gas-token.re - ${CMAKE_CURRENT_BINARY_DIR}/gas-token.c - -b - ) - -YASM_ADD_MODULE(parser_gas - parsers/gas/gas-parser.c - parsers/gas/gas-parse.c - parsers/gas/gas-parse-intel.c - gas-token.c - ) - -YASM_ADD_MODULE(parser_gnu - ) diff --git a/modules/parsers/gas/Makefile.inc b/modules/parsers/gas/Makefile.inc index a0264cc6..84fa4190 100644 --- a/modules/parsers/gas/Makefile.inc +++ b/modules/parsers/gas/Makefile.inc @@ -1,7 +1,8 @@ +# $Id$ + libyasm_a_SOURCES += modules/parsers/gas/gas-parser.c libyasm_a_SOURCES += modules/parsers/gas/gas-parser.h libyasm_a_SOURCES += modules/parsers/gas/gas-parse.c -libyasm_a_SOURCES += modules/parsers/gas/gas-parse-intel.c nodist_libyasm_a_SOURCES += gas-token.c YASM_MODULES += parser_gas parser_gnu diff --git a/modules/parsers/gas/gas-parse-intel.c b/modules/parsers/gas/gas-parse-intel.c deleted file mode 100644 index 9d412fc7..00000000 --- a/modules/parsers/gas/gas-parse-intel.c +++ /dev/null @@ -1,90 +0,0 @@ -/* - * GAS-compatible parser Intel syntax support - * - * Copyright (C) 2010 Alexei Svitkine - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the names of other contributors - * may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND OTHER CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR OTHER CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -#include - -#include - -#include "modules/parsers/gas/gas-parser.h" -#include "modules/parsers/nasm/nasm-parser-struct.h" - -extern yasm_bytecode *gas_intel_syntax_parse_instr(yasm_parser_nasm *parser_nasm, unsigned char *instr); - -#define SET_FIELDS(to, from) \ - (to)->object = (from)->object; \ - (to)->locallabel_base = (from)->locallabel_base; \ - (to)->locallabel_base_len = (from)->locallabel_base_len; \ - (to)->preproc = (from)->preproc; \ - (to)->errwarns = (from)->errwarns; \ - (to)->linemap = (from)->linemap; \ - (to)->prev_bc = (from)->prev_bc; - -yasm_bytecode *parse_instr_intel(yasm_parser_gas *parser_gas) -{ - char *stok, *slim; - unsigned char *line; - size_t length; - - yasm_parser_nasm parser_nasm; - yasm_bytecode *bc; - - memset(&parser_nasm, 0, sizeof(parser_nasm)); - - yasm_arch_set_var(parser_gas->object->arch, "gas_intel_mode", 1); - SET_FIELDS(&parser_nasm, parser_gas); - parser_nasm.masm = 1; - - stok = (char *) parser_gas->s.tok; - slim = (char *) parser_gas->s.lim; - length = 0; - while (&stok[length] < slim && stok[length] != '\n') { - length++; - } - - if (&stok[length] == slim && parser_gas->line) { - line = yasm_xmalloc(length + parser_gas->lineleft + 1); - memcpy(line, parser_gas->s.tok, length); - memcpy(line + length, parser_gas->linepos, parser_gas->lineleft); - length += parser_gas->lineleft; - if (line[length - 1] == '\n') length--; - } else { - line = yasm_xmalloc(length + 1); - memcpy(line, parser_gas->s.tok, length); - } - line[length] = '\0'; - - bc = gas_intel_syntax_parse_instr(&parser_nasm, line); - - SET_FIELDS(parser_gas, &parser_nasm); - yasm_arch_set_var(parser_gas->object->arch, "gas_intel_mode", 0); - - yasm_xfree(line); - - return bc; -} diff --git a/modules/parsers/gas/gas-parse.c b/modules/parsers/gas/gas-parse.c index 14c86a70..0439ce33 100644 --- a/modules/parsers/gas/gas-parse.c +++ b/modules/parsers/gas/gas-parse.c @@ -28,24 +28,18 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include +RCSID("$Id$"); +#define YASM_LIB_INTERNAL +#define YASM_EXPR_INTERNAL #include -#include #include #include #include "modules/parsers/gas/gas-parser.h" -typedef struct dir_lookup { - const char *name; - yasm_bytecode * (*handler) (yasm_parser_gas *, unsigned int); - unsigned int param; - enum gas_parser_state newstate; -} dir_lookup; - -static void cpp_line_marker(yasm_parser_gas *parser_gas); -static void nasm_line_marker(yasm_parser_gas *parser_gas); +static yasm_bytecode *parse_line(yasm_parser_gas *parser_gas); static yasm_bytecode *parse_instr(yasm_parser_gas *parser_gas); static int parse_dirvals(yasm_parser_gas *parser_gas, yasm_valparamhead *vps); static int parse_datavals(yasm_parser_gas *parser_gas, yasm_datavalhead *dvs); @@ -59,15 +53,15 @@ static yasm_expr *parse_expr2(yasm_parser_gas *parser_gas); static void define_label(yasm_parser_gas *parser_gas, char *name, int local); static void define_lcomm(yasm_parser_gas *parser_gas, /*@only@*/ char *name, - yasm_expr *size, /*@null@*/ yasm_expr *align); + yasm_expr *size, /*@null@*/ yasm_expr *align); static yasm_section *gas_get_section (yasm_parser_gas *parser_gas, /*@only@*/ char *name, /*@null@*/ char *flags, /*@null@*/ char *type, /*@null@*/ yasm_valparamhead *objext_valparams, int builtin); static void gas_switch_section - (yasm_parser_gas *parser_gas, /*@only@*/ const char *name, - /*@null@*/ char *flags, /*@null@*/ char *type, - /*@null@*/ yasm_valparamhead *objext_valparams, int builtin); + (yasm_parser_gas *parser_gas, /*@only@*/ char *name, /*@null@*/ char *flags, + /*@null@*/ char *type, /*@null@*/ yasm_valparamhead *objext_valparams, + int builtin); static yasm_bytecode *gas_parser_align (yasm_parser_gas *parser_gas, yasm_section *sect, yasm_expr *boundval, /*@null@*/ yasm_expr *fillval, /*@null@*/ yasm_expr *maxskipval, @@ -76,9 +70,15 @@ static yasm_bytecode *gas_parser_dir_fill (yasm_parser_gas *parser_gas, /*@only@*/ yasm_expr *repeat, /*@only@*/ /*@null@*/ yasm_expr *size, /*@only@*/ /*@null@*/ yasm_expr *value); +#if 0 +static void gas_parser_directive + (yasm_parser_gas *parser_gas, const char *name, + yasm_valparamhead *valparams, + /*@null@*/ yasm_valparamhead *objext_valparams); +#endif -#define is_eol_tok(tok) ((tok) == '\n' || (tok) == ';' || (tok) == 0) -#define is_eol() is_eol_tok(curtok) +#define is_eol_tok(tok) ((tok) == '\n' || (tok) == ';' || (tok) == 0) +#define is_eol() is_eol_tok(curtok) #define get_next_token() (curtok = gas_parser_lex(&curval, parser_gas)) @@ -87,9 +87,9 @@ get_peek_token(yasm_parser_gas *parser_gas) { char savech = parser_gas->tokch; if (parser_gas->peek_token != NONE) - yasm_internal_error(N_("can only have one token of lookahead")); + yasm_internal_error(N_("only can have one token of lookahead")); parser_gas->peek_token = - gas_parser_lex(&parser_gas->peek_tokval, parser_gas); + gas_parser_lex(&parser_gas->peek_tokval, parser_gas); parser_gas->peek_tokch = parser_gas->tokch; parser_gas->tokch = savech; } @@ -98,23 +98,25 @@ static void destroy_curtok_(yasm_parser_gas *parser_gas) { if (curtok < 256) - ; + ; else switch ((enum tokentype)curtok) { - case INTNUM: - yasm_intnum_destroy(curval.intn); - break; - case FLTNUM: - yasm_floatnum_destroy(curval.flt); - break; - case ID: - case LABEL: - case STRING: - yasm_xfree(curval.str.contents); - break; - default: - break; + case INTNUM: + yasm_intnum_destroy(curval.intn); + break; + case FLTNUM: + yasm_floatnum_destroy(curval.flt); + break; + case ID: + case LABEL: + yasm_xfree(curval.str_val); + break; + case STRING: + yasm_xfree(curval.str.contents); + break; + default: + break; } - curtok = NONE; /* sanity */ + curtok = NONE; /* sanity */ } #define destroy_curtok() destroy_curtok_(parser_gas) @@ -125,15 +127,15 @@ static void demand_eol_(yasm_parser_gas *parser_gas) { if (is_eol()) - return; + return; yasm_error_set(YASM_ERROR_SYNTAX, - N_("junk at end of line, first unrecognized character is `%c'"), - parser_gas->tokch); + N_("junk at end of line, first unrecognized character is `%c'"), + parser_gas->tokch); do { - destroy_curtok(); - get_next_token(); + destroy_curtok(); + get_next_token(); } while (!is_eol()); } #define demand_eol() demand_eol_(parser_gas) @@ -145,24 +147,47 @@ expect_(yasm_parser_gas *parser_gas, int token) const char *str; if (curtok == token) - return 1; + return 1; switch (token) { - case INTNUM: str = "integer"; break; - case FLTNUM: str = "floating point value"; break; - case STRING: str = "string"; break; - case REG: str = "register"; break; - case REGGROUP: str = "register group"; break; - case SEGREG: str = "segment register"; break; - case TARGETMOD: str = "target modifier"; break; - case LEFT_OP: str = "<<"; break; - case RIGHT_OP: str = ">>"; break; - case ID: str = "identifier"; break; - case LABEL: str = "label"; break; - default: - strch[1] = token; - str = strch; - break; + case INTNUM: str = "integer"; break; + case FLTNUM: str = "floating point value"; break; + case STRING: str = "string"; break; + case INSN: str = "instruction"; break; + case PREFIX: str = "instruction prefix"; break; + case REG: str = "register"; break; + case REGGROUP: str = "register group"; break; + case SEGREG: str = "segment register"; break; + case TARGETMOD: str = "target modifier"; break; + case LEFT_OP: str = "<<"; break; + case RIGHT_OP: str = ">>"; break; + case ID: str = "identifier"; break; + case LABEL: str = "label"; break; + case LINE: + case DIR_ALIGN: + case DIR_ASCII: + case DIR_COMM: + case DIR_DATA: + case DIR_ENDR: + case DIR_EQU: + case DIR_FILE: + case DIR_FILL: + case DIR_LEB128: + case DIR_LINE: + case DIR_LOCAL: + case DIR_LCOMM: + case DIR_ORG: + case DIR_REPT: + case DIR_SECTION: + case DIR_SECTNAME: + case DIR_SKIP: + case DIR_ZERO: + str = "directive"; + break; + default: + strch[1] = token; + str = strch; + break; } yasm_error_set(YASM_ERROR_PARSE, "expected %s", str); destroy_curtok(); @@ -170,835 +195,566 @@ expect_(yasm_parser_gas *parser_gas, int token) } #define expect(token) expect_(parser_gas, token) +void +gas_parser_parse(yasm_parser_gas *parser_gas) +{ + while (get_next_token() != 0) { + yasm_bytecode *bc = NULL, *temp_bc; + + if (!is_eol()) { + bc = parse_line(parser_gas); + demand_eol(); + } + + yasm_errwarn_propagate(parser_gas->errwarns, cur_line); + + temp_bc = yasm_section_bcs_append(cursect, bc); + if (temp_bc) + parser_gas->prev_bc = temp_bc; + if (curtok == ';') + continue; /* don't advance line number until \n */ + if (parser_gas->save_input) + yasm_linemap_add_source(parser_gas->linemap, + temp_bc, + (char *)parser_gas->save_line[parser_gas->save_last ^ 1]); + yasm_linemap_goto_next(parser_gas->linemap); + parser_gas->dir_line++; /* keep track for .line followed by .file */ + } +} + static yasm_bytecode * parse_line(yasm_parser_gas *parser_gas) { yasm_bytecode *bc; yasm_expr *e; + yasm_intnum *intn; + yasm_datavalhead dvs; yasm_valparamhead vps; + yasm_valparam *vp; + unsigned int ival; char *id; - const dir_lookup *dir; if (is_eol()) - return NULL; + return NULL; bc = parse_instr(parser_gas); if (bc) - return bc; + return bc; switch (curtok) { - case ID: + case ID: + id = ID_val; + parser_gas->state = INSTDIR; + get_next_token(); /* ID */ + if (curtok == ':') { + /* Label */ + parser_gas->state = INITIAL; + get_next_token(); /* : */ + define_label(parser_gas, id, 0); + return parse_line(parser_gas); + } else if (curtok == '=') { + /* EQU */ + /* TODO: allow redefinition, assigning to . (same as .org) */ + parser_gas->state = INITIAL; + get_next_token(); /* = */ + e = parse_expr(parser_gas); + if (e) + yasm_symtab_define_equ(p_symtab, id, e, cur_line); + else + yasm_error_set(YASM_ERROR_SYNTAX, + N_("expression expected after `%s'"), "="); + yasm_xfree(id); + return NULL; + } + + /* possibly a directive; try to parse it */ + parse_dirvals(parser_gas, &vps); + if (!yasm_object_directive(p_object, id, "gas", &vps, NULL, + cur_line)) { + yasm_vps_delete(&vps); + yasm_xfree(id); + return NULL; + } + yasm_vps_delete(&vps); + if (id[0] == '.') + yasm_warn_set(YASM_WARN_GENERAL, + N_("directive `%s' not recognized"), id); + else + yasm_error_set(YASM_ERROR_SYNTAX, + N_("instruction not recognized: `%s'"), id); + yasm_xfree(id); + return NULL; + case LABEL: + define_label(parser_gas, LABEL_val, 0); + get_next_token(); /* LABEL */ + return parse_line(parser_gas); + + /* Line directive */ + case DIR_LINE: + get_next_token(); /* DIR_LINE */ + + if (!expect(INTNUM)) return NULL; + if (yasm_intnum_sign(INTNUM_val) < 0) { + get_next_token(); /* INTNUM */ + yasm_error_set(YASM_ERROR_SYNTAX, + N_("line number is negative")); + return NULL; + } + + parser_gas->dir_line = yasm_intnum_get_uint(INTNUM_val); + yasm_intnum_destroy(INTNUM_val); + get_next_token(); /* INTNUM */ + + if (parser_gas->dir_fileline == 3) { + /* Have both file and line */ + yasm_linemap_set(parser_gas->linemap, NULL, + parser_gas->dir_line, 1); + } else if (parser_gas->dir_fileline == 1) { + /* Had previous file directive only */ + parser_gas->dir_fileline = 3; + yasm_linemap_set(parser_gas->linemap, parser_gas->dir_file, + parser_gas->dir_line, 1); + } else { + /* Didn't see file yet */ + parser_gas->dir_fileline = 2; + } + return NULL; + + /* Macro directives */ + case DIR_REPT: + get_next_token(); /* DIR_REPT */ + e = parse_expr(parser_gas); + if (!e) { + yasm_error_set(YASM_ERROR_SYNTAX, + N_("expression expected after `%s'"), + ".rept"); + return NULL; + } + intn = yasm_expr_get_intnum(&e, 0); + + if (!intn) { + yasm_error_set(YASM_ERROR_NOT_ABSOLUTE, + N_("rept expression not absolute")); + } else if (yasm_intnum_sign(intn) < 0) { + yasm_error_set(YASM_ERROR_VALUE, + N_("rept expression is negative")); + } else { + gas_rept *rept = yasm_xmalloc(sizeof(gas_rept)); + STAILQ_INIT(&rept->lines); + rept->startline = cur_line; + rept->numrept = yasm_intnum_get_uint(intn); + rept->numdone = 0; + rept->line = NULL; + rept->linepos = 0; + rept->ended = 0; + rept->oldbuf = NULL; + rept->oldbuflen = 0; + rept->oldbufpos = 0; + parser_gas->rept = rept; + } + return NULL; + case DIR_ENDR: + get_next_token(); /* DIR_ENDR */ + /* Shouldn't ever get here unless we didn't get a DIR_REPT first */ + yasm_error_set(YASM_ERROR_SYNTAX, N_("endr without matching rept")); + return NULL; + + /* Alignment directives */ + case DIR_ALIGN: + { + yasm_expr *bound, *fill=NULL, *maxskip=NULL; + + ival = DIR_ALIGN_val; + get_next_token(); /* DIR_ALIGN */ + + bound = parse_expr(parser_gas); + if (!bound) { + yasm_error_set(YASM_ERROR_SYNTAX, + N_(".align directive must specify alignment")); + return NULL; + } + + if (curtok == ',') { + get_next_token(); /* ',' */ + fill = parse_expr(parser_gas); + if (curtok == ',') { + get_next_token(); /* ',' */ + maxskip = parse_expr(parser_gas); + } + } + + return gas_parser_align(parser_gas, cursect, bound, fill, maxskip, + (int)ival); + } + case DIR_ORG: + get_next_token(); /* DIR_ORG */ + if (!expect(INTNUM)) return NULL; + /* TODO: support expr instead of intnum */ + bc = yasm_bc_create_org(yasm_intnum_get_uint(INTNUM_val), cur_line); + yasm_intnum_destroy(INTNUM_val); + get_next_token(); /* INTNUM */ + return bc; + + /* Data visibility directives */ + case DIR_LOCAL: + get_next_token(); /* DIR_LOCAL */ + if (!expect(ID)) return NULL; + yasm_symtab_declare(p_symtab, ID_val, YASM_SYM_DLOCAL, cur_line); + yasm_xfree(ID_val); + get_next_token(); /* ID */ + return NULL; + case DIR_COMM: + case DIR_LCOMM: + { + yasm_expr *align = NULL; + /*@null@*/ /*@dependent@*/ yasm_symrec *sym; + int is_lcomm = curtok == DIR_LCOMM; + + get_next_token(); /* DIR_LOCAL */ + + if (!expect(ID)) return NULL; + id = ID_val; + get_next_token(); /* ID */ + if (!expect(',')) { + yasm_xfree(id); + return NULL; + } + get_next_token(); /* , */ + e = parse_expr(parser_gas); + if (!e) { + yasm_error_set(YASM_ERROR_SYNTAX, N_("size expected for `%s'"), + ".COMM"); + return NULL; + } + if (curtok == ',') { + /* Optional alignment expression */ + get_next_token(); /* ',' */ + align = parse_expr(parser_gas); + } + /* If already explicitly declared local, treat like LCOMM */ + if (is_lcomm + || ((sym = yasm_symtab_get(p_symtab, id)) + && yasm_symrec_get_visibility(sym) == YASM_SYM_DLOCAL)) { + define_lcomm(parser_gas, id, e, align); + } else if (align) { + /* Give third parameter as objext valparam */ + yasm_valparamhead *extvps = yasm_vps_create(); + vp = yasm_vp_create_expr(NULL, align); + yasm_vps_append(extvps, vp); + + sym = yasm_symtab_declare(p_symtab, id, YASM_SYM_COMMON, + cur_line); + yasm_symrec_set_common_size(sym, e); + yasm_symrec_set_objext_valparams(sym, extvps); + + yasm_xfree(id); + } else { + sym = yasm_symtab_declare(p_symtab, id, YASM_SYM_COMMON, + cur_line); + yasm_symrec_set_common_size(sym, e); + yasm_xfree(id); + } + return NULL; + } + + /* Integer data definition directives */ + case DIR_ASCII: + ival = DIR_ASCII_val; + get_next_token(); /* DIR_ASCII */ + if (!parse_strvals(parser_gas, &dvs)) + return NULL; + return yasm_bc_create_data(&dvs, 1, (int)ival, p_object->arch, + cur_line); + case DIR_DATA: + ival = DIR_DATA_val; + get_next_token(); /* DIR_DATA */ + if (!parse_datavals(parser_gas, &dvs)) + return NULL; + return yasm_bc_create_data(&dvs, ival, 0, p_object->arch, + cur_line); + case DIR_LEB128: + ival = DIR_LEB128_val; + get_next_token(); /* DIR_LEB128 */ + if (!parse_datavals(parser_gas, &dvs)) + return NULL; + return yasm_bc_create_leb128(&dvs, (int)ival, cur_line); + + /* Empty space / fill data definition directives */ + case DIR_ZERO: + get_next_token(); /* DIR_ZERO */ + e = parse_expr(parser_gas); + if (!e) { + yasm_error_set(YASM_ERROR_SYNTAX, + N_("expression expected after `%s'"), ".ZERO"); + return NULL; + } + + yasm_dvs_initialize(&dvs); + yasm_dvs_append(&dvs, yasm_dv_create_expr( + p_expr_new_ident(yasm_expr_int(yasm_intnum_create_uint(0))))); + bc = yasm_bc_create_data(&dvs, 1, 0, p_object->arch, cur_line); + yasm_bc_set_multiple(bc, e); + return bc; + case DIR_SKIP: + { + yasm_expr *e_val; + + get_next_token(); /* DIR_SKIP */ + e = parse_expr(parser_gas); + if (!e) { + yasm_error_set(YASM_ERROR_SYNTAX, + N_("expression expected after `%s'"), ".SKIP"); + return NULL; + } + if (curtok != ',') + return yasm_bc_create_reserve(e, 1, cur_line); + get_next_token(); /* ',' */ + e_val = parse_expr(parser_gas); + yasm_dvs_initialize(&dvs); + yasm_dvs_append(&dvs, yasm_dv_create_expr(e_val)); + bc = yasm_bc_create_data(&dvs, 1, 0, p_object->arch, cur_line); + + yasm_bc_set_multiple(bc, e); + return bc; + } + + /* fill data definition directive */ + case DIR_FILL: + { + yasm_expr *sz=NULL, *val=NULL; + get_next_token(); /* DIR_FILL */ + e = parse_expr(parser_gas); + if (!e) { + yasm_error_set(YASM_ERROR_SYNTAX, + N_("expression expected after `%s'"), ".FILL"); + return NULL; + } + if (curtok == ',') { + get_next_token(); /* ',' */ + sz = parse_expr(parser_gas); + if (curtok == ',') { + get_next_token(); /* ',' */ + val = parse_expr(parser_gas); + } + } + return gas_parser_dir_fill(parser_gas, e, sz, val); + } + + /* Section directives */ + case DIR_SECTNAME: + gas_switch_section(parser_gas, DIR_SECTNAME_val, NULL, NULL, NULL, + 1); + get_next_token(); /* DIR_SECTNAME */ + return NULL; + case DIR_SECTION: + { + /* DIR_SECTION ID ',' STRING ',' '@' ID ',' dirvals */ + char *sectname, *flags = NULL, *type = NULL; + int have_vps = 0; + + get_next_token(); /* DIR_SECTION */ + + if (!expect(ID)) return NULL; + sectname = ID_val; + get_next_token(); /* ID */ + + if (curtok == ',') { + get_next_token(); /* ',' */ + if (!expect(STRING)) { + yasm_error_set(YASM_ERROR_SYNTAX, + N_("flag string expected")); + yasm_xfree(sectname); + return NULL; + } + flags = STRING_val.contents; + get_next_token(); /* STRING */ + } + + if (curtok == ',') { + get_next_token(); /* ',' */ + if (!expect('@')) { + yasm_xfree(sectname); + yasm_xfree(flags); + return NULL; + } + get_next_token(); /* '@' */ + if (!expect(ID)) { + yasm_xfree(sectname); + yasm_xfree(flags); + return NULL; + } + type = ID_val; + get_next_token(); /* ID */ + } + + if (curtok == ',') { + get_next_token(); /* ',' */ + if (parse_dirvals(parser_gas, &vps)) + have_vps = 1; + } + + gas_switch_section(parser_gas, sectname, flags, type, + have_vps ? &vps : NULL, 0); + yasm_xfree(flags); + return NULL; + } + + /* Other directives */ + case DIR_EQU: + /* ID ',' expr */ + get_next_token(); /* DIR_EQU */ + if (!expect(ID)) return NULL; id = ID_val; - - /* See if it's a gas-specific directive */ - dir = (const dir_lookup *)HAMT_search(parser_gas->dirs, id); - if (dir) { - parser_gas->state = dir->newstate; - get_next_token(); /* ID */ - return dir->handler(parser_gas, dir->param); - } - get_next_token(); /* ID */ - if (curtok == ':') { - /* Label */ - parser_gas->state = INITIAL; - get_next_token(); /* : */ - define_label(parser_gas, id, 0); - return parse_line(parser_gas); - } else if (curtok == '=') { - /* EQU */ - /* TODO: allow redefinition, assigning to . (same as .org) */ - parser_gas->state = INITIAL; - get_next_token(); /* = */ - e = parse_expr(parser_gas); - if (e) - yasm_symtab_define_equ(p_symtab, id, e, cur_line); - else - yasm_error_set(YASM_ERROR_SYNTAX, - N_("expression expected after `%s'"), "="); + if (!expect(',')) { yasm_xfree(id); return NULL; } - - /* possibly a directive; try to parse it */ - parse_dirvals(parser_gas, &vps); - if (!yasm_object_directive(p_object, id, "gas", &vps, NULL, - cur_line)) { - yasm_vps_delete(&vps); - yasm_xfree(id); - return NULL; - } - yasm_vps_delete(&vps); - if (id[0] == '.') - yasm_warn_set(YASM_WARN_GENERAL, - N_("directive `%s' not recognized"), id); + get_next_token(); /* ',' */ + e = parse_expr(parser_gas); + if (e) + yasm_symtab_define_equ(p_symtab, id, e, cur_line); else yasm_error_set(YASM_ERROR_SYNTAX, - N_("instruction not recognized: `%s'"), id); + N_("expression expected after `%s'"), ","); yasm_xfree(id); return NULL; - case LABEL: - define_label(parser_gas, LABEL_val, 0); - get_next_token(); /* LABEL */ - return parse_line(parser_gas); - case CPP_LINE_MARKER: - get_next_token(); - cpp_line_marker(parser_gas); - return NULL; - case NASM_LINE_MARKER: - get_next_token(); - nasm_line_marker(parser_gas); - return NULL; - default: - yasm_error_set(YASM_ERROR_SYNTAX, - N_("label or instruction expected at start of line")); - return NULL; + + case DIR_FILE: + get_next_token(); /* DIR_FILE */ + if (curtok == STRING) { + /* No file number; this form also sets the assembler's + * internal line number. + */ + char *filename = STRING_val.contents; + get_next_token(); /* STRING */ + if (parser_gas->dir_fileline == 3) { + /* Have both file and line */ + const char *old_fn; + unsigned long old_line; + + yasm_linemap_lookup(parser_gas->linemap, cur_line, &old_fn, + &old_line); + yasm_linemap_set(parser_gas->linemap, filename, old_line, + 1); + } else if (parser_gas->dir_fileline == 2) { + /* Had previous line directive only */ + parser_gas->dir_fileline = 3; + yasm_linemap_set(parser_gas->linemap, filename, + parser_gas->dir_line, 1); + } else { + /* Didn't see line yet, save file */ + parser_gas->dir_fileline = 1; + if (parser_gas->dir_file) + yasm_xfree(parser_gas->dir_file); + parser_gas->dir_file = yasm__xstrdup(filename); + } + + /* Pass change along to debug format */ + yasm_vps_initialize(&vps); + vp = yasm_vp_create_string(NULL, filename); + yasm_vps_append(&vps, vp); + + yasm_object_directive(p_object, ".file", "gas", &vps, NULL, + cur_line); + + yasm_vps_delete(&vps); + return NULL; + } + + /* fileno filename form */ + yasm_vps_initialize(&vps); + + if (!expect(INTNUM)) return NULL; + vp = yasm_vp_create_expr(NULL, + p_expr_new_ident(yasm_expr_int(INTNUM_val))); + yasm_vps_append(&vps, vp); + get_next_token(); /* INTNUM */ + + if (!expect(STRING)) { + yasm_vps_delete(&vps); + return NULL; + } + vp = yasm_vp_create_string(NULL, STRING_val.contents); + yasm_vps_append(&vps, vp); + get_next_token(); /* STRING */ + + yasm_object_directive(p_object, ".file", "gas", &vps, NULL, + cur_line); + + yasm_vps_delete(&vps); + return NULL; + default: + yasm_error_set(YASM_ERROR_SYNTAX, + N_("label or instruction expected at start of line")); + return NULL; } } -/* - Handle line markers generated by cpp. - - We expect a positive integer (line) followed by a string (filename). If we - fail to find either of these, we treat the line as a comment. There is a - possibility of false positives (mistaking a comment for a line marker, when - the comment is not intended as a line marker) but this cannot be avoided - without adding a filter to the input before passing it to cpp. - - This function is only called if the preprocessor was 'cpp', since the - CPP_LINE_MARKER token isn't generated for any other preprocessor. With any - other preprocessor, anything after a '#' is always treated as a comment. -*/ -static void -cpp_line_marker(yasm_parser_gas *parser_gas) -{ - yasm_valparamhead vps; - yasm_valparam *vp; - unsigned long line; - char *filename; - - /* Line number. */ - if (curtok != INTNUM) { - /* Skip over a comment. */ - while (curtok != '\n') - get_next_token(); - - return; - } - - if (yasm_intnum_sign(INTNUM_val) < 0) { - get_next_token(); /* INTNUM */ - yasm_error_set(YASM_ERROR_SYNTAX, - N_("line number is negative")); - return; - } - - line = yasm_intnum_get_uint(INTNUM_val); - - /* - Set to (line - 1) since the directive indicates that the *next* line - will have the number given. - - cpp should never produce line=0, but the if keeps us safe just incase. - */ - if (line != 0) - line--; - - yasm_intnum_destroy(INTNUM_val); - get_next_token(); /* INTNUM */ - - /* File name, in quotes. */ - if (curtok != STRING) { - /* Skip over a comment. */ - while (curtok != '\n') - get_next_token(); - - return; - } - - filename = STRING_val.contents; - get_next_token(); - - /* Set linemap. */ - yasm_linemap_set(parser_gas->linemap, filename, 0, line, 1); - - /* - The first line marker in the file (which should be on the first line - of the file) will give us the name of the source file. This information - needs to be passed on to the debug format module. - */ - if (parser_gas->seen_line_marker == 0) { - parser_gas->seen_line_marker = 1; - - yasm_vps_initialize(&vps); - vp = yasm_vp_create_string(NULL, filename); - yasm_vps_append(&vps, vp); - - yasm_object_directive(p_object, ".file", "gas", &vps, NULL, cur_line); - - yasm_vps_delete(&vps); - } else - yasm_xfree(filename); - - /* Skip flags. */ - while (1) { - switch (curtok) { - case INTNUM: - break; - - case '\n': - return; - - default: - yasm_error_set(YASM_ERROR_SYNTAX, - N_("junk at end of cpp line marker")); - return; - } - get_next_token(); - } -} - -/* - Handle line markers generated by the nasm preproc. - - We expect a positive integer (line) followed by a plus sign, followed by - another positive integer, followed by a string (filename). - - This function is only called if the preprocessor was 'nasm', since the - NASM_LINE_MARKER token isn't generated for any other preprocessor. -*/ -static void -nasm_line_marker(yasm_parser_gas *parser_gas) -{ - yasm_valparamhead vps; - yasm_valparam *vp; - unsigned long line, incr; - char *filename; - - /* Line number. */ - if (!expect(INTNUM)) return; - - if (yasm_intnum_sign(INTNUM_val) < 0) { - get_next_token(); /* INTNUM */ - yasm_error_set(YASM_ERROR_SYNTAX, - N_("line number is negative")); - return; - } - - line = yasm_intnum_get_uint(INTNUM_val); - - /* - Set to (line - 1) since the directive indicates that the *next* line - will have the number given. - - cpp should never produce line=0, but the if keeps us safe just incase. - */ - if (line != 0) - line--; - - yasm_intnum_destroy(INTNUM_val); - get_next_token(); /* INTNUM */ - - if (!expect('+')) return; - get_next_token(); /* + */ - - /* Line number increment. */ - if (!expect(INTNUM)) return; - - if (yasm_intnum_sign(INTNUM_val) < 0) { - get_next_token(); /* INTNUM */ - yasm_error_set(YASM_ERROR_SYNTAX, - N_("line increment is negative")); - return; - } - - incr = yasm_intnum_get_uint(INTNUM_val); - yasm_intnum_destroy(INTNUM_val); - - /* File name is not in quotes, so need to switch to a different tokenizer - * state. - */ - parser_gas->state = NASM_FILENAME; - get_next_token(); /* INTNUM */ - if (!expect(STRING)) { - parser_gas->state = INITIAL; - return; - } - - filename = STRING_val.contents; - - /* Set linemap. */ - yasm_linemap_set(parser_gas->linemap, filename, 0, line, incr); - - /* - The first line marker in the file (which should be on the first line - of the file) will give us the name of the source file. This information - needs to be passed on to the debug format module. - */ - if (parser_gas->seen_line_marker == 0) { - parser_gas->seen_line_marker = 1; - - yasm_vps_initialize(&vps); - vp = yasm_vp_create_string(NULL, filename); - yasm_vps_append(&vps, vp); - - yasm_object_directive(p_object, ".file", "gas", &vps, NULL, cur_line); - - yasm_vps_delete(&vps); - } else - yasm_xfree(filename); - - /* We need to poke back on the \n that was consumed by the tokenizer */ - parser_gas->peek_token = '\n'; - get_next_token(); -} - -/* Line directive */ -static yasm_bytecode * -dir_line(yasm_parser_gas *parser_gas, unsigned int param) -{ - if (!expect(INTNUM)) return NULL; - if (yasm_intnum_sign(INTNUM_val) < 0) { - get_next_token(); /* INTNUM */ - yasm_error_set(YASM_ERROR_SYNTAX, - N_("line number is negative")); - return NULL; - } - - parser_gas->dir_line = yasm_intnum_get_uint(INTNUM_val); - yasm_intnum_destroy(INTNUM_val); - get_next_token(); /* INTNUM */ - - if (parser_gas->dir_fileline == 3) { - /* Have both file and line */ - yasm_linemap_set(parser_gas->linemap, NULL, 0, - parser_gas->dir_line, 1); - } else if (parser_gas->dir_fileline == 1) { - /* Had previous file directive only */ - parser_gas->dir_fileline = 3; - yasm_linemap_set(parser_gas->linemap, parser_gas->dir_file, 0, - parser_gas->dir_line, 1); - } else { - /* Didn't see file yet */ - parser_gas->dir_fileline = 2; - } - return NULL; -} - -/* Alignment directives */ - -static yasm_bytecode * -dir_align(yasm_parser_gas *parser_gas, unsigned int param) -{ - yasm_expr *bound, *fill=NULL, *maxskip=NULL; - - bound = parse_expr(parser_gas); - if (!bound) { - yasm_error_set(YASM_ERROR_SYNTAX, - N_(".align directive must specify alignment")); - return NULL; - } - - if (curtok == ',') { - get_next_token(); /* ',' */ - fill = parse_expr(parser_gas); - if (curtok == ',') { - get_next_token(); /* ',' */ - maxskip = parse_expr(parser_gas); - } - } - - return gas_parser_align(parser_gas, cursect, bound, fill, maxskip, - (int)param); -} - -static yasm_bytecode * -dir_org(yasm_parser_gas *parser_gas, unsigned int param) -{ - yasm_intnum *start, *value=NULL; - yasm_bytecode *bc; - - /* TODO: support expr instead of intnum */ - if (!expect(INTNUM)) return NULL; - start = INTNUM_val; - get_next_token(); /* INTNUM */ - - if (curtok == ',') { - get_next_token(); /* ',' */ - /* TODO: support expr instead of intnum */ - if (!expect(INTNUM)) return NULL; - value = INTNUM_val; - get_next_token(); /* INTNUM */ - } - if (value) { - bc = yasm_bc_create_org(yasm_intnum_get_uint(start), - yasm_intnum_get_uint(value), cur_line); - yasm_intnum_destroy(value); - } else - bc = yasm_bc_create_org(yasm_intnum_get_uint(start), 0, - cur_line); - yasm_intnum_destroy(start); - return bc; -} - -/* Data visibility directives */ - -static yasm_bytecode * -dir_local(yasm_parser_gas *parser_gas, unsigned int param) -{ - if (!expect(ID)) return NULL; - yasm_symtab_declare(p_symtab, ID_val, YASM_SYM_DLOCAL, cur_line); - yasm_xfree(ID_val); - get_next_token(); /* ID */ - return NULL; -} - -static yasm_bytecode * -dir_comm(yasm_parser_gas *parser_gas, unsigned int is_lcomm) -{ - yasm_expr *align = NULL; - /*@null@*/ /*@dependent@*/ yasm_symrec *sym; - char *id; - yasm_expr *e; - - if (!expect(ID)) return NULL; - id = ID_val; - get_next_token(); /* ID */ - if (!expect(',')) { - yasm_xfree(id); - return NULL; - } - get_next_token(); /* , */ - e = parse_expr(parser_gas); - if (!e) { - yasm_error_set(YASM_ERROR_SYNTAX, N_("size expected for `%s'"), - ".COMM"); - return NULL; - } - if (curtok == ',') { - /* Optional alignment expression */ - get_next_token(); /* ',' */ - align = parse_expr(parser_gas); - } - /* If already explicitly declared local, treat like LCOMM */ - if (is_lcomm - || ((sym = yasm_symtab_get(p_symtab, id)) - && yasm_symrec_get_visibility(sym) == YASM_SYM_DLOCAL)) { - define_lcomm(parser_gas, id, e, align); - } else if (align) { - /* Give third parameter as objext valparam */ - yasm_valparamhead *extvps = yasm_vps_create(); - yasm_valparam *vp = yasm_vp_create_expr(NULL, align); - yasm_vps_append(extvps, vp); - - sym = yasm_symtab_declare(p_symtab, id, YASM_SYM_COMMON, - cur_line); - yasm_symrec_set_common_size(sym, e); - yasm_symrec_set_objext_valparams(sym, extvps); - - yasm_xfree(id); - } else { - sym = yasm_symtab_declare(p_symtab, id, YASM_SYM_COMMON, - cur_line); - yasm_symrec_set_common_size(sym, e); - yasm_xfree(id); - } - return NULL; -} - -/* Integer data definition directives */ - -static yasm_bytecode * -dir_ascii(yasm_parser_gas *parser_gas, unsigned int withzero) -{ - yasm_datavalhead dvs; - if (!parse_strvals(parser_gas, &dvs)) - return NULL; - return yasm_bc_create_data(&dvs, 1, (int)withzero, p_object->arch, - cur_line); -} - -static yasm_bytecode * -dir_data(yasm_parser_gas *parser_gas, unsigned int size) -{ - yasm_datavalhead dvs; - if (!parse_datavals(parser_gas, &dvs)) - return NULL; - return yasm_bc_create_data(&dvs, size, 0, p_object->arch, cur_line); -} - -static yasm_bytecode * -dir_leb128(yasm_parser_gas *parser_gas, unsigned int sign) -{ - yasm_datavalhead dvs; - if (!parse_datavals(parser_gas, &dvs)) - return NULL; - return yasm_bc_create_leb128(&dvs, (int)sign, cur_line); -} - -/* Empty space / fill data definition directives */ - -static yasm_bytecode * -dir_zero(yasm_parser_gas *parser_gas, unsigned int param) -{ - yasm_bytecode *bc; - yasm_datavalhead dvs; - yasm_expr *e = parse_expr(parser_gas); - if (!e) { - yasm_error_set(YASM_ERROR_SYNTAX, - N_("expression expected after `%s'"), ".ZERO"); - return NULL; - } - - yasm_dvs_initialize(&dvs); - yasm_dvs_append(&dvs, yasm_dv_create_expr( - p_expr_new_ident(yasm_expr_int(yasm_intnum_create_uint(0))))); - bc = yasm_bc_create_data(&dvs, 1, 0, p_object->arch, cur_line); - yasm_bc_set_multiple(bc, e); - return bc; -} - -static yasm_bytecode * -dir_skip(yasm_parser_gas *parser_gas, unsigned int param) -{ - yasm_expr *e, *e_val; - yasm_bytecode *bc; - yasm_datavalhead dvs; - - e = parse_expr(parser_gas); - if (!e) { - yasm_error_set(YASM_ERROR_SYNTAX, - N_("expression expected after `%s'"), ".SKIP"); - return NULL; - } - if (curtok != ',') - return yasm_bc_create_reserve(e, 1, cur_line); - get_next_token(); /* ',' */ - e_val = parse_expr(parser_gas); - yasm_dvs_initialize(&dvs); - yasm_dvs_append(&dvs, yasm_dv_create_expr(e_val)); - bc = yasm_bc_create_data(&dvs, 1, 0, p_object->arch, cur_line); - - yasm_bc_set_multiple(bc, e); - return bc; -} - -/* fill data definition directive */ -static yasm_bytecode * -dir_fill(yasm_parser_gas *parser_gas, unsigned int param) -{ - yasm_expr *sz=NULL, *val=NULL; - yasm_expr *e = parse_expr(parser_gas); - if (!e) { - yasm_error_set(YASM_ERROR_SYNTAX, - N_("expression expected after `%s'"), ".FILL"); - return NULL; - } - if (curtok == ',') { - get_next_token(); /* ',' */ - sz = parse_expr(parser_gas); - if (curtok == ',') { - get_next_token(); /* ',' */ - val = parse_expr(parser_gas); - } - } - return gas_parser_dir_fill(parser_gas, e, sz, val); -} - -/* Section directives */ - -static yasm_bytecode * -dir_bss_section(yasm_parser_gas *parser_gas, unsigned int param) -{ - gas_switch_section(parser_gas, ".bss", NULL, NULL, NULL, 1); - return NULL; -} - -static yasm_bytecode * -dir_data_section(yasm_parser_gas *parser_gas, unsigned int param) -{ - gas_switch_section(parser_gas, ".data", NULL, NULL, NULL, 1); - return NULL; -} - -static yasm_bytecode * -dir_text_section(yasm_parser_gas *parser_gas, unsigned int param) -{ - gas_switch_section(parser_gas, ".text", NULL, NULL, NULL, 1); - return NULL; -} - -static yasm_bytecode * -dir_section(yasm_parser_gas *parser_gas, unsigned int param) -{ - /* DIR_SECTION ID ',' STRING ',' '@' ID ',' dirvals */ - char *sectname, *flags = NULL, *type = NULL; - yasm_valparamhead vps; - int have_vps = 0; - - if (!expect(ID)) return NULL; - sectname = ID_val; - get_next_token(); /* ID */ - - if (curtok == ',') { - get_next_token(); /* ',' */ - if (!expect(STRING)) { - yasm_error_set(YASM_ERROR_SYNTAX, - N_("flag string expected")); - yasm_xfree(sectname); - return NULL; - } - flags = STRING_val.contents; - get_next_token(); /* STRING */ - } - - if (curtok == ',') { - get_next_token(); /* ',' */ - if (!expect('@')) { - yasm_xfree(sectname); - yasm_xfree(flags); - return NULL; - } - get_next_token(); /* '@' */ - if (!expect(ID)) { - yasm_xfree(sectname); - yasm_xfree(flags); - return NULL; - } - type = ID_val; - get_next_token(); /* ID */ - } - - if (curtok == ',') { - get_next_token(); /* ',' */ - if (parse_dirvals(parser_gas, &vps)) - have_vps = 1; - } - - gas_switch_section(parser_gas, sectname, flags, type, - have_vps ? &vps : NULL, 0); - yasm_xfree(sectname); - yasm_xfree(flags); - return NULL; -} - -/* Other directives */ - -static yasm_bytecode * -dir_equ(yasm_parser_gas *parser_gas, unsigned int param) -{ - yasm_expr *e; - char *id; - - /* ID ',' expr */ - if (!expect(ID)) return NULL; - id = ID_val; - get_next_token(); /* ID */ - if (!expect(',')) { - yasm_xfree(id); - return NULL; - } - get_next_token(); /* ',' */ - e = parse_expr(parser_gas); - if (e) - yasm_symtab_define_equ(p_symtab, id, e, cur_line); - else - yasm_error_set(YASM_ERROR_SYNTAX, - N_("expression expected after `%s'"), ","); - yasm_xfree(id); - return NULL; -} - -static yasm_bytecode * -dir_file(yasm_parser_gas *parser_gas, unsigned int param) -{ - yasm_valparamhead vps; - yasm_valparam *vp; - - if (curtok == STRING) { - /* No file number; this form also sets the assembler's - * internal line number. - */ - char *filename = STRING_val.contents; - - get_next_token(); /* STRING */ - if (parser_gas->dir_fileline == 3) { - /* Have both file and line */ - const char *old_fn; - unsigned long old_line; - - yasm_linemap_lookup(parser_gas->linemap, cur_line, &old_fn, - &old_line); - yasm_linemap_set(parser_gas->linemap, filename, 0, old_line, - 1); - } else if (parser_gas->dir_fileline == 2) { - /* Had previous line directive only */ - parser_gas->dir_fileline = 3; - yasm_linemap_set(parser_gas->linemap, filename, 0, - parser_gas->dir_line, 1); - } else { - /* Didn't see line yet, save file */ - parser_gas->dir_fileline = 1; - if (parser_gas->dir_file) - yasm_xfree(parser_gas->dir_file); - parser_gas->dir_file = yasm__xstrdup(filename); - } - - /* Pass change along to debug format */ - yasm_vps_initialize(&vps); - vp = yasm_vp_create_string(NULL, filename); - yasm_vps_append(&vps, vp); - - yasm_object_directive(p_object, ".file", "gas", &vps, NULL, - cur_line); - - yasm_vps_delete(&vps); - return NULL; - } - - /* fileno filename form */ - yasm_vps_initialize(&vps); - - if (!expect(INTNUM)) return NULL; - vp = yasm_vp_create_expr(NULL, - p_expr_new_ident(yasm_expr_int(INTNUM_val))); - yasm_vps_append(&vps, vp); - get_next_token(); /* INTNUM */ - - if (!expect(STRING)) { - yasm_vps_delete(&vps); - return NULL; - } - vp = yasm_vp_create_string(NULL, STRING_val.contents); - yasm_vps_append(&vps, vp); - get_next_token(); /* STRING */ - - yasm_object_directive(p_object, ".file", "gas", &vps, NULL, - cur_line); - - yasm_vps_delete(&vps); - return NULL; -} - - -static yasm_bytecode * -dir_intel_syntax(yasm_parser_gas *parser_gas, unsigned int param) -{ - parser_gas->intel_syntax = 1; - - do { - destroy_curtok(); - get_next_token(); - } while (!is_eol()); - return NULL; -} - -static yasm_bytecode * -dir_att_syntax(yasm_parser_gas *parser_gas, unsigned int param) -{ - parser_gas->intel_syntax = 0; - return NULL; -} - static yasm_bytecode * parse_instr(yasm_parser_gas *parser_gas) { yasm_bytecode *bc; - char *id; - uintptr_t prefix; - if (parser_gas->intel_syntax) { - bc = parse_instr_intel(parser_gas); - if (bc) { - yasm_warn_disable(YASM_WARN_UNREC_CHAR); - do { - destroy_curtok(); - get_next_token(); - } while (!is_eol()); - yasm_warn_enable(YASM_WARN_UNREC_CHAR); - } - return bc; - } + switch (curtok) { + case INSN: + { + yystype insn = curval; /* structure copy */ + yasm_insn_operands operands; + int num_operands = 0; - if (curtok != ID) - return NULL; + get_next_token(); + if (is_eol()) { + /* no operands */ + return yasm_bc_create_insn(p_object->arch, insn.arch_data, + 0, NULL, cur_line); + } - id = ID_val; + /* parse operands */ + yasm_ops_initialize(&operands); + for (;;) { + yasm_insn_operand *op = parse_operand(parser_gas); + if (!op) { + yasm_error_set(YASM_ERROR_SYNTAX, + N_("expression syntax error")); + yasm_ops_delete(&operands, 1); + return NULL; + } + yasm_ops_append(&operands, op); + num_operands++; - /* instructions/prefixes must start with a letter */ - if (!isalpha(id[0])) - return NULL; - - /* check to be sure it's not a label or equ */ - get_peek_token(parser_gas); - if (parser_gas->peek_token == ':' || parser_gas->peek_token == '=') - return NULL; - - switch (yasm_arch_parse_check_insnprefix - (p_object->arch, ID_val, ID_len, cur_line, &bc, &prefix)) { - case YASM_ARCH_INSN: - { - yasm_insn *insn; - - /* Propagate errors in case we got a warning from the arch */ - yasm_errwarn_propagate(parser_gas->errwarns, cur_line); - - insn = yasm_bc_get_insn(bc); - - yasm_xfree(id); - get_next_token(); /* ID */ - if (is_eol()) - return bc; /* no operands */ - - /* parse operands */ - for (;;) { - yasm_insn_operand *op = parse_operand(parser_gas); - if (!op) { - yasm_error_set(YASM_ERROR_SYNTAX, - N_("expression syntax error")); - yasm_bc_destroy(bc); - return NULL; - } - yasm_insn_ops_append(insn, op); - - if (is_eol()) - break; - if (!expect(',')) { - yasm_bc_destroy(bc); - return NULL; - } - get_next_token(); - } - return bc; - } - case YASM_ARCH_PREFIX: - /* Propagate errors in case we got a warning from the arch */ - yasm_errwarn_propagate(parser_gas->errwarns, cur_line); - - yasm_xfree(id); - get_next_token(); /* ID */ - bc = parse_instr(parser_gas); - if (!bc) - bc = yasm_arch_create_empty_insn(p_object->arch, cur_line); - yasm_insn_add_prefix(yasm_bc_get_insn(bc), prefix); - return bc; - default: - break; - } - - /* Check for segment register used as prefix */ - switch (yasm_arch_parse_check_regtmod(p_object->arch, ID_val, ID_len, - &prefix)) { - case YASM_ARCH_SEGREG: - yasm_xfree(id); - get_next_token(); /* ID */ - bc = parse_instr(parser_gas); - if (!bc) - bc = yasm_arch_create_empty_insn(p_object->arch, cur_line); - yasm_insn_add_seg_prefix(yasm_bc_get_insn(bc), prefix); - return bc; - default: - return NULL; + if (is_eol()) + break; + if (!expect(',')) { + yasm_ops_delete(&operands, 1); + return NULL; + } + get_next_token(); + } + return yasm_bc_create_insn(p_object->arch, insn.arch_data, + num_operands, &operands, cur_line); + } + case PREFIX: + { + yystype prefix = curval; /* structure copy */ + get_next_token(); /* PREFIX */ + bc = parse_instr(parser_gas); + if (!bc) + bc = yasm_bc_create_empty_insn(p_object->arch, cur_line); + yasm_bc_insn_add_prefix(bc, prefix.arch_data); + return bc; + } + case SEGREG: + { + uintptr_t segreg = SEGREG_val[0]; + get_next_token(); /* SEGREG */ + bc = parse_instr(parser_gas); + if (!bc) + bc = yasm_bc_create_empty_insn(p_object->arch, cur_line); + yasm_bc_insn_add_seg_prefix(bc, segreg); + } + default: + return NULL; } } @@ -1012,9 +768,9 @@ parse_dirvals(yasm_parser_gas *parser_gas, yasm_valparamhead *vps) yasm_vps_initialize(vps); for (;;) { - switch (curtok) { - case ID: - get_peek_token(parser_gas); + switch (curtok) { + case ID: + get_peek_token(parser_gas); switch (parser_gas->peek_token) { case '+': case '-': case '|': case '^': case '&': case '!': @@ -1023,36 +779,31 @@ parse_dirvals(yasm_parser_gas *parser_gas, yasm_valparamhead *vps) vp = yasm_vp_create_expr(NULL, e); break; default: - /* Just an ID */ + /* Just an ID */ vp = yasm_vp_create_id(NULL, ID_val, '\0'); - get_next_token(); /* ID */ + get_next_token(); /* ID */ break; - } - break; - case STRING: + } + break; + case STRING: vp = yasm_vp_create_string(NULL, STRING_val.contents); - get_next_token(); /* STRING */ - break; - case REG: - e = p_expr_new_ident(yasm_expr_reg(REG_val)); + get_next_token(); /* STRING */ + break; + case '@': + /* XXX: is throwing it away *really* the right thing? */ + get_next_token(); /* @ */ + continue; + default: + e = parse_expr(parser_gas); + if (!e) + return num; vp = yasm_vp_create_expr(NULL, e); - get_next_token(); /* REG */ - break; - case '@': - /* XXX: is throwing it away *really* the right thing? */ - get_next_token(); /* @ */ - continue; - default: - e = parse_expr(parser_gas); - if (!e) - return num; - vp = yasm_vp_create_expr(NULL, e); - break; - } - yasm_vps_append(vps, vp); - num++; - if (curtok == ',') - get_next_token(); /* ',' */ + break; + } + yasm_vps_append(vps, vp); + num++; + if (curtok == ',') + get_next_token(); /* ',' */ } return num; } @@ -1067,18 +818,18 @@ parse_datavals(yasm_parser_gas *parser_gas, yasm_datavalhead *dvs) yasm_dvs_initialize(dvs); for (;;) { - e = parse_expr(parser_gas); - if (!e) { - yasm_dvs_delete(dvs); - yasm_dvs_initialize(dvs); - return 0; - } - dv = yasm_dv_create_expr(e); - yasm_dvs_append(dvs, dv); - num++; - if (curtok != ',') - break; - get_next_token(); /* ',' */ + e = parse_expr(parser_gas); + if (!e) { + yasm_dvs_delete(dvs); + yasm_dvs_initialize(dvs); + return 0; + } + dv = yasm_dv_create_expr(e); + yasm_dvs_append(dvs, dv); + num++; + if (curtok != ',') + break; + get_next_token(); /* ',' */ } return num; } @@ -1092,18 +843,18 @@ parse_strvals(yasm_parser_gas *parser_gas, yasm_datavalhead *dvs) yasm_dvs_initialize(dvs); for (;;) { - if (!expect(STRING)) { - yasm_dvs_delete(dvs); - yasm_dvs_initialize(dvs); - return 0; - } - dv = yasm_dv_create_string(STRING_val.contents, STRING_val.len); - yasm_dvs_append(dvs, dv); - get_next_token(); /* STRING */ - num++; - if (curtok != ',') - break; - get_next_token(); /* ',' */ + if (!expect(STRING)) { + yasm_dvs_delete(dvs); + yasm_dvs_initialize(dvs); + return 0; + } + dv = yasm_dv_create_string(STRING_val.contents, STRING_val.len); + yasm_dvs_append(dvs, dv); + get_next_token(); /* STRING */ + num++; + if (curtok != ',') + break; + get_next_token(); /* ',' */ } return num; } @@ -1118,15 +869,15 @@ parse_memaddr(yasm_parser_gas *parser_gas) int strong = 0; if (curtok == SEGREG) { - uintptr_t segreg = SEGREG_val; - get_next_token(); /* SEGREG */ - if (!expect(':')) return NULL; - get_next_token(); /* ':' */ - ea = parse_memaddr(parser_gas); - if (!ea) - return NULL; - yasm_ea_set_segreg(ea, segreg); - return ea; + uintptr_t segreg = SEGREG_val[0]; + get_next_token(); /* SEGREG */ + if (!expect(':')) return NULL; + get_next_token(); /* ':' */ + ea = parse_memaddr(parser_gas); + if (!ea) + return NULL; + yasm_ea_set_segreg(ea, segreg); + return ea; } /* We want to parse a leading expression, except when it's actually @@ -1135,99 +886,99 @@ parse_memaddr(yasm_parser_gas *parser_gas) */ get_peek_token(parser_gas); if (curtok != '(' || (parser_gas->peek_token != REG - && parser_gas->peek_token != ',')) - e1 = parse_expr(parser_gas); + && parser_gas->peek_token != ',')) + e1 = parse_expr(parser_gas); else - e1 = NULL; + e1 = NULL; if (curtok == '(') { - int havereg = 0; - uintptr_t reg = 0; - yasm_intnum *scale = NULL; + int havereg = 0; + uintptr_t reg = 0; + yasm_intnum *scale = NULL; - get_next_token(); /* '(' */ + get_next_token(); /* '(' */ - /* base register */ - if (curtok == REG) { - e2 = p_expr_new_ident(yasm_expr_reg(REG_val)); - get_next_token(); /* REG */ - } else - e2 = p_expr_new_ident(yasm_expr_int(yasm_intnum_create_uint(0))); + /* base register */ + if (curtok == REG) { + e2 = p_expr_new_ident(yasm_expr_reg(REG_val[0])); + get_next_token(); /* REG */ + } else + e2 = p_expr_new_ident(yasm_expr_int(yasm_intnum_create_uint(0))); - if (curtok == ')') - goto done; + if (curtok == ')') + goto done; - if (!expect(',')) { - yasm_error_set(YASM_ERROR_SYNTAX, N_("invalid memory expression")); - if (e1) yasm_expr_destroy(e1); - yasm_expr_destroy(e2); - return NULL; - } - get_next_token(); /* ',' */ + if (!expect(',')) { + yasm_error_set(YASM_ERROR_SYNTAX, N_("invalid memory expression")); + if (e1) yasm_expr_destroy(e1); + yasm_expr_destroy(e2); + return NULL; + } + get_next_token(); /* ',' */ - if (curtok == ')') - goto done; + if (curtok == ')') + goto done; - /* index register */ - if (curtok == REG) { - reg = REG_val; - havereg = 1; - get_next_token(); /* REG */ - if (curtok != ',') { - scale = yasm_intnum_create_uint(1); - goto done; - } - get_next_token(); /* ',' */ - } + /* index register */ + if (curtok == REG) { + reg = REG_val[0]; + havereg = 1; + get_next_token(); /* REG */ + if (curtok != ',') { + scale = yasm_intnum_create_uint(1); + goto done; + } + get_next_token(); /* ',' */ + } - /* scale */ - if (!expect(INTNUM)) { - yasm_error_set(YASM_ERROR_SYNTAX, N_("non-integer scale")); - if (e1) yasm_expr_destroy(e1); - yasm_expr_destroy(e2); - return NULL; - } - scale = INTNUM_val; - get_next_token(); /* INTNUM */ + /* scale */ + if (!expect(INTNUM)) { + yasm_error_set(YASM_ERROR_SYNTAX, N_("non-integer scale")); + if (e1) yasm_expr_destroy(e1); + yasm_expr_destroy(e2); + return NULL; + } + scale = INTNUM_val; + get_next_token(); /* INTNUM */ done: - if (!expect(')')) { - yasm_error_set(YASM_ERROR_SYNTAX, N_("invalid memory expression")); - if (scale) yasm_intnum_destroy(scale); - if (e1) yasm_expr_destroy(e1); - yasm_expr_destroy(e2); - return NULL; - } - get_next_token(); /* ')' */ + if (!expect(')')) { + yasm_error_set(YASM_ERROR_SYNTAX, N_("invalid memory expression")); + if (scale) yasm_intnum_destroy(scale); + if (e1) yasm_expr_destroy(e1); + yasm_expr_destroy(e2); + return NULL; + } + get_next_token(); /* ')' */ - if (scale) { - if (!havereg) { - if (yasm_intnum_get_uint(scale) != 1) - yasm_warn_set(YASM_WARN_GENERAL, - N_("scale factor of %u without an index register"), - yasm_intnum_get_uint(scale)); - yasm_intnum_destroy(scale); - } else - e2 = p_expr_new(yasm_expr_expr(e2), YASM_EXPR_ADD, - yasm_expr_expr(p_expr_new(yasm_expr_reg(reg), YASM_EXPR_MUL, - yasm_expr_int(scale)))); - } + if (scale) { + if (!havereg) { + if (yasm_intnum_get_uint(scale) != 1) + yasm_warn_set(YASM_WARN_GENERAL, + N_("scale factor of %u without an index register"), + yasm_intnum_get_uint(scale)); + yasm_intnum_destroy(scale); + } else + e2 = p_expr_new(yasm_expr_expr(e2), YASM_EXPR_ADD, + yasm_expr_expr(p_expr_new(yasm_expr_reg(reg), YASM_EXPR_MUL, + yasm_expr_int(scale)))); + } - if (e1) { - /* Ordering is critical here to correctly detecting presence of - * RIP in RIP-relative expressions. - */ - e1 = p_expr_new_tree(e2, YASM_EXPR_ADD, e1); - } else - e1 = e2; - strong = 1; + if (e1) { + /* Ordering is critical here to correctly detecting presence of + * RIP in RIP-relative expressions. + */ + e1 = p_expr_new_tree(e2, YASM_EXPR_ADD, e1); + } else + e1 = e2; + strong = 1; } if (!e1) - return NULL; + return NULL; ea = yasm_arch_ea_create(p_object->arch, e1); if (strong) - ea->strong = 1; + yasm_ea_set_strong(ea, 1); return ea; } @@ -1239,84 +990,84 @@ parse_operand(yasm_parser_gas *parser_gas) uintptr_t reg; switch (curtok) { - case REG: - reg = REG_val; - get_next_token(); /* REG */ - return yasm_operand_create_reg(reg); - case SEGREG: - /* need to see if it's really a memory address */ - get_peek_token(parser_gas); - if (parser_gas->peek_token == ':') { - ea = parse_memaddr(parser_gas); - if (!ea) - return NULL; - return yasm_operand_create_mem(ea); - } - reg = SEGREG_val; - get_next_token(); /* SEGREG */ - return yasm_operand_create_segreg(reg); - case REGGROUP: - { - unsigned long regindex; - reg = REGGROUP_val; - get_next_token(); /* REGGROUP */ - if (curtok != '(') - return yasm_operand_create_reg(reg); - get_next_token(); /* '(' */ - if (!expect(INTNUM)) { - yasm_error_set(YASM_ERROR_SYNTAX, - N_("integer register index expected")); - return NULL; - } - regindex = yasm_intnum_get_uint(INTNUM_val); - get_next_token(); /* INTNUM */ - if (!expect(')')) { - yasm_error_set(YASM_ERROR_SYNTAX, - N_("missing closing parenthesis for register index")); - return NULL; - } - get_next_token(); /* ')' */ - reg = yasm_arch_reggroup_get_reg(p_object->arch, reg, regindex); - if (reg == 0) { - yasm_error_set(YASM_ERROR_SYNTAX, N_("bad register index `%u'"), - regindex); - return NULL; - } - return yasm_operand_create_reg(reg); - } - case '$': - { - yasm_expr *e; - get_next_token(); /* '$' */ - e = parse_expr(parser_gas); - if (!e) { - yasm_error_set(YASM_ERROR_SYNTAX, - N_("expression missing after `%s'"), "$"); - return NULL; - } - return yasm_operand_create_imm(e); - } - case '*': - get_next_token(); /* '*' */ - if (curtok == REG) { - op = yasm_operand_create_reg(REG_val); - get_next_token(); /* REG */ - } else { - ea = parse_memaddr(parser_gas); - if (!ea) { - yasm_error_set(YASM_ERROR_SYNTAX, - N_("expression missing after `%s'"), "*"); - return NULL; - } - op = yasm_operand_create_mem(ea); - } - op->deref = 1; - return op; - default: - ea = parse_memaddr(parser_gas); - if (!ea) - return NULL; - return yasm_operand_create_mem(ea); + case REG: + reg = REG_val[0]; + get_next_token(); /* REG */ + return yasm_operand_create_reg(reg); + case SEGREG: + /* need to see if it's really a memory address */ + get_peek_token(parser_gas); + if (parser_gas->peek_token == ':') { + ea = parse_memaddr(parser_gas); + if (!ea) + return NULL; + return yasm_operand_create_mem(ea); + } + reg = SEGREG_val[0]; + get_next_token(); /* SEGREG */ + return yasm_operand_create_segreg(reg); + case REGGROUP: + { + unsigned long regindex; + reg = REGGROUP_val[0]; + get_next_token(); /* REGGROUP */ + if (curtok != '(') + return yasm_operand_create_reg(reg); + get_next_token(); /* '(' */ + if (!expect(INTNUM)) { + yasm_error_set(YASM_ERROR_SYNTAX, + N_("integer register index expected")); + return NULL; + } + regindex = yasm_intnum_get_uint(INTNUM_val); + get_next_token(); /* INTNUM */ + if (!expect(')')) { + yasm_error_set(YASM_ERROR_SYNTAX, + N_("missing closing parenthesis for register index")); + return NULL; + } + get_next_token(); /* ')' */ + reg = yasm_arch_reggroup_get_reg(p_object->arch, reg, regindex); + if (reg == 0) { + yasm_error_set(YASM_ERROR_SYNTAX, N_("bad register index `%u'"), + regindex); + return NULL; + } + return yasm_operand_create_reg(reg); + } + case '$': + { + yasm_expr *e; + get_next_token(); /* '$' */ + e = parse_expr(parser_gas); + if (!e) { + yasm_error_set(YASM_ERROR_SYNTAX, + N_("expression missing after `%s'"), "$"); + return NULL; + } + return yasm_operand_create_imm(e); + } + case '*': + get_next_token(); /* '*' */ + if (curtok == REG) { + op = yasm_operand_create_reg(REG_val[0]); + get_next_token(); /* REG */ + } else { + ea = parse_memaddr(parser_gas); + if (!ea) { + yasm_error_set(YASM_ERROR_SYNTAX, + N_("expression missing after `%s'"), "*"); + return NULL; + } + op = yasm_operand_create_mem(ea); + } + op->deref = 1; + return op; + default: + ea = parse_memaddr(parser_gas); + if (!ea) + return NULL; + return yasm_operand_create_mem(ea); } } @@ -1337,21 +1088,21 @@ parse_expr(yasm_parser_gas *parser_gas) yasm_expr *e, *f; e = parse_expr0(parser_gas); if (!e) - return NULL; + return NULL; while (curtok == '+' || curtok == '-') { - int op = curtok; - get_next_token(); - f = parse_expr0(parser_gas); - if (!f) { - yasm_expr_destroy(e); - return NULL; - } + int op = curtok; + get_next_token(); + f = parse_expr0(parser_gas); + if (!f) { + yasm_expr_destroy(e); + return NULL; + } - switch (op) { - case '+': e = p_expr_new_tree(e, YASM_EXPR_ADD, f); break; - case '-': e = p_expr_new_tree(e, YASM_EXPR_SUB, f); break; - } + switch (op) { + case '+': e = p_expr_new_tree(e, YASM_EXPR_ADD, f); break; + case '-': e = p_expr_new_tree(e, YASM_EXPR_SUB, f); break; + } } return e; } @@ -1362,23 +1113,23 @@ parse_expr0(yasm_parser_gas *parser_gas) yasm_expr *e, *f; e = parse_expr1(parser_gas); if (!e) - return NULL; + return NULL; while (curtok == '|' || curtok == '^' || curtok == '&' || curtok == '!') { - int op = curtok; - get_next_token(); - f = parse_expr1(parser_gas); - if (!f) { - yasm_expr_destroy(e); - return NULL; - } + int op = curtok; + get_next_token(); + f = parse_expr1(parser_gas); + if (!f) { + yasm_expr_destroy(e); + return NULL; + } - switch (op) { - case '|': e = p_expr_new_tree(e, YASM_EXPR_OR, f); break; - case '^': e = p_expr_new_tree(e, YASM_EXPR_XOR, f); break; - case '&': e = p_expr_new_tree(e, YASM_EXPR_AND, f); break; - case '!': e = p_expr_new_tree(e, YASM_EXPR_NOR, f); break; - } + switch (op) { + case '|': e = p_expr_new_tree(e, YASM_EXPR_OR, f); break; + case '^': e = p_expr_new_tree(e, YASM_EXPR_XOR, f); break; + case '&': e = p_expr_new_tree(e, YASM_EXPR_AND, f); break; + case '!': e = p_expr_new_tree(e, YASM_EXPR_NOR, f); break; + } } return e; } @@ -1389,25 +1140,25 @@ parse_expr1(yasm_parser_gas *parser_gas) yasm_expr *e, *f; e = parse_expr2(parser_gas); if (!e) - return NULL; + return NULL; while (curtok == '*' || curtok == '/' || curtok == '%' || curtok == LEFT_OP - || curtok == RIGHT_OP) { - int op = curtok; - get_next_token(); - f = parse_expr2(parser_gas); - if (!f) { - yasm_expr_destroy(e); - return NULL; - } + || curtok == RIGHT_OP) { + int op = curtok; + get_next_token(); + f = parse_expr2(parser_gas); + if (!f) { + yasm_expr_destroy(e); + return NULL; + } - switch (op) { - case '*': e = p_expr_new_tree(e, YASM_EXPR_MUL, f); break; - case '/': e = p_expr_new_tree(e, YASM_EXPR_DIV, f); break; - case '%': e = p_expr_new_tree(e, YASM_EXPR_MOD, f); break; - case LEFT_OP: e = p_expr_new_tree(e, YASM_EXPR_SHL, f); break; - case RIGHT_OP: e = p_expr_new_tree(e, YASM_EXPR_SHR, f); break; - } + switch (op) { + case '*': e = p_expr_new_tree(e, YASM_EXPR_MUL, f); break; + case '/': e = p_expr_new_tree(e, YASM_EXPR_DIV, f); break; + case '%': e = p_expr_new_tree(e, YASM_EXPR_MOD, f); break; + case LEFT_OP: e = p_expr_new_tree(e, YASM_EXPR_SHL, f); break; + case RIGHT_OP: e = p_expr_new_tree(e, YASM_EXPR_SHR, f); break; + } } return e; } @@ -1419,78 +1170,72 @@ parse_expr2(yasm_parser_gas *parser_gas) yasm_symrec *sym; switch (curtok) { - case '+': - get_next_token(); - return parse_expr2(parser_gas); - case '-': - get_next_token(); - e = parse_expr2(parser_gas); - if (!e) - return NULL; - return p_expr_new_branch(YASM_EXPR_NEG, e); - case '~': - get_next_token(); - e = parse_expr2(parser_gas); - if (!e) - return NULL; - return p_expr_new_branch(YASM_EXPR_NOT, e); - case '(': - get_next_token(); - e = parse_expr(parser_gas); - if (!e) - return NULL; - if (!expect(')')) { - yasm_error_set(YASM_ERROR_SYNTAX, N_("missing parenthesis")); - return NULL; - } - get_next_token(); - return e; - case INTNUM: - e = p_expr_new_ident(yasm_expr_int(INTNUM_val)); - get_next_token(); - return e; - case FLTNUM: - e = p_expr_new_ident(yasm_expr_float(FLTNUM_val)); - get_next_token(); - return e; - case ID: - { - char *name = ID_val; - get_next_token(); /* ID */ + case '+': + get_next_token(); + return parse_expr2(parser_gas); + case '-': + get_next_token(); + e = parse_expr2(parser_gas); + if (!e) + return NULL; + return p_expr_new_branch(YASM_EXPR_NEG, e); + case '~': + get_next_token(); + e = parse_expr2(parser_gas); + if (!e) + return NULL; + return p_expr_new_branch(YASM_EXPR_NOT, e); + case '(': + get_next_token(); + e = parse_expr(parser_gas); + if (!e) + return NULL; + if (!expect(')')) { + yasm_error_set(YASM_ERROR_SYNTAX, N_("missing parenthesis")); + return NULL; + } + get_next_token(); + return e; + case INTNUM: + e = p_expr_new_ident(yasm_expr_int(INTNUM_val)); + get_next_token(); + return e; + case FLTNUM: + e = p_expr_new_ident(yasm_expr_float(FLTNUM_val)); + get_next_token(); + return e; + case ID: + case DIR_SECTNAME: + { + char *name = ID_val; + get_next_token(); /* ID */ + if (curtok == '@') { + /* TODO: this is needed for shared objects, e.g. sym@PLT */ + get_next_token(); /* '@' */ + if (!expect(ID)) { + yasm_error_set(YASM_ERROR_SYNTAX, + N_("expected identifier after `@'")); + yasm_xfree(name); + return NULL; + } + yasm_xfree(ID_val); + get_next_token(); /* ID */ + sym = yasm_symtab_use(p_symtab, name, cur_line); + yasm_xfree(name); + return p_expr_new_ident(yasm_expr_sym(sym)); + } - /* "." references the current assembly position */ - if (name[1] == '\0' && name[0] == '.') - sym = yasm_symtab_define_curpos(p_symtab, ".", - parser_gas->prev_bc, cur_line); - else - sym = yasm_symtab_use(p_symtab, name, cur_line); - yasm_xfree(name); - - if (curtok == '@') { - yasm_symrec *wrt; - /* TODO: this is needed for shared objects, e.g. sym@PLT */ - get_next_token(); /* '@' */ - if (!expect(ID)) { - yasm_error_set(YASM_ERROR_SYNTAX, - N_("expected identifier after `@'")); - return NULL; - } - wrt = yasm_objfmt_get_special_sym(p_object, ID_val, "gas"); - yasm_xfree(ID_val); - get_next_token(); /* ID */ - if (!wrt) { - yasm_warn_set(YASM_WARN_GENERAL, - N_("unrecognized identifier after `@'")); - return p_expr_new_ident(yasm_expr_sym(sym)); - } - return p_expr_new(yasm_expr_sym(sym), YASM_EXPR_WRT, - yasm_expr_sym(wrt)); - } - - return p_expr_new_ident(yasm_expr_sym(sym)); - } - default: - return NULL; + /* "." references the current assembly position */ + if (name[1] == '\0' && name[0] == '.') + sym = yasm_symtab_define_curpos(p_symtab, ".", + parser_gas->prev_bc, cur_line); + else + sym = yasm_symtab_use(p_symtab, name, cur_line); + yasm_xfree(name); + return p_expr_new_ident(yasm_expr_sym(sym)); + } + default: + return NULL; } } @@ -1498,44 +1243,44 @@ static void define_label(yasm_parser_gas *parser_gas, char *name, int local) { if (!local) { - if (parser_gas->locallabel_base) - yasm_xfree(parser_gas->locallabel_base); - parser_gas->locallabel_base_len = strlen(name); - parser_gas->locallabel_base = - yasm_xmalloc(parser_gas->locallabel_base_len+1); - strcpy(parser_gas->locallabel_base, name); + if (parser_gas->locallabel_base) + yasm_xfree(parser_gas->locallabel_base); + parser_gas->locallabel_base_len = strlen(name); + parser_gas->locallabel_base = + yasm_xmalloc(parser_gas->locallabel_base_len+1); + strcpy(parser_gas->locallabel_base, name); } yasm_symtab_define_label(p_symtab, name, parser_gas->prev_bc, 1, - cur_line); + cur_line); yasm_xfree(name); } static void define_lcomm(yasm_parser_gas *parser_gas, /*@only@*/ char *name, - yasm_expr *size, /*@null@*/ yasm_expr *align) + yasm_expr *size, /*@null@*/ yasm_expr *align) { /* Put into .bss section. */ /*@dependent@*/ yasm_section *bss = - gas_get_section(parser_gas, yasm__xstrdup(".bss"), NULL, NULL, NULL, 1); + gas_get_section(parser_gas, yasm__xstrdup(".bss"), NULL, NULL, NULL, 1); if (align) { - /* XXX: assume alignment is in bytes, not power-of-two */ - yasm_section_bcs_append(bss, gas_parser_align(parser_gas, bss, align, - NULL, NULL, 0)); + /* XXX: assume alignment is in bytes, not power-of-two */ + yasm_section_bcs_append(bss, gas_parser_align(parser_gas, bss, align, + NULL, NULL, 0)); } yasm_symtab_define_label(p_symtab, name, yasm_section_bcs_last(bss), 1, - cur_line); + cur_line); yasm_section_bcs_append(bss, yasm_bc_create_reserve(size, 1, cur_line)); yasm_xfree(name); } static yasm_section * gas_get_section(yasm_parser_gas *parser_gas, char *name, - /*@null@*/ char *flags, /*@null@*/ char *type, - /*@null@*/ yasm_valparamhead *objext_valparams, - int builtin) + /*@null@*/ char *flags, /*@null@*/ char *type, + /*@null@*/ yasm_valparamhead *objext_valparams, + int builtin) { yasm_valparamhead vps; yasm_valparam *vp; @@ -1552,100 +1297,102 @@ gas_get_section(yasm_parser_gas *parser_gas, char *name, else gasflags = yasm__xstrdup(""); vp = yasm_vp_create_string(yasm__xstrdup("gasflags"), gasflags); - yasm_vps_append(&vps, vp); - if (type) { + yasm_vps_append(&vps, vp); + if (type) { vp = yasm_vp_create_id(NULL, type, '\0'); - yasm_vps_append(&vps, vp); - } + yasm_vps_append(&vps, vp); + } } new_section = yasm_objfmt_section_switch(p_object, &vps, objext_valparams, - cur_line); + cur_line); yasm_vps_delete(&vps); return new_section; } static void -gas_switch_section(yasm_parser_gas *parser_gas, const char *name, - /*@null@*/ char *flags, /*@null@*/ char *type, - /*@null@*/ yasm_valparamhead *objext_valparams, - int builtin) +gas_switch_section(yasm_parser_gas *parser_gas, char *name, + /*@null@*/ char *flags, /*@null@*/ char *type, + /*@null@*/ yasm_valparamhead *objext_valparams, + int builtin) { yasm_section *new_section; new_section = gas_get_section(parser_gas, yasm__xstrdup(name), flags, type, - objext_valparams, builtin); + objext_valparams, builtin); if (new_section) { - cursect = new_section; - parser_gas->prev_bc = yasm_section_bcs_last(new_section); + cursect = new_section; + parser_gas->prev_bc = yasm_section_bcs_last(new_section); } else - yasm_error_set(YASM_ERROR_GENERAL, N_("invalid section name `%s'"), - name); + yasm_error_set(YASM_ERROR_GENERAL, N_("invalid section name `%s'"), + name); + + yasm_xfree(name); if (objext_valparams) - yasm_vps_delete(objext_valparams); + yasm_vps_delete(objext_valparams); } static yasm_bytecode * gas_parser_align(yasm_parser_gas *parser_gas, yasm_section *sect, - yasm_expr *boundval, /*@null@*/ yasm_expr *fillval, - /*@null@*/ yasm_expr *maxskipval, int power2) + yasm_expr *boundval, /*@null@*/ yasm_expr *fillval, + /*@null@*/ yasm_expr *maxskipval, int power2) { yasm_intnum *boundintn; /* Convert power of two to number of bytes if necessary */ if (power2) - boundval = yasm_expr_create(YASM_EXPR_SHL, - yasm_expr_int(yasm_intnum_create_uint(1)), - yasm_expr_expr(boundval), cur_line); + boundval = yasm_expr_create(YASM_EXPR_SHL, + yasm_expr_int(yasm_intnum_create_uint(1)), + yasm_expr_expr(boundval), cur_line); /* Largest .align in the section specifies section alignment. */ boundintn = yasm_expr_get_intnum(&boundval, 0); if (boundintn) { - unsigned long boundint = yasm_intnum_get_uint(boundintn); + unsigned long boundint = yasm_intnum_get_uint(boundintn); - /* Alignments must be a power of two. */ - if (is_exp2(boundint)) { - if (boundint > yasm_section_get_align(sect)) - yasm_section_set_align(sect, boundint, cur_line); - } + /* Alignments must be a power of two. */ + if (is_exp2(boundint)) { + if (boundint > yasm_section_get_align(sect)) + yasm_section_set_align(sect, boundint, cur_line); + } } return yasm_bc_create_align(boundval, fillval, maxskipval, - yasm_section_is_code(sect) ? - yasm_arch_get_fill(p_object->arch) : NULL, - cur_line); + yasm_section_is_code(sect) ? + yasm_arch_get_fill(p_object->arch) : NULL, + cur_line); } static yasm_bytecode * gas_parser_dir_fill(yasm_parser_gas *parser_gas, /*@only@*/ yasm_expr *repeat, - /*@only@*/ /*@null@*/ yasm_expr *size, - /*@only@*/ /*@null@*/ yasm_expr *value) + /*@only@*/ /*@null@*/ yasm_expr *size, + /*@only@*/ /*@null@*/ yasm_expr *value) { yasm_datavalhead dvs; yasm_bytecode *bc; unsigned int ssize; if (size) { - /*@dependent@*/ /*@null@*/ yasm_intnum *intn; - intn = yasm_expr_get_intnum(&size, 0); - if (!intn) { - yasm_error_set(YASM_ERROR_NOT_ABSOLUTE, - N_("size must be an absolute expression")); - yasm_expr_destroy(repeat); - yasm_expr_destroy(size); - if (value) - yasm_expr_destroy(value); - return NULL; - } - ssize = yasm_intnum_get_uint(intn); + /*@dependent@*/ /*@null@*/ yasm_intnum *intn; + intn = yasm_expr_get_intnum(&size, 0); + if (!intn) { + yasm_error_set(YASM_ERROR_NOT_ABSOLUTE, + N_("size must be an absolute expression")); + yasm_expr_destroy(repeat); + yasm_expr_destroy(size); + if (value) + yasm_expr_destroy(value); + return NULL; + } + ssize = yasm_intnum_get_uint(intn); } else - ssize = 1; + ssize = 1; if (!value) - value = yasm_expr_create_ident( - yasm_expr_int(yasm_intnum_create_uint(0)), cur_line); + value = yasm_expr_create_ident( + yasm_expr_int(yasm_intnum_create_uint(0)), cur_line); yasm_dvs_initialize(&dvs); yasm_dvs_append(&dvs, yasm_dv_create_expr(value)); @@ -1655,112 +1402,26 @@ gas_parser_dir_fill(yasm_parser_gas *parser_gas, /*@only@*/ yasm_expr *repeat, return bc; } - -static dir_lookup dirs_static[] = { - /* FIXME: Whether this is power-of-two or not depends on arch and objfmt. */ - {".align", dir_align, 0, INITIAL}, - {".p2align", dir_align, 1, INITIAL}, - {".balign", dir_align, 0, INITIAL}, - {".org", dir_org, 0, INITIAL}, - /* data visibility directives */ - {".local", dir_local, 0, INITIAL}, - {".comm", dir_comm, 0, INITIAL}, - {".lcomm", dir_comm, 1, INITIAL}, - /* integer data declaration directives */ - {".byte", dir_data, 1, INITIAL}, - {".2byte", dir_data, 2, INITIAL}, - {".4byte", dir_data, 4, INITIAL}, - {".8byte", dir_data, 8, INITIAL}, - {".16byte", dir_data, 16, INITIAL}, - /* TODO: These should depend on arch */ - {".short", dir_data, 2, INITIAL}, - {".int", dir_data, 4, INITIAL}, - {".long", dir_data, 4, INITIAL}, - {".hword", dir_data, 2, INITIAL}, - {".quad", dir_data, 8, INITIAL}, - {".octa", dir_data, 16, INITIAL}, - /* XXX: At least on x86, this is 2 bytes */ - {".value", dir_data, 2, INITIAL}, - /* ASCII data declaration directives */ - {".ascii", dir_ascii, 0, INITIAL}, /* no terminating zero */ - {".asciz", dir_ascii, 1, INITIAL}, /* add terminating zero */ - {".string", dir_ascii, 1, INITIAL}, /* add terminating zero */ - /* LEB128 integer data declaration directives */ - {".sleb128", dir_leb128, 1, INITIAL}, /* signed */ - {".uleb128", dir_leb128, 0, INITIAL}, /* unsigned */ - /* floating point data declaration directives */ - {".float", dir_data, 4, INITIAL}, - {".single", dir_data, 4, INITIAL}, - {".double", dir_data, 8, INITIAL}, - {".tfloat", dir_data, 10, INITIAL}, - /* section directives */ - {".bss", dir_bss_section, 0, INITIAL}, - {".data", dir_data_section, 0, INITIAL}, - {".text", dir_text_section, 0, INITIAL}, - {".section", dir_section, 0, SECTION_DIRECTIVE}, - /* empty space/fill directives */ - {".skip", dir_skip, 0, INITIAL}, - {".space", dir_skip, 0, INITIAL}, - {".fill", dir_fill, 0, INITIAL}, - {".zero", dir_zero, 0, INITIAL}, - /* syntax directives */ - {".intel_syntax", dir_intel_syntax, 0, INITIAL}, - {".att_syntax", dir_att_syntax, 0, INITIAL}, - /* other directives */ - {".equ", dir_equ, 0, INITIAL}, - {".file", dir_file, 0, INITIAL}, - {".line", dir_line, 0, INITIAL}, - {".set", dir_equ, 0, INITIAL} -}; - +#if 0 static void -no_delete(void *data) +gas_parser_directive(yasm_parser_gas *parser_gas, const char *name, + yasm_valparamhead *valparams, + yasm_valparamhead *objext_valparams) { -} + unsigned long line = cur_line; -void -gas_parser_parse(yasm_parser_gas *parser_gas) -{ - dir_lookup word; - unsigned int i; - int replace = 1; - - word.name = ".word"; - word.handler = dir_data; - word.param = yasm_arch_wordsize(p_object->arch)/8; - word.newstate = INITIAL; - - /* Create directive lookup */ - parser_gas->dirs = HAMT_create(1, yasm_internal_error_); - HAMT_insert(parser_gas->dirs, word.name, &word, &replace, no_delete); - for (i=0; idirs, dirs_static[i].name, - &dirs_static[i], &replace, no_delete); + /* Handle (mostly) output-format independent directives here */ + if (!yasm_arch_parse_directive(p_object->arch, name, valparams, + objext_valparams, parser_gas->object, line)) { + ; + } else if (yasm_objfmt_directive(p_object, name, valparams, + objext_valparams, line)) { + yasm_error_set(YASM_ERROR_GENERAL, N_("unrecognized directive [%s]"), + name); } - while (get_next_token() != 0) { - yasm_bytecode *bc = NULL, *temp_bc; - - if (!is_eol()) { - bc = parse_line(parser_gas); - demand_eol(); - } - - yasm_errwarn_propagate(parser_gas->errwarns, cur_line); - - temp_bc = yasm_section_bcs_append(cursect, bc); - if (temp_bc) - parser_gas->prev_bc = temp_bc; - if (curtok == ';') - continue; /* don't advance line number until \n */ - if (parser_gas->save_input) - yasm_linemap_add_source(parser_gas->linemap, - temp_bc, - (char *)parser_gas->save_line[parser_gas->save_last ^ 1]); - yasm_linemap_goto_next(parser_gas->linemap); - parser_gas->dir_line++; /* keep track for .line followed by .file */ - } - - HAMT_destroy(parser_gas->dirs, no_delete); + yasm_vps_delete(valparams); + if (objext_valparams) + yasm_vps_delete(objext_valparams); } +#endif diff --git a/modules/parsers/gas/gas-parser.c b/modules/parsers/gas/gas-parser.c index 088bcdad..a4a6ebda 100644 --- a/modules/parsers/gas/gas-parser.c +++ b/modules/parsers/gas/gas-parser.c @@ -28,30 +28,32 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include +/*@unused@*/ RCSID("$Id$"); +#define YASM_LIB_INTERNAL #include #include "gas-parser.h" static void -gas_parser_do_parse(yasm_object *object, yasm_preproc *pp, - int save_input, yasm_linemap *linemap, - yasm_errwarns *errwarns) +gas_parser_do_parse(yasm_object *object, yasm_preproc *pp, FILE *f, + int save_input, yasm_linemap *linemap, + yasm_errwarns *errwarns) { yasm_parser_gas parser_gas; - int i; parser_gas.object = object; parser_gas.linemap = linemap; + parser_gas.in = f; + parser_gas.locallabel_base = (char *)NULL; parser_gas.locallabel_base_len = 0; parser_gas.dir_fileline = 0; parser_gas.dir_file = NULL; parser_gas.dir_line = 0; - parser_gas.seen_line_marker = 0; parser_gas.preproc = pp; parser_gas.errwarns = errwarns; @@ -63,43 +65,42 @@ gas_parser_do_parse(yasm_object *object, yasm_preproc *pp, parser_gas.peek_token = NONE; - parser_gas.line = NULL; - /* initialize scanner structure */ yasm_scanner_initialize(&parser_gas.s); parser_gas.state = INITIAL; - for (i=0; i<10; i++) - parser_gas.local[i] = 0; + parser_gas.rept = NULL; - parser_gas.intel_syntax = 0; - - parser_gas.is_cpp_preproc = - yasm__strcasecmp(((yasm_preproc_base*)pp)->module->keyword, "cpp") == 0; - parser_gas.is_nasm_preproc = - yasm__strcasecmp(((yasm_preproc_base*)pp)->module->keyword, "nasm") == 0; + /* yacc debugging, needs YYDEBUG set in bison.y.in to work */ + parser_gas.debug = 1; gas_parser_parse(&parser_gas); + /* Check for ending inside a rept */ + if (parser_gas.rept) { + yasm_error_set(YASM_ERROR_SYNTAX, N_("rept without matching endr")); + yasm_errwarn_propagate(errwarns, parser_gas.rept->startline); + } + /* Check for ending inside a comment */ if (parser_gas.state == COMMENT) { - yasm_warn_set(YASM_WARN_GENERAL, N_("end of file in comment")); - /* XXX: Minus two to compensate for already having moved past the EOF - * in the linemap. - */ - yasm_errwarn_propagate(errwarns, - yasm_linemap_get_current(parser_gas.linemap)-2); + yasm_warn_set(YASM_WARN_GENERAL, N_("end of file in comment")); + /* XXX: Minus two to compensate for already having moved past the EOF + * in the linemap. + */ + yasm_errwarn_propagate(errwarns, + yasm_linemap_get_current(parser_gas.linemap)-2); } yasm_scanner_delete(&parser_gas.s); /* Free locallabel base if necessary */ if (parser_gas.locallabel_base) - yasm_xfree(parser_gas.locallabel_base); + yasm_xfree(parser_gas.locallabel_base); if (parser_gas.dir_file) - yasm_xfree(parser_gas.dir_file); + yasm_xfree(parser_gas.dir_file); /* Convert all undefined symbols into extern symbols */ yasm_symtab_parser_finalize(object->symtab, 1, errwarns); @@ -107,10 +108,7 @@ gas_parser_do_parse(yasm_object *object, yasm_preproc *pp, /* Define valid preprocessors to use with this parser */ static const char *gas_parser_preproc_keywords[] = { - "gas", "raw", - "cpp", - "nasm", NULL }; @@ -119,15 +117,13 @@ yasm_parser_module yasm_gas_LTX_parser = { "GNU AS (GAS)-compatible parser", "gas", gas_parser_preproc_keywords, - "gas", - NULL, /* No standard macros */ + "raw", gas_parser_do_parse }; yasm_parser_module yasm_gnu_LTX_parser = { "GNU AS (GAS)-compatible parser", "gnu", gas_parser_preproc_keywords, - "gas", - NULL, /* No standard macros */ + "raw", gas_parser_do_parse }; diff --git a/modules/parsers/gas/gas-parser.h b/modules/parsers/gas/gas-parser.h index 99659e96..23f17412 100644 --- a/modules/parsers/gas/gas-parser.h +++ b/modules/parsers/gas/gas-parser.h @@ -1,4 +1,4 @@ -/* +/* $Id$ * GAS-compatible parser header file * * Copyright (C) 2005-2007 Peter Johnson @@ -30,7 +30,7 @@ #ifndef YASM_GAS_PARSER_H #define YASM_GAS_PARSER_H -#define YYCTYPE unsigned char +#define YYCTYPE unsigned char #define MAX_SAVED_LINE_LEN 80 @@ -38,6 +38,8 @@ enum tokentype { INTNUM = 258, FLTNUM, STRING, + INSN, + PREFIX, REG, REGGROUP, SEGREG, @@ -46,32 +48,65 @@ enum tokentype { RIGHT_OP, ID, LABEL, - CPP_LINE_MARKER, - NASM_LINE_MARKER, + LINE, + DIR_ALIGN, + DIR_ASCII, + DIR_COMM, + DIR_DATA, + DIR_ENDR, + DIR_EQU, + DIR_FILE, + DIR_FILL, + DIR_LEB128, + DIR_LINE, + DIR_LOCAL, + DIR_LCOMM, + DIR_ORG, + DIR_REPT, + DIR_SECTION, + DIR_SECTNAME, + DIR_SKIP, + DIR_ZERO, NONE }; typedef union { unsigned int int_info; + char *str_val; yasm_intnum *intn; yasm_floatnum *flt; - yasm_bytecode *bc; - uintptr_t arch_data; + uintptr_t arch_data[4]; struct { - char *contents; - size_t len; + char *contents; + size_t len; } str; } yystype; #define YYSTYPE yystype -enum gas_parser_state { - INITIAL, - COMMENT, - SECTION_DIRECTIVE, - NASM_FILENAME -}; +typedef struct gas_rept_line { + STAILQ_ENTRY(gas_rept_line) link; + YYCTYPE *data; /* line characters */ + size_t len; /* length of data */ +} gas_rept_line; + +typedef struct gas_rept { + STAILQ_HEAD(reptlinelist, gas_rept_line) lines; /* repeated lines */ + unsigned long startline; /* line number of rept directive */ + unsigned long numrept; /* number of repititions to generate */ + unsigned long numdone; /* number of repititions executed so far */ + /*@null@*/ gas_rept_line *line; /* next line to repeat */ + size_t linepos; /* position to start pulling chars from line */ + int ended; /* seen endr directive yet? */ + + YYCTYPE *oldbuf; /* saved previous fill buffer */ + size_t oldbuflen; /* previous fill buffer length */ + size_t oldbufpos; /* position in previous fill buffer */ +} gas_rept; typedef struct yasm_parser_gas { + FILE *in; + int debug; + /*@only@*/ yasm_object *object; /* last "base" label for local (.) labels */ @@ -83,9 +118,6 @@ typedef struct yasm_parser_gas { /*@null@*/ char *dir_file; unsigned long dir_line; - /* Have we seen a line marker? */ - int seen_line_marker; - /*@dependent@*/ yasm_preproc *preproc; /*@dependent@*/ yasm_errwarns *errwarns; @@ -98,63 +130,56 @@ typedef struct yasm_parser_gas { YYCTYPE save_line[2][MAX_SAVED_LINE_LEN]; int save_last; - /* Line data storage used in preproc_input(). */ - char *line, *linepos; - size_t lineleft; - yasm_scanner s; - enum gas_parser_state state; + enum { + INITIAL, + COMMENT, + SECTION_DIRECTIVE, + INSTDIR + } state; - int token; /* enum tokentype or any character */ + int token; /* enum tokentype or any character */ yystype tokval; - char tokch; /* first character of token */ + char tokch; /* first character of token */ /* one token of lookahead; used sparingly */ - int peek_token; /* NONE if none */ + int peek_token; /* NONE if none */ yystype peek_tokval; char peek_tokch; - /* Index of local labels; what's stored here is the /next/ index, - * so these are all 0 at start. - */ - unsigned long local[10]; - - /* Parser-handled directives HAMT lookup */ - HAMT *dirs; - - int intel_syntax; - - int is_nasm_preproc; - int is_cpp_preproc; + /*@null@*/ gas_rept *rept; } yasm_parser_gas; /* shorter access names to commonly used parser_gas fields */ -#define p_object (parser_gas->object) -#define p_symtab (parser_gas->object->symtab) -#define cursect (parser_gas->object->cur_section) -#define curtok (parser_gas->token) -#define curval (parser_gas->tokval) +#define p_object (parser_gas->object) +#define p_symtab (parser_gas->object->symtab) +#define cursect (parser_gas->object->cur_section) +#define curtok (parser_gas->token) +#define curval (parser_gas->tokval) -#define INTNUM_val (curval.intn) -#define FLTNUM_val (curval.flt) -#define STRING_val (curval.str) -#define REG_val (curval.arch_data) -#define REGGROUP_val (curval.arch_data) -#define SEGREG_val (curval.arch_data) -#define TARGETMOD_val (curval.arch_data) -#define ID_val (curval.str.contents) -#define ID_len (curval.str.len) -#define LABEL_val (curval.str.contents) -#define LABEL_len (curval.str.len) +#define INTNUM_val (curval.intn) +#define FLTNUM_val (curval.flt) +#define STRING_val (curval.str) +#define INSN_val (curval.arch_data) +#define PREFIX_val (curval.arch_data) +#define REG_val (curval.arch_data) +#define REGGROUP_val (curval.arch_data) +#define SEGREG_val (curval.arch_data) +#define TARGETMOD_val (curval.arch_data) +#define ID_val (curval.str_val) +#define LABEL_val (curval.str_val) +#define DIR_ALIGN_val (curval.int_info) +#define DIR_ASCII_val (curval.int_info) +#define DIR_DATA_val (curval.int_info) +#define DIR_LEB128_val (curval.int_info) +#define DIR_SECTNAME_val (curval.str_val) -#define cur_line (yasm_linemap_get_current(parser_gas->linemap)) +#define cur_line (yasm_linemap_get_current(parser_gas->linemap)) -#define p_expr_new(l,o,r) yasm_expr_create(o,l,r,cur_line) -#define p_expr_new_tree(l,o,r) yasm_expr_create_tree(l,o,r,cur_line) -#define p_expr_new_branch(o,r) yasm_expr_create_branch(o,r,cur_line) -#define p_expr_new_ident(r) yasm_expr_create_ident(r,cur_line) - -yasm_bytecode *parse_instr_intel(yasm_parser_gas *parser_gas); +#define p_expr_new(l,o,r) yasm_expr_create(o,l,r,cur_line) +#define p_expr_new_tree(l,o,r) yasm_expr_create_tree(l,o,r,cur_line) +#define p_expr_new_branch(o,r) yasm_expr_create_branch(o,r,cur_line) +#define p_expr_new_ident(r) yasm_expr_create_ident(r,cur_line) void gas_parser_parse(yasm_parser_gas *parser_gas); void gas_parser_cleanup(yasm_parser_gas *parser_gas); diff --git a/modules/parsers/gas/gas-token.re b/modules/parsers/gas/gas-token.re index 1a8673db..e2073183 100644 --- a/modules/parsers/gas/gas-token.re +++ b/modules/parsers/gas/gas-token.re @@ -28,62 +28,103 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include +RCSID("$Id$"); +#define YASM_LIB_INTERNAL #include #include "modules/parsers/gas/gas-parser.h" -#define BSIZE 8192 +#define BSIZE 8192 -#define YYCURSOR cursor -#define YYLIMIT (s->lim) -#define YYMARKER (s->ptr) -#define YYFILL(n) {cursor = fill(parser_gas, cursor);} +#define YYCURSOR cursor +#define YYLIMIT (s->lim) +#define YYMARKER (s->ptr) +#define YYFILL(n) {cursor = fill(parser_gas, cursor);} -#define RETURN(i) do {s->cur = cursor; parser_gas->tokch = s->tok[0]; \ - return i;} while (0) +#define RETURN(i) {s->cur = cursor; parser_gas->tokch = s->tok[0]; \ + return i;} -#define SCANINIT() {s->tok = cursor;} +#define SCANINIT() {s->tok = cursor;} -#define TOK ((char *)s->tok) -#define TOKLEN (size_t)(cursor-s->tok) +#define TOK ((char *)s->tok) +#define TOKLEN (size_t)(cursor-s->tok) -/* Bridge function to convert byte-oriented parser with line-oriented - * preprocessor. - */ static size_t -preproc_input(yasm_parser_gas *parser_gas, /*@out@*/ YYCTYPE *buf, - size_t max_size) +rept_input(yasm_parser_gas *parser_gas, /*@out@*/ YYCTYPE *buf, + size_t max_size) { - size_t tot=0; - while (max_size > 0) { - size_t n; + gas_rept *rept = parser_gas->rept; + size_t numleft = max_size; + YYCTYPE *bufp = buf; - if (!parser_gas->line) { - parser_gas->line = yasm_preproc_get_line(parser_gas->preproc); - if (!parser_gas->line) - return tot; /* EOF */ - parser_gas->linepos = parser_gas->line; - parser_gas->lineleft = strlen(parser_gas->line) + 1; - parser_gas->line[parser_gas->lineleft-1] = '\n'; - } - - n = parser_gas->lineleftlineleft : max_size; - strncpy((char *)buf+tot, parser_gas->linepos, n); - - if (n == parser_gas->lineleft) { - yasm_xfree(parser_gas->line); - parser_gas->line = NULL; - } else { - parser_gas->lineleft -= n; - parser_gas->linepos += n; - } - - tot += n; - max_size -= n; + /* If numrept is 0, copy out just the line end characters */ + if (rept->numrept == 0) { + /* Skip first line, which contains .line */ + rept->line = STAILQ_NEXT(rept->line, link); + if (!rept->line) { + rept->numrept = 1; + rept->numdone = 1; + } + while (rept->numrept == 0 && numleft > 0) { + *bufp++ = rept->line->data[rept->line->len-1]; + rept->line = STAILQ_NEXT(rept->line, link); + if (!rept->line) { + rept->numrept = 1; + rept->numdone = 1; + } + } } - return tot; + + /* Copy out the previous fill buffer until we're *really* done */ + if (rept->numdone == rept->numrept) { + size_t numcopy = rept->oldbuflen - rept->oldbufpos; + if (numcopy > numleft) + numcopy = numleft; + memcpy(bufp, &rept->oldbuf[rept->oldbufpos], numcopy); + numleft -= numcopy; + bufp += numcopy; + rept->oldbufpos += numcopy; + + if (rept->oldbufpos == rept->oldbuflen) { + /* Delete lines, then delete rept and clear rept state */ + gas_rept_line *cur, *next; + cur = STAILQ_FIRST(&rept->lines); + while (cur) { + next = STAILQ_NEXT(cur, link); + yasm_xfree(cur->data); + yasm_xfree(cur); + cur = next; + } + yasm_xfree(rept->oldbuf); + yasm_xfree(rept); + parser_gas->rept = NULL; + } + } + + while (numleft > 0 && rept->numdone < rept->numrept) { + /* Copy from line data to buf */ + size_t numcopy = rept->line->len - rept->linepos; + if (numcopy > numleft) + numcopy = numleft; + memcpy(bufp, &rept->line->data[rept->linepos], numcopy); + numleft -= numcopy; + bufp += numcopy; + rept->linepos += numcopy; + + /* Update locations if needed */ + if (rept->linepos == rept->line->len) { + rept->line = STAILQ_NEXT(rept->line, link); + rept->linepos = 0; + } + if (rept->line == NULL) { + rept->numdone++; + rept->line = STAILQ_FIRST(&rept->lines); + } + } + + return (max_size-numleft); } #if 0 static size_t @@ -98,42 +139,46 @@ fill(yasm_parser_gas *parser_gas, YYCTYPE *cursor) yasm_scanner *s = &parser_gas->s; int first = 0; if(!s->eof){ - size_t cnt = s->tok - s->bot; - if(cnt){ - memmove(s->bot, s->tok, (size_t)(s->lim - s->tok)); - s->tok = s->bot; - s->ptr -= cnt; - cursor -= cnt; - s->lim -= cnt; - } - if (!s->bot) - first = 1; - if((s->top - s->lim) < BSIZE){ - YYCTYPE *buf = yasm_xmalloc((size_t)(s->lim - s->bot) + BSIZE); - memcpy(buf, s->tok, (size_t)(s->lim - s->tok)); - s->tok = buf; - s->ptr = &buf[s->ptr - s->bot]; - cursor = &buf[cursor - s->bot]; - s->lim = &buf[s->lim - s->bot]; - s->top = &s->lim[BSIZE]; - if (s->bot) - yasm_xfree(s->bot); - s->bot = buf; - } - if((cnt = preproc_input(parser_gas, s->lim, BSIZE)) == 0) { - s->eof = &s->lim[cnt]; *s->eof++ = '\n'; - } - s->lim += cnt; - if (first && parser_gas->save_input) { - int i; - YYCTYPE *saveline; - parser_gas->save_last ^= 1; - saveline = parser_gas->save_line[parser_gas->save_last]; - /* save next line into cur_line */ - for (i=0; i<79 && &s->tok[i] < s->lim && s->tok[i] != '\n'; i++) - saveline[i] = s->tok[i]; - saveline[i] = '\0'; - } + size_t cnt = s->tok - s->bot; + if(cnt){ + memmove(s->bot, s->tok, (size_t)(s->lim - s->tok)); + s->tok = s->bot; + s->ptr -= cnt; + cursor -= cnt; + s->lim -= cnt; + } + if (!s->bot) + first = 1; + if((s->top - s->lim) < BSIZE){ + YYCTYPE *buf = yasm_xmalloc((size_t)(s->lim - s->bot) + BSIZE); + memcpy(buf, s->tok, (size_t)(s->lim - s->tok)); + s->tok = buf; + s->ptr = &buf[s->ptr - s->bot]; + cursor = &buf[cursor - s->bot]; + s->lim = &buf[s->lim - s->bot]; + s->top = &s->lim[BSIZE]; + if (s->bot) + yasm_xfree(s->bot); + s->bot = buf; + } + if (parser_gas->rept && parser_gas->rept->ended) { + /* Pull from rept lines instead of preproc */ + cnt = rept_input(parser_gas, s->lim, BSIZE); + } else if((cnt = yasm_preproc_input(parser_gas->preproc, + (char *)s->lim, BSIZE)) == 0) { + s->eof = &s->lim[cnt]; *s->eof++ = '\n'; + } + s->lim += cnt; + if (first && parser_gas->save_input) { + int i; + YYCTYPE *saveline; + parser_gas->save_last ^= 1; + saveline = parser_gas->save_line[parser_gas->save_last]; + /* save next line into cur_line */ + for (i=0; i<79 && &s->tok[i] < s->lim && s->tok[i] != '\n'; i++) + saveline[i] = s->tok[i]; + saveline[i] = '\0'; + } } return cursor; } @@ -150,15 +195,15 @@ save_line(yasm_parser_gas *parser_gas, YYCTYPE *cursor) /* save next line into cur_line */ if ((YYLIMIT - YYCURSOR) < 80) - YYFILL(80); + YYFILL(80); for (i=0; i<79 && &cursor[i] < s->lim && cursor[i] != '\n'; i++) - saveline[i] = cursor[i]; + saveline[i] = cursor[i]; saveline[i] = '\0'; return cursor; } /* starting size of string buffer */ -#define STRBUF_ALLOC_SIZE 128 +#define STRBUF_ALLOC_SIZE 128 /* string buffer used when parsing strings/character constants */ static YYCTYPE *strbuf = NULL; @@ -170,8 +215,8 @@ static void strbuf_append(size_t count, YYCTYPE *cursor, yasm_scanner *s, int ch) { if (count >= strbuf_size) { - strbuf = yasm_xrealloc(strbuf, strbuf_size + STRBUF_ALLOC_SIZE); - strbuf_size += STRBUF_ALLOC_SIZE; + strbuf = yasm_xrealloc(strbuf, strbuf_size + STRBUF_ALLOC_SIZE); + strbuf_size += STRBUF_ALLOC_SIZE; } strbuf[count] = ch; } @@ -191,225 +236,349 @@ strbuf_append(size_t count, YYCTYPE *cursor, yasm_scanner *s, int ch) int gas_parser_lex(YYSTYPE *lvalp, yasm_parser_gas *parser_gas) { + /*@null@*/ gas_rept *rept = parser_gas->rept; yasm_scanner *s = &parser_gas->s; YYCTYPE *cursor = s->cur; size_t count; YYCTYPE savech; + int linestart; + gas_rept_line *new_line; /* Handle one token of lookahead */ if (parser_gas->peek_token != NONE) { - int tok = parser_gas->peek_token; - *lvalp = parser_gas->peek_tokval; /* structure copy */ - parser_gas->tokch = parser_gas->peek_tokch; - parser_gas->peek_token = NONE; - return tok; + int tok = parser_gas->peek_token; + *lvalp = parser_gas->peek_tokval; /* structure copy */ + parser_gas->tokch = parser_gas->peek_tokch; + parser_gas->peek_token = NONE; + return tok; } /* Catch EOF */ if (s->eof && cursor == s->eof) - return 0; + return 0; + + /* Handle rept */ + if (rept && !rept->ended) + goto rept_directive; /* Jump to proper "exclusive" states */ switch (parser_gas->state) { - case COMMENT: - goto comment; - case SECTION_DIRECTIVE: - goto section_directive; - case NASM_FILENAME: - goto nasm_filename; - default: - break; + case COMMENT: + goto comment; + case SECTION_DIRECTIVE: + goto section_directive; + default: + break; } scan: SCANINIT(); /*!re2c - /* standard decimal integer */ - ([1-9] digit*) | "0" { - savech = s->tok[TOKLEN]; - s->tok[TOKLEN] = '\0'; - lvalp->intn = yasm_intnum_create_dec(TOK); - s->tok[TOKLEN] = savech; - RETURN(INTNUM); - } + /* standard decimal integer */ + ([1-9] digit*) | "0" { + savech = s->tok[TOKLEN]; + s->tok[TOKLEN] = '\0'; + lvalp->intn = yasm_intnum_create_dec(TOK); + s->tok[TOKLEN] = savech; + RETURN(INTNUM); + } - /* 0b10010011 - binary number */ - '0b' bindigit+ { - savech = s->tok[TOKLEN]; - s->tok[TOKLEN] = '\0'; - lvalp->intn = yasm_intnum_create_bin(TOK+2); - s->tok[TOKLEN] = savech; - RETURN(INTNUM); - } + /* 0b10010011 - binary number */ + '0b' bindigit+ { + savech = s->tok[TOKLEN]; + s->tok[TOKLEN] = '\0'; + lvalp->intn = yasm_intnum_create_bin(TOK+2); + s->tok[TOKLEN] = savech; + RETURN(INTNUM); + } - /* 0777 - octal number */ - "0" octdigit+ { - savech = s->tok[TOKLEN]; - s->tok[TOKLEN] = '\0'; - lvalp->intn = yasm_intnum_create_oct(TOK); - s->tok[TOKLEN] = savech; - RETURN(INTNUM); - } + /* 0777 - octal number */ + "0" octdigit+ { + savech = s->tok[TOKLEN]; + s->tok[TOKLEN] = '\0'; + lvalp->intn = yasm_intnum_create_oct(TOK); + s->tok[TOKLEN] = savech; + RETURN(INTNUM); + } - /* 0xAA - hexidecimal number */ - '0x' hexdigit+ { - savech = s->tok[TOKLEN]; - s->tok[TOKLEN] = '\0'; - /* skip 0 and x */ - lvalp->intn = yasm_intnum_create_hex(TOK+2); - s->tok[TOKLEN] = savech; - RETURN(INTNUM); - } + /* 0xAA - hexidecimal number */ + '0x' hexdigit+ { + savech = s->tok[TOKLEN]; + s->tok[TOKLEN] = '\0'; + /* skip 0 and x */ + lvalp->intn = yasm_intnum_create_hex(TOK+2); + s->tok[TOKLEN] = savech; + RETURN(INTNUM); + } - /* floating point value */ - [-+]? digit* "." digit+ ('e' [-+]? digit+)? { - savech = s->tok[TOKLEN]; - s->tok[TOKLEN] = '\0'; - lvalp->flt = yasm_floatnum_create(TOK); - s->tok[TOKLEN] = savech; - RETURN(FLTNUM); - } - [-+]? digit+ "." digit* ('e' [-+]? digit+)? { - savech = s->tok[TOKLEN]; - s->tok[TOKLEN] = '\0'; - lvalp->flt = yasm_floatnum_create(TOK); - s->tok[TOKLEN] = savech; - RETURN(FLTNUM); - } - "0" [DdEeFfTt] [-+]? digit* ("." digit*)? ('e' [-+]? digit+)? { - savech = s->tok[TOKLEN]; - s->tok[TOKLEN] = '\0'; - lvalp->flt = yasm_floatnum_create(TOK+2); - s->tok[TOKLEN] = savech; - RETURN(FLTNUM); - } + /* floating point value */ + "0" [DdEeFfTt] [-+]? (digit+)? ("." digit*)? ('e' [-+]? digit+)? { + savech = s->tok[TOKLEN]; + s->tok[TOKLEN] = '\0'; + lvalp->flt = yasm_floatnum_create(TOK+2); + s->tok[TOKLEN] = savech; + RETURN(FLTNUM); + } - /* character constant values */ - ['] { - goto charconst; - } + /* character constant values */ + ['] { + goto charconst; + } - /* string constant values */ - dquot { - goto stringconst; - } + /* string constant values */ + dquot { + goto stringconst; + } - /* operators */ - "<<" { RETURN(LEFT_OP); } - ">>" { RETURN(RIGHT_OP); } - "<" { RETURN(LEFT_OP); } - ">" { RETURN(RIGHT_OP); } - [-+|^!*&/~$():@=,] { RETURN(s->tok[0]); } - ";" { - parser_gas->state = INITIAL; - RETURN(s->tok[0]); - } + /* operators */ + "<<" { RETURN(LEFT_OP); } + ">>" { RETURN(RIGHT_OP); } + "<" { RETURN(LEFT_OP); } + ">" { RETURN(RIGHT_OP); } + [-+|^!*&/~$():@=,] { RETURN(s->tok[0]); } + ";" { + parser_gas->state = INITIAL; + RETURN(s->tok[0]); + } - /* identifier */ - [a-zA-Z_.][a-zA-Z0-9_$.]* { - lvalp->str.contents = yasm__xstrndup(TOK, TOKLEN); - lvalp->str.len = TOKLEN; - RETURN(ID); - } + /* arch-independent directives */ + /* alignment directives */ + '.align' { + /* FIXME: Whether this is power-of-two or not depends on arch and + * objfmt. + */ + lvalp->int_info = 0; + parser_gas->state = INSTDIR; RETURN(DIR_ALIGN); + } + '.p2align' { + lvalp->int_info = 1; + parser_gas->state = INSTDIR; RETURN(DIR_ALIGN); + } + '.balign' { + lvalp->int_info = 0; + parser_gas->state = INSTDIR; RETURN(DIR_ALIGN); + } + '.org' { parser_gas->state = INSTDIR; RETURN(DIR_ORG); } + /* data visibility directives */ + '.local' { parser_gas->state = INSTDIR; RETURN(DIR_LOCAL); } + '.comm' { parser_gas->state = INSTDIR; RETURN(DIR_COMM); } + '.lcomm' { parser_gas->state = INSTDIR; RETURN(DIR_LCOMM); } + /* integer data declaration directives */ + '.byte' { + lvalp->int_info = 1; + parser_gas->state = INSTDIR; RETURN(DIR_DATA); + } + '.2byte' { + lvalp->int_info = 2; + parser_gas->state = INSTDIR; RETURN(DIR_DATA); + } + '.4byte' { + lvalp->int_info = 4; + parser_gas->state = INSTDIR; RETURN(DIR_DATA); + } + '.8byte' { + lvalp->int_info = 8; + parser_gas->state = INSTDIR; RETURN(DIR_DATA); + } + '.16byte' { + lvalp->int_info = 16; + parser_gas->state = INSTDIR; RETURN(DIR_DATA); + } + '.short' { + lvalp->int_info = 2; /* TODO: This should depend on arch */ + parser_gas->state = INSTDIR; RETURN(DIR_DATA); + } + '.int' { + lvalp->int_info = 4; /* TODO: This should depend on arch */ + parser_gas->state = INSTDIR; RETURN(DIR_DATA); + } + '.long' { + lvalp->int_info = 4; /* TODO: This should depend on arch */ + parser_gas->state = INSTDIR; RETURN(DIR_DATA); + } + '.hword' { + lvalp->int_info = 2; /* TODO: This should depend on arch */ + parser_gas->state = INSTDIR; RETURN(DIR_DATA); + } + '.word' { + lvalp->int_info = yasm_arch_wordsize(p_object->arch)/8; + parser_gas->state = INSTDIR; RETURN(DIR_DATA); + } + '.quad' { + lvalp->int_info = 8; + parser_gas->state = INSTDIR; RETURN(DIR_DATA); + } + '.octa' { + lvalp->int_info = 16; + parser_gas->state = INSTDIR; RETURN(DIR_DATA); + } + '.value' { + lvalp->int_info = 2; /* XXX: At least on x86, this is 2 bytes */ + parser_gas->state = INSTDIR; RETURN(DIR_DATA); + } + /* ASCII data declaration directives */ + '.ascii' { + lvalp->int_info = 0; /* do not add terminating zero */ + parser_gas->state = INSTDIR; RETURN(DIR_ASCII); + } + '.asciz' { + lvalp->int_info = 1; /* add terminating zero */ + parser_gas->state = INSTDIR; RETURN(DIR_ASCII); + } + '.string' { + lvalp->int_info = 1; /* add terminating zero */ + parser_gas->state = INSTDIR; RETURN(DIR_ASCII); + } + /* LEB128 integer data declaration directives */ + '.sleb128' { + lvalp->int_info = 1; /* signed */ + parser_gas->state = INSTDIR; RETURN(DIR_LEB128); + } + '.uleb128' { + lvalp->int_info = 0; /* unsigned */ + parser_gas->state = INSTDIR; RETURN(DIR_LEB128); + } + /* floating point data declaration directives */ + '.float' { + lvalp->int_info = 4; + parser_gas->state = INSTDIR; RETURN(DIR_DATA); + } + '.single' { + lvalp->int_info = 4; + parser_gas->state = INSTDIR; RETURN(DIR_DATA); + } + '.double' { + lvalp->int_info = 8; + parser_gas->state = INSTDIR; RETURN(DIR_DATA); + } + '.tfloat' { + lvalp->int_info = 10; + parser_gas->state = INSTDIR; RETURN(DIR_DATA); + } + /* section directives */ + '.bss' { + lvalp->str_val = yasm__xstrdup(".bss"); + RETURN(DIR_SECTNAME); + } + '.data' { + lvalp->str_val = yasm__xstrdup(".data"); + RETURN(DIR_SECTNAME); + } + '.text' { + lvalp->str_val = yasm__xstrdup(".text"); + RETURN(DIR_SECTNAME); + } + '.section' { + parser_gas->state = SECTION_DIRECTIVE; + RETURN(DIR_SECTION); + } + /* macro directives */ + '.rept' { parser_gas->state = INSTDIR; RETURN(DIR_REPT); } + '.endr' { parser_gas->state = INSTDIR; RETURN(DIR_ENDR); } + /* empty space/fill directives */ + '.skip' { parser_gas->state = INSTDIR; RETURN(DIR_SKIP); } + '.space' { parser_gas->state = INSTDIR; RETURN(DIR_SKIP); } + '.fill' { parser_gas->state = INSTDIR; RETURN(DIR_FILL); } + '.zero' { parser_gas->state = INSTDIR; RETURN(DIR_ZERO); } + /* other directives */ + '.equ' { parser_gas->state = INSTDIR; RETURN(DIR_EQU); } + '.file' { parser_gas->state = INSTDIR; RETURN(DIR_FILE); } + '.line' { parser_gas->state = INSTDIR; RETURN(DIR_LINE); } + '.set' { parser_gas->state = INSTDIR; RETURN(DIR_EQU); } - /* identifier with @ */ - [a-zA-Z_.]([a-zA-Z0-9_$.]*[@][a-zA-Z0-9_$.]*)+ { - /* if @ not part of ID, move the scanner cursor to the first @ */ - if (!((yasm_objfmt_base *)p_object->objfmt)->module->id_at_ok) - cursor = (unsigned char *)strchr(TOK, '@'); - lvalp->str.contents = yasm__xstrndup(TOK, TOKLEN); - lvalp->str.len = TOKLEN; - RETURN(ID); - } + /* label or maybe directive */ + [_.][a-zA-Z0-9_$.]* { + lvalp->str_val = yasm__xstrndup(TOK, TOKLEN); + RETURN(ID); + } - /* register or segment register */ - [%][a-zA-Z0-9]+ { - savech = s->tok[TOKLEN]; - s->tok[TOKLEN] = '\0'; - if (parser_gas->is_nasm_preproc && strcmp(TOK+1, "line") == 0) { - s->tok[TOKLEN] = savech; - RETURN(NASM_LINE_MARKER); - } + /* register or segment register */ + [%][a-zA-Z0-9]+ { + savech = s->tok[TOKLEN]; + s->tok[TOKLEN] = '\0'; + switch (yasm_arch_parse_check_regtmod + (p_object->arch, lvalp->arch_data, TOK+1, TOKLEN-1)) { + case YASM_ARCH_REG: + s->tok[TOKLEN] = savech; + RETURN(REG); + case YASM_ARCH_REGGROUP: + s->tok[TOKLEN] = savech; + RETURN(REGGROUP); + case YASM_ARCH_SEGREG: + s->tok[TOKLEN] = savech; + RETURN(SEGREG); + default: + break; + } + yasm_error_set(YASM_ERROR_GENERAL, + N_("Unrecognized register name `%s'"), s->tok); + s->tok[TOKLEN] = savech; + lvalp->arch_data[0] = 0; + lvalp->arch_data[1] = 0; + lvalp->arch_data[2] = 0; + lvalp->arch_data[3] = 0; + RETURN(REG); + } - switch (yasm_arch_parse_check_regtmod - (p_object->arch, TOK+1, TOKLEN-1, &lvalp->arch_data)) { - case YASM_ARCH_REG: - s->tok[TOKLEN] = savech; - RETURN(REG); - case YASM_ARCH_REGGROUP: - s->tok[TOKLEN] = savech; - RETURN(REGGROUP); - case YASM_ARCH_SEGREG: - s->tok[TOKLEN] = savech; - RETURN(SEGREG); - default: - break; - } - yasm_error_set(YASM_ERROR_GENERAL, - N_("Unrecognized register name `%s'"), s->tok); - s->tok[TOKLEN] = savech; - lvalp->arch_data = 0; - RETURN(REG); - } + /* label */ + [a-zA-Z][a-zA-Z0-9_$.]* ws* ':' { + /* strip off colon and any whitespace */ + count = TOKLEN-1; + while (s->tok[count] == ' ' || s->tok[count] == '\t' + || s->tok[count] == '\r') + count--; + /* Just an identifier, return as such. */ + lvalp->str_val = yasm__xstrndup(TOK, count); + RETURN(LABEL); + } - /* local label */ - [0-9] ':' { - /* increment label index */ - parser_gas->local[s->tok[0]-'0']++; - /* build local label name */ - lvalp->str.contents = yasm_xmalloc(30); - lvalp->str.len = - sprintf(lvalp->str.contents, "L%c\001%lu", s->tok[0], - parser_gas->local[s->tok[0]-'0']); - RETURN(LABEL); - } + /* identifier that may be an instruction, etc. */ + [a-zA-Z][a-zA-Z0-9_$.]* { + /* Can only be an instruction/prefix when not inside an + * instruction or directive. + */ + if (parser_gas->state != INSTDIR) { + savech = s->tok[TOKLEN]; + s->tok[TOKLEN] = '\0'; + switch (yasm_arch_parse_check_insnprefix + (p_object->arch, lvalp->arch_data, TOK, TOKLEN)) { + case YASM_ARCH_INSN: + s->tok[TOKLEN] = savech; + parser_gas->state = INSTDIR; + RETURN(INSN); + case YASM_ARCH_PREFIX: + s->tok[TOKLEN] = savech; + RETURN(PREFIX); + default: + s->tok[TOKLEN] = savech; + } + } + /* Propagate errors in case we got a warning from the arch */ + yasm_errwarn_propagate(parser_gas->errwarns, cur_line); + /* Just an identifier, return as such. */ + lvalp->str_val = yasm__xstrndup(TOK, TOKLEN); + RETURN(ID); + } - /* local label forward reference */ - [0-9] 'f' { - /* build local label name */ - lvalp->str.contents = yasm_xmalloc(30); - lvalp->str.len = - sprintf(lvalp->str.contents, "L%c\001%lu", s->tok[0], - parser_gas->local[s->tok[0]-'0']+1); - RETURN(ID); - } + "/*" { parser_gas->state = COMMENT; goto comment; } + "#" (any \ [\n])* { goto scan; } - /* local label backward reference */ - [0-9] 'b' { - /* build local label name */ - lvalp->str.contents = yasm_xmalloc(30); - lvalp->str.len = - sprintf(lvalp->str.contents, "L%c\001%lu", s->tok[0], - parser_gas->local[s->tok[0]-'0']); - RETURN(ID); - } + ws+ { goto scan; } - "/*" { parser_gas->state = COMMENT; goto comment; } - "#" { - if (parser_gas->is_cpp_preproc) - { - RETURN(CPP_LINE_MARKER); - } else - goto line_comment; - } - "//" { goto line_comment; } + "\n" { + if (parser_gas->save_input) + cursor = save_line(parser_gas, cursor); + parser_gas->state = INITIAL; + RETURN(s->tok[0]); + } - ws+ { goto scan; } - - "\n" { - if (parser_gas->save_input) - cursor = save_line(parser_gas, cursor); - parser_gas->state = INITIAL; - RETURN(s->tok[0]); - } - - any { - yasm_warn_set(YASM_WARN_UNREC_CHAR, - N_("ignoring unrecognized character `%s'"), - yasm__conv_unprint(s->tok[0])); - goto scan; - } + any { + yasm_warn_set(YASM_WARN_UNREC_CHAR, + N_("ignoring unrecognized character `%s'"), + yasm__conv_unprint(s->tok[0])); + goto scan; + } */ /* C-style comment; nesting not supported */ @@ -417,26 +586,20 @@ comment: SCANINIT(); /*!re2c - /* End of comment */ - "*/" { parser_gas->state = INITIAL; goto scan; } + /* End of comment */ + "*/" { parser_gas->state = INITIAL; goto scan; } - "\n" { - if (parser_gas->save_input) - cursor = save_line(parser_gas, cursor); - RETURN(s->tok[0]); - } + "\n" { + if (parser_gas->save_input) + cursor = save_line(parser_gas, cursor); + RETURN(s->tok[0]); + } - any { - if (cursor == s->eof) - return 0; - goto comment; - } - */ - - /* Single line comment. */ -line_comment: - /*!re2c - (any \ [\n])* { goto scan; } + any { + if (cursor == s->eof) + return 0; + goto comment; + } */ /* .section directive (the section name portion thereof) */ @@ -444,68 +607,34 @@ section_directive: SCANINIT(); /*!re2c - [a-zA-Z0-9_$.-]+ { - lvalp->str.contents = yasm__xstrndup(TOK, TOKLEN); - lvalp->str.len = TOKLEN; - parser_gas->state = INITIAL; - RETURN(ID); - } + [a-zA-Z0-9_$.-]+ { + lvalp->str_val = yasm__xstrndup(TOK, TOKLEN); + parser_gas->state = INITIAL; + RETURN(ID); + } - dquot { goto stringconst; } + dquot { goto stringconst; } - ws+ { goto section_directive; } + ws+ { goto section_directive; } - "," { - parser_gas->state = INITIAL; - RETURN(s->tok[0]); - } + "," { + parser_gas->state = INITIAL; + RETURN(s->tok[0]); + } - "\n" { - if (parser_gas->save_input) - cursor = save_line(parser_gas, cursor); - parser_gas->state = INITIAL; - RETURN(s->tok[0]); - } + "\n" { + if (parser_gas->save_input) + cursor = save_line(parser_gas, cursor); + parser_gas->state = INITIAL; + RETURN(s->tok[0]); + } - any { - yasm_warn_set(YASM_WARN_UNREC_CHAR, - N_("ignoring unrecognized character `%s'"), - yasm__conv_unprint(s->tok[0])); - goto section_directive; - } - */ - - /* filename portion of nasm preproc %line */ -nasm_filename: - strbuf = yasm_xmalloc(STRBUF_ALLOC_SIZE); - strbuf_size = STRBUF_ALLOC_SIZE; - count = 0; - -nasm_filename_scan: - SCANINIT(); - - /*!re2c - "\n" { - strbuf_append(count++, cursor, s, '\0'); - lvalp->str.contents = (char *)strbuf; - lvalp->str.len = count; - parser_gas->state = INITIAL; - RETURN(STRING); - } - - ws+ { goto nasm_filename_scan; } - - any { - if (cursor == s->eof) { - strbuf_append(count++, cursor, s, '\0'); - lvalp->str.contents = (char *)strbuf; - lvalp->str.len = count; - parser_gas->state = INITIAL; - RETURN(STRING); - } - strbuf_append(count++, cursor, s, s->tok[0]); - goto nasm_filename_scan; - } + any { + yasm_warn_set(YASM_WARN_UNREC_CHAR, + N_("ignoring unrecognized character `%s'"), + yasm__conv_unprint(s->tok[0])); + goto section_directive; + } */ /* character constant values */ @@ -522,38 +651,139 @@ stringconst_scan: SCANINIT(); /*!re2c - /* Handle escaped character by copying both and continuing. */ - "\\". { - if (cursor == s->eof) { - yasm_error_set(YASM_ERROR_SYNTAX, - N_("unexpected end of file in string")); - lvalp->str.contents = (char *)strbuf; - lvalp->str.len = count; - RETURN(STRING); - } - strbuf_append(count++, cursor, s, '\\'); - strbuf_append(count++, cursor, s, s->tok[1]); - goto stringconst_scan; - } + /* Handle escaped double-quote by copying and continuing */ + "\\\"" { + if (cursor == s->eof) { + yasm_error_set(YASM_ERROR_SYNTAX, + N_("unexpected end of file in string")); + lvalp->str.contents = (char *)strbuf; + lvalp->str.len = count; + RETURN(STRING); + } + strbuf_append(count++, cursor, s, '"'); + goto stringconst_scan; + } - dquot { - strbuf_append(count, cursor, s, '\0'); - yasm_unescape_cstring(strbuf, &count); - lvalp->str.contents = (char *)strbuf; - lvalp->str.len = count; - RETURN(STRING); - } + dquot { + strbuf_append(count, cursor, s, '\0'); + yasm_unescape_cstring(strbuf, &count); + lvalp->str.contents = (char *)strbuf; + lvalp->str.len = count; + RETURN(STRING); + } - any { - if (cursor == s->eof) { - yasm_error_set(YASM_ERROR_SYNTAX, - N_("unexpected end of file in string")); - lvalp->str.contents = (char *)strbuf; - lvalp->str.len = count; - RETURN(STRING); - } - strbuf_append(count++, cursor, s, s->tok[0]); - goto stringconst_scan; - } + any { + if (cursor == s->eof) { + yasm_error_set(YASM_ERROR_SYNTAX, + N_("unexpected end of file in string")); + lvalp->str.contents = (char *)strbuf; + lvalp->str.len = count; + RETURN(STRING); + } + strbuf_append(count++, cursor, s, s->tok[0]); + goto stringconst_scan; + } */ + +rept_directive: + strbuf = yasm_xmalloc(STRBUF_ALLOC_SIZE); + strbuf_size = STRBUF_ALLOC_SIZE; + count = 0; + linestart = 1; + + +rept_scan: + SCANINIT(); + + /*!re2c + [\n;] { + /* Line ending, save in lines */ + new_line = yasm_xmalloc(sizeof(gas_rept_line)); + if (cursor == s->eof) { + yasm_xfree(strbuf); + return 0; + } + strbuf_append(count++, cursor, s, s->tok[0]); + new_line->data = strbuf; + new_line->len = count; + STAILQ_INSERT_TAIL(&rept->lines, new_line, link); + /* Allocate new strbuf */ + strbuf = yasm_xmalloc(STRBUF_ALLOC_SIZE); + strbuf_size = STRBUF_ALLOC_SIZE; + count = 0; + /* Mark start of line */ + linestart = 1; + goto rept_scan; + } + '.rept' { + int i; + if (linestart) { + /* We don't support nested right now, error */ + yasm_error_set(YASM_ERROR_GENERAL, + N_("nested rept not supported")); + yasm_errwarn_propagate(parser_gas->errwarns, cur_line); + } + for (i=0; i<6; i++) + strbuf_append(count++, cursor, s, s->tok[i]); + goto rept_scan; + } + '.endr' { + if (linestart) { + /* We're done, kick off the main lexer */ + rept->line = STAILQ_FIRST(&rept->lines); + if (!rept->line) { + /* Didn't get any intervening data? Empty repeat, so + * don't even bother. + */ + yasm_xfree(strbuf); + yasm_xfree(rept); + parser_gas->rept = NULL; + } else { + rept->ended = 1; + + /* Add .line as first line to get line numbers correct */ + new_line = yasm_xmalloc(sizeof(gas_rept_line)); + new_line->data = yasm_xmalloc(40); + sprintf((char *)new_line->data, ".line %lu;", + rept->startline+1); + new_line->len = strlen((char *)new_line->data); + STAILQ_INSERT_HEAD(&rept->lines, new_line, link); + + /* Save previous fill buffer */ + rept->oldbuf = parser_gas->s.bot; + rept->oldbuflen = s->lim - s->bot; + rept->oldbufpos = cursor - s->bot; + + /* Reset fill */ + s->bot = NULL; + s->tok = NULL; + s->ptr = NULL; + s->cur = NULL; + s->lim = NULL; + s->top = NULL; + s->eof = NULL; + cursor = NULL; + YYFILL(1); + } + + goto scan; + } else { + int i; + for (i=0; i<6; i++) + strbuf_append(count++, cursor, s, s->tok[i]); + goto rept_scan; + } + } + + any { + if (cursor == s->eof) { + yasm_xfree(strbuf); + return 0; + } + strbuf_append(count++, cursor, s, s->tok[0]); + linestart = 0; + goto rept_scan; + } + */ + } diff --git a/modules/parsers/gas/tests/Makefile.inc b/modules/parsers/gas/tests/Makefile.inc index c288adcf..44827334 100644 --- a/modules/parsers/gas/tests/Makefile.inc +++ b/modules/parsers/gas/tests/Makefile.inc @@ -1,3 +1,5 @@ +# $Id$ + TESTS += modules/parsers/gas/tests/gas_test.sh EXTRA_DIST += modules/parsers/gas/tests/gas_test.sh @@ -12,8 +14,6 @@ EXTRA_DIST += modules/parsers/gas/tests/execsect.asm EXTRA_DIST += modules/parsers/gas/tests/execsect.hex EXTRA_DIST += modules/parsers/gas/tests/gas-fill.asm EXTRA_DIST += modules/parsers/gas/tests/gas-fill.hex -EXTRA_DIST += modules/parsers/gas/tests/gas-float.asm -EXTRA_DIST += modules/parsers/gas/tests/gas-float.hex EXTRA_DIST += modules/parsers/gas/tests/gas-instlabel.asm EXTRA_DIST += modules/parsers/gas/tests/gas-instlabel.hex EXTRA_DIST += modules/parsers/gas/tests/gas-line-err.asm @@ -22,8 +22,6 @@ EXTRA_DIST += modules/parsers/gas/tests/gas-line2-err.asm EXTRA_DIST += modules/parsers/gas/tests/gas-line2-err.errwarn EXTRA_DIST += modules/parsers/gas/tests/gas-push.asm EXTRA_DIST += modules/parsers/gas/tests/gas-push.hex -EXTRA_DIST += modules/parsers/gas/tests/gas-segprefix.asm -EXTRA_DIST += modules/parsers/gas/tests/gas-segprefix.hex EXTRA_DIST += modules/parsers/gas/tests/gas-semi.asm EXTRA_DIST += modules/parsers/gas/tests/gas-semi.hex EXTRA_DIST += modules/parsers/gas/tests/gassectalign.asm diff --git a/modules/parsers/gas/tests/bin/Makefile.inc b/modules/parsers/gas/tests/bin/Makefile.inc index 5428d144..8132e69c 100644 --- a/modules/parsers/gas/tests/bin/Makefile.inc +++ b/modules/parsers/gas/tests/bin/Makefile.inc @@ -1,27 +1,21 @@ +# $Id$ + TESTS += modules/parsers/gas/tests/bin/gas_bin_test.sh EXTRA_DIST += modules/parsers/gas/tests/bin/gas_bin_test.sh EXTRA_DIST += modules/parsers/gas/tests/bin/gas-comment.asm EXTRA_DIST += modules/parsers/gas/tests/bin/gas-comment.errwarn EXTRA_DIST += modules/parsers/gas/tests/bin/gas-comment.hex -EXTRA_DIST += modules/parsers/gas/tests/bin/gas-intel_syntax-noprefix.asm -EXTRA_DIST += modules/parsers/gas/tests/bin/gas-intel_syntax-noprefix.hex -EXTRA_DIST += modules/parsers/gas/tests/bin/gas-llabel.asm -EXTRA_DIST += modules/parsers/gas/tests/bin/gas-llabel.hex -EXTRA_DIST += modules/parsers/gas/tests/bin/gas-macro.asm -EXTRA_DIST += modules/parsers/gas/tests/bin/gas-macro.hex EXTRA_DIST += modules/parsers/gas/tests/bin/gas-set.asm EXTRA_DIST += modules/parsers/gas/tests/bin/gas-set.hex -EXTRA_DIST += modules/parsers/gas/tests/bin/gas-str.asm -EXTRA_DIST += modules/parsers/gas/tests/bin/gas-str.hex EXTRA_DIST += modules/parsers/gas/tests/bin/rept-err.asm EXTRA_DIST += modules/parsers/gas/tests/bin/rept-err.errwarn EXTRA_DIST += modules/parsers/gas/tests/bin/reptempty.asm EXTRA_DIST += modules/parsers/gas/tests/bin/reptempty.hex EXTRA_DIST += modules/parsers/gas/tests/bin/reptlong.asm EXTRA_DIST += modules/parsers/gas/tests/bin/reptlong.hex -EXTRA_DIST += modules/parsers/gas/tests/bin/reptnested.asm -EXTRA_DIST += modules/parsers/gas/tests/bin/reptnested.hex +EXTRA_DIST += modules/parsers/gas/tests/bin/reptnested-err.asm +EXTRA_DIST += modules/parsers/gas/tests/bin/reptnested-err.errwarn EXTRA_DIST += modules/parsers/gas/tests/bin/reptsimple.asm EXTRA_DIST += modules/parsers/gas/tests/bin/reptsimple.hex EXTRA_DIST += modules/parsers/gas/tests/bin/reptwarn.asm diff --git a/modules/parsers/gas/tests/bin/gas-comment.asm b/modules/parsers/gas/tests/bin/gas-comment.asm index 0c265f7d..ee68e554 100644 --- a/modules/parsers/gas/tests/bin/gas-comment.asm +++ b/modules/parsers/gas/tests/bin/gas-comment.asm @@ -2,8 +2,6 @@ /* So is this */ -// and so is this - .byte 0 /* at end of line? */ .byte 0 /* at end of line, diff --git a/modules/parsers/gas/tests/bin/gas-comment.errwarn b/modules/parsers/gas/tests/bin/gas-comment.errwarn index 6a29a1fd..1fb55a30 100644 --- a/modules/parsers/gas/tests/bin/gas-comment.errwarn +++ b/modules/parsers/gas/tests/bin/gas-comment.errwarn @@ -1 +1 @@ --:25: warning: end of file in comment +-:23: warning: end of file in comment diff --git a/modules/parsers/gas/tests/bin/gas-intel_syntax-noprefix.asm b/modules/parsers/gas/tests/bin/gas-intel_syntax-noprefix.asm deleted file mode 100644 index 25c65076..00000000 --- a/modules/parsers/gas/tests/bin/gas-intel_syntax-noprefix.asm +++ /dev/null @@ -1,19 +0,0 @@ -.intel_syntax noprefix -.section .rodata -.LC0: -.string "Hello" -.text - lea ecx, 4 [esp] - and esp, -16 - push DWORD PTR [ecx-4] - push ebp - fstp st(0) - ffree st(1) - mov ebp, esp - push ecx - sub esp, 4 - mov DWORD PTR [esp], OFFSET FLAT:.LC0 - add esp, 4 - pop ebp - lea esp, [ecx-4] - ret diff --git a/modules/parsers/gas/tests/bin/gas-intel_syntax-noprefix.hex b/modules/parsers/gas/tests/bin/gas-intel_syntax-noprefix.hex deleted file mode 100644 index fe0fdafa..00000000 --- a/modules/parsers/gas/tests/bin/gas-intel_syntax-noprefix.hex +++ /dev/null @@ -1,58 +0,0 @@ -67 -66 -8d -4c -24 -04 -66 -83 -e4 -f0 -67 -66 -ff -71 -fc -66 -55 -dd -d8 -dd -c1 -66 -89 -e5 -66 -51 -66 -83 -ec -04 -67 -66 -c7 -04 -24 -34 -00 -00 -00 -66 -83 -c4 -04 -66 -5d -67 -66 -8d -61 -fc -c3 -00 -48 -65 -6c -6c -6f -00 diff --git a/modules/parsers/gas/tests/bin/gas-llabel.asm b/modules/parsers/gas/tests/bin/gas-llabel.asm deleted file mode 100644 index 11f3f545..00000000 --- a/modules/parsers/gas/tests/bin/gas-llabel.asm +++ /dev/null @@ -1,29 +0,0 @@ -# Skelix by Xiaoming Mo (xiaoming.mo@skelix.org) -# Licence: GPLv2 - .text - #.globl start - .code16 -start: - jmp code -msg: - .string "Hello World!\x0" -code: - movw $0xb800,%ax - movw %ax, %es - xorw %ax, %ax - movw %ax, %ds - - movw $msg, %si - xorw %di, %di - cld - movb $0x07, %al -1: - cmpw $0, (%si) - je 1f - movsb - stosb - jmp 1b -1: jmp 1b -.org 0x1fe, 0x90 -.word 0xaa55 - diff --git a/modules/parsers/gas/tests/bin/gas-llabel.hex b/modules/parsers/gas/tests/bin/gas-llabel.hex deleted file mode 100644 index 4bef5c77..00000000 --- a/modules/parsers/gas/tests/bin/gas-llabel.hex +++ /dev/null @@ -1,512 +0,0 @@ -eb -0e -48 -65 -6c -6c -6f -20 -57 -6f -72 -6c -64 -21 -00 -00 -b8 -00 -b8 -8e -c0 -31 -c0 -8e -d8 -be -02 -00 -31 -ff -fc -b0 -07 -83 -3c -00 -74 -04 -a4 -aa -eb -f7 -eb -fe -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -90 -55 -aa diff --git a/modules/parsers/gas/tests/bin/gas-macro.asm b/modules/parsers/gas/tests/bin/gas-macro.asm deleted file mode 100644 index 29b475cc..00000000 --- a/modules/parsers/gas/tests/bin/gas-macro.asm +++ /dev/null @@ -1,25 +0,0 @@ -.macro foo arg1, arg2 -.byte \arg1 -.byte \arg2 -.endm - -.macro bar x y -.byte \x-\y -.endm - -.macro def a=5 b -.byte \a + \b -.endm - -.macro nest x=9 -.macro zap y -.byte \y -.endm -zap \x -.endm - -foo 5 6 -bar 3, 2 -def ,3 -def 3 2 -nest diff --git a/modules/parsers/gas/tests/bin/gas-macro.hex b/modules/parsers/gas/tests/bin/gas-macro.hex deleted file mode 100644 index 0904d1cd..00000000 --- a/modules/parsers/gas/tests/bin/gas-macro.hex +++ /dev/null @@ -1,6 +0,0 @@ -05 -06 -01 -08 -05 -09 diff --git a/modules/parsers/gas/tests/bin/gas-set.asm b/modules/parsers/gas/tests/bin/gas-set.asm index 6bce4a2f..24f278fb 100644 --- a/modules/parsers/gas/tests/bin/gas-set.asm +++ b/modules/parsers/gas/tests/bin/gas-set.asm @@ -1,34 +1,2 @@ -.set bar,(foo-1) .set foo,5 -.byte foo /* 0x5 */ -.byte bar /* 0x4 */ -.set foo,6 -.byte foo /* 0x6 */ -.byte bar /* 0x4 */ -.set bar,10 -.byte bar /* 0xa */ -.set bar,foo+1 -.byte bar /* 0x7 */ -.set bar,bar+1 -.byte bar /* 0x8 */ -.set bar,5 -.set bam,bar-1 -.set bar,1 -.byte bam /* 0x4 */ -.set bar, boo + 1 -.set boo, 5 -.set boo, 6 -.byte bar /* 0x6 */ -.set a, b+c -.set b, 0x1 -.set b, 0x2 -.set c, 0x10 -.set c, 0x20 -.byte a /* 0x11 */ -.set x, 5 -.set y, x+z -.set x, 10 -.set z, 1 -.byte y /* 0x6 */ -.set z, 0xfe -.byte z /* 0xfe */ +.byte foo diff --git a/modules/parsers/gas/tests/bin/gas-set.hex b/modules/parsers/gas/tests/bin/gas-set.hex index c0a5bfcf..f62fa93d 100644 --- a/modules/parsers/gas/tests/bin/gas-set.hex +++ b/modules/parsers/gas/tests/bin/gas-set.hex @@ -1,12 +1 @@ 05 -04 -06 -04 -0a -07 -08 -04 -06 -11 -06 -fe diff --git a/modules/parsers/gas/tests/bin/gas-str.asm b/modules/parsers/gas/tests/bin/gas-str.asm deleted file mode 100644 index 4d02a02c..00000000 --- a/modules/parsers/gas/tests/bin/gas-str.asm +++ /dev/null @@ -1 +0,0 @@ -.string "a\\" diff --git a/modules/parsers/gas/tests/bin/gas-str.hex b/modules/parsers/gas/tests/bin/gas-str.hex deleted file mode 100644 index d4eaa859..00000000 --- a/modules/parsers/gas/tests/bin/gas-str.hex +++ /dev/null @@ -1,3 +0,0 @@ -61 -5c -00 diff --git a/modules/parsers/gas/tests/bin/gas_bin_test.sh b/modules/parsers/gas/tests/bin/gas_bin_test.sh index aa35a4e7..f0c83e9f 100755 --- a/modules/parsers/gas/tests/bin/gas_bin_test.sh +++ b/modules/parsers/gas/tests/bin/gas_bin_test.sh @@ -1,3 +1,4 @@ #! /bin/sh +# $Id$ ${srcdir}/out_test.sh gas_bin_test modules/parsers/gas/tests/bin "gas-compat parser bin output" "-f bin -p gas" "" exit $? diff --git a/modules/parsers/gas/tests/bin/rept-err.asm b/modules/parsers/gas/tests/bin/rept-err.asm index 88582f93..143e9041 100644 --- a/modules/parsers/gas/tests/bin/rept-err.asm +++ b/modules/parsers/gas/tests/bin/rept-err.asm @@ -1,4 +1,2 @@ .rept 6 -.endr -.rept 3 .byte 0 diff --git a/modules/parsers/gas/tests/bin/rept-err.errwarn b/modules/parsers/gas/tests/bin/rept-err.errwarn index 5682b14a..050398c2 100644 --- a/modules/parsers/gas/tests/bin/rept-err.errwarn +++ b/modules/parsers/gas/tests/bin/rept-err.errwarn @@ -1 +1 @@ --:3: error: rept without matching endr +-:1: rept without matching endr diff --git a/modules/parsers/gas/tests/bin/reptnested.asm b/modules/parsers/gas/tests/bin/reptnested-err.asm similarity index 69% rename from modules/parsers/gas/tests/bin/reptnested.asm rename to modules/parsers/gas/tests/bin/reptnested-err.asm index 061cae02..bb85988a 100644 --- a/modules/parsers/gas/tests/bin/reptnested.asm +++ b/modules/parsers/gas/tests/bin/reptnested-err.asm @@ -1,7 +1,7 @@ -.rept 3 +.rept 6 .byte 1 .rept 2 +.byte 2 +.endr .byte 3 .endr -.endr -.byte 5 diff --git a/modules/parsers/gas/tests/bin/reptnested-err.errwarn b/modules/parsers/gas/tests/bin/reptnested-err.errwarn new file mode 100644 index 00000000..016b13e9 --- /dev/null +++ b/modules/parsers/gas/tests/bin/reptnested-err.errwarn @@ -0,0 +1,7 @@ +-:2: nested rept not supported +-:3: rept without matching endr +-:4: nested rept not supported +-:4: nested rept not supported +-:4: nested rept not supported +-:4: nested rept not supported +-:4: nested rept not supported diff --git a/modules/parsers/gas/tests/bin/reptnested.hex b/modules/parsers/gas/tests/bin/reptnested.hex deleted file mode 100644 index 9ec32fc7..00000000 --- a/modules/parsers/gas/tests/bin/reptnested.hex +++ /dev/null @@ -1,10 +0,0 @@ -01 -03 -03 -01 -03 -03 -01 -03 -03 -05 diff --git a/modules/parsers/gas/tests/gas-float.asm b/modules/parsers/gas/tests/gas-float.asm deleted file mode 100644 index 7101eed6..00000000 --- a/modules/parsers/gas/tests/gas-float.asm +++ /dev/null @@ -1,2 +0,0 @@ -.double 0.1 -.double -.0 diff --git a/modules/parsers/gas/tests/gas-float.hex b/modules/parsers/gas/tests/gas-float.hex deleted file mode 100644 index 4daadf4c..00000000 --- a/modules/parsers/gas/tests/gas-float.hex +++ /dev/null @@ -1,376 +0,0 @@ -7f -45 -4c -46 -01 -01 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -01 -00 -03 -00 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -b0 -00 -00 -00 -00 -00 -00 -00 -34 -00 -00 -00 -00 -00 -28 -00 -05 -00 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -9a -99 -99 -99 -99 -99 -b9 -3f -00 -00 -00 -00 -00 -00 -00 -80 -00 -2e -74 -65 -78 -74 -00 -2e -73 -74 -72 -74 -61 -62 -00 -2e -73 -79 -6d -74 -61 -62 -00 -2e -73 -68 -73 -74 -72 -74 -61 -62 -00 -00 -00 -00 -00 -2d -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -04 -00 -f1 -ff -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -03 -00 -04 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -17 -00 -00 -00 -03 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -50 -00 -00 -00 -21 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -07 -00 -00 -00 -03 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -74 -00 -00 -00 -03 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -0f -00 -00 -00 -02 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -78 -00 -00 -00 -30 -00 -00 -00 -02 -00 -00 -00 -03 -00 -00 -00 -04 -00 -00 -00 -10 -00 -00 -00 -01 -00 -00 -00 -01 -00 -00 -00 -06 -00 -00 -00 -00 -00 -00 -00 -40 -00 -00 -00 -10 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -10 -00 -00 -00 -00 -00 -00 -00 diff --git a/modules/parsers/gas/tests/gas-instlabel.asm b/modules/parsers/gas/tests/gas-instlabel.asm index 22c0c00a..44c47482 100644 --- a/modules/parsers/gas/tests/gas-instlabel.asm +++ b/modules/parsers/gas/tests/gas-instlabel.asm @@ -1,6 +1,3 @@ .globl SUB .type SUB, @function SUB: - -ADD = 5 - diff --git a/modules/parsers/gas/tests/gas-line-err.errwarn b/modules/parsers/gas/tests/gas-line-err.errwarn index f08f8be8..8f92ad62 100644 --- a/modules/parsers/gas/tests/gas-line-err.errwarn +++ b/modules/parsers/gas/tests/gas-line-err.errwarn @@ -1,6 +1,6 @@ --:1: error: invalid number of operands --:3: error: invalid number of operands -bar1.s:601: error: invalid number of operands -bar1.s:201: error: invalid number of operands -bar2.s:203: error: invalid number of operands -bar2.s:205: error: invalid number of operands +-:1: invalid number of operands +-:3: invalid number of operands +bar1.s:601: invalid number of operands +bar1.s:201: invalid number of operands +bar2.s:203: invalid number of operands +bar2.s:205: invalid number of operands diff --git a/modules/parsers/gas/tests/gas-line2-err.errwarn b/modules/parsers/gas/tests/gas-line2-err.errwarn index 5cd6b05b..4cfc626f 100644 --- a/modules/parsers/gas/tests/gas-line2-err.errwarn +++ b/modules/parsers/gas/tests/gas-line2-err.errwarn @@ -1,3 +1,3 @@ --:1: error: invalid number of operands --:3: error: invalid number of operands -bar1.s:603: error: invalid number of operands +-:1: invalid number of operands +-:3: invalid number of operands +bar1.s:603: invalid number of operands diff --git a/modules/parsers/gas/tests/gas-segprefix.asm b/modules/parsers/gas/tests/gas-segprefix.asm deleted file mode 100644 index 9295b90a..00000000 --- a/modules/parsers/gas/tests/gas-segprefix.asm +++ /dev/null @@ -1,2 +0,0 @@ -.text -es pushl %ebp diff --git a/modules/parsers/gas/tests/gas-segprefix.hex b/modules/parsers/gas/tests/gas-segprefix.hex deleted file mode 100644 index 932e1ea6..00000000 --- a/modules/parsers/gas/tests/gas-segprefix.hex +++ /dev/null @@ -1,360 +0,0 @@ -7f -45 -4c -46 -01 -01 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -01 -00 -03 -00 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -a0 -00 -00 -00 -00 -00 -00 -00 -34 -00 -00 -00 -00 -00 -28 -00 -05 -00 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -26 -55 -00 -00 -00 -2e -74 -65 -78 -74 -00 -2e -73 -74 -72 -74 -61 -62 -00 -2e -73 -79 -6d -74 -61 -62 -00 -2e -73 -68 -73 -74 -72 -74 -61 -62 -00 -00 -00 -00 -00 -2d -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -01 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -04 -00 -f1 -ff -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -03 -00 -04 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -17 -00 -00 -00 -03 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -44 -00 -00 -00 -21 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -07 -00 -00 -00 -03 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -68 -00 -00 -00 -03 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -0f -00 -00 -00 -02 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -6c -00 -00 -00 -30 -00 -00 -00 -02 -00 -00 -00 -03 -00 -00 -00 -04 -00 -00 -00 -10 -00 -00 -00 -01 -00 -00 -00 -01 -00 -00 -00 -06 -00 -00 -00 -00 -00 -00 -00 -40 -00 -00 -00 -02 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -10 -00 -00 -00 -00 -00 -00 -00 diff --git a/modules/parsers/gas/tests/gas_test.sh b/modules/parsers/gas/tests/gas_test.sh index f39d4d17..bce85d3c 100755 --- a/modules/parsers/gas/tests/gas_test.sh +++ b/modules/parsers/gas/tests/gas_test.sh @@ -1,3 +1,4 @@ #! /bin/sh +# $Id$ ${srcdir}/out_test.sh gas_test modules/parsers/gas/tests "gas-compat parser" "-f elf -p gas" ".o" exit $? diff --git a/modules/parsers/gas/tests/reggroup-err.errwarn b/modules/parsers/gas/tests/reggroup-err.errwarn index 3f428a79..1b6d02b7 100644 --- a/modules/parsers/gas/tests/reggroup-err.errwarn +++ b/modules/parsers/gas/tests/reggroup-err.errwarn @@ -1 +1 @@ --:5: error: bad register index `8' +-:5: bad register index `8' diff --git a/modules/parsers/nasm/CMakeLists.txt b/modules/parsers/nasm/CMakeLists.txt deleted file mode 100644 index 9f40beb2..00000000 --- a/modules/parsers/nasm/CMakeLists.txt +++ /dev/null @@ -1,24 +0,0 @@ -YASM_GENMACRO( - ${CMAKE_CURRENT_SOURCE_DIR}/parsers/nasm/nasm-std.mac - ${CMAKE_CURRENT_BINARY_DIR}/nasm-macros.c - nasm_standard_mac - ) - -SET_SOURCE_FILES_PROPERTIES(parsers/nasm/nasm-parser.c PROPERTIES - OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/nasm-macros.c - ) - -YASM_RE2C( - ${CMAKE_CURRENT_SOURCE_DIR}/parsers/nasm/nasm-token.re - ${CMAKE_CURRENT_BINARY_DIR}/nasm-token.c - -b - ) - -YASM_ADD_MODULE(parser_nasm - parsers/nasm/nasm-parser.c - parsers/nasm/nasm-parse.c - nasm-token.c - ) - -YASM_ADD_MODULE(parser_tasm - ) diff --git a/modules/parsers/nasm/Makefile.inc b/modules/parsers/nasm/Makefile.inc index ed58bb63..9994e316 100644 --- a/modules/parsers/nasm/Makefile.inc +++ b/modules/parsers/nasm/Makefile.inc @@ -1,10 +1,11 @@ +# $Id$ + libyasm_a_SOURCES += modules/parsers/nasm/nasm-parser.c libyasm_a_SOURCES += modules/parsers/nasm/nasm-parser.h -libyasm_a_SOURCES += modules/parsers/nasm/nasm-parser-struct.h libyasm_a_SOURCES += modules/parsers/nasm/nasm-parse.c nodist_libyasm_a_SOURCES += nasm-token.c -YASM_MODULES += parser_nasm parser_tasm +YASM_MODULES += parser_nasm nasm-token.c: $(srcdir)/modules/parsers/nasm/nasm-token.re re2c$(EXEEXT) $(top_builddir)/re2c$(EXEEXT) -b -o $@ $(srcdir)/modules/parsers/nasm/nasm-token.re @@ -13,17 +14,7 @@ BUILT_SOURCES += nasm-token.c CLEANFILES += nasm-token.c +EXTRA_DIST += modules/parsers/nasm/tests/Makefile.inc EXTRA_DIST += modules/parsers/nasm/nasm-token.re -$(top_srcdir)/modules/parsers/nasm/nasm-parser.c: nasm-macros.c - -nasm-macros.c: $(srcdir)/modules/parsers/nasm/nasm-std.mac genmacro$(EXEEXT) - $(top_builddir)/genmacro$(EXEEXT) $@ nasm_standard_mac $(srcdir)/modules/parsers/nasm/nasm-std.mac - -BUILT_SOURCES += nasm-macros.c -CLEANFILES += nasm-macros.c -EXTRA_DIST += modules/parsers/nasm/nasm-std.mac - -EXTRA_DIST += modules/parsers/nasm/tests/Makefile.inc - include modules/parsers/nasm/tests/Makefile.inc diff --git a/modules/parsers/nasm/nasm-parse.c b/modules/parsers/nasm/nasm-parse.c index 680aa0e7..14ad8d09 100644 --- a/modules/parsers/nasm/nasm-parse.c +++ b/modules/parsers/nasm/nasm-parse.c @@ -25,28 +25,32 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include +RCSID("$Id$"); +#define YASM_LIB_INTERNAL +#define YASM_EXPR_INTERNAL #include -#include +#ifdef STDC_HEADERS +# include +#endif #include "modules/parsers/nasm/nasm-parser.h" -#include "modules/preprocs/nasm/nasm.h" typedef enum { NORM_EXPR, - DIR_EXPR, /* Can't have seg:off or WRT anywhere */ - DV_EXPR /* Can't have registers anywhere */ + DIR_EXPR, + DV_EXPR } expr_type; static yasm_bytecode *parse_line(yasm_parser_nasm *parser_nasm); static int parse_directive_valparams(yasm_parser_nasm *parser_nasm, - /*@out@*/ yasm_valparamhead *vps); + /*@out@*/ yasm_valparamhead *vps); static yasm_bytecode *parse_times(yasm_parser_nasm *parser_nasm); static yasm_bytecode *parse_exp(yasm_parser_nasm *parser_nasm); static yasm_bytecode *parse_instr(yasm_parser_nasm *parser_nasm); static yasm_insn_operand *parse_operand(yasm_parser_nasm *parser_nasm); -static yasm_insn_operand *parse_memaddr(yasm_parser_nasm *parser_nasm); +static yasm_effaddr *parse_memaddr(yasm_parser_nasm *parser_nasm); static yasm_expr *parse_expr(yasm_parser_nasm *parser_nasm, expr_type type); static yasm_expr *parse_bexpr(yasm_parser_nasm *parser_nasm, expr_type type); static yasm_expr *parse_expr0(yasm_parser_nasm *parser_nasm, expr_type type); @@ -61,28 +65,11 @@ static void nasm_parser_directive (yasm_parser_nasm *parser_nasm, const char *name, /*@null@*/ yasm_valparamhead *valparams, /*@null@*/ yasm_valparamhead *objext_valparams); -static void set_nonlocal_label(yasm_parser_nasm *parser_nasm, const char *name); static void define_label(yasm_parser_nasm *parser_nasm, /*@only@*/ char *name, - unsigned int size); + int local); -static void yasm_ea_set_implicit_size_segment(yasm_parser_nasm *parser_nasm, - yasm_effaddr *ea, yasm_expr *e) -{ - if (parser_nasm->tasm) { - const char *segment = yasm_expr_segment(e); - ea->data_len = yasm_expr_size(e); - if (segment) { - const char *segreg = tasm_get_segment_register(segment); - if (segreg) - yasm_arch_parse_check_regtmod(p_object->arch, segreg, - strlen(segreg), &ea->segreg); - } - } -} - - -#define is_eol_tok(tok) ((tok) == 0) -#define is_eol() is_eol_tok(curtok) +#define is_eol_tok(tok) ((tok) == '\n' || (tok) == 0) +#define is_eol() is_eol_tok(curtok) #define get_next_token() (curtok = nasm_parser_lex(&curval, parser_nasm)) @@ -91,9 +78,9 @@ get_peek_token(yasm_parser_nasm *parser_nasm) { char savech = parser_nasm->tokch; if (parser_nasm->peek_token != NONE) - yasm_internal_error(N_("only can have one token of lookahead")); + yasm_internal_error(N_("only can have one token of lookahead")); parser_nasm->peek_token = - nasm_parser_lex(&parser_nasm->peek_tokval, parser_nasm); + nasm_parser_lex(&parser_nasm->peek_tokval, parser_nasm); parser_nasm->peek_tokch = parser_nasm->tokch; parser_nasm->tokch = savech; } @@ -102,32 +89,28 @@ static void destroy_curtok_(yasm_parser_nasm *parser_nasm) { if (curtok < 256) - ; + ; else switch ((enum tokentype)curtok) { - case INTNUM: - yasm_intnum_destroy(curval.intn); - break; - case FLTNUM: - yasm_floatnum_destroy(curval.flt); - break; - case DIRECTIVE_NAME: - case FILENAME: - case ID: - case LOCAL_ID: - case SPECIAL_ID: - case NONLOCAL_ID: - yasm_xfree(curval.str_val); - break; - case STRING: - yasm_xfree(curval.str.contents); - break; - case INSN: - yasm_bc_destroy(curval.bc); - break; - default: - break; + case INTNUM: + yasm_intnum_destroy(curval.intn); + break; + case FLTNUM: + yasm_floatnum_destroy(curval.flt); + break; + case DIRECTIVE_NAME: + case FILENAME: + case ID: + case LOCAL_ID: + case SPECIAL_ID: + yasm_xfree(curval.str_val); + break; + case STRING: + yasm_xfree(curval.str.contents); + break; + default: + break; } - curtok = NONE; /* sanity */ + curtok = NONE; /* sanity */ } #define destroy_curtok() destroy_curtok_(parser_nasm) @@ -138,74 +121,64 @@ static void demand_eol_(yasm_parser_nasm *parser_nasm) { if (is_eol()) - return; + return; yasm_error_set(YASM_ERROR_SYNTAX, - N_("junk at end of line, first unrecognized character is `%c'"), - parser_nasm->tokch); + N_("junk at end of line, first unrecognized character is `%c'"), + parser_nasm->tokch); do { - destroy_curtok(); - get_next_token(); + destroy_curtok(); + get_next_token(); } while (!is_eol()); } #define demand_eol() demand_eol_(parser_nasm) -static const char * -describe_token(int token) +static int +expect_(yasm_parser_nasm *parser_nasm, int token) { static char strch[] = "` '"; const char *str; - switch (token) { - case 0: str = "end of line"; break; - case INTNUM: str = "integer"; break; - case FLTNUM: str = "floating point value"; break; - case DIRECTIVE_NAME: str = "directive name"; break; - case FILENAME: str = "filename"; break; - case STRING: str = "string"; break; - case SIZE_OVERRIDE: str = "size override"; break; - case DECLARE_DATA: str = "DB/DW/etc."; break; - case RESERVE_SPACE: str = "RESB/RESW/etc."; break; - case INCBIN: str = "INCBIN"; break; - case EQU: str = "EQU"; break; - case TIMES: str = "TIMES"; break; - case SEG: str = "SEG"; break; - case WRT: str = "WRT"; break; - case NOSPLIT: str = "NOSPLIT"; break; - case STRICT: str = "STRICT"; break; - case INSN: str = "instruction"; break; - case PREFIX: str = "instruction prefix"; break; - case REG: str = "register"; break; - case REGGROUP: str = "register group"; break; - case SEGREG: str = "segment register"; break; - case TARGETMOD: str = "target modifier"; break; - case LEFT_OP: str = "<<"; break; - case RIGHT_OP: str = ">>"; break; - case SIGNDIV: str = "//"; break; - case SIGNMOD: str = "%%"; break; - case START_SECTION_ID: str = "$$"; break; - case ID: str = "identifier"; break; - case LOCAL_ID: str = ".identifier"; break; - case SPECIAL_ID: str = "..identifier"; break; - case NONLOCAL_ID: str = "..@identifier"; break; - case LINE: str = "%line"; break; - default: - strch[1] = token; - str = strch; - break; - } - - return str; -} - -static int -expect_(yasm_parser_nasm *parser_nasm, int token) -{ if (curtok == token) - return 1; + return 1; - yasm_error_set(YASM_ERROR_PARSE, "expected %s", describe_token(token)); + switch (token) { + case INTNUM: str = "integer"; break; + case FLTNUM: str = "floating point value"; break; + case DIRECTIVE_NAME: str = "directive name"; break; + case FILENAME: str = "filename"; break; + case STRING: str = "string"; break; + case SIZE_OVERRIDE: str = "size override"; break; + case DECLARE_DATA: str = "DB/DW/etc."; break; + case RESERVE_SPACE: str = "RESB/RESW/etc."; break; + case INCBIN: str = "INCBIN"; break; + case EQU: str = "EQU"; break; + case TIMES: str = "TIMES"; break; + case SEG: str = "SEG"; break; + case WRT: str = "WRT"; break; + case NOSPLIT: str = "NOSPLIT"; break; + case STRICT: str = "STRICT"; break; + case INSN: str = "instruction"; break; + case PREFIX: str = "instruction prefix"; break; + case REG: str = "register"; break; + case SEGREG: str = "segment register"; break; + case TARGETMOD: str = "target modifier"; break; + case LEFT_OP: str = "<<"; break; + case RIGHT_OP: str = ">>"; break; + case SIGNDIV: str = "//"; break; + case SIGNMOD: str = "%%"; break; + case START_SECTION_ID: str = "$$"; break; + case ID: str = "identifier"; break; + case LOCAL_ID: str = ".identifier"; break; + case SPECIAL_ID: str = "..identifier"; break; + case LINE: str = "%line"; break; + default: + strch[1] = token; + str = strch; + break; + } + yasm_error_set(YASM_ERROR_PARSE, "expected %s", str); destroy_curtok(); return 0; } @@ -214,65 +187,54 @@ expect_(yasm_parser_nasm *parser_nasm, int token) void nasm_parser_parse(yasm_parser_nasm *parser_nasm) { - unsigned char *line; - while ((line = (unsigned char *) - yasm_preproc_get_line(parser_nasm->preproc)) != NULL) { - yasm_bytecode *bc = NULL, *temp_bc; + while (get_next_token() != 0) { + yasm_bytecode *bc = NULL, *temp_bc; + + if (!is_eol()) { + bc = parse_line(parser_nasm); + demand_eol(); + } - parser_nasm->s.bot = line; - parser_nasm->s.tok = line; - parser_nasm->s.ptr = line; - parser_nasm->s.cur = line; - parser_nasm->s.lim = line + strlen((char *)line)+1; - parser_nasm->s.top = parser_nasm->s.lim; + if (parser_nasm->abspos) { + /* If we're inside an absolute section, just add to the absolute + * position rather than appending bytecodes to a section. + * Only RES* are allowed in an absolute section, so this is easy. + */ + if (bc) { + /*@null@*/ const yasm_expr *numitems, *multiple; + unsigned int itemsize; + numitems = yasm_bc_reserve_numitems(bc, &itemsize); + if (numitems) { + yasm_expr *e; + e = yasm_expr_create(YASM_EXPR_MUL, + yasm_expr_expr(yasm_expr_copy(numitems)), + yasm_expr_int(yasm_intnum_create_uint(itemsize)), + cur_line); + multiple = yasm_bc_get_multiple_expr(bc); + if (multiple) + e = yasm_expr_create_tree(e, YASM_EXPR_MUL, + yasm_expr_copy(multiple), + cur_line); + parser_nasm->abspos = yasm_expr_create_tree( + parser_nasm->abspos, YASM_EXPR_ADD, e, cur_line); + } else + yasm_error_set(YASM_ERROR_SYNTAX, + N_("only RES* allowed within absolute section")); + yasm_bc_destroy(bc); + } + temp_bc = NULL; + } else { + temp_bc = yasm_section_bcs_append(cursect, bc); + if (temp_bc) + parser_nasm->prev_bc = temp_bc; + } + yasm_errwarn_propagate(parser_nasm->errwarns, cur_line); - get_next_token(); - if (!is_eol()) { - bc = parse_line(parser_nasm); - demand_eol(); - } - - if (parser_nasm->abspos) { - /* If we're inside an absolute section, just add to the absolute - * position rather than appending bytecodes to a section. - * Only RES* are allowed in an absolute section, so this is easy. - */ - if (bc) { - /*@null@*/ const yasm_expr *numitems, *multiple; - unsigned int itemsize; - numitems = yasm_bc_reserve_numitems(bc, &itemsize); - if (numitems) { - yasm_expr *e; - e = yasm_expr_create(YASM_EXPR_MUL, - yasm_expr_expr(yasm_expr_copy(numitems)), - yasm_expr_int(yasm_intnum_create_uint(itemsize)), - cur_line); - multiple = yasm_bc_get_multiple_expr(bc); - if (multiple) - e = yasm_expr_create_tree(e, YASM_EXPR_MUL, - yasm_expr_copy(multiple), - cur_line); - parser_nasm->abspos = yasm_expr_create_tree( - parser_nasm->abspos, YASM_EXPR_ADD, e, cur_line); - } else - yasm_error_set(YASM_ERROR_SYNTAX, - N_("only RES* allowed within absolute section")); - yasm_bc_destroy(bc); - } - temp_bc = NULL; - } else if (bc) { - temp_bc = yasm_section_bcs_append(cursect, bc); - if (temp_bc) - parser_nasm->prev_bc = temp_bc; - } else - temp_bc = NULL; - yasm_errwarn_propagate(parser_nasm->errwarns, cur_line); - - if (parser_nasm->save_input) - yasm_linemap_add_source(parser_nasm->linemap, temp_bc, - (char *)line); - yasm_linemap_goto_next(parser_nasm->linemap); - yasm_xfree(line); + if (parser_nasm->save_input) + yasm_linemap_add_source(parser_nasm->linemap, + temp_bc, + (char *)parser_nasm->save_line[parser_nasm->save_last ^ 1]); + yasm_linemap_goto_next(parser_nasm->linemap); } } @@ -288,193 +250,148 @@ parse_line(yasm_parser_nasm *parser_nasm) bc = parse_exp(parser_nasm); if (bc) - return bc; + return bc; switch (curtok) { - case LINE: /* LINE INTNUM '+' INTNUM FILENAME */ - { - yasm_intnum *line, *incr; - char *filename; + case LINE: /* LINE INTNUM '+' INTNUM FILENAME */ + { + yasm_intnum *line, *incr; + char *filename; - get_next_token(); + get_next_token(); - if (!expect(INTNUM)) return NULL; - line = INTNUM_val; - get_next_token(); + if (!expect(INTNUM)) return NULL; + line = INTNUM_val; + get_next_token(); - if (!expect('+')) return NULL; - get_next_token(); + if (!expect('+')) return NULL; + get_next_token(); - if (!expect(INTNUM)) return NULL; - incr = INTNUM_val; - get_next_token(); + if (!expect(INTNUM)) return NULL; + incr = INTNUM_val; + get_next_token(); - if (!expect(FILENAME)) return NULL; - filename = FILENAME_val; - get_next_token(); + if (!expect(FILENAME)) return NULL; + filename = FILENAME_val; + get_next_token(); - /* %line indicates the line number of the *next* line, so subtract - * out the increment when setting the line number. - */ - yasm_linemap_set(parser_nasm->linemap, filename, 0, - yasm_intnum_get_uint(line) - yasm_intnum_get_uint(incr), - yasm_intnum_get_uint(incr)); - yasm_intnum_destroy(line); - yasm_intnum_destroy(incr); - yasm_xfree(filename); - return NULL; - } - case '[': /* [ directive ] */ - { - char *dirname; - yasm_valparamhead dir_vps; - int have_vps = 1; + /* %line indicates the line number of the *next* line, so subtract + * out the increment when setting the line number. + */ + yasm_linemap_set(parser_nasm->linemap, filename, + yasm_intnum_get_uint(line) - yasm_intnum_get_uint(incr), + yasm_intnum_get_uint(incr)); + yasm_intnum_destroy(line); + yasm_intnum_destroy(incr); + yasm_xfree(filename); + return NULL; + } + case '[': /* [ directive ] */ + { + char *dirname; + yasm_valparamhead dir_vps; + int have_vps = 1; - parser_nasm->state = DIRECTIVE; - get_next_token(); + parser_nasm->state = DIRECTIVE; + get_next_token(); - if (!expect(DIRECTIVE_NAME)) - return NULL; - dirname = DIRECTIVE_NAME_val; - get_next_token(); + if (!expect(DIRECTIVE_NAME)) + return NULL; + dirname = DIRECTIVE_NAME_val; + get_next_token(); - /* ignore [warning]. TODO: actually implement */ - if (yasm__strcasecmp(dirname, "warning") == 0) { - yasm_warn_set(YASM_WARN_GENERAL, - N_("[warning] directive not supported; ignored")); + if (curtok == ']' || curtok == ':') + have_vps = 0; + else if (!parse_directive_valparams(parser_nasm, &dir_vps)) { + yasm_error_set(YASM_ERROR_SYNTAX, + N_("invalid arguments to [%s]"), dirname); + yasm_xfree(dirname); + return NULL; + } + if (curtok == ':') { + yasm_valparamhead ext_vps; + get_next_token(); + if (!parse_directive_valparams(parser_nasm, &ext_vps)) { + yasm_error_set(YASM_ERROR_SYNTAX, + N_("invalid arguments to [%s]"), dirname); + yasm_xfree(dirname); + return NULL; + } + nasm_parser_directive(parser_nasm, dirname, + have_vps ? &dir_vps : NULL, &ext_vps); + } else + nasm_parser_directive(parser_nasm, dirname, + have_vps ? &dir_vps : NULL, NULL); + yasm_xfree(dirname); + expect(']'); + get_next_token(); + return NULL; + } + case TIMES: /* TIMES expr exp */ + get_next_token(); + return parse_times(parser_nasm); + case ID: + case SPECIAL_ID: + case LOCAL_ID: + { + char *name = ID_val; + int local = (curtok != ID); - /* throw away the rest of the directive tokens */ - while (!is_eol() && curtok != ']') - { - destroy_curtok(); - get_next_token(); - } - expect(']'); - get_next_token(); - return NULL; - } + get_next_token(); + if (is_eol()) { + /* label alone on the line */ + yasm_warn_set(YASM_WARN_ORPHAN_LABEL, + N_("label alone on a line without a colon might be in error")); + define_label(parser_nasm, name, local); + return NULL; + } + if (curtok == ':') + get_next_token(); - if (curtok == ']' || curtok == ':') - have_vps = 0; - else if (!parse_directive_valparams(parser_nasm, &dir_vps)) { - yasm_error_set(YASM_ERROR_SYNTAX, - N_("invalid arguments to [%s]"), dirname); - yasm_xfree(dirname); - return NULL; - } - if (curtok == ':') { - yasm_valparamhead ext_vps; - get_next_token(); - if (!parse_directive_valparams(parser_nasm, &ext_vps)) { - yasm_error_set(YASM_ERROR_SYNTAX, - N_("invalid arguments to [%s]"), dirname); - yasm_xfree(dirname); - return NULL; - } - nasm_parser_directive(parser_nasm, dirname, - have_vps ? &dir_vps : NULL, &ext_vps); - } else - nasm_parser_directive(parser_nasm, dirname, - have_vps ? &dir_vps : NULL, NULL); - yasm_xfree(dirname); - expect(']'); - get_next_token(); - return NULL; - } - case TIMES: /* TIMES expr exp */ - get_next_token(); - return parse_times(parser_nasm); - case ID: - case SPECIAL_ID: - case NONLOCAL_ID: - case LOCAL_ID: - { - char *name = ID_val; - int local = parser_nasm->tasm - ? (curtok == ID || curtok == LOCAL_ID || - (curtok == SPECIAL_ID && name[0] == '@')) - : (curtok != ID); - unsigned int size = 0; + if (curtok == EQU) { + /* label EQU expr */ + yasm_expr *e; + get_next_token(); + e = parse_expr(parser_nasm, NORM_EXPR); + if (!e) { + yasm_error_set(YASM_ERROR_SYNTAX, + N_("expression expected after %s"), "EQU"); + yasm_xfree(name); + return NULL; + } + yasm_symtab_define_equ(p_symtab, name, e, cur_line); + yasm_xfree(name); + return NULL; + } - get_next_token(); - if (is_eol()) { - /* label alone on the line */ - yasm_warn_set(YASM_WARN_ORPHAN_LABEL, - N_("label alone on a line without a colon might be in error")); - if (!local) - set_nonlocal_label(parser_nasm, name); - define_label(parser_nasm, name, 0); - return NULL; - } - if (curtok == ':') - get_next_token(); - - if (curtok == EQU || (parser_nasm->tasm && curtok == '=')) { - /* label EQU expr */ - yasm_expr *e; - get_next_token(); - - if (parser_nasm->tasm && curtok == SIZE_OVERRIDE) { - size = SIZE_OVERRIDE_val; - get_next_token(); - } - - e = parse_expr(parser_nasm, NORM_EXPR); - if (!e) { - yasm_error_set(YASM_ERROR_SYNTAX, - N_("expression expected after %s"), "EQU"); - yasm_xfree(name); - return NULL; - } - yasm_symtab_define_equ(p_symtab, name, e, cur_line); - yasm_xfree(name); - return NULL; - } - - if (parser_nasm->tasm && curtok == LABEL) - get_next_token(); - - if (parser_nasm->tasm && curtok == SIZE_OVERRIDE) { - size = SIZE_OVERRIDE_val; - get_next_token(); - } - - if (!local) - set_nonlocal_label(parser_nasm, name); - - if (is_eol()) { - define_label(parser_nasm, name, size); - return NULL; - } - if (curtok == TIMES) { - define_label(parser_nasm, name, size); - get_next_token(); - return parse_times(parser_nasm); - } - bc = parse_exp(parser_nasm); - if (!parser_nasm->tasm && !bc) - yasm_error_set(YASM_ERROR_SYNTAX, - N_("instruction expected after label")); - if (parser_nasm->tasm && bc && !size) - size = yasm_bc_elem_size(bc); - define_label(parser_nasm, name, size); - return bc; - } - default: - yasm_error_set(YASM_ERROR_SYNTAX, - N_("label or instruction expected at start of line")); - return NULL; + define_label(parser_nasm, name, local); + if (is_eol()) + return NULL; + if (curtok == TIMES) { + get_next_token(); + return parse_times(parser_nasm); + } + bc = parse_exp(parser_nasm); + if (!bc) + yasm_error_set(YASM_ERROR_SYNTAX, + N_("instruction expected after label")); + return bc; + } + default: + yasm_error_set(YASM_ERROR_SYNTAX, + N_("label or instruction expected at start of line")); + return NULL; } } static int parse_directive_valparams(yasm_parser_nasm *parser_nasm, - /*@out@*/ yasm_valparamhead *vps) + /*@out@*/ yasm_valparamhead *vps) { yasm_vps_initialize(vps); for (;;) { - yasm_valparam *vp; - yasm_expr *e; + yasm_valparam *vp; + yasm_expr *e; char *id = NULL; /* Look for value first */ @@ -488,12 +405,12 @@ parse_directive_valparams(yasm_parser_nasm *parser_nasm, } /* Look for parameter */ - switch (curtok) { - case STRING: + switch (curtok) { + case STRING: vp = yasm_vp_create_string(id, STRING_val.contents); - get_next_token(); - break; - case ID: + get_next_token(); + break; + case ID: /* We need a peek token, but avoid error if we have one * already; we need to work whether or not we hit the * "value=" if test above. @@ -504,34 +421,34 @@ parse_directive_valparams(yasm_parser_nasm *parser_nasm, * the expression "x+y" and not as "x", "+y"). */ if (parser_nasm->peek_token == NONE) - get_peek_token(parser_nasm); + get_peek_token(parser_nasm); switch (parser_nasm->peek_token) { case '|': case '^': case '&': case LEFT_OP: case RIGHT_OP: case '+': case '-': case '*': case '/': case '%': case SIGNDIV: case SIGNMOD: - break; + break; default: /* Just an id */ vp = yasm_vp_create_id(id, ID_val, '$'); get_next_token(); goto next; - } - /*@fallthrough@*/ - default: - e = parse_expr(parser_nasm, DIR_EXPR); + } + /*@fallthrough@*/ + default: + e = parse_expr(parser_nasm, DIR_EXPR); if (!e) { yasm_vps_delete(vps); return 0; } vp = yasm_vp_create_expr(id, e); break; - } + } next: - yasm_vps_append(vps, vp); - if (curtok == ',') - get_next_token(); - if (curtok == ']' || curtok == ':' || is_eol()) - return 1; + yasm_vps_append(vps, vp); + if (curtok == ',') + get_next_token(); + if (curtok == ']' || curtok == ':' || is_eol()) + return 1; } } @@ -541,18 +458,18 @@ parse_times(yasm_parser_nasm *parser_nasm) yasm_expr *multiple; yasm_bytecode *bc; - multiple = parse_bexpr(parser_nasm, DV_EXPR); + multiple = parse_expr(parser_nasm, DV_EXPR); if (!multiple) { - yasm_error_set(YASM_ERROR_SYNTAX, N_("expression expected after %s"), - "TIMES"); - return NULL; + yasm_error_set(YASM_ERROR_SYNTAX, N_("expression expected after %s"), + "TIMES"); + return NULL; } bc = parse_exp(parser_nasm); if (!bc) { - yasm_error_set(YASM_ERROR_SYNTAX, - N_("instruction expected after TIMES expression")); - yasm_expr_destroy(multiple); - return NULL; + yasm_error_set(YASM_ERROR_SYNTAX, + N_("instruction expected after TIMES expression")); + yasm_expr_destroy(multiple); + return NULL; } yasm_bc_set_multiple(bc, multiple); return bc; @@ -565,236 +482,178 @@ parse_exp(yasm_parser_nasm *parser_nasm) bc = parse_instr(parser_nasm); if (bc) - return bc; + return bc; switch (curtok) { - case DECLARE_DATA: - { - unsigned int size = DECLARE_DATA_val/8; - yasm_datavalhead dvs; - yasm_dataval *dv; - yasm_expr *e, *e2; + case DECLARE_DATA: + { + unsigned int size = DECLARE_DATA_val/8; + yasm_datavalhead dvs; + yasm_dataval *dv; + yasm_expr *e; - get_next_token(); + get_next_token(); - yasm_dvs_initialize(&dvs); - for (;;) { - if (curtok == STRING) { - /* Peek ahead to see if we're in an expr. If we're not, - * then generate a real string dataval. - */ - get_peek_token(parser_nasm); - if (parser_nasm->peek_token == ',' - || is_eol_tok(parser_nasm->peek_token)) { - dv = yasm_dv_create_string(STRING_val.contents, - STRING_val.len); - get_next_token(); - goto dv_done; - } - } - if (curtok == '?') { - yasm_dvs_delete(&dvs); - get_next_token(); - if (! is_eol_tok(curtok)) { - yasm_error_set(YASM_ERROR_SYNTAX, - N_("can not handle more than one '?'")); - return NULL; - } - return yasm_bc_create_reserve( - p_expr_new_ident(yasm_expr_int( - yasm_intnum_create_uint(1))), - size, cur_line); - } - if (!(e = parse_bexpr(parser_nasm, DV_EXPR))) { - yasm_error_set(YASM_ERROR_SYNTAX, - N_("expression or string expected")); - yasm_dvs_delete(&dvs); - return NULL; - } - if (curtok == DUP) { - get_next_token(); - if (curtok != '(') { - yasm_error_set(YASM_ERROR_SYNTAX, - N_("expected ( after DUP")); - goto error; - } - get_next_token(); - if (curtok == '?') { - get_next_token(); - if (curtok != ')') { - yasm_error_set(YASM_ERROR_SYNTAX, - N_("expected ) after DUPlicated expression")); - goto error; - } - get_next_token(); - if (! is_eol_tok(curtok)) { - yasm_error_set(YASM_ERROR_SYNTAX, - N_("can not handle more than one '?'")); - goto error; - } - yasm_dvs_delete(&dvs); - return yasm_bc_create_reserve(e, size, cur_line); - } else if ((e2 = parse_bexpr(parser_nasm, DV_EXPR))) { - if (curtok != ')') { - yasm_expr_destroy(e2); - yasm_error_set(YASM_ERROR_SYNTAX, - N_("expected ) after DUPlicated expression")); - goto error; - } - get_next_token(); - dv = yasm_dv_create_expr(e2); - yasm_dv_set_multiple(dv, e); - } else { - yasm_error_set(YASM_ERROR_SYNTAX, - N_("expression or string expected")); -error: - yasm_expr_destroy(e); - yasm_dvs_delete(&dvs); - return NULL; - } - } else - dv = yasm_dv_create_expr(e); + yasm_dvs_initialize(&dvs); + for (;;) { + if (curtok == STRING) { + /* Peek ahead to see if we're in an expr. If we're not, + * then generate a real string dataval. + */ + get_peek_token(parser_nasm); + if (parser_nasm->peek_token == ',' + || is_eol_tok(parser_nasm->peek_token)) { + dv = yasm_dv_create_string(STRING_val.contents, + STRING_val.len); + get_next_token(); + goto dv_done; + } + } + if ((e = parse_expr(parser_nasm, DV_EXPR))) + dv = yasm_dv_create_expr(e); + else { + yasm_error_set(YASM_ERROR_SYNTAX, + N_("expression or string expected")); + yasm_dvs_delete(&dvs); + return NULL; + } dv_done: - yasm_dvs_append(&dvs, dv); - if (is_eol()) - break; - if (!expect(',')) { - yasm_dvs_delete(&dvs); - return NULL; - } - get_next_token(); - if (is_eol()) /* allow trailing , on list */ - break; - } - return yasm_bc_create_data(&dvs, size, 0, p_object->arch, - cur_line); - } - case RESERVE_SPACE: - { - unsigned int size = RESERVE_SPACE_val/8; - yasm_expr *e; - get_next_token(); - e = parse_bexpr(parser_nasm, DV_EXPR); - if (!e) { - yasm_error_set(YASM_ERROR_SYNTAX, - N_("expression expected after %s"), "RESx"); - return NULL; - } - return yasm_bc_create_reserve(e, size, cur_line); - } - case INCBIN: - { - char *filename; - yasm_expr *start = NULL, *maxlen = NULL; + yasm_dvs_append(&dvs, dv); + if (is_eol()) + break; + if (!expect(',')) { + yasm_dvs_delete(&dvs); + return NULL; + } + get_next_token(); + if (is_eol()) /* allow trailing , on list */ + break; + } + return yasm_bc_create_data(&dvs, size, 0, p_object->arch, + cur_line); + } + case RESERVE_SPACE: + { + unsigned int size = RESERVE_SPACE_val/8; + yasm_expr *e; + get_next_token(); + e = parse_expr(parser_nasm, DV_EXPR); + if (!e) { + yasm_error_set(YASM_ERROR_SYNTAX, + N_("expression expected after %s"), "RESx"); + return NULL; + } + return yasm_bc_create_reserve(e, size, cur_line); + } + case INCBIN: + { + char *filename; + yasm_expr *start = NULL, *maxlen = NULL; - get_next_token(); + get_next_token(); - if (!expect(STRING)) { - yasm_error_set(YASM_ERROR_SYNTAX, - N_("filename string expected after INCBIN")); - return NULL; - } - filename = STRING_val.contents; - get_next_token(); + if (!expect(STRING)) { + yasm_error_set(YASM_ERROR_SYNTAX, + N_("filename string expected after INCBIN")); + return NULL; + } + filename = STRING_val.contents; + get_next_token(); - /* optional start expression */ - if (curtok == ',') - get_next_token(); - if (is_eol()) - goto incbin_done; - start = parse_bexpr(parser_nasm, DV_EXPR); - if (!start) { - yasm_error_set(YASM_ERROR_SYNTAX, - N_("expression expected for INCBIN start")); - return NULL; - } + /* optional start expression */ + if (curtok == ',') + get_next_token(); + if (is_eol()) + goto incbin_done; + start = parse_expr(parser_nasm, DV_EXPR); + if (!start) { + yasm_error_set(YASM_ERROR_SYNTAX, + N_("expression expected for INCBIN start")); + return NULL; + } - /* optional maxlen expression */ - if (curtok == ',') - get_next_token(); - if (is_eol()) - goto incbin_done; - maxlen = parse_bexpr(parser_nasm, DV_EXPR); - if (!maxlen) { - yasm_error_set(YASM_ERROR_SYNTAX, - N_("expression expected for INCBIN maximum length")); - return NULL; - } + /* optional maxlen expression */ + if (curtok == ',') + get_next_token(); + if (is_eol()) + goto incbin_done; + maxlen = parse_expr(parser_nasm, DV_EXPR); + if (!start) { + yasm_error_set(YASM_ERROR_SYNTAX, + N_("expression expected for INCBIN maximum length")); + return NULL; + } incbin_done: - return yasm_bc_create_incbin(filename, start, maxlen, - parser_nasm->linemap, cur_line); - } - default: - return NULL; + return yasm_bc_create_incbin(filename, start, maxlen, + parser_nasm->linemap, cur_line); + } + default: + return NULL; } } static yasm_bytecode * parse_instr(yasm_parser_nasm *parser_nasm) { - yasm_bytecode *bc; - switch (curtok) { - case INSN: - { - yasm_insn *insn; - bc = INSN_val; - insn = yasm_bc_get_insn(bc); + case INSN: + { + yystype insn = curval; /* structure copy */ + yasm_insn_operands operands; + int num_operands = 0; - get_next_token(); - if (is_eol()) - return bc; /* no operands */ + get_next_token(); + if (is_eol()) { + /* no operands */ + return yasm_bc_create_insn(p_object->arch, insn.arch_data, 0, + NULL, cur_line); + } - /* parse operands */ - for (;;) { - yasm_insn_operand *op = parse_operand(parser_nasm); - if (!op) { - if (insn->num_operands == 0) - yasm_error_set(YASM_ERROR_SYNTAX, - N_("unexpected %s after instruction"), - describe_token(curtok)); - else - yasm_error_set(YASM_ERROR_SYNTAX, - N_("expected operand, got %s"), - describe_token(curtok)); - yasm_bc_destroy(bc); - return NULL; - } - yasm_insn_ops_append(insn, op); + /* parse operands */ + yasm_ops_initialize(&operands); + for (;;) { + yasm_insn_operand *op = parse_operand(parser_nasm); + if (!op) { + yasm_error_set(YASM_ERROR_SYNTAX, + N_("expression syntax error")); + yasm_ops_delete(&operands, 1); + return NULL; + } + yasm_ops_append(&operands, op); + num_operands++; - if (is_eol()) - break; - if (!expect(',')) { - yasm_bc_destroy(bc); - return NULL; - } - get_next_token(); - } - return bc; - } - case PREFIX: - { - uintptr_t prefix = PREFIX_val; - get_next_token(); - bc = parse_instr(parser_nasm); - if (!bc) - bc = yasm_arch_create_empty_insn(p_object->arch, cur_line); - yasm_insn_add_prefix(yasm_bc_get_insn(bc), prefix); - return bc; - } - case SEGREG: - { - uintptr_t segreg = SEGREG_val; - get_next_token(); - bc = parse_instr(parser_nasm); - if (!bc) - bc = yasm_arch_create_empty_insn(p_object->arch, cur_line); - yasm_insn_add_seg_prefix(yasm_bc_get_insn(bc), segreg); - return bc; - } - default: - return NULL; + if (is_eol()) + break; + if (!expect(',')) { + yasm_ops_delete(&operands, 1); + return NULL; + } + get_next_token(); + } + return yasm_bc_create_insn(p_object->arch, insn.arch_data, + num_operands, &operands, cur_line); + } + case PREFIX: { + yystype prefix = curval; /* structure copy */ + yasm_bytecode *bc; + get_next_token(); + bc = parse_instr(parser_nasm); + if (bc) + yasm_bc_insn_add_prefix(bc, prefix.arch_data); + return bc; + } + case SEGREG: { + uintptr_t segreg = SEGREG_val[0]; + yasm_bytecode *bc; + get_next_token(); + bc = parse_instr(parser_nasm); + if (bc) + yasm_bc_insn_add_seg_prefix(bc, segreg); + return bc; + } + default: + return NULL; } } @@ -803,366 +662,130 @@ parse_operand(yasm_parser_nasm *parser_nasm) { yasm_insn_operand *op; switch (curtok) { - case '[': - { - get_next_token(); - op = parse_memaddr(parser_nasm); + case '[': + { + yasm_effaddr *ea; + get_next_token(); + ea = parse_memaddr(parser_nasm); - expect(']'); - get_next_token(); + expect(']'); + get_next_token(); - if (!op) { - yasm_error_set(YASM_ERROR_SYNTAX, - N_("memory address expected")); - return NULL; - } - - if (parser_nasm->tasm && !is_eol() && curtok != ',') { - yasm_expr *e = NULL, *f; - yasm_effaddr *ea; - - switch (op->type) { - case YASM_INSN__OPERAND_IMM: - e = op->data.val; - break; - case YASM_INSN__OPERAND_MEMORY: - if (op->data.ea->disp.rel) { - yasm_error_set(YASM_ERROR_SYNTAX, - N_("relative adressing not supported\n")); - return NULL; - } - e = yasm_expr_copy(op->data.ea->disp.abs); - yasm_arch_ea_destroy(p_object->arch, op->data.ea); - break; - case YASM_INSN__OPERAND_REG: - case YASM_INSN__OPERAND_SEGREG: - yasm_error_set(YASM_ERROR_SYNTAX, - N_("register adressing not supported\n")); - return NULL; - } - yasm_xfree(op); - f = parse_bexpr(parser_nasm, NORM_EXPR); - if (!f) { - yasm_expr_destroy(e); - yasm_error_set(YASM_ERROR_SYNTAX, - N_("expected expression after ]")); - return NULL; - } - e = p_expr_new_tree(e, YASM_EXPR_ADD, f); - ea = yasm_arch_ea_create(p_object->arch, e); - yasm_ea_set_implicit_size_segment(parser_nasm, ea, e); - op = yasm_operand_create_mem(ea); - } - return op; - } - case OFFSET: - { - yasm_insn_operand *op2; - get_next_token(); - if (parser_nasm->masm && curtok == ID && !yasm__strcasecmp(ID_val, "flat")) { - get_next_token(); - if (curtok == ':') { - get_next_token(); - } - } - op = parse_operand(parser_nasm); - if (!op) { - yasm_error_set(YASM_ERROR_SYNTAX, - N_("memory address expected")); - return NULL; - } - if (op->type == YASM_INSN__OPERAND_IMM) - return op; - if (op->type != YASM_INSN__OPERAND_MEMORY) { - yasm_error_set(YASM_ERROR_SYNTAX, - N_("OFFSET applied to non-memory operand")); - return NULL; - } - if (op->data.ea->disp.rel) { - yasm_error_set(YASM_ERROR_SYNTAX, - N_("OFFSET applied to non-absolute memory operand")); - return NULL; - } - if (op->data.ea->disp.abs) - op2 = yasm_operand_create_imm(op->data.ea->disp.abs); - else - op2 = yasm_operand_create_imm(p_expr_new_ident( - yasm_expr_int(yasm_intnum_create_uint(0)))); - yasm_xfree(op); - return op2; - } - case SEGREG: - { - uintptr_t segreg = SEGREG_val; - get_next_token(); - if (parser_nasm->tasm && curtok == ':') { - get_next_token(); - op = parse_operand(parser_nasm); - if (!op) - return NULL; - if (op->type == YASM_INSN__OPERAND_IMM) { - yasm_effaddr *ea = yasm_arch_ea_create(p_object->arch, - op->data.val); - yasm_insn_operand *op2; - yasm_ea_set_implicit_size_segment(parser_nasm, ea, - op->data.val); - op2 = yasm_operand_create_mem(ea); - op2->size = op->size; - yasm_xfree(op); - op = op2; - } - if (op->type != YASM_INSN__OPERAND_MEMORY) { - yasm_error_set(YASM_ERROR_SYNTAX, - N_("segment applied to non-memory operand")); - return NULL; - } - yasm_ea_set_segreg(op->data.ea, segreg); - return op; - } - op = yasm_operand_create_segreg(segreg); - return op; - } - case REG: - op = yasm_operand_create_reg(REG_val); - get_next_token(); - return op; - case REGGROUP: - { - unsigned long regindex; - uintptr_t reg = REGGROUP_val; - get_next_token(); /* REGGROUP */ - if (curtok != '(') - return yasm_operand_create_reg(reg); - get_next_token(); /* '(' */ - if (!expect(INTNUM)) { - yasm_error_set(YASM_ERROR_SYNTAX, - N_("integer register index expected")); - return NULL; - } - regindex = yasm_intnum_get_uint(INTNUM_val); - get_next_token(); /* INTNUM */ - if (!expect(')')) { - yasm_error_set(YASM_ERROR_SYNTAX, - N_("missing closing parenthesis for register index")); - return NULL; - } - get_next_token(); /* ')' */ - reg = yasm_arch_reggroup_get_reg(p_object->arch, reg, regindex); - if (reg == 0) { - yasm_error_set(YASM_ERROR_SYNTAX, N_("bad register index `%u'"), - regindex); - return NULL; - } - return yasm_operand_create_reg(reg); - } - case STRICT: - get_next_token(); - op = parse_operand(parser_nasm); - if (op) - op->strict = 1; - return op; - case SIZE_OVERRIDE: - { - unsigned int size = SIZE_OVERRIDE_val; - get_next_token(); - if (parser_nasm->masm && curtok == ID && !yasm__strcasecmp(ID_val, "ptr")) { - destroy_curtok(); - get_next_token(); - } - op = parse_operand(parser_nasm); - if (!op) - return NULL; - if (op->type == YASM_INSN__OPERAND_REG && - yasm_arch_get_reg_size(p_object->arch, op->data.reg) != size) - yasm_error_set(YASM_ERROR_TYPE, - N_("cannot override register size")); - else { - /* Silently override others unless a warning is turned on. - * This is to allow overrides such as: - * %define arg1 dword [bp+4] - * cmp word arg1, 2 - * Which expands to: - * cmp word dword [bp+4], 2 - */ - if (op->size != 0) { - if (op->size != size) - yasm_warn_set(YASM_WARN_SIZE_OVERRIDE, - N_("overriding operand size from %u-bit to %u-bit"), - op->size, size); - else - yasm_warn_set(YASM_WARN_SIZE_OVERRIDE, - N_("double operand size override")); - } - op->size = size; - } - return op; - } - case TARGETMOD: - { - uintptr_t tmod = TARGETMOD_val; - get_next_token(); - op = parse_operand(parser_nasm); - if (op) - op->targetmod = tmod; - return op; - } - case ID: - case LOCAL_ID: - case NONLOCAL_ID: - if (parser_nasm->tasm) { - get_peek_token(parser_nasm); - if (parser_nasm->peek_token == '[') { - yasm_symrec *sym = yasm_symtab_use(p_symtab, ID_val, - cur_line); - yasm_expr *e = p_expr_new_ident(yasm_expr_sym(sym)), *f; - yasm_effaddr *ea; - yasm_xfree(ID_val); - get_next_token(); - get_next_token(); - f = parse_bexpr(parser_nasm, NORM_EXPR); - if (!f) { - yasm_error_set(YASM_ERROR_SYNTAX, - N_("expected expression after [")); - return NULL; - } - e = p_expr_new_tree(e, YASM_EXPR_ADD, f); - if (!expect(']')) { - yasm_error_set(YASM_ERROR_SYNTAX, N_("missing closing bracket")); - return NULL; - } - get_next_token(); - ea = yasm_arch_ea_create(p_object->arch, e); - yasm_ea_set_implicit_size_segment(parser_nasm, ea, e); - op = yasm_operand_create_mem(ea); - return op; - } - } - /* Fallthrough */ - default: - { - yasm_expr *e = parse_bexpr(parser_nasm, NORM_EXPR); - if (!e) - return NULL; - if (curtok != ':') { - if (parser_nasm->tasm && yasm_expr_size(e)) { - yasm_effaddr *ea = yasm_arch_ea_create(p_object->arch, e); - yasm_ea_set_implicit_size_segment(parser_nasm, ea, e); - op = yasm_operand_create_mem(ea); - return op; - } else if (curtok == '[') { - yasm_expr *f; - yasm_effaddr *ea; - yasm_insn_operand *op2; - - op = parse_operand(parser_nasm); - if (!op) - return NULL; - - f = op->data.ea->disp.abs; - e = p_expr_new_tree(e, YASM_EXPR_ADD, f); - ea = yasm_arch_ea_create(p_object->arch, e); - yasm_ea_set_implicit_size_segment(parser_nasm, ea, e); - op2 = yasm_operand_create_mem(ea); - - yasm_xfree(op); - - return op2; - } else { - return yasm_operand_create_imm(e); - } - } else { - yasm_expr *off; - get_next_token(); - off = parse_bexpr(parser_nasm, NORM_EXPR); - if (!off) { - yasm_expr_destroy(e); - return NULL; - } - op = yasm_operand_create_imm(off); - op->seg = e; - return op; - } - } + if (!ea) { + yasm_error_set(YASM_ERROR_SYNTAX, + N_("memory address expected")); + return NULL; + } + return yasm_operand_create_mem(ea); + } + case SEGREG: + op = yasm_operand_create_segreg(SEGREG_val[0]); + get_next_token(); + return op; + case REG: + op = yasm_operand_create_reg(REG_val[0]); + get_next_token(); + return op; + case STRICT: + get_next_token(); + op = parse_operand(parser_nasm); + if (op) + op->strict = 1; + return op; + case SIZE_OVERRIDE: + { + unsigned int size = SIZE_OVERRIDE_val; + get_next_token(); + op = parse_operand(parser_nasm); + if (!op) + return NULL; + if (op->type == YASM_INSN__OPERAND_REG && + yasm_arch_get_reg_size(p_object->arch, op->data.reg) != size) + yasm_error_set(YASM_ERROR_TYPE, + N_("cannot override register size")); + else { + /* Silently override others unless a warning is turned on. + * This is to allow overrides such as: + * %define arg1 dword [bp+4] + * cmp word arg1, 2 + * Which expands to: + * cmp word dword [bp+4], 2 + */ + if (op->size != 0) { + if (op->size != size) + yasm_warn_set(YASM_WARN_SIZE_OVERRIDE, + N_("overriding operand size from %u-bit to %u-bit"), + op->size, size); + else + yasm_warn_set(YASM_WARN_SIZE_OVERRIDE, + N_("double operand size override")); + } + op->size = size; + } + return op; + } + case TARGETMOD: + { + uintptr_t tmod = TARGETMOD_val[0]; + get_next_token(); + op = parse_operand(parser_nasm); + if (op) + op->targetmod = tmod; + return op; + } + default: + { + yasm_expr *e = parse_expr(parser_nasm, NORM_EXPR); + if (!e) + return NULL; + return yasm_operand_create_imm(e); + } } } /* memory addresses */ -static yasm_insn_operand * +static yasm_effaddr * parse_memaddr(yasm_parser_nasm *parser_nasm) { - yasm_insn_operand *op; + yasm_effaddr *ea; switch (curtok) { - case SEGREG: - { - uintptr_t segreg = SEGREG_val; - get_next_token(); - if (!expect(':')) { - yasm_error_set(YASM_ERROR_SYNTAX, - N_("`:' required after segment register")); - return NULL; - } - get_next_token(); - op = parse_memaddr(parser_nasm); - if (op) - yasm_ea_set_segreg(op->data.ea, segreg); - return op; - } - case SIZE_OVERRIDE: - { - unsigned int size = SIZE_OVERRIDE_val; - get_next_token(); - op = parse_memaddr(parser_nasm); - if (op) - op->data.ea->disp.size = size; - return op; - } - case NOSPLIT: - get_next_token(); - op = parse_memaddr(parser_nasm); - if (op) - op->data.ea->nosplit = 1; - return op; - case REL: - get_next_token(); - op = parse_memaddr(parser_nasm); - if (op) { - op->data.ea->pc_rel = 1; - op->data.ea->not_pc_rel = 0; - } - return op; - case ABS: - get_next_token(); - op = parse_memaddr(parser_nasm); - if (op) { - op->data.ea->pc_rel = 0; - op->data.ea->not_pc_rel = 1; - } - return op; - default: - { - yasm_expr *e = parse_bexpr(parser_nasm, NORM_EXPR); - if (!e) - return NULL; - if (curtok != ':') { - yasm_effaddr *ea = yasm_arch_ea_create(p_object->arch, e); - yasm_ea_set_implicit_size_segment(parser_nasm, ea, e); - return yasm_operand_create_mem(ea); - } else { - yasm_effaddr *ea; - yasm_expr *off; - get_next_token(); - off = parse_bexpr(parser_nasm, NORM_EXPR); - if (!off) { - yasm_expr_destroy(e); - return NULL; - } - ea = yasm_arch_ea_create(p_object->arch, off); - yasm_ea_set_implicit_size_segment(parser_nasm, ea, off); - op = yasm_operand_create_mem(ea); - op->seg = e; - return op; - } - } + case SEGREG: + { + uintptr_t segreg = SEGREG_val[0]; + get_next_token(); + if (!expect(':')) { + yasm_error_set(YASM_ERROR_SYNTAX, + N_("`:' required after segment register")); + return NULL; + } + get_next_token(); + ea = parse_memaddr(parser_nasm); + if (ea) + yasm_ea_set_segreg(ea, segreg); + return ea; + } + case SIZE_OVERRIDE: + { + unsigned int size = SIZE_OVERRIDE_val; + get_next_token(); + ea = parse_memaddr(parser_nasm); + if (ea) + yasm_ea_set_len(ea, size); + return ea; + } + case NOSPLIT: + get_next_token(); + ea = parse_memaddr(parser_nasm); + if (ea) + yasm_ea_set_nosplit(ea, 1); + return ea; + default: + { + yasm_expr *e = parse_expr(parser_nasm, NORM_EXPR); + if (!e) + return NULL; + return yasm_arch_ea_create(p_object->arch, e); + } } } @@ -1184,36 +807,36 @@ parse_memaddr(yasm_parser_nasm *parser_nasm) */ #define parse_expr_common(leftfunc, tok, rightfunc, op) \ - do { \ - yasm_expr *e, *f; \ - e = leftfunc(parser_nasm, type); \ - if (!e) \ - return NULL; \ - \ - while (curtok == tok) { \ - get_next_token(); \ - f = rightfunc(parser_nasm, type); \ - if (!f) { \ - yasm_error_set(YASM_ERROR_SYNTAX, \ - N_("expected expression after %s"), \ - describe_token(op)); \ - yasm_expr_destroy(e); \ - return NULL; \ - } \ - e = p_expr_new_tree(e, op, f); \ - } \ - return e; \ + do { \ + yasm_expr *e, *f; \ + e = leftfunc(parser_nasm, type); \ + if (!e) \ + return NULL; \ + \ + while (curtok == tok) { \ + get_next_token(); \ + f = rightfunc(parser_nasm, type); \ + if (!f) { \ + yasm_expr_destroy(e); \ + return NULL; \ + } \ + e = p_expr_new_tree(e, op, f); \ + } \ + return e; \ } while(0) static yasm_expr * parse_expr(yasm_parser_nasm *parser_nasm, expr_type type) { switch (type) { - case DIR_EXPR: - /* directive expressions can't handle seg:off or WRT */ - return parse_expr0(parser_nasm, type); - default: - parse_expr_common(parse_bexpr, ':', parse_bexpr, YASM_EXPR_SEGOFF); + case NORM_EXPR: + parse_expr_common(parse_bexpr, ':', parse_bexpr, YASM_EXPR_SEGOFF); + case DV_EXPR: + /* dataval expressions can't handle seg:off */ + return parse_bexpr(parser_nasm, type); + case DIR_EXPR: + /* directive expressions can't handle seg:off or WRT */ + return parse_expr0(parser_nasm, type); } /*@notreached@*/ return NULL; @@ -1249,24 +872,21 @@ parse_expr3(yasm_parser_nasm *parser_nasm, expr_type type) yasm_expr *e, *f; e = parse_expr4(parser_nasm, type); if (!e) - return NULL; + return NULL; while (curtok == LEFT_OP || curtok == RIGHT_OP) { - int op = curtok; - get_next_token(); - f = parse_expr4(parser_nasm, type); - if (!f) { - yasm_error_set(YASM_ERROR_SYNTAX, - N_("expected expression after %s"), - describe_token(op)); - yasm_expr_destroy(e); - return NULL; - } + int op = curtok; + get_next_token(); + f = parse_expr4(parser_nasm, type); + if (!f) { + yasm_expr_destroy(e); + return NULL; + } - switch (op) { - case LEFT_OP: e = p_expr_new_tree(e, YASM_EXPR_SHL, f); break; - case RIGHT_OP: e = p_expr_new_tree(e, YASM_EXPR_SHR, f); break; - } + switch (op) { + case LEFT_OP: e = p_expr_new_tree(e, YASM_EXPR_SHL, f); break; + case RIGHT_OP: e = p_expr_new_tree(e, YASM_EXPR_SHR, f); break; + } } return e; } @@ -1277,24 +897,21 @@ parse_expr4(yasm_parser_nasm *parser_nasm, expr_type type) yasm_expr *e, *f; e = parse_expr5(parser_nasm, type); if (!e) - return NULL; + return NULL; while (curtok == '+' || curtok == '-') { - int op = curtok; - get_next_token(); - f = parse_expr5(parser_nasm, type); - if (!f) { - yasm_error_set(YASM_ERROR_SYNTAX, - N_("expected expression after %s"), - describe_token(op)); - yasm_expr_destroy(e); - return NULL; - } + int op = curtok; + get_next_token(); + f = parse_expr5(parser_nasm, type); + if (!f) { + yasm_expr_destroy(e); + return NULL; + } - switch (op) { - case '+': e = p_expr_new_tree(e, YASM_EXPR_ADD, f); break; - case '-': e = p_expr_new_tree(e, YASM_EXPR_SUB, f); break; - } + switch (op) { + case '+': e = p_expr_new_tree(e, YASM_EXPR_ADD, f); break; + case '-': e = p_expr_new_tree(e, YASM_EXPR_SUB, f); break; + } } return e; } @@ -1305,28 +922,25 @@ parse_expr5(yasm_parser_nasm *parser_nasm, expr_type type) yasm_expr *e, *f; e = parse_expr6(parser_nasm, type); if (!e) - return NULL; + return NULL; while (curtok == '*' || curtok == '/' || curtok == '%' - || curtok == SIGNDIV || curtok == SIGNMOD) { - int op = curtok; - get_next_token(); - f = parse_expr6(parser_nasm, type); - if (!f) { - yasm_error_set(YASM_ERROR_SYNTAX, - N_("expected expression after %s"), - describe_token(op)); - yasm_expr_destroy(e); - return NULL; - } + || curtok == SIGNDIV || curtok == SIGNMOD) { + int op = curtok; + get_next_token(); + f = parse_expr6(parser_nasm, type); + if (!f) { + yasm_expr_destroy(e); + return NULL; + } - switch (op) { - case '*': e = p_expr_new_tree(e, YASM_EXPR_MUL, f); break; - case '/': e = p_expr_new_tree(e, YASM_EXPR_DIV, f); break; - case '%': e = p_expr_new_tree(e, YASM_EXPR_MOD, f); break; - case SIGNDIV: e = p_expr_new_tree(e, YASM_EXPR_SIGNDIV, f); break; - case SIGNMOD: e = p_expr_new_tree(e, YASM_EXPR_SIGNMOD, f); break; - } + switch (op) { + case '*': e = p_expr_new_tree(e, YASM_EXPR_MUL, f); break; + case '/': e = p_expr_new_tree(e, YASM_EXPR_DIV, f); break; + case '%': e = p_expr_new_tree(e, YASM_EXPR_MOD, f); break; + case SIGNDIV: e = p_expr_new_tree(e, YASM_EXPR_SIGNDIV, f); break; + case SIGNMOD: e = p_expr_new_tree(e, YASM_EXPR_SIGNMOD, f); break; + } } return e; } @@ -1337,199 +951,150 @@ parse_expr6(yasm_parser_nasm *parser_nasm, expr_type type) yasm_expr *e; yasm_symrec *sym; - switch (curtok) { - case '+': - get_next_token(); - e = parse_expr6(parser_nasm, type); - if (!e) { - yasm_error_set(YASM_ERROR_SYNTAX, - N_("expected expression after %s"), "`+'"); - } - return e; - case '-': - get_next_token(); - e = parse_expr6(parser_nasm, type); - if (!e) { - yasm_error_set(YASM_ERROR_SYNTAX, - N_("expected expression after %s"), "`-'"); - return NULL; - } - return p_expr_new_branch(YASM_EXPR_NEG, e); - case '~': - get_next_token(); - e = parse_expr6(parser_nasm, type); - if (!e) { - yasm_error_set(YASM_ERROR_SYNTAX, - N_("expected expression after %s"), "`~'"); - return NULL; - } - return p_expr_new_branch(YASM_EXPR_NOT, e); - case LOW: - get_next_token(); - e = parse_expr6(parser_nasm, type); - if (!e) { - yasm_error_set(YASM_ERROR_SYNTAX, - N_("expected expression after %s"), "LOW"); - return NULL; - } - return p_expr_new_tree(e, YASM_EXPR_AND, - p_expr_new_ident(yasm_expr_int(yasm_intnum_create_uint(0xff)))); - case HIGH: - get_next_token(); - e = parse_expr6(parser_nasm, type); - if (!e) { - yasm_error_set(YASM_ERROR_SYNTAX, - N_("expected expression after %s"), "HIGH"); - return NULL; - } - return p_expr_new_tree( - p_expr_new_tree(e, YASM_EXPR_SHR, - p_expr_new_ident(yasm_expr_int( - yasm_intnum_create_uint(8)))), - YASM_EXPR_AND, - p_expr_new_ident(yasm_expr_int(yasm_intnum_create_uint(0xff)))); - case SEG: - get_next_token(); - e = parse_expr6(parser_nasm, type); - if (!e) { - yasm_error_set(YASM_ERROR_SYNTAX, - N_("expected expression after %s"), "SEG"); - return NULL; - } - return p_expr_new_branch(YASM_EXPR_SEG, e); - case '(': - get_next_token(); - e = parse_expr(parser_nasm, type); - if (!e) { - yasm_error_set(YASM_ERROR_SYNTAX, - N_("expected expression after %s"), "`('"); - return NULL; - } - if (!expect(')')) { - yasm_error_set(YASM_ERROR_SYNTAX, N_("missing parenthesis")); - return NULL; - } - get_next_token(); - return e; - case INTNUM: - e = p_expr_new_ident(yasm_expr_int(INTNUM_val)); - get_next_token(); - return e; - case REG: - if (type == DV_EXPR) { - yasm_error_set(YASM_ERROR_SYNTAX, - N_("data values can't have registers")); - return NULL; - } - e = p_expr_new_ident(yasm_expr_reg(REG_val)); - get_next_token(); - return e; - } - /* directives allow very little and handle IDs specially */ if (type == DIR_EXPR) { - switch (curtok) { - case ID: + switch (curtok) { + case '~': + get_next_token(); + e = parse_expr6(parser_nasm, type); + if (!e) + return NULL; + return p_expr_new_branch(YASM_EXPR_NOT, e); + case '(': + get_next_token(); + e = parse_expr(parser_nasm, type); + if (!e) + return NULL; + if (!expect(')')) { + yasm_error_set(YASM_ERROR_SYNTAX, N_("missing parenthesis")); + return NULL; + } + get_next_token(); + return e; + case INTNUM: + e = p_expr_new_ident(yasm_expr_int(INTNUM_val)); + break; + case REG: + e = p_expr_new_ident(yasm_expr_reg(REG_val[0])); + break; + case ID: sym = yasm_symtab_use(p_symtab, ID_val, cur_line); e = p_expr_new_ident(yasm_expr_sym(sym)); - yasm_xfree(ID_val); - break; - default: - return NULL; - } + yasm_xfree(ID_val); + break; + default: + return NULL; + } } else switch (curtok) { - case FLTNUM: - e = p_expr_new_ident(yasm_expr_float(FLTNUM_val)); - break; - case STRING: - { - yasm_intnum *intn; - if (parser_nasm->tasm) - intn = yasm_intnum_create_charconst_tasm(STRING_val.contents); - else - intn = yasm_intnum_create_charconst_nasm(STRING_val.contents); - e = p_expr_new_ident(yasm_expr_int(intn)); - yasm_xfree(STRING_val.contents); - break; - } - case SPECIAL_ID: - sym = yasm_objfmt_get_special_sym(p_object, ID_val+2, "nasm"); - if (sym) { - e = p_expr_new_ident(yasm_expr_sym(sym)); - yasm_xfree(ID_val); - break; - } - /*@fallthrough@*/ - case ID: - case LOCAL_ID: - case NONLOCAL_ID: - sym = yasm_symtab_use(p_symtab, ID_val, cur_line); - e = p_expr_new_ident(yasm_expr_sym(sym)); - yasm_xfree(ID_val); - break; - case '$': - /* "$" references the current assembly position */ - if (parser_nasm->abspos) - e = yasm_expr_copy(parser_nasm->abspos); - else { - sym = yasm_symtab_define_curpos(p_symtab, "$", - parser_nasm->prev_bc, cur_line); - e = p_expr_new_ident(yasm_expr_sym(sym)); - } - break; - case START_SECTION_ID: - /* "$$" references the start of the current section */ - if (parser_nasm->absstart) - e = yasm_expr_copy(parser_nasm->absstart); - else { - sym = yasm_symtab_define_label(p_symtab, "$$", - yasm_section_bcs_first(cursect), 0, cur_line); - e = p_expr_new_ident(yasm_expr_sym(sym)); - } - break; - default: - return NULL; + case '+': + get_next_token(); + return parse_expr6(parser_nasm, type); + case '-': + get_next_token(); + e = parse_expr6(parser_nasm, type); + if (!e) + return NULL; + return p_expr_new_branch(YASM_EXPR_NEG, e); + case '~': + get_next_token(); + e = parse_expr6(parser_nasm, type); + if (!e) + return NULL; + return p_expr_new_branch(YASM_EXPR_NOT, e); + case SEG: + get_next_token(); + e = parse_expr6(parser_nasm, type); + if (!e) + return NULL; + return p_expr_new_branch(YASM_EXPR_SEG, e); + case '(': + get_next_token(); + e = parse_expr(parser_nasm, type); + if (!e) + return NULL; + if (!expect(')')) { + yasm_error_set(YASM_ERROR_SYNTAX, N_("missing parenthesis")); + return NULL; + } + get_next_token(); + return e; + case INTNUM: + e = p_expr_new_ident(yasm_expr_int(INTNUM_val)); + break; + case FLTNUM: + e = p_expr_new_ident(yasm_expr_float(FLTNUM_val)); + break; + case REG: + if (type == DV_EXPR) { + yasm_error_set(YASM_ERROR_SYNTAX, + N_("data values can't have registers")); + return NULL; + } + e = p_expr_new_ident(yasm_expr_reg(REG_val[0])); + break; + case STRING: + e = p_expr_new_ident(yasm_expr_int( + yasm_intnum_create_charconst_nasm(STRING_val.contents))); + yasm_xfree(STRING_val.contents); + break; + case ID: + case SPECIAL_ID: + case LOCAL_ID: + sym = yasm_symtab_use(p_symtab, ID_val, cur_line); + e = p_expr_new_ident(yasm_expr_sym(sym)); + yasm_xfree(ID_val); + break; + case '$': + /* "$" references the current assembly position */ + if (parser_nasm->abspos) + e = yasm_expr_copy(parser_nasm->abspos); + else { + sym = yasm_symtab_define_curpos(p_symtab, "$", + parser_nasm->prev_bc, cur_line); + e = p_expr_new_ident(yasm_expr_sym(sym)); + } + break; + case START_SECTION_ID: + /* "$$" references the start of the current section */ + if (parser_nasm->absstart) + e = yasm_expr_copy(parser_nasm->absstart); + else { + sym = yasm_symtab_define_label(p_symtab, "$$", + yasm_section_bcs_first(cursect), 0, cur_line); + e = p_expr_new_ident(yasm_expr_sym(sym)); + } + break; + default: + return NULL; } - get_next_token(); return e; } static void -set_nonlocal_label(yasm_parser_nasm *parser_nasm, const char *name) +define_label(yasm_parser_nasm *parser_nasm, char *name, int local) { - if (!parser_nasm->tasm || tasm_locals) { - if (parser_nasm->locallabel_base) - yasm_xfree(parser_nasm->locallabel_base); - parser_nasm->locallabel_base_len = strlen(name); - parser_nasm->locallabel_base = - yasm_xmalloc(parser_nasm->locallabel_base_len+1); - strcpy(parser_nasm->locallabel_base, name); + if (!local) { + if (parser_nasm->locallabel_base) + yasm_xfree(parser_nasm->locallabel_base); + parser_nasm->locallabel_base_len = strlen(name); + parser_nasm->locallabel_base = + yasm_xmalloc(parser_nasm->locallabel_base_len+1); + strcpy(parser_nasm->locallabel_base, name); } -} - -static void -define_label(yasm_parser_nasm *parser_nasm, char *name, unsigned int size) -{ - yasm_symrec *symrec; if (parser_nasm->abspos) - symrec = yasm_symtab_define_equ(p_symtab, name, - yasm_expr_copy(parser_nasm->abspos), - cur_line); + yasm_symtab_define_equ(p_symtab, name, + yasm_expr_copy(parser_nasm->abspos), cur_line); else - symrec = yasm_symtab_define_label(p_symtab, name, parser_nasm->prev_bc, - 1, cur_line); - - yasm_symrec_set_size(symrec, size); - yasm_symrec_set_segment(symrec, tasm_segment); - + yasm_symtab_define_label(p_symtab, name, parser_nasm->prev_bc, 1, + cur_line); yasm_xfree(name); } static void dir_align(yasm_object *object, yasm_valparamhead *valparams, - yasm_valparamhead *objext_valparams, unsigned long line) + yasm_valparamhead *objext_valparams, unsigned long line) { yasm_valparam *vp = yasm_vps_first(valparams); yasm_expr *boundval = yasm_vp_expr(vp, object->symtab, line); @@ -1540,102 +1105,75 @@ dir_align(yasm_object *object, yasm_valparamhead *valparams, * intelligent! */ if (boundval && (boundintn = yasm_expr_get_intnum(&boundval, 0))) { - unsigned long boundint = yasm_intnum_get_uint(boundintn); + unsigned long boundint = yasm_intnum_get_uint(boundintn); - /* Alignments must be a power of two. */ - if (is_exp2(boundint)) { - if (boundint > yasm_section_get_align(object->cur_section)) - yasm_section_set_align(object->cur_section, boundint, line); - } + /* Alignments must be a power of two. */ + if (is_exp2(boundint)) { + if (boundint > yasm_section_get_align(object->cur_section)) + yasm_section_set_align(object->cur_section, boundint, line); + } } /* As this directive is called only when nop is used as fill, always * use arch (nop) fill. */ yasm_section_bcs_append(object->cur_section, - yasm_bc_create_align(boundval, NULL, NULL, - /*yasm_section_is_code(object->cur_section) ?*/ - yasm_arch_get_fill(object->arch)/* : NULL*/, - line)); + yasm_bc_create_align(boundval, NULL, NULL, + /*yasm_section_is_code(object->cur_section) ?*/ + yasm_arch_get_fill(object->arch)/* : NULL*/, + line)); } static void nasm_parser_directive(yasm_parser_nasm *parser_nasm, const char *name, - yasm_valparamhead *valparams, - yasm_valparamhead *objext_valparams) + yasm_valparamhead *valparams, + yasm_valparamhead *objext_valparams) { unsigned long line = cur_line; yasm_valparam *vp; if (!yasm_object_directive(p_object, name, "nasm", valparams, - objext_valparams, line)) - ; + objext_valparams, line)) + ; else if (yasm__strcasecmp(name, "absolute") == 0) { - if (!valparams) { - yasm_error_set(YASM_ERROR_SYNTAX, - N_("directive `%s' requires an argument"), - "absolute"); - } else { - vp = yasm_vps_first(valparams); - if (parser_nasm->absstart) - yasm_expr_destroy(parser_nasm->absstart); - if (parser_nasm->abspos) - yasm_expr_destroy(parser_nasm->abspos); - parser_nasm->absstart = yasm_vp_expr(vp, p_object->symtab, line); - parser_nasm->abspos = yasm_expr_copy(parser_nasm->absstart); - cursect = NULL; - parser_nasm->prev_bc = NULL; - } + vp = yasm_vps_first(valparams); + if (parser_nasm->absstart) + yasm_expr_destroy(parser_nasm->absstart); + if (parser_nasm->abspos) + yasm_expr_destroy(parser_nasm->abspos); + parser_nasm->absstart = yasm_vp_expr(vp, p_object->symtab, line); + parser_nasm->abspos = yasm_expr_copy(parser_nasm->absstart); + cursect = NULL; + parser_nasm->prev_bc = NULL; } else if (yasm__strcasecmp(name, "align") == 0) { - /* Really, we shouldn't end up with an align directive in an absolute + /* Really, we shouldn't end up with an align directive in an absolute * section (as it's supposed to be only used for nop fill), but handle - * it gracefully anyway. - */ - if (parser_nasm->abspos) { - yasm_expr *boundval, *e; - vp = yasm_vps_first(valparams); - boundval = yasm_vp_expr(vp, p_object->symtab, line); - e = yasm_expr_create_tree( - yasm_expr_create_tree(yasm_expr_copy(parser_nasm->absstart), - YASM_EXPR_SUB, - yasm_expr_copy(parser_nasm->abspos), - cur_line), - YASM_EXPR_AND, - yasm_expr_create(YASM_EXPR_SUB, yasm_expr_expr(boundval), - yasm_expr_int(yasm_intnum_create_uint(1)), - cur_line), - cur_line); - parser_nasm->abspos = yasm_expr_create_tree( - parser_nasm->abspos, YASM_EXPR_ADD, e, cur_line); + * it gracefully anyway. + */ + if (parser_nasm->abspos) { + yasm_expr *boundval, *e; + vp = yasm_vps_first(valparams); + boundval = yasm_vp_expr(vp, p_object->symtab, line); + e = yasm_expr_create_tree( + yasm_expr_create_tree(yasm_expr_copy(parser_nasm->absstart), + YASM_EXPR_SUB, + yasm_expr_copy(parser_nasm->abspos), + cur_line), + YASM_EXPR_AND, + yasm_expr_create(YASM_EXPR_SUB, yasm_expr_expr(boundval), + yasm_expr_int(yasm_intnum_create_uint(1)), + cur_line), + cur_line); + parser_nasm->abspos = yasm_expr_create_tree( + parser_nasm->abspos, YASM_EXPR_ADD, e, cur_line); } else if (!valparams) { yasm_error_set(YASM_ERROR_SYNTAX, N_("directive `%s' requires an argument"), "align"); - } else - dir_align(p_object, valparams, objext_valparams, line); - } else if (yasm__strcasecmp(name, "default") == 0) { - if (!valparams) - ; - else { - vp = yasm_vps_first(valparams); - while (vp) { - const char *id = yasm_vp_id(vp); - if (id) { - if (yasm__strcasecmp(id, "rel") == 0) - yasm_arch_set_var(p_object->arch, "default_rel", 1); - else if (yasm__strcasecmp(id, "abs") == 0) - yasm_arch_set_var(p_object->arch, "default_rel", 0); - else - yasm_error_set(YASM_ERROR_SYNTAX, - N_("unrecognized default `%s'"), id); - } else - yasm_error_set(YASM_ERROR_SYNTAX, - N_("unrecognized default value")); - vp = yasm_vps_next(vp); - } - } + } else + dir_align(p_object, valparams, objext_valparams, line); } else - yasm_error_set(YASM_ERROR_SYNTAX, N_("unrecognized directive `%s'"), - name); + yasm_error_set(YASM_ERROR_SYNTAX, N_("unrecognized directive `%s'"), + name); if (parser_nasm->absstart && cursect) { /* We switched to a new section. Get out of absolute section mode. */ @@ -1653,29 +1191,7 @@ nasm_parser_directive(yasm_parser_nasm *parser_nasm, const char *name, } if (valparams) - yasm_vps_delete(valparams); + yasm_vps_delete(valparams); if (objext_valparams) - yasm_vps_delete(objext_valparams); -} - -yasm_bytecode * -gas_intel_syntax_parse_instr(yasm_parser_nasm *parser_nasm, unsigned char *instr) -{ - yasm_bytecode *bc = NULL; - char *sinstr = (char *) instr; - - parser_nasm->s.bot = instr; - parser_nasm->s.tok = instr; - parser_nasm->s.ptr = instr; - parser_nasm->s.cur = instr; - parser_nasm->s.lim = instr + strlen(sinstr) + 1; - parser_nasm->s.top = parser_nasm->s.lim; - parser_nasm->peek_token = NONE; - - get_next_token(); - if (!is_eol()) { - bc = parse_instr(parser_nasm); - } - - return bc; + yasm_vps_delete(objext_valparams); } diff --git a/modules/parsers/nasm/nasm-parser-struct.h b/modules/parsers/nasm/nasm-parser-struct.h deleted file mode 100644 index b9223510..00000000 --- a/modules/parsers/nasm/nasm-parser-struct.h +++ /dev/null @@ -1,85 +0,0 @@ -/* - * NASM-compatible parser struct header file - * - * Copyright (C) 2002-2007 Peter Johnson - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND OTHER CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR OTHER CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -#ifndef YASM_NASM_PARSER_STRUCT_H -#define YASM_NASM_PARSER_STRUCT_H - -typedef union { - unsigned int int_info; - char *str_val; - yasm_intnum *intn; - yasm_floatnum *flt; - yasm_bytecode *bc; - uintptr_t arch_data; - struct { - char *contents; - size_t len; - } str; -} nasm_yystype; - -typedef struct yasm_parser_nasm { - int tasm; - int masm; - - /*@only@*/ yasm_object *object; - - /* last "base" label for local (.) labels */ - /*@null@*/ char *locallabel_base; - size_t locallabel_base_len; - - /*@dependent@*/ yasm_preproc *preproc; - /*@dependent@*/ yasm_errwarns *errwarns; - - /*@dependent@*/ yasm_linemap *linemap; - - /*@null@*/ yasm_bytecode *prev_bc; - - int save_input; - - yasm_scanner s; - int state; - - int token; /* enum tokentype or any character */ - nasm_yystype tokval; - char tokch; /* first character of token */ - - /* one token of lookahead; used sparingly */ - int peek_token; /* NONE if none */ - nasm_yystype peek_tokval; - char peek_tokch; - - /* Starting point of the absolute section. NULL if not in an absolute - * section. - */ - /*@null@*/ yasm_expr *absstart; - - /* Current location inside an absolute section (including the start). - * NULL if not in an absolute section. - */ - /*@null@*/ yasm_expr *abspos; -} yasm_parser_nasm; - -#endif diff --git a/modules/parsers/nasm/nasm-parser.c b/modules/parsers/nasm/nasm-parser.c index bd166929..5ca7dcb9 100644 --- a/modules/parsers/nasm/nasm-parser.c +++ b/modules/parsers/nasm/nasm-parser.c @@ -25,24 +25,26 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include +/*@unused@*/ RCSID("$Id$"); +#define YASM_LIB_INTERNAL #include #include "nasm-parser.h" static void -nasm_do_parse(yasm_object *object, yasm_preproc *pp, int save_input, - yasm_linemap *linemap, yasm_errwarns *errwarns, int tasm) +nasm_parser_do_parse(yasm_object *object, yasm_preproc *pp, FILE *f, + int save_input, yasm_linemap *linemap, + yasm_errwarns *errwarns) { yasm_parser_nasm parser_nasm; - parser_nasm.tasm = tasm; - parser_nasm.masm = 0; - parser_nasm.object = object; parser_nasm.linemap = linemap; + parser_nasm.in = f; + parser_nasm.locallabel_base = (char *)NULL; parser_nasm.locallabel_base_len = 0; @@ -52,6 +54,7 @@ nasm_do_parse(yasm_object *object, yasm_preproc *pp, int save_input, parser_nasm.prev_bc = yasm_section_bcs_first(object->cur_section); parser_nasm.save_input = save_input; + parser_nasm.save_last = 0; parser_nasm.peek_token = NONE; @@ -63,28 +66,21 @@ nasm_do_parse(yasm_object *object, yasm_preproc *pp, int save_input, parser_nasm.state = INITIAL; + /* yacc debugging, needs YYDEBUG set in bison.y.in to work */ + /* nasm_parser_debug = 1; */ + nasm_parser_parse(&parser_nasm); - /*yasm_scanner_delete(&parser_nasm.s);*/ + yasm_scanner_delete(&parser_nasm.s); /* Free locallabel base if necessary */ if (parser_nasm.locallabel_base) - yasm_xfree(parser_nasm.locallabel_base); + yasm_xfree(parser_nasm.locallabel_base); /* Check for undefined symbols */ yasm_symtab_parser_finalize(object->symtab, 0, errwarns); } -static void -nasm_parser_do_parse(yasm_object *object, yasm_preproc *pp, - int save_input, yasm_linemap *linemap, - yasm_errwarns *errwarns) -{ - nasm_do_parse(object, pp, save_input, linemap, errwarns, 0); -} - -#include "nasm-macros.c" - /* Define valid preprocessors to use with this parser */ static const char *nasm_parser_preproc_keywords[] = { "raw", @@ -92,49 +88,11 @@ static const char *nasm_parser_preproc_keywords[] = { NULL }; -static const yasm_stdmac nasm_parser_stdmacs[] = { - { "nasm", "nasm", nasm_standard_mac }, - { NULL, NULL, NULL } -}; - /* Define parser structure -- see parser.h for details */ yasm_parser_module yasm_nasm_LTX_parser = { "NASM-compatible parser", "nasm", nasm_parser_preproc_keywords, "nasm", - nasm_parser_stdmacs, nasm_parser_do_parse }; - -static void -tasm_parser_do_parse(yasm_object *object, yasm_preproc *pp, - int save_input, yasm_linemap *linemap, - yasm_errwarns *errwarns) -{ - yasm_symtab_set_case_sensitive(object->symtab, 0); - yasm_warn_disable(YASM_WARN_IMPLICIT_SIZE_OVERRIDE); - nasm_do_parse(object, pp, save_input, linemap, errwarns, 1); -} - -/* Define valid preprocessors to use with this parser */ -static const char *tasm_parser_preproc_keywords[] = { - "raw", - "tasm", - NULL -}; - -static const yasm_stdmac tasm_parser_stdmacs[] = { - { "tasm", "tasm", nasm_standard_mac }, - { NULL, NULL, NULL } -}; - -/* Define parser structure -- see parser.h for details */ -yasm_parser_module yasm_tasm_LTX_parser = { - "TASM-compatible parser", - "tasm", - tasm_parser_preproc_keywords, - "tasm", - tasm_parser_stdmacs, - tasm_parser_do_parse -}; diff --git a/modules/parsers/nasm/nasm-parser.h b/modules/parsers/nasm/nasm-parser.h index dc19cfb5..d2b078e2 100644 --- a/modules/parsers/nasm/nasm-parser.h +++ b/modules/parsers/nasm/nasm-parser.h @@ -1,4 +1,4 @@ -/* +/* $Id$ * NASM-compatible parser header file * * Copyright (C) 2002-2007 Peter Johnson @@ -27,9 +27,7 @@ #ifndef YASM_NASM_PARSER_H #define YASM_NASM_PARSER_H -#include "nasm-parser-struct.h" - -#define YYCTYPE unsigned char +#define YYCTYPE unsigned char #define MAX_SAVED_LINE_LEN 80 @@ -40,81 +38,124 @@ enum tokentype { FILENAME, STRING, SIZE_OVERRIDE, - OFFSET, DECLARE_DATA, RESERVE_SPACE, - LABEL, INCBIN, EQU, TIMES, - DUP, SEG, WRT, - ABS, - REL, NOSPLIT, STRICT, INSN, PREFIX, REG, - REGGROUP, SEGREG, TARGETMOD, LEFT_OP, RIGHT_OP, - LOW, - HIGH, SIGNDIV, SIGNMOD, START_SECTION_ID, ID, LOCAL_ID, SPECIAL_ID, - NONLOCAL_ID, LINE, - NONE /* special token for lookahead */ + NONE /* special token for lookahead */ }; -enum nasm_parser_state { - INITIAL, - DIRECTIVE, - SECTION_DIRECTIVE, - DIRECTIVE2, - LINECHG, - LINECHG2, - INSTRUCTION -}; +typedef union { + unsigned int int_info; + char *str_val; + yasm_intnum *intn; + yasm_floatnum *flt; + uintptr_t arch_data[4]; + struct { + char *contents; + size_t len; + } str; +} yystype; +#define YYSTYPE yystype -#define YYSTYPE nasm_yystype +typedef struct yasm_parser_nasm { + FILE *in; + int debug; + + /*@only@*/ yasm_object *object; + + /* last "base" label for local (.) labels */ + /*@null@*/ char *locallabel_base; + size_t locallabel_base_len; + + /*@dependent@*/ yasm_preproc *preproc; + /*@dependent@*/ yasm_errwarns *errwarns; + + /*@dependent@*/ yasm_linemap *linemap; + + /*@null@*/ yasm_bytecode *prev_bc; + + int save_input; + YYCTYPE save_line[2][MAX_SAVED_LINE_LEN]; + int save_last; + + yasm_scanner s; + enum { + INITIAL, + DIRECTIVE, + SECTION_DIRECTIVE, + DIRECTIVE2, + LINECHG, + LINECHG2, + INSTRUCTION + } state; + + int token; /* enum tokentype or any character */ + yystype tokval; + char tokch; /* first character of token */ + + /* one token of lookahead; used sparingly */ + int peek_token; /* NONE if none */ + yystype peek_tokval; + char peek_tokch; + + /* Starting point of the absolute section. NULL if not in an absolute + * section. + */ + /*@null@*/ yasm_expr *absstart; + + /* Current location inside an absolute section (including the start). + * NULL if not in an absolute section. + */ + /*@null@*/ yasm_expr *abspos; +} yasm_parser_nasm; /* shorter access names to commonly used parser_nasm fields */ -#define p_object (parser_nasm->object) -#define p_symtab (parser_nasm->object->symtab) -#define cursect (parser_nasm->object->cur_section) -#define curtok (parser_nasm->token) -#define curval (parser_nasm->tokval) +#define p_object (parser_nasm->object) +#define p_symtab (parser_nasm->object->symtab) +#define cursect (parser_nasm->object->cur_section) +#define curtok (parser_nasm->token) +#define curval (parser_nasm->tokval) -#define INTNUM_val (curval.intn) -#define FLTNUM_val (curval.flt) -#define DIRECTIVE_NAME_val (curval.str_val) -#define FILENAME_val (curval.str_val) -#define STRING_val (curval.str) -#define SIZE_OVERRIDE_val (curval.int_info) -#define DECLARE_DATA_val (curval.int_info) -#define RESERVE_SPACE_val (curval.int_info) -#define INSN_val (curval.bc) -#define PREFIX_val (curval.arch_data) -#define REG_val (curval.arch_data) -#define REGGROUP_val (curval.arch_data) -#define SEGREG_val (curval.arch_data) -#define TARGETMOD_val (curval.arch_data) -#define ID_val (curval.str_val) +#define INTNUM_val (curval.intn) +#define FLTNUM_val (curval.flt) +#define DIRECTIVE_NAME_val (curval.str_val) +#define FILENAME_val (curval.str_val) +#define STRING_val (curval.str) +#define SIZE_OVERRIDE_val (curval.int_info) +#define DECLARE_DATA_val (curval.int_info) +#define RESERVE_SPACE_val (curval.int_info) +#define INSN_val (curval.arch_data) +#define PREFIX_val (curval.arch_data) +#define REG_val (curval.arch_data) +#define SEGREG_val (curval.arch_data) +#define TARGETMOD_val (curval.arch_data) +#define ID_val (curval.str_val) -#define cur_line (yasm_linemap_get_current(parser_nasm->linemap)) +#define cur_line (yasm_linemap_get_current(parser_nasm->linemap)) -#define p_expr_new_tree(l,o,r) yasm_expr_create_tree(l,o,r,cur_line) -#define p_expr_new_branch(o,r) yasm_expr_create_branch(o,r,cur_line) -#define p_expr_new_ident(r) yasm_expr_create_ident(r,cur_line) +#define p_expr_new_tree(l,o,r) yasm_expr_create_tree(l,o,r,cur_line) +#define p_expr_new_branch(o,r) yasm_expr_create_branch(o,r,cur_line) +#define p_expr_new_ident(r) yasm_expr_create_ident(r,cur_line) void nasm_parser_parse(yasm_parser_nasm *parser_nasm); void nasm_parser_cleanup(yasm_parser_nasm *parser_nasm); diff --git a/modules/parsers/nasm/nasm-std.mac b/modules/parsers/nasm/nasm-std.mac deleted file mode 100644 index bb6e5c4e..00000000 --- a/modules/parsers/nasm/nasm-std.mac +++ /dev/null @@ -1,109 +0,0 @@ -; Standard macro set for NASM -*- nasm -*- - -; Note that although some user-level forms of directives are defined -; here, not all of them are: the user-level form of a format-specific -; directive should be defined in the module for that directive. - -; These two need to be defined, though the actual definitions will -; be constantly updated during preprocessing. -%define __FILE__ -%define __LINE__ - -%define __SECT__ [section .text] ; it ought to be defined, even if as nothing - -%imacro section 1+.nolist -%define __SECT__ [section %1] - __SECT__ -%endmacro -%imacro segment 1+.nolist -%define __SECT__ [segment %1] - __SECT__ -%endmacro - -%imacro absolute 1+.nolist -%define __SECT__ [absolute %1] - __SECT__ -%endmacro - -%imacro struc 1-2.nolist 0 -%push struc -%define %$strucname %1 -[absolute %2] -%$strucname: ; allow definition of `.member' to work sanely -%endmacro -%imacro endstruc 0.nolist -%{$strucname}_size EQU $ - %$strucname -%pop -__SECT__ -%endmacro - -%imacro istruc 1.nolist -%push istruc -%define %$strucname %1 -%$strucstart: -%endmacro -%imacro at 1-2+.nolist - times %1-($-%$strucstart) db 0 - %2 -%endmacro -%imacro iend 0.nolist - times %{$strucname}_size-($-%$strucstart) db 0 -%pop -%endmacro - -%imacro align 1-2+.nolist nop -%ifidni %2,nop - [align %1] -%else - times ($$-$) & ((%1)-1) %2 -%endif -%endmacro -%imacro alignb 1-2+.nolist resb 1 - times ($$-$) & ((%1)-1) %2 -%endmacro - -%imacro extern 1-*.nolist -%rep %0 -[extern %1] -%rotate 1 -%endrep -%endmacro - -%imacro bits 1+.nolist -[bits %1] -%endmacro - -%imacro use16 0.nolist -[bits 16] -%endmacro -%imacro use32 0.nolist -[bits 32] -%endmacro -%imacro use64 0.nolist -[bits 64] -%endmacro - -%imacro global 1-*.nolist -%rep %0 -[global %1] -%rotate 1 -%endrep -%endmacro - -%imacro common 1-*.nolist -%rep %0 -[common %1] -%rotate 1 -%endrep -%endmacro - -%imacro cpu 1+.nolist -[cpu %1] -%endmacro - -%imacro default 1+.nolist -[default %1] -%endmacro - -; NASM compatibility shim -%define __OUTPUT_FORMAT__ __YASM_OBJFMT__ diff --git a/modules/parsers/nasm/nasm-token.re b/modules/parsers/nasm/nasm-token.re index b2110ce9..a534442a 100644 --- a/modules/parsers/nasm/nasm-token.re +++ b/modules/parsers/nasm/nasm-token.re @@ -27,29 +27,74 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include +RCSID("$Id$"); +#define YASM_LIB_INTERNAL #include #include "modules/parsers/nasm/nasm-parser.h" -#include "modules/preprocs/nasm/nasm.h" -#define YYCURSOR cursor -#define YYLIMIT (s->lim) -#define YYMARKER (s->ptr) -#define YYFILL(n) {} +#define BSIZE 8192 -#define RETURN(i) {s->cur = cursor; parser_nasm->tokch = s->tok[0]; \ - return i;} +#define YYCURSOR cursor +#define YYLIMIT (s->lim) +#define YYMARKER (s->ptr) +#define YYFILL(n) {fill(parser_nasm, &cursor);} -#define SCANINIT() {s->tok = cursor;} +#define RETURN(i) {s->cur = cursor; parser_nasm->tokch = s->tok[0]; \ + return i;} -#define TOK ((char *)s->tok) -#define TOKLEN (size_t)(cursor-s->tok) +#define SCANINIT() {s->tok = cursor;} +#define TOK ((char *)s->tok) +#define TOKLEN (size_t)(cursor-s->tok) + + +static size_t +fill_input(void *d, unsigned char *buf, size_t max) +{ + return yasm_preproc_input((yasm_preproc *)d, (char *)buf, max); +} + +static void +fill(yasm_parser_nasm *parser_nasm, YYCTYPE **cursor) +{ + yasm_scanner *s = &parser_nasm->s; + if (yasm_fill_helper(s, cursor, fill_input, parser_nasm->preproc) + && parser_nasm->save_input) { + int i; + YYCTYPE *saveline; + parser_nasm->save_last ^= 1; + saveline = parser_nasm->save_line[parser_nasm->save_last]; + /* save next line into cur_line */ + for (i=0; i<79 && &s->tok[i] < s->lim && s->tok[i] != '\n'; i++) + saveline[i] = s->tok[i]; + saveline[i] = '\0'; + } +} + +static YYCTYPE * +save_line(yasm_parser_nasm *parser_nasm, YYCTYPE *cursor) +{ + yasm_scanner *s = &parser_nasm->s; + int i = 0; + YYCTYPE *saveline; + + parser_nasm->save_last ^= 1; + saveline = parser_nasm->save_line[parser_nasm->save_last]; + + /* save next line into cur_line */ + if ((YYLIMIT - YYCURSOR) < 80) + YYFILL(80); + for (i=0; i<79 && &cursor[i] < s->lim && cursor[i] != '\n'; i++) + saveline[i] = cursor[i]; + saveline[i] = '\0'; + return cursor; +} /* starting size of string buffer */ -#define STRBUF_ALLOC_SIZE 128 +#define STRBUF_ALLOC_SIZE 128 /* string buffer used when parsing strings/character constants */ static YYCTYPE *strbuf = NULL; @@ -60,57 +105,16 @@ static size_t strbuf_size = 0; static int linechg_numcount; /*!re2c - any = [\001-\377]; + any = [\000-\377]; digit = [0-9]; iletter = [a-zA-Z]; - bindigit = [01_]; - octdigit = [0-7_]; - hexdigit = [0-9a-fA-F_]; + bindigit = [01]; + octdigit = [0-7]; + hexdigit = [0-9a-fA-F]; ws = [ \t\r]; quot = ["']; */ -static int -handle_dot_label(YYSTYPE *lvalp, char *tok, size_t toklen, size_t zeropos, - yasm_parser_nasm *parser_nasm) -{ - /* check for special non-local labels like ..start */ - if (tok[zeropos+1] == '.') { - lvalp->str_val = yasm__xstrndup(tok+zeropos+(parser_nasm->tasm?2:0), - toklen-zeropos-(parser_nasm->tasm?2:0)); - /* check for special non-local ..@label */ - if (lvalp->str_val[2] == '@') - return NONLOCAL_ID; - return SPECIAL_ID; - } - if (parser_nasm->masm && tok[zeropos] == '.') { - lvalp->str_val = yasm__xstrndup(tok + zeropos, toklen - zeropos); - return SPECIAL_ID; - } - if (parser_nasm->tasm && (!tasm_locals || - (tok[zeropos] == '.' && - tok[zeropos+1] != '@' && tok[zeropos+2] != '@'))) { - /* no locals on Tasm without the 'locals' directive */ - /* .foo is never local either, but .@@foo may be (local structure - * members) */ - lvalp->str_val = yasm__xstrndup(tok + zeropos, toklen - zeropos); - return SPECIAL_ID; - } - if (!parser_nasm->locallabel_base) { - lvalp->str_val = yasm__xstrndup(tok+zeropos, toklen-zeropos); - yasm_warn_set(YASM_WARN_GENERAL, - N_("no non-local label before `%s'"), - lvalp->str_val); - } else { - size_t len = toklen - zeropos + parser_nasm->locallabel_base_len; - lvalp->str_val = yasm_xmalloc(len + 1); - strcpy(lvalp->str_val, parser_nasm->locallabel_base); - strncat(lvalp->str_val, tok+zeropos, toklen-zeropos); - lvalp->str_val[len] = '\0'; - } - - return LOCAL_ID; -} int nasm_parser_lex(YYSTYPE *lvalp, yasm_parser_nasm *parser_nasm) @@ -118,618 +122,533 @@ nasm_parser_lex(YYSTYPE *lvalp, yasm_parser_nasm *parser_nasm) yasm_scanner *s = &parser_nasm->s; YYCTYPE *cursor = s->cur; YYCTYPE endch; - size_t count; + size_t count, len; YYCTYPE savech; /* Handle one token of lookahead */ if (parser_nasm->peek_token != NONE) { - int tok = parser_nasm->peek_token; - *lvalp = parser_nasm->peek_tokval; /* structure copy */ - parser_nasm->tokch = parser_nasm->peek_tokch; - parser_nasm->peek_token = NONE; - return tok; + int tok = parser_nasm->peek_token; + *lvalp = parser_nasm->peek_tokval; /* structure copy */ + parser_nasm->tokch = parser_nasm->peek_tokch; + parser_nasm->peek_token = NONE; + return tok; } - /* Catch EOL (EOF from the scanner perspective) */ + /* Catch EOF */ if (s->eof && cursor == s->eof) - return 0; + return 0; /* Jump to proper "exclusive" states */ switch (parser_nasm->state) { - case DIRECTIVE: - goto directive; - case SECTION_DIRECTIVE: - goto section_directive; - case DIRECTIVE2: - goto directive2; - case LINECHG: - goto linechg; - case LINECHG2: - goto linechg2; - default: - break; + case DIRECTIVE: + goto directive; + case SECTION_DIRECTIVE: + goto section_directive; + case DIRECTIVE2: + goto directive2; + case LINECHG: + goto linechg; + case LINECHG2: + goto linechg2; + default: + break; } scan: SCANINIT(); - if (*cursor == '\0') - goto endofinput; /*!re2c - /* standard decimal integer */ - digit+ { - savech = s->tok[TOKLEN]; - s->tok[TOKLEN] = '\0'; - lvalp->intn = yasm_intnum_create_dec(TOK); - s->tok[TOKLEN] = savech; - RETURN(INTNUM); - } - /* 10010011b - binary number */ + /* standard decimal integer */ + digit+ { + savech = s->tok[TOKLEN]; + s->tok[TOKLEN] = '\0'; + lvalp->intn = yasm_intnum_create_dec(TOK); + s->tok[TOKLEN] = savech; + RETURN(INTNUM); + } + /* 10010011b - binary number */ - [01] bindigit* 'b' { - s->tok[TOKLEN-1] = '\0'; /* strip off 'b' */ - lvalp->intn = yasm_intnum_create_bin(TOK); - RETURN(INTNUM); - } + bindigit+ 'b' { + s->tok[TOKLEN-1] = '\0'; /* strip off 'b' */ + lvalp->intn = yasm_intnum_create_bin(TOK); + RETURN(INTNUM); + } - /* 777q or 777o - octal number */ - [0-7] octdigit* [qQoO] { - s->tok[TOKLEN-1] = '\0'; /* strip off 'q' or 'o' */ - lvalp->intn = yasm_intnum_create_oct(TOK); - RETURN(INTNUM); - } + /* 777q or 777o - octal number */ + octdigit+ [qQoO] { + s->tok[TOKLEN-1] = '\0'; /* strip off 'q' or 'o' */ + lvalp->intn = yasm_intnum_create_oct(TOK); + RETURN(INTNUM); + } - /* 0AAh form of hexidecimal number */ - digit hexdigit* 'h' { - s->tok[TOKLEN-1] = '\0'; /* strip off 'h' */ - lvalp->intn = yasm_intnum_create_hex(TOK); - RETURN(INTNUM); - } + /* 0AAh form of hexidecimal number */ + digit hexdigit* 'h' { + s->tok[TOKLEN-1] = '\0'; /* strip off 'h' */ + lvalp->intn = yasm_intnum_create_hex(TOK); + RETURN(INTNUM); + } - /* $0AA and 0xAA forms of hexidecimal number */ - (("$" digit) | '0x') hexdigit+ { - savech = s->tok[TOKLEN]; - s->tok[TOKLEN] = '\0'; - if (s->tok[1] == 'x' || s->tok[1] == 'X') - /* skip 0 and x */ - lvalp->intn = yasm_intnum_create_hex(TOK+2); - else - /* don't skip 0 */ - lvalp->intn = yasm_intnum_create_hex(TOK+1); - s->tok[TOKLEN] = savech; - RETURN(INTNUM); - } + /* $0AA and 0xAA forms of hexidecimal number */ + (("$" digit) | "0x") hexdigit+ { + savech = s->tok[TOKLEN]; + s->tok[TOKLEN] = '\0'; + if (s->tok[1] == 'x') + /* skip 0 and x */ + lvalp->intn = yasm_intnum_create_hex(TOK+2); + else + /* don't skip 0 */ + lvalp->intn = yasm_intnum_create_hex(TOK+1); + s->tok[TOKLEN] = savech; + RETURN(INTNUM); + } - /* floating point value */ - digit+ "." digit* ('e' [-+]? digit+)? { - savech = s->tok[TOKLEN]; - s->tok[TOKLEN] = '\0'; - lvalp->flt = yasm_floatnum_create(TOK); - s->tok[TOKLEN] = savech; - RETURN(FLTNUM); - } + /* floating point value */ + digit+ "." digit* ('e' [-+]? digit+)? { + savech = s->tok[TOKLEN]; + s->tok[TOKLEN] = '\0'; + lvalp->flt = yasm_floatnum_create(TOK); + s->tok[TOKLEN] = savech; + RETURN(FLTNUM); + } - /* string/character constant values */ - quot { - endch = s->tok[0]; - goto stringconst; - } + /* string/character constant values */ + quot { + endch = s->tok[0]; + goto stringconst; + } - /* %line linenum+lineinc filename */ - "%line" { - parser_nasm->state = LINECHG; - linechg_numcount = 0; - RETURN(LINE); - } + /* %line linenum+lineinc filename */ + "%line" { + parser_nasm->state = LINECHG; + linechg_numcount = 0; + RETURN(LINE); + } - /* size specifiers */ - 'byte' { lvalp->int_info = 8; RETURN(SIZE_OVERRIDE); } - 'hword' { - lvalp->int_info = yasm_arch_wordsize(p_object->arch)/2; - RETURN(SIZE_OVERRIDE); - } - 'word' { - lvalp->int_info = yasm_arch_wordsize(p_object->arch); - RETURN(SIZE_OVERRIDE); - } - 'dword' | 'long' { - lvalp->int_info = yasm_arch_wordsize(p_object->arch)*2; - RETURN(SIZE_OVERRIDE); - } - 'qword' { - lvalp->int_info = yasm_arch_wordsize(p_object->arch)*4; - RETURN(SIZE_OVERRIDE); - } - 'tword' { lvalp->int_info = 80; RETURN(SIZE_OVERRIDE); } - 'dqword' { - lvalp->int_info = yasm_arch_wordsize(p_object->arch)*8; - RETURN(SIZE_OVERRIDE); - } - 'oword' { - lvalp->int_info = yasm_arch_wordsize(p_object->arch)*8; - RETURN(SIZE_OVERRIDE); - } - 'yword' { - lvalp->int_info = 256; - RETURN(SIZE_OVERRIDE); - } + /* size specifiers */ + 'byte' { lvalp->int_info = 8; RETURN(SIZE_OVERRIDE); } + 'hword' { + lvalp->int_info = yasm_arch_wordsize(p_object->arch)/2; + RETURN(SIZE_OVERRIDE); + } + 'word' { + lvalp->int_info = yasm_arch_wordsize(p_object->arch); + RETURN(SIZE_OVERRIDE); + } + 'dword' | 'long' { + lvalp->int_info = yasm_arch_wordsize(p_object->arch)*2; + RETURN(SIZE_OVERRIDE); + } + 'qword' { + lvalp->int_info = yasm_arch_wordsize(p_object->arch)*4; + RETURN(SIZE_OVERRIDE); + } + 'tword' { lvalp->int_info = 80; RETURN(SIZE_OVERRIDE); } + 'dqword' { + lvalp->int_info = yasm_arch_wordsize(p_object->arch)*8; + RETURN(SIZE_OVERRIDE); + } - /* pseudo-instructions */ - 'db' { - lvalp->int_info = 8; - parser_nasm->state = INSTRUCTION; - RETURN(DECLARE_DATA); - } - 'dhw' { - lvalp->int_info = yasm_arch_wordsize(p_object->arch)/2; - parser_nasm->state = INSTRUCTION; - RETURN(DECLARE_DATA); - } - 'dw' { - lvalp->int_info = yasm_arch_wordsize(p_object->arch); - parser_nasm->state = INSTRUCTION; - RETURN(DECLARE_DATA); - } - 'dd' { - lvalp->int_info = yasm_arch_wordsize(p_object->arch)*2; - parser_nasm->state = INSTRUCTION; - RETURN(DECLARE_DATA); - } - 'dq' { - lvalp->int_info = yasm_arch_wordsize(p_object->arch)*4; - parser_nasm->state = INSTRUCTION; - RETURN(DECLARE_DATA); - } - 'dt' { - lvalp->int_info = 80; - parser_nasm->state = INSTRUCTION; - RETURN(DECLARE_DATA); - } - 'ddq' { - lvalp->int_info = yasm_arch_wordsize(p_object->arch)*8; - parser_nasm->state = INSTRUCTION; - RETURN(DECLARE_DATA); - } - 'do' { - lvalp->int_info = yasm_arch_wordsize(p_object->arch)*8; - parser_nasm->state = INSTRUCTION; - RETURN(DECLARE_DATA); - } - 'dy' { - lvalp->int_info = 256; - parser_nasm->state = INSTRUCTION; - RETURN(DECLARE_DATA); - } + /* pseudo-instructions */ + 'db' { lvalp->int_info = 8; RETURN(DECLARE_DATA); } + 'dhw' { + lvalp->int_info = yasm_arch_wordsize(p_object->arch)/2; + RETURN(DECLARE_DATA); + } + 'dw' { + lvalp->int_info = yasm_arch_wordsize(p_object->arch); + RETURN(DECLARE_DATA); + } + 'dd' { + lvalp->int_info = yasm_arch_wordsize(p_object->arch)*2; + RETURN(DECLARE_DATA); + } + 'dq' { + lvalp->int_info = yasm_arch_wordsize(p_object->arch)*4; + RETURN(DECLARE_DATA); + } + 'dt' { lvalp->int_info = 80; RETURN(DECLARE_DATA); } + 'ddq' { + lvalp->int_info = yasm_arch_wordsize(p_object->arch)*8; + RETURN(DECLARE_DATA); + } - 'resb' { - lvalp->int_info = 8; - parser_nasm->state = INSTRUCTION; - RETURN(RESERVE_SPACE); - } - 'reshw' { - lvalp->int_info = yasm_arch_wordsize(p_object->arch)/2; - parser_nasm->state = INSTRUCTION; - RETURN(RESERVE_SPACE); - } - 'resw' { - lvalp->int_info = yasm_arch_wordsize(p_object->arch); - parser_nasm->state = INSTRUCTION; - RETURN(RESERVE_SPACE); - } - 'resd' { - lvalp->int_info = yasm_arch_wordsize(p_object->arch)*2; - parser_nasm->state = INSTRUCTION; - RETURN(RESERVE_SPACE); - } - 'resq' { - lvalp->int_info = yasm_arch_wordsize(p_object->arch)*4; - parser_nasm->state = INSTRUCTION; - RETURN(RESERVE_SPACE); - } - 'rest' { - lvalp->int_info = 80; - parser_nasm->state = INSTRUCTION; - RETURN(RESERVE_SPACE); - } - 'resdq' { - lvalp->int_info = yasm_arch_wordsize(p_object->arch)*8; - parser_nasm->state = INSTRUCTION; - RETURN(RESERVE_SPACE); - } - 'reso' { - lvalp->int_info = yasm_arch_wordsize(p_object->arch)*8; - parser_nasm->state = INSTRUCTION; - RETURN(RESERVE_SPACE); - } - 'resy' { - lvalp->int_info = 256; - parser_nasm->state = INSTRUCTION; - RETURN(RESERVE_SPACE); - } + 'resb' { lvalp->int_info = 8; RETURN(RESERVE_SPACE); } + 'reshw' { + lvalp->int_info = yasm_arch_wordsize(p_object->arch)/2; + RETURN(RESERVE_SPACE); + } + 'resw' { + lvalp->int_info = yasm_arch_wordsize(p_object->arch); + RETURN(RESERVE_SPACE); + } + 'resd' { + lvalp->int_info = yasm_arch_wordsize(p_object->arch)*2; + RETURN(RESERVE_SPACE); + } + 'resq' { + lvalp->int_info = yasm_arch_wordsize(p_object->arch)*4; + RETURN(RESERVE_SPACE); + } + 'rest' { lvalp->int_info = 80; RETURN(RESERVE_SPACE); } + 'resdq' { + lvalp->int_info = yasm_arch_wordsize(p_object->arch)*8; + RETURN(RESERVE_SPACE); + } - 'incbin' { RETURN(INCBIN); } + 'incbin' { RETURN(INCBIN); } - 'equ' { RETURN(EQU); } + 'equ' { RETURN(EQU); } - 'times' { RETURN(TIMES); } + 'times' { RETURN(TIMES); } - 'seg' { RETURN(SEG); } - 'wrt' { RETURN(WRT); } + 'seg' { RETURN(SEG); } + 'wrt' { RETURN(WRT); } - 'abs' { RETURN(ABS); } - 'rel' { RETURN(REL); } + 'nosplit' { RETURN(NOSPLIT); } + 'strict' { RETURN(STRICT); } - 'nosplit' { RETURN(NOSPLIT); } - 'strict' { RETURN(STRICT); } + /* operators */ + "<<" { RETURN(LEFT_OP); } + ">>" { RETURN(RIGHT_OP); } + "//" { RETURN(SIGNDIV); } + "%%" { RETURN(SIGNMOD); } + "$$" { RETURN(START_SECTION_ID); } + [-+|^*&/%~$():=,\[] { RETURN(s->tok[0]); } + "]" { RETURN(s->tok[0]); } - /* operators */ - "<<" { RETURN(LEFT_OP); } - ">>" { RETURN(RIGHT_OP); } - "//" { RETURN(SIGNDIV); } - "%%" { RETURN(SIGNMOD); } - "$$" { RETURN(START_SECTION_ID); } - [-+|^*&/%~$():=,\[?] { RETURN(s->tok[0]); } - "]" { RETURN(s->tok[0]); } + /* special non-local ..@label and labels like ..start */ + ".." [a-zA-Z0-9_$#@~.?]+ { + lvalp->str_val = yasm__xstrndup(TOK, TOKLEN); + RETURN(SPECIAL_ID); + } - /* local label (.label) */ - ("." | "@@") [a-zA-Z0-9_$#@~.?]+ { - RETURN(handle_dot_label(lvalp, TOK, TOKLEN, 0, parser_nasm)); - } + /* local label (.label) */ + "." [a-zA-Z0-9_$#@~?][a-zA-Z0-9_$#@~.?]* { + if (!parser_nasm->locallabel_base) { + lvalp->str_val = yasm__xstrndup(TOK, TOKLEN); + yasm_warn_set(YASM_WARN_GENERAL, + N_("no non-local label before `%s'"), + lvalp->str_val); + } else { + len = TOKLEN + parser_nasm->locallabel_base_len; + lvalp->str_val = yasm_xmalloc(len + 1); + strcpy(lvalp->str_val, parser_nasm->locallabel_base); + strncat(lvalp->str_val, TOK, TOKLEN); + lvalp->str_val[len] = '\0'; + } - /* forced identifier */ - "$" [a-zA-Z0-9_$#@~.?]+ { - if (TOK[1] == '.' || - (parser_nasm->tasm && TOK[1] == '@' && TOK[2] == '@')) { - /* handle like .label */ - RETURN(handle_dot_label(lvalp, TOK, TOKLEN, 1, parser_nasm)); - } - lvalp->str_val = yasm__xstrndup(TOK+1, TOKLEN-1); - RETURN(ID); - } + RETURN(LOCAL_ID); + } - /* identifier that may be a register, instruction, etc. */ - [a-zA-Z_?@][a-zA-Z0-9_$#@~.?]* { - savech = s->tok[TOKLEN]; - s->tok[TOKLEN] = '\0'; - if (parser_nasm->state != INSTRUCTION) { - uintptr_t prefix; - switch (yasm_arch_parse_check_insnprefix - (p_object->arch, TOK, TOKLEN, cur_line, &lvalp->bc, - &prefix)) { - case YASM_ARCH_INSN: - parser_nasm->state = INSTRUCTION; - s->tok[TOKLEN] = savech; - RETURN(INSN); - case YASM_ARCH_PREFIX: - lvalp->arch_data = prefix; - s->tok[TOKLEN] = savech; - RETURN(PREFIX); - default: - break; - } - } - switch (yasm_arch_parse_check_regtmod - (p_object->arch, TOK, TOKLEN, &lvalp->arch_data)) { - case YASM_ARCH_REG: - s->tok[TOKLEN] = savech; - RETURN(REG); - case YASM_ARCH_SEGREG: - s->tok[TOKLEN] = savech; - RETURN(SEGREG); - case YASM_ARCH_TARGETMOD: - s->tok[TOKLEN] = savech; - RETURN(TARGETMOD); - case YASM_ARCH_REGGROUP: - if (parser_nasm->masm) { - s->tok[TOKLEN] = savech; - RETURN(REGGROUP); - } - default: - break; - } - if (parser_nasm->masm) { - if (!yasm__strcasecmp(TOK, "offset")) { - s->tok[TOKLEN] = savech; - RETURN(OFFSET); - } - } else if (parser_nasm->tasm) { - if (!yasm__strcasecmp(TOK, "shl")) { - s->tok[TOKLEN] = savech; - RETURN(LEFT_OP); - } - if (!yasm__strcasecmp(TOK, "shr")) { - s->tok[TOKLEN] = savech; - RETURN(RIGHT_OP); - } - if (!yasm__strcasecmp(TOK, "and")) { - s->tok[TOKLEN] = savech; - RETURN('&'); - } - if (!yasm__strcasecmp(TOK, "or")) { - s->tok[TOKLEN] = savech; - RETURN('|'); - } - if (!yasm__strcasecmp(TOK, "not")) { - s->tok[TOKLEN] = savech; - RETURN('~'); - } - if (!yasm__strcasecmp(TOK, "low")) { - s->tok[TOKLEN] = savech; - RETURN(LOW); - } - if (!yasm__strcasecmp(TOK, "high")) { - s->tok[TOKLEN] = savech; - RETURN(HIGH); - } - if (!yasm__strcasecmp(TOK, "offset")) { - s->tok[TOKLEN] = savech; - RETURN(OFFSET); - } - if (!yasm__strcasecmp(TOK, "fword")) { - s->tok[TOKLEN] = savech; - lvalp->int_info = yasm_arch_wordsize(p_object->arch)*2; - RETURN(SIZE_OVERRIDE); - } - if (!yasm__strcasecmp(TOK, "df")) { - s->tok[TOKLEN] = savech; - lvalp->int_info = yasm_arch_wordsize(p_object->arch)*3; - parser_nasm->state = INSTRUCTION; - RETURN(DECLARE_DATA); - } - if (!yasm__strcasecmp(TOK, "label")) { - s->tok[TOKLEN] = savech; - RETURN(LABEL); - } - if (!yasm__strcasecmp(TOK, "dup")) { - s->tok[TOKLEN] = savech; - RETURN(DUP); - } - } - /* Propagate errors in case we got a warning from the arch */ - yasm_errwarn_propagate(parser_nasm->errwarns, cur_line); - /* Just an identifier, return as such. */ - s->tok[TOKLEN] = savech; - lvalp->str_val = yasm__xstrndup(TOK, TOKLEN); - RETURN(ID); - } + /* forced identifier */ + "$" [a-zA-Z0-9_$#@~.?]+ { + lvalp->str_val = yasm__xstrndup(TOK+1, TOKLEN-1); + RETURN(ID); + } - ";" (any \ [\000])* { goto scan; } + /* identifier that may be a register, instruction, etc. */ + [a-zA-Z_?][a-zA-Z0-9_$#@~.?]* { + savech = s->tok[TOKLEN]; + s->tok[TOKLEN] = '\0'; + if (parser_nasm->state != INSTRUCTION) + switch (yasm_arch_parse_check_insnprefix + (p_object->arch, lvalp->arch_data, TOK, TOKLEN)) { + case YASM_ARCH_INSN: + parser_nasm->state = INSTRUCTION; + s->tok[TOKLEN] = savech; + RETURN(INSN); + case YASM_ARCH_PREFIX: + s->tok[TOKLEN] = savech; + RETURN(PREFIX); + default: + break; + } + switch (yasm_arch_parse_check_regtmod + (p_object->arch, lvalp->arch_data, TOK, TOKLEN)) { + case YASM_ARCH_REG: + s->tok[TOKLEN] = savech; + RETURN(REG); + case YASM_ARCH_SEGREG: + s->tok[TOKLEN] = savech; + RETURN(SEGREG); + case YASM_ARCH_TARGETMOD: + s->tok[TOKLEN] = savech; + RETURN(TARGETMOD); + default: + s->tok[TOKLEN] = savech; + } + /* Propagate errors in case we got a warning from the arch */ + yasm_errwarn_propagate(parser_nasm->errwarns, cur_line); + /* Just an identifier, return as such. */ + lvalp->str_val = yasm__xstrndup(TOK, TOKLEN); + RETURN(ID); + } - ws+ { goto scan; } + ";" (any \ [\n])* { goto scan; } - [\000] { goto endofinput; } + ws+ { goto scan; } - any { - yasm_warn_set(YASM_WARN_UNREC_CHAR, - N_("ignoring unrecognized character `%s'"), - yasm__conv_unprint(s->tok[0])); - goto scan; - } + "\n" { + if (parser_nasm->save_input) + cursor = save_line(parser_nasm, cursor); + parser_nasm->state = INITIAL; + RETURN(s->tok[0]); + } + + any { + yasm_warn_set(YASM_WARN_UNREC_CHAR, + N_("ignoring unrecognized character `%s'"), + yasm__conv_unprint(s->tok[0])); + goto scan; + } */ /* %line linenum+lineinc filename */ linechg: SCANINIT(); - if (*cursor == '\0') - goto endofinput; /*!re2c - digit+ { - linechg_numcount++; - savech = s->tok[TOKLEN]; - s->tok[TOKLEN] = '\0'; - lvalp->intn = yasm_intnum_create_dec(TOK); - s->tok[TOKLEN] = savech; - RETURN(INTNUM); - } + digit+ { + linechg_numcount++; + savech = s->tok[TOKLEN]; + s->tok[TOKLEN] = '\0'; + lvalp->intn = yasm_intnum_create_dec(TOK); + s->tok[TOKLEN] = savech; + RETURN(INTNUM); + } - [\000] { goto endofinput; } + "\n" { + if (parser_nasm->save_input) + cursor = save_line(parser_nasm, cursor); + parser_nasm->state = INITIAL; + RETURN(s->tok[0]); + } - "+" { - RETURN(s->tok[0]); - } + "+" { + RETURN(s->tok[0]); + } - ws+ { - if (linechg_numcount == 2) { - parser_nasm->state = LINECHG2; - goto linechg2; - } - goto linechg; - } + ws+ { + if (linechg_numcount == 2) { + parser_nasm->state = LINECHG2; + goto linechg2; + } + goto linechg; + } - any { - yasm_warn_set(YASM_WARN_UNREC_CHAR, - N_("ignoring unrecognized character `%s'"), - yasm__conv_unprint(s->tok[0])); - goto linechg; - } + any { + yasm_warn_set(YASM_WARN_UNREC_CHAR, + N_("ignoring unrecognized character `%s'"), + yasm__conv_unprint(s->tok[0])); + goto linechg; + } */ linechg2: SCANINIT(); - if (*cursor == '\0') - goto endofinput; /*!re2c - [\000] { goto endofinput; } + "\n" { + if (parser_nasm->save_input) + cursor = save_line(parser_nasm, cursor); + parser_nasm->state = INITIAL; + RETURN(s->tok[0]); + } - "\r" { goto linechg2; } + "\r" { } - (any \ [\000])+ { - parser_nasm->state = LINECHG; - lvalp->str_val = yasm__xstrndup(TOK, TOKLEN); - RETURN(FILENAME); - } + (any \ [\r\n])+ { + parser_nasm->state = LINECHG; + lvalp->str_val = yasm__xstrndup(TOK, TOKLEN); + RETURN(FILENAME); + } */ /* directive: [name value] */ directive: SCANINIT(); - if (*cursor == '\0') - goto endofinput; /*!re2c - [\]\000] { goto endofinput; } + [\]\n] { + if (parser_nasm->save_input) + cursor = save_line(parser_nasm, cursor); + parser_nasm->state = INITIAL; + RETURN(s->tok[0]); + } - [a-zA-Z_][a-zA-Z_0-9]* { - lvalp->str_val = yasm__xstrndup(TOK, TOKLEN); - if (yasm__strcasecmp(lvalp->str_val, "section") == 0 || - yasm__strcasecmp(lvalp->str_val, "segment") == 0) - parser_nasm->state = SECTION_DIRECTIVE; - else - parser_nasm->state = DIRECTIVE2; - RETURN(DIRECTIVE_NAME); - } + [a-zA-Z_][a-zA-Z_0-9]* { + lvalp->str_val = yasm__xstrndup(TOK, TOKLEN); + if (yasm__strcasecmp(lvalp->str_val, "section") == 0 || + yasm__strcasecmp(lvalp->str_val, "segment") == 0) + parser_nasm->state = SECTION_DIRECTIVE; + else + parser_nasm->state = DIRECTIVE2; + RETURN(DIRECTIVE_NAME); + } - any { - yasm_warn_set(YASM_WARN_UNREC_CHAR, - N_("ignoring unrecognized character `%s'"), - yasm__conv_unprint(s->tok[0])); - goto directive; - } + any { + yasm_warn_set(YASM_WARN_UNREC_CHAR, + N_("ignoring unrecognized character `%s'"), + yasm__conv_unprint(s->tok[0])); + goto directive; + } */ /* section directive (the section name portion thereof) */ section_directive: SCANINIT(); - if (*cursor == '\0') - goto endofinput; /*!re2c - [a-zA-Z0-9_$#@~.?-]+ { - lvalp->str.contents = yasm__xstrndup(TOK, TOKLEN); - lvalp->str.len = TOKLEN; - parser_nasm->state = DIRECTIVE2; - RETURN(STRING); - } + [a-zA-Z0-9_$#@~.?-]+ { + lvalp->str.contents = yasm__xstrndup(TOK, TOKLEN); + lvalp->str.len = TOKLEN; + parser_nasm->state = DIRECTIVE2; + RETURN(STRING); + } - quot { - parser_nasm->state = DIRECTIVE2; - endch = s->tok[0]; - goto stringconst; - } + quot { + parser_nasm->state = DIRECTIVE2; + endch = s->tok[0]; + goto stringconst; + } - ws+ { - parser_nasm->state = DIRECTIVE2; - goto section_directive; - } + ws+ { + parser_nasm->state = DIRECTIVE2; + goto section_directive; + } - [\]\000] { goto endofinput; } + "]" { + parser_nasm->state = INITIAL; + RETURN(s->tok[0]); + } - any { - yasm_warn_set(YASM_WARN_UNREC_CHAR, - N_("ignoring unrecognized character `%s'"), - yasm__conv_unprint(s->tok[0])); - goto section_directive; - } + "\n" { + if (parser_nasm->save_input) + cursor = save_line(parser_nasm, cursor); + parser_nasm->state = INITIAL; + RETURN(s->tok[0]); + } + + any { + yasm_warn_set(YASM_WARN_UNREC_CHAR, + N_("ignoring unrecognized character `%s'"), + yasm__conv_unprint(s->tok[0])); + goto section_directive; + } */ /* inner part of directive */ directive2: SCANINIT(); - if (*cursor == '\0') - goto endofinput; /*!re2c - /* standard decimal integer */ - digit+ { - savech = s->tok[TOKLEN]; - s->tok[TOKLEN] = '\0'; - lvalp->intn = yasm_intnum_create_dec(TOK); - s->tok[TOKLEN] = savech; - RETURN(INTNUM); - } - /* 10010011b - binary number */ + /* standard decimal integer */ + digit+ { + savech = s->tok[TOKLEN]; + s->tok[TOKLEN] = '\0'; + lvalp->intn = yasm_intnum_create_dec(TOK); + s->tok[TOKLEN] = savech; + RETURN(INTNUM); + } + /* 10010011b - binary number */ - [01] bindigit* 'b' { - s->tok[TOKLEN-1] = '\0'; /* strip off 'b' */ - lvalp->intn = yasm_intnum_create_bin(TOK); - RETURN(INTNUM); - } + bindigit+ 'b' { + s->tok[TOKLEN-1] = '\0'; /* strip off 'b' */ + lvalp->intn = yasm_intnum_create_bin(TOK); + RETURN(INTNUM); + } - /* 777q or 777o - octal number */ - [0-7] octdigit* [qQoO] { - s->tok[TOKLEN-1] = '\0'; /* strip off 'q' or 'o' */ - lvalp->intn = yasm_intnum_create_oct(TOK); - RETURN(INTNUM); - } + /* 777q or 777o - octal number */ + octdigit+ [qQoO] { + s->tok[TOKLEN-1] = '\0'; /* strip off 'q' or 'o' */ + lvalp->intn = yasm_intnum_create_oct(TOK); + RETURN(INTNUM); + } - /* 0AAh form of hexidecimal number */ - digit hexdigit* 'h' { - s->tok[TOKLEN-1] = '\0'; /* strip off 'h' */ - lvalp->intn = yasm_intnum_create_hex(TOK); - RETURN(INTNUM); - } + /* 0AAh form of hexidecimal number */ + digit hexdigit* 'h' { + s->tok[TOKLEN-1] = '\0'; /* strip off 'h' */ + lvalp->intn = yasm_intnum_create_hex(TOK); + RETURN(INTNUM); + } - /* $0AA and 0xAA forms of hexidecimal number */ - (("$" digit) | '0x') hexdigit+ { - savech = s->tok[TOKLEN]; - s->tok[TOKLEN] = '\0'; - if (s->tok[1] == 'x' || s->tok[1] == 'X') - /* skip 0 and x */ - lvalp->intn = yasm_intnum_create_hex(TOK+2); - else - /* don't skip 0 */ - lvalp->intn = yasm_intnum_create_hex(TOK+1); - s->tok[TOKLEN] = savech; - RETURN(INTNUM); - } + /* $0AA and 0xAA forms of hexidecimal number */ + (("$" digit) | "0x") hexdigit+ { + savech = s->tok[TOKLEN]; + s->tok[TOKLEN] = '\0'; + if (s->tok[1] == 'x') + /* skip 0 and x */ + lvalp->intn = yasm_intnum_create_hex(TOK+2); + else + /* don't skip 0 */ + lvalp->intn = yasm_intnum_create_hex(TOK+1); + s->tok[TOKLEN] = savech; + RETURN(INTNUM); + } - /* string/character constant values */ - quot { - endch = s->tok[0]; - goto stringconst; - } + /* string/character constant values */ + quot { + endch = s->tok[0]; + goto stringconst; + } - /* operators */ - "<<" { RETURN(LEFT_OP); } - ">>" { RETURN(RIGHT_OP); } - "//" { RETURN(SIGNDIV); } - "%%" { RETURN(SIGNMOD); } - [-+|^*&/%~$():=,\[] { RETURN(s->tok[0]); } + /* operators */ + "<<" { RETURN(LEFT_OP); } + ">>" { RETURN(RIGHT_OP); } + "//" { RETURN(SIGNDIV); } + "%%" { RETURN(SIGNMOD); } + [-+|^*&/%~$():=,\[] { RETURN(s->tok[0]); } - /* handle ] for directives */ - "]" { goto endofinput; } + /* handle ] for directives */ + "]" { + parser_nasm->state = INITIAL; + RETURN(s->tok[0]); + } /* forced identifier; within directive, don't strip '$', this is * handled later. */ - "$" [a-zA-Z0-9_$#@~.?]+ { + "$" [a-zA-Z0-9_$#@~.?]+ { lvalp->str_val = yasm__xstrndup(TOK, TOKLEN); - RETURN(ID); - } + RETURN(ID); + } - /* identifier; within directive, no local label mechanism */ - [a-zA-Z_.?][a-zA-Z0-9_$#@~.?]* { - savech = s->tok[TOKLEN]; - s->tok[TOKLEN] = '\0'; - switch (yasm_arch_parse_check_regtmod - (p_object->arch, TOK, TOKLEN, &lvalp->arch_data)) { - case YASM_ARCH_REG: - s->tok[TOKLEN] = savech; - RETURN(REG); - default: - s->tok[TOKLEN] = savech; - } - /* Propagate errors in case we got a warning from the arch */ - yasm_errwarn_propagate(parser_nasm->errwarns, cur_line); - /* Just an identifier, return as such. */ - lvalp->str_val = yasm__xstrndup(TOK, TOKLEN); - RETURN(ID); - } + /* identifier; within directive, no local label mechanism */ + [a-zA-Z_.?][a-zA-Z0-9_$#@~.?]* { + savech = s->tok[TOKLEN]; + s->tok[TOKLEN] = '\0'; + switch (yasm_arch_parse_check_regtmod + (p_object->arch, lvalp->arch_data, TOK, TOKLEN)) { + case YASM_ARCH_REG: + s->tok[TOKLEN] = savech; + RETURN(REG); + default: + s->tok[TOKLEN] = savech; + } + /* Propagate errors in case we got a warning from the arch */ + yasm_errwarn_propagate(parser_nasm->errwarns, cur_line); + /* Just an identifier, return as such. */ + lvalp->str_val = yasm__xstrndup(TOK, TOKLEN); + RETURN(ID); + } - ";" (any \ [\000])* { goto directive2; } + ";" (any \ [\n])* { goto directive2; } - ws+ { goto directive2; } + ws+ { goto directive2; } - [\000] { goto endofinput; } + "\n" { + if (parser_nasm->save_input) + cursor = save_line(parser_nasm, cursor); + parser_nasm->state = INITIAL; + RETURN(s->tok[0]); + } - any { - yasm_warn_set(YASM_WARN_UNREC_CHAR, - N_("ignoring unrecognized character `%s'"), - yasm__conv_unprint(s->tok[0])); - goto scan; - } + any { + yasm_warn_set(YASM_WARN_UNREC_CHAR, + N_("ignoring unrecognized character `%s'"), + yasm__conv_unprint(s->tok[0])); + goto scan; + } */ /* string/character constant values */ @@ -740,56 +659,37 @@ stringconst: stringconst_scan: SCANINIT(); - if (*cursor == '\0') - goto stringconst_error; /*!re2c - [\000] { goto stringconst_error; } + "\n" { + if (cursor == s->eof) + yasm_error_set(YASM_ERROR_SYNTAX, + N_("unexpected end of file in string")); + else + yasm_error_set(YASM_ERROR_SYNTAX, N_("unterminated string")); + strbuf[count] = '\0'; + lvalp->str.contents = (char *)strbuf; + lvalp->str.len = count; + if (parser_nasm->save_input) + cursor = save_line(parser_nasm, cursor); + RETURN(STRING); + } - "''" | '""' { - if (endch != s->tok[0]) { - strbuf[count++] = s->tok[0]; - if (count >= strbuf_size) { - strbuf = yasm_xrealloc(strbuf, - strbuf_size + STRBUF_ALLOC_SIZE); - strbuf_size += STRBUF_ALLOC_SIZE; - } - } else if (!parser_nasm->tasm) { - YYCURSOR--; - goto stringconst_end; - } - strbuf[count++] = s->tok[0]; - if (count >= strbuf_size) { - strbuf = yasm_xrealloc(strbuf, strbuf_size + STRBUF_ALLOC_SIZE); - strbuf_size += STRBUF_ALLOC_SIZE; - } - goto stringconst_scan; - } + any { + if (s->tok[0] == endch) { + strbuf[count] = '\0'; + lvalp->str.contents = (char *)strbuf; + lvalp->str.len = count; + RETURN(STRING); + } - any { - if (s->tok[0] == endch) - goto stringconst_end; + strbuf[count++] = s->tok[0]; + if (count >= strbuf_size) { + strbuf = yasm_xrealloc(strbuf, strbuf_size + STRBUF_ALLOC_SIZE); + strbuf_size += STRBUF_ALLOC_SIZE; + } - strbuf[count++] = s->tok[0]; - if (count >= strbuf_size) { - strbuf = yasm_xrealloc(strbuf, strbuf_size + STRBUF_ALLOC_SIZE); - strbuf_size += STRBUF_ALLOC_SIZE; - } - - goto stringconst_scan; - } + goto stringconst_scan; + } */ - -stringconst_error: - yasm_error_set(YASM_ERROR_SYNTAX, N_("unterminated string")); - -stringconst_end: - strbuf[count] = '\0'; - lvalp->str.contents = (char *)strbuf; - lvalp->str.len = count; - RETURN(STRING); - -endofinput: - parser_nasm->state = INITIAL; - RETURN(s->tok[0]); } diff --git a/modules/parsers/nasm/tests/Makefile.inc b/modules/parsers/nasm/tests/Makefile.inc index 56d0b926..552320cc 100644 --- a/modules/parsers/nasm/tests/Makefile.inc +++ b/modules/parsers/nasm/tests/Makefile.inc @@ -1,3 +1,5 @@ +# $Id$ + TESTS += modules/parsers/nasm/tests/nasm_test.sh EXTRA_DIST += modules/parsers/nasm/tests/nasm_test.sh @@ -7,27 +9,14 @@ EXTRA_DIST += modules/parsers/nasm/tests/alignnop32.asm EXTRA_DIST += modules/parsers/nasm/tests/alignnop32.hex EXTRA_DIST += modules/parsers/nasm/tests/charconstmath.asm EXTRA_DIST += modules/parsers/nasm/tests/charconstmath.hex -EXTRA_DIST += modules/parsers/nasm/tests/dirwarning.asm -EXTRA_DIST += modules/parsers/nasm/tests/dirwarning.errwarn -EXTRA_DIST += modules/parsers/nasm/tests/dirwarning.hex -EXTRA_DIST += modules/parsers/nasm/tests/dy.asm -EXTRA_DIST += modules/parsers/nasm/tests/dy.hex EXTRA_DIST += modules/parsers/nasm/tests/endcomma.asm EXTRA_DIST += modules/parsers/nasm/tests/endcomma.hex EXTRA_DIST += modules/parsers/nasm/tests/equcolon.asm EXTRA_DIST += modules/parsers/nasm/tests/equcolon.hex EXTRA_DIST += modules/parsers/nasm/tests/equlocal.asm EXTRA_DIST += modules/parsers/nasm/tests/equlocal.hex -EXTRA_DIST += modules/parsers/nasm/tests/hexconst.asm -EXTRA_DIST += modules/parsers/nasm/tests/hexconst.hex EXTRA_DIST += modules/parsers/nasm/tests/long.asm EXTRA_DIST += modules/parsers/nasm/tests/long.hex -EXTRA_DIST += modules/parsers/nasm/tests/locallabel.asm -EXTRA_DIST += modules/parsers/nasm/tests/locallabel.hex -EXTRA_DIST += modules/parsers/nasm/tests/locallabel2.asm -EXTRA_DIST += modules/parsers/nasm/tests/locallabel2.hex -EXTRA_DIST += modules/parsers/nasm/tests/nasm-prefix.asm -EXTRA_DIST += modules/parsers/nasm/tests/nasm-prefix.hex EXTRA_DIST += modules/parsers/nasm/tests/newsect.asm EXTRA_DIST += modules/parsers/nasm/tests/newsect.hex EXTRA_DIST += modules/parsers/nasm/tests/orphannowarn.asm @@ -39,12 +28,6 @@ EXTRA_DIST += modules/parsers/nasm/tests/strucalign.asm EXTRA_DIST += modules/parsers/nasm/tests/strucalign.hex EXTRA_DIST += modules/parsers/nasm/tests/struczero.asm EXTRA_DIST += modules/parsers/nasm/tests/struczero.hex -EXTRA_DIST += modules/parsers/nasm/tests/strucbase.asm -EXTRA_DIST += modules/parsers/nasm/tests/strucbase.hex -EXTRA_DIST += modules/parsers/nasm/tests/syntax-err.asm -EXTRA_DIST += modules/parsers/nasm/tests/syntax-err.errwarn -EXTRA_DIST += modules/parsers/nasm/tests/uscore.asm -EXTRA_DIST += modules/parsers/nasm/tests/uscore.hex EXTRA_DIST += modules/parsers/nasm/tests/worphan/Makefile.inc diff --git a/modules/parsers/nasm/tests/dirwarning.asm b/modules/parsers/nasm/tests/dirwarning.asm deleted file mode 100644 index 265d60a5..00000000 --- a/modules/parsers/nasm/tests/dirwarning.asm +++ /dev/null @@ -1 +0,0 @@ -[warning -w] diff --git a/modules/parsers/nasm/tests/dirwarning.errwarn b/modules/parsers/nasm/tests/dirwarning.errwarn deleted file mode 100644 index 366c8d66..00000000 --- a/modules/parsers/nasm/tests/dirwarning.errwarn +++ /dev/null @@ -1 +0,0 @@ --:1: warning: [warning] directive not supported; ignored diff --git a/modules/parsers/nasm/tests/dirwarning.hex b/modules/parsers/nasm/tests/dirwarning.hex deleted file mode 100644 index e69de29b..00000000 diff --git a/modules/parsers/nasm/tests/dy.asm b/modules/parsers/nasm/tests/dy.asm deleted file mode 100644 index 5a74e2f4..00000000 --- a/modules/parsers/nasm/tests/dy.asm +++ /dev/null @@ -1,5 +0,0 @@ -dy 0x0123456789abcdef00112233445566778899aabbccddeeff1111222233334444 -dw label -section .bss -resy 1 -label: diff --git a/modules/parsers/nasm/tests/dy.hex b/modules/parsers/nasm/tests/dy.hex deleted file mode 100644 index ead24e69..00000000 --- a/modules/parsers/nasm/tests/dy.hex +++ /dev/null @@ -1,34 +0,0 @@ -44 -44 -33 -33 -22 -22 -11 -11 -ff -ee -dd -cc -bb -aa -99 -88 -77 -66 -55 -44 -33 -22 -11 -00 -ef -cd -ab -89 -67 -45 -23 -01 -44 -00 diff --git a/modules/parsers/nasm/tests/hexconst.asm b/modules/parsers/nasm/tests/hexconst.asm deleted file mode 100644 index a0039b02..00000000 --- a/modules/parsers/nasm/tests/hexconst.asm +++ /dev/null @@ -1,2 +0,0 @@ -dd 0x500 -dd 0X500 diff --git a/modules/parsers/nasm/tests/hexconst.hex b/modules/parsers/nasm/tests/hexconst.hex deleted file mode 100644 index 90a00fe9..00000000 --- a/modules/parsers/nasm/tests/hexconst.hex +++ /dev/null @@ -1,8 +0,0 @@ -00 -05 -00 -00 -00 -05 -00 -00 diff --git a/modules/parsers/nasm/tests/locallabel.asm b/modules/parsers/nasm/tests/locallabel.asm deleted file mode 100644 index 013de530..00000000 --- a/modules/parsers/nasm/tests/locallabel.asm +++ /dev/null @@ -1,21 +0,0 @@ -label: -db 0 -.local: -db 0 -..@local1: -.local2: -dw label.local -dw label.local2 - -$label2: -db 0 -$.local: -db 0 -$..@local2: -$.local2: -dw label2.local -dw label2.local2 -dw $label2.local -dw $label2.local2 - - diff --git a/modules/parsers/nasm/tests/locallabel.hex b/modules/parsers/nasm/tests/locallabel.hex deleted file mode 100644 index 4aaba4ef..00000000 --- a/modules/parsers/nasm/tests/locallabel.hex +++ /dev/null @@ -1,16 +0,0 @@ -00 -00 -01 -00 -02 -00 -00 -00 -07 -00 -08 -00 -07 -00 -08 -00 diff --git a/modules/parsers/nasm/tests/locallabel2.asm b/modules/parsers/nasm/tests/locallabel2.asm deleted file mode 100644 index ea0f8c92..00000000 --- a/modules/parsers/nasm/tests/locallabel2.asm +++ /dev/null @@ -1,4 +0,0 @@ -nl1: -nl2:db .0 - nl2 -.0: db .1 - nl2 -.1: diff --git a/modules/parsers/nasm/tests/locallabel2.hex b/modules/parsers/nasm/tests/locallabel2.hex deleted file mode 100644 index 26334819..00000000 --- a/modules/parsers/nasm/tests/locallabel2.hex +++ /dev/null @@ -1,2 +0,0 @@ -01 -02 diff --git a/modules/parsers/nasm/tests/nasm-prefix.asm b/modules/parsers/nasm/tests/nasm-prefix.asm deleted file mode 100644 index 2bd7824f..00000000 --- a/modules/parsers/nasm/tests/nasm-prefix.asm +++ /dev/null @@ -1,5 +0,0 @@ -es -mov ax, [bx] - -a32 -mov ax, [bx] diff --git a/modules/parsers/nasm/tests/nasm-prefix.hex b/modules/parsers/nasm/tests/nasm-prefix.hex deleted file mode 100644 index 24bdfef6..00000000 --- a/modules/parsers/nasm/tests/nasm-prefix.hex +++ /dev/null @@ -1,6 +0,0 @@ -26 -8b -07 -67 -8b -07 diff --git a/modules/parsers/nasm/tests/nasm_test.sh b/modules/parsers/nasm/tests/nasm_test.sh index 0ff39b6e..dc26d21f 100755 --- a/modules/parsers/nasm/tests/nasm_test.sh +++ b/modules/parsers/nasm/tests/nasm_test.sh @@ -1,3 +1,4 @@ #! /bin/sh +# $Id$ ${srcdir}/out_test.sh nasm_test modules/parsers/nasm/tests "nasm-compat parser" "-f bin" "" exit $? diff --git a/modules/parsers/nasm/tests/strucbase.asm b/modules/parsers/nasm/tests/strucbase.asm deleted file mode 100644 index 81e2fc03..00000000 --- a/modules/parsers/nasm/tests/strucbase.asm +++ /dev/null @@ -1,11 +0,0 @@ -struc base, -7 -.a: resb 1 -.b: resb 1 -endstruc - -; Expect base and base.a to appear at -7, base.b at -6 -db base -db base.a -db base.b -; The size should be '2' here -db base_size diff --git a/modules/parsers/nasm/tests/strucbase.hex b/modules/parsers/nasm/tests/strucbase.hex deleted file mode 100644 index 5d48c5ea..00000000 --- a/modules/parsers/nasm/tests/strucbase.hex +++ /dev/null @@ -1,4 +0,0 @@ -f9 -f9 -fa -02 diff --git a/modules/parsers/nasm/tests/syntax-err.asm b/modules/parsers/nasm/tests/syntax-err.asm deleted file mode 100644 index f36010a7..00000000 --- a/modules/parsers/nasm/tests/syntax-err.asm +++ /dev/null @@ -1,17 +0,0 @@ -global crc32 -crc32: resd 1 -cli: -mov ax, 5% -mov ax, % -mov ax, ~ -mov ax, + -mov ax, - -mov ax, ( -mov ax, ) -ret 5% -ret % -ret ~ -ret + -ret - -ret ( -ret ) diff --git a/modules/parsers/nasm/tests/syntax-err.errwarn b/modules/parsers/nasm/tests/syntax-err.errwarn deleted file mode 100644 index 2e52a0d1..00000000 --- a/modules/parsers/nasm/tests/syntax-err.errwarn +++ /dev/null @@ -1,16 +0,0 @@ --:2: error: unexpected `:' after instruction --:3: error: unexpected `:' after instruction --:4: error: expected expression after `%' --:5: error: expected operand, got `%' --:6: error: expected expression after `~' --:7: error: expected expression after `+' --:8: error: expected expression after `-' --:9: error: expected expression after `(' --:10: error: expected operand, got `)' --:11: error: expected expression after `%' --:12: error: unexpected `%' after instruction --:13: error: expected expression after `~' --:14: error: expected expression after `+' --:15: error: expected expression after `-' --:16: error: expected expression after `(' --:17: error: unexpected `)' after instruction diff --git a/modules/parsers/nasm/tests/uscore.asm b/modules/parsers/nasm/tests/uscore.asm deleted file mode 100644 index 0630597f..00000000 --- a/modules/parsers/nasm/tests/uscore.asm +++ /dev/null @@ -1,10 +0,0 @@ -dq 0000_1111_2222_3333h -dq 0000111122223333h -dd 0x01_23_45_67 -dd 0x01234567 -dw 1_2_3_4q -dw 1234q -db 00_11_00_11b -db 00110011b -_0: -dw _0 diff --git a/modules/parsers/nasm/tests/uscore.hex b/modules/parsers/nasm/tests/uscore.hex deleted file mode 100644 index 4793d1d8..00000000 --- a/modules/parsers/nasm/tests/uscore.hex +++ /dev/null @@ -1,32 +0,0 @@ -33 -33 -22 -22 -11 -11 -00 -00 -33 -33 -22 -22 -11 -11 -00 -00 -67 -45 -23 -01 -67 -45 -23 -01 -9c -02 -9c -02 -33 -33 -1e -00 diff --git a/modules/parsers/nasm/tests/worphan/Makefile.inc b/modules/parsers/nasm/tests/worphan/Makefile.inc index f55b93d3..7495f8e8 100644 --- a/modules/parsers/nasm/tests/worphan/Makefile.inc +++ b/modules/parsers/nasm/tests/worphan/Makefile.inc @@ -1,3 +1,5 @@ +# $Id$ + TESTS += modules/parsers/nasm/tests/worphan/nasm_worphan_test.sh EXTRA_DIST += modules/parsers/nasm/tests/worphan/nasm_worphan_test.sh diff --git a/modules/parsers/nasm/tests/worphan/nasm_worphan_test.sh b/modules/parsers/nasm/tests/worphan/nasm_worphan_test.sh index ebb6bcd2..bc772c6b 100755 --- a/modules/parsers/nasm/tests/worphan/nasm_worphan_test.sh +++ b/modules/parsers/nasm/tests/worphan/nasm_worphan_test.sh @@ -1,3 +1,4 @@ #! /bin/sh +# $Id$ ${srcdir}/out_test.sh nasm_test modules/parsers/nasm/tests/worphan "nasm-compat parser" "-Worphan-labels -f bin" "" exit $? diff --git a/modules/parsers/nasm/tests/worphan/orphanwarn.errwarn b/modules/parsers/nasm/tests/worphan/orphanwarn.errwarn index d0071f2c..0953e811 100644 --- a/modules/parsers/nasm/tests/worphan/orphanwarn.errwarn +++ b/modules/parsers/nasm/tests/worphan/orphanwarn.errwarn @@ -1,2 +1,2 @@ --:2: warning: label alone on a line without a colon might be in error --:3: warning: label alone on a line without a colon might be in error +-:2: warning: label alone on aline without a colon might be in error +-:3: warning: label alone on aline without a colon might be in error diff --git a/modules/parsers/tasm/Makefile.inc b/modules/parsers/tasm/Makefile.inc deleted file mode 100644 index bf49f71e..00000000 --- a/modules/parsers/tasm/Makefile.inc +++ /dev/null @@ -1,3 +0,0 @@ -EXTRA_DIST += modules/parsers/tasm/tests/Makefile.inc - -include modules/parsers/tasm/tests/Makefile.inc diff --git a/modules/parsers/tasm/tests/Makefile.inc b/modules/parsers/tasm/tests/Makefile.inc deleted file mode 100644 index d37e1e63..00000000 --- a/modules/parsers/tasm/tests/Makefile.inc +++ /dev/null @@ -1,43 +0,0 @@ -TESTS += modules/parsers/tasm/tests/tasm_test.sh - -EXTRA_DIST += modules/parsers/tasm/tests/tasm_test.sh -EXTRA_DIST += modules/parsers/tasm/tests/array.asm -EXTRA_DIST += modules/parsers/tasm/tests/array.hex -EXTRA_DIST += modules/parsers/tasm/tests/case.asm -EXTRA_DIST += modules/parsers/tasm/tests/case.hex -EXTRA_DIST += modules/parsers/tasm/tests/charstr.asm -EXTRA_DIST += modules/parsers/tasm/tests/charstr.hex -EXTRA_DIST += modules/parsers/tasm/tests/dup.asm -EXTRA_DIST += modules/parsers/tasm/tests/dup.hex -EXTRA_DIST += modules/parsers/tasm/tests/equal.asm -EXTRA_DIST += modules/parsers/tasm/tests/equal.hex -EXTRA_DIST += modules/parsers/tasm/tests/expr.asm -EXTRA_DIST += modules/parsers/tasm/tests/expr.hex -EXTRA_DIST += modules/parsers/tasm/tests/irp.asm -EXTRA_DIST += modules/parsers/tasm/tests/irp.hex -EXTRA_DIST += modules/parsers/tasm/tests/label.asm -EXTRA_DIST += modules/parsers/tasm/tests/label.hex -EXTRA_DIST += modules/parsers/tasm/tests/les.asm -EXTRA_DIST += modules/parsers/tasm/tests/les.hex -EXTRA_DIST += modules/parsers/tasm/tests/lidt.asm -EXTRA_DIST += modules/parsers/tasm/tests/lidt.hex -EXTRA_DIST += modules/parsers/tasm/tests/macro.asm -EXTRA_DIST += modules/parsers/tasm/tests/macro.hex -EXTRA_DIST += modules/parsers/tasm/tests/offset.asm -EXTRA_DIST += modules/parsers/tasm/tests/offset.hex -EXTRA_DIST += modules/parsers/tasm/tests/quote.asm -EXTRA_DIST += modules/parsers/tasm/tests/quote.hex -EXTRA_DIST += modules/parsers/tasm/tests/res.asm -EXTRA_DIST += modules/parsers/tasm/tests/res.errwarn -EXTRA_DIST += modules/parsers/tasm/tests/res.hex -EXTRA_DIST += modules/parsers/tasm/tests/segment.asm -EXTRA_DIST += modules/parsers/tasm/tests/segment.hex -EXTRA_DIST += modules/parsers/tasm/tests/size.asm -EXTRA_DIST += modules/parsers/tasm/tests/size.hex -EXTRA_DIST += modules/parsers/tasm/tests/struc.asm -EXTRA_DIST += modules/parsers/tasm/tests/struc.errwarn -EXTRA_DIST += modules/parsers/tasm/tests/struc.hex - -EXTRA_DIST += modules/parsers/tasm/tests/exe/Makefile.inc - -include modules/parsers/tasm/tests/exe/Makefile.inc diff --git a/modules/parsers/tasm/tests/array.asm b/modules/parsers/tasm/tests/array.asm deleted file mode 100644 index 44842678..00000000 --- a/modules/parsers/tasm/tests/array.asm +++ /dev/null @@ -1,2 +0,0 @@ -t db 0,1,2 -mov al,t[1] diff --git a/modules/parsers/tasm/tests/array.hex b/modules/parsers/tasm/tests/array.hex deleted file mode 100644 index 97758932..00000000 --- a/modules/parsers/tasm/tests/array.hex +++ /dev/null @@ -1,6 +0,0 @@ -00 -01 -02 -a0 -01 -00 diff --git a/modules/parsers/tasm/tests/case.asm b/modules/parsers/tasm/tests/case.asm deleted file mode 100644 index 1549d4bf..00000000 --- a/modules/parsers/tasm/tests/case.asm +++ /dev/null @@ -1,3 +0,0 @@ -a db 0 -B dw A -c dw b diff --git a/modules/parsers/tasm/tests/case.hex b/modules/parsers/tasm/tests/case.hex deleted file mode 100644 index e2092e09..00000000 --- a/modules/parsers/tasm/tests/case.hex +++ /dev/null @@ -1,5 +0,0 @@ -00 -00 -00 -01 -00 diff --git a/modules/parsers/tasm/tests/charstr.asm b/modules/parsers/tasm/tests/charstr.asm deleted file mode 100644 index a753716c..00000000 --- a/modules/parsers/tasm/tests/charstr.asm +++ /dev/null @@ -1 +0,0 @@ -mov eax,"1234" diff --git a/modules/parsers/tasm/tests/charstr.hex b/modules/parsers/tasm/tests/charstr.hex deleted file mode 100644 index 42deac41..00000000 --- a/modules/parsers/tasm/tests/charstr.hex +++ /dev/null @@ -1,6 +0,0 @@ -66 -b8 -34 -33 -32 -31 diff --git a/modules/parsers/tasm/tests/dup.asm b/modules/parsers/tasm/tests/dup.asm deleted file mode 100644 index c19ea762..00000000 --- a/modules/parsers/tasm/tests/dup.asm +++ /dev/null @@ -1 +0,0 @@ -a db 10 dup(1) diff --git a/modules/parsers/tasm/tests/dup.hex b/modules/parsers/tasm/tests/dup.hex deleted file mode 100644 index 5a51766a..00000000 --- a/modules/parsers/tasm/tests/dup.hex +++ /dev/null @@ -1,10 +0,0 @@ -01 -01 -01 -01 -01 -01 -01 -01 -01 -01 diff --git a/modules/parsers/tasm/tests/equal.asm b/modules/parsers/tasm/tests/equal.asm deleted file mode 100644 index 4b8919dc..00000000 --- a/modules/parsers/tasm/tests/equal.asm +++ /dev/null @@ -1 +0,0 @@ -a = byte 1 diff --git a/modules/parsers/tasm/tests/equal.hex b/modules/parsers/tasm/tests/equal.hex deleted file mode 100644 index e69de29b..00000000 diff --git a/modules/parsers/tasm/tests/exe/Makefile.inc b/modules/parsers/tasm/tests/exe/Makefile.inc deleted file mode 100644 index 117012cc..00000000 --- a/modules/parsers/tasm/tests/exe/Makefile.inc +++ /dev/null @@ -1,6 +0,0 @@ -TESTS += modules/parsers/tasm/tests/exe/tasm_exe_test.sh - -EXTRA_DIST += modules/parsers/tasm/tests/exe/tasm_exe_test.sh -EXTRA_DIST += modules/parsers/tasm/tests/exe/exe.asm -EXTRA_DIST += modules/parsers/tasm/tests/exe/exe.hex - diff --git a/modules/parsers/tasm/tests/exe/exe.asm b/modules/parsers/tasm/tests/exe/exe.asm deleted file mode 100644 index f040a1cf..00000000 --- a/modules/parsers/tasm/tests/exe/exe.asm +++ /dev/null @@ -1,4 +0,0 @@ -a db 1 -start proc -int 22 -start endp diff --git a/modules/parsers/tasm/tests/exe/exe.hex b/modules/parsers/tasm/tests/exe/exe.hex deleted file mode 100644 index 4547fbc7..00000000 --- a/modules/parsers/tasm/tests/exe/exe.hex +++ /dev/null @@ -1,515 +0,0 @@ -4d -5a -03 -00 -02 -00 -00 -00 -20 -00 -00 -00 -ff -ff -00 -00 -00 -00 -00 -00 -01 -00 -00 -00 -22 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -00 -01 -cd -16 diff --git a/modules/parsers/tasm/tests/exe/tasm_exe_test.sh b/modules/parsers/tasm/tests/exe/tasm_exe_test.sh deleted file mode 100755 index 15fdd553..00000000 --- a/modules/parsers/tasm/tests/exe/tasm_exe_test.sh +++ /dev/null @@ -1,3 +0,0 @@ -#! /bin/sh -${srcdir}/out_test.sh tasm_test modules/parsers/tasm/tests/exe "tasm-compat parser" "-f dosexe -p tasm" "" -exit $? diff --git a/modules/parsers/tasm/tests/expr.asm b/modules/parsers/tasm/tests/expr.asm deleted file mode 100644 index f5958cae..00000000 --- a/modules/parsers/tasm/tests/expr.asm +++ /dev/null @@ -1,2 +0,0 @@ -a db low ((1 shl 2) and (16 shr 2) or (high 0x5034)) -b db not 1 diff --git a/modules/parsers/tasm/tests/expr.hex b/modules/parsers/tasm/tests/expr.hex deleted file mode 100644 index c6b00472..00000000 --- a/modules/parsers/tasm/tests/expr.hex +++ /dev/null @@ -1,2 +0,0 @@ -54 -fe diff --git a/modules/parsers/tasm/tests/irp.asm b/modules/parsers/tasm/tests/irp.asm deleted file mode 100644 index d24cd29f..00000000 --- a/modules/parsers/tasm/tests/irp.asm +++ /dev/null @@ -1,3 +0,0 @@ -irp i,<1,2,3> - mov ax,i -endm diff --git a/modules/parsers/tasm/tests/irp.hex b/modules/parsers/tasm/tests/irp.hex deleted file mode 100644 index 7bf091db..00000000 --- a/modules/parsers/tasm/tests/irp.hex +++ /dev/null @@ -1,9 +0,0 @@ -b8 -01 -00 -b8 -02 -00 -b8 -03 -00 diff --git a/modules/parsers/tasm/tests/label.asm b/modules/parsers/tasm/tests/label.asm deleted file mode 100644 index ff72ba3e..00000000 --- a/modules/parsers/tasm/tests/label.asm +++ /dev/null @@ -1,2 +0,0 @@ -a label byte -mov ax,offset a diff --git a/modules/parsers/tasm/tests/label.hex b/modules/parsers/tasm/tests/label.hex deleted file mode 100644 index b74f90bd..00000000 --- a/modules/parsers/tasm/tests/label.hex +++ /dev/null @@ -1,3 +0,0 @@ -b8 -00 -00 diff --git a/modules/parsers/tasm/tests/les.asm b/modules/parsers/tasm/tests/les.asm deleted file mode 100644 index bbcfd90a..00000000 --- a/modules/parsers/tasm/tests/les.asm +++ /dev/null @@ -1,2 +0,0 @@ -a db 1 -les ax,a diff --git a/modules/parsers/tasm/tests/les.hex b/modules/parsers/tasm/tests/les.hex deleted file mode 100644 index 032eee74..00000000 --- a/modules/parsers/tasm/tests/les.hex +++ /dev/null @@ -1,5 +0,0 @@ -01 -c4 -06 -00 -00 diff --git a/modules/parsers/tasm/tests/lidt.asm b/modules/parsers/tasm/tests/lidt.asm deleted file mode 100644 index 11cf0c6a..00000000 --- a/modules/parsers/tasm/tests/lidt.asm +++ /dev/null @@ -1,3 +0,0 @@ -idtr dw 0 - dd 0 -lidt fword ptr idtr diff --git a/modules/parsers/tasm/tests/lidt.hex b/modules/parsers/tasm/tests/lidt.hex deleted file mode 100644 index 97fb3b73..00000000 --- a/modules/parsers/tasm/tests/lidt.hex +++ /dev/null @@ -1,11 +0,0 @@ -00 -00 -00 -00 -00 -00 -0f -01 -1e -00 -00 diff --git a/modules/parsers/tasm/tests/macro.asm b/modules/parsers/tasm/tests/macro.asm deleted file mode 100644 index 75902391..00000000 --- a/modules/parsers/tasm/tests/macro.asm +++ /dev/null @@ -1,6 +0,0 @@ -a macro reg,i - mov reg,i - endm - -a ax,0 -a bx,1 diff --git a/modules/parsers/tasm/tests/macro.hex b/modules/parsers/tasm/tests/macro.hex deleted file mode 100644 index 92b4e4ae..00000000 --- a/modules/parsers/tasm/tests/macro.hex +++ /dev/null @@ -1,6 +0,0 @@ -b8 -00 -00 -bb -01 -00 diff --git a/modules/parsers/tasm/tests/offset.asm b/modules/parsers/tasm/tests/offset.asm deleted file mode 100644 index 417fd2c3..00000000 --- a/modules/parsers/tasm/tests/offset.asm +++ /dev/null @@ -1,3 +0,0 @@ -a db 1 -mov ax,offset a -mov ax,offset[a] diff --git a/modules/parsers/tasm/tests/offset.hex b/modules/parsers/tasm/tests/offset.hex deleted file mode 100644 index 3def1cf9..00000000 --- a/modules/parsers/tasm/tests/offset.hex +++ /dev/null @@ -1,7 +0,0 @@ -01 -b8 -00 -00 -b8 -00 -00 diff --git a/modules/parsers/tasm/tests/quote.asm b/modules/parsers/tasm/tests/quote.asm deleted file mode 100644 index a269ba37..00000000 --- a/modules/parsers/tasm/tests/quote.asm +++ /dev/null @@ -1,2 +0,0 @@ -a db 'don''t' -b db """" diff --git a/modules/parsers/tasm/tests/quote.hex b/modules/parsers/tasm/tests/quote.hex deleted file mode 100644 index eb41f7b4..00000000 --- a/modules/parsers/tasm/tests/quote.hex +++ /dev/null @@ -1,6 +0,0 @@ -64 -6f -6e -27 -74 -22 diff --git a/modules/parsers/tasm/tests/res.asm b/modules/parsers/tasm/tests/res.asm deleted file mode 100644 index 8cf0829a..00000000 --- a/modules/parsers/tasm/tests/res.asm +++ /dev/null @@ -1,2 +0,0 @@ -a db ? -b db 2 dup (?) diff --git a/modules/parsers/tasm/tests/res.errwarn b/modules/parsers/tasm/tests/res.errwarn deleted file mode 100644 index 490e1ad7..00000000 --- a/modules/parsers/tasm/tests/res.errwarn +++ /dev/null @@ -1,2 +0,0 @@ --:1: warning: uninitialized space declared in code/data section: zeroing --:2: warning: uninitialized space declared in code/data section: zeroing diff --git a/modules/parsers/tasm/tests/res.hex b/modules/parsers/tasm/tests/res.hex deleted file mode 100644 index 47f99ba3..00000000 --- a/modules/parsers/tasm/tests/res.hex +++ /dev/null @@ -1,3 +0,0 @@ -00 -00 -00 diff --git a/modules/parsers/tasm/tests/segment.asm b/modules/parsers/tasm/tests/segment.asm deleted file mode 100644 index f0563ebd..00000000 --- a/modules/parsers/tasm/tests/segment.asm +++ /dev/null @@ -1,8 +0,0 @@ -data segment - a db 0 -data ends - -assume es:data -code segment - mov byte ptr [a],1 -code ends diff --git a/modules/parsers/tasm/tests/segment.hex b/modules/parsers/tasm/tests/segment.hex deleted file mode 100644 index 667a69b2..00000000 --- a/modules/parsers/tasm/tests/segment.hex +++ /dev/null @@ -1,7 +0,0 @@ -00 -26 -c6 -06 -00 -00 -01 diff --git a/modules/parsers/tasm/tests/size.asm b/modules/parsers/tasm/tests/size.asm deleted file mode 100644 index 405cc407..00000000 --- a/modules/parsers/tasm/tests/size.asm +++ /dev/null @@ -1,2 +0,0 @@ -a db 0 -mov a,1 diff --git a/modules/parsers/tasm/tests/size.hex b/modules/parsers/tasm/tests/size.hex deleted file mode 100644 index 401266a1..00000000 --- a/modules/parsers/tasm/tests/size.hex +++ /dev/null @@ -1,6 +0,0 @@ -00 -c6 -06 -00 -00 -01 diff --git a/modules/parsers/tasm/tests/struc.asm b/modules/parsers/tasm/tests/struc.asm deleted file mode 100644 index 5a88b615..00000000 --- a/modules/parsers/tasm/tests/struc.asm +++ /dev/null @@ -1,8 +0,0 @@ -s struc - a db ? - b db ? -s ends - -v s <1,?> - -mov al,[v].b diff --git a/modules/parsers/tasm/tests/struc.errwarn b/modules/parsers/tasm/tests/struc.errwarn deleted file mode 100644 index 4e188892..00000000 --- a/modules/parsers/tasm/tests/struc.errwarn +++ /dev/null @@ -1 +0,0 @@ --:6: warning: uninitialized space declared in code/data section: zeroing diff --git a/modules/parsers/tasm/tests/struc.hex b/modules/parsers/tasm/tests/struc.hex deleted file mode 100644 index d2ad9563..00000000 --- a/modules/parsers/tasm/tests/struc.hex +++ /dev/null @@ -1,5 +0,0 @@ -01 -00 -a0 -01 -00 diff --git a/modules/parsers/tasm/tests/tasm_test.sh b/modules/parsers/tasm/tests/tasm_test.sh deleted file mode 100755 index 35ef7360..00000000 --- a/modules/parsers/tasm/tests/tasm_test.sh +++ /dev/null @@ -1,3 +0,0 @@ -#! /bin/sh -${srcdir}/out_test.sh tasm_test modules/parsers/tasm/tests "tasm-compat parser" "-f bin -p tasm" "" -exit $? diff --git a/modules/parsers/yasm_parsers.xml b/modules/parsers/yasm_parsers.xml index 28aa2e29..d29421de 100644 --- a/modules/parsers/yasm_parsers.xml +++ b/modules/parsers/yasm_parsers.xml @@ -2,6 +2,8 @@ + + @@ -89,11 +91,11 @@ assembler for modern Unix systems, and is used as the backend for the GCC compiler. Yasm's support for GAS syntax is moderately good, although immature: not all directives are supported, and only - 32-bit x86 and AMD64 architectures are supported. Nearly all of - the GAS preprocessor is also supported. Yasm's GAS syntax support - is good enough to handle essentially all x86 and AMD64 GCC compiler - output. The GAS parser can be selected with . + 32-bit x86 and AMD64 architectures are supported. There is also no + support for the GAS preprocessor. Despite these limitations, + Yasm's GAS syntax support is good enough to handle essentially all + x86 and AMD64 GCC compiler output. The GAS parser can be selected + with . diff --git a/modules/preprocs/CMakeLists.txt b/modules/preprocs/CMakeLists.txt deleted file mode 100644 index 59640272..00000000 --- a/modules/preprocs/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -INCLUDE(preprocs/nasm/CMakeLists.txt) -INCLUDE(preprocs/raw/CMakeLists.txt) -INCLUDE(preprocs/cpp/CMakeLists.txt) -INCLUDE(preprocs/gas/CMakeLists.txt) diff --git a/modules/preprocs/Makefile.inc b/modules/preprocs/Makefile.inc index acf06838..04145581 100644 --- a/modules/preprocs/Makefile.inc +++ b/modules/preprocs/Makefile.inc @@ -1,11 +1,7 @@ -EXTRA_DIST += modules/preprocs/tasm/Makefile.inc +# $Id$ + EXTRA_DIST += modules/preprocs/nasm/Makefile.inc EXTRA_DIST += modules/preprocs/raw/Makefile.inc -EXTRA_DIST += modules/preprocs/cpp/Makefile.inc -EXTRA_DIST += modules/preprocs/gas/Makefile.inc -include modules/preprocs/tasm/Makefile.inc include modules/preprocs/nasm/Makefile.inc include modules/preprocs/raw/Makefile.inc -include modules/preprocs/cpp/Makefile.inc -include modules/preprocs/gas/Makefile.inc diff --git a/modules/preprocs/cpp/CMakeLists.txt b/modules/preprocs/cpp/CMakeLists.txt deleted file mode 100644 index 202787cb..00000000 --- a/modules/preprocs/cpp/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -YASM_ADD_MODULE(preproc_cpp - preprocs/cpp/cpp-preproc.c - ) diff --git a/modules/preprocs/cpp/Makefile.inc b/modules/preprocs/cpp/Makefile.inc deleted file mode 100644 index 30bd24b3..00000000 --- a/modules/preprocs/cpp/Makefile.inc +++ /dev/null @@ -1,6 +0,0 @@ -# Makefile for cpp module. -# Copied from raw preprocessor module. - -libyasm_a_SOURCES += modules/preprocs/cpp/cpp-preproc.c - -YASM_MODULES += preproc_cpp diff --git a/modules/preprocs/cpp/cpp-preproc.c b/modules/preprocs/cpp/cpp-preproc.c deleted file mode 100644 index 663f726c..00000000 --- a/modules/preprocs/cpp/cpp-preproc.c +++ /dev/null @@ -1,402 +0,0 @@ -/* - * Invoke an external C preprocessor - * - * Copyright (C) 2007 Paul Barker - * Copyright (C) 2001-2007 Peter Johnson - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND OTHER CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR OTHER CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include - -/* TODO: Use autoconf to get the limit on the command line length. */ -#define CMDLINE_SIZE 32770 - -#define BSIZE 512 - -/* Pre-declare the preprocessor module object. */ -yasm_preproc_module yasm_cpp_LTX_preproc; - -/******************************************************************************* - Structures. -*******************************************************************************/ - -/* An entry in a list of arguments to pass to cpp. */ -typedef struct cpp_arg_entry { - TAILQ_ENTRY(cpp_arg_entry) entry; - - /* - The operator (eg "-I") and the parameter (eg "include/"). op is expected - to point to a string literal, whereas param is expected to be a copy of - the parameter which is free'd when no-longer needed (in - cpp_preproc_destroy()). - */ - const char *op; - char *param; -} cpp_arg_entry; - -typedef struct yasm_preproc_cpp { - yasm_preproc_base preproc; /* base structure */ - - /* List of arguments to pass to cpp. */ - TAILQ_HEAD(cpp_arg_head, cpp_arg_entry) cpp_args; - - char *filename; - FILE *f, *f_deps; - yasm_linemap *cur_lm; - yasm_errwarns *errwarns; - - int flags; -} yasm_preproc_cpp; - -/* Flag values for yasm_preproc_cpp->flags. */ -#define CPP_HAS_BEEN_INVOKED 0x01 -#define CPP_HAS_GENERATED_DEPS 0x02 - -/******************************************************************************* - Internal functions and helpers. -*******************************************************************************/ - -/* - Append a string to the command line, ensuring that we don't overflow the - buffer. -*/ -#define APPEND(s) do { \ - size_t _len = strlen(s); \ - if (p + _len >= limit) \ - yasm__fatal(N_("command line too long!")); \ - strcpy(p, s); \ - p += _len; \ -} while (0) - -/* - Put all the options together into a command line that can be used to invoke - cpp. -*/ -static char * -cpp_build_cmdline(yasm_preproc_cpp *pp, const char *extra) -{ - char *cmdline, *p, *limit; - cpp_arg_entry *arg; - - /* Initialize command line. */ - cmdline = p = yasm_xmalloc(strlen(CPP_PROG)+CMDLINE_SIZE); - limit = p + CMDLINE_SIZE; - strcpy(p, CPP_PROG); - p += strlen(CPP_PROG); - - arg = TAILQ_FIRST(&pp->cpp_args); - - /* Append arguments from the list. */ - while ( arg ) { - APPEND(" "); - APPEND(arg->op); - APPEND(" "); - APPEND(arg->param); - - arg = TAILQ_NEXT(arg, entry); - } - - /* Append extra arguments. */ - if (extra) { - APPEND(" "); - APPEND(extra); - } - /* Append final arguments. */ - APPEND(" -x assembler-with-cpp "); - APPEND(pp->filename); - - return cmdline; -} - -/* Invoke the c preprocessor. */ -static void -cpp_invoke(yasm_preproc_cpp *pp) -{ - char *cmdline; - - cmdline = cpp_build_cmdline(pp, NULL); - -#ifdef HAVE_POPEN - pp->f = popen(cmdline, "r"); - if (!pp->f) - yasm__fatal( N_("Failed to execute preprocessor") ); -#else - yasm__fatal( N_("Cannot execute preprocessor, no popen available") ); -#endif - - yasm_xfree(cmdline); -} - -/* Free memory used by the list of arguments. */ -static void -cpp_destroy_args(yasm_preproc_cpp *pp) -{ - cpp_arg_entry *arg; - - while ( (arg = TAILQ_FIRST(&pp->cpp_args)) ) { - TAILQ_REMOVE(&pp->cpp_args, arg, entry); - yasm_xfree(arg->param); - yasm_xfree(arg); - } -} - -/* Invoke the c preprocessor to generate dependency info. */ -static void -cpp_generate_deps(yasm_preproc_cpp *pp) -{ - char *cmdline; - - cmdline = cpp_build_cmdline(pp, "-M"); - -#ifdef HAVE_POPEN - pp->f_deps = popen(cmdline, "r"); - if (!pp->f_deps) - yasm__fatal( N_("Failed to execute preprocessor") ); -#else - yasm__fatal( N_("Cannot execute preprocessor, no popen available") ); -#endif - - yasm_xfree(cmdline); -} - -/******************************************************************************* - Interface functions. -*******************************************************************************/ -static yasm_preproc * -cpp_preproc_create(const char *in, yasm_symtab *symtab, yasm_linemap *lm, - yasm_errwarns *errwarns) -{ - yasm_preproc_cpp *pp = yasm_xmalloc(sizeof(yasm_preproc_cpp)); - void * iter; - const char * inc_dir; - - pp->preproc.module = &yasm_cpp_LTX_preproc; - pp->f = pp->f_deps = NULL; - pp->cur_lm = lm; - pp->errwarns = errwarns; - pp->flags = 0; - pp->filename = yasm__xstrdup(in); - - TAILQ_INIT(&pp->cpp_args); - - /* Iterate through the list of include dirs. */ - iter = NULL; - while ((inc_dir = yasm_get_include_dir(&iter)) != NULL) { - cpp_arg_entry *arg = yasm_xmalloc(sizeof(cpp_arg_entry)); - arg->op = "-I"; - arg->param = yasm__xstrdup(inc_dir); - - TAILQ_INSERT_TAIL(&pp->cpp_args, arg, entry); - } - - return (yasm_preproc *)pp; -} - -static void -cpp_preproc_destroy(yasm_preproc *preproc) -{ - yasm_preproc_cpp *pp = (yasm_preproc_cpp *)preproc; - - if (pp->f) { -#ifdef HAVE_POPEN - if (pclose(pp->f) != 0) - yasm__fatal( N_("Preprocessor exited with failure") ); -#endif - } - - cpp_destroy_args(pp); - - yasm_xfree(pp->filename); - yasm_xfree(pp); -} - -static char * -cpp_preproc_get_line(yasm_preproc *preproc) -{ - yasm_preproc_cpp *pp = (yasm_preproc_cpp *)preproc; - int bufsize = BSIZE; - char *buf, *p; - - if (! (pp->flags & CPP_HAS_BEEN_INVOKED) ) { - pp->flags |= CPP_HAS_BEEN_INVOKED; - - cpp_invoke(pp); - } - - /* - Once the preprocessor has been run, we're just dealing with a normal - file. - */ - - /* Loop to ensure entire line is read (don't want to limit line length). */ - buf = yasm_xmalloc((size_t)bufsize); - p = buf; - for (;;) { - if (!fgets(p, bufsize-(p-buf), pp->f)) { - if (ferror(pp->f)) { - yasm_error_set(YASM_ERROR_IO, - N_("error when reading from file")); - yasm_errwarn_propagate(pp->errwarns, - yasm_linemap_get_current(pp->cur_lm)); - } - break; - } - p += strlen(p); - if (p > buf && p[-1] == '\n') - break; - if ((p-buf) >= bufsize) { - /* Increase size of buffer */ - char *oldbuf = buf; - bufsize *= 2; - buf = yasm_xrealloc(buf, (size_t)bufsize); - p = buf + (p-oldbuf); - } - } - - if (p == buf) { - /* No data; must be at EOF */ - yasm_xfree(buf); - return NULL; - } - - /* Strip the line ending */ - buf[strcspn(buf, "\r\n")] = '\0'; - - return buf; -} - -static size_t -cpp_preproc_get_included_file(yasm_preproc *preproc, char *buf, - size_t max_size) -{ - char *p = buf; - int ch = '\0'; - size_t n = 0; - yasm_preproc_cpp *pp = (yasm_preproc_cpp *)preproc; - - if (! (pp->flags & CPP_HAS_GENERATED_DEPS) ) { - pp->flags |= CPP_HAS_GENERATED_DEPS; - - cpp_generate_deps(pp); - - /* Skip target name and first dependency. */ - while (ch != ':') - ch = fgetc(pp->f_deps); - - fgetc(pp->f_deps); /* Discard space after colon. */ - - while (ch != ' ' && ch != EOF) - ch = fgetc(pp->f_deps); - - if (ch == EOF) - return 0; - } - - while (n < max_size) { - ch = fgetc(pp->f_deps); - - if (ch == ' ' || ch == EOF) { - *p = '\0'; - return n; - } - - /* Eat any silly characters. */ - if (ch < ' ') - continue; - - *p++ = ch; - n++; - } - - /* Ensure the buffer is null-terminated. */ - *(p - 1) = '\0'; - return n; -} - -static void -cpp_preproc_add_include_file(yasm_preproc *preproc, const char *filename) -{ - yasm_preproc_cpp *pp = (yasm_preproc_cpp *)preproc; - - cpp_arg_entry *arg = yasm_xmalloc(sizeof(cpp_arg_entry)); - arg->op = "-include"; - arg->param = yasm__xstrdup(filename); - - TAILQ_INSERT_TAIL(&pp->cpp_args, arg, entry); -} - -static void -cpp_preproc_predefine_macro(yasm_preproc *preproc, const char *macronameval) -{ - yasm_preproc_cpp *pp = (yasm_preproc_cpp *)preproc; - - cpp_arg_entry *arg = yasm_xmalloc(sizeof(cpp_arg_entry)); - arg->op = "-D"; - arg->param = yasm__xstrdup(macronameval); - - TAILQ_INSERT_TAIL(&pp->cpp_args, arg, entry); -} - -static void -cpp_preproc_undefine_macro(yasm_preproc *preproc, const char *macroname) -{ - yasm_preproc_cpp *pp = (yasm_preproc_cpp *)preproc; - - cpp_arg_entry *arg = yasm_xmalloc(sizeof(cpp_arg_entry)); - arg->op = "-U"; - arg->param = yasm__xstrdup(macroname); - - TAILQ_INSERT_TAIL(&pp->cpp_args, arg, entry); -} - -static void -cpp_preproc_define_builtin(yasm_preproc *preproc, const char *macronameval) -{ - /* Handle a builtin as if it were a predefine. */ - cpp_preproc_predefine_macro(preproc, macronameval); -} - -static void -cpp_preproc_add_standard(yasm_preproc *preproc, const char **macros) -{ - /* TODO */ -} - -/******************************************************************************* - Preprocessor module object. -*******************************************************************************/ - -yasm_preproc_module yasm_cpp_LTX_preproc = { - "Run input through external C preprocessor", - "cpp", - cpp_preproc_create, - cpp_preproc_destroy, - cpp_preproc_get_line, - cpp_preproc_get_included_file, - cpp_preproc_add_include_file, - cpp_preproc_predefine_macro, - cpp_preproc_undefine_macro, - cpp_preproc_define_builtin, - cpp_preproc_add_standard -}; diff --git a/modules/preprocs/gas/CMakeLists.txt b/modules/preprocs/gas/CMakeLists.txt deleted file mode 100644 index e8d09148..00000000 --- a/modules/preprocs/gas/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -YASM_ADD_MODULE(preproc_gas - preprocs/gas/gas-preproc.c - preprocs/gas/gas-eval.c - ) diff --git a/modules/preprocs/gas/Makefile.inc b/modules/preprocs/gas/Makefile.inc deleted file mode 100644 index a7289a94..00000000 --- a/modules/preprocs/gas/Makefile.inc +++ /dev/null @@ -1,9 +0,0 @@ -libyasm_a_SOURCES += modules/preprocs/gas/gas-preproc.c -libyasm_a_SOURCES += modules/preprocs/gas/gas-eval.h -libyasm_a_SOURCES += modules/preprocs/gas/gas-eval.c - -YASM_MODULES += preproc_gas - -EXTRA_DIST += modules/preprocs/gas/tests/Makefile.inc - -include modules/preprocs/gas/tests/Makefile.inc diff --git a/modules/preprocs/gas/gas-eval.c b/modules/preprocs/gas/gas-eval.c deleted file mode 100644 index 3625c7a9..00000000 --- a/modules/preprocs/gas/gas-eval.c +++ /dev/null @@ -1,444 +0,0 @@ -/* eval.c expression evaluator for the Netwide Assembler - * - * The Netwide Assembler is copyright (C) 1996 Simon Tatham and - * Julian Hall. All rights reserved. The software is - * redistributable under the licence given in the file "Licence" - * distributed in the NASM archive. - * - * initial version 27/iii/95 by Simon Tatham - */ -#include -#include -#include -#include -#include -#include -#include - -#include "gas-eval.h" - -/* The assembler symbol table. */ -static yasm_symtab *symtab; - -static scanner scan; /* Address of scanner routine */ -static efunc error; /* Address of error reporting routine */ - -static struct tokenval *tokval; /* The current token */ -static int i; /* The t_type of tokval */ - -static void *scpriv; -static void *epriv; - -/* - * Recursive-descent parser. Called with a single boolean operand, - * which is TRUE if the evaluation is critical (i.e. unresolved - * symbols are an error condition). Must update the global `i' to - * reflect the token after the parsed string. May return NULL. - * - * evaluate() should report its own errors: on return it is assumed - * that if NULL has been returned, the error has already been - * reported. - */ - -/* - * Grammar parsed is: - * - * expr : bexpr [ WRT expr6 ] - * bexpr : rexp0 or expr0 depending on relative-mode setting - * rexp0 : rexp1 [ {||} rexp1...] - * rexp1 : rexp2 [ {^^} rexp2...] - * rexp2 : rexp3 [ {&&} rexp3...] - * rexp3 : expr0 [ {=,==,<>,!=,<,>,<=,>=} expr0 ] - * expr0 : expr1 [ {|} expr1...] - * expr1 : expr2 [ {^} expr2...] - * expr2 : expr3 [ {&} expr3...] - * expr3 : expr4 [ {<<,>>} expr4...] - * expr4 : expr5 [ {+,-} expr5...] - * expr5 : expr6 [ {*,/,%,//,%%} expr6...] - * expr6 : { ~,+,-,SEG } expr6 - * | (bexpr) - * | symbol - * | $ - * | number - */ - -static yasm_expr *rexp0(void), *rexp1(void), *rexp2(void), *rexp3(void); - -static yasm_expr *expr0(void), *expr1(void), *expr2(void), *expr3(void); -static yasm_expr *expr4(void), *expr5(void), *expr6(void); - -static yasm_expr *(*bexpr)(void); - -static yasm_expr *rexp0(void) -{ - yasm_expr *e, *f; - - e = rexp1(); - if (!e) - return NULL; - - while (i == TOKEN_DBL_OR) - { - i = scan(scpriv, tokval); - f = rexp1(); - if (!f) { - yasm_expr_destroy(e); - return NULL; - } - - e = yasm_expr_create_tree(e, YASM_EXPR_LOR, f, 0); - } - return e; -} - -static yasm_expr *rexp1(void) -{ - yasm_expr *e, *f; - - e = rexp2(); - if (!e) - return NULL; - - while (i == TOKEN_DBL_XOR) - { - i = scan(scpriv, tokval); - f = rexp2(); - if (!f) { - yasm_expr_destroy(e); - return NULL; - } - - e = yasm_expr_create_tree(e, YASM_EXPR_LXOR, f, 0); - } - return e; -} - -static yasm_expr *rexp2(void) -{ - yasm_expr *e, *f; - - e = rexp3(); - if (!e) - return NULL; - while (i == TOKEN_DBL_AND) - { - i = scan(scpriv, tokval); - f = rexp3(); - if (!f) { - yasm_expr_destroy(e); - return NULL; - } - - e = yasm_expr_create_tree(e, YASM_EXPR_LAND, f, 0); - } - return e; -} - -static yasm_expr *rexp3(void) -{ - yasm_expr *e, *f; - - e = expr0(); - if (!e) - return NULL; - - while (i == TOKEN_EQ || i == TOKEN_LT || i == TOKEN_GT || - i == TOKEN_NE || i == TOKEN_LE || i == TOKEN_GE) - { - int j = i; - i = scan(scpriv, tokval); - f = expr0(); - if (!f) { - yasm_expr_destroy(e); - return NULL; - } - - switch (j) - { - case TOKEN_EQ: - e = yasm_expr_create_tree(e, YASM_EXPR_EQ, f, 0); - break; - case TOKEN_LT: - e = yasm_expr_create_tree(e, YASM_EXPR_LT, f, 0); - break; - case TOKEN_GT: - e = yasm_expr_create_tree(e, YASM_EXPR_GT, f, 0); - break; - case TOKEN_NE: - e = yasm_expr_create_tree(e, YASM_EXPR_NE, f, 0); - break; - case TOKEN_LE: - e = yasm_expr_create_tree(e, YASM_EXPR_LE, f, 0); - break; - case TOKEN_GE: - e = yasm_expr_create_tree(e, YASM_EXPR_GE, f, 0); - break; - } - } - return e; -} - -static yasm_expr *expr0(void) -{ - yasm_expr *e, *f; - - e = expr1(); - if (!e) - return NULL; - - while (i == '|') - { - i = scan(scpriv, tokval); - f = expr1(); - if (!f) { - yasm_expr_destroy(e); - return NULL; - } - - e = yasm_expr_create_tree(e, YASM_EXPR_OR, f, 0); - } - return e; -} - -static yasm_expr *expr1(void) -{ - yasm_expr *e, *f; - - e = expr2(); - if (!e) - return NULL; - - while (i == '^') { - i = scan(scpriv, tokval); - f = expr2(); - if (!f) { - yasm_expr_destroy(e); - return NULL; - } - - e = yasm_expr_create_tree(e, YASM_EXPR_XOR, f, 0); - } - return e; -} - -static yasm_expr *expr2(void) -{ - yasm_expr *e, *f; - - e = expr3(); - if (!e) - return NULL; - - while (i == '&') { - i = scan(scpriv, tokval); - f = expr3(); - if (!f) { - yasm_expr_destroy(e); - return NULL; - } - - e = yasm_expr_create_tree(e, YASM_EXPR_AND, f, 0); - } - return e; -} - -static yasm_expr *expr3(void) -{ - yasm_expr *e, *f; - - e = expr4(); - if (!e) - return NULL; - - while (i == TOKEN_SHL || i == TOKEN_SHR) - { - int j = i; - i = scan(scpriv, tokval); - f = expr4(); - if (!f) { - yasm_expr_destroy(e); - return NULL; - } - - switch (j) { - case TOKEN_SHL: - e = yasm_expr_create_tree(e, YASM_EXPR_SHL, f, 0); - break; - case TOKEN_SHR: - e = yasm_expr_create_tree(e, YASM_EXPR_SHR, f, 0); - break; - } - } - return e; -} - -static yasm_expr *expr4(void) -{ - yasm_expr *e, *f; - - e = expr5(); - if (!e) - return NULL; - while (i == '+' || i == '-') - { - int j = i; - i = scan(scpriv, tokval); - f = expr5(); - if (!f) { - yasm_expr_destroy(e); - return NULL; - } - switch (j) { - case '+': - e = yasm_expr_create_tree(e, YASM_EXPR_ADD, f, 0); - break; - case '-': - e = yasm_expr_create_tree(e, YASM_EXPR_SUB, f, 0); - break; - } - } - return e; -} - -static yasm_expr *expr5(void) -{ - yasm_expr *e, *f; - - e = expr6(); - if (!e) - return NULL; - while (i == '*' || i == '/' || i == '%' || - i == TOKEN_SDIV || i == TOKEN_SMOD) - { - int j = i; - i = scan(scpriv, tokval); - f = expr6(); - if (!f) { - yasm_expr_destroy(e); - return NULL; - } - switch (j) { - case '*': - e = yasm_expr_create_tree(e, YASM_EXPR_MUL, f, 0); - break; - case '/': - e = yasm_expr_create_tree(e, YASM_EXPR_DIV, f, 0); - break; - case '%': - e = yasm_expr_create_tree(e, YASM_EXPR_MOD, f, 0); - break; - case TOKEN_SDIV: - e = yasm_expr_create_tree(e, YASM_EXPR_SIGNDIV, f, 0); - break; - case TOKEN_SMOD: - e = yasm_expr_create_tree(e, YASM_EXPR_SIGNMOD, f, 0); - break; - } - } - return e; -} - -static yasm_expr *expr6(void) -{ - yasm_expr *e = NULL; - - if (i == '-') { - i = scan(scpriv, tokval); - e = expr6(); - if (!e) - return NULL; - return yasm_expr_create_branch(YASM_EXPR_NEG, e, 0); - } else if (i == '+') { - i = scan(scpriv, tokval); - return expr6(); - } else if (i == '~') { - i = scan(scpriv, tokval); - e = expr6(); - if (!e) - return NULL; - return yasm_expr_create_branch(YASM_EXPR_NOT, e, 0); - } else if (i == TOKEN_SEG) { - i = scan(scpriv, tokval); - e = expr6(); - if (!e) - return NULL; - error(epriv, ERR_NONFATAL, "%s not supported", "SEG"); - return e; - } else if (i == '(') { - i = scan(scpriv, tokval); - e = bexpr(); - if (!e) - return NULL; - if (i != ')') { - error(epriv, ERR_NONFATAL, "expecting `)'"); - return NULL; - } - i = scan(scpriv, tokval); - return e; - } - else if (i == TOKEN_NUM || i == TOKEN_ID || - i == TOKEN_HERE || i == TOKEN_BASE) - { - switch (i) { - case TOKEN_NUM: - e = yasm_expr_create_ident(yasm_expr_int(tokval->t_integer), 0); - tokval->t_integer = NULL; - break; - case TOKEN_ID: - if (symtab) { - yasm_symrec *sym = - yasm_symtab_get(symtab, tokval->t_charptr); - if (sym) { - e = yasm_expr_create_ident(yasm_expr_sym(sym), 0); - } else { - error(epriv, ERR_NONFATAL, - "undefined symbol `%s' in preprocessor", - tokval->t_charptr); - e = yasm_expr_create_ident(yasm_expr_int( - yasm_intnum_create_int(1)), 0); - } - break; - } - /*fallthrough*/ - case TOKEN_HERE: - case TOKEN_BASE: - error(epriv, ERR_NONFATAL, - "cannot reference symbol `%s' in preprocessor", - (i == TOKEN_ID ? tokval->t_charptr : - i == TOKEN_HERE ? "$" : "$$")); - e = yasm_expr_create_ident(yasm_expr_int(yasm_intnum_create_int(1)), - 0); - break; - } - i = scan(scpriv, tokval); - return e; - } else { - error(epriv, ERR_NONFATAL, "expression syntax error"); - return NULL; - } -} - -yasm_expr *evaluate (scanner sc, void *scprivate, struct tokenval *tv, - void *eprivate, int critical, efunc report_error, - yasm_symtab *st) -{ - if (critical & CRITICAL) { - critical &= ~CRITICAL; - bexpr = rexp0; - } else - bexpr = expr0; - - scan = sc; - scpriv = scprivate; - tokval = tv; - error = report_error; - epriv = eprivate; - symtab = st; - - if (tokval->t_type == TOKEN_INVALID) - i = scan(scpriv, tokval); - else - i = tokval->t_type; - - return bexpr (); -} diff --git a/modules/preprocs/gas/gas-eval.h b/modules/preprocs/gas/gas-eval.h deleted file mode 100644 index 18dcc517..00000000 --- a/modules/preprocs/gas/gas-eval.h +++ /dev/null @@ -1,120 +0,0 @@ -/* eval.h header file for eval.c - * - * The Netwide Assembler is copyright (C) 1996 Simon Tatham and - * Julian Hall. All rights reserved. The software is - * redistributable under the licence given in the file "Licence" - * distributed in the NASM archive. - */ - -#ifndef YASM_EVAL_H -#define YASM_EVAL_H - -/* - * ------------------------- - * Error reporting functions - * ------------------------- - */ - -/* - * An error reporting function should look like this. - */ -typedef void (*efunc) (void *private_data, int severity, const char *fmt, ...); - -/* - * These are the error severity codes which get passed as the first - * argument to an efunc. - */ - -#define ERR_DEBUG 0x00000008 /* put out debugging message */ -#define ERR_WARNING 0x00000000 /* warn only: no further action */ -#define ERR_NONFATAL 0x00000001 /* terminate assembly after phase */ -#define ERR_FATAL 0x00000002 /* instantly fatal: exit with error */ -#define ERR_PANIC 0x00000003 /* internal error: panic instantly - * and dump core for reference */ -#define ERR_MASK 0x0000000F /* mask off the above codes */ -#define ERR_NOFILE 0x00000010 /* don't give source file name/line */ -#define ERR_USAGE 0x00000020 /* print a usage message */ -#define ERR_PASS1 0x00000040 /* only print this error on pass one */ - -/* - * These codes define specific types of suppressible warning. - */ - -#define ERR_WARN_MASK 0x0000FF00 /* the mask for this feature */ -#define ERR_WARN_SHR 8 /* how far to shift right */ - -#define ERR_WARN_MNP 0x00000100 /* macro-num-parameters warning */ -#define ERR_WARN_MSR 0x00000200 /* macro self-reference */ -#define ERR_WARN_OL 0x00000300 /* orphan label (no colon, and - * alone on line) */ -#define ERR_WARN_NOV 0x00000400 /* numeric overflow */ -#define ERR_WARN_GNUELF 0x00000500 /* using GNU ELF extensions */ -#define ERR_WARN_MAX 5 /* the highest numbered one */ - -/* - * The expression evaluator must be passed a scanner function; a - * standard scanner is provided as part of nasmlib.c. The - * preprocessor will use a different one. Scanners, and the - * token-value structures they return, look like this. - * - * The return value from the scanner is always a copy of the - * `t_type' field in the structure. - */ -struct tokenval { - int t_type; - yasm_intnum *t_integer, *t_inttwo; - char *t_charptr; -}; -typedef int (*scanner) (void *private_data, struct tokenval *tv); - -/* - * Token types returned by the scanner, in addition to ordinary - * ASCII character values, and zero for end-of-string. - */ -enum { /* token types, other than chars */ - TOKEN_INVALID = -1, /* a placeholder value */ - TOKEN_EOS = 0, /* end of string */ - TOKEN_EQ = '=', TOKEN_GT = '>', TOKEN_LT = '<', /* aliases */ - TOKEN_ID = 256, TOKEN_NUM, TOKEN_REG, TOKEN_INSN, /* major token types */ - TOKEN_ERRNUM, /* numeric constant with error in */ - TOKEN_HERE, TOKEN_BASE, /* $ and $$ */ - TOKEN_SPECIAL, /* BYTE, WORD, DWORD, FAR, NEAR, etc */ - TOKEN_PREFIX, /* A32, O16, LOCK, REPNZ, TIMES, etc */ - TOKEN_SHL, TOKEN_SHR, /* << and >> */ - TOKEN_SDIV, TOKEN_SMOD, /* // and %% */ - TOKEN_GE, TOKEN_LE, TOKEN_NE, /* >=, <= and <> (!= is same as <>) */ - TOKEN_DBL_AND, TOKEN_DBL_OR, TOKEN_DBL_XOR, /* &&, || and ^^ */ - TOKEN_SEG, TOKEN_WRT, /* SEG and WRT */ - TOKEN_FLOAT /* floating-point constant */ -}; - -/* - * The actual expression evaluator function looks like this. When - * called, it expects the first token of its expression to already - * be in `*tv'; if it is not, set tv->t_type to TOKEN_INVALID and - * it will start by calling the scanner. - * - * `critical' is non-zero if the expression may not contain forward - * references. The evaluator will report its own error if this - * occurs; if `critical' is 1, the error will be "symbol not - * defined before use", whereas if `critical' is 2, the error will - * be "symbol undefined". - * - * If `critical' has bit 8 set (in addition to its main value: 0x101 - * and 0x102 correspond to 1 and 2) then an extended expression - * syntax is recognised, in which relational operators such as =, < - * and >= are accepted, as well as low-precedence logical operators - * &&, ^^ and ||. - */ -#define CRITICAL 0x100 -typedef yasm_expr *(*evalfunc) (scanner sc, void *scprivate, struct tokenval *tv, - int critical, efunc error, yasm_symtab *symtab); - -/* - * The evaluator itself. - */ -yasm_expr *evaluate (scanner sc, void *scprivate, struct tokenval *tv, - void *eprivate, int critical, efunc report_error, - yasm_symtab *symtab); - -#endif diff --git a/modules/preprocs/gas/gas-preproc.c b/modules/preprocs/gas/gas-preproc.c deleted file mode 100644 index 0dd0531c..00000000 --- a/modules/preprocs/gas/gas-preproc.c +++ /dev/null @@ -1,1444 +0,0 @@ -/* - * GAS preprocessor (emulates GNU Assembler's preprocessor) - * - * Copyright (C) 2009 Alexei Svitkine - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND OTHER CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR OTHER CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -#include -#include - -#include -#include "modules/preprocs/gas/gas-eval.h" - -#define FALSE 0 -#define TRUE 1 -#define BSIZE 512 - -#ifndef MAXPATHLEN -#define MAXPATHLEN 1024 -#endif - -typedef struct buffered_line { - char *line; - int line_number; - SLIST_ENTRY(buffered_line) next; -} buffered_line; - -typedef struct included_file { - char *filename; - int lines_remaining; - SLIST_ENTRY(included_file) next; -} included_file; - -typedef struct macro_entry { - char *name; - int num_params; - char **params; - int num_lines; - char **lines; - STAILQ_ENTRY(macro_entry) next; -} macro_entry; - -typedef struct deferred_define { - char *name; - char *value; - SLIST_ENTRY(deferred_define) next; -} deferred_define; - -typedef struct expr_state { - const char *string; - char *symbol; - int string_cursor; -} expr_state; - -typedef struct yasm_preproc_gas { - yasm_preproc_base preproc; /* base structure */ - - FILE *in; - char *in_filename; - - yasm_symtab *defines; - SLIST_HEAD(deferred_defines_head, deferred_define) deferred_defines; - - int depth; - int skip_depth; - - int in_comment; - - expr_state expr; - - SLIST_HEAD(buffered_lines_head, buffered_line) buffered_lines; - SLIST_HEAD(included_files_head, included_file) included_files; - STAILQ_HEAD(macros_head, macro_entry) macros; - - int in_line_number; - int next_line_number; - int current_line_number; /* virtual (output) line number */ - - yasm_linemap *cur_lm; - yasm_errwarns *errwarns; - int fatal_error; - int detect_errors_only; -} yasm_preproc_gas; - -yasm_preproc_module yasm_gas_LTX_preproc; - -/* Forward declarations. */ - -static int substitute_values(yasm_preproc_gas *pp, char **line_ptr); - -/* String helpers. */ - -static const char *starts_with(const char *big, const char *little) -{ - while (*little) { - if (*little++ != *big++) { - return NULL; - } - } - return big; -} - -static void skip_whitespace(const char **line) -{ - while (isspace(**line)) { - (*line)++; - } -} - -static void skip_whitespace2(char **line) -{ - while (isspace(**line)) { - (*line)++; - } -} - -static const char *matches(const char *line, const char *directive) -{ - skip_whitespace(&line); - - if (*line == '.') { - line = starts_with(line + 1, directive); - if (line && (!*line || isspace(*line))) { - skip_whitespace(&line); - return line; - } - } - - return NULL; -} - -static int unquote(const char *arg, char *to, size_t to_size, char q, char expected, const char **remainder) -{ - const char *quote; - const char *end; - size_t len; - - skip_whitespace(&arg); - if (*arg != q) { - return -1; - } - - arg++; - - end = arg; - do { - quote = strchr(end, q); - if (!quote) { - return -2; - } - end = quote + 1; - } while (*(quote - 1) == '\\'); - - skip_whitespace(&end); - if (*end != expected) { - return -3; - } - - if (remainder) { - *remainder = end + 1; - } - - len = (size_t) (quote - arg); - if (len >= to_size) { - return -4; - } - - strncpy(to, arg, len); - to[len] = '\0'; - - return (int) len; -} - -/* Line-reading. */ - -static char *read_line_from_file(yasm_preproc_gas *pp, FILE *file) -{ - int bufsize = BSIZE; - char *buf; - char *p; - - buf = yasm_xmalloc((size_t)bufsize); - - /* Loop to ensure entire line is read (don't want to limit line length). */ - p = buf; - for (;;) { - if (!fgets(p, bufsize - (p - buf), file)) { - if (ferror(file)) { - yasm_error_set(YASM_ERROR_IO, N_("error when reading from file")); - yasm_errwarn_propagate(pp->errwarns, pp->current_line_number); - } - break; - } - p += strlen(p); - if (p > buf && p[-1] == '\n') { - break; - } - if ((p - buf) + 1 >= bufsize) { - /* Increase size of buffer */ - char *oldbuf = buf; - bufsize *= 2; - buf = yasm_xrealloc(buf, (size_t) bufsize); - p = buf + (p - oldbuf); - } - } - - if (p == buf) { - /* No data; must be at EOF */ - yasm_xfree(buf); - return NULL; - } - - /* Strip the line ending */ - buf[strcspn(buf, "\r\n")] = '\0'; - return buf; -} - -static char *read_line(yasm_preproc_gas *pp) -{ - char *line; - - if (!SLIST_EMPTY(&pp->included_files)) { - included_file *inc_file = SLIST_FIRST(&pp->included_files); - if (inc_file->lines_remaining <= 0) { - SLIST_REMOVE_HEAD(&pp->included_files, next); - yasm_xfree(inc_file->filename); - yasm_xfree(inc_file); - } - } - - if (!SLIST_EMPTY(&pp->buffered_lines)) { - buffered_line *bline = SLIST_FIRST(&pp->buffered_lines); - SLIST_REMOVE_HEAD(&pp->buffered_lines, next); - line = bline->line; - if (bline->line_number != -1) { - pp->next_line_number = bline->line_number; - } - yasm_xfree(bline); - if (!SLIST_EMPTY(&pp->included_files)) { - SLIST_FIRST(&pp->included_files)->lines_remaining--; - } - return line; - } - - line = read_line_from_file(pp, pp->in); - if (line) { - pp->in_line_number++; - pp->next_line_number = pp->in_line_number; - } - - return line; -} - -static const char *get_arg(yasm_preproc_gas *pp, const char *src, char *dest, size_t dest_size) -{ - const char *comma = strchr(src, ','); - if (comma) { - size_t len = (size_t) (comma - src); - if (len >= dest_size) { - len = dest_size - 1; - } - strncpy(dest, src, len); - dest[len] = '\0'; - comma++; - skip_whitespace(&comma); - } else { - yasm_error_set(YASM_ERROR_SYNTAX, N_("expected comma")); - yasm_errwarn_propagate(pp->errwarns, pp->current_line_number); - } - return comma; -} - -/* GAS expression evaluation. */ - -static char get_char(yasm_preproc_gas *pp) -{ - return pp->expr.string[pp->expr.string_cursor]; -} - -static const char *get_str(yasm_preproc_gas *pp) -{ - return pp->expr.string + pp->expr.string_cursor; -} - -static void next_char(yasm_preproc_gas *pp) -{ - pp->expr.string_cursor++; -} - -static int ishex(char c) -{ - c = tolower(c); - return isdigit(c) || (c >= 'a' && c <= 'f'); -} - -static void gas_scan_init(yasm_preproc_gas *pp, struct tokenval *tokval, const char *arg1) -{ - pp->expr.symbol = NULL; - pp->expr.string = arg1; - pp->expr.string_cursor = 0; - memset(tokval, 0, sizeof(struct tokenval)); - tokval->t_type = TOKEN_INVALID; -} - -static void gas_scan_cleanup(yasm_preproc_gas *pp, struct tokenval *tokval) -{ - if (tokval->t_integer) { - yasm_intnum_destroy(tokval->t_integer); - tokval->t_integer = NULL; - } - if (pp->expr.symbol) { - yasm_xfree(pp->expr.symbol); - pp->expr.symbol = NULL; - } -} - -static int gas_scan(void *preproc, struct tokenval *tokval) -{ - yasm_preproc_gas *pp = (yasm_preproc_gas *) preproc; - char c = get_char(pp); - const char *str; - - tokval->t_charptr = NULL; - - if (c == '\0') { - return tokval->t_type = TOKEN_EOS; - } - - if (isspace(c)) { - do { - next_char(pp); - c = get_char(pp); - } while (isspace(c)); - } - - if (isdigit(c)) { - int char_index = 0; - int value = 0; - - do { - value = value*10 + (c - '0'); - char_index++; - next_char(pp); - c = get_char(pp); - if (char_index == 1 && c == 'x' && value == 0) { - next_char(pp); - c = get_char(pp); - /* Hex notation. */ - while (ishex(c)) { - if (isdigit(c)) { - value = (value << 4) | (c - '0'); - } else { - value = (value << 4) | (tolower(c) - 'a' + 0xa); - } - next_char(pp); - c = get_char(pp); - } - break; - } - } while (isdigit(c)); - - if (tokval->t_integer) { - yasm_intnum_destroy(tokval->t_integer); - } - tokval->t_integer = yasm_intnum_create_int(value); - return tokval->t_type = TOKEN_NUM; - } - - tokval->t_type = TOKEN_INVALID; - str = get_str(pp); - - { - /* It should be tested whether GAS supports all of these or if there are missing ones. */ - unsigned i; - struct { - const char *op; - int token; - } ops[] = { - { "<<", TOKEN_SHL }, - { ">>", TOKEN_SHR }, - { "//", TOKEN_SDIV }, - { "%%", TOKEN_SMOD }, - { "==", TOKEN_EQ }, - { "!=", TOKEN_NE }, - { "<>", TOKEN_NE }, - { "<>", TOKEN_NE }, - { "<=", TOKEN_LE }, - { ">=", TOKEN_GE }, - { "&&", TOKEN_DBL_AND }, - { "^^", TOKEN_DBL_XOR }, - { "||", TOKEN_DBL_OR } - }; - if (strlen(str) > 1) { - for (i = 0; i < sizeof(ops)/sizeof(ops[0]); i++) { - if (!strncmp(str, ops[i].op, 2)) { - tokval->t_type = ops[i].token; - break; - } - } - } - } - - if (tokval->t_type != TOKEN_INVALID) { - next_char(pp); - next_char(pp); - } else { - str = get_str(pp); - - next_char(pp); - tokval->t_type = c; - - /* Is it a symbol? If so we need to make it a TOKEN_ID. */ - if (isalpha(c) || c == '_' || c == '.' || c == '%') { - int symbol_length = 1; - - c = get_char(pp); - while (isalnum(c) || c == '$' || c == '_') { - symbol_length++; - next_char(pp); - c = get_char(pp); - } - - pp->expr.symbol = yasm_xrealloc(pp->expr.symbol, symbol_length + 1); - memcpy(pp->expr.symbol, str, symbol_length); - pp->expr.symbol[symbol_length] = '\0'; - - tokval->t_type = TOKEN_ID; - tokval->t_charptr = pp->expr.symbol; - } - } - - return tokval->t_type; -} - -static void gas_err(void *private_data, int severity, const char *fmt, ...) -{ - va_list args; - yasm_preproc_gas *pp = private_data; - - if (!pp->detect_errors_only) { - va_start(args, fmt); - yasm_error_set_va(YASM_ERROR_SYNTAX, N_(fmt), args); - yasm_errwarn_propagate(pp->errwarns, pp->current_line_number); - va_end(args); - } - - pp->fatal_error = 1; -} - -static long eval_expr(yasm_preproc_gas *pp, const char *arg1) -{ - struct tokenval tv; - yasm_expr *expr; - yasm_intnum *intn; - long value; - expr_state prev_state; - - if (!*arg1) { - return 0; - } - - prev_state = pp->expr; - gas_scan_init(pp, &tv, arg1); - expr = evaluate(gas_scan, pp, &tv, pp, CRITICAL, gas_err, pp->defines); - intn = yasm_expr_get_intnum(&expr, 0); - value = yasm_intnum_get_int(intn); - yasm_expr_destroy(expr); - gas_scan_cleanup(pp, &tv); - pp->expr = prev_state; - - return value; -} - -/* If-directive helpers. */ - -static int handle_if(yasm_preproc_gas *pp, int is_true) -{ - assert(pp->depth >= 0); - assert(pp->skip_depth == 0); - if (is_true) { - pp->depth++; - } else { - pp->skip_depth = 1; - } - return 1; -} - -static int handle_endif(yasm_preproc_gas *pp) -{ - if (pp->depth) { - pp->depth--; - } else { - yasm_error_set(YASM_ERROR_SYNTAX, N_("\".endif\" without \".if\"")); - yasm_errwarn_propagate(pp->errwarns, pp->current_line_number); - return 0; - } - return 1; -} - -static int handle_else(yasm_preproc_gas *pp, int is_elseif) -{ - if (!pp->depth) { - yasm_error_set(YASM_ERROR_SYNTAX, N_("\".%s\" without \".if\""), is_elseif ? "elseif" : "else"); - yasm_errwarn_propagate(pp->errwarns, pp->current_line_number); - return 0; - } else { - pp->skip_depth = 1; - } - return 1; -} - -/* Directive-handling functions. */ - -static int eval_if(yasm_preproc_gas *pp, int negate, const char *arg1) -{ - long value; - if (!*arg1) { - yasm_error_set(YASM_ERROR_SYNTAX, N_("expression is required in \".if\" statement")); - yasm_errwarn_propagate(pp->errwarns, pp->current_line_number); - return 0; - } - value = eval_expr(pp, arg1); - handle_if(pp, (negate ? !value : !!value)); - return 1; -} - -static int eval_else(yasm_preproc_gas *pp, int unused) -{ - return handle_else(pp, 0); -} - -static int eval_endif(yasm_preproc_gas *pp, int unused) -{ - return handle_endif(pp); -} - -static int eval_elseif(yasm_preproc_gas *pp, int unused, const char *arg1) -{ - if (!*arg1) { - yasm_error_set(YASM_ERROR_SYNTAX, N_("expression is required in \".elseif\" statement")); - yasm_errwarn_propagate(pp->errwarns, pp->current_line_number); - return 0; - } - if (!handle_else(pp, 1)) { - return 0; - } - return eval_if(pp, 0, arg1); -} - -static int eval_ifb(yasm_preproc_gas *pp, int negate, const char *arg1) -{ - int is_blank = !*arg1; - return handle_if(pp, (negate ? !is_blank : is_blank)); -} - -static int eval_ifc(yasm_preproc_gas *pp, int negate, const char *args) -{ - char arg1[512], arg2[512]; - const char *remainder; - int len = unquote(args, arg1, sizeof(arg1), '\'', ',', &remainder); - if (len >= 0) { - len = unquote(remainder, arg2, sizeof(arg2), '\'', '\0', NULL); - if (len >= 0) { - int result = !strcmp(arg1, arg2); - return handle_if(pp, (negate ? !result : result)); - } - } else { - /* first argument was not single-quoted, assume non-quoted mode */ - remainder = get_arg(pp, args, arg1, sizeof(arg1)); - if (remainder) { - int result = !strcmp(arg1, remainder); - return handle_if(pp, (negate ? !result : result)); - } - } - yasm_error_set(YASM_ERROR_SYNTAX, N_("\"%s\" expects two single-quoted or unquoted arguments"), negate ? ".ifnc" : ".ifc"); - yasm_errwarn_propagate(pp->errwarns, pp->current_line_number); - return 0; -} - -static int eval_ifeqs(yasm_preproc_gas *pp, int negate, const char *args) -{ - char arg1[512], arg2[512]; - const char *remainder; - int len = unquote(args, arg1, sizeof(arg1), '"', ',', &remainder); - if (len >= 0) { - len = unquote(remainder, arg2, sizeof(arg2), '"', '\0', NULL); - if (len >= 0) { - int result = !strcmp(arg1, arg2); - return handle_if(pp, (negate ? !result : result)); - } - } - yasm_error_set(YASM_ERROR_SYNTAX, N_("\"%s\" expects two double-quoted arguments"), negate ? ".ifnes" : ".ifeqs"); - yasm_errwarn_propagate(pp->errwarns, pp->current_line_number); - return 1; -} - -static int eval_ifdef(yasm_preproc_gas *pp, int negate, const char *name) -{ - yasm_symrec *rec = yasm_symtab_get(pp->defines, name); - int result = (rec != NULL); - return handle_if(pp, (negate ? !result : result)); -} - -static int eval_ifge(yasm_preproc_gas *pp, int negate, const char *arg1) -{ - long value = eval_expr(pp, arg1); - int result = (value >= 0); - return handle_if(pp, (negate ? !result : result)); -} - -static int eval_ifgt(yasm_preproc_gas *pp, int negate, const char *arg1) -{ - long value = eval_expr(pp, arg1); - int result = (value > 0); - return handle_if(pp, (negate ? !result : result)); -} - -static int eval_include(yasm_preproc_gas *pp, int unused, const char *arg1) -{ - char *current_filename; - char filename[MAXPATHLEN]; - char *line; - int num_lines; - FILE *file; - buffered_line *prev_bline; - included_file *inc_file; - - if (unquote(arg1, filename, sizeof(filename), '"', '\0', NULL) < 0) { - yasm_error_set(YASM_ERROR_SYNTAX, N_("string expected")); - yasm_errwarn_propagate(pp->errwarns, pp->current_line_number); - return 0; - } - - if (SLIST_EMPTY(&pp->included_files)) { - current_filename = pp->in_filename; - } else { - current_filename = SLIST_FIRST(&pp->included_files)->filename; - } - file = yasm_fopen_include(filename, current_filename, "r", NULL); - if (!file) { - yasm_error_set(YASM_ERROR_SYNTAX, N_("unable to open included file \"%s\""), filename); - yasm_errwarn_propagate(pp->errwarns, pp->current_line_number); - return 0; - } - - num_lines = 0; - prev_bline = NULL; - line = read_line_from_file(pp, file); - while (line) { - buffered_line *bline = yasm_xmalloc(sizeof(buffered_line)); - bline->line = line; - bline->line_number = -1; - if (prev_bline) { - SLIST_INSERT_AFTER(prev_bline, bline, next); - } else { - SLIST_INSERT_HEAD(&pp->buffered_lines, bline, next); - } - prev_bline = bline; - line = read_line_from_file(pp, file); - num_lines++; - } - - inc_file = yasm_xmalloc(sizeof(included_file)); - inc_file->filename = yasm__xstrdup(filename); - inc_file->lines_remaining = num_lines; - SLIST_INSERT_HEAD(&pp->included_files, inc_file, next); - return 1; -} - -static int try_eval_expr(yasm_preproc_gas *pp, const char *value, long *result) -{ - int success; - - pp->detect_errors_only = 1; - *result = eval_expr(pp, value); - success = !pp->fatal_error; - pp->fatal_error = 0; - pp->detect_errors_only = 0; - - return success; -} - -static int remove_define(yasm_preproc_gas *pp, const char *name, int allow_redefine) -{ - yasm_symrec *rec = yasm_symtab_get(pp->defines, name); - if (rec) { - const yasm_symtab_iter *entry; - yasm_symtab *new_defines; - - if (!allow_redefine) { - yasm_error_set(YASM_ERROR_SYNTAX, N_("symbol \"%s\" is already defined"), name); - yasm_errwarn_propagate(pp->errwarns, pp->current_line_number); - return 0; - } - - new_defines = yasm_symtab_create(); - - for (entry = yasm_symtab_first(pp->defines); entry; entry = yasm_symtab_next(entry)) { - yasm_symrec *entry_rec = yasm_symtab_iter_value(entry); - const char *rec_name = yasm_symrec_get_name(entry_rec); - if (strcmp(rec_name, name)) { - yasm_intnum *num = yasm_intnum_create_int(eval_expr(pp, rec_name)); - yasm_expr *expr = yasm_expr_create_ident(yasm_expr_int(num), 0); - yasm_symtab_define_equ(new_defines, rec_name, expr, 0); - } - } - - yasm_symtab_destroy(pp->defines); - pp->defines = new_defines; - } - return (rec != NULL); -} - -static void add_define(yasm_preproc_gas *pp, const char *name, long value, int allow_redefine, int substitute) -{ - deferred_define *def, *prev_def, *temp_def; - yasm_intnum *num; - yasm_expr *expr; - - remove_define(pp, name, allow_redefine); - - /* Add the new define. */ - num = yasm_intnum_create_int(value); - expr = yasm_expr_create_ident(yasm_expr_int(num), 0); - yasm_symtab_define_equ(pp->defines, name, expr, 0); - - /* Perform substitution on any deferred defines. */ - if (substitute) { - prev_def = NULL; - temp_def = NULL; - SLIST_FOREACH_SAFE(def, &pp->deferred_defines, next, temp_def) { - if (substitute_values(pp, &def->value)) { - /* Value was updated - check if it can be added to the symtab. */ - if (try_eval_expr(pp, def->value, &value)) { - add_define(pp, def->name, value, FALSE, FALSE); - if (prev_def) { - SLIST_NEXT(prev_def, next) = SLIST_NEXT(def, next); - } else { - SLIST_FIRST(&pp->deferred_defines) = SLIST_NEXT(def, next); - } - yasm_xfree(def->name); - yasm_xfree(def->value); - yasm_xfree(def); - continue; - } - } - prev_def = def; - } - } -} - -static int eval_set(yasm_preproc_gas *pp, int allow_redefine, const char *name, const char *value) -{ - if (!pp->skip_depth) { - long result; - - if (!try_eval_expr(pp, value, &result)) { - deferred_define *def; - remove_define(pp, name, allow_redefine); - def = yasm_xmalloc(sizeof(deferred_define)); - def->name = yasm__xstrdup(name); - def->value = yasm__xstrdup(value); - substitute_values(pp, &def->value); - SLIST_INSERT_HEAD(&pp->deferred_defines, def, next); - } else { - add_define(pp, name, result, allow_redefine, TRUE); - } - } - return 1; -} - -static int eval_macro(yasm_preproc_gas *pp, int unused, char *args) -{ - char *end; - char *line; - long nesting = 1; - macro_entry *macro = yasm_xmalloc(sizeof(macro_entry)); - - memset(macro, 0, sizeof(macro_entry)); - - end = args; - while (*end && !isspace(*end)) { - end++; - } - macro->name = yasm_xmalloc(end - args + 1); - memcpy(macro->name, args, end - args); - macro->name[end - args] = '\0'; - - skip_whitespace2(&end); - while (*end) { - args = end; - while (*end && !isspace(*end) && *end != ',') { - end++; - } - macro->num_params++; - macro->params = yasm_xrealloc(macro->params, macro->num_params*sizeof(char *)); - macro->params[macro->num_params - 1] = yasm_xmalloc(end - args + 1); - memcpy(macro->params[macro->num_params - 1], args, end - args); - macro->params[macro->num_params - 1][end - args] = '\0'; - skip_whitespace2(&end); - if (*end == ',') { - end++; - skip_whitespace2(&end); - } - } - - STAILQ_INSERT_TAIL(&pp->macros, macro, next); - - line = read_line(pp); - while (line) { - char *line2 = line; - skip_whitespace2(&line2); - if (starts_with(line2, ".macro")) { - nesting++; - } else if (starts_with(line2, ".endm") && --nesting == 0) { - return 1; - } - macro->num_lines++; - macro->lines = yasm_xrealloc(macro->lines, macro->num_lines*sizeof(char *)); - macro->lines[macro->num_lines - 1] = line; - line = read_line(pp); - } - - yasm_error_set(YASM_ERROR_SYNTAX, N_("unexpected EOF in \".macro\" block")); - yasm_errwarn_propagate(pp->errwarns, yasm_linemap_get_current(pp->cur_lm)); - return 0; -} - -static int eval_endm(yasm_preproc_gas *pp, int unused) -{ - yasm_error_set(YASM_ERROR_SYNTAX, N_("\".endm\" without \".macro\"")); - yasm_errwarn_propagate(pp->errwarns, yasm_linemap_get_current(pp->cur_lm)); - return 0; -} - -static void get_param_value(macro_entry *macro, int param_index, const char *args, const char **value, int *length) -{ - int arg_index = 0; - const char *default_value = NULL; - const char *end, *eq = strstr(macro->params[param_index], "="); - - if (eq) { - default_value = eq + 1; - } - - skip_whitespace(&args); - end = args; - while (*end) { - args = end; - while (*end && !isspace(*end) && *end != ',') { - end++; - } - if (arg_index == param_index) { - if (end == args && default_value) { - *value = default_value; - *length = strlen(default_value); - } else { - *value = args; - *length = end - args; - } - return; - } - arg_index++; - skip_whitespace(&end); - if (*end == ',') { - end++; - skip_whitespace(&end); - } - } - - *value = default_value; - *length = (default_value ? strlen(default_value) : 0); -} - -static void expand_macro(yasm_preproc_gas *pp, macro_entry *macro, const char *args) -{ - int i, j; - buffered_line *prev_bline = NULL; - - for (i = 0; i < macro->num_lines; i++) { - buffered_line *bline = yasm_xmalloc(sizeof(buffered_line)); - struct tokenval tokval; - int prev_was_backslash = FALSE; - int line_length = strlen(macro->lines[i]); - char *work = yasm__xstrdup(macro->lines[i]); - expr_state prev_state = pp->expr; - - gas_scan_init(pp, &tokval, work); - while (gas_scan(pp, &tokval) != TOKEN_EOS) { - if (prev_was_backslash) { - if (tokval.t_type == TOKEN_ID) { - for (j = 0; j < macro->num_params; j++) { - char *end = strstr(macro->params[j], "="); - int len = (end ? (size_t)(end - macro->params[j]) - : strlen(macro->params[j])); - if (!tokval.t_charptr) { - continue; - } - if (!strncmp(tokval.t_charptr, macro->params[j], len) - && tokval.t_charptr[len] == '\0') { - /* now, find matching argument. */ - const char *value; - char *line = work + (pp->expr.string - work); - int cursor = pp->expr.string_cursor; - int value_length, delta; - - get_param_value(macro, j, args, &value, &value_length); - - len++; /* leading slash */ - delta = value_length - len; - line_length += delta; - if (delta > 0) { - line = yasm_xrealloc(line, line_length + 1); - } - memmove(line + cursor - len + value_length, line + cursor, strlen(line + cursor) + 1); - memcpy(line + cursor - len, value, value_length); - pp->expr.string = work = line; - pp->expr.string_cursor += delta; - if (pp->expr.symbol == tokval.t_charptr) { - tokval.t_charptr = NULL; - } - if (pp->expr.symbol) { - yasm_xfree(pp->expr.symbol); - pp->expr.symbol = NULL; - } - } - } - } - prev_was_backslash = FALSE; - } else if (tokval.t_type == '\\') { - prev_was_backslash = TRUE; - } - } - gas_scan_cleanup(pp, &tokval); - - bline->line = work + (pp->expr.string - work); - bline->line_number = -1; - pp->expr = prev_state; - - if (prev_bline) { - SLIST_INSERT_AFTER(prev_bline, bline, next); - } else { - SLIST_INSERT_HEAD(&pp->buffered_lines, bline, next); - } - prev_bline = bline; - } -} - -static int eval_rept(yasm_preproc_gas *pp, int unused, const char *arg1) -{ - long i, n = eval_expr(pp, arg1); - long num_lines = 0; - long nesting = 1; - char *line = read_line(pp); - buffered_line *prev_bline = NULL; - SLIST_HEAD(buffered_lines_head, buffered_line) lines; - int rept_start_file_line_number = pp->next_line_number - 1; - int rept_start_output_line_number = pp->current_line_number; - - SLIST_INIT(&lines); - - while (line) { - char *line2 = line; - skip_whitespace2(&line2); - if (starts_with(line2, ".rept")) { - nesting++; - } else if (starts_with(line2, ".endr") && --nesting == 0) { - for (i = 0; i < n; i++) { - buffered_line *current_line; - prev_bline = NULL; - SLIST_FOREACH(current_line, &lines, next) { - buffered_line *bline = yasm_xmalloc(sizeof(buffered_line)); - bline->line = yasm__xstrdup(current_line->line); - bline->line_number = current_line->line_number; - if (prev_bline) { - SLIST_INSERT_AFTER(prev_bline, bline, next); - } else { - SLIST_INSERT_HEAD(&pp->buffered_lines, bline, next); - } - prev_bline = bline; - } - } - if (!SLIST_EMPTY(&pp->included_files)) { - included_file *inc_file = SLIST_FIRST(&pp->included_files); - inc_file->lines_remaining += n * num_lines; - } - while (!SLIST_EMPTY(&lines)) { - buffered_line *bline = SLIST_FIRST(&lines); - SLIST_REMOVE_HEAD(&lines, next); - yasm_xfree(bline->line); - yasm_xfree(bline); - } - yasm_xfree(line); - return 1; - } - if (n > 0) { - buffered_line *bline = yasm_xmalloc(sizeof(buffered_line)); - bline->line = line; - bline->line_number = pp->next_line_number; - if (prev_bline) { - SLIST_INSERT_AFTER(prev_bline, bline, next); - } else { - SLIST_INSERT_HEAD(&lines, bline, next); - } - prev_bline = bline; - } else { - yasm_xfree(line); - } - line = read_line(pp); - num_lines++; - } - yasm_linemap_set(pp->cur_lm, pp->in_filename, rept_start_output_line_number, rept_start_file_line_number, 0); - yasm_error_set(YASM_ERROR_SYNTAX, N_("rept without matching endr")); - yasm_errwarn_propagate(pp->errwarns, rept_start_output_line_number); - return 0; -} - -static int eval_endr(yasm_preproc_gas *pp, int unused) -{ - yasm_error_set(YASM_ERROR_SYNTAX, N_("\".endr\" without \".rept\"")); - yasm_errwarn_propagate(pp->errwarns, pp->current_line_number); - return 0; -} - -/* Top-level line processing. */ - -typedef int (*pp_fn0_t)(yasm_preproc_gas *pp, int param); -typedef int (*pp_fn1_t)(yasm_preproc_gas *pp, int param, const char *arg1); -typedef int (*pp_fn2_t)(yasm_preproc_gas *pp, int param, const char *arg1, const char *arg2); - -#define FN(f) ((pp_fn0_t) &(f)) - -static char *find_str_bound(char *line) -{ - for (; line[0]; ++line) { - if (line[0] == '"') return line; - if (line[0] == '\\' && line[1] == '"') ++line; - } - return NULL; -} - -static char *find_comment(char *line) -{ - char *c, *s; - - for (c = line, s = line; (c = strstr(c, "/*")); s = c) { - for (;;) { - s = find_str_bound(s); - if (!s || s > c) return c; - - s = find_str_bound(s + 1); - if (!s || s > c) return NULL; - } - } - - return NULL; -} - -static void kill_comments(yasm_preproc_gas *pp, char *line) -{ - int next = 2; - char *cstart; - - skip_whitespace2(&line); - if (*line == '#' || !strncmp(line, "//", 2)) { - *line = '\0'; - return; - } - - if (pp->in_comment) { - cstart = line; - next = 0; - } else { - cstart = find_comment(line); - next = 2; - } - - while (cstart) { - char *cend = strstr(cstart + next, "*/"); - - if (!cend) { - *cstart = '\0'; - pp->in_comment = TRUE; - return; - } - - memmove(cstart, cend + 2, strlen(cend + 2) + 1); - pp->in_comment = FALSE; - cstart = strstr(cstart, "/*"); - next = 2; - } -} - -static int substitute_values(yasm_preproc_gas *pp, char **line_ptr) -{ - int changed = 0; - char *line = *line_ptr; - int line_length = strlen(line); - struct tokenval tokval; - expr_state prev_state = pp->expr; - - gas_scan_init(pp, &tokval, line); - while (gas_scan(pp, &tokval) != TOKEN_EOS) { - if (tokval.t_type == TOKEN_ID) { - yasm_symrec *rec = yasm_symtab_get(pp->defines, tokval.t_charptr); - if (rec) { - int cursor = pp->expr.string_cursor; - int len = strlen(tokval.t_charptr); - char value[64]; - int value_length = sprintf(value, "%ld", eval_expr(pp, tokval.t_charptr)); - int delta = value_length - len; - - line_length += delta; - if (delta > 0) { - line = yasm_xrealloc(line, line_length + 1); - } - memmove(line + cursor - len + value_length, line + cursor, strlen(line + cursor) + 1); - memcpy(line + cursor - len, value, value_length); - pp->expr.string = line; - pp->expr.string_cursor = cursor + delta; - changed = 1; - } - yasm_xfree(pp->expr.symbol); - pp->expr.symbol = NULL; - } - } - gas_scan_cleanup(pp, &tokval); - pp->expr = prev_state; - - if (changed) { - *line_ptr = line; - } - - return changed; -} - -static int process_line(yasm_preproc_gas *pp, char **line_ptr) -{ - macro_entry *macro; - size_t i; - char *line = *line_ptr; - struct { - const char *name; - int nargs; - pp_fn0_t fn; - int param; - } directives[] = { - {"else", 0, FN(eval_else), 0}, - {"elseif", 1, FN(eval_elseif), 0}, - {"endif", 0, FN(eval_endif), 0}, - {"if", 1, FN(eval_if), 0}, - {"ifb", 1, FN(eval_ifb), 0}, - {"ifc", 1, FN(eval_ifc), 0}, - {"ifdef", 1, FN(eval_ifdef), 0}, - {"ifeq", 1, FN(eval_if), 1}, - {"ifeqs", 1, FN(eval_ifeqs), 0}, - {"ifge", 1, FN(eval_ifge), 0}, - {"ifgt", 1, FN(eval_ifgt), 0}, - {"ifle", 1, FN(eval_ifgt), 1}, - {"iflt", 1, FN(eval_ifge), 1}, - {"ifnb", 1, FN(eval_ifb), 1}, - {"ifnc", 1, FN(eval_ifc), 1}, - {"ifndef", 1, FN(eval_ifdef), 1}, - {"ifnotdef", 1, FN(eval_ifdef), 1}, - {"ifne", 1, FN(eval_if), 0}, - {"ifnes", 1, FN(eval_ifeqs), 1}, - {"include", 1, FN(eval_include), 0}, - {"set", 2, FN(eval_set), 1}, - {"equ", 2, FN(eval_set), 1}, - {"equiv", 2, FN(eval_set), 0}, - {"macro", 1, FN(eval_macro), 0}, - {"endm", 0, FN(eval_endm), 0}, - {"rept", 1, FN(eval_rept), 0}, - {"endr", 1, FN(eval_endr), 0}, - }; - - kill_comments(pp, line); - skip_whitespace2(&line); - if (*line == '\0') { - return FALSE; - } - - /* See if this is a macro call. */ - STAILQ_FOREACH(macro, &pp->macros, next) { - const char *remainder = starts_with(line, macro->name); - if (remainder && (!*remainder || isspace(*remainder))) { - skip_whitespace2(&line); - expand_macro(pp, macro, remainder); - return FALSE; - } - } - - for (i = 0; i < sizeof(directives)/sizeof(directives[0]); i++) { - char buf1[1024]; - const char *remainder = matches(line, directives[i].name); - - if (remainder) { - if (pp->skip_depth) { - if (!strncmp("if", directives[i].name, 2)) { - pp->skip_depth++; - } else if (!strcmp("endif", directives[i].name)) { - pp->skip_depth--; - } else if (!strcmp("else", directives[i].name)) { - if (pp->skip_depth == 1) { - pp->skip_depth = 0; - pp->depth++; - } - } - return FALSE; - } else if (directives[i].nargs == 0) { - pp_fn0_t fn = (pp_fn0_t) directives[i].fn; - pp->fatal_error = !fn(pp, directives[i].param); - return FALSE; - } else if (directives[i].nargs == 1) { - pp_fn1_t fn = (pp_fn1_t) directives[i].fn; - skip_whitespace(&remainder); - pp->fatal_error = !fn(pp, directives[i].param, remainder); - return FALSE; - } else if (directives[i].nargs == 2) { - remainder = get_arg(pp, remainder, buf1, sizeof(buf1)); - if (!remainder || !*remainder || !*buf1) { - yasm_error_set(YASM_ERROR_SYNTAX, N_("\".%s\" expects two arguments"), directives[i].name); - yasm_errwarn_propagate(pp->errwarns, pp->current_line_number); - pp->fatal_error = 1; - } else { - pp_fn2_t fn = (pp_fn2_t) directives[i].fn; - pp->fatal_error = !fn(pp, directives[i].param, buf1, remainder); - } - return FALSE; - } - } - } - - if (pp->skip_depth == 0) { - substitute_values(pp, line_ptr); - return TRUE; - } - - return FALSE; -} - -/* Functions exported by the preprocessor. */ - -static yasm_preproc * -gas_preproc_create(const char *in_filename, yasm_symtab *symtab, - yasm_linemap *lm, yasm_errwarns *errwarns) -{ - FILE *f; - yasm_preproc_gas *pp = yasm_xmalloc(sizeof(yasm_preproc_gas)); - - if (strcmp(in_filename, "-") != 0) { - f = fopen(in_filename, "r"); - if (!f) { - yasm__fatal(N_("Could not open input file")); - } - } else { - f = stdin; - } - - pp->preproc.module = &yasm_gas_LTX_preproc; - pp->in = f; - pp->in_filename = yasm__xstrdup(in_filename); - pp->defines = yasm_symtab_create(); - SLIST_INIT(&pp->deferred_defines); - yasm_symtab_set_case_sensitive(pp->defines, 1); - pp->depth = 0; - pp->skip_depth = 0; - pp->in_comment = FALSE; - SLIST_INIT(&pp->buffered_lines); - SLIST_INIT(&pp->included_files); - STAILQ_INIT(&pp->macros); - pp->in_line_number = 0; - pp->next_line_number = 0; - pp->current_line_number = 0; - pp->cur_lm = lm; - pp->errwarns = errwarns; - pp->fatal_error = 0; - pp->detect_errors_only = 0; - - return (yasm_preproc *) pp; -} - -static void -gas_preproc_destroy(yasm_preproc *preproc) -{ - yasm_preproc_gas *pp = (yasm_preproc_gas *) preproc; - yasm_xfree(pp->in_filename); - yasm_symtab_destroy(pp->defines); - while (!SLIST_EMPTY(&pp->deferred_defines)) { - deferred_define *def = SLIST_FIRST(&pp->deferred_defines); - SLIST_REMOVE_HEAD(&pp->deferred_defines, next); - yasm_xfree(def->name); - yasm_xfree(def->value); - yasm_xfree(def); - } - while (!SLIST_EMPTY(&pp->buffered_lines)) { - buffered_line *bline = SLIST_FIRST(&pp->buffered_lines); - SLIST_REMOVE_HEAD(&pp->buffered_lines, next); - yasm_xfree(bline->line); - yasm_xfree(bline); - } - while (!SLIST_EMPTY(&pp->included_files)) { - included_file *inc_file = SLIST_FIRST(&pp->included_files); - SLIST_REMOVE_HEAD(&pp->included_files, next); - yasm_xfree(inc_file->filename); - yasm_xfree(inc_file); - } - while (!STAILQ_EMPTY(&pp->macros)) { - int i; - macro_entry *macro = STAILQ_FIRST(&pp->macros); - STAILQ_REMOVE_HEAD(&pp->macros, next); - yasm_xfree(macro->name); - for (i = 0; i < macro->num_params; i++) - yasm_xfree(macro->params[i]); - yasm_xfree(macro->params); - for (i = 0; i < macro->num_lines; i++) - yasm_xfree(macro->lines[i]); - yasm_xfree(macro->lines); - yasm_xfree(macro); - } - yasm_xfree(preproc); -} - -static char * -gas_preproc_get_line(yasm_preproc *preproc) -{ - yasm_preproc_gas *pp = (yasm_preproc_gas *)preproc; - int done = FALSE; - char *line = NULL; - - pp->current_line_number++; - - do { - if (line != NULL) { - yasm_xfree(line); - } - if (pp->fatal_error) { - return NULL; - } - line = read_line(pp); - if (line == NULL) { - if (pp->in_comment) { - yasm_linemap_set(pp->cur_lm, pp->in_filename, pp->current_line_number, pp->next_line_number, 0); - yasm_warn_set(YASM_WARN_GENERAL, N_("end of file in comment")); - yasm_errwarn_propagate(pp->errwarns, pp->current_line_number); - pp->in_comment = FALSE; - } - return NULL; - } - done = process_line(pp, &line); - } while (!done); - - yasm_linemap_set(pp->cur_lm, pp->in_filename, pp->current_line_number, pp->next_line_number, 0); - - return line; -} - -static size_t -gas_preproc_get_included_file(yasm_preproc *preproc, char *buf, - size_t max_size) -{ - /* TODO */ - return 0; -} - -static void -gas_preproc_add_include_file(yasm_preproc *preproc, const char *filename) -{ - yasm_preproc_gas *pp = (yasm_preproc_gas *) preproc; - eval_include(pp, 0, filename); -} - -static void -gas_preproc_predefine_macro(yasm_preproc *preproc, const char *macronameval) -{ - yasm_preproc_gas *pp = (yasm_preproc_gas *) preproc; - const char *eq = strstr(macronameval, "="); - char *name, *value; - if (eq) { - value = yasm__xstrdup(eq + 1); - name = yasm_xmalloc(eq - macronameval + 1); - memcpy(name, macronameval, eq - macronameval); - name[eq - macronameval] = '\0'; - } else { - name = yasm__xstrdup(macronameval); - value = yasm__xstrdup(""); - } - eval_set(pp, 1, name, value); - yasm_xfree(name); - yasm_xfree(value); -} - -static void -gas_preproc_undefine_macro(yasm_preproc *preproc, const char *macroname) -{ - /* TODO */ -} - -static void -gas_preproc_define_builtin(yasm_preproc *preproc, const char *macronameval) -{ - /* TODO */ -} - -static void -gas_preproc_add_standard(yasm_preproc *preproc, const char **macros) -{ - /* TODO */ -} - - -/* Define preproc structure -- see preproc.h for details */ -yasm_preproc_module yasm_gas_LTX_preproc = { - "GNU AS (GAS)-compatible preprocessor", - "gas", - gas_preproc_create, - gas_preproc_destroy, - gas_preproc_get_line, - gas_preproc_get_included_file, - gas_preproc_add_include_file, - gas_preproc_predefine_macro, - gas_preproc_undefine_macro, - gas_preproc_define_builtin, - gas_preproc_add_standard -}; diff --git a/modules/preprocs/gas/tests/Makefile.inc b/modules/preprocs/gas/tests/Makefile.inc deleted file mode 100644 index c5e628a0..00000000 --- a/modules/preprocs/gas/tests/Makefile.inc +++ /dev/null @@ -1,5 +0,0 @@ -#TESTS += modules/preprocs/gas/tests/rawpp_test.sh - -#EXTRA_DIST += modules/preprocs/gas/tests/rawpp_test.sh -#EXTRA_DIST += modules/preprocs/gas/tests/longline.asm -#EXTRA_DIST += modules/preprocs/gas/tests/longline.hex diff --git a/modules/preprocs/nasm/CMakeLists.txt b/modules/preprocs/nasm/CMakeLists.txt deleted file mode 100644 index b5abaa74..00000000 --- a/modules/preprocs/nasm/CMakeLists.txt +++ /dev/null @@ -1,33 +0,0 @@ -add_executable(genversion preprocs/nasm/genversion.c) -if(CMAKE_CROSSCOMPILING) - find_program(GENVERSION_BIN NAMES genversion REQUIRED) - add_executable(yasm::genversion IMPORTED GLOBAL) - set_property(TARGET yasm::genversion PROPERTY IMPORTED_LOCATION "${GENVERSION_BIN}") -else() - add_executable(yasm::genversion ALIAS genversion) -endif() - -add_custom_command( - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/version.mac - COMMAND yasm::genversion ${CMAKE_CURRENT_BINARY_DIR}/version.mac - ) - -YASM_GENMACRO( - ${CMAKE_CURRENT_BINARY_DIR}/version.mac - ${CMAKE_CURRENT_BINARY_DIR}/nasm-version.c - nasm_version_mac - ) - -SET_SOURCE_FILES_PROPERTIES(preprocs/nasm/nasm-preproc.c PROPERTIES - OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/nasm-version.c - ) - -YASM_ADD_MODULE(preproc_nasm - preprocs/nasm/nasm-preproc.c - preprocs/nasm/nasm-pp.c - preprocs/nasm/nasmlib.c - preprocs/nasm/nasm-eval.c - ) - -YASM_ADD_MODULE(preproc_tasm - ) diff --git a/modules/preprocs/nasm/Makefile.inc b/modules/preprocs/nasm/Makefile.inc index ef29d479..a91eb914 100644 --- a/modules/preprocs/nasm/Makefile.inc +++ b/modules/preprocs/nasm/Makefile.inc @@ -1,3 +1,5 @@ +# $Id$ + libyasm_a_SOURCES += modules/preprocs/nasm/nasm-preproc.c libyasm_a_SOURCES += modules/preprocs/nasm/nasm-pp.h libyasm_a_SOURCES += modules/preprocs/nasm/nasm-pp.c @@ -7,15 +9,25 @@ libyasm_a_SOURCES += modules/preprocs/nasm/nasmlib.c libyasm_a_SOURCES += modules/preprocs/nasm/nasm-eval.h libyasm_a_SOURCES += modules/preprocs/nasm/nasm-eval.c -YASM_MODULES += preproc_nasm preproc_tasm +YASM_MODULES += preproc_nasm -$(top_srcdir)/modules/preprocs/nasm/nasm-preproc.c: nasm-version.c +$(top_srcdir)/src/preprocs/nasm/nasm-pp.c: nasm-macros.c -nasm-version.c: version.mac genmacro$(EXEEXT) - $(top_builddir)/genmacro$(EXEEXT) $@ nasm_version_mac version.mac +nasm-macros.c: $(top_srcdir)/modules/preprocs/nasm/standard.mac version.mac genmacro$(EXEEXT) + $(top_builddir)/genmacro$(EXEEXT) $(top_srcdir)/modules/preprocs/nasm/standard.mac version.mac -BUILT_SOURCES += nasm-version.c -CLEANFILES += nasm-version.c +BUILT_SOURCES += nasm-macros.c +CLEANFILES += nasm-macros.c + +noinst_PROGRAMS += genmacro + +genmacro_SOURCES = +EXTRA_DIST += modules/preprocs/nasm/genmacro.c +genmacro_LDADD = genmacro.$(OBJEXT) +genmacro_LINK = $(CCLD_FOR_BUILD) -o $@ + +genmacro.$(OBJEXT): modules/preprocs/nasm/genmacro.c + $(CC_FOR_BUILD) $(DEFAULT_INCLUDES) $(INCLUDES) -c -o $@ `test -f modules/preprocs/nasm/genmacro.c || echo '$(srcdir)/'`modules/preprocs/nasm/genmacro.c version.mac: genversion$(EXEEXT) $(top_builddir)/genversion$(EXEEXT) $@ @@ -33,6 +45,7 @@ genversion_LINK = $(CCLD_FOR_BUILD) -o $@ genversion.$(OBJEXT): modules/preprocs/nasm/genversion.c $(CC_FOR_BUILD) $(DEFAULT_INCLUDES) $(INCLUDES) -c -o $@ `test -f modules/preprocs/nasm/genversion.c || echo '$(srcdir)/'`modules/preprocs/nasm/genversion.c +EXTRA_DIST += modules/preprocs/nasm/standard.mac EXTRA_DIST += modules/preprocs/nasm/tests/Makefile.inc include modules/preprocs/nasm/tests/Makefile.inc diff --git a/modules/preprocs/nasm/genmacro.c b/modules/preprocs/nasm/genmacro.c new file mode 100644 index 00000000..ff56976f --- /dev/null +++ b/modules/preprocs/nasm/genmacro.c @@ -0,0 +1,145 @@ +/* $Id$ + * + * C version of NASM's macros.pl + * + * Copyright (C) 2004-2007 Peter Johnson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND OTHER CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR OTHER CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +#include +#include +#include + +#define OUTPUT "nasm-macros.c" +#define MAXLINE 1024 + +int +main(int argc, char *argv[]) +{ + FILE *in, *out; + int i; + char *str; + char *strp; + char *charp; + int fline; + int line = 0; + int lindex = 0; + int tasm_count = -1; + size_t len; + + if (argc < 2) { + fprintf(stderr, "Usage: %s [ ...]\n", argv[0]); + return EXIT_FAILURE; + } + + out = fopen(OUTPUT, "wt"); + + if (!out) { + fprintf(stderr, "Could not open `%s'.\n", OUTPUT); + return EXIT_FAILURE; + } + + str = malloc(MAXLINE); + + fprintf(out, "/* This file auto-generated from standard.mac by genmacro.c" + " - don't edit it */\n\n#include \n\n" + "static const char *stdmac[] = {\n"); + + for (i=1; i 0 && (strp[len-1] == ' ' || strp[len-1] == '\t' || + strp[len-1] == '\n')) { + strp[len-1] = '\0'; + len--; + } + + /* skip blank lines */ + if (len == 0) + continue; + + /* check for special TASM ending token */ + if (strcmp(strp, "*END*TASM*MACROS*") == 0) { + tasm_count = lindex; + continue; + } + + /* output as string to output file */ + fprintf(out, " \""); + while (*strp != '\0') { + if (*strp == '\\' || *strp == '"') + fputc('\\', out); + fputc(*strp, out); + strp++; + } + fprintf(out, "\",\n"); + lindex++; + } + + fclose(in); + } + + fprintf(out, " NULL\n};\n"); + if (tasm_count == -1) + tasm_count = lindex; + fprintf(out, "#define TASM_MACRO_COUNT %d\n", tasm_count); + fclose(out); + + free(str); + + return EXIT_SUCCESS; +} diff --git a/modules/preprocs/nasm/genversion.c b/modules/preprocs/nasm/genversion.c index 164b4d6b..d654ca19 100644 --- a/modules/preprocs/nasm/genversion.c +++ b/modules/preprocs/nasm/genversion.c @@ -1,4 +1,4 @@ -/* +/* $Id$ * * Generate version.mac * @@ -25,7 +25,7 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ -#include "config.h" /* for PACKAGE_VERSION */ +#include "config.h" /* for PACKAGE_VERSION */ #include #include @@ -36,45 +36,44 @@ int main(int argc, char *argv[]) { FILE *out; - int major, minor, subminor, patchlevel, matched; + int major, minor, subminor; if (argc != 2) { - fprintf(stderr, "Usage: %s \n", argv[0]); - return EXIT_FAILURE; - } - - matched = sscanf(PACKAGE_VERSION, "%d.%d.%d.%d", &major, &minor, &subminor, - &patchlevel); - - if (matched == 3) - patchlevel = 0; - else if (matched != 4) { - fprintf(stderr, "Version tokenizing error\n"); - return EXIT_FAILURE; + fprintf(stderr, "Usage: %s \n", argv[0]); + return EXIT_FAILURE; } out = fopen(argv[1], "wt"); if (!out) { - fprintf(stderr, "Could not open `%s'.\n", argv[1]); - return EXIT_FAILURE; + fprintf(stderr, "Could not open `%s'.\n", argv[1]); + return EXIT_FAILURE; } fprintf(out, "; This file auto-generated by genversion.c" - " - don't edit it\n"); + " - don't edit it\n"); + + if (sscanf(PACKAGE_INTVER, "%d.%d.%d", &major, &minor, &subminor) != 3) { + fprintf(stderr, "Version tokenizing error\n"); + fclose(out); + remove(argv[1]); + return EXIT_FAILURE; + } fprintf(out, "%%define __YASM_MAJOR__ %d\n", major); fprintf(out, "%%define __YASM_MINOR__ %d\n", minor); fprintf(out, "%%define __YASM_SUBMINOR__ %d\n", subminor); - fprintf(out, "%%define __YASM_BUILD__ %d\n", patchlevel); - fprintf(out, "%%define __YASM_PATCHLEVEL__ %d\n", patchlevel); + if (!isdigit(PACKAGE_BUILD[0])) + fprintf(out, "%%define __YASM_BUILD__ 0\n"); + else + fprintf(out, "%%define __YASM_BUILD__ %d\n", atoi(PACKAGE_BUILD)); /* Version id (hex number) */ - fprintf(out, "%%define __YASM_VERSION_ID__ 0%02x%02x%02x%02xh\n", major, - minor, subminor, patchlevel); + fprintf(out, "%%define __YASM_VERSION_ID__ 0%02x%02x%02x00h\n", major, + minor, subminor); - /* Version string */ - fprintf(out, "%%define __YASM_VER__ \"%s\"\n", PACKAGE_VERSION); + /* Version string - version sans build */ + fprintf(out, "%%define __YASM_VER__ \"%s\"\n", PACKAGE_INTVER); fclose(out); return EXIT_SUCCESS; diff --git a/modules/preprocs/nasm/nasm-eval.c b/modules/preprocs/nasm/nasm-eval.c index e249484c..2b10d7e7 100644 --- a/modules/preprocs/nasm/nasm-eval.c +++ b/modules/preprocs/nasm/nasm-eval.c @@ -12,21 +12,17 @@ #include #include #include -#include #include #include "nasm.h" #include "nasmlib.h" #include "nasm-eval.h" -/* The assembler symbol table. */ -extern yasm_symtab *nasm_symtab; +static scanner scan; /* Address of scanner routine */ +static efunc error; /* Address of error reporting routine */ -static scanner scan; /* Address of scanner routine */ -static efunc error; /* Address of error reporting routine */ - -static struct tokenval *tokval; /* The current token */ -static int i; /* The t_type of tokval */ +static struct tokenval *tokval; /* The current token */ +static int i; /* The t_type of tokval */ static void *scpriv; @@ -76,18 +72,18 @@ static yasm_expr *rexp0(void) e = rexp1(); if (!e) - return NULL; + return NULL; while (i == TOKEN_DBL_OR) - { - i = scan(scpriv, tokval); - f = rexp1(); - if (!f) { - yasm_expr_destroy(e); - return NULL; - } + { + i = scan(scpriv, tokval); + f = rexp1(); + if (!f) { + yasm_expr_destroy(e); + return NULL; + } - e = yasm_expr_create_tree(e, YASM_EXPR_LOR, f, 0); + e = yasm_expr_create_tree(e, YASM_EXPR_LOR, f, 0); } return e; } @@ -98,18 +94,18 @@ static yasm_expr *rexp1(void) e = rexp2(); if (!e) - return NULL; + return NULL; while (i == TOKEN_DBL_XOR) { - i = scan(scpriv, tokval); - f = rexp2(); - if (!f) { - yasm_expr_destroy(e); - return NULL; - } + i = scan(scpriv, tokval); + f = rexp2(); + if (!f) { + yasm_expr_destroy(e); + return NULL; + } - e = yasm_expr_create_tree(e, YASM_EXPR_LXOR, f, 0); + e = yasm_expr_create_tree(e, YASM_EXPR_LXOR, f, 0); } return e; } @@ -120,17 +116,17 @@ static yasm_expr *rexp2(void) e = rexp3(); if (!e) - return NULL; + return NULL; while (i == TOKEN_DBL_AND) { - i = scan(scpriv, tokval); - f = rexp3(); - if (!f) { - yasm_expr_destroy(e); - return NULL; - } + i = scan(scpriv, tokval); + f = rexp3(); + if (!f) { + yasm_expr_destroy(e); + return NULL; + } - e = yasm_expr_create_tree(e, YASM_EXPR_LAND, f, 0); + e = yasm_expr_create_tree(e, YASM_EXPR_LAND, f, 0); } return e; } @@ -141,40 +137,40 @@ static yasm_expr *rexp3(void) e = expr0(); if (!e) - return NULL; + return NULL; while (i == TOKEN_EQ || i == TOKEN_LT || i == TOKEN_GT || - i == TOKEN_NE || i == TOKEN_LE || i == TOKEN_GE) + i == TOKEN_NE || i == TOKEN_LE || i == TOKEN_GE) { - int j = i; - i = scan(scpriv, tokval); - f = expr0(); - if (!f) { - yasm_expr_destroy(e); - return NULL; - } + int j = i; + i = scan(scpriv, tokval); + f = expr0(); + if (!f) { + yasm_expr_destroy(e); + return NULL; + } - switch (j) - { - case TOKEN_EQ: - e = yasm_expr_create_tree(e, YASM_EXPR_EQ, f, 0); - break; - case TOKEN_LT: - e = yasm_expr_create_tree(e, YASM_EXPR_LT, f, 0); - break; - case TOKEN_GT: - e = yasm_expr_create_tree(e, YASM_EXPR_GT, f, 0); - break; - case TOKEN_NE: - e = yasm_expr_create_tree(e, YASM_EXPR_NE, f, 0); - break; - case TOKEN_LE: - e = yasm_expr_create_tree(e, YASM_EXPR_LE, f, 0); - break; - case TOKEN_GE: - e = yasm_expr_create_tree(e, YASM_EXPR_GE, f, 0); - break; - } + switch (j) + { + case TOKEN_EQ: + e = yasm_expr_create_tree(e, YASM_EXPR_EQ, f, 0); + break; + case TOKEN_LT: + e = yasm_expr_create_tree(e, YASM_EXPR_LT, f, 0); + break; + case TOKEN_GT: + e = yasm_expr_create_tree(e, YASM_EXPR_GT, f, 0); + break; + case TOKEN_NE: + e = yasm_expr_create_tree(e, YASM_EXPR_NE, f, 0); + break; + case TOKEN_LE: + e = yasm_expr_create_tree(e, YASM_EXPR_LE, f, 0); + break; + case TOKEN_GE: + e = yasm_expr_create_tree(e, YASM_EXPR_GE, f, 0); + break; + } } return e; } @@ -185,18 +181,18 @@ static yasm_expr *expr0(void) e = expr1(); if (!e) - return NULL; + return NULL; while (i == '|') { - i = scan(scpriv, tokval); - f = expr1(); - if (!f) { - yasm_expr_destroy(e); - return NULL; - } + i = scan(scpriv, tokval); + f = expr1(); + if (!f) { + yasm_expr_destroy(e); + return NULL; + } - e = yasm_expr_create_tree(e, YASM_EXPR_OR, f, 0); + e = yasm_expr_create_tree(e, YASM_EXPR_OR, f, 0); } return e; } @@ -207,17 +203,17 @@ static yasm_expr *expr1(void) e = expr2(); if (!e) - return NULL; + return NULL; while (i == '^') { - i = scan(scpriv, tokval); - f = expr2(); - if (!f) { - yasm_expr_destroy(e); - return NULL; - } + i = scan(scpriv, tokval); + f = expr2(); + if (!f) { + yasm_expr_destroy(e); + return NULL; + } - e = yasm_expr_create_tree(e, YASM_EXPR_XOR, f, 0); + e = yasm_expr_create_tree(e, YASM_EXPR_XOR, f, 0); } return e; } @@ -228,17 +224,17 @@ static yasm_expr *expr2(void) e = expr3(); if (!e) - return NULL; + return NULL; while (i == '&') { - i = scan(scpriv, tokval); - f = expr3(); - if (!f) { - yasm_expr_destroy(e); - return NULL; - } + i = scan(scpriv, tokval); + f = expr3(); + if (!f) { + yasm_expr_destroy(e); + return NULL; + } - e = yasm_expr_create_tree(e, YASM_EXPR_AND, f, 0); + e = yasm_expr_create_tree(e, YASM_EXPR_AND, f, 0); } return e; } @@ -249,26 +245,26 @@ static yasm_expr *expr3(void) e = expr4(); if (!e) - return NULL; + return NULL; while (i == TOKEN_SHL || i == TOKEN_SHR) { - int j = i; - i = scan(scpriv, tokval); - f = expr4(); - if (!f) { - yasm_expr_destroy(e); - return NULL; - } + int j = i; + i = scan(scpriv, tokval); + f = expr4(); + if (!f) { + yasm_expr_destroy(e); + return NULL; + } - switch (j) { - case TOKEN_SHL: - e = yasm_expr_create_tree(e, YASM_EXPR_SHL, f, 0); - break; - case TOKEN_SHR: - e = yasm_expr_create_tree(e, YASM_EXPR_SHR, f, 0); - break; - } + switch (j) { + case TOKEN_SHL: + e = yasm_expr_create_tree(e, YASM_EXPR_SHL, f, 0); + break; + case TOKEN_SHR: + e = yasm_expr_create_tree(e, YASM_EXPR_SHR, f, 0); + break; + } } return e; } @@ -279,24 +275,24 @@ static yasm_expr *expr4(void) e = expr5(); if (!e) - return NULL; + return NULL; while (i == '+' || i == '-') { - int j = i; - i = scan(scpriv, tokval); - f = expr5(); - if (!f) { - yasm_expr_destroy(e); - return NULL; - } - switch (j) { - case '+': - e = yasm_expr_create_tree(e, YASM_EXPR_ADD, f, 0); - break; - case '-': - e = yasm_expr_create_tree(e, YASM_EXPR_SUB, f, 0); - break; - } + int j = i; + i = scan(scpriv, tokval); + f = expr5(); + if (!f) { + yasm_expr_destroy(e); + return NULL; + } + switch (j) { + case '+': + e = yasm_expr_create_tree(e, YASM_EXPR_ADD, f, 0); + break; + case '-': + e = yasm_expr_create_tree(e, YASM_EXPR_SUB, f, 0); + break; + } } return e; } @@ -307,34 +303,34 @@ static yasm_expr *expr5(void) e = expr6(); if (!e) - return NULL; + return NULL; while (i == '*' || i == '/' || i == '%' || - i == TOKEN_SDIV || i == TOKEN_SMOD) + i == TOKEN_SDIV || i == TOKEN_SMOD) { - int j = i; - i = scan(scpriv, tokval); - f = expr6(); - if (!f) { - yasm_expr_destroy(e); - return NULL; - } - switch (j) { - case '*': - e = yasm_expr_create_tree(e, YASM_EXPR_MUL, f, 0); - break; - case '/': - e = yasm_expr_create_tree(e, YASM_EXPR_DIV, f, 0); - break; - case '%': - e = yasm_expr_create_tree(e, YASM_EXPR_MOD, f, 0); - break; - case TOKEN_SDIV: - e = yasm_expr_create_tree(e, YASM_EXPR_SIGNDIV, f, 0); - break; - case TOKEN_SMOD: - e = yasm_expr_create_tree(e, YASM_EXPR_SIGNMOD, f, 0); - break; - } + int j = i; + i = scan(scpriv, tokval); + f = expr6(); + if (!f) { + yasm_expr_destroy(e); + return NULL; + } + switch (j) { + case '*': + e = yasm_expr_create_tree(e, YASM_EXPR_MUL, f, 0); + break; + case '/': + e = yasm_expr_create_tree(e, YASM_EXPR_DIV, f, 0); + break; + case '%': + e = yasm_expr_create_tree(e, YASM_EXPR_MOD, f, 0); + break; + case TOKEN_SDIV: + e = yasm_expr_create_tree(e, YASM_EXPR_SIGNDIV, f, 0); + break; + case TOKEN_SMOD: + e = yasm_expr_create_tree(e, YASM_EXPR_SIGNMOD, f, 0); + break; + } } return e; } @@ -344,88 +340,73 @@ static yasm_expr *expr6(void) yasm_expr *e = NULL; if (i == '-') { - i = scan(scpriv, tokval); - e = expr6(); - if (!e) - return NULL; - return yasm_expr_create_branch(YASM_EXPR_NEG, e, 0); + i = scan(scpriv, tokval); + e = expr6(); + if (!e) + return NULL; + return yasm_expr_create_branch(YASM_EXPR_NEG, e, 0); } else if (i == '+') { - i = scan(scpriv, tokval); - return expr6(); + i = scan(scpriv, tokval); + return expr6(); } else if (i == '~') { - i = scan(scpriv, tokval); - e = expr6(); - if (!e) - return NULL; - return yasm_expr_create_branch(YASM_EXPR_NOT, e, 0); + i = scan(scpriv, tokval); + e = expr6(); + if (!e) + return NULL; + return yasm_expr_create_branch(YASM_EXPR_NOT, e, 0); } else if (i == TOKEN_SEG) { - i = scan(scpriv, tokval); - e = expr6(); - if (!e) - return NULL; - error(ERR_NONFATAL, "%s not supported", "SEG"); - return e; + i = scan(scpriv, tokval); + e = expr6(); + if (!e) + return NULL; + error(ERR_NONFATAL, "%s not supported", "SEG"); + return e; } else if (i == '(') { - i = scan(scpriv, tokval); - e = bexpr(); - if (!e) - return NULL; - if (i != ')') { - error(ERR_NONFATAL, "expecting `)'"); - return NULL; - } - i = scan(scpriv, tokval); - return e; + i = scan(scpriv, tokval); + e = bexpr(); + if (!e) + return NULL; + if (i != ')') { + error(ERR_NONFATAL, "expecting `)'"); + return NULL; + } + i = scan(scpriv, tokval); + return e; } else if (i == TOKEN_NUM || i == TOKEN_ID || - i == TOKEN_HERE || i == TOKEN_BASE) + i == TOKEN_HERE || i == TOKEN_BASE) { - switch (i) { - case TOKEN_NUM: - e = yasm_expr_create_ident(yasm_expr_int(tokval->t_integer), 0); - break; - case TOKEN_ID: - if (nasm_symtab) { - yasm_symrec *sym = - yasm_symtab_get(nasm_symtab, tokval->t_charptr); - if (sym) { - e = yasm_expr_create_ident(yasm_expr_sym(sym), 0); - } else { - error(ERR_NONFATAL, - "undefined symbol `%s' in preprocessor", - tokval->t_charptr); - e = yasm_expr_create_ident(yasm_expr_int( - yasm_intnum_create_int(1)), 0); - } - break; - } - /*fallthrough*/ - case TOKEN_HERE: - case TOKEN_BASE: - error(ERR_NONFATAL, - "cannot reference symbol `%s' in preprocessor", - (i == TOKEN_ID ? tokval->t_charptr : - i == TOKEN_HERE ? "$" : "$$")); - e = yasm_expr_create_ident(yasm_expr_int(yasm_intnum_create_int(1)), - 0); - break; - } - i = scan(scpriv, tokval); - return e; + switch (i) { + case TOKEN_NUM: + e = yasm_expr_create_ident(yasm_expr_int(tokval->t_integer), 0); + break; + case TOKEN_ID: + case TOKEN_HERE: + case TOKEN_BASE: + error(ERR_NONFATAL, + "cannot reference symbol `%s' in preprocessor", + (i == TOKEN_ID ? tokval->t_charptr : + i == TOKEN_HERE ? "$" : "$$")); + e = yasm_expr_create_ident(yasm_expr_int(yasm_intnum_create_int(1)), + 0); + break; + } + i = scan(scpriv, tokval); + return e; } else { - error(ERR_NONFATAL, "expression syntax error"); - return NULL; + error(ERR_NONFATAL, "expression syntax error"); + return NULL; } } yasm_expr *nasm_evaluate (scanner sc, void *scprivate, struct tokenval *tv, - int critical, efunc report_error) + int critical, efunc report_error) { if (critical & CRITICAL) { - critical &= ~CRITICAL; - bexpr = rexp0; + critical &= ~CRITICAL; + bexpr = rexp0; } else - bexpr = expr0; + bexpr = expr0; scan = sc; scpriv = scprivate; @@ -433,9 +414,9 @@ yasm_expr *nasm_evaluate (scanner sc, void *scprivate, struct tokenval *tv, error = report_error; if (tokval->t_type == TOKEN_INVALID) - i = scan(scpriv, tokval); + i = scan(scpriv, tokval); else - i = tokval->t_type; + i = tokval->t_type; return bexpr (); } diff --git a/modules/preprocs/nasm/nasm-eval.h b/modules/preprocs/nasm/nasm-eval.h index f06937c5..32e3da8b 100644 --- a/modules/preprocs/nasm/nasm-eval.h +++ b/modules/preprocs/nasm/nasm-eval.h @@ -13,6 +13,6 @@ * The evaluator itself. */ yasm_expr *nasm_evaluate (scanner sc, void *scprivate, struct tokenval *tv, - int critical, efunc report_error); + int critical, efunc report_error); #endif diff --git a/modules/preprocs/nasm/nasm-pp.c b/modules/preprocs/nasm/nasm-pp.c index 8b7ab572..2b65330b 100644 --- a/modules/preprocs/nasm/nasm-pp.c +++ b/modules/preprocs/nasm/nasm-pp.c @@ -63,7 +63,6 @@ struct SMacro { SMacro *next; char *name; - int level; int casesense; int nparam; int in_progress; @@ -93,21 +92,21 @@ struct MMacro char *name; int casesense; long nparam_min, nparam_max; - int plus; /* is the last parameter greedy? */ - int nolist; /* is this macro listing-inhibited? */ + int plus; /* is the last parameter greedy? */ + int nolist; /* is this macro listing-inhibited? */ int in_progress; - Token *dlist; /* All defaults as one list */ - Token **defaults; /* Parameter default pointers */ - int ndefs; /* number of default parameters */ + Token *dlist; /* All defaults as one list */ + Token **defaults; /* Parameter default pointers */ + int ndefs; /* number of default parameters */ Line *expansion; MMacro *next_active; - MMacro *rep_nest; /* used for nesting %rep */ - Token **params; /* actual parameters */ - Token *iline; /* invocation line */ + MMacro *rep_nest; /* used for nesting %rep */ + Token **params; /* actual parameters */ + Token *iline; /* invocation line */ long nparam, rotate, *paramlen; unsigned long unique; - int lineno; /* Current line number on expansion */ + int lineno; /* Current line number on expansion */ }; /* @@ -144,7 +143,7 @@ struct Token { Token *next; char *text; - SMacro *mac; /* associated macro for TOK_SMAC_END */ + SMacro *mac; /* associated macro for TOK_SMAC_END */ int type; }; enum @@ -195,7 +194,7 @@ struct Include Line *expansion; char *fname; int lineno, lineinc; - MMacro *mstk; /* stack of active macros/reps */ + MMacro *mstk; /* stack of active macros/reps */ }; /* @@ -243,7 +242,7 @@ enum * These defines are used as the possible return values for do_directive */ #define NO_DIRECTIVE_FOUND 0 -#define DIRECTIVE_FOUND 1 +#define DIRECTIVE_FOUND 1 /* * Condition codes. Note that we use c_ prefix not C_ because C_ is @@ -277,15 +276,15 @@ static const char *directives[] = { "%elifid", "%elifidn", "%elifidni", "%elifmacro", "%elifnctx", "%elifndef", "%elifnid", "%elifnidn", "%elifnidni", "%elifnmacro", "%elifnnum", "%elifnstr", "%elifnum", "%elifstr", "%else", "%endif", "%endm", "%endmacro", - "%endrep", "%endscope", "%error", "%exitrep", "%iassign", "%idefine", "%if", + "%endrep", "%error", "%exitrep", "%iassign", "%idefine", "%if", "%ifctx", "%ifdef", "%ifid", "%ifidn", "%ifidni", "%ifmacro", "%ifnctx", "%ifndef", "%ifnid", "%ifnidn", "%ifnidni", "%ifnmacro", "%ifnnum", "%ifnstr", "%ifnum", "%ifstr", "%imacro", "%include", "%ixdefine", "%line", "%local", "%macro", "%pop", "%push", "%rep", "%repl", "%rotate", - "%scope", "%stacksize", - "%strlen", "%substr", "%undef", "%warning", "%xdefine" + "%stacksize", + "%strlen", "%substr", "%undef", "%xdefine" }; enum { @@ -294,22 +293,22 @@ enum PP_ELIFID, PP_ELIFIDN, PP_ELIFIDNI, PP_ELIFMACRO, PP_ELIFNCTX, PP_ELIFNDEF, PP_ELIFNID, PP_ELIFNIDN, PP_ELIFNIDNI, PP_ELIFNMACRO, PP_ELIFNNUM, PP_ELIFNSTR, PP_ELIFNUM, PP_ELIFSTR, PP_ELSE, PP_ENDIF, PP_ENDM, PP_ENDMACRO, - PP_ENDREP, PP_ENDSCOPE, PP_ERROR, PP_EXITREP, PP_IASSIGN, PP_IDEFINE, PP_IF, + PP_ENDREP, PP_ERROR, PP_EXITREP, PP_IASSIGN, PP_IDEFINE, PP_IF, PP_IFCTX, PP_IFDEF, PP_IFID, PP_IFIDN, PP_IFIDNI, PP_IFMACRO, PP_IFNCTX, PP_IFNDEF, PP_IFNID, PP_IFNIDN, PP_IFNIDNI, PP_IFNMACRO, PP_IFNNUM, PP_IFNSTR, PP_IFNUM, PP_IFSTR, PP_IMACRO, PP_INCLUDE, PP_IXDEFINE, PP_LINE, PP_LOCAL, PP_MACRO, PP_POP, PP_PUSH, PP_REP, PP_REPL, PP_ROTATE, - PP_SCOPE, PP_STACKSIZE, - PP_STRLEN, PP_SUBSTR, PP_UNDEF, PP_WARNING, PP_XDEFINE + PP_STACKSIZE, + PP_STRLEN, PP_SUBSTR, PP_UNDEF, PP_XDEFINE }; /* If this is a an IF, ELIF, ELSE or ENDIF keyword */ static int is_condition(int arg) { return ((arg >= PP_ELIF) && (arg <= PP_ENDIF)) || - ((arg >= PP_IF) && (arg <= PP_IFSTR)); + ((arg >= PP_IF) && (arg <= PP_IFSTR)); } /* For TASM compatibility we need to be able to recognise TASM compatible @@ -325,9 +324,7 @@ static int is_condition(int arg) enum { TM_ARG, TM_ELIF, TM_ELSE, TM_ENDIF, TM_IF, TM_IFDEF, TM_IFDIFI, - TM_IFNDEF, TM_INCLUDE, TM_LOCAL, - TM_REPT, TM_IRP, TM_MACRO, - TM_STRUC, TM_SEGMENT + TM_IFNDEF, TM_INCLUDE, TM_LOCAL }; static const char *tasm_directives[] = { @@ -339,7 +336,6 @@ static int StackSize = 4; static const char *StackPointer = "ebp"; static int ArgOffset = 8; static int LocalOffset = 4; -static int Level = 0; static Context *cstk; @@ -347,17 +343,15 @@ static Include *istk; static FILE *first_fp = NULL; -static efunc _error; /* Pointer to client-provided error reporting function */ +static efunc _error; /* Pointer to client-provided error reporting function */ static evalfunc evaluate; -static int pass; /* HACK: pass 0 = generate dependencies only */ +static int pass; /* HACK: pass 0 = generate dependencies only */ -static unsigned long unique; /* unique identifier numbers */ +static unsigned long unique; /* unique identifier numbers */ static Line *builtindef = NULL; -static Line *stddef = NULL; static Line *predef = NULL; -static int first_line = 1; static ListGen *list; @@ -366,7 +360,7 @@ static ListGen *list; * FIXME: We should *really* be able to configure this at run time, * or even have the hash table automatically expanding when necessary. */ -#define NHASH 4096 +#define NHASH 31 /* * The current set of multi-line macros we have defined. @@ -390,62 +384,18 @@ static MMacro *defining; #define PARAM_DELTA 16 /* - * Macros to make NASM ignore some TASM directives before the first include - * directive. + * The standard macro set: defined as `static char *stdmac[]'. Also + * gives our position in the macro set, when we're processing it. */ -static const char *tasm_compat_macros[] = -{ - "%idefine IDEAL", - "%idefine JUMPS", - "%idefine END", - "%idefine P8086 CPU 8086", - "%idefine P186 CPU 186", - "%idefine P286 CPU 286", - "%idefine P286N CPU 286", - "%idefine P286P CPU 286 Priv", - "%idefine P386 CPU 386", - "%idefine P386N CPU 386", - "%idefine P386P CPU 386 Priv", - "%idefine P486 CPU 486", - "%idefine P586 CPU 586", - "%idefine .8086 CPU 8086", - "%idefine .186 CPU 186", - "%idefine .286 CPU 286", - "%idefine .286C CPU 286", - "%idefine .286P CPU 286", - "%idefine .386 CPU 386", - "%idefine .386C CPU 386", - "%idefine .386P CPU 386", - "%idefine .486 CPU 486", - "%idefine .486C CPU 486", - "%idefine .486P CPU 486", - "%idefine .586 CPU 586", - "%idefine .586C CPU 586", - "%idefine .586P CPU 586", - "", - "%imacro TITLE 1", - "%endm", - "%imacro NAME 1", - "%endm", - "", - "%imacro EXTRN 1-*.nolist", - "%rep %0", - "[extern %1]", - "%rotate 1", - "%endrep", - "%endmacro", - "", - "%imacro PUBLIC 1-*.nolist", - "%rep %0", - "[global %1]", - "%rotate 1", - "%endrep", - "%endmacro", - "", - "; this is not needed", - "%idefine PTR", - NULL -}; +#include "nasm-macros.c" +static const char **stdmacpos; + +/* + * The extra standard macros that come from the object format, if + * any. + */ +static const char **extrastdmac = NULL; +int any_extrastdmac; static int nested_mac_count, nested_rep_count; @@ -455,8 +405,8 @@ static int nested_mac_count, nested_rep_count; #define TOKEN_BLOCKSIZE 4096 static Token *freeTokens = NULL; struct Blocks { - Blocks *next; - void *chunk; + Blocks *next; + void *chunk; }; static Blocks blocks = { NULL, NULL }; @@ -473,9 +423,8 @@ static void error(int severity, const char *fmt, ...); static void *new_Block(size_t size); static void delete_Blocks(void); static Token *new_Token(Token * next, int type, const char *text, - size_t txtlen); + size_t txtlen); static Token *delete_Token(Token * t); -static Token *tokenise(char *line); /* * Macros for safe checking of token pointers, avoid *(NULL) @@ -490,552 +439,69 @@ static Token *tokenise(char *line); * place to do it for the moment, and it is a hack (ideally it would * be nice to be able to use the NASM pre-processor to do it). */ - -typedef struct TMEndItem { - int type; - void *data; - struct TMEndItem *next; -} TMEndItem; - -static TMEndItem *EndmStack = NULL, *EndsStack = NULL; - -char **TMParameters; - -struct TStrucField { - char *name; - char *type; - struct TStrucField *next; -}; -struct TStruc { - char *name; - struct TStrucField *fields, *lastField; - struct TStruc *next; -}; -static struct TStruc *TStrucs = NULL; -static int inTstruc = 0; - -struct TSegmentAssume { - char *segreg; - char *segment; -}; -struct TSegmentAssume *TAssumes; - -const char *tasm_get_segment_register(const char *segment) -{ - struct TSegmentAssume *assume; - if (!TAssumes) - return NULL; - for (assume = TAssumes; assume->segreg; assume++) { - if (!strcmp(assume->segment, segment)) - break; - } - return assume->segreg; -} - static char * check_tasm_directive(char *line) { int i, j, k, m; - size_t len, len2; - char *p, *oldline, oldchar, *q, oldchar2; - TMEndItem *end; - - p = line; + size_t len; + char *p = line, *oldline, oldchar; /* Skip whitespace */ - while (isspace(*p) && *p != 0 && *p != ';') - p++; - - /* Ignore nasm directives */ - if (*p == '%') - return line; + while (isspace(*p) && *p != 0) + p++; /* Binary search for the directive name */ - len = 0; - while (!isspace(p[len]) && p[len] != 0 && p[len] != ';') - len++; - if (!len) - return line; - - oldchar = p[len]; - p[len] = 0; i = -1; j = elements(tasm_directives); - while (j - i > 1) + len = 0; + while (!isspace(p[len]) && p[len] != 0) + len++; + if (len) { - k = (j + i) / 2; - m = nasm_stricmp(p, tasm_directives[k]); - if (m == 0) - { - /* We have found a directive, so jam a % in front of it - * so that NASM will then recognise it as one if it's own. - */ - p[len] = oldchar; - len = strlen(p); - oldline = line; - if (k == TM_IFDIFI) - { - /* NASM does not recognise IFDIFI, so we convert it to - * %ifdef BOGUS. This is not used in NASM comaptible - * code, but does need to parse for the TASM macro - * package. - */ - line = nasm_malloc(13); - strcpy(line, "%ifdef BOGUS"); - } - else if (k == TM_INCLUDE) - { - /* add double quotes around file name */ - p += 7 + 1; - while (isspace(*p) && *p) - p++; - len = strlen(p); - line = nasm_malloc(1 + 7 + 1 + 1 + len + 1 + 1); - sprintf(line, "%%include \"%s\"", p); - } - else - { - line = nasm_malloc(len + 2); - line[0] = '%'; - memcpy(line + 1, p, len + 1); - } - nasm_free(oldline); - return line; - } - else if (m < 0) - { - j = k; - } - else - i = k; + oldchar = p[len]; + p[len] = 0; + while (j - i > 1) + { + k = (j + i) / 2; + m = nasm_stricmp(p, tasm_directives[k]); + if (m == 0) + { + /* We have found a directive, so jam a % in front of it + * so that NASM will then recognise it as one if it's own. + */ + p[len] = oldchar; + len = strlen(p); + oldline = line; + line = nasm_malloc(len + 2); + line[0] = '%'; + if (k == TM_IFDIFI) + { + /* NASM does not recognise IFDIFI, so we convert it to + * %ifdef BOGUS. This is not used in NASM comaptible + * code, but does need to parse for the TASM macro + * package. + */ + strcpy(line + 1, "ifdef BOGUS"); + } + else + { + memcpy(line + 1, p, len + 1); + } + nasm_free(oldline); + return line; + } + else if (m < 0) + { + j = k; + } + else + i = k; + } + p[len] = oldchar; } - - /* Not a simple directive */ - - if (!nasm_stricmp(p, "endm")) { - /* handle end of endm directive */ - char **parameter; - end = EndmStack; - /* undef parameters */ - if (!end) { - error(ERR_FATAL, "ENDM: not in an endm context"); - return line; - } - EndmStack = EndmStack->next; - nasm_free(line); - switch (end->type) { - case TM_MACRO: - len = 0; - for (parameter = end->data; *parameter; parameter++) - len += 6 + 1 + strlen(*parameter) + 1; - len += 5 + 1; - line = nasm_malloc(len); - p = line; - for (parameter = end->data; *parameter; parameter++) { - p += sprintf(p, "%%undef %s\n", *parameter); - nasm_free(*parameter); - } - nasm_free(end->data); - nasm_free(end); - sprintf(p, "%%endm"); - return line; - case TM_REPT: - nasm_free(end); - return nasm_strdup("%endrep"); - case TM_IRP: { - char **data; - const char *irp_format = - "%%undef %s\n" - "%%rotate 1\n" - "%%endrep\n" - "%%endm\n" - "irp %s\n" - "%%undef irp"; - data = end->data; - line = nasm_malloc(strlen(irp_format) - 4 + strlen(data[0]) - + strlen(data[1])); - sprintf(line, irp_format, data[0], data[1]); - nasm_free(data[0]); - nasm_free(data[1]); - nasm_free(data); - return line; - } - default: - error(ERR_FATAL, "ENDM: bogus endm context type %d\n",end->type); - return NULL; - } - } else if (!nasm_stricmp(p, "end")) { - nasm_free(line); - return nasm_strdup(""); - } else if (!nasm_stricmp(p, "rept")) { - /* handle repeat directive */ - end = nasm_malloc(sizeof(*end)); - end->type = TM_REPT; - end->next = EndmStack; - EndmStack = end; - memcpy(p, "%rep", 4); - p[len] = oldchar; - return line; - } else if (!nasm_stricmp(p, "locals")) { - tasm_locals = 1; - nasm_free(line); - return nasm_strdup(""); - } - - if (!oldchar) - return line; - - /* handle two-words directives */ - q = p + len + 1; - /* Skip whitespaces */ - while (isspace(*q) && *q) - q++; - - len2 = 0; - while (!isspace(q[len2]) && q[len2]!=',' && q[len2] != 0) - len2++; - oldchar2 = q[len2]; - q[len2] = '\0'; - - if (!nasm_stricmp(p, "irp")) { - /* handle indefinite repeat directive */ - const char *irp_format = - "%%imacro irp 0-*\n" - "%%rep %%0\n" - "%%define %s %%1\n"; - char **data; - - data = nasm_malloc(2*sizeof(char*)); - oldline = line; - line = nasm_malloc(strlen(irp_format) - 2 + len2 + 1); - sprintf(line,irp_format,q); - data[0] = nasm_strdup(q); - - if (!oldchar2) - error(ERR_FATAL, "%s: expected ", q + len2); - p = strchr(q + len2 + 1, '<'); - if (!p) - error(ERR_FATAL, "%s: expected ", q + len2); - p++; - q = strchr(p, '>'); - data[1] = nasm_strndup(p, q - p); - - end = nasm_malloc(sizeof(*end)); - end->type = TM_IRP; - end->next = EndmStack; - end->data = data; - EndmStack = end; - - nasm_free(oldline); - return line; - } else if (!nasm_stricmp(q, "macro")) { - char *name = p; - /* handle MACRO */ - /* count parameters */ - j = 1; - i = 0; - TMParameters = nasm_malloc(j*sizeof(*TMParameters)); - len = 0; - p = q + len2 + 1; - /* Skip whitespaces */ - while (isspace(*p) && *p) - p++; - while (*p) { - /* Get parameter name */ - for (q = p; !isspace(*q) && *q != ',' && *q; q++); - len2 = q-p; - if (len2 == 0) - error(ERR_FATAL, "'%s': expected parameter name", p); - TMParameters[i] = nasm_malloc(len2 + 1); - memcpy(TMParameters[i], p, len2); - TMParameters[i][len2] = '\0'; - len += len2; - i++; - if (i + 1 > j) { - j *= 2; - TMParameters = nasm_realloc(TMParameters, - j*sizeof(*TMParameters)); - } - if (i == 1000) - error(ERR_FATAL, "too many parameters for macro %s", name); - p = q; - while (isspace(*p) && *p) - p++; - if (!*p) - break; - if (*p != ',') - error(ERR_FATAL, "expected comma"); - p++; - while (isspace(*p) && *p) - p++; - } - TMParameters[i] = NULL; - TMParameters = nasm_realloc(TMParameters, - (i+1)*sizeof(*TMParameters)); - len += 1 + 6 + 1 + strlen(name) + 1 + 3; /* macro definition */ - len += i * (1 + 9 + 1 + 1 + 1 + 3 + 2); /* macro parameter definition */ - oldline = line; - p = line = nasm_malloc(len + 1); - p += sprintf(p, "%%imacro %s 0-*", name); - nasm_free(oldline); - for (j = 0; TMParameters[j]; j++) { - p += sprintf(p, "\n%%idefine %s %%{%-u}", TMParameters[j], j + 1); - } - end = nasm_malloc(sizeof(*end)); - end->type = TM_MACRO; - end->next = EndmStack; - end->data = TMParameters; - EndmStack = end; - return line; - } else if (!nasm_stricmp(q, "proc")) { - /* handle PROC */ - oldline = line; - line = nasm_malloc(2 + len + 1); - sprintf(line, "..%s",p); - nasm_free(oldline); - return line; - } else if (!nasm_stricmp(q, "struc")) { - /* handle struc */ - struct TStruc *struc; - if (inTstruc) { - error(ERR_FATAL, "STRUC: already in a struc context"); - return line; - } - oldline = line; - line = nasm_malloc(5 + 1 + len + 1); - sprintf(line, "struc %s", p); - struc = nasm_malloc(sizeof(*struc)); - struc->name = nasm_strdup(p); - struc->fields = NULL; - struc->lastField = NULL; - struc->next = TStrucs; - TStrucs = struc; - inTstruc = 1; - nasm_free(oldline); - end = nasm_malloc(sizeof(*end)); - end->type = TM_STRUC; - end->next = EndsStack; - EndsStack = end; - return line; - } else if (!nasm_stricmp(q, "segment")) { - /* handle SEGMENT */ - oldline = line; - line = nasm_strdup(oldchar2?q+len2+1:""); - if (tasm_segment) { - error(ERR_FATAL, "SEGMENT: already in a segment context"); - return line; - } - tasm_segment = nasm_strdup(p); - nasm_free(oldline); - end = nasm_malloc(sizeof(*end)); - end->type = TM_SEGMENT; - end->next = EndsStack; - EndsStack = end; - return line; - } else if (!nasm_stricmp(p, "ends") || !nasm_stricmp(q, "ends")) { - /* handle end of ends directive */ - end = EndsStack; - /* undef parameters */ - if (!end) { - error(ERR_FATAL, "ENDS: not in an ends context"); - return line; - } - EndsStack = EndsStack->next; - nasm_free(line); - switch (end->type) { - case TM_STRUC: - inTstruc = 0; - return nasm_strdup("endstruc"); - case TM_SEGMENT: - /* XXX: yes, we leak memory here, but that permits labels - * to avoid strduping... */ - tasm_segment = NULL; - return nasm_strdup(""); - default: - error(ERR_FATAL, "ENDS: bogus ends context type %d",end->type); - return NULL; - } - } else if (!nasm_stricmp(p, "endp") || !nasm_stricmp(q, "endp")) { - nasm_free(line); - return nasm_strdup(""); - } else if (!nasm_stricmp(p, "assume")) { - struct TSegmentAssume *assume; - /* handle ASSUME */ - if (!TAssumes) { - TAssumes = nasm_malloc(sizeof(*TAssumes)); - TAssumes[0].segreg = NULL; - } - i = 0; - q[len2] = oldchar2; - /* Skip whitespaces */ - while (isspace(*q) && *q) - q++; - while (*q && *q != ';') { - p = q; - for (; *q && *q != ';' && *q != ':' && !isspace(*q); q++); - if (!*q || *q == ';') - break; - /* segment register name */ - for (assume = TAssumes; assume->segreg; assume++) - if (strlen(assume->segreg) == (size_t)(q-p) && - !yasm__strncasecmp(assume->segreg, p, q-p)) - break; - if (!assume->segreg) { - i = assume - TAssumes + 1; - TAssumes = nasm_realloc(TAssumes, (i+1)*sizeof(*TAssumes)); - assume = TAssumes + i - 1; - assume->segreg = nasm_strndup(p, q-p); - assume[1].segreg = NULL; - } - for (; *q && *q != ';' && *q != ':' && isspace(*q); q++); - if (*q != ':') - error(ERR_FATAL, "expected `:' instead of `%c'", *q); - for (q++; *q && isspace(*q); q++); - - /* segment name */ - p = q; - for (; *q && *q != ';' && *q != ',' && !isspace(*q); q++); - assume->segment = nasm_strndup(p, q-p); - for (; *q && isspace(*q); q++); - if (*q && *q != ';' && *q != ',') - error(ERR_FATAL, "expected `,' instead of `%c'", *q); - - if (*q && *q != ';') - q++; - for (; *q && isspace(*q); q++); - } - TAssumes[i].segreg = NULL; - TAssumes = nasm_realloc(TAssumes, (i+1)*sizeof(*TAssumes)); - nasm_free(line); - return nasm_strdup(""); - } else if (inTstruc) { - struct TStrucField *field; - /* TODO: handle unnamed data */ - field = nasm_malloc(sizeof(*field)); - field->name = nasm_strdup(p); - /* TODO: type struc ! */ - field->type = nasm_strdup(q); - field->next = NULL; - if (!TStrucs->fields) - TStrucs->fields = field; - else if (TStrucs->lastField) - TStrucs->lastField->next = field; - TStrucs->lastField = field; - if (!oldchar2) { - error(ERR_FATAL, "Expected struc field initializer after %s %s", p, q); - return line; - } - oldline = line; - line = nasm_malloc(1 + len + 1 + len2 + 1 + strlen(q+len2+1) + 1); - sprintf(line, ".%s %s %s", p, q, q+len2+1); - nasm_free(oldline); - return line; - } - { - struct TStruc *struc; - for (struc = TStrucs; struc; struc = struc->next) { - if (!yasm__strcasecmp(q, struc->name)) { - char *r = q + len2 + 1, *s, *t, tasm_param[6]; - struct TStrucField *field = struc->fields; - int size, n; - if (!oldchar2) { - error(ERR_FATAL, "Expected struc field initializer after %s %s", p, q); - return line; - } - r = strchr(r, '<'); - if (!r) { - error(ERR_FATAL, "Expected < for struc field initializer in %s %s %s", p, q, r); - return line; - } - t = strchr(r + 1, '>'); - if (!t) { - error(ERR_FATAL, "Expected > for struc field initializer in %s %s %s", p, q, r); - return line; - } - *t = 0; - oldline = line; - size = len + len2 + 128; - line = nasm_malloc(size); - if (defining) - for (n=0;TMParameters[n];n++) - if (!strcmp(TMParameters[n],p)) { - sprintf(tasm_param,"%%{%d}",n+1); - p = tasm_param; - break; - } - n = sprintf(line, "%s: istruc %s\n", p, q); - /* use initialisers */ - while ((s = strchr(r + 1, ','))) { - if (!field) { - error(ERR_FATAL, "Too many initializers in structure %s %s", p, q); - return oldline; - } - *s = 0; - m = strlen(p) + 1 + strlen(field->name)*2 + 8 + - strlen(field->type) + 1 + strlen(r+1) + 2; - size += m; - line = nasm_realloc(line, size); - sprintf(line + n, "%s.%s: at .%s, %s %s\n", - p, field->name, field->name, field->type, r + 1); - n += m-1; - r = s; - field = field->next; - } - /* complete with last initializer and '?' */ - while(field) { - m = strlen(p) + 1 + strlen(field->name)*2 + 8 + - strlen(field->type) + 1 + (r ? strlen(r+1) : 1) + 2; - size += m; - line = nasm_realloc(line, size); - sprintf(line + n, "%s.%s: at .%s, %s %s\n", p, field->name, - field->name, field->type, r ? r + 1: "?"); - n += m-1; - r = NULL; - field = field->next; - } - line = nasm_realloc(line, n + 5); - sprintf(line + n, "iend"); - nasm_free(oldline); - return line; - } - } - } - - q[len2] = oldchar2; - p[len] = oldchar; - return line; } -static Token * tasm_join_tokens(Token *tline) -{ - Token *t, *prev, *next; - for (prev = NULL, t = tline; t; prev = t, t = next) { - next = t->next; - if (t->type == TOK_OTHER && !strcmp(t->text,"&")) { - if (!prev) - error(ERR_FATAL, "no token before &"); - else if (!next) - error(ERR_FATAL, "no token after &"); - else if (prev->type != next->type) - error(ERR_FATAL, "can't handle different types of token around &"); - else if (!prev->text || !next->text) - error(ERR_FATAL, "can't handle empty token around &"); - else { - int lenp = strlen(prev->text); - int lenn = strlen(next->text); - prev->text = nasm_realloc(prev->text, lenp + lenn + 1); - strncpy(prev->text + lenp, next->text, lenn + 1); - (void) delete_Token(t); - prev->next = delete_Token(next); - t = prev; - next = t->next; - } - } - } - return tline; -} - /* * The pre-preprocessing stage... This function translates line * number indications as they emerge from GNU cpp (`# lineno "file" @@ -1048,47 +514,23 @@ prepreproc(char *line) int lineno; size_t fnlen; char *fname, *oldline; - char *c, *d, *ret; - Line *l, **lp; if (line[0] == '#' && line[1] == ' ') { - oldline = line; - fname = oldline + 2; - lineno = atoi(fname); - fname += strspn(fname, "0123456789 "); - if (*fname == '"') - fname++; - fnlen = strcspn(fname, "\""); - line = nasm_malloc(20 + fnlen); - sprintf(line, "%%line %d %.*s", lineno, (int)fnlen, fname); - nasm_free(oldline); + oldline = line; + fname = oldline + 2; + lineno = atoi(fname); + fname += strspn(fname, "0123456789 "); + if (*fname == '"') + fname++; + fnlen = strcspn(fname, "\""); + line = nasm_malloc(20 + fnlen); + sprintf(line, "%%line %d %.*s", lineno, (int)fnlen, fname); + nasm_free(oldline); } if (tasm_compatible_mode) - line = check_tasm_directive(line); - - if (!(c = strchr(line, '\n'))) - return line; - - /* Turn multiline macros into several lines */ - *c = '\0'; - ret = nasm_strdup(line); - - lp = &istk->expansion; - do { - d = strchr(c+1, '\n'); - if (d) - *d = '\0'; - l = nasm_malloc(sizeof(*l)); - l -> first = tokenise(c+1); - l -> finishes = NULL; - l -> next = *lp; - *lp = l; - c = d; - lp = &l -> next; - } while (c); - nasm_free(line); - return ret; + return check_tasm_directive(line); + return line; } /* @@ -1106,17 +548,17 @@ hash(char *s) * Powers of three, mod 31. */ static const int multipliers[] = { - 1, 3, 9, 27, 19, 26, 16, 17, 20, 29, 25, 13, 8, 24, 10, - 30, 28, 22, 4, 12, 5, 15, 14, 11, 2, 6, 18, 23, 7, 21 + 1, 3, 9, 27, 19, 26, 16, 17, 20, 29, 25, 13, 8, 24, 10, + 30, 28, 22, 4, 12, 5, 15, 14, 11, 2, 6, 18, 23, 7, 21 }; while (*s) { - h += multipliers[i] * (unsigned char) (toupper(*s)); - s++; - if (++i >= elements(multipliers)) - i = 0; + h += multipliers[i] * (unsigned char) (toupper(*s)); + s++; + if (++i >= elements(multipliers)) + i = 0; } h %= NHASH; return h; @@ -1130,7 +572,7 @@ free_tlist(Token * list_) { while (list_) { - list_ = delete_Token(list_); + list_ = delete_Token(list_); } } @@ -1143,10 +585,10 @@ free_llist(Line * list_) Line *l; while (list_) { - l = list_; - list_ = list_->next; - free_tlist(l->first); - nasm_free(l); + l = list_; + list_ = list_->next; + free_tlist(l->first); + nasm_free(l); } } @@ -1176,11 +618,11 @@ ctx_pop(void) smac = c->localmac; while (smac) { - s = smac; - smac = smac->next; - nasm_free(s->name); - free_tlist(s->expansion); - nasm_free(s); + s = smac; + smac = smac->next; + nasm_free(s->name); + free_tlist(s->expansion); + nasm_free(s); } nasm_free(c->name); nasm_free(c); @@ -1199,18 +641,81 @@ read_line(void) char *buffer, *p, *q; int bufsize, continued_count; + Line *pd, *l; + Token *head, **tail, *t; + + /* Nasty hack for builtin defines */ + for (pd = builtindef; pd; pd = pd->next) + { + head = NULL; + tail = &head; + for (t = pd->first; t; t = t->next) + { + *tail = new_Token(NULL, t->type, t->text, 0); + tail = &(*tail)->next; + } + l = nasm_malloc(sizeof(Line)); + l->next = istk->expansion; + l->first = head; + l->finishes = FALSE; + istk->expansion = l; + } + + if (stdmacpos) + { + if (*stdmacpos) + { + char *ret = nasm_strdup(*stdmacpos++); + if (!*stdmacpos && any_extrastdmac) + { + stdmacpos = extrastdmac; + any_extrastdmac = FALSE; + return ret; + } + /* + * Nasty hack: here we push the contents of `predef' on + * to the top-level expansion stack, since this is the + * most convenient way to implement the pre-include and + * pre-define features. + */ + if (!*stdmacpos) + { + for (pd = predef; pd; pd = pd->next) + { + head = NULL; + tail = &head; + for (t = pd->first; t; t = t->next) + { + *tail = new_Token(NULL, t->type, t->text, 0); + tail = &(*tail)->next; + } + l = nasm_malloc(sizeof(Line)); + l->next = istk->expansion; + l->first = head; + l->finishes = FALSE; + istk->expansion = l; + } + } + return ret; + } + else + { + stdmacpos = NULL; + } + } + bufsize = BUF_DELTA; buffer = nasm_malloc(BUF_DELTA); p = buffer; continued_count = 0; while (1) { - q = fgets(p, bufsize - (int)(p - buffer), istk->fp); - if (!q) - break; - p += strlen(p); - if (p > buffer && p[-1] == '\n') - { + q = fgets(p, bufsize - (int)(p - buffer), istk->fp); + if (!q) + break; + p += strlen(p); + if (p > buffer && p[-1] == '\n') + { /* Convert backslash-CRLF line continuation sequences into nothing at all (for DOS and Windows) */ if (((p - 2) > buffer) && (p[-3] == '\\') && (p[-2] == '\r')) { @@ -1228,20 +733,20 @@ read_line(void) else { break; } - } - if (p - buffer > bufsize - 10) - { - long offset = (long)(p - buffer); - bufsize += BUF_DELTA; - buffer = nasm_realloc(buffer, (size_t)bufsize); - p = buffer + offset; /* prevent stale-pointer problems */ - } + } + if (p - buffer > bufsize - 10) + { + long offset = (long)(p - buffer); + bufsize += BUF_DELTA; + buffer = nasm_realloc(buffer, (size_t)bufsize); + p = buffer + offset; /* prevent stale-pointer problems */ + } } if (!q && p == buffer) { - nasm_free(buffer); - return NULL; + nasm_free(buffer); + return NULL; } nasm_src_set_linnum(nasm_src_get_linnum() + istk->lineinc + (continued_count * istk->lineinc)); @@ -1251,7 +756,7 @@ read_line(void) * present at the end of the line. */ while (--p >= buffer && (*p == '\n' || *p == '\r')) - *p = '\0'; + *p = '\0'; /* * Handle spurious ^Z, which may be inserted into source files @@ -1279,153 +784,153 @@ tokenise(char *line) while (*line) { - p = line; - if (*p == '%') - { - p++; - if ( isdigit(*p) || - ((*p == '-' || *p == '+') && isdigit(p[1])) || - ((*p == '+') && (isspace(p[1]) || !p[1]))) - { - do - { - p++; - } - while (isdigit(*p)); - type = TOK_PREPROC_ID; - } - else if (*p == '{') - { - p++; - while (*p && *p != '}') - { - p[-1] = *p; - p++; - } - p[-1] = '\0'; - if (*p) - p++; - type = TOK_PREPROC_ID; - } - else if (isidchar(*p) || - ((*p == '!' || *p == '%' || *p == '$') && - isidchar(p[1]))) - { - do - { - p++; - } - while (isidchar(*p)); - type = TOK_PREPROC_ID; - } - else - { - type = TOK_OTHER; - if (*p == '%') - p++; - } - } - else if (isidstart(*p) || (*p == '$' && isidstart(p[1]))) - { - type = TOK_ID; - p++; - while (*p && isidchar(*p)) - p++; - } - else if (*p == '\'' || *p == '"') - { - /* - * A string token. - */ - char c = *p; - p++; - type = TOK_STRING; - while (*p && *p != c) - p++; + p = line; + if (*p == '%') + { + p++; + if ( isdigit(*p) || + ((*p == '-' || *p == '+') && isdigit(p[1])) || + ((*p == '+') && (isspace(p[1]) || !p[1]))) + { + do + { + p++; + } + while (isdigit(*p)); + type = TOK_PREPROC_ID; + } + else if (*p == '{') + { + p++; + while (*p && *p != '}') + { + p[-1] = *p; + p++; + } + p[-1] = '\0'; + if (*p) + p++; + type = TOK_PREPROC_ID; + } + else if (isidchar(*p) || + ((*p == '!' || *p == '%' || *p == '$') && + isidchar(p[1]))) + { + do + { + p++; + } + while (isidchar(*p)); + type = TOK_PREPROC_ID; + } + else + { + type = TOK_OTHER; + if (*p == '%') + p++; + } + } + else if (isidstart(*p) || (*p == '$' && isidstart(p[1]))) + { + type = TOK_ID; + p++; + while (*p && isidchar(*p)) + p++; + } + else if (*p == '\'' || *p == '"') + { + /* + * A string token. + */ + char c = *p; + p++; + type = TOK_STRING; + while (*p && *p != c) + p++; - if (*p) - { - p++; - } - else - { - error(ERR_WARNING, "unterminated string"); - type = -1; - } - } - else if (isnumstart(*p)) - { - /* - * A number token. - */ - type = TOK_NUMBER; - p++; - while (*p && isnumchar(*p)) - p++; - } - else if (isspace(*p)) - { - type = TOK_WHITESPACE; - p++; - while (*p && isspace(*p)) - p++; - /* - * Whitespace just before end-of-line is discarded by - * pretending it's a comment; whitespace just before a - * comment gets lumped into the comment. - */ - if (!*p || *p == ';') - { - type = TOK_COMMENT; - while (*p) - p++; - } - } - else if (*p == ';') - { - type = TOK_COMMENT; - while (*p) - p++; - } - else - { - /* - * Anything else is an operator of some kind. We check - * for all the double-character operators (>>, <<, //, - * %%, <=, >=, ==, !=, <>, &&, ||, ^^), but anything - * else is a single-character operator. - */ - type = TOK_OTHER; - if ((p[0] == '>' && p[1] == '>') || - (p[0] == '<' && p[1] == '<') || - (p[0] == '/' && p[1] == '/') || - (p[0] == '<' && p[1] == '=') || - (p[0] == '>' && p[1] == '=') || - (p[0] == '=' && p[1] == '=') || - (p[0] == '!' && p[1] == '=') || - (p[0] == '<' && p[1] == '>') || - (p[0] == '&' && p[1] == '&') || - (p[0] == '|' && p[1] == '|') || - (p[0] == '^' && p[1] == '^')) - { - p++; - } - p++; - } + if (*p) + { + p++; + } + else + { + error(ERR_WARNING, "unterminated string"); + type = -1; + } + } + else if (isnumstart(*p)) + { + /* + * A number token. + */ + type = TOK_NUMBER; + p++; + while (*p && isnumchar(*p)) + p++; + } + else if (isspace(*p)) + { + type = TOK_WHITESPACE; + p++; + while (*p && isspace(*p)) + p++; + /* + * Whitespace just before end-of-line is discarded by + * pretending it's a comment; whitespace just before a + * comment gets lumped into the comment. + */ + if (!*p || *p == ';') + { + type = TOK_COMMENT; + while (*p) + p++; + } + } + else if (*p == ';') + { + type = TOK_COMMENT; + while (*p) + p++; + } + else + { + /* + * Anything else is an operator of some kind. We check + * for all the double-character operators (>>, <<, //, + * %%, <=, >=, ==, !=, <>, &&, ||, ^^), but anything + * else is a single-character operator. + */ + type = TOK_OTHER; + if ((p[0] == '>' && p[1] == '>') || + (p[0] == '<' && p[1] == '<') || + (p[0] == '/' && p[1] == '/') || + (p[0] == '<' && p[1] == '=') || + (p[0] == '>' && p[1] == '=') || + (p[0] == '=' && p[1] == '=') || + (p[0] == '!' && p[1] == '=') || + (p[0] == '<' && p[1] == '>') || + (p[0] == '&' && p[1] == '&') || + (p[0] == '|' && p[1] == '|') || + (p[0] == '^' && p[1] == '^')) + { + p++; + } + p++; + } - /* Handle unterminated string */ - if (type == -1) - { - *tail = t = new_Token(NULL, TOK_STRING, line, (size_t)(p-line)+1); - t->text[p-line] = *line; - tail = &t->next; - } - else if (type != TOK_COMMENT) - { - *tail = t = new_Token(NULL, type, line, (size_t)(p - line)); - tail = &t->next; - } - line = p; + /* Handle unterminated string */ + if (type == -1) + { + *tail = t = new_Token(NULL, TOK_STRING, line, (size_t)(p-line)+1); + t->text[p-line] = *line; + tail = &t->next; + } + else if (type != TOK_COMMENT) + { + *tail = t = new_Token(NULL, type, line, (size_t)(p - line)); + tail = &t->next; + } + line = p; } return list_; } @@ -1438,20 +943,20 @@ tokenise(char *line) static void * new_Block(size_t size) { - Blocks *b = &blocks; - - /* first, get to the end of the linked list */ - while (b->next) - b = b->next; - /* now allocate the requested chunk */ - b->chunk = nasm_malloc(size); - - /* now allocate a new block for the next request */ - b->next = nasm_malloc(sizeof(Blocks)); - /* and initialize the contents of the new block */ - b->next->next = NULL; - b->next->chunk = NULL; - return b->chunk; + Blocks *b = &blocks; + + /* first, get to the end of the linked list */ + while (b->next) + b = b->next; + /* now allocate the requested chunk */ + b->chunk = nasm_malloc(size); + + /* now allocate a new block for the next request */ + b->next = nasm_malloc(sizeof(Blocks)); + /* and initialize the contents of the new block */ + b->next->next = NULL; + b->next->chunk = NULL; + return b->chunk; } /* @@ -1460,23 +965,23 @@ new_Block(size_t size) static void delete_Blocks(void) { - Blocks *a,*b = &blocks; + Blocks *a,*b = &blocks; - /* - * keep in mind that the first block, pointed to by blocks - * is a static and not dynamically allocated, so we don't - * free it. - */ - while (b) - { - if (b->chunk) - nasm_free(b->chunk); - a = b; - b = b->next; + /* + * keep in mind that the first block, pointed to by blocks + * is a static and not dynamically allocated, so we don't + * free it. + */ + while (b) + { + if (b->chunk) + nasm_free(b->chunk); + a = b; + b = b->next; if (a != &blocks) - nasm_free(a); - } -} + nasm_free(a); + } +} /* * this function creates a new Token and passes a pointer to it @@ -1491,10 +996,10 @@ new_Token(Token * next, int type, const char *text, size_t txtlen) if (freeTokens == NULL) { - freeTokens = (Token *)new_Block(TOKEN_BLOCKSIZE * sizeof(Token)); - for (i = 0; i < TOKEN_BLOCKSIZE - 1; i++) - freeTokens[i].next = &freeTokens[i + 1]; - freeTokens[i].next = NULL; + freeTokens = (Token *)new_Block(TOKEN_BLOCKSIZE * sizeof(Token)); + for (i = 0; i < TOKEN_BLOCKSIZE - 1; i++) + freeTokens[i].next = &freeTokens[i + 1]; + freeTokens[i].next = NULL; } t = freeTokens; freeTokens = t->next; @@ -1503,15 +1008,15 @@ new_Token(Token * next, int type, const char *text, size_t txtlen) t->type = type; if (type == TOK_WHITESPACE || text == NULL) { - t->text = NULL; + t->text = NULL; } else { - if (txtlen == 0) - txtlen = strlen(text); - t->text = nasm_malloc(1 + txtlen); - strncpy(t->text, text, txtlen); - t->text[txtlen] = '\0'; + if (txtlen == 0) + txtlen = strlen(text); + t->text = nasm_malloc(1 + txtlen); + strncpy(t->text, text, txtlen); + t->text[txtlen] = '\0'; } return t; } @@ -1541,56 +1046,56 @@ detoken(Token * tlist, int expand_locals) len = 0; for (t = tlist; t; t = t->next) { - if (t->type == TOK_PREPROC_ID && t->text[1] == '!') - { - char *p2 = getenv(t->text + 2); - nasm_free(t->text); - if (p2) - t->text = nasm_strdup(p2); - else - t->text = NULL; - } - /* Expand local macros here and not during preprocessing */ - if (expand_locals && - t->type == TOK_PREPROC_ID && t->text && - t->text[0] == '%' && t->text[1] == '$') - { - Context *ctx = get_ctx(t->text, FALSE); - if (ctx) - { - char buffer[40]; - char *p2, *q = t->text + 2; + if (t->type == TOK_PREPROC_ID && t->text[1] == '!') + { + char *p2 = getenv(t->text + 2); + nasm_free(t->text); + if (p2) + t->text = nasm_strdup(p2); + else + t->text = NULL; + } + /* Expand local macros here and not during preprocessing */ + if (expand_locals && + t->type == TOK_PREPROC_ID && t->text && + t->text[0] == '%' && t->text[1] == '$') + { + Context *ctx = get_ctx(t->text, FALSE); + if (ctx) + { + char buffer[40]; + char *p2, *q = t->text + 2; - q += strspn(q, "$"); - sprintf(buffer, "..@%lu.", ctx->number); - p2 = nasm_strcat(buffer, q); - nasm_free(t->text); - t->text = p2; - } - } - if (t->type == TOK_WHITESPACE) - { - len++; - } - else if (t->text) - { - len += strlen(t->text); - } + q += strspn(q, "$"); + sprintf(buffer, "..@%lu.", ctx->number); + p2 = nasm_strcat(buffer, q); + nasm_free(t->text); + t->text = p2; + } + } + if (t->type == TOK_WHITESPACE) + { + len++; + } + else if (t->text) + { + len += strlen(t->text); + } } p = line = nasm_malloc(len + 1); for (t = tlist; t; t = t->next) { - if (t->type == TOK_WHITESPACE) - { - *p = ' '; - p++; - *p = '\0'; - } - else if (t->text) - { - strcpy(p, t->text); - p += strlen(p); - } + if (t->type == TOK_WHITESPACE) + { + *p = ' '; + p++; + *p = '\0'; + } + else if (t->text) + { + strcpy(p, t->text); + p += strlen(p); + } } *p = '\0'; return line; @@ -1610,95 +1115,95 @@ ppscan(void *private_data, struct tokenval *tokval) do { - tline = *tlineptr; - *tlineptr = tline ? tline->next : NULL; + tline = *tlineptr; + *tlineptr = tline ? tline->next : NULL; } while (tline && (tline->type == TOK_WHITESPACE || - tline->type == TOK_COMMENT)); + tline->type == TOK_COMMENT)); if (!tline) - return tokval->t_type = TOKEN_EOS; + return tokval->t_type = TOKEN_EOS; if (tline->text[0] == '$' && !tline->text[1]) - return tokval->t_type = TOKEN_HERE; + return tokval->t_type = TOKEN_HERE; if (tline->text[0] == '$' && tline->text[1] == '$' && !tline->text[2]) - return tokval->t_type = TOKEN_BASE; + return tokval->t_type = TOKEN_BASE; if (tline->type == TOK_ID) { - tokval->t_charptr = tline->text; - if (tline->text[0] == '$') - { - tokval->t_charptr++; - return tokval->t_type = TOKEN_ID; - } + tokval->t_charptr = tline->text; + if (tline->text[0] == '$') + { + tokval->t_charptr++; + return tokval->t_type = TOKEN_ID; + } - /* - * This is the only special case we actually need to worry - * about in this restricted context. - */ - if (!nasm_stricmp(tline->text, "seg")) - return tokval->t_type = TOKEN_SEG; + /* + * This is the only special case we actually need to worry + * about in this restricted context. + */ + if (!nasm_stricmp(tline->text, "seg")) + return tokval->t_type = TOKEN_SEG; - return tokval->t_type = TOKEN_ID; + return tokval->t_type = TOKEN_ID; } if (tline->type == TOK_NUMBER) { - int rn_error; + int rn_error; - tokval->t_integer = nasm_readnum(tline->text, &rn_error); - if (rn_error) - return tokval->t_type = TOKEN_ERRNUM; - tokval->t_charptr = NULL; - return tokval->t_type = TOKEN_NUM; + tokval->t_integer = nasm_readnum(tline->text, &rn_error); + if (rn_error) + return tokval->t_type = TOKEN_ERRNUM; + tokval->t_charptr = NULL; + return tokval->t_type = TOKEN_NUM; } if (tline->type == TOK_STRING) { - int rn_warn; - char q, *r; - size_t l; + int rn_warn; + char q, *r; + size_t l; - r = tline->text; - q = *r++; - l = strlen(r); + r = tline->text; + q = *r++; + l = strlen(r); - if (l == 0 || r[l - 1] != q) - return tokval->t_type = TOKEN_ERRNUM; - tokval->t_integer = nasm_readstrnum(r, l - 1, &rn_warn); - if (rn_warn) - error(ERR_WARNING | ERR_PASS1, "character constant too long"); - tokval->t_charptr = NULL; - return tokval->t_type = TOKEN_NUM; + if (l == 0 || r[l - 1] != q) + return tokval->t_type = TOKEN_ERRNUM; + tokval->t_integer = nasm_readstrnum(r, l - 1, &rn_warn); + if (rn_warn) + error(ERR_WARNING | ERR_PASS1, "character constant too long"); + tokval->t_charptr = NULL; + return tokval->t_type = TOKEN_NUM; } if (tline->type == TOK_OTHER) { - if (!strcmp(tline->text, "<<")) - return tokval->t_type = TOKEN_SHL; - if (!strcmp(tline->text, ">>")) - return tokval->t_type = TOKEN_SHR; - if (!strcmp(tline->text, "//")) - return tokval->t_type = TOKEN_SDIV; - if (!strcmp(tline->text, "%%")) - return tokval->t_type = TOKEN_SMOD; - if (!strcmp(tline->text, "==")) - return tokval->t_type = TOKEN_EQ; - if (!strcmp(tline->text, "<>")) - return tokval->t_type = TOKEN_NE; - if (!strcmp(tline->text, "!=")) - return tokval->t_type = TOKEN_NE; - if (!strcmp(tline->text, "<=")) - return tokval->t_type = TOKEN_LE; - if (!strcmp(tline->text, ">=")) - return tokval->t_type = TOKEN_GE; - if (!strcmp(tline->text, "&&")) - return tokval->t_type = TOKEN_DBL_AND; - if (!strcmp(tline->text, "^^")) - return tokval->t_type = TOKEN_DBL_XOR; - if (!strcmp(tline->text, "||")) - return tokval->t_type = TOKEN_DBL_OR; + if (!strcmp(tline->text, "<<")) + return tokval->t_type = TOKEN_SHL; + if (!strcmp(tline->text, ">>")) + return tokval->t_type = TOKEN_SHR; + if (!strcmp(tline->text, "//")) + return tokval->t_type = TOKEN_SDIV; + if (!strcmp(tline->text, "%%")) + return tokval->t_type = TOKEN_SMOD; + if (!strcmp(tline->text, "==")) + return tokval->t_type = TOKEN_EQ; + if (!strcmp(tline->text, "<>")) + return tokval->t_type = TOKEN_NE; + if (!strcmp(tline->text, "!=")) + return tokval->t_type = TOKEN_NE; + if (!strcmp(tline->text, "<=")) + return tokval->t_type = TOKEN_LE; + if (!strcmp(tline->text, ">=")) + return tokval->t_type = TOKEN_GE; + if (!strcmp(tline->text, "&&")) + return tokval->t_type = TOKEN_DBL_AND; + if (!strcmp(tline->text, "^^")) + return tokval->t_type = TOKEN_DBL_XOR; + if (!strcmp(tline->text, "||")) + return tokval->t_type = TOKEN_DBL_OR; } /* @@ -1737,39 +1242,39 @@ get_ctx(char *name, int all_contexts) size_t i; if (!name || name[0] != '%' || name[1] != '$') - return NULL; + return NULL; if (!cstk) { - error(ERR_NONFATAL, "`%s': context stack is empty", name); - return NULL; + error(ERR_NONFATAL, "`%s': context stack is empty", name); + return NULL; } for (i = strspn(name + 2, "$"), ctx = cstk; (i > 0) && ctx; i--) { - ctx = ctx->next; + ctx = ctx->next; /* i--; Lino - 02/25/02 */ } if (!ctx) { - error(ERR_NONFATAL, "`%s': context stack is only" - " %d level%s deep", name, i - 1, (i == 2 ? "" : "s")); - return NULL; + error(ERR_NONFATAL, "`%s': context stack is only" + " %d level%s deep", name, i - 1, (i == 2 ? "" : "s")); + return NULL; } if (!all_contexts) - return ctx; + return ctx; do { - /* Search for this smacro in found context */ - m = ctx->localmac; - while (m) - { - if (!mstrcmp(m->name, name, m->casesense)) - return ctx; - m = m->next; - } - ctx = ctx->next; + /* Search for this smacro in found context */ + m = ctx->localmac; + while (m) + { + if (!mstrcmp(m->name, name, m->casesense)) + return ctx; + m = m->next; + } + ctx = ctx->next; } while (ctx); return NULL; @@ -1786,7 +1291,7 @@ static FILE * inc_fopen(char *file, char **newname) { FILE *fp; - char *combine = NULL, *c; + char *combine = NULL; char *pb, *p1, *p2, *file2 = NULL; /* Try to expand all %ENVVAR% in filename. Warn, and leave %string% @@ -1795,75 +1300,54 @@ inc_fopen(char *file, char **newname) pb = file; p1 = pb; for (;;) { - char *env; - while (*p1 != '\0' && *p1 != '%') - p1++; - if (*p1 == '\0') - break; - p2 = p1+1; - while (*p2 != '\0' && *p2 != '%') - p2++; - if (*p2 == '\0') - break; - /* Okay, we have a %...%, with p1 pointing to the first %, and p2 - * pointing to the second %. - */ - *p2 = '\0'; - env = getenv(p1+1); - if (!env) { - /* warn, restore %, and continue looking */ - error(ERR_WARNING, "environment variable `%s' does not exist", - p1+1); - *p2 = '%'; - p1 = p2+1; - continue; - } - /* need to expand */ - if (!file2) { - file2 = nasm_malloc(strlen(file)+strlen(env)+1); - file2[0] = '\0'; - } else - file2 = nasm_realloc(file2, strlen(file2)+strlen(env)+1); - *p1 = '\0'; - strcat(file2, pb); - strcat(file2, env); - pb = p2+1; - p1 = pb; + char *env; + while (*p1 != '\0' && *p1 != '%') + p1++; + if (*p1 == '\0') + break; + p2 = p1+1; + while (*p2 != '\0' && *p2 != '%') + p2++; + if (*p2 == '\0') + break; + /* Okay, we have a %...%, with p1 pointing to the first %, and p2 + * pointing to the second %. + */ + *p2 = '\0'; + env = getenv(p1+1); + if (!env) { + /* warn, restore %, and continue looking */ + error(ERR_WARNING, "environment variable `%s' does not exist", + p1+1); + *p2 = '%'; + p1 = p2+1; + continue; + } + /* need to expand */ + if (!file2) { + file2 = nasm_malloc(strlen(file)+strlen(env)+1); + file2[0] = '\0'; + } else + file2 = nasm_realloc(file2, strlen(file2)+strlen(env)+1); + *p1 = '\0'; + strcat(file2, pb); + strcat(file2, env); + pb = p2+1; + p1 = pb; } /* add tail end; string is long enough that we don't need to realloc */ if (file2) - strcat(file2, pb); + strcat(file2, pb); fp = yasm_fopen_include(file2 ? file2 : file, nasm_src_get_fname(), "r", - &combine); - if (!fp && tasm_compatible_mode) - { - char *thefile = file2 ? file2 : file; - /* try a few case combinations */ - do { - for (c = thefile; *c; c++) - *c = toupper(*c); - fp = yasm_fopen_include(thefile, nasm_src_get_fname(), "r", &combine); - if (fp) break; - *thefile = tolower(*thefile); - fp = yasm_fopen_include(thefile, nasm_src_get_fname(), "r", &combine); - if (fp) break; - for (c = thefile; *c; c++) - *c = tolower(*c); - fp = yasm_fopen_include(thefile, nasm_src_get_fname(), "r", &combine); - if (fp) break; - *thefile = toupper(*thefile); - fp = yasm_fopen_include(thefile, nasm_src_get_fname(), "r", &combine); - if (fp) break; - } while (0); - } + &combine); if (!fp) - error(ERR_FATAL, "unable to open include file `%s'", - file2 ? file2 : file); + error(ERR_FATAL, "unable to open include file `%s'", + file2 ? file2 : file); nasm_preproc_add_dep(combine); if (file2) - nasm_free(file2); + nasm_free(file2); *newname = combine; return fp; @@ -1892,42 +1376,41 @@ inc_fopen(char *file, char **newname) */ static int smacro_defined(Context * ctx, char *name, int nparam, SMacro ** defn, - int nocase) + int nocase) { SMacro *m; - int highest_level = -1; if (ctx) - m = ctx->localmac; + m = ctx->localmac; else if (name[0] == '%' && name[1] == '$') { - if (cstk) - ctx = get_ctx(name, FALSE); - if (!ctx) - return FALSE; /* got to return _something_ */ - m = ctx->localmac; + if (cstk) + ctx = get_ctx(name, FALSE); + if (!ctx) + return FALSE; /* got to return _something_ */ + m = ctx->localmac; } else - m = smacros[hash(name)]; + m = smacros[hash(name)]; while (m) { - if (!mstrcmp(m->name, name, m->casesense && nocase) && - (nparam <= 0 || m->nparam == 0 || nparam == m->nparam) && (highest_level < 0 || m->level > highest_level)) - { - highest_level = m->level; - if (defn) - { - if (nparam == m->nparam || nparam == -1) - *defn = m; - else - *defn = NULL; - } - } - m = m->next; + if (!mstrcmp(m->name, name, m->casesense && nocase) && + (nparam <= 0 || m->nparam == 0 || nparam == m->nparam)) + { + if (defn) + { + if (nparam == m->nparam || nparam == -1) + *defn = m; + else + *defn = NULL; + } + return TRUE; + } + m = m->next; } - return highest_level >= 0; + return FALSE; } /* @@ -1945,39 +1428,39 @@ count_mmac_params(Token * t, int *nparam, Token *** params) *params = NULL; while (t) { - if (*nparam+1 >= paramsize) - { - paramsize += PARAM_DELTA; - *params = nasm_realloc(*params, sizeof(**params) * paramsize); - } - skip_white_(t); - brace = FALSE; - if (tok_is_(t, "{")) - brace = TRUE; - (*params)[(*nparam)++] = t; - while (tok_isnt_(t, brace ? "}" : ",")) - t = t->next; - if (t) - { /* got a comma/brace */ - t = t->next; - if (brace) - { - /* - * Now we've found the closing brace, look further - * for the comma. - */ - skip_white_(t); - if (tok_isnt_(t, ",")) - { - error(ERR_NONFATAL, - "braces do not enclose all of macro parameter"); - while (tok_isnt_(t, ",")) - t = t->next; - } - if (t) - t = t->next; /* eat the comma */ - } - } + if (*nparam+1 >= paramsize) + { + paramsize += PARAM_DELTA; + *params = nasm_realloc(*params, sizeof(**params) * paramsize); + } + skip_white_(t); + brace = FALSE; + if (tok_is_(t, "{")) + brace = TRUE; + (*params)[(*nparam)++] = t; + while (tok_isnt_(t, brace ? "}" : ",")) + t = t->next; + if (t) + { /* got a comma/brace */ + t = t->next; + if (brace) + { + /* + * Now we've found the closing brace, look further + * for the comma. + */ + skip_white_(t); + if (tok_isnt_(t, ",")) + { + error(ERR_NONFATAL, + "braces do not enclose all of macro parameter"); + while (tok_isnt_(t, ",")) + t = t->next; + } + if (t) + t = t->next; /* eat the comma */ + } + } } } @@ -2000,305 +1483,302 @@ if_condition(Token * tline, int i) switch (i) { - case PP_IFCTX: - case PP_ELIFCTX: - case PP_IFNCTX: - case PP_ELIFNCTX: - j = FALSE; /* have we matched yet? */ - while (cstk && tline) - { - skip_white_(tline); - if (!tline || tline->type != TOK_ID) - { - error(ERR_NONFATAL, - "`%s' expects context identifiers", - directives[i]); - free_tlist(origline); - return -1; - } - if (!nasm_stricmp(tline->text, cstk->name)) - j = TRUE; - tline = tline->next; - } - if (i == PP_IFNCTX || i == PP_ELIFNCTX) - j = !j; - free_tlist(origline); - return j; + case PP_IFCTX: + case PP_ELIFCTX: + case PP_IFNCTX: + case PP_ELIFNCTX: + j = FALSE; /* have we matched yet? */ + while (cstk && tline) + { + skip_white_(tline); + if (!tline || tline->type != TOK_ID) + { + error(ERR_NONFATAL, + "`%s' expects context identifiers", + directives[i]); + free_tlist(origline); + return -1; + } + if (!nasm_stricmp(tline->text, cstk->name)) + j = TRUE; + tline = tline->next; + } + if (i == PP_IFNCTX || i == PP_ELIFNCTX) + j = !j; + free_tlist(origline); + return j; - case PP_IFDEF: - case PP_ELIFDEF: - case PP_IFNDEF: - case PP_ELIFNDEF: - j = FALSE; /* have we matched yet? */ - while (tline) - { - skip_white_(tline); - if (!tline || (tline->type != TOK_ID && - (tline->type != TOK_PREPROC_ID || - tline->text[1] != '$'))) - { - error(ERR_NONFATAL, - "`%s' expects macro identifiers", - directives[i]); - free_tlist(origline); - return -1; - } - if (smacro_defined(NULL, tline->text, 0, NULL, 1)) - j = TRUE; - tline = tline->next; - } - if (i == PP_IFNDEF || i == PP_ELIFNDEF) - j = !j; - free_tlist(origline); - return j; + case PP_IFDEF: + case PP_ELIFDEF: + case PP_IFNDEF: + case PP_ELIFNDEF: + j = FALSE; /* have we matched yet? */ + while (tline) + { + skip_white_(tline); + if (!tline || (tline->type != TOK_ID && + (tline->type != TOK_PREPROC_ID || + tline->text[1] != '$'))) + { + error(ERR_NONFATAL, + "`%s' expects macro identifiers", + directives[i]); + free_tlist(origline); + return -1; + } + if (smacro_defined(NULL, tline->text, 0, NULL, 1)) + j = TRUE; + tline = tline->next; + } + if (i == PP_IFNDEF || i == PP_ELIFNDEF) + j = !j; + free_tlist(origline); + return j; - case PP_IFIDN: - case PP_ELIFIDN: - case PP_IFNIDN: - case PP_ELIFNIDN: - case PP_IFIDNI: - case PP_ELIFIDNI: - case PP_IFNIDNI: - case PP_ELIFNIDNI: - tline = expand_smacro(tline); - t = tt = tline; - while (tok_isnt_(tt, ",")) - tt = tt->next; - if (!tt) - { - error(ERR_NONFATAL, - "`%s' expects two comma-separated arguments", - directives[i]); - free_tlist(tline); - return -1; - } - tt = tt->next; - casesense = (i == PP_IFIDN || i == PP_ELIFIDN || - i == PP_IFNIDN || i == PP_ELIFNIDN); - j = TRUE; /* assume equality unless proved not */ - while ((t->type != TOK_OTHER || strcmp(t->text, ",")) && tt) - { - if (tt->type == TOK_OTHER && !strcmp(tt->text, ",")) - { - error(ERR_NONFATAL, "`%s': more than one comma on line", - directives[i]); - free_tlist(tline); - return -1; - } - if (t->type == TOK_WHITESPACE) - { - t = t->next; - continue; - } - if (tt->type == TOK_WHITESPACE) - { - tt = tt->next; - continue; - } - if (tt->type != t->type) - { - j = FALSE; /* found mismatching tokens */ - break; - } - /* Unify surrounding quotes for strings */ - if (t->type == TOK_STRING) - { - tt->text[0] = t->text[0]; - tt->text[strlen(tt->text) - 1] = t->text[0]; - } - if (mstrcmp(tt->text, t->text, casesense) != 0) - { - j = FALSE; /* found mismatching tokens */ - break; - } + case PP_IFIDN: + case PP_ELIFIDN: + case PP_IFNIDN: + case PP_ELIFNIDN: + case PP_IFIDNI: + case PP_ELIFIDNI: + case PP_IFNIDNI: + case PP_ELIFNIDNI: + tline = expand_smacro(tline); + t = tt = tline; + while (tok_isnt_(tt, ",")) + tt = tt->next; + if (!tt) + { + error(ERR_NONFATAL, + "`%s' expects two comma-separated arguments", + directives[i]); + free_tlist(tline); + return -1; + } + tt = tt->next; + casesense = (i == PP_IFIDN || i == PP_ELIFIDN || + i == PP_IFNIDN || i == PP_ELIFNIDN); + j = TRUE; /* assume equality unless proved not */ + while ((t->type != TOK_OTHER || strcmp(t->text, ",")) && tt) + { + if (tt->type == TOK_OTHER && !strcmp(tt->text, ",")) + { + error(ERR_NONFATAL, "`%s': more than one comma on line", + directives[i]); + free_tlist(tline); + return -1; + } + if (t->type == TOK_WHITESPACE) + { + t = t->next; + continue; + } + if (tt->type == TOK_WHITESPACE) + { + tt = tt->next; + continue; + } + if (tt->type != t->type) + { + j = FALSE; /* found mismatching tokens */ + break; + } + /* Unify surrounding quotes for strings */ + if (t->type == TOK_STRING) + { + tt->text[0] = t->text[0]; + tt->text[strlen(tt->text) - 1] = t->text[0]; + } + if (mstrcmp(tt->text, t->text, casesense) != 0) + { + j = FALSE; /* found mismatching tokens */ + break; + } - t = t->next; - tt = tt->next; - } - if ((t->type != TOK_OTHER || strcmp(t->text, ",")) || tt) - j = FALSE; /* trailing gunk on one end or other */ - if (i == PP_IFNIDN || i == PP_ELIFNIDN || - i == PP_IFNIDNI || i == PP_ELIFNIDNI) - j = !j; - free_tlist(tline); - return j; + t = t->next; + tt = tt->next; + } + if ((t->type != TOK_OTHER || strcmp(t->text, ",")) || tt) + j = FALSE; /* trailing gunk on one end or other */ + if (i == PP_IFNIDN || i == PP_ELIFNIDN || + i == PP_IFNIDNI || i == PP_ELIFNIDNI) + j = !j; + free_tlist(tline); + return j; case PP_IFMACRO: case PP_ELIFMACRO: case PP_IFNMACRO: case PP_ELIFNMACRO: - { - int found = 0; - MMacro searching, *mmac; + { + int found = 0; + MMacro searching, *mmac; - tline = tline->next; - skip_white_(tline); - tline = expand_id(tline); - if (!tok_type_(tline, TOK_ID)) - { - error(ERR_NONFATAL, - "`%s' expects a macro name", - directives[i]); - return -1; - } - searching.name = nasm_strdup(tline->text); - searching.casesense = (i == PP_MACRO); - searching.plus = FALSE; - searching.nolist = FALSE; - searching.in_progress = FALSE; - searching.rep_nest = NULL; - searching.nparam_min = 0; - searching.nparam_max = INT_MAX; - tline = expand_smacro(tline->next); - skip_white_(tline); - if (!tline) - { - } else if (!tok_type_(tline, TOK_NUMBER)) - { - error(ERR_NONFATAL, - "`%s' expects a parameter count or nothing", - directives[i]); - } - else - { - intn = nasm_readnum(tline->text, &j); - searching.nparam_min = searching.nparam_max = - yasm_intnum_get_int(intn); - yasm_intnum_destroy(intn); - if (j) - error(ERR_NONFATAL, - "unable to parse parameter count `%s'", - tline->text); - } - if (tline && tok_is_(tline->next, "-")) - { - tline = tline->next->next; - if (tok_is_(tline, "*")) - searching.nparam_max = INT_MAX; - else if (!tok_type_(tline, TOK_NUMBER)) - error(ERR_NONFATAL, - "`%s' expects a parameter count after `-'", - directives[i]); - else - { - intn = nasm_readnum(tline->text, &j); - searching.nparam_max = yasm_intnum_get_int(intn); - yasm_intnum_destroy(intn); - if (j) - error(ERR_NONFATAL, - "unable to parse parameter count `%s'", - tline->text); - if (searching.nparam_min > searching.nparam_max) - error(ERR_NONFATAL, - "minimum parameter count exceeds maximum"); - } - } - if (tline && tok_is_(tline->next, "+")) - { - tline = tline->next; - searching.plus = TRUE; - } - mmac = mmacros[hash(searching.name)]; - while (mmac) - { - if (!strcmp(mmac->name, searching.name) && - (mmac->nparam_min <= searching.nparam_max - || searching.plus) - && (searching.nparam_min <= mmac->nparam_max - || mmac->plus)) - { - found = TRUE; - break; - } - mmac = mmac->next; - } - nasm_free(searching.name); - free_tlist(origline); - if (i == PP_IFNMACRO || i == PP_ELIFNMACRO) - found = !found; - return found; - } + tline = tline->next; + skip_white_(tline); + tline = expand_id(tline); + if (!tok_type_(tline, TOK_ID)) + { + error(ERR_NONFATAL, + "`%s' expects a macro name", + directives[i]); + return -1; + } + searching.name = nasm_strdup(tline->text); + searching.casesense = (i == PP_MACRO); + searching.plus = FALSE; + searching.nolist = FALSE; + searching.in_progress = FALSE; + searching.rep_nest = NULL; + searching.nparam_min = 0; + searching.nparam_max = INT_MAX; + tline = expand_smacro(tline->next); + skip_white_(tline); + if (!tline) + { + } else if (!tok_type_(tline, TOK_NUMBER)) + { + error(ERR_NONFATAL, + "`%s' expects a parameter count or nothing", + directives[i]); + } + else + { + intn = nasm_readnum(tline->text, &j); + searching.nparam_min = searching.nparam_max = + yasm_intnum_get_int(intn); + yasm_intnum_destroy(intn); + if (j) + error(ERR_NONFATAL, + "unable to parse parameter count `%s'", + tline->text); + } + if (tline && tok_is_(tline->next, "-")) + { + tline = tline->next->next; + if (tok_is_(tline, "*")) + searching.nparam_max = INT_MAX; + else if (!tok_type_(tline, TOK_NUMBER)) + error(ERR_NONFATAL, + "`%s' expects a parameter count after `-'", + directives[i]); + else + { + intn = nasm_readnum(tline->text, &j); + searching.nparam_max = yasm_intnum_get_int(intn); + yasm_intnum_destroy(intn); + if (j) + error(ERR_NONFATAL, + "unable to parse parameter count `%s'", + tline->text); + if (searching.nparam_min > searching.nparam_max) + error(ERR_NONFATAL, + "minimum parameter count exceeds maximum"); + } + } + if (tline && tok_is_(tline->next, "+")) + { + tline = tline->next; + searching.plus = TRUE; + } + mmac = mmacros[hash(searching.name)]; + while (mmac) + { + if (!strcmp(mmac->name, searching.name) && + (mmac->nparam_min <= searching.nparam_max + || searching.plus) + && (searching.nparam_min <= mmac->nparam_max + || mmac->plus)) + { + found = TRUE; + break; + } + mmac = mmac->next; + } + nasm_free(searching.name); + free_tlist(origline); + if (i == PP_IFNMACRO || i == PP_ELIFNMACRO) + found = !found; + return found; + } - case PP_IFID: - case PP_ELIFID: - case PP_IFNID: - case PP_ELIFNID: - case PP_IFNUM: - case PP_ELIFNUM: - case PP_IFNNUM: - case PP_ELIFNNUM: - case PP_IFSTR: - case PP_ELIFSTR: - case PP_IFNSTR: - case PP_ELIFNSTR: - tline = expand_smacro(tline); - t = tline; - while (tok_type_(t, TOK_WHITESPACE)) - t = t->next; - j = FALSE; /* placate optimiser */ - if (t) - switch (i) - { - case PP_IFID: - case PP_ELIFID: - case PP_IFNID: - case PP_ELIFNID: - j = (t->type == TOK_ID); - break; - case PP_IFNUM: - case PP_ELIFNUM: - case PP_IFNNUM: - case PP_ELIFNNUM: - while (tok_is_(t, "+") || tok_is_(t, "-") || - tok_type_(t, TOK_WHITESPACE)) - t = t->next; - j = (t && t->type == TOK_NUMBER); - break; - case PP_IFSTR: - case PP_ELIFSTR: - case PP_IFNSTR: - case PP_ELIFNSTR: - j = (t->type == TOK_STRING); - break; - } - if (i == PP_IFNID || i == PP_ELIFNID || - i == PP_IFNNUM || i == PP_ELIFNNUM || - i == PP_IFNSTR || i == PP_ELIFNSTR) - j = !j; - free_tlist(tline); - return j; + case PP_IFID: + case PP_ELIFID: + case PP_IFNID: + case PP_ELIFNID: + case PP_IFNUM: + case PP_ELIFNUM: + case PP_IFNNUM: + case PP_ELIFNNUM: + case PP_IFSTR: + case PP_ELIFSTR: + case PP_IFNSTR: + case PP_ELIFNSTR: + tline = expand_smacro(tline); + t = tline; + while (tok_type_(t, TOK_WHITESPACE)) + t = t->next; + j = FALSE; /* placate optimiser */ + if (t) + switch (i) + { + case PP_IFID: + case PP_ELIFID: + case PP_IFNID: + case PP_ELIFNID: + j = (t->type == TOK_ID); + break; + case PP_IFNUM: + case PP_ELIFNUM: + case PP_IFNNUM: + case PP_ELIFNNUM: + j = (t->type == TOK_NUMBER); + break; + case PP_IFSTR: + case PP_ELIFSTR: + case PP_IFNSTR: + case PP_ELIFNSTR: + j = (t->type == TOK_STRING); + break; + } + if (i == PP_IFNID || i == PP_ELIFNID || + i == PP_IFNNUM || i == PP_ELIFNNUM || + i == PP_IFNSTR || i == PP_ELIFNSTR) + j = !j; + free_tlist(tline); + return j; - case PP_IF: - case PP_ELIF: - t = tline = expand_smacro(tline); - tptr = &t; - tokval.t_type = TOKEN_INVALID; - evalresult = evaluate(ppscan, tptr, &tokval, pass | CRITICAL, - error); - free_tlist(tline); - if (!evalresult) - return -1; - if (tokval.t_type) - error(ERR_WARNING, - "trailing garbage after expression ignored"); - intn = yasm_expr_get_intnum(&evalresult, 0); - if (!intn) - { - error(ERR_NONFATAL, - "non-constant value given to `%s'", directives[i]); - yasm_expr_destroy(evalresult); - return -1; - } - j = !yasm_intnum_is_zero(intn); - yasm_expr_destroy(evalresult); - return j; + case PP_IF: + case PP_ELIF: + t = tline = expand_smacro(tline); + tptr = &t; + tokval.t_type = TOKEN_INVALID; + evalresult = evaluate(ppscan, tptr, &tokval, pass | CRITICAL, + error); + free_tlist(tline); + if (!evalresult) + return -1; + if (tokval.t_type) + error(ERR_WARNING, + "trailing garbage after expression ignored"); + intn = yasm_expr_get_intnum(&evalresult, 0); + if (!intn) + { + error(ERR_NONFATAL, + "non-constant value given to `%s'", directives[i]); + yasm_expr_destroy(evalresult); + return -1; + } + j = !yasm_intnum_is_zero(intn); + yasm_expr_destroy(evalresult); + return j; - default: - error(ERR_FATAL, - "preprocessor directive `%s' not yet implemented", - directives[i]); - free_tlist(origline); - return -1; /* yeah, right */ + default: + error(ERR_FATAL, + "preprocessor directive `%s' not yet implemented", + directives[i]); + free_tlist(origline); + return -1; /* yeah, right */ } } @@ -2313,9 +1793,6 @@ expand_macros_in_string(char **p) Token *line = tokenise(*p); line = expand_smacro(line); *p = detoken(line, FALSE); - do - line = delete_Token(line); - while (line); } /** @@ -2345,38 +1822,38 @@ do_directive(Token * tline) Line *l; struct tokenval tokval; yasm_expr *evalresult; - MMacro *tmp_defining; /* Used when manipulating rep_nest */ + MMacro *tmp_defining; /* Used when manipulating rep_nest */ yasm_intnum *intn; origline = tline; skip_white_(tline); if (!tok_type_(tline, TOK_PREPROC_ID) || - (tline->text[1] == '%' || tline->text[1] == '$' - || tline->text[1] == '!')) - return NO_DIRECTIVE_FOUND; + (tline->text[1] == '%' || tline->text[1] == '$' + || tline->text[1] == '!')) + return NO_DIRECTIVE_FOUND; i = -1; j = elements(directives); while (j - i > 1) { - k = (j + i) / 2; - m = nasm_stricmp(tline->text, directives[k]); - if (m == 0) { - if (tasm_compatible_mode) { - i = k; - j = -2; - } else if (k != PP_ARG && k != PP_LOCAL && k != PP_STACKSIZE) { - i = k; - j = -2; - } - break; - } - else if (m < 0) { - j = k; - } - else - i = k; + k = (j + i) / 2; + m = nasm_stricmp(tline->text, directives[k]); + if (m == 0) { + if (tasm_compatible_mode) { + i = k; + j = -2; + } else if (k != PP_ARG && k != PP_LOCAL && k != PP_STACKSIZE) { + i = k; + j = -2; + } + break; + } + else if (m < 0) { + j = k; + } + else + i = k; } /* @@ -2386,10 +1863,10 @@ do_directive(Token * tline) * directives. */ if (((istk->conds && !emitting(istk->conds->state)) || - (istk->mstk && !istk->mstk->in_progress)) && - !is_condition(i)) + (istk->mstk && !istk->mstk->in_progress)) && + !is_condition(i)) { - return NO_DIRECTIVE_FOUND; + return NO_DIRECTIVE_FOUND; } /* @@ -2400,1403 +1877,1329 @@ do_directive(Token * tline) * causes an error, so should be let through. */ if (defining && i != PP_MACRO && i != PP_IMACRO && - i != PP_ENDMACRO && i != PP_ENDM && - (defining->name || (i != PP_ENDREP && i != PP_REP))) + i != PP_ENDMACRO && i != PP_ENDM && + (defining->name || (i != PP_ENDREP && i != PP_REP))) { - return NO_DIRECTIVE_FOUND; + return NO_DIRECTIVE_FOUND; } if (defining) { - if (i == PP_MACRO || i == PP_IMACRO) { - nested_mac_count++; - return NO_DIRECTIVE_FOUND; - } else if (nested_mac_count > 0) { - if (i == PP_ENDMACRO) { - nested_mac_count--; - return NO_DIRECTIVE_FOUND; - } - } - if (!defining->name) { - if (i == PP_REP) { - nested_rep_count++; - return NO_DIRECTIVE_FOUND; - } else if (nested_rep_count > 0) { - if (i == PP_ENDREP) { - nested_rep_count--; - return NO_DIRECTIVE_FOUND; - } - } - } + if (i == PP_MACRO || i == PP_IMACRO) { + nested_mac_count++; + return NO_DIRECTIVE_FOUND; + } else if (nested_mac_count > 0) { + if (i == PP_ENDMACRO) { + nested_mac_count--; + return NO_DIRECTIVE_FOUND; + } + } + if (!defining->name) { + if (i == PP_REP) { + nested_rep_count++; + return NO_DIRECTIVE_FOUND; + } else if (nested_rep_count > 0) { + if (i == PP_ENDREP) { + nested_rep_count--; + return NO_DIRECTIVE_FOUND; + } + } + } } if (j != -2) { - error(ERR_NONFATAL, "unknown preprocessor directive `%s'", - tline->text); - return NO_DIRECTIVE_FOUND; /* didn't get it */ + error(ERR_NONFATAL, "unknown preprocessor directive `%s'", + tline->text); + return NO_DIRECTIVE_FOUND; /* didn't get it */ } switch (i) { - case PP_STACKSIZE: - /* Directive to tell NASM what the default stack size is. The - * default is for a 16-bit stack, and this can be overriden with - * %stacksize large. - * the following form: - * - * ARG arg1:WORD, arg2:DWORD, arg4:QWORD - */ - tline = tline->next; - if (tline && tline->type == TOK_WHITESPACE) - tline = tline->next; - if (!tline || tline->type != TOK_ID) - { - error(ERR_NONFATAL, "`%%stacksize' missing size parameter"); - free_tlist(origline); - return DIRECTIVE_FOUND; - } - if (nasm_stricmp(tline->text, "flat") == 0) - { - /* All subsequent ARG directives are for a 32-bit stack */ - StackSize = 4; - StackPointer = "ebp"; - ArgOffset = 8; - LocalOffset = 4; - } - else if (nasm_stricmp(tline->text, "large") == 0) - { - /* All subsequent ARG directives are for a 16-bit stack, - * far function call. - */ - StackSize = 2; - StackPointer = "bp"; - ArgOffset = 4; - LocalOffset = 2; - } - else if (nasm_stricmp(tline->text, "small") == 0) - { - /* All subsequent ARG directives are for a 16-bit stack, - * far function call. We don't support near functions. - */ - StackSize = 2; - StackPointer = "bp"; - ArgOffset = 6; - LocalOffset = 2; - } - else - { - error(ERR_NONFATAL, "`%%stacksize' invalid size type"); - free_tlist(origline); - return DIRECTIVE_FOUND; - } - free_tlist(origline); - return DIRECTIVE_FOUND; + case PP_STACKSIZE: + /* Directive to tell NASM what the default stack size is. The + * default is for a 16-bit stack, and this can be overriden with + * %stacksize large. + * the following form: + * + * ARG arg1:WORD, arg2:DWORD, arg4:QWORD + */ + tline = tline->next; + if (tline && tline->type == TOK_WHITESPACE) + tline = tline->next; + if (!tline || tline->type != TOK_ID) + { + error(ERR_NONFATAL, "`%%stacksize' missing size parameter"); + free_tlist(origline); + return DIRECTIVE_FOUND; + } + if (nasm_stricmp(tline->text, "flat") == 0) + { + /* All subsequent ARG directives are for a 32-bit stack */ + StackSize = 4; + StackPointer = "ebp"; + ArgOffset = 8; + LocalOffset = 4; + } + else if (nasm_stricmp(tline->text, "large") == 0) + { + /* All subsequent ARG directives are for a 16-bit stack, + * far function call. + */ + StackSize = 2; + StackPointer = "bp"; + ArgOffset = 4; + LocalOffset = 2; + } + else if (nasm_stricmp(tline->text, "small") == 0) + { + /* All subsequent ARG directives are for a 16-bit stack, + * far function call. We don't support near functions. + */ + StackSize = 2; + StackPointer = "bp"; + ArgOffset = 6; + LocalOffset = 2; + } + else + { + error(ERR_NONFATAL, "`%%stacksize' invalid size type"); + free_tlist(origline); + return DIRECTIVE_FOUND; + } + free_tlist(origline); + return DIRECTIVE_FOUND; - case PP_ARG: - /* TASM like ARG directive to define arguments to functions, in - * the following form: - * - * ARG arg1:WORD, arg2:DWORD, arg4:QWORD - */ - offset = ArgOffset; - do - { - char *arg, directive[256]; - int size = StackSize; + case PP_ARG: + /* TASM like ARG directive to define arguments to functions, in + * the following form: + * + * ARG arg1:WORD, arg2:DWORD, arg4:QWORD + */ + offset = ArgOffset; + do + { + char *arg, directive[256]; + int size = StackSize; - /* Find the argument name */ - tline = tline->next; - if (tline && tline->type == TOK_WHITESPACE) - tline = tline->next; - if (!tline || tline->type != TOK_ID) - { - error(ERR_NONFATAL, "`%%arg' missing argument parameter"); - free_tlist(origline); - return DIRECTIVE_FOUND; - } - arg = tline->text; + /* Find the argument name */ + tline = tline->next; + if (tline && tline->type == TOK_WHITESPACE) + tline = tline->next; + if (!tline || tline->type != TOK_ID) + { + error(ERR_NONFATAL, "`%%arg' missing argument parameter"); + free_tlist(origline); + return DIRECTIVE_FOUND; + } + arg = tline->text; - /* Find the argument size type */ - tline = tline->next; - if (!tline || tline->type != TOK_OTHER - || tline->text[0] != ':') - { - error(ERR_NONFATAL, - "Syntax error processing `%%arg' directive"); - free_tlist(origline); - return DIRECTIVE_FOUND; - } - tline = tline->next; - if (!tline || tline->type != TOK_ID) - { - error(ERR_NONFATAL, - "`%%arg' missing size type parameter"); - free_tlist(origline); - return DIRECTIVE_FOUND; - } + /* Find the argument size type */ + tline = tline->next; + if (!tline || tline->type != TOK_OTHER + || tline->text[0] != ':') + { + error(ERR_NONFATAL, + "Syntax error processing `%%arg' directive"); + free_tlist(origline); + return DIRECTIVE_FOUND; + } + tline = tline->next; + if (!tline || tline->type != TOK_ID) + { + error(ERR_NONFATAL, + "`%%arg' missing size type parameter"); + free_tlist(origline); + return DIRECTIVE_FOUND; + } - /* Allow macro expansion of type parameter */ - tt = tokenise(tline->text); - tt = expand_smacro(tt); - if (nasm_stricmp(tt->text, "byte") == 0) - { - size = MAX(StackSize, 1); - } - else if (nasm_stricmp(tt->text, "word") == 0) - { - size = MAX(StackSize, 2); - } - else if (nasm_stricmp(tt->text, "dword") == 0) - { - size = MAX(StackSize, 4); - } - else if (nasm_stricmp(tt->text, "qword") == 0) - { - size = MAX(StackSize, 8); - } - else if (nasm_stricmp(tt->text, "tword") == 0) - { - size = MAX(StackSize, 10); - } - else - { - error(ERR_NONFATAL, - "Invalid size type for `%%arg' missing directive"); - free_tlist(tt); - free_tlist(origline); - return DIRECTIVE_FOUND; - } - free_tlist(tt); + /* Allow macro expansion of type parameter */ + tt = tokenise(tline->text); + tt = expand_smacro(tt); + if (nasm_stricmp(tt->text, "byte") == 0) + { + size = MAX(StackSize, 1); + } + else if (nasm_stricmp(tt->text, "word") == 0) + { + size = MAX(StackSize, 2); + } + else if (nasm_stricmp(tt->text, "dword") == 0) + { + size = MAX(StackSize, 4); + } + else if (nasm_stricmp(tt->text, "qword") == 0) + { + size = MAX(StackSize, 8); + } + else if (nasm_stricmp(tt->text, "tword") == 0) + { + size = MAX(StackSize, 10); + } + else + { + error(ERR_NONFATAL, + "Invalid size type for `%%arg' missing directive"); + free_tlist(tt); + free_tlist(origline); + return DIRECTIVE_FOUND; + } + free_tlist(tt); - /* Now define the macro for the argument */ - sprintf(directive, "%%define %s (%s+%d)", arg, StackPointer, - offset); - do_directive(tokenise(directive)); - offset += size; + /* Now define the macro for the argument */ + sprintf(directive, "%%define %s (%s+%d)", arg, StackPointer, + offset); + do_directive(tokenise(directive)); + offset += size; - /* Move to the next argument in the list */ - tline = tline->next; - if (tline && tline->type == TOK_WHITESPACE) - tline = tline->next; - } - while (tline && tline->type == TOK_OTHER - && tline->text[0] == ','); - free_tlist(origline); - return DIRECTIVE_FOUND; + /* Move to the next argument in the list */ + tline = tline->next; + if (tline && tline->type == TOK_WHITESPACE) + tline = tline->next; + } + while (tline && tline->type == TOK_OTHER + && tline->text[0] == ','); + free_tlist(origline); + return DIRECTIVE_FOUND; - case PP_LOCAL: - /* TASM like LOCAL directive to define local variables for a - * function, in the following form: - * - * LOCAL local1:WORD, local2:DWORD, local4:QWORD = LocalSize - * - * The '= LocalSize' at the end is ignored by NASM, but is - * required by TASM to define the local parameter size (and used - * by the TASM macro package). - */ - offset = LocalOffset; - do - { - char *local, directive[256]; - int size = StackSize; + case PP_LOCAL: + /* TASM like LOCAL directive to define local variables for a + * function, in the following form: + * + * LOCAL local1:WORD, local2:DWORD, local4:QWORD = LocalSize + * + * The '= LocalSize' at the end is ignored by NASM, but is + * required by TASM to define the local parameter size (and used + * by the TASM macro package). + */ + offset = LocalOffset; + do + { + char *local, directive[256]; + int size = StackSize; - /* Find the argument name */ - tline = tline->next; - if (tline && tline->type == TOK_WHITESPACE) - tline = tline->next; - if (!tline || tline->type != TOK_ID) - { - error(ERR_NONFATAL, - "`%%local' missing argument parameter"); - free_tlist(origline); - return DIRECTIVE_FOUND; - } - local = tline->text; + /* Find the argument name */ + tline = tline->next; + if (tline && tline->type == TOK_WHITESPACE) + tline = tline->next; + if (!tline || tline->type != TOK_ID) + { + error(ERR_NONFATAL, + "`%%local' missing argument parameter"); + free_tlist(origline); + return DIRECTIVE_FOUND; + } + local = tline->text; - /* Find the argument size type */ - tline = tline->next; - if (!tline || tline->type != TOK_OTHER - || tline->text[0] != ':') - { - error(ERR_NONFATAL, - "Syntax error processing `%%local' directive"); - free_tlist(origline); - return DIRECTIVE_FOUND; - } - tline = tline->next; - if (!tline || tline->type != TOK_ID) - { - error(ERR_NONFATAL, - "`%%local' missing size type parameter"); - free_tlist(origline); - return DIRECTIVE_FOUND; - } + /* Find the argument size type */ + tline = tline->next; + if (!tline || tline->type != TOK_OTHER + || tline->text[0] != ':') + { + error(ERR_NONFATAL, + "Syntax error processing `%%local' directive"); + free_tlist(origline); + return DIRECTIVE_FOUND; + } + tline = tline->next; + if (!tline || tline->type != TOK_ID) + { + error(ERR_NONFATAL, + "`%%local' missing size type parameter"); + free_tlist(origline); + return DIRECTIVE_FOUND; + } - /* Allow macro expansion of type parameter */ - tt = tokenise(tline->text); - tt = expand_smacro(tt); - if (nasm_stricmp(tt->text, "byte") == 0) - { - size = MAX(StackSize, 1); - } - else if (nasm_stricmp(tt->text, "word") == 0) - { - size = MAX(StackSize, 2); - } - else if (nasm_stricmp(tt->text, "dword") == 0) - { - size = MAX(StackSize, 4); - } - else if (nasm_stricmp(tt->text, "qword") == 0) - { - size = MAX(StackSize, 8); - } - else if (nasm_stricmp(tt->text, "tword") == 0) - { - size = MAX(StackSize, 10); - } - else - { - error(ERR_NONFATAL, - "Invalid size type for `%%local' missing directive"); - free_tlist(tt); - free_tlist(origline); - return DIRECTIVE_FOUND; - } - free_tlist(tt); + /* Allow macro expansion of type parameter */ + tt = tokenise(tline->text); + tt = expand_smacro(tt); + if (nasm_stricmp(tt->text, "byte") == 0) + { + size = MAX(StackSize, 1); + } + else if (nasm_stricmp(tt->text, "word") == 0) + { + size = MAX(StackSize, 2); + } + else if (nasm_stricmp(tt->text, "dword") == 0) + { + size = MAX(StackSize, 4); + } + else if (nasm_stricmp(tt->text, "qword") == 0) + { + size = MAX(StackSize, 8); + } + else if (nasm_stricmp(tt->text, "tword") == 0) + { + size = MAX(StackSize, 10); + } + else + { + error(ERR_NONFATAL, + "Invalid size type for `%%local' missing directive"); + free_tlist(tt); + free_tlist(origline); + return DIRECTIVE_FOUND; + } + free_tlist(tt); - /* Now define the macro for the argument */ - sprintf(directive, "%%define %s (%s-%d)", local, StackPointer, - offset); - do_directive(tokenise(directive)); - offset += size; + /* Now define the macro for the argument */ + sprintf(directive, "%%define %s (%s-%d)", local, StackPointer, + offset); + do_directive(tokenise(directive)); + offset += size; - /* Now define the assign to setup the enter_c macro correctly */ - sprintf(directive, "%%assign %%$localsize %%$localsize+%d", - size); - do_directive(tokenise(directive)); + /* Now define the assign to setup the enter_c macro correctly */ + sprintf(directive, "%%assign %%$localsize %%$localsize+%d", + size); + do_directive(tokenise(directive)); - /* Move to the next argument in the list */ - tline = tline->next; - if (tline && tline->type == TOK_WHITESPACE) - tline = tline->next; - } - while (tline && tline->type == TOK_OTHER - && tline->text[0] == ','); - free_tlist(origline); - return DIRECTIVE_FOUND; + /* Move to the next argument in the list */ + tline = tline->next; + if (tline && tline->type == TOK_WHITESPACE) + tline = tline->next; + } + while (tline && tline->type == TOK_OTHER + && tline->text[0] == ','); + free_tlist(origline); + return DIRECTIVE_FOUND; - case PP_CLEAR: - if (tline->next) - error(ERR_WARNING, - "trailing garbage after `%%clear' ignored"); - for (j = 0; j < NHASH; j++) - { - while (mmacros[j]) - { - MMacro *m2 = mmacros[j]; - mmacros[j] = m2->next; - free_mmacro(m2); - } - while (smacros[j]) - { - SMacro *s = smacros[j]; - smacros[j] = smacros[j]->next; - nasm_free(s->name); - free_tlist(s->expansion); - nasm_free(s); - } - } - free_tlist(origline); - return DIRECTIVE_FOUND; + case PP_CLEAR: + if (tline->next) + error(ERR_WARNING, + "trailing garbage after `%%clear' ignored"); + for (j = 0; j < NHASH; j++) + { + while (mmacros[j]) + { + MMacro *m2 = mmacros[j]; + mmacros[j] = m2->next; + free_mmacro(m2); + } + while (smacros[j]) + { + SMacro *s = smacros[j]; + smacros[j] = smacros[j]->next; + nasm_free(s->name); + free_tlist(s->expansion); + nasm_free(s); + } + } + free_tlist(origline); + return DIRECTIVE_FOUND; - case PP_INCLUDE: - tline = tline->next; - skip_white_(tline); - if (!tline || (tline->type != TOK_STRING && - tline->type != TOK_INTERNAL_STRING)) - { - error(ERR_NONFATAL, "`%%include' expects a file name"); - free_tlist(origline); - return DIRECTIVE_FOUND; /* but we did _something_ */ - } - if (tline->next) - error(ERR_WARNING, - "trailing garbage after `%%include' ignored"); - if (tline->type != TOK_INTERNAL_STRING) - { - p = tline->text + 1; /* point past the quote to the name */ - p[strlen(p) - 1] = '\0'; /* remove the trailing quote */ - } - else - p = tline->text; /* internal_string is easier */ - expand_macros_in_string(&p); - inc = nasm_malloc(sizeof(Include)); - inc->next = istk; - inc->conds = NULL; - inc->fp = inc_fopen(p, &newname); - nasm_free(p); - inc->fname = nasm_src_set_fname(newname); - inc->lineno = nasm_src_set_linnum(0); - inc->lineinc = 1; - inc->expansion = NULL; - inc->mstk = NULL; - istk = inc; - list->uplevel(LIST_INCLUDE); - free_tlist(origline); - return DIRECTIVE_FOUND; + case PP_INCLUDE: + tline = tline->next; + skip_white_(tline); + if (!tline || (tline->type != TOK_STRING && + tline->type != TOK_INTERNAL_STRING)) + { + error(ERR_NONFATAL, "`%%include' expects a file name"); + free_tlist(origline); + return DIRECTIVE_FOUND; /* but we did _something_ */ + } + if (tline->next) + error(ERR_WARNING, + "trailing garbage after `%%include' ignored"); + if (tline->type != TOK_INTERNAL_STRING) + { + p = tline->text + 1; /* point past the quote to the name */ + p[strlen(p) - 1] = '\0'; /* remove the trailing quote */ + } + else + p = tline->text; /* internal_string is easier */ + expand_macros_in_string(&p); + inc = nasm_malloc(sizeof(Include)); + inc->next = istk; + inc->conds = NULL; + inc->fp = inc_fopen(p, &newname); + inc->fname = nasm_src_set_fname(newname); + inc->lineno = nasm_src_set_linnum(0); + inc->lineinc = 1; + inc->expansion = NULL; + inc->mstk = NULL; + istk = inc; + list->uplevel(LIST_INCLUDE); + free_tlist(origline); + return DIRECTIVE_FOUND; - case PP_PUSH: - tline = tline->next; - skip_white_(tline); - tline = expand_id(tline); - if (!tok_type_(tline, TOK_ID)) - { - error(ERR_NONFATAL, "`%%push' expects a context identifier"); - free_tlist(origline); - return DIRECTIVE_FOUND; /* but we did _something_ */ - } - if (tline->next) - error(ERR_WARNING, "trailing garbage after `%%push' ignored"); - ctx = nasm_malloc(sizeof(Context)); - ctx->next = cstk; - ctx->localmac = NULL; - ctx->name = nasm_strdup(tline->text); - ctx->number = unique++; - cstk = ctx; - free_tlist(origline); - break; + case PP_PUSH: + tline = tline->next; + skip_white_(tline); + tline = expand_id(tline); + if (!tok_type_(tline, TOK_ID)) + { + error(ERR_NONFATAL, "`%%push' expects a context identifier"); + free_tlist(origline); + return DIRECTIVE_FOUND; /* but we did _something_ */ + } + if (tline->next) + error(ERR_WARNING, "trailing garbage after `%%push' ignored"); + ctx = nasm_malloc(sizeof(Context)); + ctx->next = cstk; + ctx->localmac = NULL; + ctx->name = nasm_strdup(tline->text); + ctx->number = unique++; + cstk = ctx; + free_tlist(origline); + break; - case PP_REPL: - tline = tline->next; - skip_white_(tline); - tline = expand_id(tline); - if (!tok_type_(tline, TOK_ID)) - { - error(ERR_NONFATAL, "`%%repl' expects a context identifier"); - free_tlist(origline); - return DIRECTIVE_FOUND; /* but we did _something_ */ - } - if (tline->next) - error(ERR_WARNING, "trailing garbage after `%%repl' ignored"); - if (!cstk) - error(ERR_NONFATAL, "`%%repl': context stack is empty"); - else - { - nasm_free(cstk->name); - cstk->name = nasm_strdup(tline->text); - } - free_tlist(origline); - break; + case PP_REPL: + tline = tline->next; + skip_white_(tline); + tline = expand_id(tline); + if (!tok_type_(tline, TOK_ID)) + { + error(ERR_NONFATAL, "`%%repl' expects a context identifier"); + free_tlist(origline); + return DIRECTIVE_FOUND; /* but we did _something_ */ + } + if (tline->next) + error(ERR_WARNING, "trailing garbage after `%%repl' ignored"); + if (!cstk) + error(ERR_NONFATAL, "`%%repl': context stack is empty"); + else + { + nasm_free(cstk->name); + cstk->name = nasm_strdup(tline->text); + } + free_tlist(origline); + break; - case PP_POP: - if (tline->next) - error(ERR_WARNING, "trailing garbage after `%%pop' ignored"); - if (!cstk) - error(ERR_NONFATAL, - "`%%pop': context stack is already empty"); - else - ctx_pop(); - free_tlist(origline); - break; + case PP_POP: + if (tline->next) + error(ERR_WARNING, "trailing garbage after `%%pop' ignored"); + if (!cstk) + error(ERR_NONFATAL, + "`%%pop': context stack is already empty"); + else + ctx_pop(); + free_tlist(origline); + break; - case PP_SCOPE: - if (tline->next) - error(ERR_WARNING, "trailing garbage after `%%scope' ignored"); - Level++; - free_tlist(origline); - break; + case PP_ERROR: + tline->next = expand_smacro(tline->next); + tline = tline->next; + skip_white_(tline); + if (tok_type_(tline, TOK_STRING)) + { + p = tline->text + 1; /* point past the quote to the name */ + p[strlen(p) - 1] = '\0'; /* remove the trailing quote */ + expand_macros_in_string(&p); + error(ERR_NONFATAL, "%s", p); + nasm_free(p); + } + else + { + p = detoken(tline, FALSE); + error(ERR_WARNING, "%s", p); + nasm_free(p); + } + free_tlist(origline); + break; - case PP_ENDSCOPE: - if (tline->next) - error(ERR_WARNING, "trailing garbage after `%%endscope' ignored"); - if (!Level) - error(ERR_NONFATAL, - "`%%endscope': already popped all levels"); - else - { - for (k = 0; k < NHASH; k++) - { - SMacro **smlast = &smacros[k]; - smac = smacros[k]; - while (smac) - { - if (smac->level < Level) - { - smlast = &smac->next; - smac = smac->next; - } - else - { - *smlast = smac->next; - nasm_free(smac->name); - free_tlist(smac->expansion); - nasm_free(smac); - smac = *smlast; - } - } - } - for (ctx = cstk; ctx; ctx = ctx->next) - { - SMacro **smlast = &ctx->localmac; - smac = ctx->localmac; - while (smac) - { - if (smac->level < Level) - { - smlast = &smac->next; - smac = smac->next; - } - else - { - *smlast = smac->next; - nasm_free(smac->name); - free_tlist(smac->expansion); - nasm_free(smac); - smac = *smlast; - } - } - } - Level--; - } - free_tlist(origline); - break; - - case PP_ERROR: - case PP_WARNING: - tline->next = expand_smacro(tline->next); - tline = tline->next; - skip_white_(tline); - if (tok_type_(tline, TOK_STRING)) - { - p = tline->text + 1; /* point past the quote to the name */ - p[strlen(p) - 1] = '\0'; /* remove the trailing quote */ - expand_macros_in_string(&p); - error((i == PP_ERROR) ? ERR_NONFATAL : ERR_WARNING, "%s", p); - nasm_free(p); - } - else - { - p = detoken(tline, FALSE); - error(ERR_WARNING, "%s", p); - nasm_free(p); - } - free_tlist(origline); - break; - - case PP_IF: - case PP_IFCTX: - case PP_IFDEF: - case PP_IFID: - case PP_IFIDN: - case PP_IFIDNI: + case PP_IF: + case PP_IFCTX: + case PP_IFDEF: + case PP_IFID: + case PP_IFIDN: + case PP_IFIDNI: case PP_IFMACRO: - case PP_IFNCTX: - case PP_IFNDEF: - case PP_IFNID: - case PP_IFNIDN: - case PP_IFNIDNI: + case PP_IFNCTX: + case PP_IFNDEF: + case PP_IFNID: + case PP_IFNIDN: + case PP_IFNIDNI: case PP_IFNMACRO: - case PP_IFNNUM: - case PP_IFNSTR: - case PP_IFNUM: - case PP_IFSTR: - if (istk->conds && !emitting(istk->conds->state)) - j = COND_NEVER; - else - { - j = if_condition(tline->next, i); - tline->next = NULL; /* it got freed */ - j = j < 0 ? COND_NEVER : j ? COND_IF_TRUE : COND_IF_FALSE; - } - free_tlist(origline); - cond = nasm_malloc(sizeof(Cond)); - cond->next = istk->conds; - cond->state = j; - istk->conds = cond; - return DIRECTIVE_FOUND; + case PP_IFNNUM: + case PP_IFNSTR: + case PP_IFNUM: + case PP_IFSTR: + if (istk->conds && !emitting(istk->conds->state)) + j = COND_NEVER; + else + { + j = if_condition(tline->next, i); + tline->next = NULL; /* it got freed */ + j = j < 0 ? COND_NEVER : j ? COND_IF_TRUE : COND_IF_FALSE; + } + free_tlist(origline); + cond = nasm_malloc(sizeof(Cond)); + cond->next = istk->conds; + cond->state = j; + istk->conds = cond; + return DIRECTIVE_FOUND; - case PP_ELIF: - case PP_ELIFCTX: - case PP_ELIFDEF: - case PP_ELIFID: - case PP_ELIFIDN: - case PP_ELIFIDNI: + case PP_ELIF: + case PP_ELIFCTX: + case PP_ELIFDEF: + case PP_ELIFID: + case PP_ELIFIDN: + case PP_ELIFIDNI: case PP_ELIFMACRO: - case PP_ELIFNCTX: - case PP_ELIFNDEF: - case PP_ELIFNID: - case PP_ELIFNIDN: - case PP_ELIFNIDNI: + case PP_ELIFNCTX: + case PP_ELIFNDEF: + case PP_ELIFNID: + case PP_ELIFNIDN: + case PP_ELIFNIDNI: case PP_ELIFNMACRO: - case PP_ELIFNNUM: - case PP_ELIFNSTR: - case PP_ELIFNUM: - case PP_ELIFSTR: - if (!istk->conds) - error(ERR_FATAL, "`%s': no matching `%%if'", directives[i]); - if (emitting(istk->conds->state) - || istk->conds->state == COND_NEVER) - istk->conds->state = COND_NEVER; - else - { - /* - * IMPORTANT: In the case of %if, we will already have - * called expand_mmac_params(); however, if we're - * processing an %elif we must have been in a - * non-emitting mode, which would have inhibited - * the normal invocation of expand_mmac_params(). Therefore, - * we have to do it explicitly here. - */ - j = if_condition(expand_mmac_params(tline->next), i); - tline->next = NULL; /* it got freed */ - istk->conds->state = - j < 0 ? COND_NEVER : j ? COND_IF_TRUE : COND_IF_FALSE; - } - free_tlist(origline); - return DIRECTIVE_FOUND; + case PP_ELIFNNUM: + case PP_ELIFNSTR: + case PP_ELIFNUM: + case PP_ELIFSTR: + if (!istk->conds) + error(ERR_FATAL, "`%s': no matching `%%if'", directives[i]); + if (emitting(istk->conds->state) + || istk->conds->state == COND_NEVER) + istk->conds->state = COND_NEVER; + else + { + /* + * IMPORTANT: In the case of %if, we will already have + * called expand_mmac_params(); however, if we're + * processing an %elif we must have been in a + * non-emitting mode, which would have inhibited + * the normal invocation of expand_mmac_params(). Therefore, + * we have to do it explicitly here. + */ + j = if_condition(expand_mmac_params(tline->next), i); + tline->next = NULL; /* it got freed */ + istk->conds->state = + j < 0 ? COND_NEVER : j ? COND_IF_TRUE : COND_IF_FALSE; + } + free_tlist(origline); + return DIRECTIVE_FOUND; - case PP_ELSE: - if (tline->next) - error(ERR_WARNING, "trailing garbage after `%%else' ignored"); - if (!istk->conds) - error(ERR_FATAL, "`%%else': no matching `%%if'"); - if (emitting(istk->conds->state) - || istk->conds->state == COND_NEVER) - istk->conds->state = COND_ELSE_FALSE; - else - istk->conds->state = COND_ELSE_TRUE; - free_tlist(origline); - return DIRECTIVE_FOUND; + case PP_ELSE: + if (tline->next) + error(ERR_WARNING, "trailing garbage after `%%else' ignored"); + if (!istk->conds) + error(ERR_FATAL, "`%%else': no matching `%%if'"); + if (emitting(istk->conds->state) + || istk->conds->state == COND_NEVER) + istk->conds->state = COND_ELSE_FALSE; + else + istk->conds->state = COND_ELSE_TRUE; + free_tlist(origline); + return DIRECTIVE_FOUND; - case PP_ENDIF: - if (tline->next) - error(ERR_WARNING, - "trailing garbage after `%%endif' ignored"); - if (!istk->conds) - error(ERR_FATAL, "`%%endif': no matching `%%if'"); - cond = istk->conds; - istk->conds = cond->next; - nasm_free(cond); - free_tlist(origline); - return DIRECTIVE_FOUND; + case PP_ENDIF: + if (tline->next) + error(ERR_WARNING, + "trailing garbage after `%%endif' ignored"); + if (!istk->conds) + error(ERR_FATAL, "`%%endif': no matching `%%if'"); + cond = istk->conds; + istk->conds = cond->next; + nasm_free(cond); + free_tlist(origline); + return DIRECTIVE_FOUND; - case PP_MACRO: - case PP_IMACRO: - if (defining) - error(ERR_FATAL, - "`%%%smacro': already defining a macro", - (i == PP_IMACRO ? "i" : "")); - tline = tline->next; - skip_white_(tline); - tline = expand_id(tline); - if (!tok_type_(tline, TOK_ID)) - { - error(ERR_NONFATAL, - "`%%%smacro' expects a macro name", - (i == PP_IMACRO ? "i" : "")); - return DIRECTIVE_FOUND; - } - defining = nasm_malloc(sizeof(MMacro)); - defining->name = nasm_strdup(tline->text); - defining->casesense = (i == PP_MACRO); - defining->plus = FALSE; - defining->nolist = FALSE; - defining->in_progress = FALSE; - defining->rep_nest = NULL; - tline = expand_smacro(tline->next); - skip_white_(tline); - if (!tok_type_(tline, TOK_NUMBER)) - { - error(ERR_NONFATAL, - "`%%%smacro' expects a parameter count", - (i == PP_IMACRO ? "i" : "")); - defining->nparam_min = defining->nparam_max = 0; - } - else - { - intn = nasm_readnum(tline->text, &j); - defining->nparam_min = defining->nparam_max = - yasm_intnum_get_int(intn); - yasm_intnum_destroy(intn); - if (j) - error(ERR_NONFATAL, - "unable to parse parameter count `%s'", - tline->text); - } - if (tline && tok_is_(tline->next, "-")) - { - tline = tline->next->next; - if (tok_is_(tline, "*")) - defining->nparam_max = INT_MAX; - else if (!tok_type_(tline, TOK_NUMBER)) - error(ERR_NONFATAL, - "`%%%smacro' expects a parameter count after `-'", - (i == PP_IMACRO ? "i" : "")); - else - { - intn = nasm_readnum(tline->text, &j); - defining->nparam_max = yasm_intnum_get_int(intn); - yasm_intnum_destroy(intn); - if (j) - error(ERR_NONFATAL, - "unable to parse parameter count `%s'", - tline->text); - if (defining->nparam_min > defining->nparam_max) - error(ERR_NONFATAL, - "minimum parameter count exceeds maximum"); - } - } - if (tline && tok_is_(tline->next, "+")) - { - tline = tline->next; - defining->plus = TRUE; - } - if (tline && tok_type_(tline->next, TOK_ID) && - !nasm_stricmp(tline->next->text, ".nolist")) - { - tline = tline->next; - defining->nolist = TRUE; - } - mmac = mmacros[hash(defining->name)]; - while (mmac) - { - if (!strcmp(mmac->name, defining->name) && - (mmac->nparam_min <= defining->nparam_max - || defining->plus) - && (defining->nparam_min <= mmac->nparam_max - || mmac->plus)) - { - error(ERR_WARNING, - "redefining multi-line macro `%s'", - defining->name); - break; - } - mmac = mmac->next; - } - /* - * Handle default parameters. - */ - if (tline && tline->next) - { - defining->dlist = tline->next; - tline->next = NULL; - count_mmac_params(defining->dlist, &defining->ndefs, - &defining->defaults); - } - else - { - defining->dlist = NULL; - defining->defaults = NULL; - } - defining->expansion = NULL; - free_tlist(origline); - return DIRECTIVE_FOUND; + case PP_MACRO: + case PP_IMACRO: + if (defining) + error(ERR_FATAL, + "`%%%smacro': already defining a macro", + (i == PP_IMACRO ? "i" : "")); + tline = tline->next; + skip_white_(tline); + tline = expand_id(tline); + if (!tok_type_(tline, TOK_ID)) + { + error(ERR_NONFATAL, + "`%%%smacro' expects a macro name", + (i == PP_IMACRO ? "i" : "")); + return DIRECTIVE_FOUND; + } + defining = nasm_malloc(sizeof(MMacro)); + defining->name = nasm_strdup(tline->text); + defining->casesense = (i == PP_MACRO); + defining->plus = FALSE; + defining->nolist = FALSE; + defining->in_progress = FALSE; + defining->rep_nest = NULL; + tline = expand_smacro(tline->next); + skip_white_(tline); + if (!tok_type_(tline, TOK_NUMBER)) + { + error(ERR_NONFATAL, + "`%%%smacro' expects a parameter count", + (i == PP_IMACRO ? "i" : "")); + defining->nparam_min = defining->nparam_max = 0; + } + else + { + intn = nasm_readnum(tline->text, &j); + defining->nparam_min = defining->nparam_max = + yasm_intnum_get_int(intn); + yasm_intnum_destroy(intn); + if (j) + error(ERR_NONFATAL, + "unable to parse parameter count `%s'", + tline->text); + } + if (tline && tok_is_(tline->next, "-")) + { + tline = tline->next->next; + if (tok_is_(tline, "*")) + defining->nparam_max = INT_MAX; + else if (!tok_type_(tline, TOK_NUMBER)) + error(ERR_NONFATAL, + "`%%%smacro' expects a parameter count after `-'", + (i == PP_IMACRO ? "i" : "")); + else + { + intn = nasm_readnum(tline->text, &j); + defining->nparam_max = yasm_intnum_get_int(intn); + yasm_intnum_destroy(intn); + if (j) + error(ERR_NONFATAL, + "unable to parse parameter count `%s'", + tline->text); + if (defining->nparam_min > defining->nparam_max) + error(ERR_NONFATAL, + "minimum parameter count exceeds maximum"); + } + } + if (tline && tok_is_(tline->next, "+")) + { + tline = tline->next; + defining->plus = TRUE; + } + if (tline && tok_type_(tline->next, TOK_ID) && + !nasm_stricmp(tline->next->text, ".nolist")) + { + tline = tline->next; + defining->nolist = TRUE; + } + mmac = mmacros[hash(defining->name)]; + while (mmac) + { + if (!strcmp(mmac->name, defining->name) && + (mmac->nparam_min <= defining->nparam_max + || defining->plus) + && (defining->nparam_min <= mmac->nparam_max + || mmac->plus)) + { + error(ERR_WARNING, + "redefining multi-line macro `%s'", + defining->name); + break; + } + mmac = mmac->next; + } + /* + * Handle default parameters. + */ + if (tline && tline->next) + { + defining->dlist = tline->next; + tline->next = NULL; + count_mmac_params(defining->dlist, &defining->ndefs, + &defining->defaults); + } + else + { + defining->dlist = NULL; + defining->defaults = NULL; + } + defining->expansion = NULL; + free_tlist(origline); + return DIRECTIVE_FOUND; - case PP_ENDM: - case PP_ENDMACRO: - if (!defining) - { - error(ERR_NONFATAL, "`%s': not defining a macro", - tline->text); - return DIRECTIVE_FOUND; - } - k = hash(defining->name); - defining->next = mmacros[k]; - mmacros[k] = defining; - defining = NULL; - free_tlist(origline); - return DIRECTIVE_FOUND; + case PP_ENDM: + case PP_ENDMACRO: + if (!defining) + { + error(ERR_NONFATAL, "`%s': not defining a macro", + tline->text); + return DIRECTIVE_FOUND; + } + k = hash(defining->name); + defining->next = mmacros[k]; + mmacros[k] = defining; + defining = NULL; + free_tlist(origline); + return DIRECTIVE_FOUND; - case PP_ROTATE: - if (tline->next && tline->next->type == TOK_WHITESPACE) - tline = tline->next; - if (tline->next == NULL) - { - free_tlist(origline); - error(ERR_NONFATAL, "`%%rotate' missing rotate count"); - return DIRECTIVE_FOUND; - } - t = expand_smacro(tline->next); - tline->next = NULL; - free_tlist(origline); - tline = t; - tptr = &t; - tokval.t_type = TOKEN_INVALID; - evalresult = evaluate(ppscan, tptr, &tokval, pass, error); - free_tlist(tline); - if (!evalresult) - return DIRECTIVE_FOUND; - if (tokval.t_type) - error(ERR_WARNING, - "trailing garbage after expression ignored"); - intn = yasm_expr_get_intnum(&evalresult, 0); - if (!intn) - { - error(ERR_NONFATAL, "non-constant value given to `%%rotate'"); - yasm_expr_destroy(evalresult); - return DIRECTIVE_FOUND; - } - mmac = istk->mstk; - while (mmac && !mmac->name) /* avoid mistaking %reps for macros */ - mmac = mmac->next_active; - if (!mmac) - { - error(ERR_NONFATAL, - "`%%rotate' invoked outside a macro call"); - } - else if (mmac->nparam == 0) - { - error(ERR_NONFATAL, - "`%%rotate' invoked within macro without parameters"); - } - else - { - mmac->rotate = mmac->rotate + yasm_intnum_get_int(intn); - - if (mmac->rotate < 0) - mmac->rotate = - mmac->nparam - (-mmac->rotate) % mmac->nparam; - mmac->rotate %= mmac->nparam; - } - yasm_expr_destroy(evalresult); - return DIRECTIVE_FOUND; + case PP_ROTATE: + if (tline->next && tline->next->type == TOK_WHITESPACE) + tline = tline->next; + if (tline->next == NULL) + { + free_tlist(origline); + error(ERR_NONFATAL, "`%%rotate' missing rotate count"); + return DIRECTIVE_FOUND; + } + t = expand_smacro(tline->next); + tline->next = NULL; + free_tlist(origline); + tline = t; + tptr = &t; + tokval.t_type = TOKEN_INVALID; + evalresult = evaluate(ppscan, tptr, &tokval, pass, error); + free_tlist(tline); + if (!evalresult) + return DIRECTIVE_FOUND; + if (tokval.t_type) + error(ERR_WARNING, + "trailing garbage after expression ignored"); + intn = yasm_expr_get_intnum(&evalresult, 0); + if (!intn) + { + error(ERR_NONFATAL, "non-constant value given to `%%rotate'"); + yasm_expr_destroy(evalresult); + return DIRECTIVE_FOUND; + } + mmac = istk->mstk; + while (mmac && !mmac->name) /* avoid mistaking %reps for macros */ + mmac = mmac->next_active; + if (!mmac) + { + error(ERR_NONFATAL, + "`%%rotate' invoked outside a macro call"); + } + else if (mmac->nparam == 0) + { + error(ERR_NONFATAL, + "`%%rotate' invoked within macro without parameters"); + } + else + { + mmac->rotate = mmac->rotate + yasm_intnum_get_int(intn); + + if (mmac->rotate < 0) + mmac->rotate = + mmac->nparam - (-mmac->rotate) % mmac->nparam; + mmac->rotate %= mmac->nparam; + } + yasm_expr_destroy(evalresult); + return DIRECTIVE_FOUND; - case PP_REP: - nolist = FALSE; - do { - tline = tline->next; - } while (tok_type_(tline, TOK_WHITESPACE)); + case PP_REP: + nolist = FALSE; + do { + tline = tline->next; + } while (tok_type_(tline, TOK_WHITESPACE)); - if (tok_type_(tline, TOK_ID) && - nasm_stricmp(tline->text, ".nolist") == 0) - { - nolist = TRUE; - do { - tline = tline->next; - } while (tok_type_(tline, TOK_WHITESPACE)); - } + if (tok_type_(tline, TOK_ID) && + nasm_stricmp(tline->text, ".nolist") == 0) + { + nolist = TRUE; + do { + tline = tline->next; + } while (tok_type_(tline, TOK_WHITESPACE)); + } - if (tline) - { - t = expand_smacro(tline); - tptr = &t; - tokval.t_type = TOKEN_INVALID; - evalresult = evaluate(ppscan, tptr, &tokval, pass, error); - if (!evalresult) - { - free_tlist(origline); - return DIRECTIVE_FOUND; - } - if (tokval.t_type) - error(ERR_WARNING, - "trailing garbage after expression ignored"); - intn = yasm_expr_get_intnum(&evalresult, 0); - if (!intn) - { - error(ERR_NONFATAL, "non-constant value given to `%%rep'"); - yasm_expr_destroy(evalresult); - return DIRECTIVE_FOUND; - } - i = (int)yasm_intnum_get_int(intn) + 1; - yasm_expr_destroy(evalresult); - } - else - { - error(ERR_NONFATAL, "`%%rep' expects a repeat count"); - i = 0; - } - free_tlist(origline); + if (tline) + { + t = expand_smacro(tline); + tptr = &t; + tokval.t_type = TOKEN_INVALID; + evalresult = evaluate(ppscan, tptr, &tokval, pass, error); + if (!evalresult) + { + free_tlist(origline); + return DIRECTIVE_FOUND; + } + if (tokval.t_type) + error(ERR_WARNING, + "trailing garbage after expression ignored"); + intn = yasm_expr_get_intnum(&evalresult, 0); + if (!intn) + { + error(ERR_NONFATAL, "non-constant value given to `%%rep'"); + yasm_expr_destroy(evalresult); + return DIRECTIVE_FOUND; + } + i = (int)yasm_intnum_get_int(intn) + 1; + yasm_expr_destroy(evalresult); + } + else + { + error(ERR_NONFATAL, "`%%rep' expects a repeat count"); + i = 0; + } + free_tlist(origline); - tmp_defining = defining; - defining = nasm_malloc(sizeof(MMacro)); - defining->name = NULL; /* flags this macro as a %rep block */ - defining->casesense = 0; - defining->plus = FALSE; - defining->nolist = nolist; - defining->in_progress = i; - defining->nparam_min = defining->nparam_max = 0; - defining->defaults = NULL; - defining->dlist = NULL; - defining->expansion = NULL; - defining->next_active = istk->mstk; - defining->rep_nest = tmp_defining; - return DIRECTIVE_FOUND; + tmp_defining = defining; + defining = nasm_malloc(sizeof(MMacro)); + defining->name = NULL; /* flags this macro as a %rep block */ + defining->casesense = 0; + defining->plus = FALSE; + defining->nolist = nolist; + defining->in_progress = i; + defining->nparam_min = defining->nparam_max = 0; + defining->defaults = NULL; + defining->dlist = NULL; + defining->expansion = NULL; + defining->next_active = istk->mstk; + defining->rep_nest = tmp_defining; + return DIRECTIVE_FOUND; - case PP_ENDREP: - if (!defining || defining->name) - { - error(ERR_NONFATAL, "`%%endrep': no matching `%%rep'"); - return DIRECTIVE_FOUND; - } + case PP_ENDREP: + if (!defining || defining->name) + { + error(ERR_NONFATAL, "`%%endrep': no matching `%%rep'"); + return DIRECTIVE_FOUND; + } - /* - * Now we have a "macro" defined - although it has no name - * and we won't be entering it in the hash tables - we must - * push a macro-end marker for it on to istk->expansion. - * After that, it will take care of propagating itself (a - * macro-end marker line for a macro which is really a %rep - * block will cause the macro to be re-expanded, complete - * with another macro-end marker to ensure the process - * continues) until the whole expansion is forcibly removed - * from istk->expansion by a %exitrep. - */ - l = nasm_malloc(sizeof(Line)); - l->next = istk->expansion; - l->finishes = defining; - l->first = NULL; - istk->expansion = l; + /* + * Now we have a "macro" defined - although it has no name + * and we won't be entering it in the hash tables - we must + * push a macro-end marker for it on to istk->expansion. + * After that, it will take care of propagating itself (a + * macro-end marker line for a macro which is really a %rep + * block will cause the macro to be re-expanded, complete + * with another macro-end marker to ensure the process + * continues) until the whole expansion is forcibly removed + * from istk->expansion by a %exitrep. + */ + l = nasm_malloc(sizeof(Line)); + l->next = istk->expansion; + l->finishes = defining; + l->first = NULL; + istk->expansion = l; - istk->mstk = defining; + istk->mstk = defining; - list->uplevel(defining->nolist ? LIST_MACRO_NOLIST : LIST_MACRO); - tmp_defining = defining; - defining = defining->rep_nest; - free_tlist(origline); - return DIRECTIVE_FOUND; + list->uplevel(defining->nolist ? LIST_MACRO_NOLIST : LIST_MACRO); + tmp_defining = defining; + defining = defining->rep_nest; + free_tlist(origline); + return DIRECTIVE_FOUND; - case PP_EXITREP: - /* - * We must search along istk->expansion until we hit a - * macro-end marker for a macro with no name. Then we set - * its `in_progress' flag to 0. - */ - for (l = istk->expansion; l; l = l->next) - if (l->finishes && !l->finishes->name) - break; + case PP_EXITREP: + /* + * We must search along istk->expansion until we hit a + * macro-end marker for a macro with no name. Then we set + * its `in_progress' flag to 0. + */ + for (l = istk->expansion; l; l = l->next) + if (l->finishes && !l->finishes->name) + break; - if (l) - l->finishes->in_progress = 0; - else - error(ERR_NONFATAL, "`%%exitrep' not within `%%rep' block"); - free_tlist(origline); - return DIRECTIVE_FOUND; + if (l) + l->finishes->in_progress = 0; + else + error(ERR_NONFATAL, "`%%exitrep' not within `%%rep' block"); + free_tlist(origline); + return DIRECTIVE_FOUND; - case PP_XDEFINE: - case PP_IXDEFINE: - case PP_DEFINE: - case PP_IDEFINE: - tline = tline->next; - skip_white_(tline); - tline = expand_id(tline); - if (!tline || (tline->type != TOK_ID && - (tline->type != TOK_PREPROC_ID || - tline->text[1] != '$'))) - { - error(ERR_NONFATAL, - "`%%%s%sdefine' expects a macro identifier", - ((i == PP_IDEFINE || i == PP_IXDEFINE) ? "i" : ""), - ((i == PP_XDEFINE || i == PP_IXDEFINE) ? "x" : "")); - free_tlist(origline); - return DIRECTIVE_FOUND; - } + case PP_XDEFINE: + case PP_IXDEFINE: + case PP_DEFINE: + case PP_IDEFINE: + tline = tline->next; + skip_white_(tline); + tline = expand_id(tline); + if (!tline || (tline->type != TOK_ID && + (tline->type != TOK_PREPROC_ID || + tline->text[1] != '$'))) + { + error(ERR_NONFATAL, + "`%%%s%sdefine' expects a macro identifier", + ((i == PP_IDEFINE || i == PP_IXDEFINE) ? "i" : ""), + ((i == PP_XDEFINE || i == PP_IXDEFINE) ? "x" : "")); + free_tlist(origline); + return DIRECTIVE_FOUND; + } - ctx = get_ctx(tline->text, FALSE); - if (!ctx) - smhead = &smacros[hash(tline->text)]; - else - smhead = &ctx->localmac; - mname = tline->text; - last = tline; - param_start = tline = tline->next; - nparam = 0; + ctx = get_ctx(tline->text, FALSE); + if (!ctx) + smhead = &smacros[hash(tline->text)]; + else + smhead = &ctx->localmac; + mname = tline->text; + last = tline; + param_start = tline = tline->next; + nparam = 0; - /* Expand the macro definition now for %xdefine and %ixdefine */ - if ((i == PP_XDEFINE) || (i == PP_IXDEFINE)) - tline = expand_smacro(tline); + /* Expand the macro definition now for %xdefine and %ixdefine */ + if ((i == PP_XDEFINE) || (i == PP_IXDEFINE)) + tline = expand_smacro(tline); - if (tok_is_(tline, "(")) - { - /* - * This macro has parameters. - */ + if (tok_is_(tline, "(")) + { + /* + * This macro has parameters. + */ - tline = tline->next; - while (1) - { - skip_white_(tline); - if (!tline) - { - error(ERR_NONFATAL, "parameter identifier expected"); - free_tlist(origline); - return DIRECTIVE_FOUND; - } - if (tline->type != TOK_ID) - { - error(ERR_NONFATAL, - "`%s': parameter identifier expected", - tline->text); - free_tlist(origline); - return DIRECTIVE_FOUND; - } - tline->type = TOK_SMAC_PARAM + nparam++; - tline = tline->next; - skip_white_(tline); - if (tok_is_(tline, ",")) - { - tline = tline->next; - continue; - } - if (!tok_is_(tline, ")")) - { - error(ERR_NONFATAL, - "`)' expected to terminate macro template"); - free_tlist(origline); - return DIRECTIVE_FOUND; - } - break; - } - last = tline; - tline = tline->next; - } - if (tok_type_(tline, TOK_WHITESPACE)) - last = tline, tline = tline->next; - macro_start = NULL; - last->next = NULL; - t = tline; - while (t) - { - if (t->type == TOK_ID) - { - for (tt = param_start; tt; tt = tt->next) - if (tt->type >= TOK_SMAC_PARAM && - !strcmp(tt->text, t->text)) - t->type = tt->type; - } - tt = t->next; - t->next = macro_start; - macro_start = t; - t = tt; - } - /* - * Good. We now have a macro name, a parameter count, and a - * token list (in reverse order) for an expansion. We ought - * to be OK just to create an SMacro, store it, and let - * free_tlist have the rest of the line (which we have - * carefully re-terminated after chopping off the expansion - * from the end). - */ - if (smacro_defined(ctx, mname, nparam, &smac, i == PP_DEFINE)) - { - if (!smac) - { - error(ERR_WARNING, - "single-line macro `%s' defined both with and" - " without parameters", mname); - free_tlist(origline); - free_tlist(macro_start); - return DIRECTIVE_FOUND; - } - else if (smac->level == Level) - { - /* - * We're redefining in the same level, so we have to - * take over an existing SMacro structure. This means - * freeing what was already in it. - */ - nasm_free(smac->name); - free_tlist(smac->expansion); - } - else - { - smac = nasm_malloc(sizeof(SMacro)); - smac->next = *smhead; - *smhead = smac; - } - } - else - { - smac = nasm_malloc(sizeof(SMacro)); - smac->next = *smhead; - *smhead = smac; - } - smac->name = nasm_strdup(mname); - smac->casesense = ((i == PP_DEFINE) || (i == PP_XDEFINE)); - smac->nparam = nparam; - smac->level = Level; - smac->expansion = macro_start; - smac->in_progress = FALSE; - free_tlist(origline); - return DIRECTIVE_FOUND; + tline = tline->next; + while (1) + { + skip_white_(tline); + if (!tline) + { + error(ERR_NONFATAL, "parameter identifier expected"); + free_tlist(origline); + return DIRECTIVE_FOUND; + } + if (tline->type != TOK_ID) + { + error(ERR_NONFATAL, + "`%s': parameter identifier expected", + tline->text); + free_tlist(origline); + return DIRECTIVE_FOUND; + } + tline->type = TOK_SMAC_PARAM + nparam++; + tline = tline->next; + skip_white_(tline); + if (tok_is_(tline, ",")) + { + tline = tline->next; + continue; + } + if (!tok_is_(tline, ")")) + { + error(ERR_NONFATAL, + "`)' expected to terminate macro template"); + free_tlist(origline); + return DIRECTIVE_FOUND; + } + break; + } + last = tline; + tline = tline->next; + } + if (tok_type_(tline, TOK_WHITESPACE)) + last = tline, tline = tline->next; + macro_start = NULL; + last->next = NULL; + t = tline; + while (t) + { + if (t->type == TOK_ID) + { + for (tt = param_start; tt; tt = tt->next) + if (tt->type >= TOK_SMAC_PARAM && + !strcmp(tt->text, t->text)) + t->type = tt->type; + } + tt = t->next; + t->next = macro_start; + macro_start = t; + t = tt; + } + /* + * Good. We now have a macro name, a parameter count, and a + * token list (in reverse order) for an expansion. We ought + * to be OK just to create an SMacro, store it, and let + * free_tlist have the rest of the line (which we have + * carefully re-terminated after chopping off the expansion + * from the end). + */ + if (smacro_defined(ctx, mname, nparam, &smac, i == PP_DEFINE)) + { + if (!smac) + { + error(ERR_WARNING, + "single-line macro `%s' defined both with and" + " without parameters", mname); + free_tlist(origline); + free_tlist(macro_start); + return DIRECTIVE_FOUND; + } + else + { + /* + * We're redefining, so we have to take over an + * existing SMacro structure. This means freeing + * what was already in it. + */ + nasm_free(smac->name); + free_tlist(smac->expansion); + } + } + else + { + smac = nasm_malloc(sizeof(SMacro)); + smac->next = *smhead; + *smhead = smac; + } + smac->name = nasm_strdup(mname); + smac->casesense = ((i == PP_DEFINE) || (i == PP_XDEFINE)); + smac->nparam = nparam; + smac->expansion = macro_start; + smac->in_progress = FALSE; + free_tlist(origline); + return DIRECTIVE_FOUND; - case PP_UNDEF: - tline = tline->next; - skip_white_(tline); - tline = expand_id(tline); - if (!tline || (tline->type != TOK_ID && - (tline->type != TOK_PREPROC_ID || - tline->text[1] != '$'))) - { - error(ERR_NONFATAL, "`%%undef' expects a macro identifier"); - free_tlist(origline); - return DIRECTIVE_FOUND; - } - if (tline->next) - { - error(ERR_WARNING, - "trailing garbage after macro name ignored"); - } + case PP_UNDEF: + tline = tline->next; + skip_white_(tline); + tline = expand_id(tline); + if (!tline || (tline->type != TOK_ID && + (tline->type != TOK_PREPROC_ID || + tline->text[1] != '$'))) + { + error(ERR_NONFATAL, "`%%undef' expects a macro identifier"); + free_tlist(origline); + return DIRECTIVE_FOUND; + } + if (tline->next) + { + error(ERR_WARNING, + "trailing garbage after macro name ignored"); + } - /* Find the context that symbol belongs to */ - ctx = get_ctx(tline->text, FALSE); - if (!ctx) - smhead = &smacros[hash(tline->text)]; - else - smhead = &ctx->localmac; + /* Find the context that symbol belongs to */ + ctx = get_ctx(tline->text, FALSE); + if (!ctx) + smhead = &smacros[hash(tline->text)]; + else + smhead = &ctx->localmac; - mname = tline->text; + mname = tline->text; - /* - * We now have a macro name... go hunt for it. - */ - while (smacro_defined(ctx, mname, -1, &smac, 1)) - { - /* Defined, so we need to find its predecessor and nuke it */ - SMacro **s; - for (s = smhead; *s && *s != smac; s = &(*s)->next); - if (*s) - { - *s = smac->next; - nasm_free(smac->name); - free_tlist(smac->expansion); - nasm_free(smac); - } - } - free_tlist(origline); - return DIRECTIVE_FOUND; + /* + * We now have a macro name... go hunt for it. + */ + while (smacro_defined(ctx, mname, -1, &smac, 1)) + { + /* Defined, so we need to find its predecessor and nuke it */ + SMacro **s; + for (s = smhead; *s && *s != smac; s = &(*s)->next); + if (*s) + { + *s = smac->next; + nasm_free(smac->name); + free_tlist(smac->expansion); + nasm_free(smac); + } + } + free_tlist(origline); + return DIRECTIVE_FOUND; - case PP_STRLEN: - tline = tline->next; - skip_white_(tline); - tline = expand_id(tline); - if (!tline || (tline->type != TOK_ID && - (tline->type != TOK_PREPROC_ID || - tline->text[1] != '$'))) - { - error(ERR_NONFATAL, - "`%%strlen' expects a macro identifier as first parameter"); - free_tlist(origline); - return DIRECTIVE_FOUND; - } - ctx = get_ctx(tline->text, FALSE); - if (!ctx) - smhead = &smacros[hash(tline->text)]; - else - smhead = &ctx->localmac; - mname = tline->text; - last = tline; - tline = expand_smacro(tline->next); - last->next = NULL; + case PP_STRLEN: + tline = tline->next; + skip_white_(tline); + tline = expand_id(tline); + if (!tline || (tline->type != TOK_ID && + (tline->type != TOK_PREPROC_ID || + tline->text[1] != '$'))) + { + error(ERR_NONFATAL, + "`%%strlen' expects a macro identifier as first parameter"); + free_tlist(origline); + return DIRECTIVE_FOUND; + } + ctx = get_ctx(tline->text, FALSE); + if (!ctx) + smhead = &smacros[hash(tline->text)]; + else + smhead = &ctx->localmac; + mname = tline->text; + last = tline; + tline = expand_smacro(tline->next); + last->next = NULL; - t = tline; - while (tok_type_(t, TOK_WHITESPACE)) - t = t->next; - /* t should now point to the string */ - if (t->type != TOK_STRING) - { - error(ERR_NONFATAL, - "`%%strlen` requires string as second parameter"); - free_tlist(tline); - free_tlist(origline); - return DIRECTIVE_FOUND; - } + t = tline; + while (tok_type_(t, TOK_WHITESPACE)) + t = t->next; + /* t should now point to the string */ + if (t->type != TOK_STRING) + { + error(ERR_NONFATAL, + "`%%strlen` requires string as second parameter"); + free_tlist(tline); + free_tlist(origline); + return DIRECTIVE_FOUND; + } - macro_start = nasm_malloc(sizeof(*macro_start)); - macro_start->next = NULL; - make_tok_num(macro_start, - yasm_intnum_create_uint((unsigned long)(strlen(t->text) - 2))); - macro_start->mac = NULL; + macro_start = nasm_malloc(sizeof(*macro_start)); + macro_start->next = NULL; + make_tok_num(macro_start, + yasm_intnum_create_uint((unsigned long)(strlen(t->text) - 2))); + macro_start->mac = NULL; - /* - * We now have a macro name, an implicit parameter count of - * zero, and a numeric token to use as an expansion. Create - * and store an SMacro. - */ - if (smacro_defined(ctx, mname, 0, &smac, i == PP_STRLEN)) - { - if (!smac) - error(ERR_WARNING, - "single-line macro `%s' defined both with and" - " without parameters", mname); - else - { - /* - * We're redefining, so we have to take over an - * existing SMacro structure. This means freeing - * what was already in it. - */ - nasm_free(smac->name); - free_tlist(smac->expansion); - } - } - else - { - smac = nasm_malloc(sizeof(SMacro)); - smac->next = *smhead; - *smhead = smac; - } - smac->name = nasm_strdup(mname); - smac->casesense = (i == PP_STRLEN); - smac->nparam = 0; - smac->level = 0; - smac->expansion = macro_start; - smac->in_progress = FALSE; - free_tlist(tline); - free_tlist(origline); - return DIRECTIVE_FOUND; + /* + * We now have a macro name, an implicit parameter count of + * zero, and a numeric token to use as an expansion. Create + * and store an SMacro. + */ + if (smacro_defined(ctx, mname, 0, &smac, i == PP_STRLEN)) + { + if (!smac) + error(ERR_WARNING, + "single-line macro `%s' defined both with and" + " without parameters", mname); + else + { + /* + * We're redefining, so we have to take over an + * existing SMacro structure. This means freeing + * what was already in it. + */ + nasm_free(smac->name); + free_tlist(smac->expansion); + } + } + else + { + smac = nasm_malloc(sizeof(SMacro)); + smac->next = *smhead; + *smhead = smac; + } + smac->name = nasm_strdup(mname); + smac->casesense = (i == PP_STRLEN); + smac->nparam = 0; + smac->expansion = macro_start; + smac->in_progress = FALSE; + free_tlist(tline); + free_tlist(origline); + return DIRECTIVE_FOUND; - case PP_SUBSTR: - tline = tline->next; - skip_white_(tline); - tline = expand_id(tline); - if (!tline || (tline->type != TOK_ID && - (tline->type != TOK_PREPROC_ID || - tline->text[1] != '$'))) - { - error(ERR_NONFATAL, - "`%%substr' expects a macro identifier as first parameter"); - free_tlist(origline); - return DIRECTIVE_FOUND; - } - ctx = get_ctx(tline->text, FALSE); - if (!ctx) - smhead = &smacros[hash(tline->text)]; - else - smhead = &ctx->localmac; - mname = tline->text; - last = tline; - tline = expand_smacro(tline->next); - last->next = NULL; + case PP_SUBSTR: + tline = tline->next; + skip_white_(tline); + tline = expand_id(tline); + if (!tline || (tline->type != TOK_ID && + (tline->type != TOK_PREPROC_ID || + tline->text[1] != '$'))) + { + error(ERR_NONFATAL, + "`%%substr' expects a macro identifier as first parameter"); + free_tlist(origline); + return DIRECTIVE_FOUND; + } + ctx = get_ctx(tline->text, FALSE); + if (!ctx) + smhead = &smacros[hash(tline->text)]; + else + smhead = &ctx->localmac; + mname = tline->text; + last = tline; + tline = expand_smacro(tline->next); + last->next = NULL; - t = tline->next; - while (tok_type_(t, TOK_WHITESPACE)) - t = t->next; + t = tline->next; + while (tok_type_(t, TOK_WHITESPACE)) + t = t->next; - /* t should now point to the string */ - if (t->type != TOK_STRING) - { - error(ERR_NONFATAL, - "`%%substr` requires string as second parameter"); - free_tlist(tline); - free_tlist(origline); - return DIRECTIVE_FOUND; - } + /* t should now point to the string */ + if (t->type != TOK_STRING) + { + error(ERR_NONFATAL, + "`%%substr` requires string as second parameter"); + free_tlist(tline); + free_tlist(origline); + return DIRECTIVE_FOUND; + } - tt = t->next; - tptr = &tt; - tokval.t_type = TOKEN_INVALID; - evalresult = evaluate(ppscan, tptr, &tokval, pass, error); - if (!evalresult) - { - free_tlist(tline); - free_tlist(origline); - return DIRECTIVE_FOUND; - } - intn = yasm_expr_get_intnum(&evalresult, 0); - if (!intn) - { - error(ERR_NONFATAL, "non-constant value given to `%%substr`"); - free_tlist(tline); - free_tlist(origline); - yasm_expr_destroy(evalresult); - return DIRECTIVE_FOUND; - } + tt = t->next; + tptr = &tt; + tokval.t_type = TOKEN_INVALID; + evalresult = evaluate(ppscan, tptr, &tokval, pass, error); + if (!evalresult) + { + free_tlist(tline); + free_tlist(origline); + return DIRECTIVE_FOUND; + } + intn = yasm_expr_get_intnum(&evalresult, 0); + if (!intn) + { + error(ERR_NONFATAL, "non-constant value given to `%%substr`"); + free_tlist(tline); + free_tlist(origline); + yasm_expr_destroy(evalresult); + return DIRECTIVE_FOUND; + } - macro_start = nasm_malloc(sizeof(*macro_start)); - macro_start->next = NULL; - macro_start->text = nasm_strdup("'''"); - if (yasm_intnum_sign(intn) == 1 - && yasm_intnum_get_uint(intn) < strlen(t->text) - 1) - { - macro_start->text[1] = t->text[yasm_intnum_get_uint(intn)]; - } - else - { - macro_start->text[2] = '\0'; - } - yasm_expr_destroy(evalresult); - macro_start->type = TOK_STRING; - macro_start->mac = NULL; + macro_start = nasm_malloc(sizeof(*macro_start)); + macro_start->next = NULL; + macro_start->text = nasm_strdup("'''"); + if (yasm_intnum_sign(intn) == 1 + && yasm_intnum_get_uint(intn) < strlen(t->text) - 1) + { + macro_start->text[1] = t->text[yasm_intnum_get_uint(intn)]; + } + else + { + macro_start->text[2] = '\0'; + } + yasm_expr_destroy(evalresult); + macro_start->type = TOK_STRING; + macro_start->mac = NULL; - /* - * We now have a macro name, an implicit parameter count of - * zero, and a numeric token to use as an expansion. Create - * and store an SMacro. - */ - if (smacro_defined(ctx, mname, 0, &smac, i == PP_SUBSTR)) - { - if (!smac) - error(ERR_WARNING, - "single-line macro `%s' defined both with and" - " without parameters", mname); - else - { - /* - * We're redefining, so we have to take over an - * existing SMacro structure. This means freeing - * what was already in it. - */ - nasm_free(smac->name); - free_tlist(smac->expansion); - } - } - else - { - smac = nasm_malloc(sizeof(SMacro)); - smac->next = *smhead; - *smhead = smac; - } - smac->name = nasm_strdup(mname); - smac->casesense = (i == PP_SUBSTR); - smac->nparam = 0; - smac->level = 0; - smac->expansion = macro_start; - smac->in_progress = FALSE; - free_tlist(tline); - free_tlist(origline); - return DIRECTIVE_FOUND; + /* + * We now have a macro name, an implicit parameter count of + * zero, and a numeric token to use as an expansion. Create + * and store an SMacro. + */ + if (smacro_defined(ctx, mname, 0, &smac, i == PP_SUBSTR)) + { + if (!smac) + error(ERR_WARNING, + "single-line macro `%s' defined both with and" + " without parameters", mname); + else + { + /* + * We're redefining, so we have to take over an + * existing SMacro structure. This means freeing + * what was already in it. + */ + nasm_free(smac->name); + free_tlist(smac->expansion); + } + } + else + { + smac = nasm_malloc(sizeof(SMacro)); + smac->next = *smhead; + *smhead = smac; + } + smac->name = nasm_strdup(mname); + smac->casesense = (i == PP_SUBSTR); + smac->nparam = 0; + smac->expansion = macro_start; + smac->in_progress = FALSE; + free_tlist(tline); + free_tlist(origline); + return DIRECTIVE_FOUND; - case PP_ASSIGN: - case PP_IASSIGN: - tline = tline->next; - skip_white_(tline); - tline = expand_id(tline); - if (!tline || (tline->type != TOK_ID && - (tline->type != TOK_PREPROC_ID || - tline->text[1] != '$'))) - { - error(ERR_NONFATAL, - "`%%%sassign' expects a macro identifier", - (i == PP_IASSIGN ? "i" : "")); - free_tlist(origline); - return DIRECTIVE_FOUND; - } - ctx = get_ctx(tline->text, FALSE); - if (!ctx) - smhead = &smacros[hash(tline->text)]; - else - smhead = &ctx->localmac; - mname = tline->text; - last = tline; - tline = expand_smacro(tline->next); - last->next = NULL; + case PP_ASSIGN: + case PP_IASSIGN: + tline = tline->next; + skip_white_(tline); + tline = expand_id(tline); + if (!tline || (tline->type != TOK_ID && + (tline->type != TOK_PREPROC_ID || + tline->text[1] != '$'))) + { + error(ERR_NONFATAL, + "`%%%sassign' expects a macro identifier", + (i == PP_IASSIGN ? "i" : "")); + free_tlist(origline); + return DIRECTIVE_FOUND; + } + ctx = get_ctx(tline->text, FALSE); + if (!ctx) + smhead = &smacros[hash(tline->text)]; + else + smhead = &ctx->localmac; + mname = tline->text; + last = tline; + tline = expand_smacro(tline->next); + last->next = NULL; - t = tline; - tptr = &t; - tokval.t_type = TOKEN_INVALID; - evalresult = evaluate(ppscan, tptr, &tokval, pass, error); - free_tlist(tline); - if (!evalresult) - { - free_tlist(origline); - return DIRECTIVE_FOUND; - } + t = tline; + tptr = &t; + tokval.t_type = TOKEN_INVALID; + evalresult = evaluate(ppscan, tptr, &tokval, pass, error); + free_tlist(tline); + if (!evalresult) + { + free_tlist(origline); + return DIRECTIVE_FOUND; + } - if (tokval.t_type) - error(ERR_WARNING, - "trailing garbage after expression ignored"); + if (tokval.t_type) + error(ERR_WARNING, + "trailing garbage after expression ignored"); - intn = yasm_expr_get_intnum(&evalresult, 0); - if (!intn) - { - error(ERR_NONFATAL, - "non-constant value given to `%%%sassign'", - (i == PP_IASSIGN ? "i" : "")); - free_tlist(origline); - yasm_expr_destroy(evalresult); - return DIRECTIVE_FOUND; - } + intn = yasm_expr_get_intnum(&evalresult, 0); + if (!intn) + { + error(ERR_NONFATAL, + "non-constant value given to `%%%sassign'", + (i == PP_IASSIGN ? "i" : "")); + free_tlist(origline); + yasm_expr_destroy(evalresult); + return DIRECTIVE_FOUND; + } - macro_start = nasm_malloc(sizeof(*macro_start)); - macro_start->next = NULL; - make_tok_num(macro_start, yasm_intnum_copy(intn)); - yasm_expr_destroy(evalresult); - macro_start->mac = NULL; + macro_start = nasm_malloc(sizeof(*macro_start)); + macro_start->next = NULL; + make_tok_num(macro_start, yasm_intnum_copy(intn)); + yasm_expr_destroy(evalresult); + macro_start->mac = NULL; - /* - * We now have a macro name, an implicit parameter count of - * zero, and a numeric token to use as an expansion. Create - * and store an SMacro. - */ - if (smacro_defined(ctx, mname, 0, &smac, i == PP_ASSIGN)) - { - if (!smac) - error(ERR_WARNING, - "single-line macro `%s' defined both with and" - " without parameters", mname); - else - { - /* - * We're redefining, so we have to take over an - * existing SMacro structure. This means freeing - * what was already in it. - */ - nasm_free(smac->name); - free_tlist(smac->expansion); - } - } - else - { - smac = nasm_malloc(sizeof(SMacro)); - smac->next = *smhead; - *smhead = smac; - } - smac->name = nasm_strdup(mname); - smac->casesense = (i == PP_ASSIGN); - smac->nparam = 0; - smac->level = 0; - smac->expansion = macro_start; - smac->in_progress = FALSE; - free_tlist(origline); - return DIRECTIVE_FOUND; + /* + * We now have a macro name, an implicit parameter count of + * zero, and a numeric token to use as an expansion. Create + * and store an SMacro. + */ + if (smacro_defined(ctx, mname, 0, &smac, i == PP_ASSIGN)) + { + if (!smac) + error(ERR_WARNING, + "single-line macro `%s' defined both with and" + " without parameters", mname); + else + { + /* + * We're redefining, so we have to take over an + * existing SMacro structure. This means freeing + * what was already in it. + */ + nasm_free(smac->name); + free_tlist(smac->expansion); + } + } + else + { + smac = nasm_malloc(sizeof(SMacro)); + smac->next = *smhead; + *smhead = smac; + } + smac->name = nasm_strdup(mname); + smac->casesense = (i == PP_ASSIGN); + smac->nparam = 0; + smac->expansion = macro_start; + smac->in_progress = FALSE; + free_tlist(origline); + return DIRECTIVE_FOUND; - case PP_LINE: - /* - * Syntax is `%line nnn[+mmm] [filename]' - */ - tline = tline->next; - skip_white_(tline); - if (!tok_type_(tline, TOK_NUMBER)) - { - error(ERR_NONFATAL, "`%%line' expects line number"); - free_tlist(origline); - return DIRECTIVE_FOUND; - } - intn = nasm_readnum(tline->text, &j); - k = yasm_intnum_get_int(intn); - yasm_intnum_destroy(intn); - m = 1; - tline = tline->next; - if (tok_is_(tline, "+")) - { - tline = tline->next; - if (!tok_type_(tline, TOK_NUMBER)) - { - error(ERR_NONFATAL, "`%%line' expects line increment"); - free_tlist(origline); - return DIRECTIVE_FOUND; - } - intn = nasm_readnum(tline->text, &j); - m = yasm_intnum_get_int(intn); - yasm_intnum_destroy(intn); - tline = tline->next; - } - skip_white_(tline); - nasm_src_set_linnum(k); - istk->lineinc = m; - if (tline) - { - nasm_free(nasm_src_set_fname(detoken(tline, FALSE))); - } - free_tlist(origline); - return DIRECTIVE_FOUND; + case PP_LINE: + /* + * Syntax is `%line nnn[+mmm] [filename]' + */ + tline = tline->next; + skip_white_(tline); + if (!tok_type_(tline, TOK_NUMBER)) + { + error(ERR_NONFATAL, "`%%line' expects line number"); + free_tlist(origline); + return DIRECTIVE_FOUND; + } + intn = nasm_readnum(tline->text, &j); + k = yasm_intnum_get_int(intn); + yasm_intnum_destroy(intn); + m = 1; + tline = tline->next; + if (tok_is_(tline, "+")) + { + tline = tline->next; + if (!tok_type_(tline, TOK_NUMBER)) + { + error(ERR_NONFATAL, "`%%line' expects line increment"); + free_tlist(origline); + return DIRECTIVE_FOUND; + } + intn = nasm_readnum(tline->text, &j); + m = yasm_intnum_get_int(intn); + yasm_intnum_destroy(intn); + tline = tline->next; + } + skip_white_(tline); + nasm_src_set_linnum(k); + istk->lineinc = m; + if (tline) + { + nasm_free(nasm_src_set_fname(detoken(tline, FALSE))); + } + free_tlist(origline); + return DIRECTIVE_FOUND; - default: - error(ERR_FATAL, - "preprocessor directive `%s' not yet implemented", - directives[i]); - break; + default: + error(ERR_FATAL, + "preprocessor directive `%s' not yet implemented", + directives[i]); + break; } return DIRECTIVE_FOUND; } @@ -3814,33 +3217,33 @@ find_cc(Token * t) skip_white_(t); if (t->type != TOK_ID) - return -1; + return -1; tt = t->next; skip_white_(tt); if (tt && (tt->type != TOK_OTHER || strcmp(tt->text, ","))) - return -1; + return -1; i = -1; j = elements(conditions); while (j - i > 1) { - k = (j + i) / 2; - m = nasm_stricmp(t->text, conditions[k]); - if (m == 0) - { - i = k; - j = -2; - break; - } - else if (m < 0) - { - j = k; - } - else - i = k; + k = (j + i) / 2; + m = nasm_stricmp(t->text, conditions[k]); + if (m == 0) + { + i = k; + j = -2; + break; + } + else if (m < 0) + { + j = k; + } + else + i = k; } if (j != -2) - return -1; + return -1; return i; } @@ -3858,246 +3261,177 @@ expand_mmac_params(Token * tline) while (tline) { - if (tline->type == TOK_PREPROC_ID && - (((tline->text[1] == '+' || tline->text[1] == '-') - && tline->text[2]) || tline->text[1] == '%' - || (tline->text[1] >= '0' && tline->text[1] <= '9'))) - { - char *text = NULL; - int type = 0, cc; /* type = 0 to placate optimisers */ - char tmpbuf[30]; - char *second_text = NULL; - int n, i; - MMacro *mac; + if (tline->type == TOK_PREPROC_ID && + (((tline->text[1] == '+' || tline->text[1] == '-') + && tline->text[2]) || tline->text[1] == '%' + || (tline->text[1] >= '0' && tline->text[1] <= '9'))) + { + char *text = NULL; + int type = 0, cc; /* type = 0 to placate optimisers */ + char tmpbuf[30]; + int n, i; + MMacro *mac; - t = tline; - tline = tline->next; + t = tline; + tline = tline->next; - second_text = strchr(t->text, ':'); - - mac = istk->mstk; - while (mac && !mac->name) /* avoid mistaking %reps for macros */ - mac = mac->next_active; - if (!mac) - error(ERR_NONFATAL, "`%s': not in a macro call", t->text); - else - { - if (second_text) - { - int end = atoi(second_text+1)-1; - int is_fst = 1; - int k; - n = atoi(t->text + 1)-1; - if (end < 0) - end += mac->nparam; - - for (k = n; k <= end; k++) - { - if (k >= mac->nparam) - tt = NULL; - else - { - if (mac->nparam > 1) - k = (k + mac->rotate) % mac->nparam; - tt = mac->params[k]; - } - if (tt) - { - if (!is_fst && mac->paramlen[k]) - { - *tail = new_Token(NULL, TOK_OTHER, ",", 0); - tail = &(*tail)->next; - } - if (mac->paramlen[k]) - is_fst = 0; - for (i = 0; i < mac->paramlen[k]; i++) - { - *tail = - new_Token(NULL, tt->type, tt->text, - 0); - tail = &(*tail)->next; - tt = tt->next; - } - } - text = NULL; /* we've done it here */ - } - } - else - { - switch (t->text[1]) - { - /* - * We have to make a substitution of one of the - * forms %1, %-1, %+1, %%foo, %0. - */ - case '0': - type = TOK_NUMBER; - sprintf(tmpbuf, "%ld", mac->nparam); - text = nasm_strdup(tmpbuf); - break; - case '%': - type = TOK_ID; - sprintf(tmpbuf, "..@%lu.", mac->unique); - text = nasm_strcat(tmpbuf, t->text + 2); - break; - case '-': - n = atoi(t->text + 2) - 1; - if (n >= mac->nparam) - tt = NULL; - else - { - if (mac->nparam > 1) - n = (n + mac->rotate) % mac->nparam; - tt = mac->params[n]; - } - if (!tt) - { - error(ERR_NONFATAL, - "macro parameter %d is not a condition code", - n + 1); - text = NULL; - } - else - { - cc = find_cc(tt); - if (cc == -1) - { - error(ERR_NONFATAL, - "macro parameter %d is not a condition code", - n + 1); - text = NULL; - } - else - { - type = TOK_ID; - if (inverse_ccs[cc] == -1) - { - error(ERR_NONFATAL, - "condition code `%s' is not invertible", - conditions[cc]); - text = NULL; - } - else - text = - nasm_strdup(conditions[inverse_ccs - [cc]]); - } - } - break; - case '+': - n = atoi(t->text + 2) - 1; - if (n >= mac->nparam) - tt = NULL; - else - { - if (mac->nparam > 1) - n = (n + mac->rotate) % mac->nparam; - tt = mac->params[n]; - } - if (!tt) - { - error(ERR_NONFATAL, - "macro parameter %d is not a condition code", - n + 1); - text = NULL; - } - else - { - cc = find_cc(tt); - if (cc == -1) - { - error(ERR_NONFATAL, - "macro parameter %d is not a condition code", - n + 1); - text = NULL; - } - else - { - type = TOK_ID; - text = nasm_strdup(conditions[cc]); - } - } - break; - default: - n = atoi(t->text + 1) - 1; - if (n >= mac->nparam) - tt = NULL; - else - { - if (mac->nparam > 1) - n = (n + mac->rotate) % mac->nparam; - tt = mac->params[n]; - } - if (tt) - { - for (i = 0; i < mac->paramlen[n]; i++) - { - *tail = - new_Token(NULL, tt->type, tt->text, - 0); - tail = &(*tail)->next; - tt = tt->next; - } - } - text = NULL; /* we've done it here */ - break; - } - } - } - - if (!text) - { - delete_Token(t); - } - else - { - *tail = t; - tail = &t->next; - t->type = type; - nasm_free(t->text); - t->text = text; - t->mac = NULL; - } - continue; - } - else - { - t = *tail = tline; - tline = tline->next; - t->mac = NULL; - tail = &t->next; - } + mac = istk->mstk; + while (mac && !mac->name) /* avoid mistaking %reps for macros */ + mac = mac->next_active; + if (!mac) + error(ERR_NONFATAL, "`%s': not in a macro call", t->text); + else + switch (t->text[1]) + { + /* + * We have to make a substitution of one of the + * forms %1, %-1, %+1, %%foo, %0. + */ + case '0': + type = TOK_NUMBER; + sprintf(tmpbuf, "%ld", mac->nparam); + text = nasm_strdup(tmpbuf); + break; + case '%': + type = TOK_ID; + sprintf(tmpbuf, "..@%lu.", mac->unique); + text = nasm_strcat(tmpbuf, t->text + 2); + break; + case '-': + n = atoi(t->text + 2) - 1; + if (n >= mac->nparam) + tt = NULL; + else + { + if (mac->nparam > 1) + n = (n + mac->rotate) % mac->nparam; + tt = mac->params[n]; + } + cc = find_cc(tt); + if (cc == -1) + { + error(ERR_NONFATAL, + "macro parameter %d is not a condition code", + n + 1); + text = NULL; + } + else + { + type = TOK_ID; + if (inverse_ccs[cc] == -1) + { + error(ERR_NONFATAL, + "condition code `%s' is not invertible", + conditions[cc]); + text = NULL; + } + else + text = + nasm_strdup(conditions[inverse_ccs + [cc]]); + } + break; + case '+': + n = atoi(t->text + 2) - 1; + if (n >= mac->nparam) + tt = NULL; + else + { + if (mac->nparam > 1) + n = (n + mac->rotate) % mac->nparam; + tt = mac->params[n]; + } + cc = find_cc(tt); + if (cc == -1) + { + error(ERR_NONFATAL, + "macro parameter %d is not a condition code", + n + 1); + text = NULL; + } + else + { + type = TOK_ID; + text = nasm_strdup(conditions[cc]); + } + break; + default: + n = atoi(t->text + 1) - 1; + if (n >= mac->nparam) + tt = NULL; + else + { + if (mac->nparam > 1) + n = (n + mac->rotate) % mac->nparam; + tt = mac->params[n]; + } + if (tt) + { + for (i = 0; i < mac->paramlen[n]; i++) + { + *tail = + new_Token(NULL, tt->type, tt->text, + 0); + tail = &(*tail)->next; + tt = tt->next; + } + } + text = NULL; /* we've done it here */ + break; + } + if (!text) + { + delete_Token(t); + } + else + { + *tail = t; + tail = &t->next; + t->type = type; + nasm_free(t->text); + t->text = text; + t->mac = NULL; + } + continue; + } + else + { + t = *tail = tline; + tline = tline->next; + t->mac = NULL; + tail = &t->next; + } } *tail = NULL; t = thead; for (; t && (tt = t->next) != NULL; t = t->next) - switch (t->type) - { - case TOK_WHITESPACE: - if (tt->type == TOK_WHITESPACE) - { - t->next = delete_Token(tt); - } - break; - case TOK_ID: - if (tt->type == TOK_ID || tt->type == TOK_NUMBER) - { - char *tmp = nasm_strcat(t->text, tt->text); - nasm_free(t->text); - t->text = tmp; - t->next = delete_Token(tt); - } - break; - case TOK_NUMBER: - if (tt->type == TOK_NUMBER) - { - char *tmp = nasm_strcat(t->text, tt->text); - nasm_free(t->text); - t->text = tmp; - t->next = delete_Token(tt); - } - break; - } + switch (t->type) + { + case TOK_WHITESPACE: + if (tt->type == TOK_WHITESPACE) + { + t->next = delete_Token(tt); + } + break; + case TOK_ID: + if (tt->type == TOK_ID || tt->type == TOK_NUMBER) + { + char *tmp = nasm_strcat(t->text, tt->text); + nasm_free(t->text); + t->text = tmp; + t->next = delete_Token(tt); + } + break; + case TOK_NUMBER: + if (tt->type == TOK_NUMBER) + { + char *tmp = nasm_strcat(t->text, tt->text); + nasm_free(t->text); + t->text = tmp; + t->next = delete_Token(tt); + } + break; + } return thead; } @@ -4129,12 +3463,12 @@ expand_smacro(Token * tline) */ if (org_tline) { - tline = - new_Token(org_tline->next, org_tline->type, org_tline->text, - 0); - tline->mac = org_tline->mac; - nasm_free(org_tline->text); - org_tline->text = NULL; + tline = + new_Token(org_tline->next, org_tline->type, org_tline->text, + 0); + tline->mac = org_tline->mac; + nasm_free(org_tline->text); + org_tline->text = NULL; } again: @@ -4142,277 +3476,277 @@ expand_smacro(Token * tline) thead = NULL; while (tline) - { /* main token loop */ - if ((mname = tline->text)) - { - /* if this token is a local macro, look in local context */ - if (tline->type == TOK_ID || tline->type == TOK_PREPROC_ID) - ctx = get_ctx(mname, TRUE); - else - ctx = NULL; - if (!ctx) - head = smacros[hash(mname)]; - else - head = ctx->localmac; - /* - * We've hit an identifier. As in is_mmacro below, we first - * check whether the identifier is a single-line macro at - * all, then think about checking for parameters if - * necessary. - */ - for (m = head; m; m = m->next) - if (!mstrcmp(m->name, mname, m->casesense)) - break; - if (m) - { - mstart = tline; - params = NULL; - paramsize = NULL; - if (m->nparam == 0) - { - /* - * Simple case: the macro is parameterless. Discard the - * one token that the macro call took, and push the - * expansion back on the to-do stack. - */ - if (!m->expansion) - { - if (!strcmp("__FILE__", m->name)) - { - long num = 0; - nasm_src_get(&num, &(tline->text)); - nasm_quote(&(tline->text)); - tline->type = TOK_STRING; - continue; - } - if (!strcmp("__LINE__", m->name)) - { - nasm_free(tline->text); - make_tok_num(tline, yasm_intnum_create_int(nasm_src_get_linnum())); - continue; - } - tline = delete_Token(tline); - continue; - } - } - else - { - /* - * Complicated case: at least one macro with this name - * exists and takes parameters. We must find the - * parameters in the call, count them, find the SMacro - * that corresponds to that form of the macro call, and - * substitute for the parameters when we expand. What a - * pain. - */ - /*tline = tline->next; - skip_white_(tline);*/ - do { - t = tline->next; - while (tok_type_(t, TOK_SMAC_END)) - { - t->mac->in_progress = FALSE; - t->text = NULL; - t = tline->next = delete_Token(t); - } - tline = t; - } while (tok_type_(tline, TOK_WHITESPACE)); - if (!tok_is_(tline, "(")) - { - /* - * This macro wasn't called with parameters: ignore - * the call. (Behaviour borrowed from gnu cpp.) - */ - tline = mstart; - m = NULL; - } - else - { - int paren = 0; - int white = 0; - brackets = 0; - nparam = 0; - sparam = PARAM_DELTA; - params = nasm_malloc(sparam * sizeof(Token *)); - params[0] = tline->next; - paramsize = nasm_malloc(sparam * sizeof(int)); - paramsize[0] = 0; - while (TRUE) - { /* parameter loop */ - /* - * For some unusual expansions - * which concatenates function call - */ - t = tline->next; - while (tok_type_(t, TOK_SMAC_END)) - { - t->mac->in_progress = FALSE; - t->text = NULL; - t = tline->next = delete_Token(t); - } - tline = t; + { /* main token loop */ + if ((mname = tline->text)) + { + /* if this token is a local macro, look in local context */ + if (tline->type == TOK_ID || tline->type == TOK_PREPROC_ID) + ctx = get_ctx(mname, TRUE); + else + ctx = NULL; + if (!ctx) + head = smacros[hash(mname)]; + else + head = ctx->localmac; + /* + * We've hit an identifier. As in is_mmacro below, we first + * check whether the identifier is a single-line macro at + * all, then think about checking for parameters if + * necessary. + */ + for (m = head; m; m = m->next) + if (!mstrcmp(m->name, mname, m->casesense)) + break; + if (m) + { + mstart = tline; + params = NULL; + paramsize = NULL; + if (m->nparam == 0) + { + /* + * Simple case: the macro is parameterless. Discard the + * one token that the macro call took, and push the + * expansion back on the to-do stack. + */ + if (!m->expansion) + { + if (!strcmp("__FILE__", m->name)) + { + long num = 0; + nasm_src_get(&num, &(tline->text)); + nasm_quote(&(tline->text)); + tline->type = TOK_STRING; + continue; + } + if (!strcmp("__LINE__", m->name)) + { + nasm_free(tline->text); + make_tok_num(tline, yasm_intnum_create_int(nasm_src_get_linnum())); + continue; + } + tline = delete_Token(tline); + continue; + } + } + else + { + /* + * Complicated case: at least one macro with this name + * exists and takes parameters. We must find the + * parameters in the call, count them, find the SMacro + * that corresponds to that form of the macro call, and + * substitute for the parameters when we expand. What a + * pain. + */ + /*tline = tline->next; + skip_white_(tline);*/ + do { + t = tline->next; + while (tok_type_(t, TOK_SMAC_END)) + { + t->mac->in_progress = FALSE; + t->text = NULL; + t = tline->next = delete_Token(t); + } + tline = t; + } while (tok_type_(tline, TOK_WHITESPACE)); + if (!tok_is_(tline, "(")) + { + /* + * This macro wasn't called with parameters: ignore + * the call. (Behaviour borrowed from gnu cpp.) + */ + tline = mstart; + m = NULL; + } + else + { + int paren = 0; + int white = 0; + brackets = 0; + nparam = 0; + sparam = PARAM_DELTA; + params = nasm_malloc(sparam * sizeof(Token *)); + params[0] = tline->next; + paramsize = nasm_malloc(sparam * sizeof(int)); + paramsize[0] = 0; + while (TRUE) + { /* parameter loop */ + /* + * For some unusual expansions + * which concatenates function call + */ + t = tline->next; + while (tok_type_(t, TOK_SMAC_END)) + { + t->mac->in_progress = FALSE; + t->text = NULL; + t = tline->next = delete_Token(t); + } + tline = t; - if (!tline) - { - error(ERR_NONFATAL, - "macro call expects terminating `)'"); - break; - } - if (tline->type == TOK_WHITESPACE - && brackets <= 0) - { - if (paramsize[nparam]) - white++; - else - params[nparam] = tline->next; - continue; /* parameter loop */ - } - if (tline->type == TOK_OTHER - && tline->text[1] == 0) - { - char ch = tline->text[0]; - if (ch == ',' && !paren && brackets <= 0) - { - if (++nparam >= sparam) - { - sparam += PARAM_DELTA; - params = nasm_realloc(params, - sparam * sizeof(Token *)); - paramsize = nasm_realloc(paramsize, - sparam * sizeof(int)); - } - params[nparam] = tline->next; - paramsize[nparam] = 0; - white = 0; - continue; /* parameter loop */ - } - if (ch == '{' && - (brackets > 0 || (brackets == 0 && - !paramsize[nparam]))) - { - if (!(brackets++)) - { - params[nparam] = tline->next; - continue; /* parameter loop */ - } - } - if (ch == '}' && brackets > 0) - if (--brackets == 0) - { - brackets = -1; - continue; /* parameter loop */ - } - if (ch == '(' && !brackets) - paren++; - if (ch == ')' && brackets <= 0) - if (--paren < 0) - break; - } - if (brackets < 0) - { - brackets = 0; - error(ERR_NONFATAL, "braces do not " - "enclose all of macro parameter"); - } - paramsize[nparam] += white + 1; - white = 0; - } /* parameter loop */ - nparam++; - while (m && (m->nparam != nparam || - mstrcmp(m->name, mname, - m->casesense))) - m = m->next; - if (!m) - error(ERR_WARNING | ERR_WARN_MNP, - "macro `%s' exists, " - "but not taking %d parameters", - mstart->text, nparam); - } - } - if (m && m->in_progress) - m = NULL; - if (!m) /* in progess or didn't find '(' or wrong nparam */ - { - /* - * Design question: should we handle !tline, which - * indicates missing ')' here, or expand those - * macros anyway, which requires the (t) test a few - * lines down? - */ - nasm_free(params); - nasm_free(paramsize); - tline = mstart; - } - else - { - /* - * Expand the macro: we are placed on the last token of the - * call, so that we can easily split the call from the - * following tokens. We also start by pushing an SMAC_END - * token for the cycle removal. - */ - t = tline; - if (t) - { - tline = t->next; - t->next = NULL; - } - tt = new_Token(tline, TOK_SMAC_END, NULL, 0); - tt->mac = m; - m->in_progress = TRUE; - tline = tt; - for (t = m->expansion; t; t = t->next) - { - if (t->type >= TOK_SMAC_PARAM) - { - Token *pcopy = tline, **ptail = &pcopy; - Token *ttt, *pt; - int i; + if (!tline) + { + error(ERR_NONFATAL, + "macro call expects terminating `)'"); + break; + } + if (tline->type == TOK_WHITESPACE + && brackets <= 0) + { + if (paramsize[nparam]) + white++; + else + params[nparam] = tline->next; + continue; /* parameter loop */ + } + if (tline->type == TOK_OTHER + && tline->text[1] == 0) + { + char ch = tline->text[0]; + if (ch == ',' && !paren && brackets <= 0) + { + if (++nparam >= sparam) + { + sparam += PARAM_DELTA; + params = nasm_realloc(params, + sparam * sizeof(Token *)); + paramsize = nasm_realloc(paramsize, + sparam * sizeof(int)); + } + params[nparam] = tline->next; + paramsize[nparam] = 0; + white = 0; + continue; /* parameter loop */ + } + if (ch == '{' && + (brackets > 0 || (brackets == 0 && + !paramsize[nparam]))) + { + if (!(brackets++)) + { + params[nparam] = tline->next; + continue; /* parameter loop */ + } + } + if (ch == '}' && brackets > 0) + if (--brackets == 0) + { + brackets = -1; + continue; /* parameter loop */ + } + if (ch == '(' && !brackets) + paren++; + if (ch == ')' && brackets <= 0) + if (--paren < 0) + break; + } + if (brackets < 0) + { + brackets = 0; + error(ERR_NONFATAL, "braces do not " + "enclose all of macro parameter"); + } + paramsize[nparam] += white + 1; + white = 0; + } /* parameter loop */ + nparam++; + while (m && (m->nparam != nparam || + mstrcmp(m->name, mname, + m->casesense))) + m = m->next; + if (!m) + error(ERR_WARNING | ERR_WARN_MNP, + "macro `%s' exists, " + "but not taking %d parameters", + mstart->text, nparam); + } + } + if (m && m->in_progress) + m = NULL; + if (!m) /* in progess or didn't find '(' or wrong nparam */ + { + /* + * Design question: should we handle !tline, which + * indicates missing ')' here, or expand those + * macros anyway, which requires the (t) test a few + * lines down? + */ + nasm_free(params); + nasm_free(paramsize); + tline = mstart; + } + else + { + /* + * Expand the macro: we are placed on the last token of the + * call, so that we can easily split the call from the + * following tokens. We also start by pushing an SMAC_END + * token for the cycle removal. + */ + t = tline; + if (t) + { + tline = t->next; + t->next = NULL; + } + tt = new_Token(tline, TOK_SMAC_END, NULL, 0); + tt->mac = m; + m->in_progress = TRUE; + tline = tt; + for (t = m->expansion; t; t = t->next) + { + if (t->type >= TOK_SMAC_PARAM) + { + Token *pcopy = tline, **ptail = &pcopy; + Token *ttt, *pt; + int i; - ttt = params[t->type - TOK_SMAC_PARAM]; - for (i = paramsize[t->type - TOK_SMAC_PARAM]; - --i >= 0;) - { - pt = *ptail = - new_Token(tline, ttt->type, ttt->text, - 0); - ptail = &pt->next; - ttt = ttt->next; - } - tline = pcopy; - } - else - { - tt = new_Token(tline, t->type, t->text, 0); - tline = tt; - } - } + ttt = params[t->type - TOK_SMAC_PARAM]; + for (i = paramsize[t->type - TOK_SMAC_PARAM]; + --i >= 0;) + { + pt = *ptail = + new_Token(tline, ttt->type, ttt->text, + 0); + ptail = &pt->next; + ttt = ttt->next; + } + tline = pcopy; + } + else + { + tt = new_Token(tline, t->type, t->text, 0); + tline = tt; + } + } - /* - * Having done that, get rid of the macro call, and clean - * up the parameters. - */ - nasm_free(params); - nasm_free(paramsize); - free_tlist(mstart); - continue; /* main token loop */ - } - } - } + /* + * Having done that, get rid of the macro call, and clean + * up the parameters. + */ + nasm_free(params); + nasm_free(paramsize); + free_tlist(mstart); + continue; /* main token loop */ + } + } + } - if (tline->type == TOK_SMAC_END) - { - tline->mac->in_progress = FALSE; - tline = delete_Token(tline); - } - else - { - t = *tail = tline; - tline = tline->next; - t->mac = NULL; - t->next = NULL; - tail = &t->next; - } + if (tline->type == TOK_SMAC_END) + { + tline->mac->in_progress = FALSE; + tline = delete_Token(tline); + } + else + { + t = *tail = tline; + tline = tline->next; + t->mac = NULL; + t->next = NULL; + tail = &t->next; + } } /* @@ -4426,62 +3760,62 @@ expand_smacro(Token * tline) rescan = 0; while (t) { - while (t && t->type != TOK_ID && t->type != TOK_PREPROC_ID) - t = t->next; - if (!t || !t->next) - break; - if (t->next->type == TOK_ID || - t->next->type == TOK_PREPROC_ID || - t->next->type == TOK_NUMBER) - { - char *p = nasm_strcat(t->text, t->next->text); - nasm_free(t->text); - t->next = delete_Token(t->next); - t->text = p; - rescan = 1; - } - else if (t->next->type == TOK_WHITESPACE && t->next->next && - t->next->next->type == TOK_PREPROC_ID && - strcmp(t->next->next->text, "%+") == 0) - { - /* free the next whitespace, the %+ token and next whitespace */ - int i; - for (i = 1; i <= 3; i++) - { - if (!t->next || (i != 2 && t->next->type != TOK_WHITESPACE)) - break; - t->next = delete_Token(t->next); - } /* endfor */ - } - else - t = t->next; + while (t && t->type != TOK_ID && t->type != TOK_PREPROC_ID) + t = t->next; + if (!t || !t->next) + break; + if (t->next->type == TOK_ID || + t->next->type == TOK_PREPROC_ID || + t->next->type == TOK_NUMBER) + { + char *p = nasm_strcat(t->text, t->next->text); + nasm_free(t->text); + t->next = delete_Token(t->next); + t->text = p; + rescan = 1; + } + else if (t->next->type == TOK_WHITESPACE && t->next->next && + t->next->next->type == TOK_PREPROC_ID && + strcmp(t->next->next->text, "%+") == 0) + { + /* free the next whitespace, the %+ token and next whitespace */ + int i; + for (i = 1; i <= 3; i++) + { + if (!t->next || (i != 2 && t->next->type != TOK_WHITESPACE)) + break; + t->next = delete_Token(t->next); + } /* endfor */ + } + else + t = t->next; } /* If we concatenaded something, re-scan the line for macros */ if (rescan) { - tline = thead; - goto again; + tline = thead; + goto again; } if (org_tline) { - if (thead) - { - *org_tline = *thead; - /* since we just gave text to org_line, don't free it */ - thead->text = NULL; - delete_Token(thead); - } - else - { - /* the expression expanded to empty line; - we can't return NULL for some reasons - we just set the line to a single WHITESPACE token. */ - memset(org_tline, 0, sizeof(*org_tline)); - org_tline->text = NULL; - org_tline->type = TOK_WHITESPACE; - } - thead = org_tline; + if (thead) + { + *org_tline = *thead; + /* since we just gave text to org_line, don't free it */ + thead->text = NULL; + delete_Token(thead); + } + else + { + /* the expression expanded to empty line; + we can't return NULL for some reasons + we just set the line to a single WHITESPACE token. */ + memset(org_tline, 0, sizeof(*org_tline)); + org_tline->text = NULL; + org_tline->type = TOK_WHITESPACE; + } + thead = org_tline; } return thead; @@ -4494,12 +3828,12 @@ expand_smacro(Token * tline) * are more than one element forming the name, user wants a expansion, * otherwise it will be left as-is. Example: * - * %define %$abc cde + * %define %$abc cde * * the identifier %$abc will be left as-is so that the handler for %define * will suck it and define the corresponding value. Other case: * - * %define _%$abc cde + * %define _%$abc cde * * In this case user wants name to be expanded *before* %define starts * working, so we'll expand %$abc into something (if it has a value; @@ -4512,34 +3846,34 @@ expand_id(Token * tline) Token *cur, *oldnext = NULL; if (!tline || !tline->next) - return tline; + return tline; cur = tline; while (cur->next && - (cur->next->type == TOK_ID || - cur->next->type == TOK_PREPROC_ID || cur->next->type == TOK_NUMBER)) - cur = cur->next; + (cur->next->type == TOK_ID || + cur->next->type == TOK_PREPROC_ID || cur->next->type == TOK_NUMBER)) + cur = cur->next; /* If identifier consists of just one token, don't expand */ if (cur == tline) - return tline; + return tline; if (cur) { - oldnext = cur->next; /* Detach the tail past identifier */ - cur->next = NULL; /* so that expand_smacro stops here */ + oldnext = cur->next; /* Detach the tail past identifier */ + cur->next = NULL; /* so that expand_smacro stops here */ } tline = expand_smacro(tline); if (cur) { - /* expand_smacro possibly changhed tline; re-scan for EOL */ - cur = tline; - while (cur && cur->next) - cur = cur->next; - if (cur) - cur->next = oldnext; + /* expand_smacro possibly changhed tline; re-scan for EOL */ + cur = tline; + while (cur && cur->next) + cur = cur->next; + if (cur) + cur->next = oldnext; } return tline; @@ -4569,10 +3903,10 @@ is_mmacro(Token * tline, Token *** params_array) * list if necessary to find the proper MMacro. */ for (m = head; m; m = m->next) - if (!mstrcmp(m->name, tline->text, m->casesense)) - break; + if (!mstrcmp(m->name, tline->text, m->casesense)) + break; if (!m) - return NULL; + return NULL; /* * OK, we have a potential macro. Count and demarcate the @@ -4586,62 +3920,62 @@ is_mmacro(Token * tline, Token *** params_array) */ while (m) { - if (m->nparam_min <= nparam && (m->plus || nparam <= m->nparam_max)) - { - /* - * This one is right. Just check if cycle removal - * prohibits us using it before we actually celebrate... - */ - if (m->in_progress) - { + if (m->nparam_min <= nparam && (m->plus || nparam <= m->nparam_max)) + { + /* + * This one is right. Just check if cycle removal + * prohibits us using it before we actually celebrate... + */ + if (m->in_progress) + { #if 0 - error(ERR_NONFATAL, - "self-reference in multi-line macro `%s'", m->name); + error(ERR_NONFATAL, + "self-reference in multi-line macro `%s'", m->name); #endif - nasm_free(params); - return NULL; - } - /* - * It's right, and we can use it. Add its default - * parameters to the end of our list if necessary. - */ - if (m->defaults && nparam < m->nparam_min + m->ndefs) - { - params = - nasm_realloc(params, - ((m->nparam_min + m->ndefs + 1) * sizeof(*params))); - while (nparam < m->nparam_min + m->ndefs) - { - params[nparam] = m->defaults[nparam - m->nparam_min]; - nparam++; - } - } - /* - * If we've gone over the maximum parameter count (and - * we're in Plus mode), ignore parameters beyond - * nparam_max. - */ - if (m->plus && nparam > m->nparam_max) - nparam = m->nparam_max; - /* - * Then terminate the parameter list, and leave. - */ - if (!params) - { /* need this special case */ - params = nasm_malloc(sizeof(*params)); - nparam = 0; - } - params[nparam] = NULL; - *params_array = params; - return m; - } - /* - * This one wasn't right: look for the next one with the - * same name. - */ - for (m = m->next; m; m = m->next) - if (!mstrcmp(m->name, tline->text, m->casesense)) - break; + nasm_free(params); + return NULL; + } + /* + * It's right, and we can use it. Add its default + * parameters to the end of our list if necessary. + */ + if (m->defaults && nparam < m->nparam_min + m->ndefs) + { + params = + nasm_realloc(params, + ((m->nparam_min + m->ndefs + 1) * sizeof(*params))); + while (nparam < m->nparam_min + m->ndefs) + { + params[nparam] = m->defaults[nparam - m->nparam_min]; + nparam++; + } + } + /* + * If we've gone over the maximum parameter count (and + * we're in Plus mode), ignore parameters beyond + * nparam_max. + */ + if (m->plus && nparam > m->nparam_max) + nparam = m->nparam_max; + /* + * Then terminate the parameter list, and leave. + */ + if (!params) + { /* need this special case */ + params = nasm_malloc(sizeof(*params)); + nparam = 0; + } + params[nparam] = NULL; + *params_array = params; + return m; + } + /* + * This one wasn't right: look for the next one with the + * same name. + */ + for (m = m->next; m; m = m->next) + if (!mstrcmp(m->name, tline->text, m->casesense)) + break; } /* @@ -4649,8 +3983,8 @@ is_mmacro(Token * tline, Token *** params_array) * parameters. Issue a warning, and fail to expand the macro. */ error(ERR_WARNING | ERR_WARN_MNP, - "macro `%s' exists, but not taking %d parameters", - tline->text, nparam); + "macro `%s' exists, but not taking %d parameters", + tline->text, nparam); nasm_free(params); return NULL; } @@ -4676,32 +4010,32 @@ expand_mmacro(Token * tline) skip_white_(t); /* if (!tok_type_(t, TOK_ID)) Lino 02/25/02 */ if (!tok_type_(t, TOK_ID) && !tok_type_(t, TOK_PREPROC_ID)) - return 0; + return 0; m = is_mmacro(t, ¶ms); if (!m) { - Token *last; - /* - * We have an id which isn't a macro call. We'll assume - * it might be a label; we'll also check to see if a - * colon follows it. Then, if there's another id after - * that lot, we'll check it again for macro-hood. - */ - label = last = t; - t = t->next; - if (tok_type_(t, TOK_WHITESPACE)) - last = t, t = t->next; - if (tok_is_(t, ":")) - { - dont_prepend = 1; - last = t, t = t->next; - if (tok_type_(t, TOK_WHITESPACE)) - last = t, t = t->next; - } - if (!tok_type_(t, TOK_ID) || (m = is_mmacro(t, ¶ms)) == NULL) - return 0; - last->next = NULL; - tline = t; + Token *last; + /* + * We have an id which isn't a macro call. We'll assume + * it might be a label; we'll also check to see if a + * colon follows it. Then, if there's another id after + * that lot, we'll check it again for macro-hood. + */ + label = last = t; + t = t->next; + if (tok_type_(t, TOK_WHITESPACE)) + last = t, t = t->next; + if (tok_is_(t, ":")) + { + dont_prepend = 1; + last = t, t = t->next; + if (tok_type_(t, TOK_WHITESPACE)) + last = t, t = t->next; + } + if (!tok_type_(t, TOK_ID) || (m = is_mmacro(t, ¶ms)) == NULL) + return 0; + last->next = NULL; + tline = t; } /* @@ -4710,31 +4044,31 @@ expand_mmacro(Token * tline) * present. */ for (nparam = 0; params[nparam]; nparam++) - ; + ; paramlen = nparam ? nasm_malloc(nparam * sizeof(*paramlen)) : NULL; for (i = 0; params[i]; i++) { - int brace = FALSE; - int comma = (!m->plus || i < nparam - 1); + int brace = FALSE; + int comma = (!m->plus || i < nparam - 1); - t = params[i]; - skip_white_(t); - if (tok_is_(t, "{")) - t = t->next, brace = TRUE, comma = FALSE; - params[i] = t; - paramlen[i] = 0; - while (t) - { - if (comma && t->type == TOK_OTHER && !strcmp(t->text, ",")) - break; /* ... because we have hit a comma */ - if (comma && t->type == TOK_WHITESPACE && tok_is_(t->next, ",")) - break; /* ... or a space then a comma */ - if (brace && t->type == TOK_OTHER && !strcmp(t->text, "}")) - break; /* ... or a brace */ - t = t->next; - paramlen[i]++; - } + t = params[i]; + skip_white_(t); + if (tok_is_(t, "{")) + t = t->next, brace = TRUE, comma = FALSE; + params[i] = t; + paramlen[i] = 0; + while (t) + { + if (comma && t->type == TOK_OTHER && !strcmp(t->text, ",")) + break; /* ... because we have hit a comma */ + if (comma && t->type == TOK_WHITESPACE && tok_is_(t->next, ",")) + break; /* ... or a space then a comma */ + if (brace && t->type == TOK_OTHER && !strcmp(t->text, "}")) + break; /* ... or a brace */ + t = t->next; + paramlen[i]++; + } } /* @@ -4770,29 +4104,29 @@ expand_mmacro(Token * tline) for (l = m->expansion; l; l = l->next) { - Token **tail; + Token **tail; - ll = nasm_malloc(sizeof(Line)); - ll->finishes = NULL; - ll->next = istk->expansion; - istk->expansion = ll; - tail = &ll->first; + ll = nasm_malloc(sizeof(Line)); + ll->finishes = NULL; + ll->next = istk->expansion; + istk->expansion = ll; + tail = &ll->first; - for (t = l->first; t; t = t->next) - { - Token *x = t; - if (t->type == TOK_PREPROC_ID && - t->text[1] == '0' && t->text[2] == '0') - { - dont_prepend = -1; - x = label; - if (!x) - continue; - } - tt = *tail = new_Token(NULL, x->type, x->text, 0); - tail = &tt->next; - } - *tail = NULL; + for (t = l->first; t; t = t->next) + { + Token *x = t; + if (t->type == TOK_PREPROC_ID && + t->text[1] == '0' && t->text[2] == '0') + { + dont_prepend = -1; + x = label; + if (!x) + continue; + } + tt = *tail = new_Token(NULL, x->type, x->text, 0); + tail = &tt->next; + } + *tail = NULL; } /* @@ -4801,22 +4135,22 @@ expand_mmacro(Token * tline) */ if (label) { - if (dont_prepend < 0) - free_tlist(startline); - else - { - ll = nasm_malloc(sizeof(Line)); - ll->finishes = NULL; - ll->next = istk->expansion; - istk->expansion = ll; - ll->first = startline; - if (!dont_prepend) - { - while (label->next) - label = label->next; - label->next = tt = new_Token(NULL, TOK_OTHER, ":", 0); - } - } + if (dont_prepend < 0) + free_tlist(startline); + else + { + ll = nasm_malloc(sizeof(Line)); + ll->finishes = NULL; + ll->next = istk->expansion; + istk->expansion = ll; + ll->first = startline; + if (!dont_prepend) + { + while (label->next) + label = label->next; + label->next = tt = new_Token(NULL, TOK_OTHER, ":", 0); + } + } } list->uplevel(m->nolist ? LIST_MACRO_NOLIST : LIST_MACRO); @@ -4825,8 +4159,8 @@ expand_mmacro(Token * tline) } /* - * Since preprocessor always operates only on the line that didn't - * arrive yet, we should always use ERR_OFFBY1. Also since user + * Since preprocessor always operate only on the line that didn't + * arrived yet, we should always use ERR_OFFBY1. Also since user * won't want to see same error twice (preprocessing is done once * per pass) we will want to show errors only during pass one. */ @@ -4838,26 +4172,22 @@ error(int severity, const char *fmt, ...) /* If we're in a dead branch of IF or something like it, ignore the error */ if (istk && istk->conds && !emitting(istk->conds->state)) - return; + return; va_start(arg, fmt); -#ifdef HAVE_VSNPRINTF - vsnprintf(buff, sizeof(buff), fmt, arg); -#else vsprintf(buff, fmt, arg); -#endif va_end(arg); if (istk && istk->mstk && istk->mstk->name) - _error(severity | ERR_PASS1, "(%s:%d) %s", istk->mstk->name, - istk->mstk->lineno, buff); + _error(severity | ERR_PASS1, "(%s:%d) %s", istk->mstk->name, + istk->mstk->lineno, buff); else - _error(severity | ERR_PASS1, "%s", buff); + _error(severity | ERR_PASS1, "%s", buff); } static void pp_reset(FILE *f, const char *file, int apass, efunc errfunc, evalfunc eval, - ListGen * listgen) + ListGen * listgen) { int h; @@ -4879,46 +4209,19 @@ pp_reset(FILE *f, const char *file, int apass, efunc errfunc, evalfunc eval, nested_rep_count = 0; for (h = 0; h < NHASH; h++) { - mmacros[h] = NULL; - smacros[h] = NULL; + mmacros[h] = NULL; + smacros[h] = NULL; } unique = 0; - if (tasm_compatible_mode) { - pp_extra_stdmac(tasm_compat_macros); - } + if (tasm_compatible_mode) { + stdmacpos = stdmac; + } else { + stdmacpos = &stdmac[TASM_MACRO_COUNT]; + } + any_extrastdmac = (extrastdmac != NULL); list = listgen; evaluate = eval; pass = apass; - first_line = 1; -} - -/* - * Nasty hack: here we push the contents of `predef' on - * to the top-level expansion stack, since this is the - * most convenient way to implement the pre-include and - * pre-define features. - */ -static void -poke_predef(Line *predef_lines) -{ - Line *pd, *l; - Token *head, **tail, *t; - - for (pd = predef_lines; pd; pd = pd->next) - { - head = NULL; - tail = &head; - for (t = pd->first; t; t = t->next) - { - *tail = new_Token(NULL, t->type, t->text, 0); - tail = &(*tail)->next; - } - l = nasm_malloc(sizeof(Line)); - l->next = istk->expansion; - l->first = head; - l->finishes = FALSE; - istk->expansion = l; - } } static char * @@ -4929,240 +4232,224 @@ pp_getline(void) while (1) { - /* - * Fetch a tokenised line, either from the macro-expansion - * buffer or from the input file. - */ - tline = NULL; + /* + * Fetch a tokenised line, either from the macro-expansion + * buffer or from the input file. + */ + tline = NULL; + while (istk->expansion && istk->expansion->finishes) + { + Line *l = istk->expansion; + if (!l->finishes->name && l->finishes->in_progress > 1) + { + Line *ll; - if (first_line) - { - /* Reverse order */ - poke_predef(predef); - poke_predef(stddef); - poke_predef(builtindef); - first_line = 0; - } + /* + * This is a macro-end marker for a macro with no + * name, which means it's not really a macro at all + * but a %rep block, and the `in_progress' field is + * more than 1, meaning that we still need to + * repeat. (1 means the natural last repetition; 0 + * means termination by %exitrep.) We have + * therefore expanded up to the %endrep, and must + * push the whole block on to the expansion buffer + * again. We don't bother to remove the macro-end + * marker: we'd only have to generate another one + * if we did. + */ + l->finishes->in_progress--; + for (l = l->finishes->expansion; l; l = l->next) + { + Token *t, *tt, **tail; - if (!istk) - return NULL; - while (istk->expansion && istk->expansion->finishes) - { - Line *l = istk->expansion; - if (!l->finishes->name && l->finishes->in_progress > 1) - { - Line *ll; + ll = nasm_malloc(sizeof(Line)); + ll->next = istk->expansion; + ll->finishes = NULL; + ll->first = NULL; + tail = &ll->first; - /* - * This is a macro-end marker for a macro with no - * name, which means it's not really a macro at all - * but a %rep block, and the `in_progress' field is - * more than 1, meaning that we still need to - * repeat. (1 means the natural last repetition; 0 - * means termination by %exitrep.) We have - * therefore expanded up to the %endrep, and must - * push the whole block on to the expansion buffer - * again. We don't bother to remove the macro-end - * marker: we'd only have to generate another one - * if we did. - */ - l->finishes->in_progress--; - for (l = l->finishes->expansion; l; l = l->next) - { - Token *t, *tt, **tail; + for (t = l->first; t; t = t->next) + { + if (t->text || t->type == TOK_WHITESPACE) + { + tt = *tail = new_Token(NULL, t->type, t->text, 0); + tail = &tt->next; + } + } - ll = nasm_malloc(sizeof(Line)); - ll->next = istk->expansion; - ll->finishes = NULL; - ll->first = NULL; - tail = &ll->first; + istk->expansion = ll; + } + } + else + { + /* + * Check whether a `%rep' was started and not ended + * within this macro expansion. This can happen and + * should be detected. It's a fatal error because + * I'm too confused to work out how to recover + * sensibly from it. + */ + if (defining) + { + if (defining->name) + error(ERR_PANIC, "defining with name in expansion"); + else if (istk->mstk->name) + error(ERR_FATAL, "`%%rep' without `%%endrep' within" + " expansion of macro `%s'", istk->mstk->name); + } - for (t = l->first; t; t = t->next) - { - if (t->text || t->type == TOK_WHITESPACE) - { - tt = *tail = new_Token(NULL, t->type, t->text, 0); - tail = &tt->next; - } - } + /* + * FIXME: investigate the relationship at this point between + * istk->mstk and l->finishes + */ + { + MMacro *m = istk->mstk; + istk->mstk = m->next_active; + if (m->name) + { + /* + * This was a real macro call, not a %rep, and + * therefore the parameter information needs to + * be freed. + */ + nasm_free(m->params); + free_tlist(m->iline); + nasm_free(m->paramlen); + l->finishes->in_progress = FALSE; + } + else + free_mmacro(m); + } + istk->expansion = l->next; + nasm_free(l); + list->downlevel(LIST_MACRO); + } + } + while (1) + { /* until we get a line we can use */ - istk->expansion = ll; - } - } - else - { - /* - * Check whether a `%rep' was started and not ended - * within this macro expansion. This can happen and - * should be detected. It's a fatal error because - * I'm too confused to work out how to recover - * sensibly from it. - */ - if (defining) - { - if (defining->name) - error(ERR_PANIC, "defining with name in expansion"); - else if (istk->mstk->name) - error(ERR_FATAL, "`%%rep' without `%%endrep' within" - " expansion of macro `%s'", istk->mstk->name); - } + if (istk->expansion) + { /* from a macro expansion */ + char *p; + Line *l = istk->expansion; + if (istk->mstk) + istk->mstk->lineno++; + tline = l->first; + istk->expansion = l->next; + nasm_free(l); + p = detoken(tline, FALSE); + list->line(LIST_MACRO, p); + nasm_free(p); + break; + } + line = read_line(); + if (line) + { /* from the current input file */ + line = prepreproc(line); + tline = tokenise(line); + nasm_free(line); + break; + } + /* + * The current file has ended; work down the istk + */ + { + Include *i = istk; + if (i->fp != first_fp) + fclose(i->fp); + if (i->conds) + error(ERR_FATAL, "expected `%%endif' before end of file"); + /* only set line and file name if there's a next node */ + if (i->next) + { + nasm_src_set_linnum(i->lineno); + nasm_free(nasm_src_set_fname(nasm_strdup(i->fname))); + } + istk = i->next; + list->downlevel(LIST_INCLUDE); + nasm_free(i); + if (!istk) + return NULL; + if (istk->expansion && istk->expansion->finishes) + break; + } + } - /* - * FIXME: investigate the relationship at this point between - * istk->mstk and l->finishes - */ - { - MMacro *m = istk->mstk; - istk->mstk = m->next_active; - if (m->name) - { - /* - * This was a real macro call, not a %rep, and - * therefore the parameter information needs to - * be freed. - */ - nasm_free(m->params); - free_tlist(m->iline); - nasm_free(m->paramlen); - l->finishes->in_progress = FALSE; - } - else - free_mmacro(m); - } - istk->expansion = l->next; - nasm_free(l); - list->downlevel(LIST_MACRO); - } - } - while (1) - { /* until we get a line we can use */ + /* + * We must expand MMacro parameters and MMacro-local labels + * _before_ we plunge into directive processing, to cope + * with things like `%define something %1' such as STRUC + * uses. Unless we're _defining_ a MMacro, in which case + * those tokens should be left alone to go into the + * definition; and unless we're in a non-emitting + * condition, in which case we don't want to meddle with + * anything. + */ + if (!defining && !(istk->conds && !emitting(istk->conds->state))) + tline = expand_mmac_params(tline); - if (istk->expansion) - { /* from a macro expansion */ - char *p; - Line *l = istk->expansion; - if (istk->mstk) - istk->mstk->lineno++; - tline = l->first; - istk->expansion = l->next; - nasm_free(l); - p = detoken(tline, FALSE); - list->line(LIST_MACRO, p); - nasm_free(p); - break; - } - line = read_line(); - if (line) - { /* from the current input file */ - line = prepreproc(line); - tline = tokenise(line); - nasm_free(line); - break; - } - /* - * The current file has ended; work down the istk - */ - { - Include *i = istk; - if (i->fp != first_fp) - fclose(i->fp); - if (i->conds) - error(ERR_FATAL, "expected `%%endif' before end of file"); - /* only set line and file name if there's a next node */ - if (i->next) - { - nasm_src_set_linnum(i->lineno); - nasm_free(nasm_src_set_fname(nasm_strdup(i->fname))); - } - istk = i->next; - list->downlevel(LIST_INCLUDE); - nasm_free(i->fname); - nasm_free(i); - if (!istk) - return NULL; - if (istk->expansion && istk->expansion->finishes) - break; - } - } - - /* - * We must expand MMacro parameters and MMacro-local labels - * _before_ we plunge into directive processing, to cope - * with things like `%define something %1' such as STRUC - * uses. Unless we're _defining_ a MMacro, in which case - * those tokens should be left alone to go into the - * definition; and unless we're in a non-emitting - * condition, in which case we don't want to meddle with - * anything. - */ - if (!defining && !(istk->conds && !emitting(istk->conds->state))) - tline = expand_mmac_params(tline); - - /* - * Check the line to see if it's a preprocessor directive. - */ - if (do_directive(tline) == DIRECTIVE_FOUND) - { - continue; - } - else if (defining) - { - /* - * We're defining a multi-line macro. We emit nothing - * at all, and just - * shove the tokenised line on to the macro definition. - */ - Line *l = nasm_malloc(sizeof(Line)); - l->next = defining->expansion; - l->first = tline; - l->finishes = FALSE; - defining->expansion = l; - continue; - } - else if (istk->conds && !emitting(istk->conds->state)) - { - /* - * We're in a non-emitting branch of a condition block. - * Emit nothing at all, not even a blank line: when we - * emerge from the condition we'll give a line-number - * directive so we keep our place correctly. - */ - free_tlist(tline); - continue; - } - else if (istk->mstk && !istk->mstk->in_progress) - { - /* - * We're in a %rep block which has been terminated, so - * we're walking through to the %endrep without - * emitting anything. Emit nothing at all, not even a - * blank line: when we emerge from the %rep block we'll - * give a line-number directive so we keep our place - * correctly. - */ - free_tlist(tline); - continue; - } - else - { - tline = expand_smacro(tline); - if (!expand_mmacro(tline)) - { - /* - * De-tokenise the line again, and emit it. - */ - if (tasm_compatible_mode) - tline = tasm_join_tokens(tline); - - line = detoken(tline, TRUE); - free_tlist(tline); - break; - } - else - { - continue; /* expand_mmacro calls free_tlist */ - } - } + /* + * Check the line to see if it's a preprocessor directive. + */ + if (do_directive(tline) == DIRECTIVE_FOUND) + { + continue; + } + else if (defining) + { + /* + * We're defining a multi-line macro. We emit nothing + * at all, and just + * shove the tokenised line on to the macro definition. + */ + Line *l = nasm_malloc(sizeof(Line)); + l->next = defining->expansion; + l->first = tline; + l->finishes = FALSE; + defining->expansion = l; + continue; + } + else if (istk->conds && !emitting(istk->conds->state)) + { + /* + * We're in a non-emitting branch of a condition block. + * Emit nothing at all, not even a blank line: when we + * emerge from the condition we'll give a line-number + * directive so we keep our place correctly. + */ + free_tlist(tline); + continue; + } + else if (istk->mstk && !istk->mstk->in_progress) + { + /* + * We're in a %rep block which has been terminated, so + * we're walking through to the %endrep without + * emitting anything. Emit nothing at all, not even a + * blank line: when we emerge from the %rep block we'll + * give a line-number directive so we keep our place + * correctly. + */ + free_tlist(tline); + continue; + } + else + { + tline = expand_smacro(tline); + if (!expand_mmacro(tline)) + { + /* + * De-tokenise the line again, and emit it. + */ + line = detoken(tline, TRUE); + free_tlist(tline); + break; + } + else + { + continue; /* expand_mmacro calls free_tlist */ + } + } } return line; @@ -5173,59 +4460,48 @@ pp_cleanup(int pass_) { int h; - if (pass_ == 1) + if (defining) { - if (defining) - { - error(ERR_NONFATAL, "end of file while still defining macro `%s'", - defining->name); - free_mmacro(defining); - } - return; + error(ERR_NONFATAL, "end of file while still defining macro `%s'", + defining->name); + free_mmacro(defining); } while (cstk) - ctx_pop(); + ctx_pop(); for (h = 0; h < NHASH; h++) { - while (mmacros[h]) - { - MMacro *m = mmacros[h]; - mmacros[h] = mmacros[h]->next; - free_mmacro(m); - } - while (smacros[h]) - { - SMacro *s = smacros[h]; - smacros[h] = smacros[h]->next; - nasm_free(s->name); - free_tlist(s->expansion); - nasm_free(s); - } + while (mmacros[h]) + { + MMacro *m = mmacros[h]; + mmacros[h] = mmacros[h]->next; + free_mmacro(m); + } + while (smacros[h]) + { + SMacro *s = smacros[h]; + smacros[h] = smacros[h]->next; + nasm_free(s->name); + free_tlist(s->expansion); + nasm_free(s); + } } while (istk) { - Include *i = istk; - istk = istk->next; - if (i->fp != first_fp) - fclose(i->fp); - nasm_free(i->fname); - nasm_free(i); + Include *i = istk; + istk = istk->next; + if (i->fp != first_fp) + fclose(i->fp); + nasm_free(i->fname); + nasm_free(i); } while (cstk) - ctx_pop(); + ctx_pop(); if (pass_ == 0) - { - free_llist(builtindef); - free_llist(stddef); - free_llist(predef); - builtindef = NULL; - stddef = NULL; - predef = NULL; - freeTokens = NULL; - delete_Blocks(); - blocks.next = NULL; - blocks.chunk = NULL; - } + { + free_llist(builtindef); + free_llist(predef); + delete_Blocks(); + } } void @@ -5256,10 +4532,10 @@ pp_pre_define(char *definition) space = new_Token(NULL, TOK_WHITESPACE, NULL, 0); def = new_Token(space, TOK_PREPROC_ID, "%define", 0); if (equals) - *equals = ' '; + *equals = ' '; space->next = tokenise(definition); if (equals) - *equals = '='; + *equals = '='; l = nasm_malloc(sizeof(Line)); l->next = predef; @@ -5296,10 +4572,10 @@ pp_builtin_define(char *definition) space = new_Token(NULL, TOK_WHITESPACE, NULL, 0); def = new_Token(space, TOK_PREPROC_ID, "%define", 0); if (equals) - *equals = ' '; + *equals = ' '; space->next = tokenise(definition); if (equals) - *equals = '='; + *equals = '='; l = nasm_malloc(sizeof(Line)); l->next = builtindef; @@ -5311,24 +4587,7 @@ pp_builtin_define(char *definition) void pp_extra_stdmac(const char **macros) { - const char **lp; - - for (lp=macros; *lp; lp++) - { - char *macro; - Token *t; - Line *l; - - macro = nasm_strdup(*lp); - t = tokenise(macro); - nasm_free(macro); - - l = nasm_malloc(sizeof(Line)); - l->next = stddef; - l->first = t; - l->finishes = FALSE; - stddef = l; - } + extrastdmac = macros; } static void @@ -5336,7 +4595,6 @@ make_tok_num(Token * tok, yasm_intnum *val) { tok->text = yasm_intnum_get_str(val); tok->type = TOK_NUMBER; - yasm_intnum_destroy(val); } Preproc nasmpp = { diff --git a/modules/preprocs/nasm/nasm-preproc.c b/modules/preprocs/nasm/nasm-preproc.c index 75e60157..9db354dc 100644 --- a/modules/preprocs/nasm/nasm-preproc.c +++ b/modules/preprocs/nasm/nasm-preproc.c @@ -25,7 +25,9 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include +/*@unused@*/ RCSID("$Id$"); +#define YASM_LIB_INTERNAL #include #include "nasm.h" @@ -37,19 +39,15 @@ typedef struct yasm_preproc_nasm { yasm_preproc_base preproc; /* Base structure */ FILE *in; - char *line; + char *line, *linepos; + size_t lineleft; char *file_name; long prior_linnum; int lineinc; } yasm_preproc_nasm; -yasm_symtab *nasm_symtab; static yasm_linemap *cur_lm; static yasm_errwarns *cur_errwarns; int tasm_compatible_mode = 0; -int tasm_locals; -const char *tasm_segment; - -#include "nasm-version.c" typedef struct preproc_dep { STAILQ_ENTRY(preproc_dep) link; @@ -108,51 +106,40 @@ nasm_efunc(int severity, const char *fmt, ...) va_start(va, fmt); switch (severity & ERR_MASK) { - case ERR_WARNING: - yasm_warn_set_va(YASM_WARN_PREPROC, fmt, va); - break; - case ERR_NONFATAL: - yasm_error_set_va(YASM_ERROR_GENERAL, fmt, va); - break; - case ERR_FATAL: - yasm_fatal(fmt, va); - /*@notreached@*/ - break; - case ERR_PANIC: - yasm_internal_error(fmt); /* FIXME */ - break; - case ERR_DEBUG: - break; + case ERR_WARNING: + yasm_warn_set_va(YASM_WARN_PREPROC, fmt, va); + break; + case ERR_NONFATAL: + yasm_error_set_va(YASM_ERROR_GENERAL, fmt, va); + break; + case ERR_FATAL: + yasm_fatal(fmt, va); + /*@notreached@*/ + break; + case ERR_PANIC: + yasm_internal_error(fmt); /* FIXME */ + break; + case ERR_DEBUG: + break; } va_end(va); yasm_errwarn_propagate(cur_errwarns, - yasm_linemap_poke(cur_lm, nasm_src_get_fname(), - (unsigned long)nasm_src_get_linnum())); + yasm_linemap_poke(cur_lm, nasm_src_get_fname(), + (unsigned long)nasm_src_get_linnum())); } static yasm_preproc * -nasm_preproc_create(const char *in_filename, yasm_symtab *symtab, - yasm_linemap *lm, yasm_errwarns *errwarns) +nasm_preproc_create(FILE *f, const char *in_filename, yasm_linemap *lm, + yasm_errwarns *errwarns) { - FILE *f; yasm_preproc_nasm *preproc_nasm = yasm_xmalloc(sizeof(yasm_preproc_nasm)); preproc_nasm->preproc.module = &yasm_nasm_LTX_preproc; - if (strcmp(in_filename, "-") != 0) { - f = fopen(in_filename, "r"); - if (!f) - yasm__fatal( N_("Could not open input file") ); - } - else - f = stdin; - preproc_nasm->in = f; - nasm_symtab = symtab; cur_lm = lm; cur_errwarns = errwarns; - preproc_deps = yasm_xmalloc(sizeof(struct preproc_dep_head)); - STAILQ_INIT(preproc_deps); + preproc_deps = NULL; done_dep_preproc = 0; preproc_nasm->line = NULL; preproc_nasm->file_name = NULL; @@ -160,8 +147,6 @@ nasm_preproc_create(const char *in_filename, yasm_symtab *symtab, preproc_nasm->lineinc = 0; nasmpp.reset(f, in_filename, 2, nasm_efunc, nasm_evaluate, &nil_list); - pp_extra_stdmac(nasm_version_mac); - return (yasm_preproc *)preproc_nasm; } @@ -170,56 +155,61 @@ nasm_preproc_destroy(yasm_preproc *preproc) { yasm_preproc_nasm *preproc_nasm = (yasm_preproc_nasm *)preproc; nasmpp.cleanup(0); - if (preproc_nasm->line) - yasm_xfree(preproc_nasm->line); if (preproc_nasm->file_name) - yasm_xfree(preproc_nasm->file_name); - if (preproc_nasm->in) - fclose(preproc_nasm->in); + yasm_xfree(preproc_nasm->file_name); yasm_xfree(preproc); - while (!STAILQ_EMPTY(preproc_deps)) { - preproc_dep *dep = STAILQ_FIRST(preproc_deps); - STAILQ_REMOVE_HEAD(preproc_deps, link); - yasm_xfree(dep->name); - yasm_xfree(dep); - } - yasm_xfree(nasm_src_set_fname(NULL)); + if (preproc_deps) + yasm_xfree(preproc_deps); } -static char * -nasm_preproc_get_line(yasm_preproc *preproc) +static size_t +nasm_preproc_input(yasm_preproc *preproc, char *buf, size_t max_size) { yasm_preproc_nasm *preproc_nasm = (yasm_preproc_nasm *)preproc; - long linnum; + size_t tot = 0, n; + long linnum = preproc_nasm->prior_linnum += preproc_nasm->lineinc; int altline; - char *line; - if (preproc_nasm->line) { - char *retval = preproc_nasm->line; - preproc_nasm->line = NULL; - return retval; + if (!preproc_nasm->line) { + preproc_nasm->line = nasmpp.getline(); + if (!preproc_nasm->line) + return 0; + preproc_nasm->linepos = preproc_nasm->line; + preproc_nasm->lineleft = strlen(preproc_nasm->line) + 1; + preproc_nasm->line[preproc_nasm->lineleft-1] = '\n'; + + altline = nasm_src_get(&linnum, &preproc_nasm->file_name); + if (altline) { + if (altline == 1 && preproc_nasm->lineinc == 1) { + *buf++ = '\n'; + max_size--; + tot++; + } else { + preproc_nasm->lineinc = + (altline != -1 || preproc_nasm->lineinc != 1); + n = sprintf(buf, "%%line %ld+%d %s\n", linnum, + preproc_nasm->lineinc, preproc_nasm->file_name); + buf += n; + max_size -= n; + tot += n; + } + preproc_nasm->prior_linnum = linnum; + } } - line = nasmpp.getline(); - if (!line) - { - nasmpp.cleanup(1); - return NULL; /* EOF */ + n = preproc_nasm->lineleftlineleft:max_size; + strncpy(buf, preproc_nasm->linepos, n); + tot += n; + + if (n == preproc_nasm->lineleft) { + yasm_xfree(preproc_nasm->line); + preproc_nasm->line = NULL; + } else { + preproc_nasm->lineleft -= n; + preproc_nasm->linepos += n; } - linnum = preproc_nasm->prior_linnum += preproc_nasm->lineinc; - altline = nasm_src_get(&linnum, &preproc_nasm->file_name); - if (altline != 0) { - preproc_nasm->lineinc = - (altline != -1 || preproc_nasm->lineinc != 1); - preproc_nasm->line = line; - line = yasm_xmalloc(40+strlen(preproc_nasm->file_name)); - sprintf(line, "%%line %ld+%d %s", linnum, - preproc_nasm->lineinc, preproc_nasm->file_name); - preproc_nasm->prior_linnum = linnum; - } - - return line; + return tot; } void @@ -227,6 +217,10 @@ nasm_preproc_add_dep(char *name) { preproc_dep *dep; + /* If not processing dependencies, simply return */ + if (!preproc_deps) + return; + /* Save in preproc_deps */ dep = yasm_xmalloc(sizeof(preproc_dep)); dep->name = yasm__xstrdup(name); @@ -235,35 +229,40 @@ nasm_preproc_add_dep(char *name) static size_t nasm_preproc_get_included_file(yasm_preproc *preproc, /*@out@*/ char *buf, - size_t max_size) + size_t max_size) { + if (!preproc_deps) { + preproc_deps = yasm_xmalloc(sizeof(struct preproc_dep_head)); + STAILQ_INIT(preproc_deps); + } + for (;;) { - char *line; + char *line; - /* Pull first dep out of preproc_deps and return it if there is one */ - if (!STAILQ_EMPTY(preproc_deps)) { - char *name; - preproc_dep *dep = STAILQ_FIRST(preproc_deps); - STAILQ_REMOVE_HEAD(preproc_deps, link); - name = dep->name; - yasm_xfree(dep); - strncpy(buf, name, max_size); - buf[max_size-1] = '\0'; - yasm_xfree(name); - return strlen(buf); - } + /* Pull first dep out of preproc_deps and return it if there is one */ + if (!STAILQ_EMPTY(preproc_deps)) { + char *name; + preproc_dep *dep = STAILQ_FIRST(preproc_deps); + STAILQ_REMOVE_HEAD(preproc_deps, link); + name = dep->name; + yasm_xfree(dep); + strncpy(buf, name, max_size); + buf[max_size-1] = '\0'; + yasm_xfree(name); + return strlen(buf); + } - /* No more preprocessing to do */ - if (done_dep_preproc) { - return 0; - } + /* No more preprocessing to do */ + if (done_dep_preproc) { + return 0; + } - /* Preprocess some more, throwing away the result */ - line = nasmpp.getline(); - if (line) - yasm_xfree(line); - else - done_dep_preproc = 1; + /* Preprocess some more, throwing away the result */ + line = nasmpp.getline(); + if (line) + yasm_xfree(line); + else + done_dep_preproc = 1; } } @@ -297,45 +296,16 @@ nasm_preproc_define_builtin(yasm_preproc *preproc, const char *macronameval) yasm_xfree(mnv); } -static void -nasm_preproc_add_standard(yasm_preproc *preproc, const char **macros) -{ - pp_extra_stdmac(macros); -} - /* Define preproc structure -- see preproc.h for details */ yasm_preproc_module yasm_nasm_LTX_preproc = { "Real NASM Preprocessor", "nasm", nasm_preproc_create, nasm_preproc_destroy, - nasm_preproc_get_line, + nasm_preproc_input, nasm_preproc_get_included_file, nasm_preproc_add_include_file, nasm_preproc_predefine_macro, nasm_preproc_undefine_macro, - nasm_preproc_define_builtin, - nasm_preproc_add_standard -}; - -static yasm_preproc * -tasm_preproc_create(const char *in_filename, yasm_symtab *symtab, - yasm_linemap *lm, yasm_errwarns *errwarns) -{ - tasm_compatible_mode = 1; - return nasm_preproc_create(in_filename, symtab, lm, errwarns); -} - -yasm_preproc_module yasm_tasm_LTX_preproc = { - "Real TASM Preprocessor", - "tasm", - tasm_preproc_create, - nasm_preproc_destroy, - nasm_preproc_get_line, - nasm_preproc_get_included_file, - nasm_preproc_add_include_file, - nasm_preproc_predefine_macro, - nasm_preproc_undefine_macro, - nasm_preproc_define_builtin, - nasm_preproc_add_standard + nasm_preproc_define_builtin }; diff --git a/modules/preprocs/nasm/nasm.h b/modules/preprocs/nasm/nasm.h index b3382ffe..9a83543a 100644 --- a/modules/preprocs/nasm/nasm.h +++ b/modules/preprocs/nasm/nasm.h @@ -15,7 +15,7 @@ #endif #ifndef FALSE -#define FALSE 0 /* comes in handy */ +#define FALSE 0 /* comes in handy */ #endif #ifndef TRUE #define TRUE 1 @@ -51,31 +51,31 @@ typedef void (*efunc) (int severity, const char *fmt, ...); * argument to an efunc. */ -#define ERR_DEBUG 0x00000008 /* put out debugging message */ -#define ERR_WARNING 0x00000000 /* warn only: no further action */ -#define ERR_NONFATAL 0x00000001 /* terminate assembly after phase */ -#define ERR_FATAL 0x00000002 /* instantly fatal: exit with error */ -#define ERR_PANIC 0x00000003 /* internal error: panic instantly - * and dump core for reference */ -#define ERR_MASK 0x0000000F /* mask off the above codes */ -#define ERR_NOFILE 0x00000010 /* don't give source file name/line */ -#define ERR_USAGE 0x00000020 /* print a usage message */ -#define ERR_PASS1 0x00000040 /* only print this error on pass one */ +#define ERR_DEBUG 0x00000008 /* put out debugging message */ +#define ERR_WARNING 0x00000000 /* warn only: no further action */ +#define ERR_NONFATAL 0x00000001 /* terminate assembly after phase */ +#define ERR_FATAL 0x00000002 /* instantly fatal: exit with error */ +#define ERR_PANIC 0x00000003 /* internal error: panic instantly + * and dump core for reference */ +#define ERR_MASK 0x0000000F /* mask off the above codes */ +#define ERR_NOFILE 0x00000010 /* don't give source file name/line */ +#define ERR_USAGE 0x00000020 /* print a usage message */ +#define ERR_PASS1 0x00000040 /* only print this error on pass one */ /* * These codes define specific types of suppressible warning. */ -#define ERR_WARN_MASK 0x0000FF00 /* the mask for this feature */ -#define ERR_WARN_SHR 8 /* how far to shift right */ +#define ERR_WARN_MASK 0x0000FF00 /* the mask for this feature */ +#define ERR_WARN_SHR 8 /* how far to shift right */ -#define ERR_WARN_MNP 0x00000100 /* macro-num-parameters warning */ -#define ERR_WARN_MSR 0x00000200 /* macro self-reference */ -#define ERR_WARN_OL 0x00000300 /* orphan label (no colon, and - * alone on line) */ -#define ERR_WARN_NOV 0x00000400 /* numeric overflow */ -#define ERR_WARN_GNUELF 0x00000500 /* using GNU ELF extensions */ -#define ERR_WARN_MAX 5 /* the highest numbered one */ +#define ERR_WARN_MNP 0x00000100 /* macro-num-parameters warning */ +#define ERR_WARN_MSR 0x00000200 /* macro self-reference */ +#define ERR_WARN_OL 0x00000300 /* orphan label (no colon, and + * alone on line) */ +#define ERR_WARN_NOV 0x00000400 /* numeric overflow */ +#define ERR_WARN_GNUELF 0x00000500 /* using GNU ELF extensions */ +#define ERR_WARN_MAX 5 /* the highest numbered one */ /* * ----------------------- @@ -162,21 +162,21 @@ typedef int (*scanner) (void *private_data, struct tokenval *tv); * Token types returned by the scanner, in addition to ordinary * ASCII character values, and zero for end-of-string. */ -enum { /* token types, other than chars */ - TOKEN_INVALID = -1, /* a placeholder value */ - TOKEN_EOS = 0, /* end of string */ +enum { /* token types, other than chars */ + TOKEN_INVALID = -1, /* a placeholder value */ + TOKEN_EOS = 0, /* end of string */ TOKEN_EQ = '=', TOKEN_GT = '>', TOKEN_LT = '<', /* aliases */ TOKEN_ID = 256, TOKEN_NUM, TOKEN_REG, TOKEN_INSN, /* major token types */ - TOKEN_ERRNUM, /* numeric constant with error in */ - TOKEN_HERE, TOKEN_BASE, /* $ and $$ */ - TOKEN_SPECIAL, /* BYTE, WORD, DWORD, FAR, NEAR, etc */ - TOKEN_PREFIX, /* A32, O16, LOCK, REPNZ, TIMES, etc */ - TOKEN_SHL, TOKEN_SHR, /* << and >> */ - TOKEN_SDIV, TOKEN_SMOD, /* // and %% */ + TOKEN_ERRNUM, /* numeric constant with error in */ + TOKEN_HERE, TOKEN_BASE, /* $ and $$ */ + TOKEN_SPECIAL, /* BYTE, WORD, DWORD, FAR, NEAR, etc */ + TOKEN_PREFIX, /* A32, O16, LOCK, REPNZ, TIMES, etc */ + TOKEN_SHL, TOKEN_SHR, /* << and >> */ + TOKEN_SDIV, TOKEN_SMOD, /* // and %% */ TOKEN_GE, TOKEN_LE, TOKEN_NE, /* >=, <= and <> (!= is same as <>) */ TOKEN_DBL_AND, TOKEN_DBL_OR, TOKEN_DBL_XOR, /* &&, || and ^^ */ - TOKEN_SEG, TOKEN_WRT, /* SEG and WRT */ - TOKEN_FLOAT /* floating-point constant */ + TOKEN_SEG, TOKEN_WRT, /* SEG and WRT */ + TOKEN_FLOAT /* floating-point constant */ }; /* @@ -199,7 +199,7 @@ enum { /* token types, other than chars */ */ #define CRITICAL 0x100 typedef yasm_expr *(*evalfunc) (scanner sc, void *scprivate, struct tokenval *tv, - int critical, efunc error); + int critical, efunc error); /* * Preprocessors ought to look like this: @@ -276,8 +276,5 @@ enum { #define elements(x) ( sizeof(x) / sizeof(*(x)) ) extern int tasm_compatible_mode; -extern int tasm_locals; -extern const char *tasm_segment; -const char *tasm_get_segment_register(const char *segment); #endif diff --git a/modules/preprocs/nasm/nasmlib.c b/modules/preprocs/nasm/nasmlib.c index 2ced9117..268aa287 100644 --- a/modules/preprocs/nasm/nasmlib.c +++ b/modules/preprocs/nasm/nasmlib.c @@ -1,4 +1,4 @@ -/* nasmlib.c library routines for the Netwide Assembler +/* nasmlib.c library routines for the Netwide Assembler * * The Netwide Assembler is copyright (C) 1996 Simon Tatham and * Julian Hall. All rights reserved. The software is @@ -12,7 +12,7 @@ #include "nasm.h" #include "nasmlib.h" -/*#include "insns.h"*/ /* For MAX_KEYWORD */ +/*#include "insns.h"*/ /* For MAX_KEYWORD */ #define lib_isnumchar(c) ( isalnum(c) || (c) == '$') #define numvalue(c) ((c)>='a' ? (c)-'a'+10 : (c)>='A' ? (c)-'A'+10 : (c)-'0') @@ -28,7 +28,7 @@ yasm_intnum *nasm_readnum (char *str, int *error) *error = FALSE; - while (isspace(*r)) r++; /* find start of number */ + while (isspace(*r)) r++; /* find start of number */ /* * If the number came from make_tok_num (as a result of an %assign), it @@ -36,8 +36,8 @@ yasm_intnum *nasm_readnum (char *str, int *error) */ if (*r == '-') { - r++; - sign = 1; + r++; + sign = 1; } q = r; @@ -50,17 +50,17 @@ yasm_intnum *nasm_readnum (char *str, int *error) * Otherwise, it's ordinary decimal. */ if (*r=='0' && (r[1]=='x' || r[1]=='X')) - radix = 16, r += 2; + radix = 16, r += 2; else if (*r=='$') - radix = 16, r++; + radix = 16, r++; else if (q[-1]=='H' || q[-1]=='h') - radix = 16 , q--; + radix = 16 , q--; else if (q[-1]=='Q' || q[-1]=='q' || q[-1]=='O' || q[-1]=='o') - radix = 8 , q--; + radix = 8 , q--; else if (q[-1]=='B' || q[-1]=='b') - radix = 2 , q--; + radix = 2 , q--; else - radix = 10; + radix = 10; /* * If this number has been found for us by something other than @@ -69,46 +69,46 @@ yasm_intnum *nasm_readnum (char *str, int *error) * now. */ if (r >= q) { - *error = TRUE; - return yasm_intnum_create_uint(0); + *error = TRUE; + return yasm_intnum_create_uint(0); } /* Check for valid number of that radix */ p = r; while (*p && p < q) { - if (*p<'0' || (*p>'9' && *p<'A') || (digit = numvalue(*p)) >= radix) - { - *error = TRUE; - return yasm_intnum_create_uint(0); - } - p++; + if (*p<'0' || (*p>'9' && *p<'A') || (digit = numvalue(*p)) >= radix) + { + *error = TRUE; + return yasm_intnum_create_uint(0); + } + p++; } /* Use intnum to actually do the conversion */ save = *q; *q = '\0'; switch (radix) { - case 2: - intn = yasm_intnum_create_bin(r); - break; - case 8: - intn = yasm_intnum_create_oct(r); - break; - case 10: - intn = yasm_intnum_create_dec(r); - break; - case 16: - intn = yasm_intnum_create_hex(r); - break; - default: - *error = TRUE; - intn = yasm_intnum_create_uint(0); - break; + case 2: + intn = yasm_intnum_create_bin(r); + break; + case 8: + intn = yasm_intnum_create_oct(r); + break; + case 10: + intn = yasm_intnum_create_dec(r); + break; + case 16: + intn = yasm_intnum_create_hex(r); + break; + default: + *error = TRUE; + intn = yasm_intnum_create_uint(0); + break; } *q = save; if (sign) - yasm_intnum_calc(intn, YASM_EXPR_NEG, NULL); + yasm_intnum_calc(intn, YASM_EXPR_NEG, NULL); return intn; } @@ -158,16 +158,16 @@ int nasm_src_get(long *xline, char **xname) { if (!file_name || !*xname || strcmp(*xname, file_name)) { - nasm_free(*xname); - *xname = file_name ? nasm_strdup(file_name) : NULL; - *xline = line_number; - return -2; + nasm_free(*xname); + *xname = file_name ? nasm_strdup(file_name) : NULL; + *xline = line_number; + return -2; } if (*xline != line_number) { - long tmp = line_number - *xline; - *xline = line_number; - return tmp; + long tmp = line_number - *xline; + *xline = line_number; + return tmp; } return 0; } @@ -178,10 +178,10 @@ void nasm_quote(char **str) char q=(*str)[0]; char *p; if (ln>1 && (*str)[ln-1]==q && (q=='"' || q=='\'')) - return; + return; q = '"'; if (strchr(*str,q)) - q = '\''; + q = '\''; p = nasm_malloc(ln+3); strcpy(p+1, *str); nasm_free(*str); diff --git a/modules/preprocs/nasm/nasmlib.h b/modules/preprocs/nasm/nasmlib.h index c26c0668..a14f64b4 100644 --- a/modules/preprocs/nasm/nasmlib.h +++ b/modules/preprocs/nasm/nasmlib.h @@ -1,4 +1,4 @@ -/* nasmlib.h header file for nasmlib.c +/* nasmlib.h header file for nasmlib.c * * The Netwide Assembler is copyright (C) 1996 Simon Tatham and * Julian Hall. All rights reserved. The software is diff --git a/modules/preprocs/nasm/standard.mac b/modules/preprocs/nasm/standard.mac new file mode 100644 index 00000000..6d285d9e --- /dev/null +++ b/modules/preprocs/nasm/standard.mac @@ -0,0 +1,285 @@ +; Standard macro set for NASM -*- nasm -*- + +; Macros to make NASM ignore some TASM directives before the first include +; directive. + + %idefine IDEAL + %idefine JUMPS + %idefine P386 + %idefine P486 + %idefine P586 + %idefine END + +; This is a magic token which indicates the end of the TASM macros +*END*TASM*MACROS* + +; Note that although some user-level forms of directives are defined +; here, not all of them are: the user-level form of a format-specific +; directive should be defined in the module for that directive. + +; These two need to be defined, though the actual definitions will +; be constantly updated during preprocessing. +%define __FILE__ +%define __LINE__ + +%define __SECT__ [section .text] ; it ought to be defined, even if as nothing + +%imacro section 1+.nolist +%define __SECT__ [section %1] + __SECT__ +%endmacro +%imacro segment 1+.nolist +%define __SECT__ [segment %1] + __SECT__ +%endmacro + +%imacro absolute 1+.nolist +%define __SECT__ [absolute %1] + __SECT__ +%endmacro + +%imacro struc 1.nolist +%push struc +%define %$strucname %1 +[absolute 0] +%$strucname: ; allow definition of `.member' to work sanely +%endmacro +%imacro endstruc 0.nolist +%{$strucname}_size: +%pop +__SECT__ +%endmacro + +%imacro istruc 1.nolist +%push istruc +%define %$strucname %1 +%$strucstart: +%endmacro +%imacro at 1-2+.nolist + times %1-($-%$strucstart) db 0 + %2 +%endmacro +%imacro iend 0.nolist + times %{$strucname}_size-($-%$strucstart) db 0 +%pop +%endmacro + +%imacro align 1-2+.nolist nop +%ifidni %2,nop + [align %1] +%else + times ($$-$) & ((%1)-1) %2 +%endif +%endmacro +%imacro alignb 1-2+.nolist resb 1 + times ($$-$) & ((%1)-1) %2 +%endmacro + +%imacro extern 1-*.nolist +%rep %0 +[extern %1] +%rotate 1 +%endrep +%endmacro + +%imacro bits 1+.nolist +[bits %1] +%endmacro + +%imacro use16 0.nolist +[bits 16] +%endmacro +%imacro use32 0.nolist +[bits 32] +%endmacro +%imacro use64 0.nolist +[bits 64] +%endmacro + +%imacro global 1-*.nolist +%rep %0 +[global %1] +%rotate 1 +%endrep +%endmacro + +%imacro common 1-*.nolist +%rep %0 +[common %1] +%rotate 1 +%endrep +%endmacro + +%imacro cpu 1+.nolist +[cpu %1] +%endmacro + +; NASM compatibility shim +%define __OUTPUT_FORMAT__ __YASM_OBJFMT__ + +%ifidn __YASM_OBJFMT__,bin +%imacro org 1+.nolist +[org %1] +%endmacro +%endif + +%ifidn __YASM_OBJFMT__,win32 +%imacro export 1+.nolist +[export %1] +%endmacro +%endif + +%ifidn __YASM_OBJFMT__,win64 +%define __YASM_WIN64__ +%endif + +%ifidn __YASM_OBJFMT__,x64 +%define __YASM_WIN64__ +%endif + +%ifdef __YASM_WIN64__ +%undef __YASM_WIN64__ + +%imacro export 1+.nolist +[export %1] +%endmacro + +; Raw exception handling operations +%imacro proc_frame 1+.nolist +%1: +[proc_frame %1] +%endmacro + +%if 0 +; Disable these as they're too closely named to the macroized ones. +; MASM needs a preceding . to use these, so it seems reasonable for +; us to similarly require the []. +%imacro pushreg 1.nolist +[pushreg %1] +%endmacro + +%imacro setframe 1-2.nolist +[setframe %1 %2] +%endmacro + +%imacro allocstack 1.nolist +[allocstack %1] +%endmacro + +%imacro savereg 2.nolist +[savereg %1 %2] +%endmacro + +%imacro savexmm128 2.nolist +[savexmm128 %1 %2] +%endmacro + +%imacro pushframe 0-1.nolist +[pushframe %1] +%endmacro + +%imacro endprolog 0.nolist +[endprolog] +%endmacro +%endif + +%imacro endproc_frame 0.nolist +[endproc_frame] +%endmacro + +; Complex (macro) exception handling operations +; Mimics many macros provided by MASM's macamd64.inc +%imacro push_reg 1 +push %1 +[pushreg %1] +%endmacro + +%imacro rex_push_reg 1 +db 0x48 +push %1 +[pushreg %1] +%endmacro + +%imacro push_eflags 0 +pushfq +[allocstack 8] +%endmacro + +%imacro rex_push_eflags 0 +db 0x48 +pushfq +[allocstack 8] +%endmacro + +%imacro alloc_stack 1 +sub rsp, %1 +[allocstack %1] +%endmacro + +%imacro save_reg 2 +mov [rsp+%2], %1 +[savereg %1 %2] +%endmacro + +%imacro save_xmm128 2 +movdqa [rsp+%2], %1 +[savexmm128 %1 %2] +%endmacro + +%imacro push_frame 0-1.nolist +[pushframe %1] +%endmacro + +%imacro set_frame 1-2 +%if %0==1 +mov %1, rsp +%else +lea %1, [rsp+%2] +%endif +[setframe %1 %2] +%endmacro + +%imacro end_prolog 0.nolist +[endprolog] +%endmacro + +%imacro end_prologue 0.nolist +[endprolog] +%endmacro + +%endif + +%ifidn __YASM_OBJFMT__,elf +%define __YASM_ELF__ +%endif + +%ifidn __YASM_OBJFMT__,elf32 +%define __YASM_ELF__ +%endif + +%ifidn __YASM_OBJFMT__,elf64 +%define __YASM_ELF__ +%endif + +%ifdef __YASM_ELF__ +%undef __YASM_ELF__ +%imacro type 1+.nolist +[type %1] +%endmacro +%imacro size 1+.nolist +[size %1] +%endmacro +%imacro weak 1+.nolist +[weak %1] +%endmacro +%endif + +%ifidn __YASM_OBJFMT__,rdf +%imacro library 1+.nolist +[library %1] +%endmacro +%imacro module 1+.nolist +[module %1] +%endmacro +%endif + diff --git a/modules/preprocs/nasm/tests/Makefile.inc b/modules/preprocs/nasm/tests/Makefile.inc index 3a6a8b60..6d7dcfb5 100644 --- a/modules/preprocs/nasm/tests/Makefile.inc +++ b/modules/preprocs/nasm/tests/Makefile.inc @@ -1,3 +1,5 @@ +# $Id$ + TESTS += modules/preprocs/nasm/tests/nasmpp_test.sh EXTRA_DIST += modules/preprocs/nasm/tests/nasmpp_test.sh @@ -7,20 +9,14 @@ EXTRA_DIST += modules/preprocs/nasm/tests/ifcritical-err.asm EXTRA_DIST += modules/preprocs/nasm/tests/ifcritical-err.errwarn EXTRA_DIST += modules/preprocs/nasm/tests/longline.asm EXTRA_DIST += modules/preprocs/nasm/tests/longline.hex -EXTRA_DIST += modules/preprocs/nasm/tests/macroeof-err.asm -EXTRA_DIST += modules/preprocs/nasm/tests/macroeof-err.errwarn EXTRA_DIST += modules/preprocs/nasm/tests/noinclude-err.asm EXTRA_DIST += modules/preprocs/nasm/tests/noinclude-err.errwarn EXTRA_DIST += modules/preprocs/nasm/tests/nasmpp-bigint.asm EXTRA_DIST += modules/preprocs/nasm/tests/nasmpp-bigint.hex EXTRA_DIST += modules/preprocs/nasm/tests/nasmpp-decimal.asm EXTRA_DIST += modules/preprocs/nasm/tests/nasmpp-decimal.hex -EXTRA_DIST += modules/preprocs/nasm/tests/nasmpp-invalidcc.asm -EXTRA_DIST += modules/preprocs/nasm/tests/nasmpp-invalidcc.errwarn EXTRA_DIST += modules/preprocs/nasm/tests/nasmpp-nested.asm EXTRA_DIST += modules/preprocs/nasm/tests/nasmpp-nested.errwarn EXTRA_DIST += modules/preprocs/nasm/tests/nasmpp-nested.hex EXTRA_DIST += modules/preprocs/nasm/tests/orgsect.asm EXTRA_DIST += modules/preprocs/nasm/tests/orgsect.hex -EXTRA_DIST += modules/preprocs/nasm/tests/scope-err.asm -EXTRA_DIST += modules/preprocs/nasm/tests/scope-err.errwarn diff --git a/modules/preprocs/nasm/tests/ifcritical-err.errwarn b/modules/preprocs/nasm/tests/ifcritical-err.errwarn index 73ca327c..9c617cf7 100644 --- a/modules/preprocs/nasm/tests/ifcritical-err.errwarn +++ b/modules/preprocs/nasm/tests/ifcritical-err.errwarn @@ -1 +1 @@ --:5: error: non-constant value given to `%if' +-:5: cannot reference symbol `teststringlen' in preprocessor diff --git a/modules/preprocs/nasm/tests/macroeof-err.asm b/modules/preprocs/nasm/tests/macroeof-err.asm deleted file mode 100644 index dd51488b..00000000 --- a/modules/preprocs/nasm/tests/macroeof-err.asm +++ /dev/null @@ -1 +0,0 @@ -%macro foo 0 diff --git a/modules/preprocs/nasm/tests/macroeof-err.errwarn b/modules/preprocs/nasm/tests/macroeof-err.errwarn deleted file mode 100644 index c92f71e4..00000000 --- a/modules/preprocs/nasm/tests/macroeof-err.errwarn +++ /dev/null @@ -1 +0,0 @@ --:1: error: end of file while still defining macro `foo' diff --git a/modules/preprocs/nasm/tests/nasmpp-invalidcc.asm b/modules/preprocs/nasm/tests/nasmpp-invalidcc.asm deleted file mode 100644 index 989fc3c8..00000000 --- a/modules/preprocs/nasm/tests/nasmpp-invalidcc.asm +++ /dev/null @@ -1,9 +0,0 @@ -%macro ret_if_cc 1-* - j%+2 %%skip - ret - j%-2 %%skip - ret - %%skip: -%endmacro - -ret_if_cc ne diff --git a/modules/preprocs/nasm/tests/nasmpp-invalidcc.errwarn b/modules/preprocs/nasm/tests/nasmpp-invalidcc.errwarn deleted file mode 100644 index 37670af2..00000000 --- a/modules/preprocs/nasm/tests/nasmpp-invalidcc.errwarn +++ /dev/null @@ -1,4 +0,0 @@ --:9: error: (ret_if_cc:1) macro parameter 2 is not a condition code --:9: error: instruction expected after label --:9: error: (ret_if_cc:3) macro parameter 2 is not a condition code --:9: error: instruction expected after label diff --git a/modules/preprocs/nasm/tests/nasmpp-nested.errwarn b/modules/preprocs/nasm/tests/nasmpp-nested.errwarn index 31839e33..4df49285 100644 --- a/modules/preprocs/nasm/tests/nasmpp-nested.errwarn +++ b/modules/preprocs/nasm/tests/nasmpp-nested.errwarn @@ -1,3 +1,3 @@ --:27: warning: (WORK_1:2) 4 --:28: warning: (WORK_2:2) 4 --:29: warning: (DONT_WORK_1:3) 4 4 +-:27: warning: (WORK_1:4) 4 +-:28: warning: (WORK_2:4) 4 +-:29: warning: (DONT_WORK_1:6) 4 4 diff --git a/modules/preprocs/nasm/tests/nasmpp_test.sh b/modules/preprocs/nasm/tests/nasmpp_test.sh index c55c4204..e8e07081 100755 --- a/modules/preprocs/nasm/tests/nasmpp_test.sh +++ b/modules/preprocs/nasm/tests/nasmpp_test.sh @@ -1,3 +1,4 @@ #! /bin/sh +# $Id$ ${srcdir}/out_test.sh nasmpp_test modules/preprocs/nasm/tests "nasm preproc" "-f bin" "" exit $? diff --git a/modules/preprocs/nasm/tests/scope-err.asm b/modules/preprocs/nasm/tests/scope-err.asm deleted file mode 100644 index 0359532f..00000000 --- a/modules/preprocs/nasm/tests/scope-err.asm +++ /dev/null @@ -1,13 +0,0 @@ -%define a b -%error a -%scope -%define a c -%error a -%scope -%define a d -%error a -%endscope -%error a -%endscope -%error a -%endscope diff --git a/modules/preprocs/nasm/tests/scope-err.errwarn b/modules/preprocs/nasm/tests/scope-err.errwarn deleted file mode 100644 index 32cea76c..00000000 --- a/modules/preprocs/nasm/tests/scope-err.errwarn +++ /dev/null @@ -1,6 +0,0 @@ --:2: warning: b --:5: warning: c --:8: warning: d --:10: warning: c --:12: warning: b --:13: error: `%endscope': already popped all levels diff --git a/modules/preprocs/raw/CMakeLists.txt b/modules/preprocs/raw/CMakeLists.txt deleted file mode 100644 index fc345386..00000000 --- a/modules/preprocs/raw/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -YASM_ADD_MODULE(preproc_raw - preprocs/raw/raw-preproc.c - ) diff --git a/modules/preprocs/raw/Makefile.inc b/modules/preprocs/raw/Makefile.inc index 5756ca91..ad3ae673 100644 --- a/modules/preprocs/raw/Makefile.inc +++ b/modules/preprocs/raw/Makefile.inc @@ -1,7 +1,5 @@ +# $Id$ + libyasm_a_SOURCES += modules/preprocs/raw/raw-preproc.c YASM_MODULES += preproc_raw - -EXTRA_DIST += modules/preprocs/raw/tests/Makefile.inc - -include modules/preprocs/raw/tests/Makefile.inc diff --git a/modules/preprocs/raw/raw-preproc.c b/modules/preprocs/raw/raw-preproc.c index 15fd7836..aaf04afe 100644 --- a/modules/preprocs/raw/raw-preproc.c +++ b/modules/preprocs/raw/raw-preproc.c @@ -25,15 +25,16 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include +/*@unused@*/ RCSID("$Id$"); +#define YASM_LIB_INTERNAL #include -#define BSIZE 512 - typedef struct yasm_preproc_raw { yasm_preproc_base preproc; /* base structure */ + int is_interactive; FILE *in; yasm_linemap *cur_lm; yasm_errwarns *errwarns; @@ -41,25 +42,21 @@ typedef struct yasm_preproc_raw { yasm_preproc_module yasm_raw_LTX_preproc; -static yasm_preproc * -raw_preproc_create(const char *in_filename, yasm_symtab *symtab, - yasm_linemap *lm, yasm_errwarns *errwarns) -{ - FILE *f; - yasm_preproc_raw *preproc_raw = yasm_xmalloc(sizeof(yasm_preproc_raw)); +int isatty(int); - if (strcmp(in_filename, "-") != 0) { - f = fopen(in_filename, "r"); - if (!f) - yasm__fatal( N_("Could not open input file") ); - } - else - f = stdin; +static yasm_preproc * +raw_preproc_create(FILE *f, const char *in_filename, yasm_linemap *lm, + yasm_errwarns *errwarns) +{ + yasm_preproc_raw *preproc_raw = yasm_xmalloc(sizeof(yasm_preproc_raw)); preproc_raw->preproc.module = &yasm_raw_LTX_preproc; preproc_raw->in = f; preproc_raw->cur_lm = lm; preproc_raw->errwarns = errwarns; + /*@-unrecog@*/ + preproc_raw->is_interactive = f ? (isatty(fileno(f)) > 0) : 0; + /*@=unrecog@*/ return (yasm_preproc *)preproc_raw; } @@ -70,53 +67,37 @@ raw_preproc_destroy(yasm_preproc *preproc) yasm_xfree(preproc); } -static char * -raw_preproc_get_line(yasm_preproc *preproc) +static size_t +raw_preproc_input(yasm_preproc *preproc, char *buf, size_t max_size) { yasm_preproc_raw *preproc_raw = (yasm_preproc_raw *)preproc; - int bufsize = BSIZE; - char *buf = yasm_xmalloc((size_t)bufsize); - char *p; + int c = '*'; + size_t n; - /* Loop to ensure entire line is read (don't want to limit line length). */ - p = buf; - for (;;) { - if (!fgets(p, bufsize-(p-buf), preproc_raw->in)) { - if (ferror(preproc_raw->in)) { - yasm_error_set(YASM_ERROR_IO, - N_("error when reading from file")); - yasm_errwarn_propagate(preproc_raw->errwarns, - yasm_linemap_get_current(preproc_raw->cur_lm)); - } - break; - } - p += strlen(p); - if (p > buf && p[-1] == '\n') - break; - if ((p-buf)+1 >= bufsize) { - /* Increase size of buffer */ - char *oldbuf = buf; - bufsize *= 2; - buf = yasm_xrealloc(buf, (size_t)bufsize); - p = buf + (p-oldbuf); - } + if (preproc_raw->is_interactive) { + for (n = 0; n < max_size && (c = getc(preproc_raw->in)) != EOF && + c != '\n'; n++) + buf[n] = (char)c; + if (c == '\n') + buf[n++] = (char)c; + if (c == EOF && ferror(preproc_raw->in)) { + yasm_error_set(YASM_ERROR_IO, N_("error when reading from file")); + yasm_errwarn_propagate(preproc_raw->errwarns, + yasm_linemap_get_current(preproc_raw->cur_lm)); + } + } else if (((n = fread(buf, 1, max_size, preproc_raw->in)) == 0) && + ferror(preproc_raw->in)) { + yasm_error_set(YASM_ERROR_IO, N_("error when reading from file")); + yasm_errwarn_propagate(preproc_raw->errwarns, + yasm_linemap_get_current(preproc_raw->cur_lm)); } - if (p == buf) { - /* No data; must be at EOF */ - yasm_xfree(buf); - return NULL; - } - - /* Strip the line ending */ - buf[strcspn(buf, "\r\n")] = '\0'; - - return buf; + return n; } static size_t raw_preproc_get_included_file(yasm_preproc *preproc, char *buf, - size_t max_size) + size_t max_size) { /* no included files */ return 0; @@ -146,12 +127,6 @@ raw_preproc_define_builtin(yasm_preproc *preproc, const char *macronameval) /* no builtin defines */ } -static void -raw_preproc_add_standard(yasm_preproc *preproc, const char **macros) -{ - /* no standard macros */ -} - /* Define preproc structure -- see preproc.h for details */ yasm_preproc_module yasm_raw_LTX_preproc = { @@ -159,11 +134,10 @@ yasm_preproc_module yasm_raw_LTX_preproc = { "raw", raw_preproc_create, raw_preproc_destroy, - raw_preproc_get_line, + raw_preproc_input, raw_preproc_get_included_file, raw_preproc_add_include_file, raw_preproc_predefine_macro, raw_preproc_undefine_macro, - raw_preproc_define_builtin, - raw_preproc_add_standard + raw_preproc_define_builtin }; diff --git a/modules/preprocs/raw/tests/Makefile.inc b/modules/preprocs/raw/tests/Makefile.inc deleted file mode 100644 index 82923d51..00000000 --- a/modules/preprocs/raw/tests/Makefile.inc +++ /dev/null @@ -1,5 +0,0 @@ -TESTS += modules/preprocs/raw/tests/rawpp_test.sh - -EXTRA_DIST += modules/preprocs/raw/tests/rawpp_test.sh -EXTRA_DIST += modules/preprocs/raw/tests/longline.asm -EXTRA_DIST += modules/preprocs/raw/tests/longline.hex diff --git a/modules/preprocs/raw/tests/longline.asm b/modules/preprocs/raw/tests/longline.asm deleted file mode 100644 index 2d5931a1..00000000 --- a/modules/preprocs/raw/tests/longline.asm +++ /dev/null @@ -1 +0,0 @@ -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa: diff --git a/modules/preprocs/raw/tests/longline.hex b/modules/preprocs/raw/tests/longline.hex deleted file mode 100644 index e69de29b..00000000 diff --git a/modules/preprocs/raw/tests/rawpp_test.sh b/modules/preprocs/raw/tests/rawpp_test.sh deleted file mode 100755 index 40339545..00000000 --- a/modules/preprocs/raw/tests/rawpp_test.sh +++ /dev/null @@ -1,3 +0,0 @@ -#! /bin/sh -${srcdir}/out_test.sh rawpp_test modules/preprocs/raw/tests "raw preproc" "-f bin -r raw" "" -exit $? diff --git a/modules/preprocs/tasm/Makefile.inc b/modules/preprocs/tasm/Makefile.inc deleted file mode 100644 index a9468351..00000000 --- a/modules/preprocs/tasm/Makefile.inc +++ /dev/null @@ -1,3 +0,0 @@ -EXTRA_DIST += modules/preprocs/tasm/tests/Makefile.inc - -include modules/preprocs/tasm/tests/Makefile.inc diff --git a/modules/preprocs/tasm/tests/Makefile.inc b/modules/preprocs/tasm/tests/Makefile.inc deleted file mode 100644 index e2d56c19..00000000 --- a/modules/preprocs/tasm/tests/Makefile.inc +++ /dev/null @@ -1,7 +0,0 @@ -TESTS += modules/preprocs/tasm/tests/tasmpp_test.sh - -EXTRA_DIST += modules/preprocs/tasm/tests/tasmpp_test.sh -EXTRA_DIST += modules/preprocs/tasm/tests/tasm-assume-comment.asm -EXTRA_DIST += modules/preprocs/tasm/tests/tasm-assume-comment.hex -EXTRA_DIST += modules/preprocs/tasm/tests/tasm-comment-instr.asm -EXTRA_DIST += modules/preprocs/tasm/tests/tasm-comment-instr.hex diff --git a/modules/preprocs/tasm/tests/tasm-assume-comment.asm b/modules/preprocs/tasm/tests/tasm-assume-comment.asm deleted file mode 100644 index 6b7cc1bf..00000000 --- a/modules/preprocs/tasm/tests/tasm-assume-comment.asm +++ /dev/null @@ -1,3 +0,0 @@ -assume cs:code,ds:code,es:code ; tiny model (CS=DS=ES) -assume ds:code,es:code; close comment -assume fs:code,gs:code diff --git a/modules/preprocs/tasm/tests/tasm-assume-comment.hex b/modules/preprocs/tasm/tests/tasm-assume-comment.hex deleted file mode 100644 index e69de29b..00000000 diff --git a/modules/preprocs/tasm/tests/tasm-comment-instr.asm b/modules/preprocs/tasm/tests/tasm-comment-instr.asm deleted file mode 100644 index d93001b1..00000000 --- a/modules/preprocs/tasm/tests/tasm-comment-instr.asm +++ /dev/null @@ -1 +0,0 @@ -ansi_normal db 0x27,'[0;40;37m$' diff --git a/modules/preprocs/tasm/tests/tasm-comment-instr.hex b/modules/preprocs/tasm/tests/tasm-comment-instr.hex deleted file mode 100644 index 594d68f0..00000000 --- a/modules/preprocs/tasm/tests/tasm-comment-instr.hex +++ /dev/null @@ -1,11 +0,0 @@ -27 -5b -30 -3b -34 -30 -3b -33 -37 -6d -24 diff --git a/modules/preprocs/tasm/tests/tasmpp_test.sh b/modules/preprocs/tasm/tests/tasmpp_test.sh deleted file mode 100755 index 622e5a07..00000000 --- a/modules/preprocs/tasm/tests/tasmpp_test.sh +++ /dev/null @@ -1,3 +0,0 @@ -#! /bin/sh -${srcdir}/out_test.sh tasmpp_test modules/preprocs/tasm/tests "tasm preproc" "-f bin -p tasm" "" -exit $? diff --git a/modules/preprocs/yapp/Makefile.inc b/modules/preprocs/yapp/Makefile.inc index 137fe2fb..e1659032 100644 --- a/modules/preprocs/yapp/Makefile.inc +++ b/modules/preprocs/yapp/Makefile.inc @@ -1,3 +1,5 @@ +# $Id$ + libyasm_a_SOURCES += modules/preprocs/yapp/yapp-preproc.c libyasm_a_SOURCES += modules/preprocs/yapp/yapp-preproc.h libyasm_a_SOURCES += modules/preprocs/yapp/yapp-token.h diff --git a/modules/preprocs/yapp/tests/Makefile.inc b/modules/preprocs/yapp/tests/Makefile.inc index 4ac216dc..7dd1285f 100644 --- a/modules/preprocs/yapp/tests/Makefile.inc +++ b/modules/preprocs/yapp/tests/Makefile.inc @@ -1,3 +1,5 @@ +# $IdPath$ + TESTS += modules/preprocs/yapp/tests/yapp_test.sh EXTRA_DIST += modules/preprocs/yapp/tests/Makefile.inc diff --git a/modules/preprocs/yapp/tests/yapp_test.sh b/modules/preprocs/yapp/tests/yapp_test.sh index 146d5ae6..53143850 100755 --- a/modules/preprocs/yapp/tests/yapp_test.sh +++ b/modules/preprocs/yapp/tests/yapp_test.sh @@ -1,4 +1,5 @@ #! /bin/sh +# $Id$ case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in *c*,-n*) ECHO_N= ECHO_C=' @@ -28,7 +29,7 @@ do og=`echo ${asm} | sed 's,.asm$,.pre,'` e=${a}.ew eg=`echo ${asm} | sed 's,.asm$,.errwarn,'` - if test \! -f ${eg}; then + if test \! -e ${eg}; then eg=/dev/null fi diff --git a/modules/preprocs/yapp/yapp-preproc.c b/modules/preprocs/yapp/yapp-preproc.c index ec91256e..257de213 100644 --- a/modules/preprocs/yapp/yapp-preproc.c +++ b/modules/preprocs/yapp/yapp-preproc.c @@ -25,7 +25,9 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include +/*@unused@*/ RCSID("$Id$"); +#define YASM_LIB_INTERNAL #include #include "yapp-preproc.h" @@ -34,7 +36,7 @@ #define ydebug(x) /* printf x */ typedef struct yasm_preproc_yapp { - yasm_preproc_base preproc; /* base structure */ + yasm_preproc_base preproc; /* base structure */ } yasm_preproc_yapp; yasm_preproc_module yasm_yapp_LTX_preproc; @@ -70,8 +72,8 @@ typedef struct YAPP_Macro_s { struct source_head macro_head; struct source_head param_head; enum { - YAPP_MACRO = 0, - YAPP_DEFINE + YAPP_MACRO = 0, + YAPP_DEFINE } type; int args; int fillargs; @@ -101,9 +103,9 @@ yapp_define_param_get (HAMT *hamt, const char *key); static void replay_saved_tokens(char *ident, - struct source_head *from_head, - struct source_head *to_head, - source **to_tail); + struct source_head *from_head, + struct source_head *to_head, + source **to_tail); YAPP_Macro * yapp_macro_insert (char *name, int argc, int fillargs) @@ -141,22 +143,22 @@ yapp_define_insert (char *name, int argc, int fillargs) ym = yapp_macro_get(name); if (ym) { - if ((argc >= 0 && ym->args < 0) - || (argc < 0 && ym->args >= 0)) - { - yasm_warn_set(YASM_WARN_PREPROC, N_("Attempted %%define both with and without parameters")); - return NULL; - } + if ((argc >= 0 && ym->args < 0) + || (argc < 0 && ym->args >= 0)) + { + yasm_warn_set(YASM_WARN_PREPROC, N_("Attempted %%define both with and without parameters")); + return NULL; + } } else if (argc >= 0) { - /* insert placeholder for paramlisted defines */ - ym = yasm_xmalloc(sizeof(YAPP_Macro)); - ym->type = YAPP_DEFINE; - ym->args = argc; - ym->fillargs = fillargs; - ym->expanding = 0; - HAMT_insert(macro_table, name, (void *)ym, &zero, (void (*)(void *))yapp_macro_error_exists); + /* insert placeholder for paramlisted defines */ + ym = yasm_xmalloc(sizeof(YAPP_Macro)); + ym->type = YAPP_DEFINE; + ym->args = argc; + ym->fillargs = fillargs; + ym->expanding = 0; + HAMT_insert(macro_table, name, (void *)ym, &zero, (void (*)(void *))yapp_macro_error_exists); } /* now for the real one */ @@ -167,8 +169,8 @@ yapp_define_insert (char *name, int argc, int fillargs) ym->expanding = 0; if (argc>=0) { - mungename = yasm_xmalloc(strlen(name)+8); - sprintf(mungename, "%s(%d)", name, argc); + mungename = yasm_xmalloc(strlen(name)+8); + sprintf(mungename, "%s(%d)", name, argc); } ydebug(("YAPP: +Inserting macro %s\n", mungename)); @@ -191,9 +193,9 @@ void yapp_macro_delete (YAPP_Macro *ym) { while (!SLIST_EMPTY(&ym->macro_head)) { - source *s = SLIST_FIRST(&ym->macro_head); - yasm_xfree(s); - SLIST_REMOVE_HEAD(&ym->macro_head, next); + source *s = SLIST_FIRST(&ym->macro_head); + yasm_xfree(s); + SLIST_REMOVE_HEAD(&ym->macro_head, next); } yasm_xfree(ym); } @@ -232,28 +234,19 @@ copy_token(YAPP_Token *tok, struct source_head *to_head, source **to_tail); void expand_macro(char *name, - struct source_head *from_head, - struct source_head *to_head, - source **to_tail); + struct source_head *from_head, + struct source_head *to_head, + source **to_tail); void expand_token_list(struct source_head *paramexp, struct source_head *to_head, source **to_tail); static yasm_preproc * -yapp_preproc_create(const char *in_filename, yasm_linemap *lm, - yasm_errwarns *errwarns) +yapp_preproc_create(FILE *f, const char *in_filename, yasm_linemap *lm, + yasm_errwarns *errwarns) { - FILE *f; yasm_preproc_yapp *preproc_yapp = yasm_xmalloc(sizeof(yasm_preproc_yapp)); - if (strcmp(in_filename, "-") != 0) { - f = fopen(in_filename, "r"); - if (!f) - yasm__fatal( N_("Could not open input file") ); - } - else - f = stdin; - preproc_yapp->preproc.module = &yasm_yapp_LTX_preproc; yapp_preproc_linemap = lm; @@ -299,15 +292,15 @@ push_if(int val) switch (current_output) { - case YAPP_OUTPUT: - current_output = val ? YAPP_OUTPUT : YAPP_NO_OUTPUT; - break; + case YAPP_OUTPUT: + current_output = val ? YAPP_OUTPUT : YAPP_NO_OUTPUT; + break; - case YAPP_NO_OUTPUT: - case YAPP_OLD_OUTPUT: - case YAPP_BLOCKED_OUTPUT: - current_output = YAPP_BLOCKED_OUTPUT; - break; + case YAPP_NO_OUTPUT: + case YAPP_OLD_OUTPUT: + case YAPP_BLOCKED_OUTPUT: + current_output = YAPP_BLOCKED_OUTPUT; + break; } if (current_output != YAPP_OUTPUT) set_inhibit(); @@ -322,20 +315,20 @@ push_else(int val) { switch (current_output) { - /* if it was NO, turn to output IFF val is true */ - case YAPP_NO_OUTPUT: - current_output = val ? YAPP_OUTPUT : YAPP_NO_OUTPUT; - break; + /* if it was NO, turn to output IFF val is true */ + case YAPP_NO_OUTPUT: + current_output = val ? YAPP_OUTPUT : YAPP_NO_OUTPUT; + break; - /* if it was yes, make it OLD */ - case YAPP_OUTPUT: - current_output = YAPP_OLD_OUTPUT; - break; + /* if it was yes, make it OLD */ + case YAPP_OUTPUT: + current_output = YAPP_OLD_OUTPUT; + break; - /* leave OLD as OLD, BLOCKED as BLOCKED */ - case YAPP_OLD_OUTPUT: - case YAPP_BLOCKED_OUTPUT: - break; + /* leave OLD as OLD, BLOCKED as BLOCKED */ + case YAPP_OLD_OUTPUT: + case YAPP_BLOCKED_OUTPUT: + break; } if (current_output != YAPP_OUTPUT) set_inhibit(); } @@ -371,82 +364,82 @@ append_processed_token(source *tok, struct source_head *to_head, source **to_tai { ydebug(("YAPP: appended token \"%s\"\n", tok->token.str)); if (*to_tail) { - SLIST_INSERT_AFTER(*to_tail, tok, next); + SLIST_INSERT_AFTER(*to_tail, tok, next); } else { - SLIST_INSERT_HEAD(to_head, tok, next); + SLIST_INSERT_HEAD(to_head, tok, next); } *to_tail = tok; if (to_head == &source_head) - saved_length += strlen(tok->token.str); + saved_length += strlen(tok->token.str); } void append_token(int token, struct source_head *to_head, source **to_tail) { if (current_output != YAPP_OUTPUT) { - ydebug(("YAPP: append_token while not YAPP_OUTPUT\n")); - return; + ydebug(("YAPP: append_token while not YAPP_OUTPUT\n")); + return; } /* attempt to condense LINES together or newlines onto LINES */ if ((*to_tail) && (*to_tail)->token.type == LINE - && (token == '\n' || token == LINE)) + && (token == '\n' || token == LINE)) { - yasm_xfree ((*to_tail)->token.str); - (*to_tail)->token.str = yasm_xmalloc(23+strlen(yapp_preproc_current_file)); - sprintf((*to_tail)->token.str, "%%line %d+1 %s\n", yapp_preproc_line_number, yapp_preproc_current_file); + yasm_xfree ((*to_tail)->token.str); + (*to_tail)->token.str = yasm_xmalloc(23+strlen(yapp_preproc_current_file)); + sprintf((*to_tail)->token.str, "%%line %d+1 %s\n", yapp_preproc_line_number, yapp_preproc_current_file); } else { - src = yasm_xmalloc(sizeof(source)); - src->token.type = token; - switch (token) - { - case INTNUM: - src->token.str = yasm__xstrdup(yapp_preproc_lval.int_str_val.str); - src->token.val.int_val = yapp_preproc_lval.int_str_val.val; - break; + src = yasm_xmalloc(sizeof(source)); + src->token.type = token; + switch (token) + { + case INTNUM: + src->token.str = yasm__xstrdup(yapp_preproc_lval.int_str_val.str); + src->token.val.int_val = yapp_preproc_lval.int_str_val.val; + break; - case FLTNUM: - src->token.str = yasm__xstrdup(yapp_preproc_lval.double_str_val.str); - src->token.val.double_val = yapp_preproc_lval.double_str_val.val; - break; + case FLTNUM: + src->token.str = yasm__xstrdup(yapp_preproc_lval.double_str_val.str); + src->token.val.double_val = yapp_preproc_lval.double_str_val.val; + break; - case STRING: - case WHITESPACE: - src->token.str = yasm__xstrdup(yapp_preproc_lval.str_val); - break; + case STRING: + case WHITESPACE: + src->token.str = yasm__xstrdup(yapp_preproc_lval.str_val); + break; - case IDENT: - src->token.str = yasm__xstrdup(yapp_preproc_lval.str_val); - break; + case IDENT: + src->token.str = yasm__xstrdup(yapp_preproc_lval.str_val); + break; - case '+': case '-': case '*': case '/': case '%': case ',': case '\n': - case '[': case ']': case '(': case ')': - src->token.str = yasm_xmalloc(2); - src->token.str[0] = (char)token; - src->token.str[1] = '\0'; - break; + case '+': case '-': case '*': case '/': case '%': case ',': case '\n': + case '[': case ']': case '(': case ')': + src->token.str = yasm_xmalloc(2); + src->token.str[0] = (char)token; + src->token.str[1] = '\0'; + break; - case LINE: - /* TODO: consider removing any trailing newline or LINE tokens */ - src->token.str = yasm_xmalloc(23+strlen(yapp_preproc_current_file)); - sprintf(src->token.str, "%%line %d+1 %s\n", yapp_preproc_line_number, yapp_preproc_current_file); - break; + case LINE: + /* TODO: consider removing any trailing newline or LINE tokens */ + src->token.str = yasm_xmalloc(23+strlen(yapp_preproc_current_file)); + sprintf(src->token.str, "%%line %d+1 %s\n", yapp_preproc_line_number, yapp_preproc_current_file); + break; - default: - yasm_xfree(src); - return; - } - append_processed_token(src, to_head, to_tail); + default: + yasm_xfree(src); + return; + } + append_processed_token(src, to_head, to_tail); } } static void replay_saved_tokens(char *ident, - struct source_head *from_head, - struct source_head *to_head, - source **to_tail) + struct source_head *from_head, + struct source_head *to_head, + source **to_tail) { source *item, *after; ydebug(("-No, %s didn't match any macro we have\n", ident)); @@ -457,11 +450,11 @@ replay_saved_tokens(char *ident, item = SLIST_FIRST(from_head); while (item) { - after = SLIST_NEXT(item, next); - SLIST_INSERT_AFTER(*to_tail, item, next); - *to_tail = item; - saved_length += strlen(item->token.str); - item = after; + after = SLIST_NEXT(item, next); + SLIST_INSERT_AFTER(*to_tail, item, next); + *to_tail = item; + saved_length += strlen(item->token.str); + item = after; } SLIST_INIT(from_head); } @@ -471,12 +464,12 @@ append_to_return(struct source_head *to_head, source **to_tail) { int token = yapp_preproc_lex(); while (token != '\n') { - ydebug(("YAPP: ATR: '%c' \"%s\"\n", token, yapp_preproc_lval.str_val)); - if (token == 0) - return 0; - append_token(token, to_head, to_tail); - token = yapp_preproc_lex(); - } + ydebug(("YAPP: ATR: '%c' \"%s\"\n", token, yapp_preproc_lval.str_val)); + if (token == 0) + return 0; + append_token(token, to_head, to_tail); + token = yapp_preproc_lex(); + } return '\n'; } @@ -485,10 +478,10 @@ eat_through_return(struct source_head *to_head, source **to_tail) { int token; while ((token = yapp_preproc_lex()) != '\n') { - if (token == 0) - return 0; - yasm_error_set(YASM_ERROR_SYNTAX, - N_("Skipping possibly valid %%define stuff")); + if (token == 0) + return 0; + yasm_error_set(YASM_ERROR_SYNTAX, + N_("Skipping possibly valid %%define stuff")); } append_token('\n', to_head, to_tail); return '\n'; @@ -499,10 +492,10 @@ yapp_get_ident(const char *synlvl) { int token = yapp_preproc_lex(); if (token == WHITESPACE) - token = yapp_preproc_lex(); + token = yapp_preproc_lex(); if (token != IDENT) { - yasm_error_set(YASM_ERROR_SYNTAX, N_("Identifier expected after %%%s"), - synlvl); + yasm_error_set(YASM_ERROR_SYNTAX, N_("Identifier expected after %%%s"), + synlvl); } return token; } @@ -519,9 +512,9 @@ copy_token(YAPP_Token *tok, struct source_head *to_head, source **to_tail) void expand_macro(char *name, - struct source_head *from_head, - struct source_head *to_head, - source **to_tail) + struct source_head *from_head, + struct source_head *to_head, + source **to_tail) { struct source_head replay_head, arg_head; source *replay_tail, *arg_tail; @@ -533,219 +526,219 @@ expand_macro(char *name, if (ym->expanding) yasm_internal_error(N_("Recursively expanding a macro!")); if (ym->type == YAPP_DEFINE) { - if (ym->args == -1) { - /* no parens to deal with */ - ym->expanding = 1; - expand_token_list(&ym->macro_head, to_head, to_tail); - ym->expanding = 0; - } - else - { - char *mungename; - int token; - int argc=0; - int parennest=0; - HAMT *param_table; - source *replay, *param; + if (ym->args == -1) { + /* no parens to deal with */ + ym->expanding = 1; + expand_token_list(&ym->macro_head, to_head, to_tail); + ym->expanding = 0; + } + else + { + char *mungename; + int token; + int argc=0; + int parennest=0; + HAMT *param_table; + source *replay, *param; - ydebug(("YAPP: +Expanding multi-arg macro %s...\n", name)); + ydebug(("YAPP: +Expanding multi-arg macro %s...\n", name)); - /* Build up both a parameter reference list and a token buffer, - * because we won't know until we've reached the closing paren if - * we can actuall expand the macro or not. bleah. */ - /* worse, we can't build the parameter list until we know the - * parameter names, which we can't look up until we know the - * number of arguments. sigh */ - /* HMM */ - SLIST_INIT(&replay_head); - replay_tail = SLIST_FIRST(&replay_head); + /* Build up both a parameter reference list and a token buffer, + * because we won't know until we've reached the closing paren if + * we can actuall expand the macro or not. bleah. */ + /* worse, we can't build the parameter list until we know the + * parameter names, which we can't look up until we know the + * number of arguments. sigh */ + /* HMM */ + SLIST_INIT(&replay_head); + replay_tail = SLIST_FIRST(&replay_head); - /* find out what we got */ - if (from_head) { - yasm_internal_error(N_("Expanding macro with non-null from_head ugh\n")); - } - token = yapp_preproc_lex(); - append_token(token, &replay_head, &replay_tail); - /* allow one whitespace */ - if (token == WHITESPACE) { - ydebug(("Ignoring WS between macro and paren\n")); - token = yapp_preproc_lex(); - append_token(token, &replay_head, &replay_tail); - } - if (token != '(') { - ydebug(("YAPP: -Didn't get to left paren; instead got '%c' \"%s\"\n", token, yapp_preproc_lval.str_val)); - replay_saved_tokens(name, &replay_head, to_head, to_tail); - return; - } + /* find out what we got */ + if (from_head) { + yasm_internal_error(N_("Expanding macro with non-null from_head ugh\n")); + } + token = yapp_preproc_lex(); + append_token(token, &replay_head, &replay_tail); + /* allow one whitespace */ + if (token == WHITESPACE) { + ydebug(("Ignoring WS between macro and paren\n")); + token = yapp_preproc_lex(); + append_token(token, &replay_head, &replay_tail); + } + if (token != '(') { + ydebug(("YAPP: -Didn't get to left paren; instead got '%c' \"%s\"\n", token, yapp_preproc_lval.str_val)); + replay_saved_tokens(name, &replay_head, to_head, to_tail); + return; + } - /* at this point, we've got the left paren. time to get annoyed */ - while (token != ')') { - token = yapp_preproc_lex(); - append_token(token, &replay_head, &replay_tail); - /* TODO: handle { } for commas? or is that just macros? */ - switch (token) { - case '(': - parennest++; - break; + /* at this point, we've got the left paren. time to get annoyed */ + while (token != ')') { + token = yapp_preproc_lex(); + append_token(token, &replay_head, &replay_tail); + /* TODO: handle { } for commas? or is that just macros? */ + switch (token) { + case '(': + parennest++; + break; - case ')': - if (parennest) { - parennest--; - token = ','; - } - else { - argc++; - } - break; + case ')': + if (parennest) { + parennest--; + token = ','; + } + else { + argc++; + } + break; - case ',': - if (!parennest) - argc++; - break; + case ',': + if (!parennest) + argc++; + break; - case WHITESPACE: case IDENT: case INTNUM: case FLTNUM: case STRING: - case '+': case '-': case '*': case '/': - break; + case WHITESPACE: case IDENT: case INTNUM: case FLTNUM: case STRING: + case '+': case '-': case '*': case '/': + break; - default: - if (token < 256) - yasm_internal_error(N_("Unexpected character token in parameter expansion")); - else - yasm_error_set(YASM_ERROR_SYNTAX, N_("Cannot handle preprocessor items inside possible macro invocation")); - } - } + default: + if (token < 256) + yasm_internal_error(N_("Unexpected character token in parameter expansion")); + else + yasm_error_set(YASM_ERROR_SYNTAX, N_("Cannot handle preprocessor items inside possible macro invocation")); + } + } - /* Now we have the argument count; let's see if it exists */ - mungename = yasm_xmalloc(strlen(name)+8); - sprintf(mungename, "%s(%d)", name, argc); - ym = yapp_macro_get(mungename); - if (!ym) - { - ydebug(("YAPP: -Didn't find macro %s\n", mungename)); - replay_saved_tokens(name, &replay_head, to_head, to_tail); - yasm_xfree(mungename); - return; - } - ydebug(("YAPP: +Found macro %s\n", mungename)); + /* Now we have the argument count; let's see if it exists */ + mungename = yasm_xmalloc(strlen(name)+8); + sprintf(mungename, "%s(%d)", name, argc); + ym = yapp_macro_get(mungename); + if (!ym) + { + ydebug(("YAPP: -Didn't find macro %s\n", mungename)); + replay_saved_tokens(name, &replay_head, to_head, to_tail); + yasm_xfree(mungename); + return; + } + ydebug(("YAPP: +Found macro %s\n", mungename)); - ym->expanding = 1; + ym->expanding = 1; - /* so the macro exists. build a HAMT parameter table */ - param_table = HAMT_create(yasm_internal_error_); - /* fill the entries by walking the replay buffer and create - * "macros". coincidentally, clear the replay buffer. */ + /* so the macro exists. build a HAMT parameter table */ + param_table = HAMT_create(yasm_internal_error_); + /* fill the entries by walking the replay buffer and create + * "macros". coincidentally, clear the replay buffer. */ - /* get to the opening paren */ - replay = SLIST_FIRST(&replay_head); - while (replay->token.type != '(') { - ydebug(("YAPP: Ignoring replay token '%c' \"%s\"\n", replay->token.type, replay->token.str)); - SLIST_REMOVE_HEAD(&replay_head, next); - yasm_xfree(replay->token.str); - yasm_xfree(replay); - replay = SLIST_FIRST(&replay_head); - } - ydebug(("YAPP: Ignoring replay token '%c' \"%s\"\n", replay->token.type, replay->token.str)); + /* get to the opening paren */ + replay = SLIST_FIRST(&replay_head); + while (replay->token.type != '(') { + ydebug(("YAPP: Ignoring replay token '%c' \"%s\"\n", replay->token.type, replay->token.str)); + SLIST_REMOVE_HEAD(&replay_head, next); + yasm_xfree(replay->token.str); + yasm_xfree(replay); + replay = SLIST_FIRST(&replay_head); + } + ydebug(("YAPP: Ignoring replay token '%c' \"%s\"\n", replay->token.type, replay->token.str)); - /* free the open paren */ - SLIST_REMOVE_HEAD(&replay_head, next); - yasm_xfree(replay->token.str); - yasm_xfree(replay); + /* free the open paren */ + SLIST_REMOVE_HEAD(&replay_head, next); + yasm_xfree(replay->token.str); + yasm_xfree(replay); - param = SLIST_FIRST(&ym->param_head); + param = SLIST_FIRST(&ym->param_head); - SLIST_INIT(&arg_head); - arg_tail = SLIST_FIRST(&arg_head); + SLIST_INIT(&arg_head); + arg_tail = SLIST_FIRST(&arg_head); - replay = SLIST_FIRST(&replay_head); - SLIST_REMOVE_HEAD(&replay_head, next); - while (parennest || replay) { - if (replay->token.type == '(') { - parennest++; - append_processed_token(replay, &arg_head, &arg_tail); - ydebug(("YAPP: +add arg token '%c'\n", replay->token.type)); - } - else if (parennest && replay->token.type == ')') { - parennest--; - append_processed_token(replay, &arg_head, &arg_tail); - ydebug(("YAPP: +add arg token '%c'\n", replay->token.type)); - } - else if ((!parennest) && (replay->token.type == ',' - || replay->token.type == ')')) - { - int zero=0; - struct source_head *argmacro = yasm_xmalloc(sizeof(struct source_head)); - memcpy(argmacro, &arg_head, sizeof(struct source_head)); - SLIST_INIT(&arg_head); - arg_tail = SLIST_FIRST(&arg_head); + replay = SLIST_FIRST(&replay_head); + SLIST_REMOVE_HEAD(&replay_head, next); + while (parennest || replay) { + if (replay->token.type == '(') { + parennest++; + append_processed_token(replay, &arg_head, &arg_tail); + ydebug(("YAPP: +add arg token '%c'\n", replay->token.type)); + } + else if (parennest && replay->token.type == ')') { + parennest--; + append_processed_token(replay, &arg_head, &arg_tail); + ydebug(("YAPP: +add arg token '%c'\n", replay->token.type)); + } + else if ((!parennest) && (replay->token.type == ',' + || replay->token.type == ')')) + { + int zero=0; + struct source_head *argmacro = yasm_xmalloc(sizeof(struct source_head)); + memcpy(argmacro, &arg_head, sizeof(struct source_head)); + SLIST_INIT(&arg_head); + arg_tail = SLIST_FIRST(&arg_head); - /* don't save the comma */ - yasm_xfree(replay->token.str); - yasm_xfree(replay); + /* don't save the comma */ + yasm_xfree(replay->token.str); + yasm_xfree(replay); - HAMT_insert(param_table, - param->token.str, - (void *)argmacro, - &zero, - (void (*)(void *))yapp_macro_error_sameargname); - param = SLIST_NEXT(param, next); - } - else if (replay->token.type == IDENT - && yapp_defined(replay->token.str)) - { - ydebug(("YAPP: +add arg macro '%c' \"%s\"\n", replay->token.type, replay->token.str)); - expand_macro(replay->token.str, &replay_head, &arg_head, &arg_tail); - } - else if (arg_tail || replay->token.type != WHITESPACE) { - ydebug(("YAPP: +else add arg token '%c' \"%s\"\n", replay->token.type, replay->token.str)); - append_processed_token(replay, &arg_head, &arg_tail); - } - replay = SLIST_FIRST(&replay_head); - if (replay) SLIST_REMOVE_HEAD(&replay_head, next); - } - if (replay) { - yasm_xfree(replay->token.str); - yasm_xfree(replay); - } - else if (param) { - yasm_internal_error(N_("Got to end of arglist before end of replay!")); - } - replay = SLIST_FIRST(&replay_head); - if (replay || param) - yasm_internal_error(N_("Count and distribution of define args mismatched!")); + HAMT_insert(param_table, + param->token.str, + (void *)argmacro, + &zero, + (void (*)(void *))yapp_macro_error_sameargname); + param = SLIST_NEXT(param, next); + } + else if (replay->token.type == IDENT + && yapp_defined(replay->token.str)) + { + ydebug(("YAPP: +add arg macro '%c' \"%s\"\n", replay->token.type, replay->token.str)); + expand_macro(replay->token.str, &replay_head, &arg_head, &arg_tail); + } + else if (arg_tail || replay->token.type != WHITESPACE) { + ydebug(("YAPP: +else add arg token '%c' \"%s\"\n", replay->token.type, replay->token.str)); + append_processed_token(replay, &arg_head, &arg_tail); + } + replay = SLIST_FIRST(&replay_head); + if (replay) SLIST_REMOVE_HEAD(&replay_head, next); + } + if (replay) { + yasm_xfree(replay->token.str); + yasm_xfree(replay); + } + else if (param) { + yasm_internal_error(N_("Got to end of arglist before end of replay!")); + } + replay = SLIST_FIRST(&replay_head); + if (replay || param) + yasm_internal_error(N_("Count and distribution of define args mismatched!")); - /* the param_table is set up without errors, so expansion is ready - * to go */ - SLIST_FOREACH (replay, &ym->macro_head, next) { - if (replay->token.type == IDENT) { + /* the param_table is set up without errors, so expansion is ready + * to go */ + SLIST_FOREACH (replay, &ym->macro_head, next) { + if (replay->token.type == IDENT) { - /* check local args first */ - struct source_head *paramexp = - yapp_define_param_get(param_table, replay->token.str); + /* check local args first */ + struct source_head *paramexp = + yapp_define_param_get(param_table, replay->token.str); - if (paramexp) { - expand_token_list(paramexp, to_head, to_tail); - } - else { - /* otherwise, check macros */ - YAPP_Macro *imacro = yapp_macro_get(replay->token.str); - if (imacro != NULL && !imacro->expanding) { - expand_macro(replay->token.str, NULL, to_head, to_tail); - } - else { - /* otherwise it's just a vanilla ident */ - copy_token(&replay->token, to_head, to_tail); - } - } - } - else { - copy_token(&replay->token, to_head, to_tail); - } - } - ym->expanding = 0; - } + if (paramexp) { + expand_token_list(paramexp, to_head, to_tail); + } + else { + /* otherwise, check macros */ + YAPP_Macro *imacro = yapp_macro_get(replay->token.str); + if (imacro != NULL && !imacro->expanding) { + expand_macro(replay->token.str, NULL, to_head, to_tail); + } + else { + /* otherwise it's just a vanilla ident */ + copy_token(&replay->token, to_head, to_tail); + } + } + } + else { + copy_token(&replay->token, to_head, to_tail); + } + } + ym->expanding = 0; + } } else - yasm_internal_error(N_("Invoking Macros not yet supported")); + yasm_internal_error(N_("Invoking Macros not yet supported")); ym->expanding = 0; } @@ -755,18 +748,18 @@ expand_token_list(struct source_head *paramexp, struct source_head *to_head, sou { source *item; SLIST_FOREACH (item, paramexp, next) { - if (item->token.type == IDENT) { - YAPP_Macro *imacro = yapp_macro_get(item->token.str); - if (imacro != NULL && !imacro->expanding) { - expand_macro(item->token.str, NULL, to_head, to_tail); - } - else { - copy_token(&item->token, to_head, to_tail); - } - } - else { - copy_token(&item->token, to_head, to_tail); - } + if (item->token.type == IDENT) { + YAPP_Macro *imacro = yapp_macro_get(item->token.str); + if (imacro != NULL && !imacro->expanding) { + expand_macro(item->token.str, NULL, to_head, to_tail); + } + else { + copy_token(&item->token, to_head, to_tail); + } + } + else { + copy_token(&item->token, to_head, to_tail); + } } } @@ -780,187 +773,187 @@ yapp_preproc_input(yasm_preproc *preproc, char *buf, size_t max_size) while ((size_t)saved_length < max_size && state != YAPP_STATE_EOF) { - token = yapp_preproc_lex(); + token = yapp_preproc_lex(); - switch (state) { - case YAPP_STATE_INITIAL: - switch (token) - { - char *s; - default: - append_token(token, &source_head, &source_tail); - /*if (append_to_return()==0) state=YAPP_STATE_EOF;*/ - ydebug(("YAPP: default: '%c' \"%s\"\n", token, yapp_preproc_lval.str_val)); - /*yasm_error_set(YASM_ERROR_SYNTAX, N_("YAPP got an unhandled token."));*/ - break; + switch (state) { + case YAPP_STATE_INITIAL: + switch (token) + { + char *s; + default: + append_token(token, &source_head, &source_tail); + /*if (append_to_return()==0) state=YAPP_STATE_EOF;*/ + ydebug(("YAPP: default: '%c' \"%s\"\n", token, yapp_preproc_lval.str_val)); + /*yasm_error_set(YASM_ERROR_SYNTAX, N_("YAPP got an unhandled token."));*/ + break; - case IDENT: - ydebug(("YAPP: ident: \"%s\"\n", yapp_preproc_lval.str_val)); - if (yapp_defined(yapp_preproc_lval.str_val)) { - expand_macro(yapp_preproc_lval.str_val, NULL, &source_head, &source_tail); - } - else { - append_token(token, &source_head, &source_tail); - } - break; + case IDENT: + ydebug(("YAPP: ident: \"%s\"\n", yapp_preproc_lval.str_val)); + if (yapp_defined(yapp_preproc_lval.str_val)) { + expand_macro(yapp_preproc_lval.str_val, NULL, &source_head, &source_tail); + } + else { + append_token(token, &source_head, &source_tail); + } + break; - case 0: - state = YAPP_STATE_EOF; - break; + case 0: + state = YAPP_STATE_EOF; + break; - case '\n': - append_token(token, &source_head, &source_tail); - break; + case '\n': + append_token(token, &source_head, &source_tail); + break; - case CLEAR: - HAMT_destroy(macro_table, (void (*)(void *))yapp_macro_delete); - macro_table = HAMT_create(yasm_internal_error_); - break; + case CLEAR: + HAMT_destroy(macro_table, (void (*)(void *))yapp_macro_delete); + macro_table = HAMT_create(yasm_internal_error_); + break; - case DEFINE: - ydebug(("YAPP: define: ")); - token = yapp_get_ident("define"); - ydebug((" \"%s\"\n", yapp_preproc_lval.str_val)); - s = yasm__xstrdup(yapp_preproc_lval.str_val); + case DEFINE: + ydebug(("YAPP: define: ")); + token = yapp_get_ident("define"); + ydebug((" \"%s\"\n", yapp_preproc_lval.str_val)); + s = yasm__xstrdup(yapp_preproc_lval.str_val); - /* three cases: newline or stuff or left paren */ - token = yapp_preproc_lex(); - if (token == '\n') { - /* no args or content - just insert it */ - yapp_define_insert(s, -1, 0); - append_token('\n', &source_head, &source_tail); - } - else if (token == WHITESPACE) { - /* no parens */ - if(append_to_return(¯o_head, ¯o_tail)==0) state=YAPP_STATE_EOF; - else { - yapp_define_insert(s, -1, 0); - } - append_token('\n', &source_head, &source_tail); - } - else if (token == '(') { - /* get all params of the parameter list */ - /* ensure they alternate IDENT and ',' */ - int param_count = 0; - int last_token = ','; + /* three cases: newline or stuff or left paren */ + token = yapp_preproc_lex(); + if (token == '\n') { + /* no args or content - just insert it */ + yapp_define_insert(s, -1, 0); + append_token('\n', &source_head, &source_tail); + } + else if (token == WHITESPACE) { + /* no parens */ + if(append_to_return(¯o_head, ¯o_tail)==0) state=YAPP_STATE_EOF; + else { + yapp_define_insert(s, -1, 0); + } + append_token('\n', &source_head, &source_tail); + } + else if (token == '(') { + /* get all params of the parameter list */ + /* ensure they alternate IDENT and ',' */ + int param_count = 0; + int last_token = ','; - ydebug((" *Getting arglist for define %s\n", s)); + ydebug((" *Getting arglist for define %s\n", s)); - while ((token = yapp_preproc_lex())!=')') { - ydebug(("YAPP: +read token '%c' \"%s\" for macro %s\n", token, yapp_preproc_lval.str_val, s)); - if (token == WHITESPACE) { - token = last_token; - } - else if (last_token == ',' && token == IDENT) { - append_token(token, ¶m_head, ¶m_tail); - param_count++; - } - else if (token == 0) { - state = YAPP_STATE_EOF; - break; - } - else if (last_token == ',' || token != ',') - yasm_error_set(YASM_ERROR_SYNTAX, N_("Unexpected token in %%define parameters")); - last_token = token; - } - if (token == ')') { - /* after paramlist and ')' */ - /* everything is what it's defined to be */ - token = yapp_preproc_lex(); - if (token != WHITESPACE) append_token(token, ¯o_head, ¯o_tail); - if (append_to_return(¯o_head, ¯o_tail)==0) state=YAPP_STATE_EOF; - else { - ydebug(("YAPP: Inserting define macro %s (%d)\n", s, param_count)); - yapp_define_insert(s, param_count, 0); - } - } - append_token('\n', &source_head, &source_tail); - } - else { - yasm_internal_error(N_("%%define ... failed miserably - neither \\n, WS, or ( followed ident")); - } - break; + while ((token = yapp_preproc_lex())!=')') { + ydebug(("YAPP: +read token '%c' \"%s\" for macro %s\n", token, yapp_preproc_lval.str_val, s)); + if (token == WHITESPACE) { + token = last_token; + } + else if (last_token == ',' && token == IDENT) { + append_token(token, ¶m_head, ¶m_tail); + param_count++; + } + else if (token == 0) { + state = YAPP_STATE_EOF; + break; + } + else if (last_token == ',' || token != ',') + yasm_error_set(YASM_ERROR_SYNTAX, N_("Unexpected token in %%define parameters")); + last_token = token; + } + if (token == ')') { + /* after paramlist and ')' */ + /* everything is what it's defined to be */ + token = yapp_preproc_lex(); + if (token != WHITESPACE) append_token(token, ¯o_head, ¯o_tail); + if (append_to_return(¯o_head, ¯o_tail)==0) state=YAPP_STATE_EOF; + else { + ydebug(("YAPP: Inserting define macro %s (%d)\n", s, param_count)); + yapp_define_insert(s, param_count, 0); + } + } + append_token('\n', &source_head, &source_tail); + } + else { + yasm_internal_error(N_("%%define ... failed miserably - neither \\n, WS, or ( followed ident")); + } + break; - case UNDEF: - token = yapp_get_ident("undef"); - yapp_undef(yapp_preproc_lval.str_val); - state = YAPP_STATE_NEED_EOL; - break; + case UNDEF: + token = yapp_get_ident("undef"); + yapp_undef(yapp_preproc_lval.str_val); + state = YAPP_STATE_NEED_EOL; + break; - case IFDEF: - token = yapp_get_ident("ifdef"); - push_if(yapp_defined(yapp_preproc_lval.str_val)); - state = YAPP_STATE_NEED_EOL; - break; + case IFDEF: + token = yapp_get_ident("ifdef"); + push_if(yapp_defined(yapp_preproc_lval.str_val)); + state = YAPP_STATE_NEED_EOL; + break; - case IFNDEF: - token = yapp_get_ident("ifndef"); - push_if(!yapp_defined(yapp_preproc_lval.str_val)); - state = YAPP_STATE_NEED_EOL; - break; + case IFNDEF: + token = yapp_get_ident("ifndef"); + push_if(!yapp_defined(yapp_preproc_lval.str_val)); + state = YAPP_STATE_NEED_EOL; + break; - case ELSE: - push_else(1); - if (current_output == YAPP_OUTPUT) need_line_directive = 1; - state = YAPP_STATE_NEED_EOL; - break; + case ELSE: + push_else(1); + if (current_output == YAPP_OUTPUT) need_line_directive = 1; + state = YAPP_STATE_NEED_EOL; + break; - case ELIFDEF: - token = yapp_get_ident("elifdef"); - push_else(yapp_defined(yapp_preproc_lval.str_val)); - if (current_output == YAPP_OUTPUT) need_line_directive = 1; - state = YAPP_STATE_NEED_EOL; - break; + case ELIFDEF: + token = yapp_get_ident("elifdef"); + push_else(yapp_defined(yapp_preproc_lval.str_val)); + if (current_output == YAPP_OUTPUT) need_line_directive = 1; + state = YAPP_STATE_NEED_EOL; + break; - case ELIFNDEF: - token = yapp_get_ident("elifndef"); - push_else(!yapp_defined(yapp_preproc_lval.str_val)); - if (current_output == YAPP_OUTPUT) need_line_directive = 1; - state = YAPP_STATE_NEED_EOL; - break; + case ELIFNDEF: + token = yapp_get_ident("elifndef"); + push_else(!yapp_defined(yapp_preproc_lval.str_val)); + if (current_output == YAPP_OUTPUT) need_line_directive = 1; + state = YAPP_STATE_NEED_EOL; + break; - case ENDIF: - /* there's got to be another way to do this: */ - /* only set if going from non-output to output */ - if (current_output != YAPP_OUTPUT) need_line_directive = 1; - pop_if(); - if (current_output != YAPP_OUTPUT) need_line_directive = 0; - state = YAPP_STATE_NEED_EOL; - break; + case ENDIF: + /* there's got to be another way to do this: */ + /* only set if going from non-output to output */ + if (current_output != YAPP_OUTPUT) need_line_directive = 1; + pop_if(); + if (current_output != YAPP_OUTPUT) need_line_directive = 0; + state = YAPP_STATE_NEED_EOL; + break; - case INCLUDE: - case LINE: - need_line_directive = 1; - break; - } - if (state == YAPP_STATE_NEED_EOL) - { - if (eat_through_return(&source_head, &source_tail)==0) state=YAPP_STATE_EOF; - else state=YAPP_STATE_INITIAL; - } - break; - default: - yasm_error_set(YASM_ERROR_PARSE, N_("YAPP got into a bad state")); - } - if (need_line_directive) { - append_token(LINE, &source_head, &source_tail); - need_line_directive = 0; - } + case INCLUDE: + case LINE: + need_line_directive = 1; + break; + } + if (state == YAPP_STATE_NEED_EOL) + { + if (eat_through_return(&source_head, &source_tail)==0) state=YAPP_STATE_EOF; + else state=YAPP_STATE_INITIAL; + } + break; + default: + yasm_error_set(YASM_ERROR_PARSE, N_("YAPP got into a bad state")); + } + if (need_line_directive) { + append_token(LINE, &source_head, &source_tail); + need_line_directive = 0; + } } /* convert saved stuff into output. we either have enough, or are EOF */ while (n < max_size && saved_length) { - src = SLIST_FIRST(&source_head); - if (max_size - n >= strlen(src->token.str)) { - strcpy(buf+n, src->token.str); - n += strlen(src->token.str); + src = SLIST_FIRST(&source_head); + if (max_size - n >= strlen(src->token.str)) { + strcpy(buf+n, src->token.str); + n += strlen(src->token.str); - saved_length -= strlen(src->token.str); - SLIST_REMOVE_HEAD(&source_head, next); - yasm_xfree(src->token.str); - yasm_xfree(src); - } + saved_length -= strlen(src->token.str); + SLIST_REMOVE_HEAD(&source_head, next); + yasm_xfree(src->token.str); + yasm_xfree(src); + } } return n; @@ -968,7 +961,7 @@ yapp_preproc_input(yasm_preproc *preproc, char *buf, size_t max_size) static size_t yapp_preproc_get_included_file(yasm_preproc *preproc, /*@out@*/ char *buf, - size_t max_size) + size_t max_size) { /* TODO */ return 0; @@ -998,12 +991,6 @@ yapp_preproc_define_builtin(yasm_preproc *preproc, const char *macronameval) /* TODO */ } -static void -yapp_preproc_add_standard(yasm_preproc *preproc, const char **macros) -{ - /* TODO */ -} - /* Define preproc structure -- see preproc.h for details */ yasm_preproc_module yasm_yapp_LTX_preproc = { "YAPP preprocessing (NASM style)", @@ -1015,6 +1002,5 @@ yasm_preproc_module yasm_yapp_LTX_preproc = { yapp_preproc_add_include_file, yapp_preproc_predefine_macro, yapp_preproc_undefine_macro, - yapp_preproc_define_builtin, - yapp_preproc_add_standard + yapp_preproc_define_builtin }; diff --git a/modules/preprocs/yapp/yapp-preproc.h b/modules/preprocs/yapp/yapp-preproc.h index 38065ab6..9e5366ae 100644 --- a/modules/preprocs/yapp/yapp-preproc.h +++ b/modules/preprocs/yapp/yapp-preproc.h @@ -1,4 +1,4 @@ -/* +/* $Id$ * YAPP preprocessor (mimics NASM's preprocessor) header file * * Copyright (C) 2001 Michael Urman @@ -30,9 +30,9 @@ typedef struct YAPP_Token_s { unsigned int type; char *str; union { - unsigned int int_val; - double double_val; - char *str_val; + unsigned int int_val; + double double_val; + char *str_val; } val; } YAPP_Token; @@ -48,9 +48,9 @@ typedef enum { /* tracks nested %if* %elif* %else %endif structures */ typedef enum { - YAPP_OUTPUT, /* this level+module outputs */ - YAPP_NO_OUTPUT, /* this would never output */ - YAPP_OLD_OUTPUT, /* this level has already output */ + YAPP_OUTPUT, /* this level+module outputs */ + YAPP_NO_OUTPUT, /* this would never output */ + YAPP_OLD_OUTPUT, /* this level has already output */ YAPP_BLOCKED_OUTPUT /* the surrounding level is not outputting */ } YAPP_Output; @@ -58,5 +58,5 @@ void yapp_lex_initialize(FILE *f); void set_inhibit(void); extern /*@dependent@*/ yasm_linemap *yapp_preproc_linemap; -#define cur_lindex yasm_linemap_get_current(yapp_preproc_linemap) +#define cur_lindex yasm_linemap_get_current(yapp_preproc_linemap) diff --git a/modules/preprocs/yapp/yapp-token.h b/modules/preprocs/yapp/yapp-token.h index e63c4c83..43012495 100644 --- a/modules/preprocs/yapp/yapp-token.h +++ b/modules/preprocs/yapp/yapp-token.h @@ -1,60 +1,60 @@ typedef union { char *str_val; struct { - char *str; - unsigned long val; + char *str; + unsigned long val; } int_str_val; struct { - char *str; - double val; + char *str; + double val; } double_str_val; } YYSTYPE; -#define INTNUM 257 -#define FLTNUM 258 -#define STRING 259 -#define IDENT 260 -#define CLEAR 261 -#define INCLUDE 262 -#define LINE 263 -#define DEFINE 264 -#define UNDEF 265 -#define ASSIGN 266 -#define MACRO 267 -#define ENDMACRO 268 -#define ROTATE 269 -#define REP 270 -#define EXITREP 271 -#define ENDREP 272 -#define IF 273 -#define ELIF 274 -#define ELSE 275 -#define ENDIF 276 -#define IFDEF 277 -#define ELIFDEF 278 -#define IFNDEF 279 -#define ELIFNDEF 280 -#define IFCTX 281 -#define ELIFCTX 282 -#define IFIDN 283 -#define ELIFIDN 284 -#define IFIDNI 285 -#define ELIFIDNI 286 -#define IFID 287 -#define ELIFID 288 -#define IFNUM 289 -#define ELIFNUM 290 -#define IFSTR 291 -#define ELIFSTR 292 -#define ERROR 293 -#define PUSH 294 -#define POP 295 -#define REPL 296 -#define LEFT_OP 297 -#define RIGHT_OP 298 -#define SIGNDIV 299 -#define SIGNMOD 300 -#define UNARYOP 301 -#define WHITESPACE 302 +#define INTNUM 257 +#define FLTNUM 258 +#define STRING 259 +#define IDENT 260 +#define CLEAR 261 +#define INCLUDE 262 +#define LINE 263 +#define DEFINE 264 +#define UNDEF 265 +#define ASSIGN 266 +#define MACRO 267 +#define ENDMACRO 268 +#define ROTATE 269 +#define REP 270 +#define EXITREP 271 +#define ENDREP 272 +#define IF 273 +#define ELIF 274 +#define ELSE 275 +#define ENDIF 276 +#define IFDEF 277 +#define ELIFDEF 278 +#define IFNDEF 279 +#define ELIFNDEF 280 +#define IFCTX 281 +#define ELIFCTX 282 +#define IFIDN 283 +#define ELIFIDN 284 +#define IFIDNI 285 +#define ELIFIDNI 286 +#define IFID 287 +#define ELIFID 288 +#define IFNUM 289 +#define ELIFNUM 290 +#define IFSTR 291 +#define ELIFSTR 292 +#define ERROR 293 +#define PUSH 294 +#define POP 295 +#define REPL 296 +#define LEFT_OP 297 +#define RIGHT_OP 298 +#define SIGNDIV 299 +#define SIGNMOD 300 +#define UNARYOP 301 +#define WHITESPACE 302 extern YYSTYPE yapp_preproc_lval; diff --git a/modules/preprocs/yapp/yapp-token.l b/modules/preprocs/yapp/yapp-token.l index d1390777..38a4c184 100644 --- a/modules/preprocs/yapp/yapp-token.l +++ b/modules/preprocs/yapp/yapp-token.l @@ -26,6 +26,7 @@ */ %{ #include +/*@unused@*/ RCSID("$Id$"); #define YASM_LIB_INTERNAL #include diff --git a/out_test.sh b/out_test.sh index c5f6efc2..2f9bb079 100755 --- a/out_test.sh +++ b/out_test.sh @@ -1,4 +1,5 @@ #! /bin/sh +# $Id$ YASM_TEST_SUITE=1 export YASM_TEST_SUITE @@ -28,67 +29,65 @@ do og=`echo ${asm} | sed 's,.asm$,.hex,'` e=${a}.ew eg=`echo ${asm} | sed 's,.asm$,.errwarn,'` - egp=1 - if test \! -f ${eg}; then - eg=/dev/null - egp=0 + if test \! -e ${eg}; then + eg=/dev/null fi # Run within a subshell to prevent signal messages from displaying. sh -c "cat ${asm} | ./yasm $4 -o results/${o} - 2>results/${e}" >/dev/null 2>/dev/null status=$? if test $status -gt 128; then - # We should never get a coredump! - echo $ECHO_N "C$ECHO_C" + # We should never get a coredump! + echo $ECHO_N "C$ECHO_C" eval "failed$failedct='C: ${a} crashed!'" - failedct=`expr $failedct + 1` + failedct=`expr $failedct + 1` elif test $status -gt 0; then - echo ${asm} | grep err >/dev/null - if test \( $? -gt 0 \) -a \( \! $egp \); then - # YASM detected errors but shouldn't have! - echo $ECHO_N "E$ECHO_C" + echo ${asm} | grep err >/dev/null + if test $? -gt 0; then + # YASM detected errors but shouldn't have! + echo $ECHO_N "E$ECHO_C" eval "failed$failedct='E: ${a} returned an error code!'" - failedct=`expr $failedct + 1` - else - # We got errors, check to see if they match: - if diff -w ${eg} results/${e} >/dev/null; then - # Error/warnings match, it passes! - echo $ECHO_N ".$ECHO_C" - passedct=`expr $passedct + 1` - else - # Error/warnings don't match. - echo $ECHO_N "W$ECHO_C" + failedct=`expr $failedct + 1` + else + # We got errors, check to see if they match: + if diff -w ${eg} results/${e} >/dev/null; then + # Error/warnings match, it passes! + echo $ECHO_N ".$ECHO_C" + passedct=`expr $passedct + 1` + else + # Error/warnings don't match. + echo $ECHO_N "W$ECHO_C" eval "failed$failedct='W: ${a} did not match errors and warnings!'" - failedct=`expr $failedct + 1` - fi - fi + failedct=`expr $failedct + 1` + fi + fi else - echo ${asm} | grep -v err >/dev/null - if test $? -gt 0; then - # YASM didn't detect errors but should have! - echo $ECHO_N "E$ECHO_C" + echo ${asm} | grep -v err >/dev/null + if test $? -gt 0; then + # YASM didn't detect errors but should have! + echo $ECHO_N "E$ECHO_C" eval "failed$failedct='E: ${a} did not return an error code!'" - failedct=`expr $failedct + 1` - else - ./test_hd results/${o} > results/${oh} - if diff -w ${og} results/${oh} >/dev/null; then - if diff -w ${eg} results/${e} >/dev/null; then - # Both object file and error/warnings match, it passes! - echo $ECHO_N ".$ECHO_C" - passedct=`expr $passedct + 1` - else - # Error/warnings don't match. - echo $ECHO_N "W$ECHO_C" + failedct=`expr $failedct + 1` + else + ./test_hd results/${o} > results/${oh} + if diff ${og} results/${oh} >/dev/null; then + if diff -w ${eg} results/${e} >/dev/null; then + # Both object file and error/warnings match, it passes! + echo $ECHO_N ".$ECHO_C" + passedct=`expr $passedct + 1` + else + # Error/warnings don't match. + echo $ECHO_N "W$ECHO_C" eval "failed$failedct='W: ${a} did not match errors and warnings!'" - failedct=`expr $failedct + 1` - fi - else - # Object file doesn't match. - echo $ECHO_N "O$ECHO_C" + failedct=`expr $failedct + 1` + fi + else + # Object file doesn't match. + echo $ECHO_N "O$ECHO_C" eval "failed$failedct='O: ${a} did not match object file!'" - failedct=`expr $failedct + 1` - fi - fi + failedct=`expr $failedct + 1` + fi + fi fi done diff --git a/plugins/README b/plugins/README deleted file mode 100644 index 63a6a53c..00000000 --- a/plugins/README +++ /dev/null @@ -1,22 +0,0 @@ -These directories contain example yasm plugins. -Yasm is only capable of loading plugins when it was built using cmake. -To build yasm with cmake on Unix, from the yasm source tree, do: - mkdir objdir - cd objdir - cmake .. - make - -The plugins are written to be compiled against an *installed* yasm. -Plugins may be loaded on the yasm command line using the -N command line -option, e.g.: - yasm -N ./libdbgmod.so - yasm -N Release/dbgmod.dll - yasm -N /usr/local/lib/libx86mod -(the .so will be automatically appended) -If no directory path is specified, yasm will search in standard library -locations (e.g. LD_LIBRARY_PATH, the rpath of the yasm executable, etc) to -try to load the plugin. Thus the last example (after installing the plugin) -could likely be written: - yasm -N x86mod - -Plugins may override builtin modules like x86. diff --git a/plugins/dbg/CMakeLists.txt b/plugins/dbg/CMakeLists.txt deleted file mode 100644 index b0b9653f..00000000 --- a/plugins/dbg/CMakeLists.txt +++ /dev/null @@ -1,59 +0,0 @@ -PROJECT(dbgmod) -CMAKE_MINIMUM_REQUIRED(VERSION 2.4) - -SET (YASM_POSSIBLE_PATHS - "$ENV{ProgramFiles}/Yasm/Bin" - /usr/bin - /usr/local/bin - ) - -FIND_PROGRAM(YASM_PATH yasm - PATHS ${YASM_POSSIBLE_PATHS} - ) - -SET (YASM_POSSIBLE_INCLUDE_PATHS - "${YASM_PATH}" - "${YASM_PATH}/../include" - "$ENV{ProgramFiles}/Yasm/Include" - /usr/include - /usr/local/include - ) - -FIND_PATH(YASM_INCLUDE_PATH NAMES libyasm.h - DOC "The path to the libyasm include files" - PATHS ${YASM_POSSIBLE_INCLUDE_PATHS} - ) - -IF (NOT YASM_INCLUDE_PATH) - MESSAGE(FATAL_ERROR "Could not find yasm include files") -ENDIF (NOT YASM_INCLUDE_PATH) - -INCLUDE_DIRECTORIES(${YASM_INCLUDE_PATH}) - -SET (YASM_POSSIBLE_LIB_PATHS - "${YASM_PATH}" - "${YASM_PATH}/../lib" - "${YASM_INCLUDE_PATH}/../lib" - "$ENV{ProgramFiles}/Yasm/Lib" - /usr/lib - /usr/local/lib - ) - -FIND_LIBRARY(YASM_LIBRARY - NAMES yasm - DOC "The path to the libyasm library" - PATHS ${YASM_POSSIBLE_LIB_PATHS} - ) - -IF (NOT YASM_LIBRARY) - MESSAGE(FATAL_ERROR "Could not find yasm library") -ENDIF (NOT YASM_LIBRARY) - -ADD_LIBRARY(dbgmod MODULE - init_plugin.c - dbg-objfmt.c - ) -TARGET_LINK_LIBRARIES(dbgmod ${YASM_LIBRARY}) -if(WIN32) - SET_PROPERTY(TARGET dbgmod PROPERTY PREFIX "") -endif() diff --git a/plugins/dbg/README b/plugins/dbg/README deleted file mode 100644 index d4fdbc58..00000000 --- a/plugins/dbg/README +++ /dev/null @@ -1,21 +0,0 @@ -This directory demonstrates how to build a basic plugin. -It does not need access to the yasm source, only an installed yasm. - -To build: - mkdir objdir - cd objdir - cmake .. - make - -Testing (on Windows): - yasm -N Release/dbgmod.dll -f dbg - - db 5 - ^Z - -Testing (on Unix): - yasm -N ./libdbgmod.so -f dbg - - db 5 - ^D - -Result lines will have PLUGIN prefixed to the function calls; this -demonstrates the plugin is being used rather than the builtin dbg module. diff --git a/plugins/dbg/dbg-objfmt.c b/plugins/dbg/dbg-objfmt.c deleted file mode 100644 index 1aef7c20..00000000 --- a/plugins/dbg/dbg-objfmt.c +++ /dev/null @@ -1,175 +0,0 @@ -/* - * Debugging object format (used to debug object format module interface) - * - * Copyright (C) 2001-2007 Peter Johnson - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND OTHER CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR OTHER CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -#include -#include - -#define N_(String) (String) - -typedef struct yasm_objfmt_dbg { - yasm_objfmt_base objfmt; /* base structure */ - - FILE *dbgfile; -} yasm_objfmt_dbg; - -yasm_objfmt_module yasm_dbg_LTX_objfmt; - - -static yasm_objfmt * -dbg_objfmt_create(yasm_object *object) -{ - yasm_objfmt_dbg *objfmt_dbg = yasm_xmalloc(sizeof(yasm_objfmt_dbg)); - - objfmt_dbg->objfmt.module = &yasm_dbg_LTX_objfmt; - - objfmt_dbg->dbgfile = tmpfile(); - if (!objfmt_dbg->dbgfile) { - fprintf(stderr, N_("could not open temporary file")); - return 0; - } - fprintf(objfmt_dbg->dbgfile, "PLUGIN create()\n"); - return (yasm_objfmt *)objfmt_dbg; -} - -static void -dbg_objfmt_output(yasm_object *object, FILE *f, int all_syms, - yasm_errwarns *errwarns) -{ - yasm_objfmt_dbg *objfmt_dbg = (yasm_objfmt_dbg *)object->objfmt; - char buf[1024]; - size_t i; - - /* Copy temp file to real output file */ - rewind(objfmt_dbg->dbgfile); - while ((i = fread(buf, 1, 1024, objfmt_dbg->dbgfile))) { - if (fwrite(buf, 1, i, f) != i) - break; - } - - /* Reassign objfmt debug file to output file */ - fclose(objfmt_dbg->dbgfile); - objfmt_dbg->dbgfile = f; - - fprintf(objfmt_dbg->dbgfile, "PLUGIN output(f, object->\n"); - yasm_object_print(object, objfmt_dbg->dbgfile, 1); - fprintf(objfmt_dbg->dbgfile, "%d)\n", all_syms); - fprintf(objfmt_dbg->dbgfile, " Symbol Table:\n"); - yasm_symtab_print(object->symtab, objfmt_dbg->dbgfile, 1); -} - -static void -dbg_objfmt_destroy(yasm_objfmt *objfmt) -{ - yasm_objfmt_dbg *objfmt_dbg = (yasm_objfmt_dbg *)objfmt; - fprintf(objfmt_dbg->dbgfile, "PLUGIN destroy()\n"); - yasm_xfree(objfmt); -} - -static yasm_section * -dbg_objfmt_add_default_section(yasm_object *object) -{ - yasm_objfmt_dbg *objfmt_dbg = (yasm_objfmt_dbg *)object->objfmt; - yasm_section *retval; - int isnew; - - retval = yasm_object_get_general(object, ".text", 0, 0, 0, &isnew, 0); - if (isnew) { - fprintf(objfmt_dbg->dbgfile, "(new) "); - yasm_symtab_define_label(object->symtab, ".text", - yasm_section_bcs_first(retval), 1, 0); - yasm_section_set_default(retval, 1); - } - return retval; -} - -static /*@observer@*/ /*@null@*/ yasm_section * -dbg_objfmt_section_switch(yasm_object *object, yasm_valparamhead *valparams, - /*@unused@*/ /*@null@*/ - yasm_valparamhead *objext_valparams, - unsigned long line) -{ - yasm_objfmt_dbg *objfmt_dbg = (yasm_objfmt_dbg *)object->objfmt; - yasm_valparam *vp; - yasm_section *retval; - int isnew; - - fprintf(objfmt_dbg->dbgfile, "PLUGIN section_switch(headp, "); - yasm_vps_print(valparams, objfmt_dbg->dbgfile); - fprintf(objfmt_dbg->dbgfile, ", "); - yasm_vps_print(objext_valparams, objfmt_dbg->dbgfile); - fprintf(objfmt_dbg->dbgfile, ", %lu), returning ", line); - - vp = yasm_vps_first(valparams); - if (!yasm_vp_string(vp)) { - fprintf(objfmt_dbg->dbgfile, "NULL\n"); - return NULL; - } - retval = yasm_object_get_general(object, yasm_vp_string(vp), 0, 0, 0, - &isnew, line); - if (isnew) { - fprintf(objfmt_dbg->dbgfile, "(new) "); - yasm_symtab_define_label(object->symtab, vp->val, - yasm_section_bcs_first(retval), 1, line); - } - yasm_section_set_default(retval, 0); - fprintf(objfmt_dbg->dbgfile, "\"%s\" section\n", vp->val); - return retval; -} - -static /*@observer@*/ /*@null@*/ yasm_symrec * -dbg_objfmt_get_special_sym(yasm_object *object, const char *name, - const char *parser) -{ - yasm_objfmt_dbg *objfmt_dbg = (yasm_objfmt_dbg *)object->objfmt; - fprintf(objfmt_dbg->dbgfile, - "PLUGIN get_special_sym(object, \"%s\", \"%s\")\n", - name, parser); - return NULL; -} - -/* Define valid debug formats to use with this object format */ -static const char *dbg_objfmt_dbgfmt_keywords[] = { - "null", - NULL -}; - -/* Define objfmt structure -- see objfmt.h for details */ -yasm_objfmt_module yasm_dbg_LTX_objfmt = { - "Trace of all info passed to object format module", - "dbg", - "dbg", - 32, - dbg_objfmt_dbgfmt_keywords, - "null", - NULL, /* no directives */ - NULL, /* no standard macros */ - dbg_objfmt_create, - dbg_objfmt_output, - dbg_objfmt_destroy, - dbg_objfmt_add_default_section, - dbg_objfmt_section_switch, - dbg_objfmt_get_special_sym -}; diff --git a/plugins/dbg/init_plugin.c b/plugins/dbg/init_plugin.c deleted file mode 100644 index 5c4eb6aa..00000000 --- a/plugins/dbg/init_plugin.c +++ /dev/null @@ -1,13 +0,0 @@ -#include -#include - -extern yasm_arch_module yasm_dbg_LTX_objfmt; - -#ifdef _WIN32 -__declspec(dllexport) -#endif -void -yasm_init_plugin(void) -{ - yasm_register_module(YASM_MODULE_OBJFMT, "dbg", &yasm_dbg_LTX_objfmt); -} diff --git a/plugins/x86/CMakeLists.txt b/plugins/x86/CMakeLists.txt deleted file mode 100644 index 87343dd3..00000000 --- a/plugins/x86/CMakeLists.txt +++ /dev/null @@ -1,149 +0,0 @@ -PROJECT(x86mod) -CMAKE_MINIMUM_REQUIRED(VERSION 2.4) - -SET(YASM_SOURCE_DIR "${PROJECT_SOURCE_DIR}/../.." - CACHE STRING "Location of Yasm source") - -IF (NOT YASM_SOURCE_DIR) - MESSAGE(FATAL_ERROR "YASM_SOURCE_DIR must be defined") -ENDIF (NOT YASM_SOURCE_DIR) - -SET(SOURCE_DIR "${YASM_SOURCE_DIR}/modules/arch/x86") - -SET (YASM_POSSIBLE_PATHS - "$ENV{ProgramFiles}/Yasm/Bin" - /usr/bin - /usr/local/bin - ) - -FIND_PROGRAM(YASM_PATH yasm - PATHS ${YASM_POSSIBLE_PATHS} - ) - -SET (GENPERF_POSSIBLE_PATHS - ${YASM_SOURCE_DIR}/objdir/tools/genperf - ${YASM_SOURCE_DIR}/objdir/tools/genperf/Debug - ${YASM_SOURCE_DIR}/objdir/tools/genperf/Release - ) - -FIND_PROGRAM(GENPERF_PATH genperf - DOC "The path to the yasm genperf executable" - PATHS ${GENPERF_POSSIBLE_PATHS} - ) - -IF (NOT GENPERF_PATH) - MESSAGE(FATAL_ERROR "Could not find genperf executable") -ENDIF (NOT GENPERF_PATH) - -SET (YASM_POSSIBLE_INCLUDE_PATHS - "${YASM_PATH}" - "${YASM_PATH}/../include" - "$ENV{ProgramFiles}/Yasm/Include" - /usr/include - /usr/local/include - ) - -FIND_PATH(YASM_INCLUDE_PATH NAMES libyasm.h - DOC "The path to the libyasm include files" - PATHS ${YASM_POSSIBLE_INCLUDE_PATHS} - ) - -IF (NOT YASM_INCLUDE_PATH) - MESSAGE(FATAL_ERROR "Could not find yasm include files") -ENDIF (NOT YASM_INCLUDE_PATH) - -INCLUDE_DIRECTORIES(${YASM_INCLUDE_PATH}) -INCLUDE_DIRECTORIES(${YASM_SOURCE_DIR}) - -SET (YASM_POSSIBLE_LIB_PATHS - "${YASM_PATH}" - "${YASM_PATH}/../lib" - "${YASM_INCLUDE_PATH}/../lib" - "$ENV{ProgramFiles}/Yasm/Lib" - /usr/lib - /usr/local/lib - ) - -FIND_LIBRARY(YASM_LIBRARY - NAMES yasm - DOC "The path to the libyasm library" - PATHS ${YASM_POSSIBLE_LIB_PATHS} - ) - -IF (NOT YASM_LIBRARY) - MESSAGE(FATAL_ERROR "Could not find yasm library") -ENDIF (NOT YASM_LIBRARY) - -INCLUDE(FindPythonInterp) - -IF (NOT PYTHON_EXECUTABLE) - MESSAGE(FATAL_ERROR "Could not find Python executable") -ENDIF (NOT PYTHON_EXECUTABLE) - -INCLUDE_DIRECTORIES(${SOURCE_DIR}) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) - -ADD_CUSTOM_COMMAND( - OUTPUT - ${CMAKE_CURRENT_BINARY_DIR}/x86insns.c - ${CMAKE_CURRENT_BINARY_DIR}/x86insn_gas.gperf - ${CMAKE_CURRENT_BINARY_DIR}/x86insn_nasm.gperf - COMMAND ${PYTHON_EXECUTABLE} ${SOURCE_DIR}/gen_x86_insn.py - ${CMAKE_CURRENT_BINARY_DIR}/x86insns.c - ${CMAKE_CURRENT_BINARY_DIR}/x86insn_gas.gperf - ${CMAKE_CURRENT_BINARY_DIR}/x86insn_nasm.gperf - MAIN_DEPENDENCY ${SOURCE_DIR}/gen_x86_insn.py - ) - -macro (YASM_GENPERF _in_NAME _out_NAME) - add_custom_command( - OUTPUT ${_out_NAME} - COMMAND ${GENPERF_PATH} ${_in_NAME} ${_out_NAME} - MAIN_DEPENDENCY ${_in_NAME} - ) -endmacro (YASM_GENPERF) - -YASM_GENPERF( - ${SOURCE_DIR}/x86cpu.gperf - ${CMAKE_CURRENT_BINARY_DIR}/x86cpu.c - ) - -YASM_GENPERF( - ${SOURCE_DIR}/x86regtmod.gperf - ${CMAKE_CURRENT_BINARY_DIR}/x86regtmod.c - ) - -YASM_GENPERF( - ${CMAKE_CURRENT_BINARY_DIR}/x86insn_nasm.gperf - ${CMAKE_CURRENT_BINARY_DIR}/x86insn_nasm.c - ) - -YASM_GENPERF( - ${CMAKE_CURRENT_BINARY_DIR}/x86insn_gas.gperf - ${CMAKE_CURRENT_BINARY_DIR}/x86insn_gas.c - ) - -SET(insn_DEPS - ${CMAKE_CURRENT_BINARY_DIR}/x86insn_nasm.c - ${CMAKE_CURRENT_BINARY_DIR}/x86insn_gas.c - ${CMAKE_CURRENT_BINARY_DIR}/x86insns.c - ) - -SET_SOURCE_FILES_PROPERTIES(${SOURCE_DIR}/x86id.c PROPERTIES - OBJECT_DEPENDS "${insn_DEPS}" - ) - -ADD_LIBRARY(x86mod MODULE - init_plugin.c - ${SOURCE_DIR}/x86arch.c - ${SOURCE_DIR}/x86bc.c - ${SOURCE_DIR}/x86expr.c - ${SOURCE_DIR}/x86id.c - x86cpu.c - x86regtmod.c - ) -TARGET_LINK_LIBRARIES(x86mod ${YASM_LIBRARY}) - -if(WIN32) - SET_PROPERTY(TARGET x86mod PROPERTY PREFIX "") -endif() diff --git a/plugins/x86/README b/plugins/x86/README deleted file mode 100644 index dddedd0d..00000000 --- a/plugins/x86/README +++ /dev/null @@ -1,19 +0,0 @@ -This directory demonstrates how to build a yasm builtin module as a plugin. -This can be useful for integrating custom changes without -rebuilding/reinstalling yasm. - -It requires access to the yasm source. It defaults to assuming it is being -built inside of the yasm source tree. - -To build: - mkdir objdir - cd objdir - cmake .. - make - -Testing (on Windows): - yasm -N Release/x86mod.dll -f x86 ... - -Testing (on Unix): - yasm -N ./libx86mod.so -f x86 ... - diff --git a/plugins/x86/init_plugin.c b/plugins/x86/init_plugin.c deleted file mode 100644 index 39a94ed0..00000000 --- a/plugins/x86/init_plugin.c +++ /dev/null @@ -1,13 +0,0 @@ -#include -#include - -extern yasm_arch_module yasm_x86_LTX_arch; - -#ifdef _WIN32 -__declspec(dllexport) -#endif -void -yasm_init_plugin(void) -{ - yasm_register_module(YASM_MODULE_ARCH, "x86", &yasm_x86_LTX_arch); -} diff --git a/po/.gitignore b/po/.gitignore deleted file mode 100644 index 38039dfd..00000000 --- a/po/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -Makefile.in.in -POTFILES -cat-id-tbl.c -yasm.pot -stamp-cat-id -remove-potcdate.sed -Makefile -Makefile.in -.*.swp -stamp-po diff --git a/po/ChangeLog b/po/ChangeLog index 3cafdef3..e69de29b 100644 --- a/po/ChangeLog +++ b/po/ChangeLog @@ -1,9 +0,0 @@ -2014-08-10 gettextize - - * Makefile.in.in: Upgrade to gettext-0.18.3. - * Rules-quot: Upgrade to gettext-0.18.3. - -2010-06-15 gettextize - - * Makefile.in.in: Upgrade to gettext-0.17. - diff --git a/po/Makefile.in.in b/po/Makefile.in.in index fabdc76c..5022b8b1 100644 --- a/po/Makefile.in.in +++ b/po/Makefile.in.in @@ -1,5 +1,5 @@ # Makefile for PO directory in any package using GNU gettext. -# Copyright (C) 1995-1997, 2000-2007, 2009-2010 by Ulrich Drepper +# Copyright (C) 1995-1997, 2000-2006 by Ulrich Drepper # # This file can be copied and used freely without restrictions. It can # be used in projects which are not available under the GNU General Public @@ -8,14 +8,12 @@ # Please note that the actual code of GNU gettext is covered by the GNU # General Public License and is *not* in the public domain. # -# Origin: gettext-0.18.3 -GETTEXT_MACRO_VERSION = 0.18 +# Origin: gettext-0.16 PACKAGE = @PACKAGE@ VERSION = @VERSION@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -SED = @SED@ SHELL = /bin/sh @SET_MAKE@ @@ -89,8 +87,8 @@ CATALOGS = @CATALOGS@ .po.gmo: @lang=`echo $* | sed -e 's,.*/,,'`; \ test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \ - echo "$${cdcmd}rm -f $${lang}.gmo && $(GMSGFMT) -c --statistics --verbose -o $${lang}.gmo $${lang}.po"; \ - cd $(srcdir) && rm -f $${lang}.gmo && $(GMSGFMT) -c --statistics --verbose -o t-$${lang}.gmo $${lang}.po && mv t-$${lang}.gmo $${lang}.gmo + echo "$${cdcmd}rm -f $${lang}.gmo && $(GMSGFMT) -c --statistics -o $${lang}.gmo $${lang}.po"; \ + cd $(srcdir) && rm -f $${lang}.gmo && $(GMSGFMT) -c --statistics -o t-$${lang}.gmo $${lang}.po && mv t-$${lang}.gmo $${lang}.gmo .sin.sed: sed -e '/^#/d' $< > t-$@ @@ -102,13 +100,6 @@ all: all-@USE_NLS@ all-yes: stamp-po all-no: -# Ensure that the gettext macros and this Makefile.in.in are in sync. -CHECK_MACRO_VERSION = \ - test "$(GETTEXT_MACRO_VERSION)" = "@GETTEXT_MACRO_VERSION@" \ - || { echo "*** error: gettext infrastructure mismatch: using a Makefile.in.in from gettext version $(GETTEXT_MACRO_VERSION) but the autoconf macros are from gettext version @GETTEXT_MACRO_VERSION@" 1>&2; \ - exit 1; \ - } - # $(srcdir)/$(DOMAIN).pot is only created when needed. When xgettext finds no # internationalized messages, no $(srcdir)/$(DOMAIN).pot is created (because # we don't want to bother translators with empty POT files). We assume that @@ -124,7 +115,6 @@ CHECK_MACRO_VERSION = \ # $(POFILES) has been designed to not touch files that don't need to be # changed. stamp-po: $(srcdir)/$(DOMAIN).pot - @$(CHECK_MACRO_VERSION) test ! -f $(srcdir)/$(DOMAIN).pot || \ test -z "$(GMOFILES)" || $(MAKE) $(GMOFILES) @test ! -f $(srcdir)/$(DOMAIN).pot || { \ @@ -139,43 +129,17 @@ stamp-po: $(srcdir)/$(DOMAIN).pot # This target rebuilds $(DOMAIN).pot; it is an expensive operation. # Note that $(DOMAIN).pot is not touched if it doesn't need to be changed. -# The determination of whether the package xyz is a GNU one is based on the -# heuristic whether some file in the top level directory mentions "GNU xyz". -# If GNU 'find' is available, we avoid grepping through monster files. $(DOMAIN).pot-update: $(POTFILES) $(srcdir)/POTFILES.in remove-potcdate.sed - if { if (LC_ALL=C find --version) 2>/dev/null | grep GNU >/dev/null; then \ - LC_ALL=C find -L $(top_srcdir) -maxdepth 1 -type f -size -10000000c -exec grep 'GNU @PACKAGE@' /dev/null '{}' ';' 2>/dev/null; \ - else \ - LC_ALL=C grep 'GNU @PACKAGE@' $(top_srcdir)/* 2>/dev/null; \ - fi; \ - } | grep -v 'libtool:' >/dev/null; then \ - package_gnu='GNU '; \ - else \ - package_gnu=''; \ - fi; \ if test -n '$(MSGID_BUGS_ADDRESS)' || test '$(PACKAGE_BUGREPORT)' = '@'PACKAGE_BUGREPORT'@'; then \ msgid_bugs_address='$(MSGID_BUGS_ADDRESS)'; \ else \ msgid_bugs_address='$(PACKAGE_BUGREPORT)'; \ fi; \ - case `$(XGETTEXT) --version | sed 1q | sed -e 's,^[^0-9]*,,'` in \ - '' | 0.[0-9] | 0.[0-9].* | 0.1[0-5] | 0.1[0-5].* | 0.16 | 0.16.[0-1]*) \ - $(XGETTEXT) --default-domain=$(DOMAIN) --directory=$(top_srcdir) \ - --add-comments=TRANSLATORS: $(XGETTEXT_OPTIONS) @XGETTEXT_EXTRA_OPTIONS@ \ - --files-from=$(srcdir)/POTFILES.in \ - --copyright-holder='$(COPYRIGHT_HOLDER)' \ - --msgid-bugs-address="$$msgid_bugs_address" \ - ;; \ - *) \ - $(XGETTEXT) --default-domain=$(DOMAIN) --directory=$(top_srcdir) \ - --add-comments=TRANSLATORS: $(XGETTEXT_OPTIONS) @XGETTEXT_EXTRA_OPTIONS@ \ - --files-from=$(srcdir)/POTFILES.in \ - --copyright-holder='$(COPYRIGHT_HOLDER)' \ - --package-name="$${package_gnu}@PACKAGE@" \ - --package-version='@VERSION@' \ - --msgid-bugs-address="$$msgid_bugs_address" \ - ;; \ - esac + $(XGETTEXT) --default-domain=$(DOMAIN) --directory=$(top_srcdir) \ + --add-comments=TRANSLATORS: $(XGETTEXT_OPTIONS) \ + --files-from=$(srcdir)/POTFILES.in \ + --copyright-holder='$(COPYRIGHT_HOLDER)' \ + --msgid-bugs-address="$$msgid_bugs_address" test ! -f $(DOMAIN).po || { \ if test -f $(srcdir)/$(DOMAIN).pot; then \ sed -f remove-potcdate.sed < $(srcdir)/$(DOMAIN).pot > $(DOMAIN).1po && \ @@ -203,15 +167,8 @@ $(POFILES): $(srcdir)/$(DOMAIN).pot @lang=`echo $@ | sed -e 's,.*/,,' -e 's/\.po$$//'`; \ if test -f "$(srcdir)/$${lang}.po"; then \ test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \ - echo "$${cdcmd}$(MSGMERGE_UPDATE) $(MSGMERGE_OPTIONS) --lang=$${lang} $${lang}.po $(DOMAIN).pot"; \ - cd $(srcdir) \ - && { case `$(MSGMERGE_UPDATE) --version | sed 1q | sed -e 's,^[^0-9]*,,'` in \ - '' | 0.[0-9] | 0.[0-9].* | 0.1[0-7] | 0.1[0-7].*) \ - $(MSGMERGE_UPDATE) $(MSGMERGE_OPTIONS) $${lang}.po $(DOMAIN).pot;; \ - *) \ - $(MSGMERGE_UPDATE) $(MSGMERGE_OPTIONS) --lang=$${lang} $${lang}.po $(DOMAIN).pot;; \ - esac; \ - }; \ + echo "$${cdcmd}$(MSGMERGE_UPDATE) $${lang}.po $(DOMAIN).pot"; \ + cd $(srcdir) && $(MSGMERGE_UPDATE) $${lang}.po $(DOMAIN).pot; \ else \ $(MAKE) $${lang}.po-create; \ fi @@ -234,6 +191,7 @@ install-data: install-data-@USE_NLS@ fi install-data-no: all install-data-yes: all + $(mkdir_p) $(DESTDIR)$(datadir) @catalogs='$(CATALOGS)'; \ for cat in $$catalogs; do \ cat=`basename $$cat`; \ @@ -285,6 +243,7 @@ installdirs-data: installdirs-data-@USE_NLS@ fi installdirs-data-no: installdirs-data-yes: + $(mkdir_p) $(DESTDIR)$(datadir) @catalogs='$(CATALOGS)'; \ for cat in $$catalogs; do \ cat=`basename $$cat`; \ @@ -410,15 +369,9 @@ update-po: Makefile tmpdir=`pwd`; \ echo "$$lang:"; \ test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \ - echo "$${cdcmd}$(MSGMERGE) $(MSGMERGE_OPTIONS) --lang=$$lang $$lang.po $(DOMAIN).pot -o $$lang.new.po"; \ + echo "$${cdcmd}$(MSGMERGE) $$lang.po $(DOMAIN).pot -o $$lang.new.po"; \ cd $(srcdir); \ - if { case `$(MSGMERGE) --version | sed 1q | sed -e 's,^[^0-9]*,,'` in \ - '' | 0.[0-9] | 0.[0-9].* | 0.1[0-7] | 0.1[0-7].*) \ - $(MSGMERGE) $(MSGMERGE_OPTIONS) -o $$tmpdir/$$lang.new.po $$lang.po $(DOMAIN).pot;; \ - *) \ - $(MSGMERGE) $(MSGMERGE_OPTIONS) --lang=$$lang -o $$tmpdir/$$lang.new.po $$lang.po $(DOMAIN).pot;; \ - esac; \ - }; then \ + if $(MSGMERGE) $$lang.po $(DOMAIN).pot -o $$tmpdir/$$lang.new.po; then \ if cmp $$lang.po $$tmpdir/$$lang.new.po >/dev/null 2>&1; then \ rm -f $$tmpdir/$$lang.new.po; \ else \ @@ -439,13 +392,9 @@ $(DUMMYPOFILES): update-gmo: Makefile $(GMOFILES) @: -# Recreate Makefile by invoking config.status. Explicitly invoke the shell, -# because execution permission bits may not work on the current file system. -# Use @SHELL@, which is the shell determined by autoconf for the use by its -# scripts, not $(SHELL) which is hardwired to /bin/sh and may be deficient. Makefile: Makefile.in.in Makevars $(top_builddir)/config.status @POMAKEFILEDEPS@ cd $(top_builddir) \ - && @SHELL@ ./config.status $(subdir)/$@.in po-directories + && $(SHELL) ./config.status $(subdir)/$@.in po-directories force: diff --git a/po/Makevars b/po/Makevars index 589f9f15..89166e06 100644 --- a/po/Makevars +++ b/po/Makevars @@ -39,15 +39,3 @@ MSGID_BUGS_ADDRESS = bug-yasm@tortall.net # This is the list of locale categories, beyond LC_MESSAGES, for which the # message catalogs shall be used. It is usually empty. EXTRA_LOCALE_CATEGORIES = - -# This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt' -# context. Possible values are "yes" and "no". Set this to yes if the -# package uses functions taking also a message context, like pgettext(), or -# if in $(XGETTEXT_OPTIONS) you define keywords with a context argument. -USE_MSGCTXT = no - -# These options get passed to msgmerge. -# Useful options are in particular: -# --previous to keep previous msgids of translated messages, -# --quiet to reduce the verbosity. -MSGMERGE_OPTIONS = diff --git a/po/Makevars.template b/po/Makevars.template new file mode 100644 index 00000000..32692ab4 --- /dev/null +++ b/po/Makevars.template @@ -0,0 +1,41 @@ +# Makefile variables for PO directory in any package using GNU gettext. + +# Usually the message domain is the same as the package name. +DOMAIN = $(PACKAGE) + +# These two variables depend on the location of this directory. +subdir = po +top_builddir = .. + +# These options get passed to xgettext. +XGETTEXT_OPTIONS = --keyword=_ --keyword=N_ + +# This is the copyright holder that gets inserted into the header of the +# $(DOMAIN).pot file. Set this to the copyright holder of the surrounding +# package. (Note that the msgstr strings, extracted from the package's +# sources, belong to the copyright holder of the package.) Translators are +# expected to transfer the copyright for their translations to this person +# or entity, or to disclaim their copyright. The empty string stands for +# the public domain; in this case the translators are expected to disclaim +# their copyright. +COPYRIGHT_HOLDER = Free Software Foundation, Inc. + +# This is the email address or URL to which the translators shall report +# bugs in the untranslated strings: +# - Strings which are not entire sentences, see the maintainer guidelines +# in the GNU gettext documentation, section 'Preparing Strings'. +# - Strings which use unclear terms or require additional context to be +# understood. +# - Strings which make invalid assumptions about notation of date, time or +# money. +# - Pluralisation problems. +# - Incorrect English spelling. +# - Incorrect formatting. +# It can be your email address, or a mailing list address where translators +# can write to without being subscribed, or the URL of a web page through +# which the translators can contact you. +MSGID_BUGS_ADDRESS = + +# This is the list of locale categories, beyond LC_MESSAGES, for which the +# message catalogs shall be used. It is usually empty. +EXTRA_LOCALE_CATEGORIES = diff --git a/po/POTFILES.in b/po/POTFILES.in index dc17f974..987b022c 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -1,12 +1,16 @@ # List of source files containing translatable strings. # To update, try "find . -name \*.c | xargs grep -c _\( | grep -v :0 | sort" # Copyright (c) 2001 Peter Johnson +# +# $Id$ frontends/yasm/yasm-options.c frontends/yasm/yasm.c +#lc3bid.c libyasm/bc-align.c libyasm/bc-data.c libyasm/bc-incbin.c +libyasm/bc-insn.c libyasm/bc-org.c libyasm/bc-reserve.c libyasm/bitvect.c @@ -16,15 +20,13 @@ libyasm/expr.c libyasm/file.c libyasm/floatnum.c libyasm/hamt.c -libyasm/insn.c libyasm/intnum.c libyasm/section.c libyasm/symrec.c -libyasm/valparam.c libyasm/value.c libyasm/xmalloc.c -modules/arch/lc3b/lc3barch.c -modules/arch/lc3b/lc3bbc.c +#modules/arch/lc3b/lc3barch.c +#modules/arch/lc3b/lc3bbc.c modules/arch/x86/x86arch.c modules/arch/x86/x86bc.c modules/arch/x86/x86expr.c @@ -52,9 +54,5 @@ modules/parsers/gas/gas-parser.c modules/parsers/gas/gas-token.re modules/parsers/nasm/nasm-parse.c modules/parsers/nasm/nasm-token.re -modules/preprocs/cpp/cpp-preproc.c -modules/preprocs/gas/gas-preproc.c -modules/preprocs/gas/gas-eval.c -modules/preprocs/nasm/nasm-preproc.c modules/preprocs/nasm/nasm-pp.c modules/preprocs/raw/raw-preproc.c diff --git a/po/Rules-quot b/po/Rules-quot index 5931e539..9c2a995e 100644 --- a/po/Rules-quot +++ b/po/Rules-quot @@ -14,13 +14,13 @@ en@boldquot.po-update: en@boldquot.po-update-en .insert-header.po-update-en: @lang=`echo $@ | sed -e 's/\.po-update-en$$//'`; \ - if test "$(PACKAGE)" = "gettext-tools"; then PATH=`pwd`/../src:$$PATH; GETTEXTLIBDIR=`cd $(top_srcdir)/src && pwd`; export GETTEXTLIBDIR; fi; \ + if test "$(PACKAGE)" = "gettext"; then PATH=`pwd`/../src:$$PATH; GETTEXTLIBDIR=`cd $(top_srcdir)/src && pwd`; export GETTEXTLIBDIR; fi; \ tmpdir=`pwd`; \ echo "$$lang:"; \ ll=`echo $$lang | sed -e 's/@.*//'`; \ LC_ALL=C; export LC_ALL; \ cd $(srcdir); \ - if $(MSGINIT) -i $(DOMAIN).pot --no-translator -l $$lang -o - 2>/dev/null | sed -f $$tmpdir/$$lang.insert-header | $(MSGCONV) -t UTF-8 | $(MSGFILTER) $(SED) -f `echo $$lang | sed -e 's/.*@//'`.sed 2>/dev/null > $$tmpdir/$$lang.new.po; then \ + if $(MSGINIT) -i $(DOMAIN).pot --no-translator -l $$ll -o - 2>/dev/null | sed -f $$tmpdir/$$lang.insert-header | $(MSGCONV) -t UTF-8 | $(MSGFILTER) sed -f `echo $$lang | sed -e 's/.*@//'`.sed 2>/dev/null > $$tmpdir/$$lang.new.po; then \ if cmp $$lang.po $$tmpdir/$$lang.new.po >/dev/null 2>&1; then \ rm -f $$tmpdir/$$lang.new.po; \ else \ diff --git a/splint.sh b/splint.sh index 56850ff3..03d1867f 100755 --- a/splint.sh +++ b/splint.sh @@ -11,77 +11,33 @@ splint \ -retvalother \ -shiftimplementation \ -shiftnegative \ - -fixedformalarray \ +ansi89limits \ - +ansistrictlib \ - +trytorecover \ - -globs \ - -I. \ -I/usr/local/include \ + -Isrc \ + -Isrc/arch/x86 \ + -I. \ -DHAVE_CONFIG_H \ + -DHAVE_BOGUS_SYS_QUEUE_H \ -Dlint \ - frontends/yasm/yasm-options.c \ - frontends/yasm/yasm.c \ - libyasm/arch.c \ - libyasm/assocdat.c \ - libyasm/bc-align.c \ - libyasm/bc-data.c \ - libyasm/bc-incbin.c \ - libyasm/bc-insn.c \ - libyasm/bc-org.c \ - libyasm/bc-reserve.c \ - libyasm/bytecode.c \ - libyasm/errwarn.c \ - libyasm/expr.c \ - libyasm/file.c \ - libyasm/floatnum.c \ - libyasm/hamt.c \ - libyasm/intnum.c \ - libyasm/inttree.c \ - libyasm/linemap.c \ - libyasm/md5.c \ - libyasm/mergesort.c \ - libyasm/phash.c \ - libyasm/section.c \ - libyasm/strcasecmp.c \ - libyasm/strsep.c \ - libyasm/symrec.c \ - libyasm/valparam.c \ - libyasm/value.c \ - libyasm/xmalloc.c \ - libyasm/xstrdup.c \ - modules/arch/lc3b/lc3barch.c \ - modules/arch/lc3b/lc3bbc.c \ - modules/arch/x86/x86arch.c \ - modules/arch/x86/x86bc.c \ - modules/arch/x86/x86expr.c \ - modules/arch/x86/x86id.c \ - modules/dbgfmts/codeview/cv-dbgfmt.c \ - modules/dbgfmts/codeview/cv-symline.c \ - modules/dbgfmts/codeview/cv-type.c \ - modules/dbgfmts/dwarf2/dwarf2-aranges.c \ - modules/dbgfmts/dwarf2/dwarf2-dbgfmt.c \ - modules/dbgfmts/dwarf2/dwarf2-info.c \ - modules/dbgfmts/dwarf2/dwarf2-line.c \ - modules/dbgfmts/null/null-dbgfmt.c \ - modules/dbgfmts/stabs/stabs-dbgfmt.c \ - modules/listfmts/nasm/nasm-listfmt.c \ - modules/objfmts/bin/bin-objfmt.c \ - modules/objfmts/coff/coff-objfmt.c \ - modules/objfmts/coff/win64-except.c \ - modules/objfmts/dbg/dbg-objfmt.c \ - modules/objfmts/elf/elf-objfmt.c \ - modules/objfmts/elf/elf-x86-amd64.c \ - modules/objfmts/elf/elf-x86-x86.c \ - modules/objfmts/elf/elf.c \ - modules/objfmts/macho/macho-objfmt.c \ - modules/objfmts/rdf/rdf-objfmt.c \ - modules/objfmts/xdf/xdf-objfmt.c \ - modules/parsers/gas/gas-parse.c \ - modules/parsers/gas/gas-parse-intel.c \ - modules/parsers/gas/gas-parser.c \ - modules/parsers/nasm/nasm-parse.c \ - modules/parsers/nasm/nasm-parser.c \ - modules/preprocs/nasm/nasm-preproc.c \ - modules/preprocs/raw/raw-preproc.c - + src/main.c \ + src/options.c \ + src/arch.c \ + src/bytecode.c \ + src/errwarn.c \ + src/expr.c \ + src/file.c \ + src/floatnum.c \ + src/globals.c \ + src/intnum.c \ + src/parser.c \ + src/section.c \ + src/arch/x86/x86arch.c \ + src/arch/x86/x86bc.c \ + src/arch/x86/x86expr.c \ + src/objfmts/dbg/dbg-objfmt.c \ + src/objfmts/bin/bin-objfmt.c \ + src/parsers/nasm/nasm-parser.c \ + src/preprocs/raw/raw-preproc.c \ + src/optimizers/basic/basic-optimizer.c \ + src/symrec.c \ + src/hamt.c diff --git a/test_hd.c b/test_hd.c index 8ae5cabe..54838e6a 100644 --- a/test_hd.c +++ b/test_hd.c @@ -1,4 +1,4 @@ -/* +/* $Id$ * * Simple hexidecimal dump, two hex digits per line. * @@ -35,23 +35,23 @@ main(int argc, char *argv[]) int ch; if (argc != 2) { - fprintf(stderr, "Usage: %s \n", argv[0]); - return EXIT_FAILURE; + fprintf(stderr, "Usage: %s \n", argv[0]); + return EXIT_FAILURE; } bfile = fopen(argv[1], "rb"); if (!bfile) { - fprintf(stderr, "Could not open `%s'.\n", argv[1]); - return EXIT_FAILURE; + fprintf(stderr, "Could not open `%s'.\n", argv[1]); + return EXIT_FAILURE; } while ((ch = fgetc(bfile)) != EOF) - printf("%02x \n", ch); + printf("%02x \n", ch); if (ferror(bfile)) { - fprintf(stderr, "Error reading from `%s'.\n", argv[1]); - return EXIT_FAILURE; + fprintf(stderr, "Error reading from `%s'.\n", argv[1]); + return EXIT_FAILURE; } fclose(bfile); diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt deleted file mode 100644 index 4b83d4eb..00000000 --- a/tools/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -ADD_SUBDIRECTORY(genmacro) -ADD_SUBDIRECTORY(genperf) -ADD_SUBDIRECTORY(re2c) diff --git a/tools/Makefile.inc b/tools/Makefile.inc index dbc67fcb..264b8e16 100644 --- a/tools/Makefile.inc +++ b/tools/Makefile.inc @@ -1,9 +1,7 @@ +# $Id$ + EXTRA_DIST += tools/re2c/Makefile.inc -EXTRA_DIST += tools/genmacro/Makefile.inc -EXTRA_DIST += tools/genperf/Makefile.inc -EXTRA_DIST += tools/python-yasm/Makefile.inc +EXTRA_DIST += tools/gap/Makefile.inc include tools/re2c/Makefile.inc -include tools/genmacro/Makefile.inc -include tools/genperf/Makefile.inc -include tools/python-yasm/Makefile.inc +include tools/gap/Makefile.inc diff --git a/tools/gap/Makefile.inc b/tools/gap/Makefile.inc new file mode 100644 index 00000000..4457af76 --- /dev/null +++ b/tools/gap/Makefile.inc @@ -0,0 +1,34 @@ +# $Id$ + +# These utility programs have to be built for BUILD host in cross-build. +# This makes things rather non-standard automake + +noinst_PROGRAMS += gap + +gap_SOURCES = +EXTRA_DIST += tools/gap/gap.c +EXTRA_DIST += tools/gap/perfect.c +EXTRA_DIST += tools/gap/perfect.h +EXTRA_DIST += tools/gap/standard.h +gap_LDADD = gap.$(OBJEXT) +gap_LDADD += gap-perfect.$(OBJEXT) +gap_LDADD += gap-phash.$(OBJEXT) +gap_LDADD += gap-xmalloc.$(OBJEXT) +gap_LDADD += gap-xstrdup.$(OBJEXT) +gap_LINK = $(CCLD_FOR_BUILD) -o $@ + +gap.$(OBJEXT): tools/gap/gap.c + $(CC_FOR_BUILD) $(DEFAULT_INCLUDES) $(INCLUDES) -c -o $@ `test -f tools/gap/gap.c || echo '$(srcdir)/'`tools/gap/gap.c + +gap-perfect.$(OBJEXT): tools/gap/perfect.c + $(CC_FOR_BUILD) $(DEFAULT_INCLUDES) $(INCLUDES) -c -o $@ `test -f tools/gap/perfect.c || echo '$(srcdir)/'`tools/gap/perfect.c + +gap-phash.$(OBJEXT): libyasm/phash.c + $(CC_FOR_BUILD) $(DEFAULT_INCLUDES) $(INCLUDES) -c -o $@ `test -f libyasm/phash.c || echo '$(srcdir)/'`libyasm/phash.c + +gap-xmalloc.$(OBJEXT): libyasm/xmalloc.c + $(CC_FOR_BUILD) $(DEFAULT_INCLUDES) $(INCLUDES) -c -o $@ `test -f libyasm/xmalloc.c || echo '$(srcdir)/'`libyasm/xmalloc.c + +gap-xstrdup.$(OBJEXT): libyasm/xstrdup.c + $(CC_FOR_BUILD) $(DEFAULT_INCLUDES) $(INCLUDES) -c -o $@ `test -f libyasm/xstrdup.c || echo '$(srcdir)/'`libyasm/xstrdup.c + diff --git a/tools/gap/gap.c b/tools/gap/gap.c new file mode 100644 index 00000000..c4aaf807 --- /dev/null +++ b/tools/gap/gap.c @@ -0,0 +1,854 @@ +/* $Id$ + * + * Generate Arch Parser (GAP): generates ARCHparse.c from ARCHparse.gap. + * + * Copyright (C) 2006-2007 Peter Johnson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND OTHER CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR OTHER CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +#include +#include +#include +#include +#include "tools/gap/perfect.h" +#include "libyasm/compat-queue.h" +#include "libyasm/coretype.h" +#include "libyasm/errwarn.h" + +typedef STAILQ_HEAD(slist, sval) slist; +typedef struct sval { + STAILQ_ENTRY(sval) link; + char *str; +} sval; + +typedef STAILQ_HEAD(dir_list, dir) dir_list; +typedef struct dir { + STAILQ_ENTRY(dir) link; + char *name; + const char *func; + slist args; +} dir; + +typedef STAILQ_HEAD(dir_byp_list, dir_byp) dir_byp_list; +typedef struct dir_byp { + STAILQ_ENTRY(dir_byp) link; + /*@null@*/ char *parser; + dir_list dirs; +} dir_byp; + +typedef enum { + ARCH = 0, + PARSERS, + INSN, + CPU, + CPU_ALIAS, + CPU_FEATURE, + TARGETMOD, + PREFIX, + REG, + REGGROUP, + SEGREG, + NUM_DIRS +} dir_type; + +typedef struct { + void (*parse_insn) (void); /* arch-specific parse_insn */ + int multi_parser[NUM_DIRS]; /* whether it has an initial parser field */ +} arch_handler; + +static void x86_parse_insn(void); +static const arch_handler arch_x86 = { + x86_parse_insn, + {0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0} +}; + +static struct { + const char *name; + const arch_handler *arch; +} archs[] = { + {"x86", &arch_x86}, +}; + +static char line[1024]; +static unsigned int cur_line = 0, next_line = 1; +static int errors = 0; +static const arch_handler *arch = NULL; + +/* Lists of directives, keyed by parser name */ +static dir_byp_list insnprefix_byp; +static dir_byp_list cpu_byp; +static dir_byp_list regtmod_byp; + +static void +report_error(const char *fmt, ...) +{ + va_list ap; + + fprintf(stderr, "%u: ", cur_line); + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); + va_end(ap); + fputc('\n', stderr); + errors++; +} + +void +yasm__fatal(const char *message, ...) +{ + abort(); +} + +static void +dup_slist(slist *out, slist *in) +{ + sval *sv; + + STAILQ_INIT(out); + STAILQ_FOREACH(sv, in, link) { + sval *nsv = yasm_xmalloc(sizeof(sval)); + nsv->str = yasm__xstrdup(sv->str); + STAILQ_INSERT_TAIL(out, nsv, link); + } +} + +static dir * +dup_dir(dir *in) +{ + dir *out = yasm_xmalloc(sizeof(dir)); + out->name = yasm__xstrdup(in->name); + out->func = in->func; + dup_slist(&out->args, &in->args); + return out; +} + +static dir_list * +get_dirs(dir_byp_list *byp, /*@null@*/ const char *parser) +{ + dir_list *found = NULL; + dir_byp *db; + + if (STAILQ_EMPTY(byp)) { + report_error("PARSERS not yet specified"); + return NULL; + } + + STAILQ_FOREACH(db, byp, link) { + if ((!parser && !db->parser) || + (parser && db->parser && strcmp(parser, db->parser) == 0)) { + found = &db->dirs; + break; + } + } + + return found; +} + +/* Add a keyword/data to a slist of slist keyed by parser name. + * Returns nonzero on error. + */ +static int +add_dir(dir_byp_list *byp, /*@null@*/ const char *parser, dir *d) +{ + dir_list *found = get_dirs(byp, parser); + + if (found) { + STAILQ_INSERT_TAIL(found, d, link); + return 0; + } else if (!parser) { + /* Add separately to all */ + dir_byp *db; + int first = 1; + STAILQ_FOREACH(db, byp, link) { + if (!first) + d = dup_dir(d); + first = 0; + STAILQ_INSERT_TAIL(&db->dirs, d, link); + } + return 0; + } else { + report_error("parser not found"); + return 1; + } +} + +static char * +check_parser(dir_type type) +{ + char *parser = NULL; + + if (arch->multi_parser[type]) { + parser = strtok(NULL, " \t\n"); + if (strcmp(parser, "-") == 0) + parser = NULL; + } + + return parser; +} + +static void +parse_args(slist *args) +{ + char *tok; + sval *sv; + + STAILQ_INIT(args); + + tok = strtok(NULL, " \t\n"); + if (!tok) { + report_error("no args"); + return; + } + + while (tok) { + sv = yasm_xmalloc(sizeof(sval)); + sv->str = yasm__xstrdup(tok); + STAILQ_INSERT_TAIL(args, sv, link); + tok = strtok(NULL, " \t\n"); + } +} + +static dir * +parse_generic(dir_type type, const char *func, dir_byp_list *byp) +{ + char *parser = check_parser(type); + char *name = strtok(NULL, " \t\n"); + dir *d = yasm_xmalloc(sizeof(dir)); + + d->name = yasm__xstrdup(name); + d->func = func; + parse_args(&d->args); + + add_dir(byp, parser, d); + return d; +} + +static void +parse_arch(void) +{ + size_t i; + int found = 0; + char *tok = strtok(NULL, " \t\n"); + + if (!tok) { + report_error("ARCH requires an operand"); + return; + } + for (i=0; imulti_parser[INSN] || arch->multi_parser[PREFIX]) { + db = yasm_xmalloc(sizeof(dir_byp)); + db->parser = yasm__xstrdup(tok); + STAILQ_INIT(&db->dirs); + + STAILQ_INSERT_TAIL(&insnprefix_byp, db, link); + } + if (arch->multi_parser[CPU] || arch->multi_parser[CPU_ALIAS] || + arch->multi_parser[CPU_FEATURE]) { + db = yasm_xmalloc(sizeof(dir_byp)); + db->parser = yasm__xstrdup(tok); + STAILQ_INIT(&db->dirs); + + STAILQ_INSERT_TAIL(&cpu_byp, db, link); + } + if (arch->multi_parser[TARGETMOD] || arch->multi_parser[REG] || + arch->multi_parser[REGGROUP] || arch->multi_parser[SEGREG]) { + db = yasm_xmalloc(sizeof(dir_byp)); + db->parser = yasm__xstrdup(tok); + STAILQ_INIT(&db->dirs); + + STAILQ_INSERT_TAIL(®tmod_byp, db, link); + } + tok = strtok(NULL, " \t\n"); + } + + /* Add NULL (global) versions if not already created */ + if (STAILQ_EMPTY(&insnprefix_byp)) { + db = yasm_xmalloc(sizeof(dir_byp)); + db->parser = NULL; + STAILQ_INIT(&db->dirs); + + STAILQ_INSERT_TAIL(&insnprefix_byp, db, link); + } + if (STAILQ_EMPTY(&cpu_byp)) { + db = yasm_xmalloc(sizeof(dir_byp)); + db->parser = NULL; + STAILQ_INIT(&db->dirs); + + STAILQ_INSERT_TAIL(&cpu_byp, db, link); + } + if (STAILQ_EMPTY(®tmod_byp)) { + db = yasm_xmalloc(sizeof(dir_byp)); + db->parser = NULL; + STAILQ_INIT(&db->dirs); + + STAILQ_INSERT_TAIL(®tmod_byp, db, link); + } +} + +static void +x86_parse_insn(void) +{ + char *parser = check_parser(INSN); + char *bname = strtok(NULL, " \t\n"); + char *suffix = strtok(NULL, " \t\n"); + dir *d; + slist args; + sval *sv; + + if (!suffix) { + report_error("INSN requires suffix"); + return; + } + + /* save the remainder of args */ + parse_args(&args); + + if (suffix[0] != '"') { + /* Just one instruction to generate */ + sv = yasm_xmalloc(sizeof(sval)); + sv->str = yasm__xstrdup(suffix); + STAILQ_INSERT_HEAD(&args, sv, link); + + d = yasm_xmalloc(sizeof(dir)); + d->name = yasm__xstrdup(bname); + d->func = "INSN"; + d->args = args; + add_dir(&insnprefix_byp, parser, d); + } else { + /* Need to generate with suffixes for gas */ + char *p; + char sufstr[6]; + size_t bnamelen = strlen(bname); + + strcpy(sufstr, "SUF_X"); + + for (p = &suffix[1]; *p != '"'; p++) { + sufstr[4] = toupper(*p); + + d = yasm_xmalloc(sizeof(dir)); + + d->name = yasm_xmalloc(bnamelen+2); + strcpy(d->name, bname); + d->name[bnamelen] = tolower(*p); + d->name[bnamelen+1] = '\0'; + + d->func = "INSN"; + dup_slist(&d->args, &args); + + sv = yasm_xmalloc(sizeof(sval)); + sv->str = yasm__xstrdup(sufstr); + STAILQ_INSERT_HEAD(&d->args, sv, link); + + add_dir(&insnprefix_byp, "gas", d); + } + + /* And finally the version sans suffix */ + sv = yasm_xmalloc(sizeof(sval)); + sv->str = yasm__xstrdup("NONE"); + STAILQ_INSERT_HEAD(&args, sv, link); + + d = yasm_xmalloc(sizeof(dir)); + d->name = yasm__xstrdup(bname); + d->func = "INSN"; + d->args = args; + add_dir(&insnprefix_byp, parser, d); + } +} + +static void +parse_insn(void) +{ + if (!arch) { + report_error("ARCH not defined prior to INSN"); + return; + } + arch->parse_insn(); +} + +static void +parse_cpu(void) +{ + dir *d = parse_generic(CPU, "CPU", &cpu_byp); + sval *sv = yasm_xmalloc(sizeof(sval)); + sv->str = yasm__xstrdup("CPU_MODE_VERBATIM"); + STAILQ_INSERT_TAIL(&d->args, sv, link); +} + +static void +parse_cpu_alias(void) +{ + char *parser = check_parser(CPU_ALIAS); + char *name = strtok(NULL, " \t\n"); + char *alias = strtok(NULL, " \t\n"); + dir_list *dirs = get_dirs(&cpu_byp, parser); + dir *aliasd, *d; + + if (!alias) { + report_error("CPU_ALIAS requires an operand"); + return; + } + + STAILQ_FOREACH(aliasd, dirs, link) { + if (strcmp(aliasd->name, alias) == 0) + break; + } + if (!aliasd) { + report_error("could not find `%s'", alias); + return; + } + + d = yasm_xmalloc(sizeof(dir)); + d->name = yasm__xstrdup(name); + d->func = "CPU"; + dup_slist(&d->args, &aliasd->args); + + add_dir(&cpu_byp, parser, d); +} + +static void +parse_cpu_feature(void) +{ + char *parser = check_parser(CPU_FEATURE); + char *name = strtok(NULL, " \t\n"); + dir *name_dir = yasm_xmalloc(sizeof(dir)); + dir *noname_dir = yasm_xmalloc(sizeof(dir)); + sval *sv; + + name_dir->name = yasm__xstrdup(name); + name_dir->func = "CPU_FEATURE"; + parse_args(&name_dir->args); + + noname_dir->name = yasm_xmalloc(strlen(name)+3); + strcpy(noname_dir->name, "no"); + strcat(noname_dir->name, name); + noname_dir->func = name_dir->func; + dup_slist(&noname_dir->args, &name_dir->args); + + sv = yasm_xmalloc(sizeof(sval)); + sv->str = yasm__xstrdup("CPU_MODE_SET"); + STAILQ_INSERT_TAIL(&name_dir->args, sv, link); + + sv = yasm_xmalloc(sizeof(sval)); + sv->str = yasm__xstrdup("CPU_MODE_CLEAR"); + STAILQ_INSERT_TAIL(&noname_dir->args, sv, link); + + add_dir(&cpu_byp, parser, name_dir); + add_dir(&cpu_byp, parser, noname_dir); +} + +static void +parse_targetmod(void) +{ + parse_generic(TARGETMOD, "TARGETMOD", ®tmod_byp); +} + +static void +parse_prefix(void) +{ + parse_generic(PREFIX, "PREFIX", &insnprefix_byp); +} + +static void +parse_reg(void) +{ + parse_generic(REG, "REG", ®tmod_byp); +} + +static void +parse_reggroup(void) +{ + parse_generic(REGGROUP, "REGGROUP", ®tmod_byp); +} + +static void +parse_segreg(void) +{ + parse_generic(SEGREG, "SEGREG", ®tmod_byp); +} + +/* make the c output for the perfect hash tab array */ +static void +make_c_tab( + FILE *f, + const char *which, + const char *parser, + bstuff *tab, /* table indexed by b */ + ub4 smax, /* range of scramble[] */ + ub4 blen, /* b in 0..blen-1, power of 2 */ + ub4 *scramble) /* used in final hash */ +{ + ub4 i; + /* table for the mapping for the perfect hash */ + if (blen >= USE_SCRAMBLE) { + /* A way to make the 1-byte values in tab bigger */ + if (smax > UB2MAXVAL+1) { + fprintf(f, "static const unsigned long %s_", which); + if (parser) + fprintf(f, "%s_", parser); + fprintf(f, "scramble[] = {\n"); + for (i=0; i<=UB1MAXVAL; i+=4) + fprintf(f, "0x%.8lx, 0x%.8lx, 0x%.8lx, 0x%.8lx,\n", + scramble[i+0], scramble[i+1], scramble[i+2], scramble[i+3]); + } else { + fprintf(f, "static const unsigned short %s_", which); + if (parser) + fprintf(f, "%s_", parser); + fprintf(f, "scramble[] = {\n"); + for (i=0; i<=UB1MAXVAL; i+=8) + fprintf(f, +"0x%.4lx, 0x%.4lx, 0x%.4lx, 0x%.4lx, 0x%.4lx, 0x%.4lx, 0x%.4lx, 0x%.4lx,\n", + scramble[i+0], scramble[i+1], scramble[i+2], scramble[i+3], + scramble[i+4], scramble[i+5], scramble[i+6], scramble[i+7]); + } + fprintf(f, "};\n"); + fprintf(f, "\n"); + } + + if (blen > 0) { + /* small adjustments to _a_ to make values distinct */ + if (smax <= UB1MAXVAL+1 || blen >= USE_SCRAMBLE) + fprintf(f, "static const unsigned char %s_", which); + else + fprintf(f, "static const unsigned short %s_", which); + if (parser) + fprintf(f, "%s_", parser); + fprintf(f, "tab[] = {\n"); + + if (blen < 16) { + for (i=0; iname_k = yasm__xstrdup(d->name); + k->len_k = (ub4)strlen(d->name); + k->next_k = keys; + keys = k; + nkeys++; + } + + /* find the hash */ + findhash(&tab, &tabh, &alen, &blen, &salt, &final, + scramble, &smax, keys, nkeys, &form); + + /* output the dir table: this should loop up to smax for NORMAL_HP, + * or up to pakd.nkeys for MINIMAL_HP. + */ + fprintf(out, "static const %s_parse_data %s_", which, which); + if (parser) + fprintf(out, "%s_", parser); + fprintf(out, "pd[%lu] = {\n", nkeys); + for (i=0; iname, tabh[i].key_h->name_k) == 0) + break; + } + if (!d) { + report_error("internal error: could not find `%s'", + tabh[i].key_h->name_k); + break; + } + if (cpumode) + fprintf(out, "{\"%s\",", d->name); + else + fprintf(out, "%s(\"%s\",", d->func, d->name); + STAILQ_FOREACH(sv, &d->args, link) { + fprintf(out, " %s", sv->str); + if (STAILQ_NEXT(sv, link)) + fprintf(out, ","); + } + fprintf(out, cpumode ? "}" : ")"); + } else + fprintf(out, " { NULL }"); + + if (i < nkeys-1) + fprintf(out, ","); + fprintf(out, "\n"); + } + fprintf(out, "};\n"); + + /* output the hash tab[] array */ + make_c_tab(out, which, parser, tab, smax, blen, scramble); + + /* The hash function */ + fprintf(out, "#define tab %s_", which); + if (parser) + fprintf(out, "%s_", parser); + fprintf(out, "tab\n"); + fprintf(out, "static const %s_parse_data *\n%s_", which, which); + if (parser) + fprintf(out, "%s_", parser); + fprintf(out, "find(const char *key, size_t len)\n"); + fprintf(out, "{\n"); + fprintf(out, " const %s_parse_data *ret;\n", which); + for (i=0; i= %lu) return NULL;\n", nkeys); + fprintf(out, " ret = &%s_", which); + if (parser) + fprintf(out, "%s_", parser); + fprintf(out, "pd[rsl];\n"); + fprintf(out, " if (strcmp(key, ret->name) != 0) return NULL;\n"); + fprintf(out, " return ret;\n"); + fprintf(out, "}\n"); + fprintf(out, "#undef tab\n\n"); + + free(tab); + free(tabh); +} + +/* Get an entire "real" line from the input file by combining any + * \\\n continuations. + */ +static int get_line(FILE *in) +{ + char *p = line; + cur_line = next_line; + + if (feof(in)) + return 0; + + while (p < &line[1023-128]) { + if (!fgets(p, 128, in)) + return 1; + next_line++; + /* if continuation, strip out leading whitespace */ + if (p > line) { + char *p2 = p; + while (isspace(*p2)) p2++; + if (p2 > p) + memmove(p, p2, strlen(p2)+1); + } + while (*p) p++; + if (p[-2] != '\\' || p[-1] != '\n') { + if (p[-1] == '\n') + p[-1] = '\0'; + return 1; + } + p -= 2; + } + return 0; +} + +static struct { + const char *name; + int indx; + void (*handler) (void); +} directives[] = { + {"ARCH", ARCH, parse_arch}, + {"PARSERS", PARSERS, parse_parsers}, + {"INSN", INSN, parse_insn}, + {"CPU", CPU, parse_cpu}, + {"CPU_ALIAS", CPU_ALIAS, parse_cpu_alias}, + {"CPU_FEATURE", CPU_FEATURE, parse_cpu_feature}, + {"TARGETMOD", TARGETMOD, parse_targetmod}, + {"PREFIX", PREFIX, parse_prefix}, + {"REG", REG, parse_reg}, + {"REGGROUP", REGGROUP, parse_reggroup}, + {"SEGREG", SEGREG, parse_segreg}, +}; + +int +main(int argc, char *argv[]) +{ + FILE *in, *out; + size_t i; + char *tok; + int count[NUM_DIRS]; + dir_byp *db; + + for (i=0; i \n"); + return EXIT_FAILURE; + } + + in = fopen(argv[1], "rt"); + if (!in) { + fprintf(stderr, "Could not open `%s' for reading\n", argv[1]); + return EXIT_FAILURE; + } + + STAILQ_INIT(&insnprefix_byp); + STAILQ_INIT(&cpu_byp); + STAILQ_INIT(®tmod_byp); + + /* Parse input file */ + while (get_line(in)) { + int found; + /*printf("%s\n", line);*/ + tok = strtok(line, " \t\n"); + if (!tok) + continue; + + /* Comments start with # as the first thing on a line */ + if (tok[0] == '#') + continue; + + /* Look for directive */ + found = 0; + for (i=0; i 0) + return EXIT_FAILURE; + + out = fopen(argv[2], "wt"); + if (!out) { + fprintf(stderr, "Could not open `%s' for writing\n", argv[2]); + return EXIT_FAILURE; + } + + /* Get perfect hashes for the three lists of directives */ + STAILQ_FOREACH(db, &insnprefix_byp, link) + perfect_dir(out, "insnprefix", db->parser, &db->dirs); + STAILQ_FOREACH(db, &cpu_byp, link) + perfect_dir(out, "cpu", db->parser, &db->dirs); + STAILQ_FOREACH(db, ®tmod_byp, link) + perfect_dir(out, "regtmod", db->parser, &db->dirs); + + if (errors > 0) + return EXIT_FAILURE; + + return EXIT_SUCCESS; +} + diff --git a/tools/genperf/perfect.c b/tools/gap/perfect.c similarity index 83% rename from tools/genperf/perfect.c rename to tools/gap/perfect.c index 318cb5e6..c56304f6 100644 --- a/tools/genperf/perfect.c +++ b/tools/gap/perfect.c @@ -1,4 +1,6 @@ -/* Modified for use with yasm by Peter Johnson. */ +/* Modified for use with yasm by Peter Johnson. + * $Id$ + */ /* ------------------------------------------------------------------------------ perfect.c: code to generate code for a hash for perfect hashing. @@ -48,10 +50,10 @@ determined a perfect hash for the whole set of keys. */ #include -#include "tools/genperf/standard.h" +#include "tools/gap/standard.h" #include "libyasm/coretype.h" #include "libyasm/phash.h" -#include "tools/genperf/perfect.h" +#include "tools/gap/perfect.h" #define CHECKSTATE 8 @@ -62,7 +64,8 @@ Find the mapping that will produce a perfect hash */ /* return the ceiling of the log (base 2) of val */ -ub4 phash_log2(ub4 val) +ub4 phash_log2(val) +ub4 val; { ub4 i; for (i=0; ((ub4)1<len_k == key2->len_k) && - !memcmp(key1->name_k, key2->name_k, (size_t)key1->len_k)) + !memcmp(key1->name_k, key2->name_k, (size_t)key1->len_k)) { fprintf(stderr, "perfect.c: Duplicates keys! %.*s\n", - (int)key1->len_k, key1->name_k); + (int)key1->len_k, key1->name_k); exit(EXIT_FAILURE); } break; @@ -135,7 +138,7 @@ static void checkdup( break; case AB_HT: fprintf(stderr, "perfect.c: Duplicate keys! %.8lx %.8lx\n", - key1->a_k, key1->b_k); + key1->a_k, key1->b_k); exit(EXIT_FAILURE); break; default: @@ -168,15 +171,15 @@ static int inittab( key *otherkey; for (otherkey=tabb[mykey->b_k].list_b; - otherkey; - otherkey=otherkey->nextb_k) + otherkey; + otherkey=otherkey->nextb_k) { if (mykey->a_k == otherkey->a_k) { nocollision = FALSE; - checkdup(mykey, otherkey, form); - if (!complete) - return FALSE; + checkdup(mykey, otherkey, form); + if (!complete) + return FALSE; } } ++tabb[mykey->b_k].listlen_b; @@ -213,14 +216,14 @@ static void initnorm( } final->used = 4; sprintf(final->line[0], - " unsigned long i,state[CHECKSTATE],rsl;\n"); + " unsigned long i,state[CHECKSTATE],rsl;\n"); sprintf(final->line[1], - " for (i=0; iline[2], - " phash_checksum(key, len, state);\n"); + " phash_checksum(key, len, state);\n"); sprintf(final->line[3], - " rsl = ((state[0]&0x%lx)^scramble[tab[state[1]&0x%lx]]);\n", - alen-1, blen-1); + " rsl = ((state[0]&0x%lx)^scramble[tab[state[1]&0x%lx]]);\n", + alen-1, blen-1); } else { @@ -235,7 +238,7 @@ static void initnorm( } final->used = 2; sprintf(final->line[0], - " unsigned long rsl, val = phash_lookup(key, len, 0x%lxUL);\n", initlev); + " unsigned long rsl, val = phash_lookup(key, len, 0x%lxUL);\n", initlev); if (smax <= 1) { sprintf(final->line[1], " rsl = 0;\n"); @@ -243,12 +246,12 @@ static void initnorm( else if (blen < USE_SCRAMBLE) { sprintf(final->line[1], " rsl = ((val>>%ld)^tab[val&0x%lx]);\n", - UB4BITS-phash_log2(alen), blen-1); + UB4BITS-phash_log2(alen), blen-1); } else { sprintf(final->line[1], " rsl = ((val>>%ld)^scramble[tab[val&0x%lx]]);\n", - UB4BITS-phash_log2(alen), blen-1); + UB4BITS-phash_log2(alen), blen-1); } } } @@ -290,12 +293,12 @@ static void initinl( else if (blen < USE_SCRAMBLE) { sprintf(final->line[0], " unsigned long rsl = ((val & 0x%lx) ^ tab[val >> %ld]);\n", - amask, UB4BITS-blog); + amask, UB4BITS-blog); } else { sprintf(final->line[0], " unsigned long rsl = ((val & 0x%lx) ^ scramble[tab[val >> %ld]]);\n", - amask, UB4BITS-blog); + amask, UB4BITS-blog); } } @@ -366,7 +369,7 @@ static void duplicates( for (i=0; inextb_k) for (key2=key1->nextb_k; key2; key2=key2->nextb_k) - checkdup(key1, key2, form); + checkdup(key1, key2, form); } @@ -400,7 +403,7 @@ static int apply( hash = mykey->a_k^stabb; if (mykey == tabh[hash].key_h) { /* erase hash for all of child's siblings */ - tabh[hash].key_h = (key *)0; + tabh[hash].key_h = (key *)0; } } @@ -414,13 +417,13 @@ static int apply( hash = mykey->a_k^stabb; if (rollback) { - if (parent == 0) continue; /* root never had a hash */ + if (parent == 0) continue; /* root never had a hash */ } else if (tabh[hash].key_h) { - /* very rare: roll back any changes */ - apply(tabb, tabh, tabq, blen, scramble, tail, TRUE); - return FALSE; /* failure, collision */ + /* very rare: roll back any changes */ + apply(tabb, tabh, tabq, blen, scramble, tail, TRUE); + return FALSE; /* failure, collision */ } tabh[hash].key_h = mykey; } @@ -486,26 +489,26 @@ static int augment( for (mykey = myb->list_b; mykey; mykey=mykey->nextb_k) { - key *childkey; - ub4 hash = mykey->a_k^scramble[i]; + key *childkey; + ub4 hash = mykey->a_k^scramble[i]; - if (hash >= highhash) break; /* out of bounds */ - childkey = tabh[hash].key_h; + if (hash >= highhash) break; /* out of bounds */ + childkey = tabh[hash].key_h; - if (childkey) - { - bstuff *hitb = &tabb[childkey->b_k]; + if (childkey) + { + bstuff *hitb = &tabb[childkey->b_k]; - if (childb) - { - if (childb != hitb) break; /* hit at most one child b */ - } - else - { - childb = hitb; /* remember this as childb */ - if (childb->water_b == highwater) break; /* already explored */ - } - } + if (childb) + { + if (childb != hitb) break; /* hit at most one child b */ + } + else + { + childb = hitb; /* remember this as childb */ + if (childb->water_b == highwater) break; /* already explored */ + } + } } if (mykey) continue; /* myb with i has multiple collisions */ @@ -519,11 +522,11 @@ static int augment( if (!childb) { /* found an *i* with no collisions? */ - /* try to apply the augmenting path */ - if (apply(tabb, tabh, tabq, blen, scramble, tail, FALSE)) - return TRUE; /* success, item was added to the perfect hash */ + /* try to apply the augmenting path */ + if (apply(tabb, tabh, tabq, blen, scramble, tail, FALSE)) + return TRUE; /* success, item was added to the perfect hash */ - --tail; /* don't know how to handle such a child! */ + --tail; /* don't know how to handle such a child! */ } } } @@ -547,8 +550,8 @@ static int perfect( /* clear any state from previous attempts */ memset((void *)tabh, 0, - (size_t)(sizeof(hstuff)* - ((form->perfect == MINIMAL_HP) ? nkeys : smax))); + (size_t)(sizeof(hstuff)* + ((form->perfect == MINIMAL_HP) ? nkeys : smax))); memset((void *)tabq, 0, (size_t)(sizeof(qstuff)*(blen+1))); for (maxkeys=0,i=0; i0; --j) for (i=0; iperfect == MINIMAL_HP ? - nkeys : *smax)); + nkeys : *smax)); /* check that (a,b) are distinct and put them in tabb indexed by b */ (void)inittab(*tabb, *blen, keys, form, FALSE); @@ -628,21 +631,21 @@ static void hash_ab( { if (form->perfect == MINIMAL_HP) { - fprintf(stderr, "fatal error: Cannot find perfect hash for user (A,B) pairs\n"); + printf("fatal error: Cannot find perfect hash for user (A,B) pairs\n"); exit(EXIT_FAILURE); } else { /* try with 2*smax */ - yasm_xfree((void *)tabh); + free((void *)tabh); *smax = *smax * 2; scrambleinit(scramble, *smax); tabh = (hstuff *)yasm_xmalloc(sizeof(hstuff)*(form->perfect == MINIMAL_HP ? - nkeys : *smax)); + nkeys : *smax)); if (!perfect(*tabb, tabh, tabq, *blen, *smax, scramble, nkeys, form)) { - fprintf(stderr, "fatal error: Cannot find perfect hash for user (A,B) pairs\n"); - exit(EXIT_FAILURE); + printf("fatal error: Cannot find perfect hash for user (A,B) pairs\n"); + exit(EXIT_FAILURE); } } } @@ -670,8 +673,10 @@ static void hash_ab( sprintf(final->line[0], " unsigned long rsl = (a ^ scramble[tab[b]]);\n"); } - yasm_xfree((void *)tabq); - yasm_xfree((void *)tabh); + printf("success, found a perfect hash\n"); + + free((void *)tabq); + free((void *)tabh); } @@ -731,10 +736,10 @@ static void initalen( *blen = *smax; /* go for function speed not space */ else if (*smax/4 <= (1<<14)) *blen = ((nkeys <= *smax*0.56) ? *smax/32 : - (nkeys <= *smax*0.74) ? *smax/16 : *smax/8); + (nkeys <= *smax*0.74) ? *smax/16 : *smax/8); else *blen = ((nkeys <= *smax*0.6) ? *smax/16 : - (nkeys <= *smax*0.8) ? *smax/8 : *smax/4); + (nkeys <= *smax*0.8) ? *smax/8 : *smax/4); if ((form->speed == FAST_HS) && (*blen < *smax/8)) *blen = *smax/8; @@ -749,7 +754,6 @@ static void initalen( case 0: *alen = 1; *blen = 1; - break; case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8: *alen = (form->perfect == NORMAL_HP) ? *smax : *smax/2; *blen = *smax/2; @@ -765,31 +769,31 @@ static void initalen( case 17: if (form->speed == FAST_HS) { - *alen = *smax/2; - *blen = *smax/4; + *alen = *smax/2; + *blen = *smax/4; } else if (*smax/4 < USE_SCRAMBLE) { - *alen = ((nkeys <= *smax*0.52) ? *smax/8 : *smax/4); - *blen = ((nkeys <= *smax*0.52) ? *smax/8 : *smax/4); + *alen = ((nkeys <= *smax*0.52) ? *smax/8 : *smax/4); + *blen = ((nkeys <= *smax*0.52) ? *smax/8 : *smax/4); } else { - *alen = ((nkeys <= *smax*(5.0/8.0)) ? *smax/8 : - (nkeys <= *smax*(3.0/4.0)) ? *smax/4 : *smax/2); - *blen = *smax/4; /* always give the small size a shot */ + *alen = ((nkeys <= *smax*(5.0/8.0)) ? *smax/8 : + (nkeys <= *smax*(3.0/4.0)) ? *smax/4 : *smax/2); + *blen = *smax/4; /* always give the small size a shot */ } break; case 18: if (form->speed == FAST_HS) { - *alen = *smax/2; - *blen = *smax/2; + *alen = *smax/2; + *blen = *smax/2; } else { - *alen = *smax/8; /* never require the multiword hash */ - *blen = (nkeys <= *smax*(5.0/8.0)) ? *smax/4 : *smax/2; + *alen = *smax/8; /* never require the multiword hash */ + *blen = (nkeys <= *smax*(5.0/8.0)) ? *smax/4 : *smax/2; } break; case 19: @@ -812,7 +816,7 @@ static void initalen( */ void findhash( bstuff **tabb, /* output, tab[] of the perfect hash, length *blen */ - hstuff **tabh, /* output, table of keys indexed by hash value */ + hstuff **tabh, /* output, table of keys indexed by hash value */ ub4 *alen, /* output, 0..alen-1 is range for a of (a,b) */ ub4 *blen, /* output, 0..blen-1 is range for b of (a,b) */ ub4 *salt, /* output, initializes initial hash */ @@ -833,7 +837,7 @@ void findhash( if (form->hashtype == AB_HT) { hash_ab(tabb, alen, blen, salt, final, - scramble, smax, keys, nkeys, form); + scramble, smax, keys, nkeys, form); return; } @@ -849,7 +853,7 @@ void findhash( *tabb = (bstuff *)yasm_xmalloc((size_t)(sizeof(bstuff)*(*blen))); tabq = (qstuff *)yasm_xmalloc(sizeof(qstuff)*(*blen+1)); *tabh = (hstuff *)yasm_xmalloc(sizeof(hstuff)*(form->perfect == MINIMAL_HP ? - nkeys : *smax)); + nkeys : *smax)); /* Actually find the perfect hash */ *salt = 0; @@ -861,7 +865,7 @@ void findhash( /* Try to find distinct (A,B) for all keys */ rslinit = initkey(keys, nkeys, *tabb, *alen, *blen, *smax, trysalt, - form, final); + form, final); if (rslinit == 2) { /* initkey actually found a perfect hash, not just distinct (a,b) */ @@ -874,52 +878,54 @@ void findhash( /* didn't find distinct (a,b) */ if (++bad_initkey >= RETRY_INITKEY) { - /* Try to put more bits in (A,B) to make distinct (A,B) more likely */ - if (*alen < maxalen) - { - *alen *= 2; - } - else if (*blen < *smax) - { - *blen *= 2; - yasm_xfree(tabq); - yasm_xfree(*tabb); - *tabb = (bstuff *)yasm_xmalloc((size_t)(sizeof(bstuff)*(*blen))); - tabq = (qstuff *)yasm_xmalloc((size_t)(sizeof(qstuff)*(*blen+1))); - } - else - { - duplicates(*tabb, *blen, keys, form); /* check for duplicates */ - fprintf(stderr, "fatal error: Cannot perfect hash: cannot find distinct (A,B)\n"); - exit(EXIT_FAILURE); - } - bad_initkey = 0; - bad_perfect = 0; + /* Try to put more bits in (A,B) to make distinct (A,B) more likely */ + if (*alen < maxalen) + { + *alen *= 2; + } + else if (*blen < *smax) + { + *blen *= 2; + free(tabq); + free(*tabb); + *tabb = (bstuff *)yasm_xmalloc((size_t)(sizeof(bstuff)*(*blen))); + tabq = (qstuff *)yasm_xmalloc((size_t)(sizeof(qstuff)*(*blen+1))); + } + else + { + duplicates(*tabb, *blen, keys, form); /* check for duplicates */ + printf("fatal error: Cannot perfect hash: cannot find distinct (A,B)\n"); + exit(EXIT_FAILURE); + } + bad_initkey = 0; + bad_perfect = 0; } continue; /* two keys have same (a,b) pair */ } + printf("found distinct (A,B) on attempt %ld\n", trysalt); + /* Given distinct (A,B) for all keys, build a perfect hash */ if (!perfect(*tabb, *tabh, tabq, *blen, *smax, scramble, nkeys, form)) { if ((form->hashtype != INT_HT && ++bad_perfect >= RETRY_PERFECT) || - (form->hashtype == INT_HT && ++bad_perfect >= RETRY_HEX)) + (form->hashtype == INT_HT && ++bad_perfect >= RETRY_HEX)) { - if (*blen < *smax) - { - *blen *= 2; - yasm_xfree(*tabb); - yasm_xfree(tabq); - *tabb = (bstuff *)yasm_xmalloc((size_t)(sizeof(bstuff)*(*blen))); - tabq = (qstuff *)yasm_xmalloc((size_t)(sizeof(qstuff)*(*blen+1))); - --trysalt; /* we know this salt got distinct (A,B) */ - } - else - { - fprintf(stderr, "fatal error: Cannot perfect hash: cannot build tab[]\n"); - exit(EXIT_FAILURE); - } - bad_perfect = 0; + if (*blen < *smax) + { + *blen *= 2; + free(*tabb); + free(tabq); + *tabb = (bstuff *)yasm_xmalloc((size_t)(sizeof(bstuff)*(*blen))); + tabq = (qstuff *)yasm_xmalloc((size_t)(sizeof(qstuff)*(*blen+1))); + --trysalt; /* we know this salt got distinct (A,B) */ + } + else + { + printf("fatal error: Cannot perfect hash: cannot build tab[]\n"); + exit(EXIT_FAILURE); + } + bad_perfect = 0; } continue; } @@ -928,8 +934,10 @@ void findhash( break; } + printf("built perfect hash table of size %ld\n", *blen); + /* free working memory */ - yasm_xfree((void *)tabq); + free((void *)tabq); } #if 0 @@ -1037,37 +1045,37 @@ hashform *form; /* user directives */ else if (blen <= 1024) { for (i=0; i>fout, "%02x " % byte - count += 1 - print "Processed %d instructions" % count - - -if __name__ == "__main__": - import sys - if len(sys.argv) != 3: - print >>sys.stderr, "Usage: gencheck.py " - sys.exit(2) - gen_expected(open(sys.argv[2], "w"), open(sys.argv[1], "r")) diff --git a/tools/genmacro/CMakeLists.txt b/tools/genmacro/CMakeLists.txt deleted file mode 100644 index 9e8933b0..00000000 --- a/tools/genmacro/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -add_executable(genmacro - genmacro.c - ) - -if(CMAKE_CROSSCOMPILING) - find_program(GENMACRO_BIN NAMES genmacro REQUIRED) - add_executable(yasm::genmacro IMPORTED GLOBAL) - set_property(TARGET yasm::genmacro PROPERTY IMPORTED_LOCATION "${GENMACRO_BIN}") -else() - add_executable(yasm::genmacro ALIAS genmacro) -endif() diff --git a/tools/genmacro/Makefile.inc b/tools/genmacro/Makefile.inc deleted file mode 100644 index 722f95da..00000000 --- a/tools/genmacro/Makefile.inc +++ /dev/null @@ -1,14 +0,0 @@ -# These utility programs have to be built for BUILD host in cross-build. -# This makes things rather non-standard automake - -noinst_PROGRAMS += genmacro - -genmacro_SOURCES = -EXTRA_DIST += tools/genmacro/genmacro.c -genmacro_LDADD = genmacro.$(OBJEXT) -genmacro_LINK = $(CCLD_FOR_BUILD) -o $@ - -genmacro.$(OBJEXT): tools/genmacro/genmacro.c - $(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(DEFAULT_INCLUDES) $(INCLUDES) \ - -c -o $@ `test -f tools/genmacro/genmacro.c || echo '$(srcdir)/'`tools/genmacro/genmacro.c - diff --git a/tools/genmacro/genmacro.c b/tools/genmacro/genmacro.c deleted file mode 100644 index 73901bfc..00000000 --- a/tools/genmacro/genmacro.c +++ /dev/null @@ -1,130 +0,0 @@ -/* - * - * C version of NASM's macros.pl - * - * Copyright (C) 2004-2008 Peter Johnson - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND OTHER CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR OTHER CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -#include -#include -#include - -#define MAXLINE 1024 - -int -main(int argc, char *argv[]) -{ - FILE *in, *out; - int i; - char *str; - char *strp; - char *charp; - int fline; - size_t len; - - if (argc < 4) { - fprintf(stderr, "Usage: %s [ ...]\n", argv[0]); - return EXIT_FAILURE; - } - - out = fopen(argv[1], "wt"); - - if (!out) { - fprintf(stderr, "Could not open `%s'.\n", argv[1]); - return EXIT_FAILURE; - } - - str = malloc(MAXLINE); - - fprintf(out, "/* This file auto-generated from standard.mac by genmacro.c" - " - don't edit it */\n\n#include \n\n" - "static const char *%s[] = {\n", argv[2]); - - for (i=3; i 0 && (strp[len-1] == ' ' || strp[len-1] == '\t' || - strp[len-1] == '\r' || strp[len-1] == '\n')) { - strp[len-1] = '\0'; - len--; - } - - /* skip blank lines */ - if (len == 0) - continue; - - /* output as string to output file */ - fprintf(out, " \""); - while (*strp != '\0') { - if (*strp == '\\' || *strp == '"') - fputc('\\', out); - fputc(*strp, out); - strp++; - } - fprintf(out, "\",\n"); - } - - fclose(in); - } - - fprintf(out, " NULL\n};\n"); - fclose(out); - - free(str); - - return EXIT_SUCCESS; -} diff --git a/tools/genperf/CMakeLists.txt b/tools/genperf/CMakeLists.txt deleted file mode 100644 index c9db7c11..00000000 --- a/tools/genperf/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -add_executable(genperf - genperf.c - perfect.c - ../../libyasm/phash.c - ../../libyasm/xmalloc.c - ../../libyasm/xstrdup.c - ) -set_target_properties(genperf PROPERTIES COMPILE_FLAGS -DYASM_LIB_DECL=) - -if(CMAKE_CROSSCOMPILING) - find_program(GENPERF_BIN NAMES genperf REQUIRED) - add_executable(yasm::genperf IMPORTED GLOBAL) - set_property(TARGET yasm::genperf PROPERTY IMPORTED_LOCATION "${GENPERF_BIN}") -else() - add_executable(yasm::genperf ALIAS genperf) -endif() diff --git a/tools/genperf/Makefile.inc b/tools/genperf/Makefile.inc deleted file mode 100644 index 135da6b9..00000000 --- a/tools/genperf/Makefile.inc +++ /dev/null @@ -1,42 +0,0 @@ -# These utility programs have to be built for BUILD host in cross-build. -# This makes things rather non-standard automake - -noinst_PROGRAMS += genperf - -# Suffix rule for genperf -SUFFIXES += .gperf -.gperf.c: genperf$(EXEEXT) - $(top_builddir)/genperf$(EXEEXT) $< $@ - -genperf_SOURCES = -EXTRA_DIST += tools/genperf/genperf.c -EXTRA_DIST += tools/genperf/perfect.c -EXTRA_DIST += tools/genperf/perfect.h -EXTRA_DIST += tools/genperf/standard.h -genperf_LDADD = genperf.$(OBJEXT) -genperf_LDADD += gp-perfect.$(OBJEXT) -genperf_LDADD += gp-phash.$(OBJEXT) -genperf_LDADD += gp-xmalloc.$(OBJEXT) -genperf_LDADD += gp-xstrdup.$(OBJEXT) -genperf_LINK = $(CCLD_FOR_BUILD) -o $@ - -genperf.$(OBJEXT): tools/genperf/genperf.c - $(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(DEFAULT_INCLUDES) $(INCLUDES) \ - -c -o $@ `test -f tools/genperf/genperf.c || echo '$(srcdir)/'`tools/genperf/genperf.c - -gp-perfect.$(OBJEXT): tools/genperf/perfect.c - $(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(DEFAULT_INCLUDES) $(INCLUDES) \ - -c -o $@ `test -f tools/genperf/perfect.c || echo '$(srcdir)/'`tools/genperf/perfect.c - -gp-phash.$(OBJEXT): libyasm/phash.c - $(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(DEFAULT_INCLUDES) $(INCLUDES) \ - -c -o $@ `test -f libyasm/phash.c || echo '$(srcdir)/'`libyasm/phash.c - -gp-xmalloc.$(OBJEXT): libyasm/xmalloc.c - $(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(DEFAULT_INCLUDES) $(INCLUDES) \ - -c -o $@ `test -f libyasm/xmalloc.c || echo '$(srcdir)/'`libyasm/xmalloc.c - -gp-xstrdup.$(OBJEXT): libyasm/xstrdup.c - $(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(DEFAULT_INCLUDES) $(INCLUDES) \ - -c -o $@ `test -f libyasm/xstrdup.c || echo '$(srcdir)/'`libyasm/xstrdup.c - diff --git a/tools/genperf/genperf.c b/tools/genperf/genperf.c deleted file mode 100644 index 073b7502..00000000 --- a/tools/genperf/genperf.c +++ /dev/null @@ -1,540 +0,0 @@ -/* - * - * Generate Minimal Perfect Hash (genperf) - * - * Copyright (C) 2006-2007 Peter Johnson - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND OTHER CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR OTHER CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -#include -#include -#include -#include -#include "tools/genperf/perfect.h" -#include "libyasm/compat-queue.h" -#include "libyasm/coretype.h" -#include "libyasm/errwarn.h" - -typedef STAILQ_HEAD(slist, sval) slist; -typedef struct sval { - STAILQ_ENTRY(sval) link; - char *str; -} sval; - -typedef STAILQ_HEAD(keyword_list, keyword) keyword_list; -typedef struct keyword { - STAILQ_ENTRY(keyword) link; - char *name; - char *args; - unsigned int line; -} keyword; - -static unsigned int cur_line = 1; -static int errors = 0; - -static void -report_error(const char *fmt, ...) -{ - va_list ap; - - fprintf(stderr, "%u: ", cur_line); - va_start(ap, fmt); - vfprintf(stderr, fmt, ap); - va_end(ap); - fputc('\n', stderr); - errors++; -} - -void -yasm__fatal(const char *message, ...) -{ - abort(); -} - -/* make the c output for the perfect hash tab array */ -static void -make_c_tab( - FILE *f, - bstuff *tab, /* table indexed by b */ - ub4 smax, /* range of scramble[] */ - ub4 blen, /* b in 0..blen-1, power of 2 */ - ub4 *scramble) /* used in final hash */ -{ - ub4 i; - /* table for the mapping for the perfect hash */ - if (blen >= USE_SCRAMBLE) { - /* A way to make the 1-byte values in tab bigger */ - if (smax > UB2MAXVAL+1) { - fprintf(f, " static const unsigned long scramble[] = {\n"); - for (i=0; i<=UB1MAXVAL; i+=4) - fprintf(f, " 0x%.8lx, 0x%.8lx, 0x%.8lx, 0x%.8lx,\n", - scramble[i+0], scramble[i+1], scramble[i+2], scramble[i+3]); - } else { - fprintf(f, " static const unsigned short scramble[] = {\n"); - for (i=0; i<=UB1MAXVAL; i+=8) - fprintf(f, -" 0x%.4lx, 0x%.4lx, 0x%.4lx, 0x%.4lx, 0x%.4lx, 0x%.4lx, 0x%.4lx, 0x%.4lx,\n", - scramble[i+0], scramble[i+1], scramble[i+2], scramble[i+3], - scramble[i+4], scramble[i+5], scramble[i+6], scramble[i+7]); - } - fprintf(f, " };\n"); - fprintf(f, "\n"); - } - - if (blen > 0) { - /* small adjustments to _a_ to make values distinct */ - if (smax <= UB1MAXVAL+1 || blen >= USE_SCRAMBLE) - fprintf(f, " static const unsigned char "); - else - fprintf(f, " static const unsigned short "); - fprintf(f, "tab[] = {\n"); - - if (blen < 16) { - for (i=0; iname_k = yasm__xstrdup(kw->name); - k->len_k = (ub4)strlen(kw->name); - k->next_k = keys; - keys = k; - nkeys++; - } - - /* find the hash */ - findhash(&tab, &tabh, &alen, &blen, &salt, &final, - scramble, &smax, keys, nkeys, &form); - - /* The hash function beginning */ - fprintf(out, "static const struct %s *\n", struct_name); - fprintf(out, "%s(const char *key, size_t len)\n", lookup_function_name); - fprintf(out, "{\n"); - - /* output the dir table: this should loop up to smax for NORMAL_HP, - * or up to pakd.nkeys for MINIMAL_HP. - */ - fprintf(out, " static const struct %s pd[%lu] = {\n", struct_name, nkeys); - for (i=0; iname, tabh[i].key_h->name_k) == 0) - break; - } - if (!kw) { - report_error("internal error: could not find `%s'", - tabh[i].key_h->name_k); - break; - } - fprintf(out, "#line %u \"%s\"\n", kw->line, filename); - fprintf(out, " {\"%s\"%s}", kw->name, kw->args); - } else - fprintf(out, " { NULL }"); - - if (i < nkeys-1) - fprintf(out, ","); - fprintf(out, "\n"); - } - fprintf(out, " };\n"); - - /* output the hash tab[] array */ - make_c_tab(out, tab, smax, blen, scramble); - - /* The hash function body */ - fprintf(out, " const struct %s *ret;\n", struct_name); - for (i=0; i= %lu) return NULL;\n", nkeys); - fprintf(out, " ret = &pd[rsl];\n"); - fprintf(out, " if (strcmp(key, ret->name) != 0) return NULL;\n"); - fprintf(out, " return ret;\n"); - fprintf(out, "}\n"); - fprintf(out, "\n"); - - yasm_xfree(tab); - yasm_xfree(tabh); -} - -int -main(int argc, char *argv[]) -{ - FILE *in, *out; - size_t i; - char *ch; - static char line[1024], tmp[1024]; - static char struct_name[128] = ""; - static char lookup_function_name[128] = "in_word_set"; - static char language[16] = ""; - static char delimiters[16] = ",\r\n"; - static char name[128]; - static char filename[768]; - int need_struct = 0; - int have_struct = 0; - int go_keywords = 0; - int ignore_case = 0; - int compare_strncmp = 0; - int readonly_tables = 0; - slist usercode, usercode2; - keyword_list keywords; - sval *sv; - keyword *kw; - - if (argc != 3) { - fprintf(stderr, "Usage: genperf \n"); - return EXIT_FAILURE; - } - - in = fopen(argv[1], "rt"); - if (!in) { - fprintf(stderr, "Could not open `%s' for reading\n", argv[1]); - return EXIT_FAILURE; - } - - ch = argv[1]; - i = 0; - while (*ch && i < 767) { - if (*ch == '\\') { - filename[i++] = '/'; - ch++; - } else - filename[i++] = *ch++; - } - filename[i] = '\0'; - - STAILQ_INIT(&usercode); - STAILQ_INIT(&usercode2); - STAILQ_INIT(&keywords); - - /* Parse declarations section */ - while (fgets(line, 1024, in)) { - /* Comments start with # as the first thing on a line */ - if (line[0] == '#') { - cur_line++; - continue; - } - - /* Handle structure declaration */ - if (strncmp(line, "struct", 6) == 0) { - int braces; - - if (!need_struct) { - report_error("struct without %%struct-type declaration"); - return EXIT_FAILURE; - } - if (have_struct) { - report_error("more than one struct declaration"); - return EXIT_FAILURE; - } - have_struct = 1; - - /* copy struct name */ - ch = &line[6]; - while (isspace(*ch)) - ch++; - i = 0; - while ((isalnum(*ch) || *ch == '_') && i < 127) - struct_name[i++] = *ch++; - if (i == 127) { - report_error("struct name too long"); - return EXIT_FAILURE; - } - struct_name[i] = '\0'; - - sv = yasm_xmalloc(sizeof(sval)); - sprintf(tmp, "#line %u \"%s\"\n", cur_line, filename); - sv->str = yasm__xstrdup(tmp); - STAILQ_INSERT_TAIL(&usercode, sv, link); - - braces = 0; - do { - /* count braces to determine when we're done */ - ch = line; - while (*ch != '\0') { - if (*ch == '{') - braces++; - if (*ch == '}') - braces--; - ch++; - } - sv = yasm_xmalloc(sizeof(sval)); - sv->str = yasm__xstrdup(line); - STAILQ_INSERT_TAIL(&usercode, sv, link); - cur_line++; - if (braces <= 0) - break; - } while (fgets(line, 1024, in)); - cur_line++; - continue; - } - - /* Ignore non-declaration lines */ - if (line[0] != '%') { - cur_line++; - continue; - } - - /* %% terminates declarations section */ - if (line[1] == '%') { - if (need_struct && !have_struct) { - report_error("%%struct-type declaration, but no struct found"); - return EXIT_FAILURE; - } - go_keywords = 1; - break; /* move on to keywords section */ - } - - /* %{ begins a verbatim code section that ends with %} */ - if (line[1] == '{') { - sv = yasm_xmalloc(sizeof(sval)); - sprintf(tmp, "#line %u \"%s\"\n\n", cur_line, filename); - sv->str = yasm__xstrdup(tmp); - STAILQ_INSERT_TAIL(&usercode, sv, link); - - while (fgets(line, 1024, in)) { - cur_line++; - if (line[0] == '%' && line[1] == '}') - break; - sv = yasm_xmalloc(sizeof(sval)); - sv->str = yasm__xstrdup(line); - STAILQ_INSERT_TAIL(&usercode, sv, link); - } - cur_line++; - continue; - } - - if (strncmp(&line[1], "ignore-case", 11) == 0) { - ignore_case = 1; - } else if (strncmp(&line[1], "compare-strncmp", 15) == 0) { - compare_strncmp = 1; - } else if (strncmp(&line[1], "readonly-tables", 15) == 0) { - readonly_tables = 1; - } else if (strncmp(&line[1], "language=", 9) == 0) { - ch = &line[10]; - i = 0; - while (*ch != '\n' && i<15) - language[i++] = *ch++; - language[i] = '\0'; - } else if (strncmp(&line[1], "delimiters=", 11) == 0) { - ch = &line[12]; - i = 0; - while (i<15) - delimiters[i++] = *ch++; - delimiters[i] = '\0'; - } else if (strncmp(&line[1], "enum", 4) == 0) { - /* unused */ - } else if (strncmp(&line[1], "struct-type", 11) == 0) { - need_struct = 1; - } else if (strncmp(&line[1], "define", 6) == 0) { - /* Several different defines we need to handle */ - ch = &line[7]; - while (isspace(*ch)) - ch++; - - if (strncmp(ch, "hash-function-name", 18) == 0) { - /* unused */ - } else if (strncmp(ch, "lookup-function-name", 20) == 0) { - ch = &line[7+20+1]; - while (isspace(*ch)) - ch++; - i = 0; - while ((isalnum(*ch) || *ch == '_') && i < 127) - lookup_function_name[i++] = *ch++; - if (i == 127) { - report_error("struct name too long"); - return EXIT_FAILURE; - } - lookup_function_name[i] = '\0'; - } else { - fprintf(stderr, "%u: unrecognized define `%s'\n", cur_line, - line); - } - } else { - fprintf(stderr, "%u: unrecognized declaration `%s'\n", cur_line, - line); - } - - cur_line++; - } - - if (!go_keywords) { - report_error("no keywords section found"); - return EXIT_FAILURE; - } - - /* Parse keywords section */ - while (fgets(line, 1024, in)) { - char *d; - - /* Comments start with # as the first thing on a line */ - if (line[0] == '#') { - cur_line++; - continue; - } - - /* Keywords section terminated with %% */ - if (line[0] == '%' && line[1] == '%') - break; - - /* Look for name */ - ch = &line[0]; - i = 0; - while (strchr(delimiters, *ch) == NULL && i < 127) - name[i++] = *ch++; - if (i == 127) { - report_error("keyword name too long"); - return EXIT_FAILURE; - } - name[i] = '\0'; - - /* Strip EOL */ - d = strrchr(ch, '\n'); - if (d) - *d = '\0'; - d = strrchr(ch, '\r'); - if (d) - *d = '\0'; - kw = yasm_xmalloc(sizeof(keyword)); - kw->name = yasm__xstrdup(name); - kw->args = yasm__xstrdup(ch); - kw->line = cur_line; - STAILQ_INSERT_TAIL(&keywords, kw, link); - cur_line++; - } - - if (errors > 0) - return EXIT_FAILURE; - - /* Pull in any end code */ - if (!feof(in)) { - sv = yasm_xmalloc(sizeof(sval)); - sprintf(tmp, "#line %u \"%s\"\n\n", cur_line, filename); - sv->str = yasm__xstrdup(tmp); - STAILQ_INSERT_TAIL(&usercode2, sv, link); - - while (fgets(line, 1024, in)) { - sv = yasm_xmalloc(sizeof(sval)); - sv->str = yasm__xstrdup(line); - STAILQ_INSERT_TAIL(&usercode2, sv, link); - } - } - - /* output code */ - out = fopen(argv[2], "wt"); - if (!out) { - fprintf(stderr, "Could not open `%s' for writing\n", argv[2]); - return EXIT_FAILURE; - } - - fprintf(out, "/* %s code produced by genperf */\n", language); - fprintf(out, "/* Command-line: genperf %s %s */\n", argv[1], argv[2]); - - STAILQ_FOREACH(sv, &usercode, link) - fprintf(out, "%s", sv->str); - - /* Get perfect hash */ - perfect_gen(out, lookup_function_name, struct_name, &keywords, filename); - - STAILQ_FOREACH(sv, &usercode2, link) - fprintf(out, "%s", sv->str); - - fclose(out); - - if (errors > 0) { - remove(argv[2]); - return EXIT_FAILURE; - } - - return EXIT_SUCCESS; -} - diff --git a/tools/python-yasm/Makefile.inc b/tools/python-yasm/Makefile.inc deleted file mode 100644 index fce135b4..00000000 --- a/tools/python-yasm/Makefile.inc +++ /dev/null @@ -1,79 +0,0 @@ -PYBINDING_DEPS = tools/python-yasm/bytecode.pxi -PYBINDING_DEPS += tools/python-yasm/errwarn.pxi -PYBINDING_DEPS += tools/python-yasm/expr.pxi -PYBINDING_DEPS += tools/python-yasm/floatnum.pxi -PYBINDING_DEPS += tools/python-yasm/intnum.pxi -PYBINDING_DEPS += tools/python-yasm/symrec.pxi -PYBINDING_DEPS += tools/python-yasm/value.pxi - -EXTRA_DIST += tools/python-yasm/pyxelator/cparse.py -EXTRA_DIST += tools/python-yasm/pyxelator/genpyx.py -EXTRA_DIST += tools/python-yasm/pyxelator/ir.py -EXTRA_DIST += tools/python-yasm/pyxelator/lexer.py -EXTRA_DIST += tools/python-yasm/pyxelator/node.py -EXTRA_DIST += tools/python-yasm/pyxelator/parse_core.py -EXTRA_DIST += tools/python-yasm/pyxelator/work_unit.py -EXTRA_DIST += tools/python-yasm/pyxelator/wrap_yasm.py -EXTRA_DIST += tools/python-yasm/setup.py -EXTRA_DIST += tools/python-yasm/yasm.pyx -EXTRA_DIST += $(PYBINDING_DEPS) - -if HAVE_PYTHON_BINDINGS - -# Use Pyxelator to generate Pyrex function headers. -_yasm.pxi: ${HEADERS} - @rm -rf .tmp - @mkdir .tmp - $(PYTHON) $(srcdir)/tools/python-yasm/pyxelator/wrap_yasm.py \ - "YASM_DIR=${srcdir}" "CPP=${CPP}" "CPPFLAGS=${CPPFLAGS}" - @rm -rf .tmp - -CLEANFILES += _yasm.pxi - -# Need to build a local copy of the main Pyrex input file to include _yasm.pxi -# from the build directory. Also need to fixup the other .pxi include paths. -yasm.pyx: $(srcdir)/tools/python-yasm/yasm.pyx - sed -e 's,^include "\([^_]\),include "${srcdir}/tools/python-yasm/\1,' \ - $(srcdir)/tools/python-yasm/yasm.pyx > $@ - -CLEANFILES += yasm.pyx - -# Actually run Cython -yasm_python.c: yasm.pyx _yasm.pxi $(PYBINDING_DEPS) - $(PYTHON) -c "from Cython.Compiler.Main import main; main(command_line=1)" \ - -o $@ yasm.pyx - -CLEANFILES += yasm_python.c - -# Now the Python build magic... -python-setup.txt: Makefile - echo "includes=${DEFS} ${DEFAULT_INCLUDES} ${INCLUDES} ${AM_CPPFLAGS} ${CPPFLAGS}" > python-setup.txt - echo "sources=${libyasm_a_SOURCES} ${nodist_libyasm_a_SOURCES}" >> python-setup.txt - echo "srcdir=${srcdir}" >> python-setup.txt - echo "gcc=${GCC}" >> python-setup.txt - -CLEANFILES += python-setup.txt - -.python-build: python-setup.txt yasm_python.c ${libyasm_a_SOURCES} ${nodist_libyasm_a_SOURCES} - $(PYTHON) `test -f tools/python-yasm/setup.py || echo '$(srcdir)/'`tools/python-yasm/setup.py build - touch .python-build -python-build: .python-build - -CLEANFILES += .python-build - -python-install: .python-build - $(PYTHON) `test -f tools/python-yasm/setup.py || echo '$(srcdir)/'`tools/python-yasm/setup.py install "--install-lib=$(DESTDIR)$(pythondir)" - -python-uninstall: - rm -f `$(PYTHON) -c "import sys;sys.path.insert(0, '${DESTDIR}${pythondir}'); import yasm; print yasm.__file__"` - -else - -python-build: -python-install: -python-uninstall: - -endif - -EXTRA_DIST += tools/python-yasm/tests/Makefile.inc -include tools/python-yasm/tests/Makefile.inc diff --git a/tools/python-yasm/bytecode.pxi b/tools/python-yasm/bytecode.pxi deleted file mode 100644 index 34aeaa57..00000000 --- a/tools/python-yasm/bytecode.pxi +++ /dev/null @@ -1,107 +0,0 @@ -# Python bindings for Yasm: Pyrex input file for bytecode.h -# -# Copyright (C) 2006 Michael Urman, Peter Johnson -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND OTHER CONTRIBUTORS ``AS IS'' -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR OTHER CONTRIBUTORS BE -# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. - -cdef class Bytecode: - cdef yasm_bytecode *bc - - cdef object __weakref__ # make weak-referenceable - - def __cinit__(self, bc): - self.bc = NULL - if PyCObject_Check(bc): - self.bc = __get_voidp(bc, Bytecode) - else: - raise NotImplementedError - - def __dealloc__(self): - # Only free if we're not part of a section; if we're part of a section - # the section takes care of freeing the bytecodes. - if self.bc.section == NULL: - yasm_bc_destroy(self.bc) - - property len: - def __get__(self): return self.bc.len - def __set__(self, value): self.bc.len = value - property mult_int: - def __get__(self): return self.bc.mult_int - def __set__(self, value): self.bc.mult_int = value - property line: - def __get__(self): return self.bc.line - def __set__(self, value): self.bc.line = value - property offset: - def __get__(self): return self.bc.offset - def __set__(self, value): self.bc.offset = value - property bc_index: - def __get__(self): return self.bc.bc_index - def __set__(self, value): self.bc.bc_index = value - property symbols: - # Someday extend this to do something modifiable, e.g. return a - # list-like object. - def __get__(self): - cdef yasm_symrec *sym - cdef int i - if self.bc.symrecs == NULL: - return [] - s = [] - i = 0 - sym = self.bc.symrecs[i] - while sym != NULL: - s.append(__make_symbol(sym)) - i = i+1 - sym = self.bc.symrecs[i] - return s - -# -# Keep Bytecode reference paired with bc using weak references. -# This is broken in Pyrex 0.9.4.1; Pyrex 0.9.5 has a working version. -# - -from weakref import WeakValueDictionary as __weakvaldict -__bytecode_map = __weakvaldict() -#__bytecode_map = {} - -cdef object __make_bytecode(yasm_bytecode *bc): - __error_check() - vptr = PyCObject_FromVoidPtr(bc, NULL) - data = __bytecode_map.get(vptr, None) - if data: - return data - bcobj = Bytecode(__pass_voidp(bc, Bytecode)) - __bytecode_map[vptr] = bcobj - return bcobj - -# Org bytecode -def __org__new__(cls, start, value=0, line=0): - cdef yasm_bytecode *bc - bc = yasm_bc_create_org(start, line, value) - obj = Bytecode.__new__(cls, __pass_voidp(bc, Bytecode)) - __bytecode_map[PyCObject_FromVoidPtr(bc, NULL)] = obj - return obj -__org__new__ = staticmethod(__org__new__) -class Org(Bytecode): - __new__ = __org__new__ - - -#cdef class Section: diff --git a/tools/python-yasm/errwarn.pxi b/tools/python-yasm/errwarn.pxi deleted file mode 100644 index 9568cc07..00000000 --- a/tools/python-yasm/errwarn.pxi +++ /dev/null @@ -1,73 +0,0 @@ -# Python bindings for Yasm: Pyrex input file for errwarn.h -# -# Copyright (C) 2006 Peter Johnson -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND OTHER CONTRIBUTORS ``AS IS'' -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR OTHER CONTRIBUTORS BE -# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. - -class YasmError(Exception): pass - -cdef int __error_check() except 1: - cdef yasm_error_class errclass - cdef unsigned long xrefline - cdef char *errstr, *xrefstr - - # short path for the common case - if not yasm_error_occurred(): - return 0 - - # look up our preferred python error, fall back to YasmError - # Order matters here. Go from most to least specific within a class - if yasm_error_matches(YASM_ERROR_ZERO_DIVISION): - exception = ZeroDivisionError - # Enable these once there are tests that need them. - #elif yasm_error_matches(YASM_ERROR_OVERFLOW): - # exception = OverflowError - #elif yasm_error_matches(YASM_ERROR_FLOATING_POINT): - # exception = FloatingPointError - #elif yasm_error_matches(YASM_ERROR_ARITHMETIC): - # exception = ArithmeticError - #elif yasm_error_matches(YASM_ERROR_ASSERTION): - # exception = AssertionError - #elif yasm_error_matches(YASM_ERROR_VALUE): - # exception = ValueError # include notabs, notconst, toocomplex - #elif yasm_error_matches(YASM_ERROR_IO): - # exception = IOError - #elif yasm_error_matches(YASM_ERROR_NOT_IMPLEMENTED): - # exception = NotImplementedError - #elif yasm_error_matches(YASM_ERROR_TYPE): - # exception = TypeError - #elif yasm_error_matches(YASM_ERROR_SYNTAX): - # exception = SyntaxError #include parse - else: - exception = YasmError - - # retrieve info (clears error) - yasm_error_fetch(&errclass, &errstr, &xrefline, &xrefstr) - - if xrefline and xrefstr: - PyErr_Format(exception, "%s: %d: %s", errstr, xrefline, xrefstr) - else: - PyErr_SetString(exception, errstr) - - if xrefstr: free(xrefstr) - free(errstr) - return 1 diff --git a/tools/python-yasm/expr.pxi b/tools/python-yasm/expr.pxi deleted file mode 100644 index 995a46ad..00000000 --- a/tools/python-yasm/expr.pxi +++ /dev/null @@ -1,136 +0,0 @@ -# Python bindings for Yasm: Pyrex input file for expr.h -# -# Copyright (C) 2006 Michael Urman, Peter Johnson -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND OTHER CONTRIBUTORS ``AS IS'' -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR OTHER CONTRIBUTORS BE -# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. - -cdef extern from *: - # Defined as a macro, so not automatically brought in by pyxelator - cdef yasm_expr *yasm_expr_simplify(yasm_expr *e, int calc_bc_dist) - -import operator -__op = {} -for ops, operation in [ - ((operator.__add__, operator.add, '+'), YASM_EXPR_ADD), - ((operator.__and__, operator.and_, '&'), YASM_EXPR_AND), - ((operator.__div__, operator.div, '/'), YASM_EXPR_SIGNDIV), - ((operator.__floordiv__, operator.floordiv, '//'), YASM_EXPR_SIGNDIV), - ((operator.__ge__, operator.ge, '>='), YASM_EXPR_GE), - ((operator.__gt__, operator.gt, '>'), YASM_EXPR_GT), - ((operator.__inv__, operator.inv, '~'), YASM_EXPR_NOT), - ((operator.__invert__, operator.invert), YASM_EXPR_NOT), - ((operator.__le__, operator.le, '<='), YASM_EXPR_LE), - ((operator.__lt__, operator.lt, '<'), YASM_EXPR_LT), - ((operator.__mod__, operator.mod, '%'), YASM_EXPR_SIGNMOD), - ((operator.__mul__, operator.mul, '*'), YASM_EXPR_MUL), - ((operator.__neg__, operator.neg), YASM_EXPR_NEG), - ((operator.__not__, operator.not_, 'not'), YASM_EXPR_LNOT), - ((operator.__or__, operator.or_, '|'), YASM_EXPR_OR), - ((operator.__sub__, operator.sub, '-'), YASM_EXPR_SUB), - ((operator.__xor__, operator.xor, '^'), YASM_EXPR_XOR), - ]: - for op in ops: - __op[op] = operation - -del operator, op, ops, operation - -cdef object __make_expression(yasm_expr *expr): - return Expression(__pass_voidp(expr, Expression)) - -cdef class Expression: - cdef yasm_expr *expr - - def __cinit__(self, op, *args, **kwargs): - self.expr = NULL - - if isinstance(op, Expression): - self.expr = yasm_expr_copy((op).expr) - return - if PyCObject_Check(op): - self.expr = __get_voidp(op, Expression) - return - - cdef size_t numargs - cdef unsigned long line - - op = __op.get(op, op) - numargs = len(args) - line = kwargs.get('line', 0) - - if numargs == 0 or numargs > 2: - raise NotImplementedError - elif numargs == 2: - self.expr = yasm_expr_create(op, self.__new_item(args[0]), - self.__new_item(args[1]), line) - else: - self.expr = yasm_expr_create(op, self.__new_item(args[0]), NULL, - line) - - cdef yasm_expr__item* __new_item(self, value) except NULL: - cdef yasm_expr__item *retval - if isinstance(value, Expression): - return yasm_expr_expr(yasm_expr_copy((value).expr)) - #elif isinstance(value, Symbol): - # return yasm_expr_sym((value).sym) - #elif isinstance(value, Register): - # return yasm_expr_reg((value).reg) - elif isinstance(value, FloatNum): - return yasm_expr_float(yasm_floatnum_copy((value).flt)) - elif isinstance(value, IntNum): - return yasm_expr_int(yasm_intnum_copy((value).intn)) - else: - try: - intnum = IntNum(value) - except: - raise ValueError("Invalid item value type '%s'" % type(value)) - else: - retval = yasm_expr_int((intnum).intn) - (intnum).intn = NULL - return retval - - def __dealloc__(self): - if self.expr != NULL: yasm_expr_destroy(self.expr) - - def simplify(self, calc_bc_dist=False): - self.expr = yasm_expr_simplify(self.expr, calc_bc_dist) - - def extract_segoff(self): - cdef yasm_expr *retval - retval = yasm_expr_extract_segoff(&self.expr) - if retval == NULL: - raise ValueError("not a SEG:OFF expression") - return __make_expression(retval) - - def extract_wrt(self): - cdef yasm_expr *retval - retval = yasm_expr_extract_wrt(&self.expr) - if retval == NULL: - raise ValueError("not a WRT expression") - return __make_expression(retval) - - def get_intnum(self, calc_bc_dist=False): - cdef yasm_intnum *retval - retval = yasm_expr_get_intnum(&self.expr, calc_bc_dist) - if retval == NULL: - raise ValueError("not an intnum expression") - return __make_intnum(yasm_intnum_copy(retval)) - diff --git a/tools/python-yasm/floatnum.pxi b/tools/python-yasm/floatnum.pxi deleted file mode 100644 index b7bfbc30..00000000 --- a/tools/python-yasm/floatnum.pxi +++ /dev/null @@ -1,49 +0,0 @@ -# Python bindings for Yasm: Pyrex input file for floatnum.h -# -# Copyright (C) 2006 Michael Urman, Peter Johnson -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND OTHER CONTRIBUTORS ``AS IS'' -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR OTHER CONTRIBUTORS BE -# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. - -cdef class FloatNum: - cdef yasm_floatnum *flt - def __cinit__(self, value): - self.flt = NULL - if isinstance(value, FloatNum): - self.flt = yasm_floatnum_copy((value).flt) - return - if PyCObject_Check(value): # should check Desc - self.flt = PyCObject_AsVoidPtr(value) - return - - if isinstance(value, float): string = str(float) - else: string = value - self.flt = yasm_floatnum_create(string) - - def __dealloc__(self): - if self.flt != NULL: yasm_floatnum_destroy(self.flt) - - def __neg__(self): - result = FloatNum(self) - yasm_floatnum_calc((result).flt, YASM_EXPR_NEG, NULL) - return result - def __pos__(self): return self - diff --git a/tools/python-yasm/intnum.pxi b/tools/python-yasm/intnum.pxi deleted file mode 100644 index 320ca1b0..00000000 --- a/tools/python-yasm/intnum.pxi +++ /dev/null @@ -1,170 +0,0 @@ -# Python bindings for Yasm: Pyrex input file for intnum.h -# -# Copyright (C) 2006 Michael Urman, Peter Johnson -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND OTHER CONTRIBUTORS ``AS IS'' -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR OTHER CONTRIBUTORS BE -# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. - -cdef class IntNum - -cdef object __intnum_op_ex(object x, yasm_expr_op op, object y): - value = __intnum_op(x, op, y) - __error_check() - return value - -cdef object __intnum_op(object x, yasm_expr_op op, object y): - if isinstance(x, IntNum): - result = IntNum(x) - if y is None: - yasm_intnum_calc((result).intn, op, NULL) - else: - # Coerce to intnum if not already - if isinstance(y, IntNum): - rhs = y - else: - rhs = IntNum(y) - yasm_intnum_calc((result).intn, op, (rhs).intn) - return result - elif isinstance(y, IntNum): - # Reversed operation - x OP y still, just y is intnum, x isn't. - result = IntNum(x) - yasm_intnum_calc((result).intn, op, (y).intn) - return result - else: - raise NotImplementedError - -cdef object __make_intnum(yasm_intnum *intn): - return IntNum(__pass_voidp(intn, IntNum)) - -cdef class IntNum: - cdef yasm_intnum *intn - - def __cinit__(self, value, base=None): - cdef unsigned char buf[16] - - self.intn = NULL - - if isinstance(value, IntNum): - self.intn = yasm_intnum_copy((value).intn) - return - if PyCObject_Check(value): - self.intn = __get_voidp(value, IntNum) - return - - if isinstance(value, str): - if base == 2: - self.intn = yasm_intnum_create_bin(value) - elif base == 8: - self.intn = yasm_intnum_create_oct(value) - elif base == 10 or base is None: - self.intn = yasm_intnum_create_dec(value) - elif base == 16: - self.intn = yasm_intnum_create_hex(value) - elif base == "nasm": - self.intn = yasm_intnum_create_charconst_nasm(value) - else: - raise ValueError("base must be 2, 8, 10, 16, or \"nasm\"") - elif isinstance(value, (int, long)): - _PyLong_AsByteArray(long(value), buf, 16, 1, 1) - self.intn = yasm_intnum_create_sized(buf, 1, 16, 0) - else: - raise ValueError - - def __dealloc__(self): - if self.intn != NULL: yasm_intnum_destroy(self.intn) - - def __long__(self): - cdef unsigned char buf[16] - yasm_intnum_get_sized(self.intn, buf, 16, 128, 0, 0, 0) - return _PyLong_FromByteArray(buf, 16, 1, 1) - - def __repr__(self): - return "IntNum(%d)" % self - - def __int__(self): return int(self.__long__()) - def __complex__(self): return complex(self.__long__()) - def __float__(self): return float(self.__long__()) - - def __oct__(self): return oct(int(self.__long__())) - def __hex__(self): return hex(int(self.__long__())) - - def __add__(x, y): return __intnum_op(x, YASM_EXPR_ADD, y) - def __sub__(x, y): return __intnum_op(x, YASM_EXPR_SUB, y) - def __mul__(x, y): return __intnum_op(x, YASM_EXPR_MUL, y) - def __div__(x, y): return __intnum_op_ex(x, YASM_EXPR_SIGNDIV, y) - def __floordiv__(x, y): return __intnum_op_ex(x, YASM_EXPR_SIGNDIV, y) - def __mod__(x, y): return __intnum_op_ex(x, YASM_EXPR_SIGNMOD, y) - def __neg__(self): return __intnum_op(self, YASM_EXPR_NEG, None) - def __pos__(self): return self - def __abs__(self): - if yasm_intnum_sign(self.intn) >= 0: return IntNum(self) - else: return __intnum_op(self, YASM_EXPR_NEG, None) - def __nonzero__(self): return not yasm_intnum_is_zero(self.intn) - def __invert__(self): return __intnum_op(self, YASM_EXPR_NOT, None) - def __lshift__(x, y): return __intnum_op(x, YASM_EXPR_SHL, y) - def __rshift__(x, y): return __intnum_op(x, YASM_EXPR_SHR, y) - def __and__(x, y): return __intnum_op(x, YASM_EXPR_AND, y) - def __or__(x, y): return __intnum_op(x, YASM_EXPR_OR, y) - def __xor__(x, y): return __intnum_op(x, YASM_EXPR_XOR, y) - - cdef object __op(self, yasm_expr_op op, object x): - if isinstance(x, IntNum): - rhs = x - else: - rhs = IntNum(x) - yasm_intnum_calc(self.intn, op, (rhs).intn) - return self - - def __iadd__(self, x): return self.__op(YASM_EXPR_ADD, x) - def __isub__(self, x): return self.__op(YASM_EXPR_SUB, x) - def __imul__(self, x): return self.__op(YASM_EXPR_MUL, x) - def __idiv__(self, x): return self.__op(YASM_EXPR_SIGNDIV, x) - def __ifloordiv__(self, x): return self.__op(YASM_EXPR_SIGNDIV, x) - def __imod__(self, x): return self.__op(YASM_EXPR_MOD, x) - def __ilshift__(self, x): return self.__op(YASM_EXPR_SHL, x) - def __irshift__(self, x): return self.__op(YASM_EXPR_SHR, x) - def __iand__(self, x): return self.__op(YASM_EXPR_AND, x) - def __ior__(self, x): return self.__op(YASM_EXPR_OR, x) - def __ixor__(self, x): return self.__op(YASM_EXPR_XOR, x) - - def __cmp__(self, x): - cdef yasm_intnum *t - t = yasm_intnum_copy(self.intn) - if isinstance(x, IntNum): - rhs = x - else: - rhs = IntNum(x) - yasm_intnum_calc(t, YASM_EXPR_SUB, (rhs).intn) - result = yasm_intnum_sign(t) - yasm_intnum_destroy(t) - return result - - def __richcmp__(x, y, op): - cdef yasm_expr_op aop - if op == 0: aop = YASM_EXPR_LT - elif op == 1: aop = YASM_EXPR_LE - elif op == 2: aop = YASM_EXPR_EQ - elif op == 3: aop = YASM_EXPR_NE - elif op == 4: aop = YASM_EXPR_GT - elif op == 5: aop = YASM_EXPR_GE - else: raise NotImplementedError - v = __intnum_op(x, aop, y) - return bool(not yasm_intnum_is_zero((v).intn)) diff --git a/tools/python-yasm/pyxelator/TODO b/tools/python-yasm/pyxelator/TODO deleted file mode 100644 index cfe1e184..00000000 --- a/tools/python-yasm/pyxelator/TODO +++ /dev/null @@ -1,16 +0,0 @@ - -pyxelator TODO: -=============== - -.) callback functions: these are working but it needs to be thought out some more. Exceptions are not propagated from callbacks. -.) no nice module structure: it's all in one fat module. -.) extern symbols and macros are a little tricky to wrap, some have been hardcoded (!!) in petscmacros.py. -.) type checking -.) upcasting -.) adapt system memory usage audit: record and check every malloc/free/memcpy/memcmp - and every memory access using those nasty void* pointers - -21/10/05 - - - diff --git a/tools/python-yasm/pyxelator/cparse.py b/tools/python-yasm/pyxelator/cparse.py deleted file mode 100755 index 53754f86..00000000 --- a/tools/python-yasm/pyxelator/cparse.py +++ /dev/null @@ -1,819 +0,0 @@ -#!/usr/bin/env python - -""" - -(c) 2002, 2003, 2004, 2005 Simon Burton -Released under GNU LGPL license. - -""" - -import sys - -from lexer import Lexer -from parse_core import Symbols, Parser -import node as node_module - - -class Node(node_module.Node): - - def is_typedef(self): - for x in self: - if isinstance(x,Node): - if x.is_typedef(): - return 1 - return 0 - - #def explain(self): - #l = [] - #for x in self: - #if isinstance(x,Node): - #l.append(x.explain()) - #else: - #l.append(str(x)) - #return string.join(l," ") - ##(self.__class__.__name__,string.join(l) ) - - def psource(self): - if hasattr(self,'lines'): - print "# "+string.join(self.lines,"\n# ")+"\n" - - -################################################################### -# -################################################################### -# - - -class BasicType(Node): - " int char short etc. " - def __init__(self,name): - Node.__init__(self,name) - -class Qualifier(Node): - """ - """ - def __init__(self,name): - Node.__init__(self,name) - self.name=name - -class StorageClass(Node): - """ - """ - def __init__(self,name): - Node.__init__(self,name) - self.name=name - -class Typedef(StorageClass): - """ - """ - def __init__(self,s='typedef'): - Node.__init__(self,s) - #def explain(self): - #return "type" - -class Ellipses(Node): - """ - """ - def __init__(self,s='...'): - Node.__init__(self,s) - -class GCCBuiltin(BasicType): - """ - """ - pass - - -class Identifier(Node): - """ - """ - def __init__(self,name="",*items): - if name or 1: - Node.__init__(self,name,*items) - else: - Node.__init__(self) - self.name=name - -class Function(Node,Parser): - """ - """ - def __init__(self,*items): - Node.__init__(self,*items) - - def parse(self,lexer,symbols): - symbols = Symbols(symbols) - args = '' - #lexer.get_token() - if lexer.tok != ')': - if not lexer.tok: - self.parse_error(lexer) - #lexer.unget_token() # unget start of decl - while lexer.tok != ')': - node = ParameterDeclaration() - node.parse(lexer,symbols) - self.append( node ) - if lexer.tok != ')' and lexer.tok != ',': - self.parse_error(lexer) - if lexer.tok == ',': - lexer.get_token() - lexer.get_token() - - -class Pointer(Node): - """ - """ - def __init__(self,*items): - Node.__init__(self,*items) - -class Array(Node,Parser): - """ - """ - def __init__(self,*items): - Node.__init__(self,*items) - - def parse(self,lexer,symbols): - lexer.get_token() # a number or ']' - # XX - # HACK HACK: constant c expressions can appear in here: - # eg. [ 15 * sizeof (int) - 2 * sizeof (void *) ] - # XX - toks = [] - while lexer.tok != ']': - #self.append( lexer.kind ) - toks.append( lexer.tok ) - lexer.get_token() - child = " ".join(toks) - if child == "": - child = None - self.append( child ) - lexer.get_token() # read past the ']' - -class Tag(Node): - """ - """ - pass - - -class Compound(Node,Parser): - "Struct or Union" - - def __init__(self,*items,**kw): - Node.__init__(self,*items,**kw) - - def parse(self,lexer,symbols): - symbols = Symbols(symbols) - tag = "" # anonymous - if lexer.tok != '{': - tag = lexer.tok - if not ( tag[0]=='_' or tag[0].isalpha() ): - self.parse_error(lexer ,"expected tag, got '%s'"%tag ) - lexer.get_token() - if tag: - self.append(Tag(tag)) - else: - self.append(Tag()) - self.tag = tag - if lexer.tok == '{': - fieldlist = [] - lexer.get_token() - if lexer.tok != '}': - if not lexer.tok: self.parse_error(lexer) - while lexer.tok != '}': - node = StructDeclaration() - node.parse(lexer,symbols) - fieldlist.append( node ) - self += fieldlist - lexer.get_token() - if self.verbose: - print "%s.__init__() #<--"%(self) - -class Struct(Compound): - """ - """ - pass - -class Union(Compound): - """ - """ - pass - -class Enum(Node,Parser): - """ - """ - def __init__(self,*items,**kw): - Node.__init__(self,*items,**kw) - - def parse(self,lexer,symbols): - tag = "" # anonymous - if lexer.tok != '{': - tag = lexer.tok - if not ( tag[0]=='_' or tag[0].isalpha() ): - self.parse_error(lexer ,"expected tag, got '%s'"%tag ) - lexer.get_token() - if tag: - self.append(Tag(tag)) - else: - self.append(Tag()) - self.tag = tag - if lexer.tok == '{': - lexer.get_token() - if lexer.tok != '}': # XX dopey control flow - if not lexer.tok: # XX dopey control flow - self.parse_error(lexer) # XX dopey control flow - while lexer.tok != '}': # XX dopey control flow - if lexer.kind is not None: - self.expected_error(lexer ,"identifier" ) - ident = Identifier(lexer.tok) - if symbols[ident[0]] is not None: - self.parse_error(lexer,"%s already defined."%ident[0]) - symbols[ident[0]]=ident - self.append( ident ) - lexer.get_token() - if lexer.tok == '=': - lexer.get_token() - # ConstantExpr - # XX hack hack XX - while lexer.tok!=',' and lexer.tok!='}': - lexer.get_token() -# if type( lexer.kind ) is not int: -# #self.parse_error(lexer ,"expected integer" ) -# # XX hack hack XX -# while lexer.tok!=',' and lexer.tok!='}': -# lexer.get_token() -# else: -# # put initializer into the Identifier -# ident.append( lexer.kind ) -# lexer.get_token() - if lexer.tok != '}': - if lexer.tok != ',': - self.expected_error(lexer,"}",",") - lexer.get_token() # ',' - lexer.get_token() - if self.verbose: - print "%s.__init__() #<--"%(self) - - - -class Declarator(Node,Parser): - """ - """ - def __init__(self,*items): - Node.__init__(self,*items) - self.ident = None - - def parse(self,lexer,symbols): - #Parser.parse_enter(self,lexer) - stack = [] - # read up to identifier, pushing tokens onto stack - self.ident = self.parse_identifier(lexer,symbols,stack) - self.name = '' - if self.ident is not None: - self.append( self.ident ) - self.name = self.ident.name - # now read outwards from identifier - self.parse_declarator(lexer,symbols,stack) - #Parser.parse_leave(self,lexer) - - def parse_identifier(self,lexer,symbols,stack): - if self.verbose: - print "%s.parse_identifier()"%self - ident = None - if lexer.tok != ';': - while lexer.tok and lexer.kind is not None: - stack.append( (lexer.tok, lexer.kind) ) - lexer.get_token() - if lexer.tok: - ident = Identifier( lexer.tok ) - #stack.append( (ident.name, ident) ) - lexer.get_token() - if self.verbose: - print "%s.parse_identifier()=%s"%(self,repr(ident)) - return ident - - def parse_declarator(self,lexer,symbols,stack,level=0): - if self.verbose: - print " "*level+"%s.parse_declarator(%s) # --->"%\ - (self,stack) - if lexer.tok == '[': - while lexer.tok == '[': - node = Array() - node.parse(lexer,symbols) - self.append(node) - if lexer.tok == '(': - self.parse_error(lexer ,"array of functions" ) - elif lexer.tok == '(': - lexer.get_token() - node = Function() - node.parse(lexer,symbols) - self.append( node ) - if lexer.tok == '(': - self.parse_error(lexer ,"function returns a function" ) - if lexer.tok == '[': - self.parse_error(lexer ,"function returns an array" ) - while stack: - tok, kind = stack[-1] # peek - if tok == '(': - stack.pop() - self.consume(lexer,')') - self.parse_declarator(lexer,symbols,stack,level+1) - elif tok == '*': - stack.pop() - self.append( Pointer() ) - else: - tok, kind = stack.pop() - self.append( kind ) - if self.verbose: - print " "*level+"%s.parse_declarator(%s) # <---"%\ - (self,stack) - - -class AbstractDeclarator(Declarator): - """ used in ParameterDeclaration; may lack an identifier """ - - def parse_identifier(self,lexer,symbols,stack): - if self.verbose: - print "%s.parse_identifier()"%self - ident = None - ident = Identifier() - while 1: - if lexer.tok == ';': - self.parse_error(lexer) - if lexer.tok == ')': - break - if lexer.tok == ',': - break - if lexer.tok == '[': - break - if lexer.kind is None: - #print "%s.new identifier"%self - ident = Identifier( lexer.tok ) - lexer.get_token() - #stack.append( (ident.name, ident) ) - break - stack.append( (lexer.tok, lexer.kind) ) - lexer.get_token() - if self.verbose: - print "%s.parse_identifier()=%s"%(self,repr(ident)) - return ident - -class FieldLength(Node): - """ - """ - pass - -class StructDeclarator(Declarator): - """ - """ - def parse(self,lexer,symbols): - if lexer.tok != ':': - Declarator.parse(self,lexer,symbols) - if lexer.tok == ':': - lexer.get_token() - # ConstantExpr - length = int(lexer.tok) - #print "length = ",length - self.append( FieldLength(length) ) - lexer.get_token() - -class DeclarationSpecifiers(Node,Parser): - """ - """ - def __init__(self,*items): - Node.__init__(self,*items) - - def __eq__(self,other): - " unordered (set/bag) equality " - if not isinstance(other,Node): - return 0 - for i in range(len(self)): - if not self[i] in other: - return 0 - for i in range(len(other)): - if not other[i] in self: - return 0 - return 1 - - def parse(self,lexer,symbols): - self.parse_spec(lexer,symbols) - self.reverse() - - def parse_spec(self,lexer,symbols): - typespec = None - while lexer.tok: - if isinstance( lexer.kind, TypeAlias ) or\ - isinstance( lexer.kind, BasicType ): - if typespec is not None: - self.parse_error(lexer ,"type already specified as %s"\ - %typespec ) - typespec=lexer.kind - self.append( lexer.kind ) - lexer.get_token() - elif isinstance( lexer.kind, Qualifier ): - self.append( lexer.kind ) - lexer.get_token() - elif isinstance( lexer.kind, StorageClass ): - self.append( lexer.kind ) - lexer.get_token() - elif lexer.tok=='struct': - lexer.get_token() - self.parse_struct(lexer,symbols) - break #? - elif lexer.tok=='union': - lexer.get_token() - self.parse_union(lexer,symbols) - break #? - elif lexer.tok=='enum': - lexer.get_token() - self.parse_enum(lexer,symbols) - break #? - elif lexer.kind is None: - # identifier - break - else: - break - - def parse_struct(self,lexer,symbols): - if self.verbose: - print "%s.parse_struct()"%(self) - node = Struct() - node.parse(lexer,symbols) - _node = None - if node.tag: - _node = symbols.get_tag( node.tag ) - if _node is not None: - if not isinstance( _node, Struct ): - self.parse_error(lexer,"tag defined as wrong kind") - if len(node)>1: - if len(_node)>1: - self.parse_error(lexer,"tag already defined as %s"%_node) - #symbols.set_tag( node.tag, node ) - #else: - # refer to the previously defined struct - ##node = _node - #node = _node.clone() - if 0: - # refer to the previously defined struct - if len(node)==1: - _node = symbols.deep_get_tag( node.tag ) - if _node is not None: - node=_node - # But what about any future reference to the struct ? - if node.tag: - symbols.set_tag( node.tag, node ) - self.append( node ) - - def parse_union(self,lexer,symbols): - if self.verbose: - print "%s.parse_union(%s)"%(self,node) - node = Union() - node.parse(lexer,symbols) - _node = None - if node.tag: - _node = symbols.get_tag( node.tag ) - if _node is not None: - if not isinstance( _node, Union ): - self.parse_error(lexer,"tag %s defined as wrong kind"%repr(node.tag)) - if len(node)>1: - if len(_node)>1: - self.parse_error(lexer,"tag already defined as %s"%_node) - #symbols.set_tag( node.tag, node ) - #else: - #node = _node - #if len(node)==1: - #_node = symbols.deep_get_tag( node.tag ) - #if _node is not None: - #node=_node - if node.tag: - symbols.set_tag( node.tag, node ) - self.append( node ) - - def parse_enum(self,lexer,symbols): - if self.verbose: - print "%s.parse_enum(%s)"%(self,node) - node = Enum() - node.parse(lexer,symbols) - _node = None - if node.tag: - _node = symbols.get_tag( node.tag ) - if _node is not None: - if not isinstance( _node, Enum ): - self.parse_error(lexer,"tag defined as wrong kind") - if len(node)>1: - if len(_node)>1: - self.parse_error(lexer,"tag already defined as %s"%_node) - #symbols.set_tag( node.tag, node ) - #else: - #node = _node - #if len(node)==1: - #_node = symbols.deep_get_tag( node.tag ) - #if _node is not None: - #node=_node - if node.tag: - symbols.set_tag( node.tag, node ) - self.append( node ) - - def is_typedef(self): - return self.find(Typedef) is not None - - def needs_declarator(self): - for node in self: - if isinstance( node, Struct ): - return False - if isinstance( node, Enum ): - return False - if isinstance( node, Union ): - return False - return True - - - -class TypeSpecifiers(DeclarationSpecifiers): - " used in ParameterDeclaration " - - def parse_spec(self,lexer,symbols): - typespec = None - while lexer.tok: - if isinstance( lexer.kind, TypeAlias ) or\ - isinstance( lexer.kind, BasicType ): - if typespec is not None: - self.parse_error(lexer ,"type already specified as %s"\ - %typespec ) - typespec=lexer.kind - self.append( lexer.kind ) - lexer.get_token() - elif isinstance( lexer.kind, Qualifier ): - self.append( lexer.kind ) - lexer.get_token() - elif isinstance( lexer.kind, StorageClass ): - self.parse_error(lexer ,"'%s' cannot appear here"%lexer.tok ) - elif lexer.tok=='struct': - lexer.get_token() - self.parse_struct(lexer,symbols) - break #? - elif lexer.tok=='union': - lexer.get_token() - self.parse_union(lexer,symbols) - break #? - elif lexer.tok=='enum': - lexer.get_token() - self.parse_enum(lexer,symbols) - break #? - elif lexer.kind is None: - # identifier - break - else: - break - - -class Initializer(Node,Parser): - """ - """ - def __init__(self,*items): - Node.__init__(self,*items) - - def parse(self,lexer,symbols): - self.parse_error(lexer,"not implemented") - - -class TypeAlias(Node): - " typedefed things " - - def __init__(self,name,decl=None): - Node.__init__(self,name)#,decl) - self.name=name - self.decl=decl - - -class Declaration(Node,Parser): - """ - """ - def __init__(self,*items): - Node.__init__(self,*items) - #self.acted=False - - def parse(self,lexer,symbols): - if not lexer.tok: - return - Parser.parse_enter(self,lexer) - declspec = DeclarationSpecifiers() - declspec.parse(lexer,symbols) - if len(declspec)==0: - if lexer.tok == ';': - lexer.get_token() - # empty declaration... - return - self.parse_error(lexer, - "expected specifiers, got '%s'"%lexer.tok ) - self.append(declspec) - while 1: - decl = Declarator() - decl.parse(lexer,symbols) - if len(decl)==0: - if declspec.needs_declarator(): - self.parse_error(lexer, - "expected declarator, got '%s'"%lexer.tok ) - self.append(decl) - ident = decl.ident - if ident is not None: - #if len(ident): - # install symbol - node = symbols[ident[0]] - if node is not None: - # we allow functions to be defined (as same) again - #print node.deepstr(),'\n', self.deepstr() - _node = node.clone() - _node.delete(Identifier) - _self = self.clone() - _self.delete(Identifier) - if _node != _self: - self.parse_error(lexer, - "\n%s\n already defined as \n%s\n"%\ - (self.deepstr(),node.deepstr())) - else: - if self.is_typedef(): - #lexer.mktypedef( ident[0], self ) - tp = TypeAlias(ident[0],decl) - lexer.mktypedef( ident[0], tp ) - else: - symbols[ident[0]] = self - if lexer.tok == '=': - # parse initializer - lexer.get_token() - init = Initializer() - init.parse(lexer,symbols) - ident.append( init ) # as in Enum - #else: struct, union or enum - if lexer.tok == ';': - # no more declarators - break - if lexer.tok == '{': - # ! ahhh, function body !!! -# sys.stderr.write( -# "WARNING: function body found at line %s\n"%lexer.lno ) - bcount = 1 - while bcount: - lexer.get_brace_token() - if lexer.tok == '}': - bcount -= 1 - if lexer.tok == '{': - bcount += 1 - lexer.get_token() - Parser.parse_leave(self,lexer) - return - self.consume(lexer,',') - self.consume(lexer,';') - Parser.parse_leave(self,lexer) - - def is_typedef(self): - spec=self[0] - assert isinstance(spec,DeclarationSpecifiers), self.deepstr() - return spec.is_typedef() - - -class ParameterDeclaration(Declaration): - """ - """ - def parse(self,lexer,symbols): - typespec = TypeSpecifiers() - typespec.parse(lexer,symbols) - self.append(typespec) - decl = AbstractDeclarator() - decl.parse(lexer,symbols) - self.append(decl) - ident = decl.ident - if ident is not None and ident[0]: - node = symbols[ident[0]] - if node is not None: - self.parse_error(lexer, - "%s already defined as %s"%(ident,node)) - else: - symbols[ident[0]] = self - - -class StructDeclaration(Declaration): - """ - """ - def parse(self,lexer,symbols): - if not lexer.tok: - return - declspec = DeclarationSpecifiers() - declspec.parse(lexer,symbols) - self.append(declspec) - if len(declspec)==0: - if lexer.tok == ';': - lexer.get_token() - # empty declaration... - return - self.parse_error(lexer, - "expected specifiers, got '%s'"%lexer.tok ) - while 1: - decl = StructDeclarator() - decl.parse(lexer,symbols) - if len(decl)==0: - self.parse_error(lexer, - "expected declarator, got '%s'"%lexer.tok ) - self.append(decl) - ident = decl.ident - if ident is not None: - node = symbols[ident[0]] - if node is not None: - self.parse_error(lexer , - "%s already defined as %s"%(ident,node)) - else: - if declspec.is_typedef(): - self.parse_error(lexer,"typedef in struct or union") - else: - symbols[ident[0]] = self - if lexer.tok == ';': - break - self.consume(lexer,',') - self.consume(lexer,';') - - -class TransUnit(Node,Parser): - """ - """ - def __init__(self,*items,**kw): - Node.__init__(self,*items,**kw) - - def parse(self,s,verbose=0): - self.symbols = Symbols() - self.lexer = Lexer(s,verbose=verbose) #,host=__module__) - node = None - while self.lexer.tok: - node=Declaration() - node.parse(self.lexer,self.symbols) - #sys.stderr.write( "# line %s\n"%self.lexer.lno ) - if node: - self.append(node) - #node.psource() - #print node.deepstr(),'\n' - #node.act() - - def strip(self,files): - " leave only the declarations from " - i=0 - while i -Released under GNU LGPL license. - -version 0.xx - -This is a module of mixin classes for ir.py . - -Towards the end of ir.py our global class definitions -are remapped to point to the class definitions in ir.py . -So, for example, when we refer to Node we get ir.Node . - -""" - -import sys -from datetime import datetime - -# XX use this Context class instead of all those kw dicts !! XX -class Context(object): - " just a record (struct) " - def __init__( self, **kw ): - for key, value in kw.items(): - setattr( self, key, value ) - def __getattr__( self, name ): - return None # ? - def __getitem__( self, name ): - return getattr(self, name) - -class OStream(object): - def __init__( self, filename=None ): - self.filename = filename - self.tokens = [] - self._indent = 0 - def put( self, token="" ): - assert type(token) is str - self.tokens.append( token ) - def startln( self, token="" ): - assert type(token) is str - self.tokens.append( ' '*self._indent + token ) - def putln( self, ln="" ): - assert type(ln) is str - self.tokens.append( ' '*self._indent + ln + '\n') - def endln( self, token="" ): - assert type(token) is str - self.tokens.append( token + '\n') - def indent( self ): - self._indent += 1 - def dedent( self ): - self._indent -= 1 - assert self._indent >= 0, self._indent - def join( self ): - return ''.join( self.tokens ) - def close( self ): - s = ''.join( self.tokens ) - f = open( self.filename, 'w' ) - f.write(s) - -# -############################################################################### -# - -class Node(object): - """ - tree structure - """ - _unique_id = 0 - def get_unique_id(cls): - Node._unique_id += 1 - return Node._unique_id - get_unique_id = classmethod(get_unique_id) - -# XX toks: use a tree of tokens: a list that can be push'ed and pop'ed XX - def pyxstr(self,toks=None,indent=0,**kw): - """ - Build a list of tokens; return the joined tokens string - """ - if toks is None: - toks = [] - for x in self: - if isinstance(x,Node): - x.pyxstr(toks, indent, **kw) - else: - toks.insert(0,str(x)+' ') - s = ''.join(toks) - return s - -# -################################################# - -class Named(object): - "has a .name property" - pass - -class BasicType(object): - "float double void char int" - pass - -class Qualifier(object): - "register signed unsigned short long const volatile inline" - def pyxstr(self,toks=None,indent=0,**kw): - if toks is None: - toks = [] - x = self[0] - if x not in ( 'const','volatile','inline','register'): # ignore these - toks.insert(0,str(x)+' ') - s = ''.join(toks) - return s - -class StorageClass(object): - "extern static auto" - def pyxstr(self,toks=None,indent=0,**kw): - return "" - -class Ellipses(object): - "..." - pass - -class GCCBuiltin(BasicType): - "things with __builtin prefix" - pass - -class Identifier(object): - """ - """ - def pyxstr(self,toks=None,indent=0,**kw): - if toks is None: - toks=[] - if self.name: - toks.append( self.name ) - return " ".join(toks) - -class TypeAlias(object): - """ - typedefed things, eg. size_t - """ - def pyxstr(self,toks=None,indent=0,cprefix="",**kw): - if toks is None: - toks = [] - for x in self: - if isinstance(x,Node): - x.pyxstr(toks, indent, cprefix=cprefix, **kw) - else: - s = str(x)+' ' - if cprefix: - s = cprefix+s - toks.insert(0,s) - s = ''.join(toks) - return s - -class Function(object): - """ - """ - def pyxstr(self,toks,indent=0,**kw): - #print '%s.pyxstr(%s)'%(self,toks) - _toks=[] - assert len(self) - i=0 - while isinstance(self[i],Declarator): - if not self[i].is_void(): - _toks.append( self[i].pyxstr(indent=indent, **kw) ) - i=i+1 - toks.append( '(%s)'% ', '.join(_toks) ) - while i&%s' % (self.name, cprefix+self.name) ) - ## expose a python object: - #ostream.putln( '%s.%s = %s' % (modname,self.name, self.name) ) - ostream.putln( '%s = %s( addr = &%s )' % (self.name, self.pyx_adaptor_name(cobjects), cprefix+self.name) ) - return ostream - - -class Typedef(Declarator): - def pyxstr(self,toks=None,indent=0,cprefix="",use_cdef=True,shadow_name=True,**kw): # shadow_name=True - " warning: i do not check if my name is already in 'names' " - assert shadow_name == True - self = self.clone() # <----- NOTE - toks=[] - names = kw.get('names',{}) # what names have been defined ? - kw['names']=names - - #if self.tagged and not self.tagged.tag.name: - ## "typedef struct {...} foo;" => "typedef struct foo {...} foo;" - ## (to be emitted in the node loop below, and suppressed in the final toks.append) - #self.tagged.tag = Tag( self.name ) # this is how pyrex does it: tag.name == self.name - # XX that doesn't work (the resulting c fails to compile) XX - - self._pyxstr( toks, indent, cprefix, use_cdef, shadow_name, **kw ) - - #print self.deepstr() - if self.name and not names.has_key( self.name ): - names[ self.name ] = self - if not (self.tagged and self.name == self.tagged.tag.name): - comment = "" - if self.name in python_kws: - comment = "#" - #if cprefix: - # self.name = '%s%s "%s" ' % ( cprefix, self.name, self.name ) # XX pyrex can't do this - if cprefix: # shadow_name=True - # My c-name gets this prefix. See also TypeAlias.pyxstr(): it also prepends the cprefix. - self.name = '%s%s "%s" ' % ( cprefix, self.name, self.name ) - toks.append( ' '*indent + comment + 'ctypedef ' + Node.pyxstr(self,indent=indent, cprefix=cprefix, **kw).strip() ) - return ' \n'.join(toks) - - -class AbstractDeclarator(Declarator): - """ used in Function; may lack an identifier """ - def pyxstr(self,toks=None,indent=0,**kw): - if self.name in python_kws: - # Would be better to do this in __init__, but our subclass doesn't call our __init__. - self.name = '_' + self.name - #return ' '*indent + Node.pyxstr(self,toks,indent, **kw).strip() - return Node.pyxstr(self,toks,indent, **kw).strip() - - -class FieldLength(object): - """ - """ - def pyxstr(self,toks,indent,**kw): - pass - - -class StructDeclarator(Declarator): # also used in Union - """ - """ - def pyxstr(self,toks=None,indent=0,**kw): - comment = "" - if self.name in python_kws: - comment = "#" - return ' '*indent + comment + Node.pyxstr(self,toks,indent, **kw).strip() - -class DeclarationSpecifiers(object): - """ - """ - pass - -class TypeSpecifiers(DeclarationSpecifiers): - """ - """ - pass - -class Initializer(object): - """ - """ - pass - -class Declaration(object): - """ - """ - pass - -class ParameterDeclaration(Declaration): - """ - """ - pass - -class StructDeclaration(Declaration): - """ - """ - pass - -class TransUnit(object): - """ - Top level node. - """ - def pyx_decls(self, filenames, modname, macros = {}, names = {}, func_cb=None, cprefix="", **kw): - # PART 1: emit extern declarations - ostream = OStream() - now = datetime.today() - ostream.putln( now.strftime('# Code generated by pyxelator on %x at %X') + '\n' ) - ostream.putln("# PART 1: extern declarations") - for filename in filenames: - ostream.putln( 'cdef extern from "%s":\n pass\n' % filename ) - ostream.putln( 'cdef extern from *:' ) - file = None # current file - for node in self: - ostream.putln('') - ostream.putln(' # ' + node.cstr() ) - assert node.marked - comment = False - if node.name and node.name in names: - comment = True # redeclaration - #ostream.putln( node.deepstr( comment=True ) ) - s = node.pyxstr(indent=1, names=names, tag_lookup = self.tag_lookup, cprefix=cprefix, **kw) - if s.split(): - if comment: - s = "#"+s.replace( '\n', '\n#' ) + " # redeclaration " - if node.file != file: - file = node.file - #ostream.putln( 'cdef extern from "%s":' % file ) - ostream.putln( ' # "%s"' % file ) - ostream.putln( s ) - ostream.putln('\n') - #s = '\n'.join(toks) - return ostream.join() - -# XX warn when we find a python keyword XX -python_kws = """ -break continue del def except exec finally pass print raise -return try global assert lambda yield -for while if elif else and in is not or import from """.split() -python_kws = dict( zip( python_kws, (None,)*len(python_kws) ) ) - - diff --git a/tools/python-yasm/pyxelator/ir.py b/tools/python-yasm/pyxelator/ir.py deleted file mode 100755 index cfa9c02e..00000000 --- a/tools/python-yasm/pyxelator/ir.py +++ /dev/null @@ -1,1163 +0,0 @@ -#!/usr/bin/env python -""" ir.py - parse c declarations - -(c) 2002, 2003, 2004, 2005 Simon Burton -Released under GNU LGPL license. - -version 0.xx - -""" - -import sys -#import cPickle as pickle -import pickle - -#from lexer import Lexer -from parse_core import Symbols #, Parser -import node as node_module -import cparse -import genpyx - -class Node(genpyx.Node, node_module.Node): - """ - tree structure - """ - def __init__( self, *args, **kw ): - node_module.Node.__init__( self, *args, **kw ) - self._marked = False - def get_marked( self ): - return self._marked - def set_marked( self, marked ): -# if marked: -# print "MARK", self - self._marked = marked - marked = property( get_marked, set_marked ) - -# def __getstate__( self ): -# return self.__class__, tuple( [ item.__getstate__() for item in self ] ) -# def __setstate__( self, state ): -# cls, states = state -# states = list(states) -# for idx, state in enumerate(states): -# items[idx] = items[idx].__setstate__( - def __getstate__(self): - return str(self) - def __setstate__(self, state): - Node.__init__(self) - self[:] = eval(state) - -# _unique_id = 0 -# def get_unique_id(cls): -# Node._unique_id += 1 -# return Node._unique_id -# get_unique_id = classmethod(get_unique_id) - - def __hash__( self ): - return hash( tuple([hash(type(self))]+[hash(item) for item in self]) ) - - def clone(self): - l = [] - for item in self: - if isinstance(item,Node): - item = item.clone() - l.append(item) - return self.__class__(*l, **self.__dict__) - - def init_from( self, other ): # class method ? - # Warning: shallow init - self[:] = other - self.__dict__.update( other.__dict__ ) - return self - -# def is_struct(self): -# for x in self: -# if isinstance(x,Node): -# if x.is_struct(): -# return 1 -# return 0 - - - #def explain(self): - #l = [] - #for x in self: - #if isinstance(x,Node): - #l.append(x.explain()) - #else: - #l.append(str(x)) - #return string.join(l," ") - ##(self.__class__.__name__,string.join(l) ) - - def psource(self): - if hasattr(self,'lines'): -# print "# "+string.join(self.lines,"\n# ")+"\n" - print "# "+"\n# ".join(self.lines)+"\n" - - def cstr(self,l=None): - """ - Build a list of tokens; return the joined tokens string - """ - if l is None: - l = [] - for x in self: - if isinstance(x,Node): - x.cstr(l) - else: - l.insert(0,str(x)+' ') - s = ''.join(l) - return s - - def ctype(self): # anon_clone - " return clone of self without identifiers " - #print "%s.ctype()"%self - l=[] - for x in self: - if isinstance(x,Node): - l.append(x.ctype()) - else: - l.append(x) - #print "%s.__class__(*%s)"%(self,l) - return self.__class__(*l, **self.__dict__) # XX **self.__dict__ ? - - def cbasetype(self): - " return ctype with all TypeAlias's replaced " - # WARNING: we cache results (so do not mutate self!!) - l=[] - for x in self: - if isinstance(x,Node): - l.append(x.cbasetype()) - else: - l.append(x) - #print "%s.__class__(*%s)"%(self,l) - return self.__class__(*l, **self.__dict__) # XX **self.__dict__ ? - - def signature( self, tank=None ): - if tank is None: - tank = {} - for node in self.nodes(): - if not tank.has_key( type(node) ): - tank[ type(node) ] = {} - type(node).tank = tank[type(node)] - shape = tuple( [ type(_node).__name__ for _node in node ] ) - if not tank[type(node)].has_key(shape): - tank[type(node)][shape] = [] - tank[type(node)][shape].append( node ) - return tank - - def psig( self, tank=None ): - if tank is None: - tank = {} - tank = self.signature(tank) - for key in tank.keys(): - print key.__name__ - for shape in tank[key].keys(): - print " ", shape - -# -################################################# - -class Named(genpyx.Named, Node): - " has a .name property " - def get_name(self): - if self: - assert type(self[0])==str - return self[0] - return None - def set_name(self, name): - if self: - self[0] = name - else: - self.append(name) - name = property(get_name,set_name) - - -class BasicType(genpyx.BasicType, Named): - "float double void char int" - pass - -class Qualifier(genpyx.Qualifier, Named): - "register signed unsigned short long const volatile inline" - pass - -class StorageClass(genpyx.StorageClass, Named): - "extern static auto" - pass - -class Ellipses(genpyx.Ellipses, Named): - "..." - pass - -class GCCBuiltin(genpyx.GCCBuiltin, BasicType): - "things with __builtin prefix" - pass - -class Identifier(genpyx.Identifier, Named): - """ - shape = +( str, +ConstExpr ) - """ - #def explain(self): - #if len(self)==1: - #return "%s"%self.name - #else: - #return "%s initialized to %s"%(self.name, - #Node(self[1]).explain()) # will handle Initializer - -# def ctype(self): -# return self.__class__(*self[1:]) #.clone() ? - -# def get_name(self): -# if self: -# return self[0] -# def set_name(self, name): -# if self: -# self[0] = name -# else: -# self.append(name) -# name = property(get_name,set_name) - - def cstr(self,l=None): - if l is None: - l=[] - if len(self)>1: - assert len(self)==2 - l.append( '%s = %s'%(self[0],self[1]) ) - elif len(self)==1: - l.append( str(self[0]) ) - return " ".join(l) - -class TypeAlias(genpyx.TypeAlias, Named): - """ - typedefed things, eg. size_t - - """ - def cbasetype( self ): - node = self.typedef.cbasetype().get_rest() - return node - -class Function(genpyx.Function, Node): - """ - """ - #def explain(self): - #if len(self): - #return "function (%s), returning"%\ - #", ".join( map(lambda x:x.explain(),self) ) - #else: - #return "function returning" - - def cstr(self,l): - #print '%s.cstr(%s)'%(self,l) - _l=[] - assert len(self) - i=0 - while isinstance(self[i],Declarator): - _l.append( self[i].cstr() ) - i=i+1 - l.append( '(%s)'% ', '.join(_l) ) - while i1 # more than just a tag - def get_members(self): - return self[1:] - members = property(get_members) # fields ? - - def ctype(self): - if not self.tag.name: - #print "# WARNING : anonymous struct " # OK i think - return self.clone() -# self = self.clone() -# return self[:1] # just the tag - return self.__class__( self.tag, **self.__dict__ ) # just the Tag -# return self.__class__( *self, **self.__dict__ ) - - def cbasetype(self): - return self.ctype() # is this enough ??? -# return Node.cbasetype(self) # XX lookup my tag if i am empty ..? - - -class Compound(genpyx.Compound, Taged): - "Struct or Union" - - def cstr(self,_l=None): - assert isinstance( self[0], Tag ) - tag='' - if len(self[0]): - tag=' '+self[0][0] - if isinstance(self,Struct): - l=[ 'struct%s '%tag ] - elif isinstance(self,Union): - l=[ 'union%s '%tag ] - if len(self)>1: - l.append(' { ') - for decl in self[1:]: - l.append( decl.cstr()+"; " ) - l.append('} ') - if _l is None: - _l=[] - while l: - _l.insert( 0, l.pop() ) - # XX empty struct with no tag -> "struct" XX - return "".join( _l ) - - def ctype(self): - tp = Taged.ctype(self) - for i in range(1,len(tp)): - tp[i] = StructDeclarator().init_from( tp[i] ) - return tp - -class Struct(genpyx.Struct, Compound): - """ - """ - pass - - -class Union(genpyx.Union, Compound): - """ - """ - pass - - -class Enum(genpyx.Enum, Taged): - """ - """ - def cstr(self,_l=None): - assert isinstance( self[0], Tag ) - tag='' - if len(self[0]): - tag=' '+self[0][0] - l=[ 'enum%s '%tag ] - if len(self)>1: - l.append(' { ') - for node in self[1:]: - l.append( node.cstr()+', ' ) - l.append('} ') - if _l is None: - _l=[] - while l: - _l.insert( 0, l.pop() ) - return ''.join( _l ) - -class Declarator(genpyx.Declarator, Node): - """ - """ - - def __eq__(self,other): - " unordered equality " - # ordering sometimes gets lost when we do a cbasetype - if not isinstance(other,Node): - return False - a, b = self[:], other[:] - a.sort() - b.sort() - return a == b - - def __hash__( self ): - hs = [hash(item) for item in self] - hs.sort() - return hash( tuple([hash(type(self))]+hs) ) - - def transform(self): - return - - def get_identifier(self): - if len(self)>1: - return self[0] - def set_identifier(self, identifier): - if len(self)>1: - self[0] = identifier - else: - self.insert(0,identifier) - identifier = property(get_identifier,set_identifier) - - def get_spec(self): - spec = self[-1] - if type(spec)==TypeSpecifiers: # isinstance ?? - return spec - spec = property(get_spec) - - def get_type_alias(self): - if self.spec: - if isinstance(self.spec[0], TypeAlias): - return self.spec[0] - type_alias = property(get_type_alias) - - def get_tagged(self): - if self.spec: - return self.spec.tagged # i am a tagged - tagged = property(get_tagged) - - def get_compound(self): - if self.spec: - return self.spec.compound # i am a compound - compound = property(get_compound) - - def get_struct(self): - if self.spec: - return self.spec.struct # i am a struct - struct = property(get_struct) - - def get_union(self): - if self.spec: - return self.spec.union # i am a union - union = property(get_union) - - def get_enum(self): - if self.spec: - return self.spec.enum # i am an enum - enum = property(get_enum) - - def get_function(self): - if len(self)>1 and type(self[1])==Function: # isinstance ?? - return self[1] - function = property(get_function) - - def get_pointer(self): - if len(self)>1 and type(self[1])==Pointer: # isinstance ?? - return self[1] - pointer = property(get_pointer) - - def get_array(self): - if len(self)>1 and type(self[1])==Array: # isinstance ?? - return self[1] - array = property(get_array) - - def get_name(self): - if self.identifier: - return self.identifier.name - def set_name(self, name): - assert self.identifier is not None - self.identifier.name = name - name = property(get_name, set_name) - - def get_rest(self): # XX needs a better name - if len(self)>1: - return self[1] - return self[0] - - def pointer_to( self ): - " return Declarator pointing to self's type " - decl = Declarator(Identifier(), Pointer(self.get_rest().clone())) - return decl - - def deref( self ): - " return (clone of) Declarator that self is pointing to " - node = self.ctype() # clone - pointer = node.pointer or node.array - assert pointer, "cannot dereference non-pointer" - node[1:2] = pointer - return node - - def is_void(self): - return self.spec and BasicType('void') in self.spec - - def is_pointer_to_fn(self): - return self.pointer and self.deref().function - - def is_pointer_to_char(self): -# return self.ctype() == TransUnit("char *a;").transform()[0].ctype() - node = self.pointer or self.array - if node: - spec = node.spec - if spec and BasicType('char') in spec and not BasicType('unsigned') in spec: - return True - return False - - def is_callback(self): - " i am a pointer to a function whose last arg is void* " - if self.is_pointer_to_fn(): - fn = self.deref().function - if fn.args: - arg = fn.args[-1] - if arg.pointer and arg.deref().is_void(): - return True - - def is_complete( self, tag_lookup ): - if self.tagged and self.tagged.tag.name in tag_lookup and not tag_lookup[self.tagged.tag.name].has_members(): - return False - return True - - def is_primative( self ): - "i am a char,short,int,float,double... " - spec = self.cbasetype().spec - return spec and spec.find(BasicType) - - def is_pyxnative( self ): - # pyrex handles char* too - # but i don't know if we should make this the default - # sometimes we want to send a NULL, so ... XXX - self = self.cbasetype() - if self.is_void(): - return False - if self.is_primative(): - return True - if self.enum: - return True -# pointer = None -# if self.pointer: -# pointer = self.pointer -# elif self.array: -# pointer = self.array -# if pointer and pointer.spec: -# spec = pointer.spec -# if BasicType("char") in spec and not Qualifier("unsigned") in spec: -# # char*, const char* -## print self.deepstr() -# return True - return False - - def cstr(self,l=None): - return Node.cstr(self,l).strip() - - def ctype(self): - decl=Declarator() - decl.init_from( self.clone() ) - decl.identifier = Identifier() - for i in range(1,len(decl)): - decl[i]=decl[i].ctype() - return decl - - def cbasetype(self): - # WARNING: we cache results (so do not mutate self!!) - try: - # this cache improves performance by 50% - return self.__cbasetype.clone() - except AttributeError: - pass - decl = self.ctype() # gets rid of Identifier names - for i, node in enumerate(decl): - decl[i] = decl[i].cbasetype() -# return decl.get_rest() - - done = False - while not done: - done = True - nodes = decl.deepfilter( TypeSpecifiers ) - for node in nodes: - if node.deepfind( TypeSpecifiers ) != node: - # this node has another TypeSpecifier; - decl.expose_node( node ) - done = False - break # start again... - - # each TypeSpecifier needs to absorb primitive siblings (StorageClass, BasicType etc.) - nodes = decl.deepfilter( TypeSpecifiers ) - for node in nodes: - parent = decl.get_parent(node) - i = 0 - while i < len(parent): - assert not type(parent[i]) in (TypeAlias, Enum, Struct, Union) - if type(parent[i]) in (StorageClass, BasicType, Qualifier): - node.append( parent.pop(i) ) - else: - i = i + 1 - - self.__cbasetype = decl.clone() - return decl - - def invalidate(self): - # flush cache, etc. - try: - del self.__cbasetype - except AttributeError: - pass - - def declare_str(self,name): - " return c string declaring name with same type as self " - tp = self.ctype() - tp.name = name - return tp.cstr()+";" - -class Typedef(genpyx.Typedef, Declarator): - def cstr(self,l=None): - return 'typedef ' + Declarator.cstr(self,l) #.strip() - -class AbstractDeclarator(genpyx.AbstractDeclarator, Declarator): - """ used in Function; may lack an identifier """ - - #def cstr(self,l=None): - #return Node.cstr(self,l) - -# def ctype(self): -# # _type_ ignores the name of our identifier -# return Node.ctype(self) - -class FieldLength(genpyx.FieldLength, Node): - """ - """ - #def explain(self): - #return "" - - def cstr(self,l): - l.append(':%s'%self[0]) - -class StructDeclarator(genpyx.StructDeclarator, Declarator): # also used in Union - """ - """ - #def explain(self): - #flen = self.find(FieldLength) - #if flen is not None: - #i = self.index(flen) - #self.pop(i) - #s = Declarator.explain(self) - #self.insert(i,flen) - #width = flen[0] - #if width > 0: - #return s+" bitfield %s wide"%width - #else: - #return s+" alignment bitfield" - #else: - #return Declarator.explain(self) -# def ctype(self): -# return self - def get_field_length(self): - if len(self)>1 and isinstance( self[1], FieldLength ): - return self[1] - field_length = property(get_field_length) - - -class DeclarationSpecifiers(genpyx.DeclarationSpecifiers, Node): -#class TypeSpecifiers(Node): - """ - """ - def __eq__(self,other): - " unordered equality " - if not isinstance(other,Node): - return False - a, b = self[:], other[:] - a.sort() - b.sort() - return a == b - - def __hash__( self ): - hs = [hash(item) for item in self] - hs.sort() - return hash( tuple([hash(type(self))]+hs) ) - -# def is_struct(self): -# return self.find(Struct) is not None - - -class TypeSpecifiers(genpyx.TypeSpecifiers, DeclarationSpecifiers): - """ - """ - def get_tagged(self): - if self and isinstance(self[0],Taged): - return self[0] - tagged = property(get_tagged) - - def get_compound(self): - if self and isinstance(self[0],Compound): - return self[0] - compound = property(get_compound) - - def get_struct(self): - if self and isinstance(self[0],Struct): - return self[0] - struct = property(get_struct) - - def get_union(self): - if self and isinstance(self[0],Union): - return self[0] - union = property(get_union) - - def get_enum(self): - if self and isinstance(self[0],Enum): - return self[0] - enum = property(get_enum) - - def cbasetype(self): - node = Node.cbasetype(self) -# node.expose( TypeSpecifiers ) -# if node.deepfind(TypeSpecifiers) != node: - return node - -class Initializer(genpyx.Initializer, Node): - """ - """ - pass - - - -class Declaration(genpyx.Declaration, Node): - """ - """ - def do_spec(self): - " distribute DeclarationSpecifiers over each Declarator " - spec=self[0] - assert isinstance(spec,DeclarationSpecifiers), spec.deepstr() - self.pop(0) - for declarator in self: - assert isinstance(declarator,Declarator) - #if isinstance(declarator,DeclarationSpecifiers #huh? - ##for node in spec: - ##declarator.append(node.clone()) - declarator.append(spec) - - def transform(self): - # children go first - for node in self.nodes(): - if isinstance(node,Declaration): - node.do_spec() - node.file = self.file # overkill ? - self.expose(Declaration) - - #def explain(self): - #return string.join([x.explain() for x in self],", ") - #return string.join(map(lambda x:x.explain(),self),", ") - - -class ParameterDeclaration(genpyx.ParameterDeclaration, Declaration): - """ - """ - pass - - -class StructDeclaration(genpyx.StructDeclaration, Declaration): - """ - """ - pass - - -class TransUnit(genpyx.TransUnit, Node): - """ - Top level node. - """ - def __init__( self, item ): # XX __init__ uses different signature ! XX - if type(item)==str: - node = cparse.TransUnit() - node.parse(item) - else: - node = item - assert isinstance( node, cparse.TransUnit ), str(node) - Node.__init__(self) - self[:] = [ self.convert(child) for child in node ] - self.__dict__.update( node.__dict__ ) - assert "name" not in node.__dict__ - - self.syms = {} # map identifier names to their Declarator's - self.typedefs = {} # map names to Typedef's - self.tag_lookup = {} # map struct, union, enum tags to Taged's - - # XX should call transform here XX - -# print self.deepstr() - def __getstate__( self ): - nodes = tuple( [ repr(node) for node in self ] ) - typedefs = tuple( [ (key,repr(val)) for key,val in self.typedefs.items() ] ) - return nodes, typedefs - def __setstate__( self, state ): - Node.__init__(self) - nodes, typedefs = state - nodes = [ eval(node) for node in nodes ] - self[:] = nodes - typedefs = [ (key,eval(val)) for key,val in typedefs ] - self.typedefs = dict(typedefs) - - def convert( self, node ): -# name = node.__class__.__name__ -# cls = globals()[ name ] - cls = cls_lookup[ type(node) ] - _node = cls() - for child in node: - if isinstance(child, node_module.Node): - child = self.convert( child ) - else: - assert child is None or type(child) in (str, int), type(child) - _node.append( child ) - _node.__dict__.update( node.__dict__ ) - return _node - - def strip(self,files): - " leave only the declarations from " - i=0 - while i -Released under GNU LGPL license. - -version 0.xx - -""" - -import sys -import string -import types -import copy - -#from cparse import BasicType, Qualifier, StorageClass, Typedef, Ellipses, GCCBuiltin -#from cparse import * - -import cparse as host - -class LexError(Exception): - pass - -class Lexer(object): - def __init__(self,s="",verbose=0,**kw): - self.verbose = verbose - self.lookup = {} # a map for keywords and typedefs - for t in \ - "float double void char int".split(): - self.lookup[t] = host.BasicType( t ) - for t in \ - "register signed unsigned short long const volatile inline".split(): # inline here ??? - self.lookup[t] = host.Qualifier( t ) - for t in "extern static auto".split(): - self.lookup[t] = host.StorageClass( t ) - self.lookup['typedef'] = host.Typedef() - #self.lookup['__inline__'] = host.GCCBuiltin('__inline__') - #self.lookup['__extension__'] = host.Qualifier('__extension__') - self.lookup['...'] = host.Ellipses() - if s: - self.lex(s) - for key in kw.keys(): - self.__dict__[key] = kw[key] - - def lex(self,s): - self.stack = None - self.lines = s.splitlines() - self.set_state("","",0,0) - self.so_file = "" - self._newline() - self.get_token() # start - - def mktypedef(self,tok,node): - if self.verbose: - print "%s.mktypedef(%s,%s)"%(self,tok,node) - self.lookup[ tok ] = node - - def rmtypedef(self,tok): - " used in round trip testing " -# print "# rmtypedef(%s)"%tok - assert isinstance( self.lookup[ tok ], host.Node ) # existance - del self.lookup[ tok ] - - def _get_kind(self,tok): - #print '_get_kind(%s)'%tok,self.lookup - try: - return self.lookup[tok] - #return self.lookup[tok].clone() - except KeyError: - if tok.startswith("__builtin"): - node = host.GCCBuiltin(tok) - self.lookup[tok] = node - return node - #elif tok in ( "__extension__", ): - #node = GCCBuiltin(tok) - #self.lookup[tok] = node - #return node - return None - - def _newline(self): - while self.lno < len(self.lines): - line = self.lines[self.lno] - if not line or line[0] != "#": - break - l = line.split('"') - assert len(l)>=2 - self.so_file = l[1] - #self.so_lno = int( l[0].split()[1] ) - #sys.stderr.write("# %s %s: %s\n"%(so_lno,so_file,l)) - self.lno+=1 - - def get_brace_token( self ): - self.push_state() - ident_chars0 = string.letters+"_" - ident_chars1 = string.letters+string.digits+"_" - tok, kind = "", "" - while self.lno < len(self.lines): - s = self.lines[self.lno] - i=self.col - while i < len(s): - if s[i] not in '{}': - i=i+1 - continue - else: - tok = s[i] - kind = tok - self.col = i+1 - break - # keep moving - #sys.stderr.write( "lexer ignoring '%s'\n"%s[i] ) - i=i+1 - if i==len(s): - # nothing found - assert tok == "" - self.col=0 - self.lno+=1 - self._newline() - else: - assert tok - break - self.set_state(tok,kind,self.lno,self.col) - - def get_token(self): - self.push_state() - ident_chars0 = string.letters+"_" - ident_chars1 = string.letters+string.digits+"_" - tok, kind = "", "" - while self.lno < len(self.lines): - s = self.lines[self.lno] - i=self.col - while i < len(s): - if s[i].isspace(): - i=i+1 - continue - #if s[i] in ident_chars0: - if s[i].isalpha() or s[i]=='_': - # identifier - j=i+1 - while j|&': - tok = s[i] - kind = tok - self.col = i+1 - break - if s[i] == "'": - j = i+2 - while j -Released under GNU LGPL license. - -version 0.xx - -""" - -import string - - -class Node(list): - " A node in a parse tree " - - def __init__(self,*items,**kw): - list.__init__( self, items ) - self.lock1 = 0 # these two should be properties (simplifies serializing) - self.lock2 = 0 - self.verbose = 0 - for key in kw.keys(): - self.__dict__[key] = kw[key] - - def __str__(self): - attrs = [] - for item in self: - if isinstance(item,Node): - attrs.append( str(item) ) - else: - attrs.append( repr(item) ) - attrs = ','.join(attrs) - return "%s(%s)"%(self.__class__.__name__,attrs) - - def safe_repr( self, tank ): - tank[ str(self) ] = None - attrs = [] - for item in self: - if isinstance(item,Node): - attrs.append( item.safe_repr(tank) ) # can we use repr here ? - else: - attrs.append( repr(item) ) - # this is the dangerous bit: - for key, val in self.__dict__.items(): - if isinstance(val,Node): - if str(val) not in tank: - attrs.append( '%s=%s'%(key,val.safe_repr(tank)) ) - else: - attrs.append( '%s=%s'%(key,repr(val)) ) - attrs = ','.join(attrs) - return "%s(%s)"%(self.__class__.__name__,attrs) - - def __repr__(self): - #attrs = ','.join( [repr(item) for item in self] + \ - # [ '%s=%s'%(key,repr(val)) for key,val in self.__dict__.items() ] ) - #return "%s%s"%(self.__class__.__name__,tuple(attrs)) - return self.safe_repr({}) - - def __eq__(self,other): - if not isinstance(other,Node): - return 0 - if len(self)!=len(other): - return 0 - for i in range(len(self)): - if not self[i]==other[i]: - return 0 - return 1 - - def __ne__(self,other): - return not self==other - - def filter(self,cls): - return [x for x in self if isinstance(x,cls)] - #return filter( lambda x:isinstance(x,cls), self ) - - def deepfilter(self,cls): - " bottom-up " - return [x for x in self.nodes() if isinstance(x,cls)] - - def find(self,cls): - for x in self: - if isinstance(x,cls): - return x - return None - - def deepfind(self,cls): - " bottom-up isinstance search " - for x in self: - if isinstance(x,Node): - if isinstance(x,cls): - return x - node = x.deepfind(cls) - if node is not None: - return node - if isinstance(self,cls): - return self - return None - - def leaves(self): - for i in self: - if isinstance( i, Node ): - for j in i.leaves(): - yield j - else: - yield i - - def nodes(self): - " bottom-up iteration " - for i in self: - if isinstance( i, Node ): - for j in i.nodes(): - yield j - yield self - - def deeplen(self): - i=0 - if not self.lock2: - self.lock2=1 - for item in self: - i+=1 - if isinstance(item,Node): - i+=item.deeplen() - self.lock2=0 - else: - i+=1 - return i - - def deepstr(self,level=0,comment=False,nl='\n',indent=' '): - if self.deeplen() < 4: - nl = ""; indent = "" - #else: - #nl="\n"; indent = " " - s = [] - if not self.lock1: - self.lock1=1 - for item in self: - if isinstance(item,Node): - s.append( indent*(level+1)+item.deepstr(level+1,False,nl,indent) ) - else: - s.append( indent*(level+1)+repr(item) ) - self.lock1=0 - else: - for item in self: - if isinstance(item,Node): - s.append( indent*(level+1)+"" ) - else: - s.append( indent*(level+1)+"%s"%repr(item) ) - s = "%s(%s)"%(self.__class__.__name__,nl+string.join(s,","+nl)) - if comment: - s = '#' + s.replace('\n','\n#') - return s - - def clone(self): - items = [] - for item in self: - if isinstance(item,Node): - item = item.clone() - items.append(item) - # we skip any attributes... - return self.__class__(*items) - - def fastclone(self): - # XX is it faster ??? - #print "clone" - nodes = [self] - idxs = [0] - itemss = [ [] ] - while nodes: - assert len(nodes)==len(idxs)==len(itemss) - node = nodes[-1] - items = itemss[-1] - assert idxs[-1] == len(items) - while idxs[-1]==len(node): - # pop - _node = node.__class__( *items ) - _node.__dict__.update( node.__dict__ ) - nodes.pop(-1) - idxs.pop(-1) - itemss.pop(-1) - if not nodes: - #for node0 in self.nodes(): - #for node1 in _node.nodes(): - #assert node0 is not node1 - #assert _node == self - return _node # Done !! - node = nodes[-1] - items = itemss[-1] - items.append(_node) # set - idxs[-1] += 1 - assert idxs[-1] == len(items) - #assert idxs[-1] < len(node), str( (node,nodes,idxs,itemss) ) - - _node = node[ idxs[-1] ] - # while idxs[-1] instance ' - # children first - for x in self: - if isinstance(x,Node): - x.expose(cls) - # now the tricky bit - i=0 - while i < len(self): - if isinstance(self[i],cls): - node=self.pop(i) - for x in node: - assert not isinstance(x,cls) - # pass on some attributes - if hasattr(node,'lines') and not hasattr(x,'lines'): - x.lines=node.lines - if hasattr(node,'file') and not hasattr(x,'file'): - x.file=node.file - self.insert(i,x) # expose - i=i+1 - assert i<=len(self) - else: - i=i+1 - - def get_parent( self, item ): # XX 25% CPU time here XX - assert self != item - if item in self: - return self - for child in self: - if isinstance(child, Node): - parent = child.get_parent(item) - if parent is not None: - return parent - return None - - def expose_node( self, item ): - assert self != item - parent = self.get_parent(item) - idx = parent.index( item ) - parent[idx:idx+1] = item[:] - - def delete(self,cls): - ' delete any subtree ' - for x in self: - if isinstance(x,Node): - x.delete(cls) - # now the tricky bit - i=0 - while i < len(self): - if isinstance(self[i],cls): - self.pop(i) - else: - i=i+1 - - def deeprm(self,item): - ' remove any items matching ' - for x in self: - if isinstance(x,Node): - x.deeprm(item) - # now the tricky bit - i=0 - while i < len(self): - if self[i] == item: - self.pop(i) - else: - i=i+1 - - def idem(self,cls): - " is made idempotent " - # children first - for x in self: - if isinstance(x,Node): - x.idem(cls) - if isinstance(self,cls): - # now the tricky bit - i=0 - while i < len(self): - if isinstance(self[i],cls): - node = self.pop(i) - for x in node: - assert not isinstance(x,cls) - self.insert(i,x) # idempotent - i=i+1 - assert i<=len(self) - else: - i=i+1 - -if __name__=="__main__": - node = Node( 'a', Node(1,2), Node(Node(Node(),1)) ) - - print node - print node.clone() - - - - diff --git a/tools/python-yasm/pyxelator/parse_core.py b/tools/python-yasm/pyxelator/parse_core.py deleted file mode 100755 index 84fb8941..00000000 --- a/tools/python-yasm/pyxelator/parse_core.py +++ /dev/null @@ -1,106 +0,0 @@ -#!/usr/bin/env python -""" cdecl.py - parse c declarations - -(c) 2002, 2003, 2004, 2005 Simon Burton -Released under GNU LGPL license. - -version 0.xx - -""" - -import sys - - -class Symbols(object): - def __init__(self,parent=None,verbose=False): - self.verbose = verbose - self.parent=parent # are we a nested namespace? - self.lookup = {} # identifiers - self.tags = {} # struct, union, enum tags - - def __str__(self): - return "Symbols(%s,%s)"%(self.lookup,self.tags) - - def __getitem__(self,key): - try: - item = self.lookup[key] - except KeyError: - item = None - #if self.parent is not None: - #item = self.parent[item] - ## self[key] = item # cache - #if self.verbose: print "%s.get('%s')='%s'"%(self,key,item) - return item - - def __setitem__(self,key,val): - #if self.verbose: print "%s.set('%s','%s')"%(self,key,val) - assert val is not None - self.lookup[key] = val - - def set_tag(self,key,val): - #if self.verbose: print "%s.set_tag(%s,%s)"%(self,key,val) - assert len(key) - self.tags[key] = val - - def deep_get_tag(self,key): - try: - item = self.tags[key] - except KeyError: - item = None - if self.parent is not None: - item = self.parent.deep_get_tag(key) - #if self.verbose: print "%s.get_tag(%s)=%s"%(self,key,item) - return item - - def get_tag(self,key): - try: - item = self.tags[key] - except KeyError: - item = None - #if self.verbose: print "%s.get_tag(%s)=%s"%(self,key,item) - return item - -################################################################### -# -################################################################### -# - - -class ParseError(Exception): - def __init__(self,*e): - self.e = e - - def __str__(self): - return "".join(map(str,self.e)) - - -class Parser(object): - def parse_error(self,lexer,reason="?",*blah): - sys.stderr.write( "%s.parse_error()\n"%self.deepstr() ) - sys.stderr.write( "at line %s: %s\n"%(lexer.lno+1,reason) ) - sys.stderr.write( lexer.err_string() ) - raise ParseError(reason,*blah) - - def expected_error(self,lexer,*l): - self.parse_error( lexer, "expected %s, got '%s'"\ - %(" or ".join(map(repr,l)),lexer.tok)) - - def consume(self,lexer,tok): - if lexer.tok != tok: - self.expected_error(lexer, tok) - lexer.get_token() - - def parse_enter(self,lexer): - #return - self.start_lno=lexer.lno - self.file=lexer.so_file - - def parse_leave(self,lexer): - #return - self.lines = lexer.lines[self.start_lno:max(lexer.lno,self.start_lno+1)] - -################################################################### -# -################################################################### -# - diff --git a/tools/python-yasm/pyxelator/work_unit.py b/tools/python-yasm/pyxelator/work_unit.py deleted file mode 100755 index 31ab3e56..00000000 --- a/tools/python-yasm/pyxelator/work_unit.py +++ /dev/null @@ -1,192 +0,0 @@ -#!/usr/bin/env python - -""" - -(c) 2002, 2003, 2004, 2005 Simon Burton -Released under GNU LGPL license. - -version 0.xx - -""" - - -import sys -import os - -import cparse -import ir - -def callcmd(cmd): - try: - from subprocess import call - try: - retcode = call(cmd, shell=True) - assert retcode == 0, "command failed: %s"%cmd - except OSError, e: - assert False, "command failed: %s"%e - except ImportError: - status = os.system( cmd ) - assert status == 0, "command failed: %s"%cmd - -class WorkUnit(object): - def __init__(self, files, modname, filename, - std=False, strip=False, mark_cb=None, - extradefs="", use_header=None, CC="gcc", CPP="gcc -E", - CPPFLAGS=""): - self.files = tuple(files) - self.modname = modname - self.filename = filename - self.CPPFLAGS = CPPFLAGS - self.CPP = CPP - if CC == 'g++': - self.CPPFLAGS += " -D__cplusplus" - self.std = std - self.strip = strip - self.mark_cb = mark_cb - self.node = None - self.extradefs = extradefs - self.CC = CC - self.use_header = use_header - - def mkheader( self ): - if self.use_header: - return self.use_header - tmpname = str(abs(hash( (self.files,self.CPPFLAGS) ))) - name = '.tmp/%s' % tmpname - ifile = open( name+'.h', "w" ) - ifile.write( """ -#define __attribute__(...) -#define __const const -#define __restrict -#define __extension__ -#define __asm__(...) -#define __asm(...) -#define __inline__ -#define __inline -""" ) - for filename in self.files: - if self.std: - line = '#include <%s>\n'%filename - else: - line = '#include "%s"\n'%filename - ifile.write( line ) - print line, - ifile.close() - cmd = '%s %s %s > %s'%(self.CPP,name+'.h',self.CPPFLAGS,name+'.E') - sys.stderr.write( "# %s\n" % cmd ) - callcmd( cmd ) - assert open(name+'.E').read().count('\n') > 10, "failed to run preprocessor" - cmd = '%s -dM %s %s > %s'%(self.CPP,name+'.h',self.CPPFLAGS,name+'.dM') - sys.stderr.write( "# %s\n" % cmd ) - callcmd( cmd ) - assert open(name+'.dM').read().count('\n') > 10, "failed to run preprocessor with -dM" - return name - - def parse(self, verbose=False): - sys.stderr.write( "# parse %s\n" % str(self.files) ) - name = self.mkheader() - # read macros - f = open(name+'.dM') - macros = {} - for line in f.readlines(): - if line: - macro = line.split()[1] - if macro.count('('): - macro = macro[:macro.index('(')] - macros[macro] = None - #keys = macros.keys() - #keys.sort() - #for key in keys: - #print key - self.macros = macros - # parse preprocessed code - f = open(name+'.E') - s = f.read() + self.extradefs - self.node = cparse.TransUnit(verbose = verbose) - sys.stderr.write( "# parsing %s lines\n" % s.count('\n') ) - self.node.parse( s ) - if self.strip: - self.node.strip(self.files) - - def transform(self, verbose=False, test_parse=False, test_types=False): - sys.stderr.write( "# processing...\n" ) - self.node = ir.TransUnit( self.node ) - self.node.transform(verbose, test_parse, test_types) - #self.node[0].psource() - if self.mark_cb is not None: - self.node.mark(self.mark_cb,verbose=False) - - def output( self, func_cb = None ): - sys.stderr.write( "# pyxstr...\n" ) - decls = self.node.pyx_decls(self.files, self.modname, macros = self.macros, func_cb = func_cb, names={}, cprefix="" ) - - name = self.filename - assert name.endswith(".pyx") - - pxi = name[:-3]+'pxi' - file = open( pxi, "w" ) - file.write(decls) - sys.stderr.write( "# wrote %s, %d lines\n" % (pxi,decls.count('\n')) ) - - def pprint(self): - for decl in self.node: - #decl.psource() - #cstr = decl.cstr() - #cstr = cstr.replace( '\n', '\n# ' ) - print - #print '#', cstr - print decl.deepstr() - -def file_exists(path): - try: - os.stat(path) - return True - except OSError: - return False - -if sys.platform.count('darwin'): - shared_ext = '.dylib' -else: - shared_ext = '.so' - -def get_syms(libs, libdirs): - # XX write interface to objdump -t XX - libnames = [] - for lib in libs: - for ext in shared_ext,'.a': - libname = 'lib'+lib+ext - for libdir in libdirs: - path = libdir+'/'+libname - if file_exists(path): - libnames.append(path) - break - #else: - #print "cannot find %s lib as %s in %s" % ( lib, libname, libdir ) - print 'libnames:', libnames - syms = {} - accept = [ ' %s '%c for c in 'TVWBCDGRS' ] - #f = open('syms.out','w') - for libname in libnames: - try: - from subprocess import Popen, PIPE - p = Popen(['nm', libname], bufsize=1, stdout=PIPE) - fout = p.stdout - except ImportError: - fin, fout = os.popen2( 'nm %s' % libname ) - for line in fout.readlines(): - for acc in accept: - if line.count(acc): - left, right = line.split(acc) - sym = right.strip() - if sys.platform.count('darwin'): - if sym[0] == '_': - sym = sym[1:] # remove underscore prefix - if sym.endswith('.eh'): - sym = sym[:-len('.eh')] - syms[sym] = None - #f.write( '%s: %s %s\n' % (sym,line[:-1],libname) ) - break - return syms - - - diff --git a/tools/python-yasm/pyxelator/wrap_yasm.py b/tools/python-yasm/pyxelator/wrap_yasm.py deleted file mode 100755 index 58553ab2..00000000 --- a/tools/python-yasm/pyxelator/wrap_yasm.py +++ /dev/null @@ -1,57 +0,0 @@ -#!/usr/bin/env python - -""" - -(c) 2002, 2003, 2004, 2005 Simon Burton -Released under GNU LGPL license. - -version 0.xx - -""" - - -import sys -import os - -from work_unit import WorkUnit, get_syms -import ir - - -def mk_tao(CPPFLAGS = "", CPP = "gcc -E", modname = '_yasm', oname = None, YASM_DIR = ".", **options): - if oname is None: - oname = modname+'.pyx' - CPPFLAGS += " -I"+YASM_DIR - CPPFLAGS += " -DYASM_PYXELATOR" - CPPFLAGS += " -DYASM_LIB_INTERNAL" - CPPFLAGS += " -DYASM_BC_INTERNAL" - CPPFLAGS += " -DYASM_EXPR_INTERNAL" - files = [ 'libyasm.h', 'libyasm/assocdat.h', 'libyasm/bitvect.h' ] - - syms = get_syms( ['yasm'], [YASM_DIR] ) - def cb(trans_unit, node, *args): - name, file = node.name, node.file - return True - return name in syms - extradefs = "" - unit = WorkUnit(files,modname,oname,False,mark_cb=cb,extradefs=extradefs, - CPPFLAGS=CPPFLAGS, CPP=CPP, **options) - - - unit.parse( False ) - unit.transform(verbose=False, test_parse=False, test_types=False) - unit.output() - -def main(): - options = {} - for i,arg in enumerate(sys.argv[1:]): - if arg.count('='): - key,val = arg.split('=', 1) - options[key]=val - mk_tao(**options) - -if __name__=="__main__": - main() - - - - diff --git a/tools/python-yasm/setup.py b/tools/python-yasm/setup.py deleted file mode 100644 index d4ce2f44..00000000 --- a/tools/python-yasm/setup.py +++ /dev/null @@ -1,88 +0,0 @@ -#! /usr/bin/env python -# Build Python extension with configuration file input -# -# Copyright (C) 2006 Peter Johnson -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND OTHER CONTRIBUTORS ``AS IS'' -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR OTHER CONTRIBUTORS BE -# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. - -from distutils.core import setup -from distutils.extension import Extension -from Cython.Distutils import build_ext -from os.path import basename, join, exists - -def ReadSetup(filename): - """ReadSetup goes through filename and parses out the values stored - in the file. Values need to be stored in a - \"key=value format\"""" - return dict(line.split('=', 1) for line in open(filename)) - -def ParseCPPFlags(flags): - """parse the CPPFlags macro""" - incl_dir = [x[2:] for x in flags.split() if x.startswith("-I")] - cppflags = [x for x in flags.split() if not x.startswith("-I")] - cppflags.append("-DYASM_LIB_INTERNAL") - cppflags.append("-DYASM_BC_INTERNAL") - cppflags.append("-DYASM_EXPR_INTERNAL") - return (incl_dir, cppflags) - -def ParseSources(src, srcdir): - """parse the Sources macro""" - # do the dance of detecting if the source file is in the current - # directory, and if it's not, prepend srcdir - sources = [] - for tok in src.split(): - if tok.endswith(".c"): - fn = tok - else: - continue - if not exists(fn): - fn = join(srcdir, fn) - sources.append(fn) - - return sources - -def RunSetup(incldir, cppflags, sources): - setup( - name='yasm', - version='0.0', - description='Python bindings for Yasm', - author='Michael Urman, Peter Johnson', - url='http://www.tortall.net/projects/yasm', - ext_modules=[ - Extension('yasm', - sources=sources, - extra_compile_args=cppflags, - include_dirs=incldir, - ), - ], - cmdclass = dict(build_ext=build_ext), - ) - -if __name__ == "__main__": - opts = ReadSetup("python-setup.txt") - incldir, cppflags = ParseCPPFlags(opts["includes"]) - sources = ParseSources(opts["sources"], opts["srcdir"].strip()) - sources.append('yasm_python.c') - if opts["gcc"].strip() == "yes": - cppflags.append('-w') - RunSetup(incldir, cppflags, sources) - diff --git a/tools/python-yasm/symrec.pxi b/tools/python-yasm/symrec.pxi deleted file mode 100644 index eb56ccf0..00000000 --- a/tools/python-yasm/symrec.pxi +++ /dev/null @@ -1,285 +0,0 @@ -# Python bindings for Yasm: Pyrex input file for symrec.h -# -# Copyright (C) 2006 Michael Urman, Peter Johnson -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND OTHER CONTRIBUTORS ``AS IS'' -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR OTHER CONTRIBUTORS BE -# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. - -cdef class Symbol: - cdef yasm_symrec *sym - - def __cinit__(self, symrec): - self.sym = NULL - if PyCObject_Check(symrec): - self.sym = __get_voidp(symrec, Symbol) - else: - raise NotImplementedError - - # no deref or destroy necessary - - property name: - def __get__(self): return yasm_symrec_get_name(self.sym) - - property status: - def __get__(self): - cdef yasm_sym_status status - s = set() - status = yasm_symrec_get_status(self.sym) - if status & YASM_SYM_USED: s.add('used') - if status & YASM_SYM_DEFINED: s.add('defined') - if status & YASM_SYM_VALUED: s.add('valued') - return s - - property in_table: - def __get__(self): - return bool(yasm_symrec_get_status(self.sym) & - YASM_SYM_NOTINTABLE) - - property visibility: - def __get__(self): - cdef yasm_sym_vis vis - s = set() - vis = yasm_symrec_get_visibility(self.sym) - if vis & YASM_SYM_GLOBAL: s.add('global') - if vis & YASM_SYM_COMMON: s.add('common') - if vis & YASM_SYM_EXTERN: s.add('extern') - if vis & YASM_SYM_DLOCAL: s.add('dlocal') - return s - - property equ: - def __get__(self): - cdef yasm_expr *e - e = yasm_symrec_get_equ(self.sym) - if not e: - raise AttributeError("not an EQU") - return __make_expression(yasm_expr_copy(e)) - - property label: - def __get__(self): - cdef yasm_symrec_get_label_bytecodep bc - if yasm_symrec_get_label(self.sym, &bc): - return None #Bytecode(bc) - else: - raise AttributeError("not a label or not defined") - - property is_special: - def __get__(self): return bool(yasm_symrec_is_special(self.sym)) - - property is_curpos: - def __get__(self): return bool(yasm_symrec_is_curpos(self.sym)) - - def get_data(self): pass # TODO - #return (yasm_symrec_get_data(self.sym, PyYasmAssocData)) - - def set_data(self, data): pass # TODO - #yasm_symrec_set_data(self.sym, PyYasmAssocData, data) - -# -# Use associated data mechanism to keep Symbol reference paired with symrec. -# - -cdef void __python_symrec_cb_destroy(void *data): - Py_DECREF(data) -cdef void __python_symrec_cb_print(void *data, FILE *f, int indent_level): - pass -__python_symrec_cb = __assoc_data_callback( - PyCObject_FromVoidPtr(&__python_symrec_cb_destroy, NULL), - PyCObject_FromVoidPtr(&__python_symrec_cb_print, NULL)) - -cdef object __make_symbol(yasm_symrec *symrec): - cdef void *data - __error_check() - data = yasm_symrec_get_data(symrec, - (<__assoc_data_callback>__python_symrec_cb).cb) - if data != NULL: - return data - symbol = Symbol(__pass_voidp(symrec, Symbol)) - yasm_symrec_add_data(symrec, - (<__assoc_data_callback>__python_symrec_cb).cb, - symbol) - Py_INCREF(symbol) # We're keeping a reference on the C side! - return symbol - -cdef class Bytecode -cdef class SymbolTable - -cdef class SymbolTableKeyIterator: - cdef yasm_symtab_iter *iter - - def __cinit__(self, symtab): - if not isinstance(symtab, SymbolTable): - raise TypeError - self.iter = yasm_symtab_first((symtab).symtab) - - def __iter__(self): - return self - - def __next__(self): - if self.iter == NULL: - raise StopIteration - rv = yasm_symrec_get_name(yasm_symtab_iter_value(self.iter)) - self.iter = yasm_symtab_next(self.iter) - return rv - -cdef class SymbolTableValueIterator: - cdef yasm_symtab_iter *iter - - def __cinit__(self, symtab): - if not isinstance(symtab, SymbolTable): - raise TypeError - self.iter = yasm_symtab_first((symtab).symtab) - - def __iter__(self): - return self - - def __next__(self): - if self.iter == NULL: - raise StopIteration - rv = __make_symbol(yasm_symtab_iter_value(self.iter)) - self.iter = yasm_symtab_next(self.iter) - return rv - -cdef class SymbolTableItemIterator: - cdef yasm_symtab_iter *iter - - def __cinit__(self, symtab): - if not isinstance(symtab, SymbolTable): - raise TypeError - self.iter = yasm_symtab_first((symtab).symtab) - - def __iter__(self): - return self - - def __next__(self): - cdef yasm_symrec *sym - if self.iter == NULL: - raise StopIteration - sym = yasm_symtab_iter_value(self.iter) - rv = (yasm_symrec_get_name(sym), __make_symbol(sym)) - self.iter = yasm_symtab_next(self.iter) - return rv - -cdef int __parse_vis(vis) except -1: - if not vis or vis == 'local': return YASM_SYM_LOCAL - if vis == 'global': return YASM_SYM_GLOBAL - if vis == 'common': return YASM_SYM_COMMON - if vis == 'extern': return YASM_SYM_EXTERN - if vis == 'dlocal': return YASM_SYM_DLOCAL - msg = "bad visibility value %r" % vis - PyErr_SetString(ValueError, msg) - return -1 - -cdef class SymbolTable: - cdef yasm_symtab *symtab - - def __cinit__(self): - self.symtab = yasm_symtab_create() - - def __dealloc__(self): - if self.symtab != NULL: yasm_symtab_destroy(self.symtab) - - def use(self, name, line): - return __make_symbol(yasm_symtab_use(self.symtab, name, line)) - - def define_equ(self, name, expr, line): - if not isinstance(expr, Expression): - raise TypeError - return __make_symbol(yasm_symtab_define_equ(self.symtab, name, - yasm_expr_copy((expr).expr), line)) - - def define_label(self, name, precbc, in_table, line): - if not isinstance(precbc, Bytecode): - raise TypeError - return __make_symbol(yasm_symtab_define_label(self.symtab, name, - (precbc).bc, in_table, line)) - - def define_special(self, name, vis): - return __make_symbol( - yasm_symtab_define_special(self.symtab, name, - __parse_vis(vis))) - - def declare(self, name, vis, line): - return __make_symbol( - yasm_symtab_declare(self.symtab, name, - __parse_vis(vis), line)) - - # - # Methods to make SymbolTable behave like a dictionary of Symbols. - # - - def __getitem__(self, key): - cdef yasm_symrec *symrec - symrec = yasm_symtab_get(self.symtab, key) - if symrec == NULL: - raise KeyError - return __make_symbol(symrec) - - def __contains__(self, key): - cdef yasm_symrec *symrec - symrec = yasm_symtab_get(self.symtab, key) - return symrec != NULL - - def keys(self): - cdef yasm_symtab_iter *iter - l = [] - iter = yasm_symtab_first(self.symtab) - while iter != NULL: - l.append(yasm_symrec_get_name(yasm_symtab_iter_value(iter))) - iter = yasm_symtab_next(iter) - return l - - def values(self): - cdef yasm_symtab_iter *iter - l = [] - iter = yasm_symtab_first(self.symtab) - while iter != NULL: - l.append(__make_symbol(yasm_symtab_iter_value(iter))) - iter = yasm_symtab_next(iter) - return l - - def items(self): - cdef yasm_symtab_iter *iter - cdef yasm_symrec *sym - l = [] - iter = yasm_symtab_first(self.symtab) - while iter != NULL: - sym = yasm_symtab_iter_value(iter) - l.append((yasm_symrec_get_name(sym), __make_symbol(sym))) - iter = yasm_symtab_next(iter) - return l - - def has_key(self, key): - cdef yasm_symrec *symrec - symrec = yasm_symtab_get(self.symtab, key) - return symrec != NULL - - def get(self, key, x): - cdef yasm_symrec *symrec - symrec = yasm_symtab_get(self.symtab, key) - if symrec == NULL: - return x - return __make_symbol(symrec) - - def iterkeys(self): return SymbolTableKeyIterator(self) - def itervalues(self): return SymbolTableValueIterator(self) - def iteritems(self): return SymbolTableItemIterator(self) - def __iter__(self): return SymbolTableKeyIterator(self) - diff --git a/tools/python-yasm/tests/Makefile.inc b/tools/python-yasm/tests/Makefile.inc deleted file mode 100644 index c6df22c5..00000000 --- a/tools/python-yasm/tests/Makefile.inc +++ /dev/null @@ -1,13 +0,0 @@ -EXTRA_DIST += tools/python-yasm/tests/python_test.sh -EXTRA_DIST += tools/python-yasm/tests/__init__.py -EXTRA_DIST += tools/python-yasm/tests/test_bytecode.py -EXTRA_DIST += tools/python-yasm/tests/test_expr.py -EXTRA_DIST += tools/python-yasm/tests/test_intnum.py -EXTRA_DIST += tools/python-yasm/tests/test_symrec.py - -if HAVE_PYTHON_BINDINGS - -TESTS_ENVIRONMENT += PYTHON=${PYTHON} -TESTS += tools/python-yasm/tests/python_test.sh - -endif diff --git a/tools/python-yasm/tests/__init__.py b/tools/python-yasm/tests/__init__.py deleted file mode 100644 index f5afb30c..00000000 --- a/tools/python-yasm/tests/__init__.py +++ /dev/null @@ -1,69 +0,0 @@ -# Test wrapper from Quod Libet -# http://www.sacredchao.net/quodlibet/ -import unittest, sys -suites = [] -add = registerCase = suites.append -from unittest import TestCase - -class Mock(object): - # A generic mocking object. - def __init__(self, **kwargs): self.__dict__.update(kwargs) - -import test_intnum -import test_symrec -import test_bytecode -import test_expr - -class Result(unittest.TestResult): - - separator1 = '=' * 70 - separator2 = '-' * 70 - - def addSuccess(self, test): - unittest.TestResult.addSuccess(self, test) - sys.stdout.write('.') - - def addError(self, test, err): - unittest.TestResult.addError(self, test, err) - sys.stdout.write('E') - - def addFailure(self, test, err): - unittest.TestResult.addFailure(self, test, err) - sys.stdout.write('F') - - def printErrors(self): - succ = self.testsRun - (len(self.errors) + len(self.failures)) - v = "%3d" % succ - count = 50 - self.testsRun - sys.stdout.write((" " * count) + v + "\n") - self.printErrorList('ERROR', self.errors) - self.printErrorList('FAIL', self.failures) - - def printErrorList(self, flavour, errors): - for test, err in errors: - sys.stdout.write(self.separator1 + "\n") - sys.stdout.write("%s: %s\n" % (flavour, str(test))) - sys.stdout.write(self.separator2 + "\n") - sys.stdout.write("%s\n" % err) - -class Runner: - def run(self, test): - suite = unittest.makeSuite(test) - pref = '%s (%d): ' % (test.__name__, len(suite._tests)) - print pref + " " * (25 - len(pref)), - result = Result() - suite(result) - result.printErrors() - return bool(result.failures + result.errors) - -def unit(run = []): - runner = Runner() - failures = False - for test in suites: - if not run or test.__name__ in run: - failures |= runner.run(test) - return failures - -if __name__ == "__main__": - raise SystemExit(unit(sys.argv[1:])) - diff --git a/tools/python-yasm/tests/python_test.sh b/tools/python-yasm/tests/python_test.sh deleted file mode 100755 index 18e7a69e..00000000 --- a/tools/python-yasm/tests/python_test.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh -# Based on _sanity.sh from Quod Libet -# http://www.sacredchao.net/quodlibet/ - -set -e - -test -n "${srcdir}" || srcdir=. -test -n "${PYTHON}" || PYTHON=python - -if test "$1" = "--help" -o "$1" = "-h"; then - echo "Usage: $0 --sanity | [TestName] ..." - exit 0 -elif [ "$1" = "--sanity" ]; then - echo "Running static sanity checks." - grep "except None:" ${srcdir}/tools/python-yasm/tests/*.py -else - ${PYTHON} -c "import sys; import glob; sys.path.insert(0, '${srcdir}/tools/python-yasm'); sys.path.insert(0, glob.glob('build/lib.*')[0]); import tests; raise SystemExit(tests.unit('$*'.split()))" -fi - diff --git a/tools/python-yasm/tests/test_bytecode.py b/tools/python-yasm/tests/test_bytecode.py deleted file mode 100644 index eb0e96db..00000000 --- a/tools/python-yasm/tests/test_bytecode.py +++ /dev/null @@ -1,3 +0,0 @@ -from tests import TestCase, add -from yasm import Bytecode, Expression - diff --git a/tools/python-yasm/tests/test_expr.py b/tools/python-yasm/tests/test_expr.py deleted file mode 100644 index 97b021c3..00000000 --- a/tools/python-yasm/tests/test_expr.py +++ /dev/null @@ -1,18 +0,0 @@ -from tests import TestCase, add -from yasm import Expression -import operator - -class TExpression(TestCase): - def test_create(self): - e1 = Expression(operator.add, 1, 2) - e2 = Expression('+', 1, 2) - - self.assertEquals(e1.get_intnum(), e1.get_intnum()) - - def test_extract(self): - e1 = Expression('/', 15, 5) - self.assertEquals(e1.get_intnum(), 3) - self.assertRaises(ValueError, e1.extract_segoff) - self.assertRaises(ValueError, e1.extract_wrt) - -add(TExpression) diff --git a/tools/python-yasm/tests/test_intnum.py b/tools/python-yasm/tests/test_intnum.py deleted file mode 100644 index a2220180..00000000 --- a/tools/python-yasm/tests/test_intnum.py +++ /dev/null @@ -1,77 +0,0 @@ -from tests import TestCase, add -from yasm import IntNum - -class TIntNum(TestCase): - legal_values = [ - 0, 1, -1, 2, -2, 17, -17, - 2**31-1, -2**31, 2**31, 2**32-1, -2**32, - 2**63-1, -2**63-1, 2**63, 2**64, -2**64, - 2**127-1, -2**127 - ] - overflow_values = [ - 2**127, -2**127-1 - ] - - def test_to_from(self): - for i in self.legal_values: - self.assertEquals(i, int(IntNum(i))) - self.assertEquals(i, long(IntNum(i))) - - def test_overflow(self): - for i in self.overflow_values: - self.assertRaises(OverflowError, IntNum, i) - - str_values = [ - "0", "00000", "1234", "87654321", "010101010", "FADCBEEF" - ] - base_values = [2, 8, 10, 12, 16, None, "nasm", "foo"] - - def test_from_str(self): - pass - - def test_from_str_base(self): - pass - - def test_exceptions(self): - self.assertRaises(ZeroDivisionError, IntNum(1).__div__, 0) - - IntNum(1) / 1 # make sure the above error is cleared - - try: IntNum(1) / 0 - except ZeroDivisionError, err: - self.assertEquals('divide by zero', str(err)) - - def test_xor(self): - a = IntNum(-234) - b = IntNum(432) - c = a ^ b - self.assertEquals(a, -234) - self.assertEquals(b, 432) - self.assertEquals(c, -234 ^ 432) - - def test_ixor(self): - a = IntNum(-234) - b = IntNum(432) - a ^= b; b ^= a; a ^= b - self.assertEquals(a, 432) - self.assertEquals(b, -234) - - def test_cmp(self): - a = IntNum(-1) - b = IntNum(0) - c = IntNum(1) - self.assert_(a < b < c) - self.assert_(a <= b <= c) - self.assert_(c >= b >= a) - self.assert_(c > b > a) - self.assert_(a != b != c) - - def test_abs(self): - a = IntNum(-1) - b = IntNum(0) - c = IntNum(1) - - self.assertEquals(abs(a), abs(c)) - self.assertEquals(abs(a) - abs(c), abs(b)) - -add(TIntNum) diff --git a/tools/python-yasm/tests/test_symrec.py b/tools/python-yasm/tests/test_symrec.py deleted file mode 100644 index a575b194..00000000 --- a/tools/python-yasm/tests/test_symrec.py +++ /dev/null @@ -1,80 +0,0 @@ -from tests import TestCase, add -from yasm import SymbolTable, Expression, YasmError - -class TSymbolTable(TestCase): - def setUp(self): - self.symtab = SymbolTable() - - def test_keys(self): - self.assertEquals(len(self.symtab.keys()), 0) - self.symtab.declare("foo", None, 0) - keys = self.symtab.keys() - self.assertEquals(len(keys), 1) - self.assertEquals(keys[0], "foo") - - def test_contains(self): - self.assert_("foo" not in self.symtab) - self.symtab.declare("foo", None, 0) - self.assert_("foo" in self.symtab) - - def test_exception(self): - expr = Expression('+', 1, 2) - self.symtab.define_equ("foo", expr, 0) - self.assertRaises(YasmError, self.symtab.define_equ, "foo", expr, 0) - self.symtab.define_equ("bar", expr, 0) # cleared - self.assertRaises(YasmError, self.symtab.define_special, "bar", - 'global') - - def test_iters(self): - tab = self.symtab - tab.declare("foo", None, 0) - tab.declare("bar", None, 0) - tab.declare("baz", None, 0) - - # while ordering is not known, it must be consistent - self.assertEquals(list(tab.keys()), list(tab.iterkeys())) - self.assertEquals(list(tab.values()), list(tab.itervalues())) - self.assertEquals(list(tab.items()), list(tab.iteritems())) - self.assertEquals(list(tab.iteritems()), zip(tab.keys(), tab.values())) - -add(TSymbolTable) - -class TSymbolAttr(TestCase): - def setUp(self): - self.symtab = SymbolTable() - self.declsym = self.symtab.declare("foo", None, 0) - - def test_visibility(self): - sym = self.symtab.declare("local1", None, 0) - self.assertEquals(sym.visibility, set()) - sym = self.symtab.declare("local2", '', 0) - self.assertEquals(sym.visibility, set()) - sym = self.symtab.declare("local3", 'local', 0) - self.assertEquals(sym.visibility, set()) - sym = self.symtab.declare("global", 'global', 0) - self.assertEquals(sym.visibility, set(['global'])) - sym = self.symtab.declare("common", 'common', 0) - self.assertEquals(sym.visibility, set(['common'])) - sym = self.symtab.declare("extern", 'extern', 0) - self.assertEquals(sym.visibility, set(['extern'])) - sym = self.symtab.declare("dlocal", 'dlocal', 0) - self.assertEquals(sym.visibility, set(['dlocal'])) - - self.assertRaises(ValueError, - lambda: self.symtab.declare("extern2", 'foo', 0)) - def test_name(self): - self.assertEquals(self.declsym.name, "foo") - - def test_equ(self): - self.assertRaises(AttributeError, lambda: self.declsym.equ) - - def test_label(self): - self.assertRaises(AttributeError, lambda: self.declsym.label) - - def test_is_special(self): - self.assertEquals(self.declsym.is_special, False) - - def test_is_curpos(self): - self.assertEquals(self.declsym.is_curpos, False) - -add(TSymbolAttr) diff --git a/tools/python-yasm/value.pxi b/tools/python-yasm/value.pxi deleted file mode 100644 index 5d78c054..00000000 --- a/tools/python-yasm/value.pxi +++ /dev/null @@ -1,56 +0,0 @@ -# Python bindings for Yasm: Pyrex input file for value.h -# -# Copyright (C) 2006 Michael Urman, Peter Johnson -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND OTHER CONTRIBUTORS ``AS IS'' -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR OTHER CONTRIBUTORS BE -# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. - -cdef class Value: - cdef yasm_value value - def __cinit__(self, value=None, size=None): - cdef unsigned int sz - if size is None: - sz = 0 - else: - sz = size; - - yasm_value_initialize(&self.value, NULL, sz) - if value is None: - pass - elif isinstance(value, Expression): - yasm_value_initialize(&self.value, - yasm_expr_copy((value).expr), sz) - elif isinstance(value, Symbol): - yasm_value_init_sym(&self.value, (value).sym, sz) - else: - raise TypeError("Invalid value type '%s'" % type(value)) - - def __dealloc__(self): - yasm_value_delete(&self.value) - - def finalize(self, precbc=None): - if precbc is None: - return yasm_value_finalize(&self.value, NULL) - elif isinstance(precbc, Bytecode): - return yasm_value_finalize(&self.value, (precbc).bc) - else: - raise TypeError("Invalid precbc type '%s'" % type(precbc)) - diff --git a/tools/python-yasm/yasm.pyx b/tools/python-yasm/yasm.pyx deleted file mode 100644 index adbc734e..00000000 --- a/tools/python-yasm/yasm.pyx +++ /dev/null @@ -1,137 +0,0 @@ -# Python bindings for Yasm: Main Pyrex input file -# -# Copyright (C) 2006 Michael Urman, Peter Johnson -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND OTHER CONTRIBUTORS ``AS IS'' -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR OTHER CONTRIBUTORS BE -# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -"""Interface to the Yasm library. - -The Yasm library (aka libyasm) provides the core functionality of the Yasm -assembler. Classes in this library provide for manipulation of machine -instructions and object file constructs such as symbol tables and sections. - -Expression objects encapsulate complex expressions containing registers, -symbols, and operations such as SEG. - -Bytecode objects encapsulate data or code objects such as data, reserve, -align, or instructions. - -Section objects encapsulate an object file section, including the section -name, any Bytecode objects contained within that section, and other -information. - -""" - -cdef extern from "Python.h": - cdef object PyCObject_FromVoidPtr(void *cobj, void (*destr)(void *)) - cdef object PyCObject_FromVoidPtrAndDesc(void *cobj, void *desc, - void (*destr)(void *, void *)) - cdef int PyType_Check(object) - cdef int PyCObject_Check(object) - cdef void *PyCObject_AsVoidPtr(object) - cdef void *PyCObject_GetDesc(object) - - cdef object _PyLong_FromByteArray(unsigned char *bytes, unsigned int n, - int little_endian, int is_signed) - cdef int _PyLong_AsByteArray(object v, unsigned char *bytes, unsigned int n, - int little_endian, int is_signed) except -1 - - cdef void Py_INCREF(object o) - cdef void Py_DECREF(object o) - - cdef void PyErr_SetString(object type, char *message) - cdef object PyErr_Format(object type, char *format, ...) - -cdef extern from "stdlib.h": - cdef void *malloc(int n) - cdef void free(void *p) - -include "_yasm.pxi" - -cdef object __pass_voidp(void *obj, object forclass): - return PyCObject_FromVoidPtrAndDesc(obj, forclass, NULL) - -cdef void *__get_voidp(object obj, object forclass) except NULL: - cdef void* desc - - if not PyCObject_Check(obj): - msg = "obj %r is not a CObject" % obj - PyErr_SetString(TypeError, msg) - return NULL - - desc = PyCObject_GetDesc(obj) - - if desc != forclass: - if desc == NULL: - msg = "CObject type is not set (expecting %s)" % forclass - elif PyType_Check(desc): - msg = "CObject is for %s not %s" % (desc, forclass) - else: - msg = "CObject is incorrect (expecting %s)" % forclass - PyErr_SetString(TypeError, msg) - return NULL - - return PyCObject_AsVoidPtr(obj) - -# -# Link to associated data mechanism to keep Python references paired with -# yasm objects. -# -cdef class __assoc_data_callback: - cdef yasm_assoc_data_callback *cb - def __cinit__(self, destroy, print_): - self.cb = malloc(sizeof(yasm_assoc_data_callback)) - self.cb.destroy = PyCObject_AsVoidPtr(destroy) - #self.cb.print_ = PyCObject_AsVoidPtr(print_) - def __dealloc__(self): - free(self.cb) - - -cdef class Register: - cdef unsigned long reg - def __cinit__(self, reg): - self.reg = reg - -include "errwarn.pxi" -include "intnum.pxi" -include "floatnum.pxi" -include "expr.pxi" -include "symrec.pxi" -include "value.pxi" - -include "bytecode.pxi" - -cdef __initialize(): - BitVector_Boot() - yasm_intnum_initialize() - yasm_floatnum_initialize() - yasm_errwarn_initialize() - -def __cleanup(): - yasm_floatnum_cleanup() - yasm_intnum_cleanup() - yasm_errwarn_cleanup() - BitVector_Shutdown() - -__initialize() -import atexit -atexit.register(__cleanup) - diff --git a/tools/re2c/CMakeLists.txt b/tools/re2c/CMakeLists.txt deleted file mode 100644 index 2a25f733..00000000 --- a/tools/re2c/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -add_executable(re2c - main.c - code.c - dfa.c - parser.c - actions.c - scanner.c - mbo_getopt.c - substr.c - translate.c - ) - -if(CMAKE_CROSSCOMPILING) - find_program(RE2C_BIN NAMES re2c REQUIRED) - add_executable(yasm::re2c IMPORTED GLOBAL) - set_property(TARGET yasm::re2c PROPERTY IMPORTED_LOCATION "${RE2C_BIN}") -else() - add_executable(yasm::re2c ALIAS re2c) -endif() diff --git a/tools/re2c/Makefile.inc b/tools/re2c/Makefile.inc index edb89a5d..abd2db87 100644 --- a/tools/re2c/Makefile.inc +++ b/tools/re2c/Makefile.inc @@ -1,3 +1,5 @@ +# $Id$ + # These utility programs have to be built for BUILD host in cross-build. # This makes things rather non-standard automake @@ -36,40 +38,31 @@ re2c_LDADD += re2c-translate.$(OBJEXT) re2c_LINK = $(CCLD_FOR_BUILD) -o $@ re2c-main.$(OBJEXT): tools/re2c/main.c - $(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(DEFAULT_INCLUDES) $(INCLUDES) \ - -c -o $@ `test -f tools/re2c/main.c || echo '$(srcdir)/'`tools/re2c/main.c + $(CC_FOR_BUILD) $(DEFAULT_INCLUDES) $(INCLUDES) -c -o $@ `test -f tools/re2c/main.c || echo '$(srcdir)/'`tools/re2c/main.c re2c-code.$(OBJEXT): tools/re2c/code.c - $(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(DEFAULT_INCLUDES) $(INCLUDES) \ - -c -o $@ `test -f tools/re2c/code.c || echo '$(srcdir)/'`tools/re2c/code.c + $(CC_FOR_BUILD) $(DEFAULT_INCLUDES) $(INCLUDES) -c -o $@ `test -f tools/re2c/code.c || echo '$(srcdir)/'`tools/re2c/code.c re2c-dfa.$(OBJEXT): tools/re2c/dfa.c - $(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(DEFAULT_INCLUDES) $(INCLUDES) \ - -c -o $@ `test -f tools/re2c/dfa.c || echo '$(srcdir)/'`tools/re2c/dfa.c + $(CC_FOR_BUILD) $(DEFAULT_INCLUDES) $(INCLUDES) -c -o $@ `test -f tools/re2c/dfa.c || echo '$(srcdir)/'`tools/re2c/dfa.c re2c-parser.$(OBJEXT): tools/re2c/parser.c - $(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(DEFAULT_INCLUDES) $(INCLUDES) \ - -c -o $@ `test -f tools/re2c/parser.c || echo '$(srcdir)/'`tools/re2c/parser.c + $(CC_FOR_BUILD) $(DEFAULT_INCLUDES) $(INCLUDES) -c -o $@ `test -f tools/re2c/parser.c || echo '$(srcdir)/'`tools/re2c/parser.c re2c-actions.$(OBJEXT): tools/re2c/actions.c - $(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(DEFAULT_INCLUDES) $(INCLUDES) \ - -c -o $@ `test -f tools/re2c/actions.c || echo '$(srcdir)/'`tools/re2c/actions.c + $(CC_FOR_BUILD) $(DEFAULT_INCLUDES) $(INCLUDES) -c -o $@ `test -f tools/re2c/actions.c || echo '$(srcdir)/'`tools/re2c/actions.c re2c-scanner.$(OBJEXT): tools/re2c/scanner.c - $(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(DEFAULT_INCLUDES) $(INCLUDES) \ - -c -o $@ `test -f tools/re2c/scanner.c || echo '$(srcdir)/'`tools/re2c/scanner.c + $(CC_FOR_BUILD) $(DEFAULT_INCLUDES) $(INCLUDES) -c -o $@ `test -f tools/re2c/scanner.c || echo '$(srcdir)/'`tools/re2c/scanner.c re2c-mbo_getopt.$(OBJEXT): tools/re2c/mbo_getopt.c - $(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(DEFAULT_INCLUDES) $(INCLUDES) \ - -c -o $@ `test -f tools/re2c/mbo_getopt.c || echo '$(srcdir)/'`tools/re2c/mbo_getopt.c + $(CC_FOR_BUILD) $(DEFAULT_INCLUDES) $(INCLUDES) -c -o $@ `test -f tools/re2c/mbo_getopt.c || echo '$(srcdir)/'`tools/re2c/mbo_getopt.c re2c-substr.$(OBJEXT): tools/re2c/substr.c - $(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(DEFAULT_INCLUDES) $(INCLUDES) \ - -c -o $@ `test -f tools/re2c/substr.c || echo '$(srcdir)/'`tools/re2c/substr.c + $(CC_FOR_BUILD) $(DEFAULT_INCLUDES) $(INCLUDES) -c -o $@ `test -f tools/re2c/substr.c || echo '$(srcdir)/'`tools/re2c/substr.c re2c-translate.$(OBJEXT): tools/re2c/translate.c - $(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(DEFAULT_INCLUDES) $(INCLUDES) \ - -c -o $@ `test -f tools/re2c/translate.c || echo '$(srcdir)/'`tools/re2c/translate.c + $(CC_FOR_BUILD) $(DEFAULT_INCLUDES) $(INCLUDES) -c -o $@ `test -f tools/re2c/translate.c || echo '$(srcdir)/'`tools/re2c/translate.c EXTRA_DIST += tools/re2c/CHANGELOG EXTRA_DIST += tools/re2c/NO_WARRANTY diff --git a/tools/re2c/code.c b/tools/re2c/code.c index e870eb1c..1c72517a 100644 --- a/tools/re2c/code.c +++ b/tools/re2c/code.c @@ -1,7 +1,3 @@ -#ifdef _WIN32 -#include -#include -#endif #include #include #include @@ -10,57 +6,6 @@ #include "tools/re2c/dfa.h" #include "tools/re2c/parse.h" -#ifdef _WIN32 -/* tmpfile() replacment for Windows. - * - * On Windows tmpfile() creates the file in the root directory. This - * may fail due to unsufficient privileges. - */ -static FILE * -win32_tmpfile (void) -{ - DWORD path_len; - WCHAR path_name[MAX_PATH + 1]; - WCHAR file_name[MAX_PATH + 1]; - HANDLE handle; - int fd; - FILE *fp; - - path_len = GetTempPathW (MAX_PATH, path_name); - if (path_len <= 0 || path_len >= MAX_PATH) - return NULL; - - if (GetTempFileNameW (path_name, L"ps_", 0, file_name) == 0) - return NULL; - - handle = CreateFileW (file_name, - GENERIC_READ | GENERIC_WRITE, - 0, - NULL, - CREATE_ALWAYS, - FILE_ATTRIBUTE_NORMAL | FILE_FLAG_DELETE_ON_CLOSE, - NULL); - if (handle == INVALID_HANDLE_VALUE) { - DeleteFileW (file_name); - return NULL; - } - - fd = _open_osfhandle((intptr_t) handle, 0); - if (fd < 0) { - CloseHandle (handle); - return NULL; - } - - fp = fdopen(fd, "w+b"); - if (fp == NULL) { - _close(fd); - return NULL; - } - - return fp; -} -#endif - static void useLabel(size_t value) { while (value >= vUsedLabelAlloc) { vUsedLabels = realloc(vUsedLabels, vUsedLabelAlloc * 2); @@ -201,11 +146,11 @@ void BitMap_gen(FILE *o, unsigned int lb, unsigned int ub){ unsigned int n = ub - lb; unsigned int i; unsigned char *bm = malloc(sizeof(unsigned char)*n); + memset(bm, 0, n); fputs("\tstatic unsigned char yybm[] = {", o); for(i = 0; b; i += n){ unsigned char m; unsigned int j; - memset(bm, 0, n); for(m = 0x80; b && m; b = b->next, m >>= 1){ b->i = i; b->m = m; doGen(b->go, b->on, bm-lb, m); @@ -216,7 +161,6 @@ void BitMap_gen(FILE *o, unsigned int lb, unsigned int ub){ } } fputs("\n\t};\n", o); oline+=2; - free(bm); } } @@ -461,8 +405,8 @@ Go_genSwitch(Go *g, FILE *o, State *from, State *next, int *readCh){ if(g->span[i].to != def) *(t++) = &g->span[i]; - if (dFlag) - fputs("\tYYDEBUG(-1, yych);\n", o); + if (dFlag) + fputs("\tYYDEBUG(-1, yych);\n", o); #if 0 if (*readCh) { @@ -899,17 +843,14 @@ void DFA_emit(DFA *d, FILE *o){ nOrgOline = oline; maxFillIndexes = vFillIndexes; orgVFillIndexes = vFillIndexes; -#ifdef _WIN32 - tmpo = win32_tmpfile(); -#else - tmpo = tmpfile(); -#endif + tmpo = fopen("re2c.tmp", "wt"); for(s = d->head; s; s = s->next){ int readCh = 0; State_emit(s, tmpo, &readCh); Go_genGoto(&s->go, tmpo, s, s->next, &readCh); } fclose(tmpo); + remove("re2c.tmp"); maxFillIndexes = vFillIndexes; vFillIndexes = orgVFillIndexes; oline = nOrgOline; @@ -936,12 +877,12 @@ void DFA_emit(DFA *d, FILE *o){ oline++; useLabel(label); } else { - int j; + int i; fputs("\tswitch(YYGETSTATE()) {\n", o); fputs("\t\tcase -1: goto yy0;\n", o); - for (j=0; jlabel = 0; s->rule = NULL; - s->next = NULL; s->link = NULL; - s->depth = 0; s->kCount = 0; s->kernel = NULL; - s->isBase = 0; s->action = NULL; s->go.nSpans = 0; s->go.span = NULL; diff --git a/tools/re2c/main.c b/tools/re2c/main.c index 94843160..f0baaf61 100644 --- a/tools/re2c/main.c +++ b/tools/re2c/main.c @@ -45,23 +45,20 @@ static void usage() "-? -h --help Display this info.\n" "\n" "-b --bit-vectors Implies -s. Use bit vectors as well in the attempt to\n" - " coax better code out of the compiler. Most useful for\n"); - fprintf(stderr, + " coax better code out of the compiler. Most useful for\n" " specifications with more than a few keywords (e.g. for\n" " most programming languages).\n" "\n" "-e --ecb Cross-compile from an ASCII platform to\n" " an EBCDIC one.\n" - "\n"); - fprintf(stderr, + "\n" "-s --nested-ifs Generate nested ifs for some switches. Many compilers\n" " need this assist to generate better code.\n" "\n" "-f --storable-state Generate a scanner with support for storable state\n" "\n" "-o --output=output Specify the output file instead of stdout\n" - "\n"); - fprintf(stderr, + "\n" "-d --debug-output Creates a parser that dumps information during\n" " about the current position and in which state the\n" " parser is.\n" @@ -162,7 +159,7 @@ int main(int argc, char *argv[]) } } - /* set up the output stream */ + // set up the output stream if (outputFileName == 0 || (fileName[0] == '-' && fileName[1] == '\0')) { outputFileName = mystrdup(""); output = stdout; diff --git a/tools/re2c/scanner.c b/tools/re2c/scanner.c index 034c935b..4640ee4a 100644 --- a/tools/re2c/scanner.c +++ b/tools/re2c/scanner.c @@ -48,7 +48,7 @@ fill(Scanner *s, unsigned char *cursor) s->lim -= cnt; } if((s->top - s->lim) < BSIZE){ - unsigned char *buf = malloc(((s->lim - s->bot) + BSIZE) + 1); + unsigned char *buf = malloc(((s->lim - s->bot) + BSIZE)); memcpy(buf, s->tok, s->lim - s->tok); s->tok = buf; s->ptr = &buf[s->ptr - s->bot]; diff --git a/tools/re2c/scanner.re b/tools/re2c/scanner.re index 423835b6..10af0883 100644 --- a/tools/re2c/scanner.re +++ b/tools/re2c/scanner.re @@ -45,7 +45,7 @@ fill(Scanner *s, unsigned char *cursor) s->lim -= cnt; } if((s->top - s->lim) < BSIZE){ - unsigned char *buf = malloc(((s->lim - s->bot) + BSIZE) + 1); + unsigned char *buf = malloc(((s->lim - s->bot) + BSIZE)); memcpy(buf, s->tok, s->lim - s->tok); s->tok = buf; s->ptr = &buf[s->ptr - s->bot]; diff --git a/tools/xdf/xdf.h b/tools/xdf/xdf.h index e2150d25..8f13774b 100644 --- a/tools/xdf/xdf.h +++ b/tools/xdf/xdf.h @@ -1,5 +1,6 @@ /* XDF - Extended Dynamic Object Format */ /* Version 2.0 */ +/* $Id$ */ /* FILE HEADER */ /* SECTION HEADERS [] */ @@ -17,12 +18,10 @@ #ifndef XDF_H_INCLUDED #define XDF_H_INCLUDED -#include - -typedef uint8_t u8; -typedef uint16_t u16; -typedef uint32_t u32; -typedef uint64_t u64; +typedef unsigned char u8; +typedef unsigned short u16; +typedef unsigned int u32; +typedef unsigned long long u64; typedef enum { @@ -79,7 +78,6 @@ typedef struct { /* 16 bytes */ } FILE_HEADER; -#define FILE_HEADER_SIZE (4+4+4+4) typedef struct { /* 40 bytes */ @@ -96,7 +94,6 @@ typedef struct { /* 40 bytes */ } SECTION_HEADER; -#define SECTION_HEADER_SIZE (4+8+8+2+2+4+4+4+4) typedef struct { /* 16 bytes */ @@ -107,7 +104,6 @@ typedef struct { /* 16 bytes */ } SYMBOL_ENTRY; -#define SYMBOL_ENTRY_SIZE (4+4+4+4) typedef struct { /* 16 bytes */ diff --git a/tools/xdf/xdfdump.c b/tools/xdf/xdfdump.c index 8d3df212..e1ee2510 100644 --- a/tools/xdf/xdfdump.c +++ b/tools/xdf/xdfdump.c @@ -1,4 +1,4 @@ -/* +/* $Id$ * Extended Dynamic Object format dumper * * Copyright (C) 2004-2007 Peter Johnson @@ -39,15 +39,6 @@ print_file_header(const FILE_HEADER *filehead) printf("\tTotal Headers Size=%d\n", filehead->f_size); } -void -read_syment(SYMBOL_ENTRY *syment, FILE *f) -{ - fread(&syment->e_sect_idx, sizeof(syment->e_sect_idx), 1, f); - fread(&syment->e_sect_off, sizeof(syment->e_sect_off), 1, f); - fread(&syment->e_name_off, sizeof(syment->e_name_off), 1, f); - fread(&syment->e_flags, sizeof(syment->e_flags), 1, f); -} - const char * get_syment_name(const SYMBOL_ENTRY *syment, FILE *f) { @@ -65,8 +56,8 @@ get_sym_name(u32 idx, FILE *f, size_t symtab_off) { SYMBOL_ENTRY syment; long oldpos = ftell(f); - fseek(f, symtab_off+idx*SYMBOL_ENTRY_SIZE, SEEK_SET); - read_syment(&syment, f); + fseek(f, symtab_off+idx*sizeof(SYMBOL_ENTRY), SEEK_SET); + fread(&syment, sizeof(syment), 1, f); fseek(f, oldpos, SEEK_SET); return get_syment_name(&syment, f); } @@ -76,33 +67,33 @@ get_sect_name(u32 idx, FILE *f, size_t symtab_off, size_t secttab_off) { SECTION_HEADER secthead; long oldpos = ftell(f); - fseek(f, secttab_off+idx*SECTION_HEADER_SIZE, SEEK_SET); - fread(§head.s_name_idx, sizeof(secthead.s_name_idx), 1, f); + fseek(f, secttab_off+idx*sizeof(SECTION_HEADER), SEEK_SET); + fread(§head, sizeof(secthead), 1, f); fseek(f, oldpos, SEEK_SET); return get_sym_name(secthead.s_name_idx, f, symtab_off); } void print_symbol(const SYMBOL_ENTRY *syment, FILE *f, size_t symtab_off, - size_t secttab_off) + size_t secttab_off) { int first = 1; printf("\tOffset=0x%08X Flags=", syment->e_sect_off); if (syment->e_flags & XDF_SYM_EXTERN) - printf("%sEXTERN", first-->0?"":"|"); + printf("%sEXTERN", first-->0?"":"|"); if (syment->e_flags & XDF_SYM_GLOBAL) - printf("%sGLOBAL", first-->0?"":"|"); + printf("%sGLOBAL", first-->0?"":"|"); if (syment->e_flags & XDF_SYM_EQU) - printf("%sEQU", first-->0?"":"|"); + printf("%sEQU", first-->0?"":"|"); if (first>0) - printf("None"); + printf("None"); printf(" Name=`%s' Section=", get_syment_name(syment, f)); - if (syment->e_sect_idx >= 0x80000000) - printf("%d\n", syment->e_sect_idx); + if ((long)syment->e_sect_idx < 0) + printf("%d\n", syment->e_sect_idx); else - printf("`%s' (%d)\n", - get_sect_name(syment->e_sect_idx, f, symtab_off, secttab_off), - syment->e_sect_idx); + printf("`%s' (%d)\n", + get_sect_name(syment->e_sect_idx, f, symtab_off, secttab_off), + syment->e_sect_idx); } void @@ -110,27 +101,27 @@ print_reloc(const RELOCATION_ENTRY *relocent, FILE *f, size_t symtab_off) { const char *type = "UNK"; switch (relocent->r_type) { - case XDF_RELOC_REL: - type = "REL"; - break; - case XDF_RELOC_WRT: - type = "WRT"; - break; - case XDF_RELOC_RIP: - type = "RIP"; - break; - case XDF_RELOC_SEG: - type = "SEG"; - break; + case XDF_RELOC_REL: + type = "REL"; + break; + case XDF_RELOC_WRT: + type = "WRT"; + break; + case XDF_RELOC_RIP: + type = "RIP"; + break; + case XDF_RELOC_SEG: + type = "SEG"; + break; } printf("\t Offset=0x%08X Type=%s Size=%d Shift=%d Target=`%s' (%d)", - relocent->r_off, type, relocent->r_size, relocent->r_shift, - get_sym_name(relocent->r_targ_idx, f, symtab_off), - relocent->r_targ_idx); + relocent->r_off, type, relocent->r_size, relocent->r_shift, + get_sym_name(relocent->r_targ_idx, f, symtab_off), + relocent->r_targ_idx); if (relocent->r_type == XDF_RELOC_WRT) - printf(" Base=`%s' (%d)", - get_sym_name(relocent->r_base_idx, f, symtab_off), - relocent->r_base_idx); + printf(" Base=`%s' (%d)", + get_sym_name(relocent->r_base_idx, f, symtab_off), + relocent->r_base_idx); printf("\n"); } @@ -140,54 +131,54 @@ print_section(const SECTION_HEADER *secthead, FILE *f, size_t symtab_off) int first = 1; u32 i; printf("Section `%s' (section name symtab %d):\n", - get_sym_name(secthead->s_name_idx, f, symtab_off), - secthead->s_name_idx); + get_sym_name(secthead->s_name_idx, f, symtab_off), + secthead->s_name_idx); printf("\tPhysical Address=0x%016llX\n", secthead->s_addr); printf("\tVirtual Address=0x%016llX\n", secthead->s_vaddr); printf("\tAlign=%d\n", secthead->s_align); printf("\tFlags="); if (secthead->s_flags & XDF_SECT_ABSOLUTE) - printf("%sABSOLUTE", first-->0?"":"|"); + printf("%sABSOLUTE", first-->0?"":"|"); if (secthead->s_flags & XDF_SECT_FLAT) - printf("%sFLAT", first-->0?"":"|"); + printf("%sFLAT", first-->0?"":"|"); if (secthead->s_flags & XDF_SECT_BSS) - printf("%sBSS", first-->0?"":"|"); + printf("%sBSS", first-->0?"":"|"); if (secthead->s_flags & XDF_SECT_USE_16) - printf("%sUSE16", first-->0?"":"|"); + printf("%sUSE16", first-->0?"":"|"); if (secthead->s_flags & XDF_SECT_USE_32) - printf("%sUSE32", first-->0?"":"|"); + printf("%sUSE32", first-->0?"":"|"); if (secthead->s_flags & XDF_SECT_USE_64) - printf("%sUSE64", first-->0?"":"|"); + printf("%sUSE64", first-->0?"":"|"); if (first>0) - printf("None"); + printf("None"); printf("\n\tData Offset=0x%08X\n", secthead->s_data_off); printf("\tData Size=%d\n", secthead->s_data_size); if (!(secthead->s_flags & XDF_SECT_BSS) && secthead->s_data_size > 0) { - printf("\tSection Data:"); - long oldpos = ftell(f); - fseek(f, secthead->s_data_off, SEEK_SET); - for (i=0; is_data_size; i++) { - if (i % 16 == 0) - printf("\n\t\t%08X:", i); - if (i % 2 == 0) - printf(" "); - printf("%02X", fgetc(f)); - } - printf("\n"); - fseek(f, oldpos, SEEK_SET); + printf("\tSection Data:"); + long oldpos = ftell(f); + fseek(f, secthead->s_data_off, SEEK_SET); + for (i=0; is_data_size; i++) { + if (i % 16 == 0) + printf("\n\t\t%08X:", i); + if (i % 2 == 0) + printf(" "); + printf("%02X", fgetc(f)); + } + printf("\n"); + fseek(f, oldpos, SEEK_SET); } printf("\tReloc Table Offset=0x%08X\n", secthead->s_reltab_off); printf("\tNum Relocs=%d\n", secthead->s_num_reloc); if (secthead->s_num_reloc > 0) { - printf("\tRelocations:\n"); - long oldpos = ftell(f); - fseek(f, secthead->s_reltab_off, SEEK_SET); - for (i=0; is_num_reloc; i++) { - RELOCATION_ENTRY relocent; - fread(&relocent, sizeof(relocent), 1, f); - print_reloc(&relocent, f, symtab_off); - } - fseek(f, oldpos, SEEK_SET); + printf("\tRelocations:\n"); + long oldpos = ftell(f); + fseek(f, secthead->s_reltab_off, SEEK_SET); + for (i=0; is_num_reloc; i++) { + RELOCATION_ENTRY relocent; + fread(&relocent, sizeof(relocent), 1, f); + print_reloc(&relocent, f, symtab_off); + } + fseek(f, oldpos, SEEK_SET); } } @@ -200,48 +191,37 @@ main(int argc, char **argv) u32 i; if (argc != 2) { - fprintf(stderr, "Usage: %s \n", argv[0]); - return EXIT_FAILURE; + fprintf(stderr, "Usage: %s \n", argv[0]); + return EXIT_FAILURE; } f = fopen(argv[1], "rb"); if (!f) { - fprintf(stderr, "Could not open `%s'\n", argv[1]); - return EXIT_FAILURE; + fprintf(stderr, "Could not open `%s'\n", argv[1]); + return EXIT_FAILURE; } - fread(&filehead.f_magic, sizeof(filehead.f_magic), 1, f); - fread(&filehead.f_nsect, sizeof(filehead.f_nsect), 1, f); - fread(&filehead.f_nsyms, sizeof(filehead.f_nsyms), 1, f); - fread(&filehead.f_size, sizeof(filehead.f_size), 1, f); + fread(&filehead, sizeof(filehead), 1, f); if (filehead.f_magic != XDF_MAGIC) { - fprintf(stderr, "Magic number mismatch (expected %08X, got %08X\n", - XDF_MAGIC, filehead.f_magic); - return EXIT_FAILURE; + fprintf(stderr, "Magic number mismatch (expected %08X, got %08X\n", + XDF_MAGIC, filehead.f_magic); + return EXIT_FAILURE; } print_file_header(&filehead); - symtab_off = FILE_HEADER_SIZE+filehead.f_nsect*SECTION_HEADER_SIZE; + symtab_off = sizeof(FILE_HEADER)+filehead.f_nsect*sizeof(SECTION_HEADER); for (i=0; i #include -#ifdef HAVE_STRINGS_H -#include -#endif - -#include #include #ifdef lint -# define _(String) String +# define _(String) String #else # ifdef HAVE_LOCALE_H # include @@ -76,73 +71,89 @@ # ifdef ENABLE_NLS # include -# define _(String) gettext(String) +# define _(String) gettext(String) # else -# define gettext(Msgid) (Msgid) -# define dgettext(Domainname, Msgid) (Msgid) +# define gettext(Msgid) (Msgid) +# define dgettext(Domainname, Msgid) (Msgid) # define dcgettext(Domainname, Msgid, Category) (Msgid) -# define textdomain(Domainname) while (0) /* nothing */ -# define bindtextdomain(Domainname, Dirname) while (0) /* nothing */ -# define _(String) (String) +# define textdomain(Domainname) while (0) /* nothing */ +# define bindtextdomain(Domainname, Dirname) while (0) /* nothing */ +# define _(String) (String) # endif #endif #ifdef gettext_noop -# define N_(String) gettext_noop(String) +# define N_(String) gettext_noop(String) #else -# define N_(String) (String) +# define N_(String) (String) #endif #ifdef HAVE_MERGESORT -#define yasm__mergesort(a, b, c, d) mergesort(a, b, c, d) +#define yasm__mergesort(a, b, c, d) mergesort(a, b, c, d) #endif #ifdef HAVE_STRSEP -#define yasm__strsep(a, b) strsep(a, b) +#define yasm__strsep(a, b) strsep(a, b) #endif #ifdef HAVE_STRCASECMP -# define yasm__strcasecmp(x, y) strcasecmp(x, y) -# define yasm__strncasecmp(x, y, n) strncasecmp(x, y, n) +# define yasm__strcasecmp(x, y) strcasecmp(x, y) +# define yasm__strncasecmp(x, y, n) strncasecmp(x, y, n) #elif HAVE_STRICMP -# define yasm__strcasecmp(x, y) stricmp(x, y) -# define yasm__strncasecmp(x, y, n) strnicmp(x, y, n) +# define yasm__strcasecmp(x, y) stricmp(x, y) +# define yasm__strncasecmp(x, y, n) strnicmp(x, y, n) #elif HAVE__STRICMP -# define yasm__strcasecmp(x, y) _stricmp(x, y) -# define yasm__strncasecmp(x, y, n) _strnicmp(x, y, n) +# define yasm__strcasecmp(x, y) _stricmp(x, y) +# define yasm__strncasecmp(x, y, n) _strnicmp(x, y, n) #elif HAVE_STRCMPI -# define yasm__strcasecmp(x, y) strcmpi(x, y) -# define yasm__strncasecmp(x, y, n) strncmpi(x, y, n) +# define yasm__strcasecmp(x, y) strcmpi(x, y) +# define yasm__strncasecmp(x, y, n) strncmpi(x, y, n) #else # define USE_OUR_OWN_STRCASECMP #endif +#if !defined(HAVE_TOASCII) || defined(lint) +# define toascii(c) ((c) & 0x7F) +#endif + #include +#ifdef HAVE_SYS_CDEFS_H +# include +#endif + +#ifdef __RCSID +# define RCSID(s) __RCSID(s) +#elif defined(__GNUC__) && defined(__ELF__) +# define RCSID(s) __asm__(".ident\t\"" s "\"") +#else +# define RCSID(s) static const char rcsid[] = s +#endif + #ifdef WITH_DMALLOC # include -# define yasm__xstrdup(str) xstrdup(str) -# define yasm_xmalloc(size) xmalloc(size) -# define yasm_xcalloc(count, size) xcalloc(count, size) -# define yasm_xrealloc(ptr, size) xrealloc(ptr, size) -# define yasm_xfree(ptr) xfree(ptr) +# define yasm__xstrdup(str) xstrdup(str) +# define yasm_xmalloc(size) xmalloc(size) +# define yasm_xcalloc(count, size) xcalloc(count, size) +# define yasm_xrealloc(ptr, size) xrealloc(ptr, size) +# define yasm_xfree(ptr) xfree(ptr) #endif /* Bit-counting: used primarily by HAMT but also in a few other places. */ -#define BC_TWO(c) (0x1ul << (c)) -#define BC_MSK(c) (((unsigned long)(-1)) / (BC_TWO(BC_TWO(c)) + 1ul)) -#define BC_COUNT(x,c) ((x) & BC_MSK(c)) + (((x) >> (BC_TWO(c))) & BC_MSK(c)) -#define BitCount(d, s) do { \ - d = BC_COUNT(s, 0); \ - d = BC_COUNT(d, 1); \ - d = BC_COUNT(d, 2); \ - d = BC_COUNT(d, 3); \ - d = BC_COUNT(d, 4); \ +#define BC_TWO(c) (0x1ul << (c)) +#define BC_MSK(c) (((unsigned long)(-1)) / (BC_TWO(BC_TWO(c)) + 1ul)) +#define BC_COUNT(x,c) ((x) & BC_MSK(c)) + (((x) >> (BC_TWO(c))) & BC_MSK(c)) +#define BitCount(d, s) do { \ + d = BC_COUNT(s, 0); \ + d = BC_COUNT(d, 1); \ + d = BC_COUNT(d, 2); \ + d = BC_COUNT(d, 3); \ + d = BC_COUNT(d, 4); \ } while (0) /** Determine if a value is exactly a power of 2. Zero is treated as a power * of two. - * \param x value + * \param x value * \return Nonzero if x is a power of 2. */ #define is_exp2(x) ((x & (x - 1)) == 0) @@ -150,10 +161,10 @@ #ifndef NELEMS /** Get the number of elements in an array. * \internal - * \param array array + * \param array array * \return Number of elements. */ -#define NELEMS(array) (sizeof(array) / sizeof(array[0])) +#define NELEMS(array) (sizeof(array) / sizeof(array[0])) #endif #endif diff --git a/yasm.1 b/yasm.1 index 8b0d8456..71db01e0 100644 --- a/yasm.1 +++ b/yasm.1 @@ -1,55 +1,47 @@ -'\" t .\" Title: yasm .\" Author: Peter Johnson -.\" Generator: DocBook XSL Stylesheets v1.75.2 +.\" Generator: DocBook XSL Stylesheets v1.71.1 .\" Date: April 2007 .\" Manual: The Yasm Modular Assembler .\" Source: Yasm -.\" Language: English .\" .TH "YASM" "1" "April 2007" "Yasm" "The Yasm Modular Assembler" -.\" ----------------------------------------------------------------- -.\" * set default formatting -.\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l -.\" ----------------------------------------------------------------- -.\" * MAIN CONTENT STARTS HERE * -.\" ----------------------------------------------------------------- .SH "NAME" yasm \- The Yasm Modular Assembler .SH "SYNOPSIS" -.HP \w'\fByasm\fR\ 'u +.HP 5 \fByasm\fR [\fB\-f\ \fR\fB\fIformat\fR\fR] [\fB\-o\ \fR\fB\fIoutfile\fR\fR] [\fB\fIother\ options\fR\fR...] {\fIinfile\fR} -.HP \w'\fByasm\fR\ 'u +.HP 5 \fByasm\fR \fB\-h\fR .SH "DESCRIPTION" .PP The Yasm Modular Assembler is a portable, retargetable assembler written under the \(lqnew\(rq -(2 or 3 clause) BSD license\&. Yasm currently supports the x86 and AMD64 instruction sets, accepts NASM and GAS assembler syntaxes, outputs binary, ELF32, ELF64, COFF, Win32, and Win64 object formats, and generates source debugging information in STABS, DWARF 2, and CodeView 8 formats\&. +(2 or 3 clause) BSD license. Yasm currently supports the x86 and AMD64 instruction sets, accepts NASM and GAS assembler syntaxes, outputs binary, ELF32, ELF64, COFF, Win32, and Win64 object formats, and generates source debugging information in STABS, DWARF 2, and CodeView 8 formats. .PP YASM consists of the \fByasm\fR -command, libyasm, the core backend library, and a large number of modules\&. Currently, libyasm and the loadable modules are statically built into the +command, libyasm, the core backend library, and a large number of modules. Currently, libyasm and the loadable modules are statically built into the \fByasm\fR -executable\&. +executable. .PP The \fByasm\fR command assembles the file infile and directs output to the file \fIoutfile\fR -if specified\&. If +if specified. If \fIoutfile\fR is not specified, \fByasm\fR will derive a default output file name from the name of its input file, usually by appending -\&.o +\fI.o\fR or -\&.obj, or by removing all extensions for a raw binary file\&. Failing that, the output file name will be -yasm\&.out\&. +\fI.obj\fR, or by removing all extensions for a raw binary file. Failing that, the output file name will be +\fIyasm.out\fR. .PP If called with an \fIinfile\fR @@ -58,115 +50,115 @@ of \fByasm\fR assembles the standard input and directs output to the file \fIoutfile\fR, or -yasm\&.out +\fIyasm.out\fR if no \fIoutfile\fR -is specified\&. +is specified. .SH "OPTIONS" .PP -Many options may be given in one of two forms: either a dash followed by a single letter, or two dashes followed by a long option name\&. Options are listed in alphabetical order\&. +Many options may be given in one of two forms: either a dash followed by a single letter, or two dashes followed by a long option name. Options are listed in alphabetical order. .SS "General Options" .PP \fB\-a \fR\fB\fIarch\fR\fR or \fB\-\-arch=\fR\fB\fIarch\fR\fR: Select target architecture .RS 4 -Selects the target architecture\&. The default architecture is -\(lqx86\(rq, which supports both the IA\-32 and derivatives and AMD64 instruction sets\&. To print a list of available architectures to standard output, use +Selects the target architecture. The default architecture is +\(lqx86\(rq, which supports both the IA\-32 and derivatives and AMD64 instruction sets. To print a list of available architectures to standard output, use \(lqhelp\(rq as -\fIarch\fR\&. See +\fIarch\fR. See \fByasm_arch\fR(7) -for a list of supported architectures\&. +for a list of supported architectures. .RE .PP \fB\-f \fR\fB\fIformat\fR\fR or \fB\-\-oformat=\fR\fB\fIformat\fR\fR: Select object format .RS 4 -Selects the output object format\&. The default object format is -\(lqbin\(rq, which is a flat format binary with no relocation\&. To print a list of available object formats to standard output, use +Selects the output object format. The default object format is +\(lqbin\(rq, which is a flat format binary with no relocation. To print a list of available object formats to standard output, use \(lqhelp\(rq as -\fIformat\fR\&. See +\fIformat\fR. See \fByasm_objfmts\fR(7) -for a list of supported object formats\&. +for a list of supported object formats. .RE .PP \fB\-g \fR\fB\fIdebug\fR\fR or \fB\-\-dformat=\fR\fB\fIdebug\fR\fR: Select debugging format .RS 4 -Selects the debugging format for debug information\&. Debugging information can be used by a debugger to associate executable code back to the source file or get data structure and type information\&. Available debug formats vary between different object formats; +Selects the debugging format for debug information. Debugging information can be used by a debugger to associate executable code back to the source file or get data structure and type information. Available debug formats vary between different object formats; \fByasm\fR -will error when an invalid combination is selected\&. The default object format is selected by the object format\&. To print a list of available debugging formats to standard output, use +will error when an invalid combination is selected. The default object format is selected by the object format. To print a list of available debugging formats to standard output, use \(lqhelp\(rq as -\fIdebug\fR\&. See +\fIdebug\fR. See \fByasm_dbgfmts\fR(7) -for a list of supported debugging formats\&. -.RE -.PP -\fB\-L \fR\fB\fIlist\fR\fR or \fB\-\-lformat=\fR\fB\fIlist\fR\fR: Select list file format -.RS 4 -Selects the format/style of the output list file\&. List files typically intermix the original source with the machine code generated by the assembler\&. The default list format is -\(lqnasm\(rq, which mimics the NASM list file format\&. To print a list of available list file formats to standard output, use -\(lqhelp\(rq -as -\fIlist\fR\&. -.RE -.PP -\fB\-l \fR\fB\fIlistfile\fR\fR or \fB\-\-list=\fR\fB\fIlistfile\fR\fR: Specify list filename -.RS 4 -Specifies the name of the output list file\&. If this option is not used, no list file is generated\&. -.RE -.PP -\fB\-m \fR\fB\fImachine\fR\fR or \fB\-\-machine=\fR\fB\fImachine\fR\fR: Select target machine architecture -.RS 4 -Selects the target machine architecture\&. Essentially a subtype of the selected architecture, the machine type selects between major subsets of an architecture\&. For example, for the -\(lqx86\(rq -architecture, the two available machines are -\(lqx86\(rq, which is used for the IA\-32 and derivative 32\-bit instruction set, and -\(lqamd64\(rq, which is used for the 64\-bit instruction set\&. This differentiation is required to generate the proper object file for relocatable object formats such as COFF and ELF\&. To print a list of available machines for a given architecture to standard output, use -\(lqhelp\(rq -as -\fImachine\fR -and the given architecture using -\fB\-a \fR\fB\fIarch\fR\fR\&. See -\fByasm_arch\fR(7) -for more details\&. -.RE -.PP -\fB\-o \fR\fB\fIfilename\fR\fR or \fB\-\-objfile=\fR\fB\fIfilename\fR\fR: Specify object filename -.RS 4 -Specifies the name of the output file, overriding any default name generated by Yasm\&. -.RE -.PP -\fB\-p \fR\fB\fIparser\fR\fR or \fB\-\-parser=\fR\fB\fIparser\fR\fR: Select parser -.RS 4 -Selects the parser (the assembler syntax)\&. The default parser is -\(lqnasm\(rq, which emulates the syntax of NASM, the Netwide Assembler\&. Another available parser is -\(lqgas\(rq, which emulates the syntax of GNU AS\&. To print a list of available parsers to standard output, use -\(lqhelp\(rq -as -\fIparser\fR\&. See -\fByasm_parsers\fR(7) -for a list of supported parsers\&. -.RE -.PP -\fB\-r \fR\fB\fIpreproc\fR\fR or \fB\-\-preproc=\fR\fB\fIpreproc\fR\fR: Select preprocessor -.RS 4 -Selects the preprocessor to use on the input file before passing it to the parser\&. Preprocessors often provide macro functionality that is not included in the main parser\&. The default preprocessor is -\(lqnasm\(rq, which is an imported version of the actual NASM preprocessor\&. A -\(lqraw\(rq -preprocessor is also available, which simply skips the preprocessing step, passing the input file directly to the parser\&. To print a list of available preprocessors to standard output, use -\(lqhelp\(rq -as -\fIpreproc\fR\&. +for a list of supported debugging formats. .RE .PP \fB\-h\fR or \fB\-\-help\fR: Print a summary of options .RS 4 -Prints a summary of invocation options\&. All other options are ignored, and no output file is generated\&. +Prints a summary of invocation options. All other options are ignored, and no output file is generated. +.RE +.PP +\fB\-L \fR\fB\fIlist\fR\fR or \fB\-\-lformat=\fR\fB\fIlist\fR\fR: Select list file format +.RS 4 +Selects the format/style of the output list file. List files typically intermix the original source with the machine code generated by the assembler. The default list format is +\(lqnasm\(rq, which mimics the NASM list file format. To print a list of available list file formats to standard output, use +\(lqhelp\(rq +as +\fIlist\fR. +.RE +.PP +\fB\-l \fR\fB\fIlistfile\fR\fR or \fB\-\-list=\fR\fB\fIlistfile\fR\fR: Specify list filename +.RS 4 +Specifies the name of the output list file. If this option is not used, no list file is generated. +.RE +.PP +\fB\-m \fR\fB\fImachine\fR\fR or \fB\-\-machine=\fR\fB\fImachine\fR\fR: Select target machine architecture +.RS 4 +Selects the target machine architecture. Essentially a subtype of the selected architecture, the machine type selects between major subsets of an architecture. For example, for the +\(lqx86\(rq +architecture, the two available machines are +\(lqx86\(rq, which is used for the IA\-32 and derivative 32\-bit instruction set, and +\(lqamd64\(rq, which is used for the 64\-bit instruction set. This differentiation is required to generate the proper object file for relocatable object formats such as COFF and ELF. To print a list of available machines for a given architecture to standard output, use +\(lqhelp\(rq +as +\fImachine\fR +and the given architecture using +\fB\-a \fR\fB\fIarch\fR\fR. See +\fByasm_arch\fR(7) +for more details. +.RE +.PP +\fB\-o \fR\fB\fIfilename\fR\fR or \fB\-\-objfile=\fR\fB\fIfilename\fR\fR: Specify object filename +.RS 4 +Specifies the name of the output file, overriding any default name generated by Yasm. +.RE +.PP +\fB\-p \fR\fB\fIparser\fR\fR or \fB\-\-parser=\fR\fB\fIparser\fR\fR: Select parser +.RS 4 +Selects the parser (the assembler syntax). The default parser is +\(lqnasm\(rq, which emulates the syntax of NASM, the Netwide Assembler. Another available parser is +\(lqgas\(rq, which emulates the syntax of GNU AS. To print a list of available parsers to standard output, use +\(lqhelp\(rq +as +\fIparser\fR. See +\fByasm_parsers\fR(7) +for a list of supported parsers. +.RE +.PP +\fB\-r \fR\fB\fIpreproc\fR\fR or \fB\-\-preproc=\fR\fB\fIpreproc\fR\fR: Select preprocessor +.RS 4 +Selects the preprocessor to use on the input file before passing it to the parser. Preprocessors often provide macro functionality that is not included in the main parser. The default preprocessor is +\(lqnasm\(rq, which is an imported version of the actual NASM preprocessor. A +\(lqraw\(rq +preprocessor is also available, which simply skips the preprocessing step, passing the input file directly to the parser. To print a list of available preprocessors to standard output, use +\(lqhelp\(rq +as +\fIpreproc\fR. .RE .PP \fB\-\-version\fR: Get the Yasm version .RS 4 -This option causes Yasm to prints the version number of Yasm as well as a license summary to standard output\&. All other options are ignored, and no output file is generated\&. +This option causes Yasm to prints the version number of Yasm as well as a license summary to standard output. All other options are ignored, and no output file is generated. .RE .SS "Warning Options" .PP @@ -174,71 +166,71 @@ This option causes Yasm to prints the version number of Yasm as well as a licens options have two contrary forms: \fB\-W\fR\fB\fIname\fR\fR and -\fB\-Wno\-\fR\fB\fIname\fR\fR\&. Only the non\-default forms are shown here\&. +\fB\-Wno\-\fR\fB\fIname\fR\fR. Only the non\-default forms are shown here. .PP The warning options are handled in the order given on the command line, so if \fB\-w\fR is followed by \fB\-Worphan\-labels\fR, all warnings are turned off \fIexcept\fR -for orphan\-labels\&. +for orphan\-labels. .PP \fB\-w\fR: Inhibit all warning messages .RS 4 -This option causes Yasm to inhibit all warning messages\&. As discussed above, this option may be followed by other options to re\-enable specified warnings\&. +This option causes Yasm to inhibit all warning messages. As discussed above, this option may be followed by other options to re\-enable specified warnings. .RE .PP \fB\-Werror\fR: Treat warnings as errors .RS 4 -This option causes Yasm to treat all warnings as errors\&. Normally warnings do not prevent an object file from being generated and do not result in a failure exit status from -\fByasm\fR, whereas errors do\&. This option makes warnings equivalent to errors in terms of this behavior\&. +This option causes Yasm to treat all warnings as errors. Normally warnings do not prevent an object file from being generated and do not result in a failure exit status from +\fByasm\fR, whereas errors do. This option makes warnings equivalent to errors in terms of this behavior. .RE .PP \fB\-Wno\-unrecognized\-char\fR: Do not warn on unrecognized input characters .RS 4 -Causes Yasm to not warn on unrecognized characters found in the input\&. Normally Yasm will generate a warning for any non\-ASCII character found in the input file\&. +Causes Yasm to not warn on unrecognized characters found in the input. Normally Yasm will generate a warning for any non\-ASCII character found in the input file. .RE .PP \fB\-Worphan\-labels\fR: Warn on labels lacking a trailing option .RS 4 -When using the NASM\-compatible parser, causes Yasm to warn about labels found alone on a line without a trailing colon\&. While these are legal labels in NASM syntax, they may be unintentional, due to typos or macro definition ordering\&. +When using the NASM\-compatible parser, causes Yasm to warn about labels found alone on a line without a trailing colon. While these are legal labels in NASM syntax, they may be unintentional, due to typos or macro definition ordering. .RE .PP \fB\-X \fR\fB\fIstyle\fR\fR: Change error/warning reporting style .RS 4 -Selects a specific output style for error and warning messages\&. The default is +Selects a specific output style for error and warning messages. The default is \(lqgnu\(rq style, which mimics the output of -\fBgcc\fR\&. The +\fBgcc\fR. The \(lqvc\(rq -style is also available, which mimics the output of Microsoft\'s Visual C++ compiler\&. +style is also available, which mimics the output of Microsoft's Visual C++ compiler. .sp This option is available so that Yasm integrates more naturally into IDE environments such as Visual Studio or -Emacs, allowing the IDE to correctly recognize the error/warning message as such and link back to the offending line of source code\&. +Emacs, allowing the IDE to correctly recognize the error/warning message as such and link back to the offending line of source code. .RE .SS "Preprocessor Options" .PP While these preprocessor options theoretically will affect any preprocessor, the only preprocessor currently in Yasm is the \(lqnasm\(rq -preprocessor\&. +preprocessor. .PP \fB\-D \fR\fB\fImacro[=value]\fR\fR: Pre\-define a macro .RS 4 -Pre\-defines a single\-line macro\&. The value is optional (if no value is given, the macro is still defined, but to an empty value)\&. +Pre\-defines a single\-line macro. The value is optional (if no value is given, the macro is still defined, but to an empty value). .RE .PP \fB\-e\fR or \fB\-\-preproc\-only\fR: Only preprocess .RS 4 -Stops assembly after the preprocessing stage; preprocessed output is sent to the specified output name or, if no output name is specified, the standard output\&. No object file is produced\&. +Stops assembly after the preprocessing stage; preprocessed output is sent to the specified output name or, if no output name is specified, the standard output. No object file is produced. .RE .PP \fB\-I \fR\fB\fIpath\fR\fR: Add include file path .RS 4 Adds directory \fIpath\fR -to the search path for include files\&. The search path defaults to only including the directory in which the source file resides\&. +to the search path for include files. The search path defaults to only including the directory in which the source file resides. .RE .PP \fB\-P \fR\fB\fIfilename\fR\fR: Pre\-include a file @@ -246,77 +238,65 @@ to the search path for include files\&. The search path defaults to only includi Pre\-includes file \fIfilename\fR, making it look as though \fIfilename\fR -was prepended to the input\&. Can be useful for prepending multi\-line macros that the +was prepended to the input. Can be useful for prepending multi\-line macros that the \fB\-D\fR -can\'t support\&. +can't support. .RE .PP \fB\-U \fR\fB\fImacro\fR\fR: Undefine a macro .RS 4 Undefines a single\-line macro (may be either a built\-in macro or one defined earlier in the command line with -\fB\-D\fR\&. +\fB\-D\fR. .RE .SH "EXAMPLES" .PP To assemble NASM syntax, 32\-bit x86 source -source\&.asm +\fIsource.asm\fR into ELF file -source\&.o, warning on orphan labels: +\fIsource.o\fR, warning on orphan labels: .sp -.if n \{\ .RS 4 -.\} .nf -yasm \-f elf32 \-Worphan\-labels source\&.asm +yasm \-f elf32 \-Worphan\-labels source.asm .fi -.if n \{\ .RE -.\} .PP To assemble NASM syntax AMD64 source -x\&.asm +\fIx.asm\fR into Win64 file -object\&.obj: +\fIobject.obj\fR: .sp -.if n \{\ .RS 4 -.\} .nf -yasm \-f win64 \-o object\&.obj x\&.asm +yasm \-f win64 \-o object.obj x.asm .fi -.if n \{\ .RE -.\} .PP To assemble already preprocessed NASM syntax x86 source -y\&.asm +\fIy.asm\fR into flat binary file -y\&.com: +\fIy.com\fR: .sp -.if n \{\ .RS 4 -.\} .nf -yasm \-f bin \-r raw \-o y\&.com y\&.asm +yasm \-f bin \-r raw \-o y.com y.asm .fi -.if n \{\ .RE -.\} .SH "DIAGNOSTICS" .PP The \fByasm\fR -command exits 0 on success, and nonzero if an error occurs\&. +command exits 0 on success, and nonzero if an error occurs. .SH "COMPATIBILITY" .PP -Yasm\'s NASM parser and preprocessor, while they strive to be as compatible as possible with NASM, have a few incompatibilities due to YASM\'s different internal structure\&. +Yasm's NASM parser and preprocessor, while they strive to be as compatible as possible with NASM, have a few incompatibilities due to YASM's different internal structure. .PP -Yasm\'s GAS parser and preprocessor are missing a number of features present in GNU AS\&. +Yasm's GAS parser and preprocessor are missing a number of features present in GNU AS. .SH "RESTRICTIONS" .PP -As object files are often architecture and machine dependent, not all combinations of object formats, architectures, and machines are legal; trying to use an invalid combination will result in an error\&. +As object files are often architecture and machine dependent, not all combinations of object formats, architectures, and machines are legal; trying to use an invalid combination will result in an error. .PP -There is no support for symbol maps\&. +There is no support for symbol maps. .SH "SEE ALSO" .PP \fByasm_arch\fR(7), @@ -336,14 +316,14 @@ architecture, it is overly easy to generate AMD64 code (using the \fBBITS 64\fR directive) and generate a 32\-bit object file (by failing to specify \fB\-m amd64\fR -or selecting a 64\-bit object format such as ELF64 on the command line)\&. +or selecting a 64\-bit object format such as ELF64 on the command line). .SH "AUTHOR" .PP -\fBPeter Johnson\fR <\&peter@tortall\&.net\&> -.RS 4 +\fBPeter Johnson\fR <\&peter@tortall.net\&> +.sp -1n +.IP "" 4 Author. -.RE .SH "COPYRIGHT" -.br Copyright \(co 2004, 2005, 2006, 2007 Peter Johnson .br + diff --git a/yasm_arch.7 b/yasm_arch.7 index ccdfd056..dd329c5b 100644 --- a/yasm_arch.7 +++ b/yasm_arch.7 @@ -1,40 +1,23 @@ -'\" t .\" Title: yasm_arch .\" Author: Peter Johnson -.\" Generator: DocBook XSL Stylesheets v1.76.1 +.\" Generator: DocBook XSL Stylesheets v1.70.1 .\" Date: October 2006 .\" Manual: Yasm Supported Architectures .\" Source: Yasm -.\" Language: English .\" .TH "YASM_ARCH" "7" "October 2006" "Yasm" "Yasm Supported Architectures" -.\" ----------------------------------------------------------------- -.\" * Define some portability stuff -.\" ----------------------------------------------------------------- -.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -.\" http://bugs.debian.org/507673 -.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html -.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -.ie \n(.g .ds Aq \(aq -.el .ds Aq ' -.\" ----------------------------------------------------------------- -.\" * set default formatting -.\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l -.\" ----------------------------------------------------------------- -.\" * MAIN CONTENT STARTS HERE * -.\" ----------------------------------------------------------------- .SH "NAME" yasm_arch \- Yasm Supported Target Architectures .SH "SYNOPSIS" -.HP \w'\fByasm\fR\ 'u -\fByasm\fR \fB\-a\ \fR\fB\fIarch\fR\fR [\fB\-m\ \fR\fB\fImachine\fR\fR] \fB\fI\&.\&.\&.\fR\fR +.HP 5 +\fByasm\fR \fB\-a\ \fR\fB\fIarch\fR\fR [\fB\-m\ \fR\fB\fImachine\fR\fR] \fB\fI...\fR\fR .SH "DESCRIPTION" .PP -The standard Yasm distribution includes a number of modules for different target architectures\&. Each target architecture can support one or more machine architectures\&. +The standard Yasm distribution includes a number of modules for different target architectures. Each target architecture can support one or more machine architectures. .PP The architecture and machine are selected on the \fByasm\fR(1) @@ -42,9 +25,9 @@ command line by use of the \fB\-a \fR\fB\fIarch\fR\fR and \fB\-m \fR\fB\fImachine\fR\fR -command line options, respectively\&. +command line options, respectively. .PP -The machine architecture may also automatically be selected by certain object formats\&. For example, the +The machine architecture may also automatically be selected by certain object formats. For example, the \(lqelf32\(rq object format selects the \(lqx86\(rq @@ -52,787 +35,318 @@ machine architecture by default, while the \(lqelf64\(rq object format selects the \(lqamd64\(rq -machine architecture by default\&. +machine architecture by default. .SH "X86 ARCHITECTURE" .PP The \(lqx86\(rq -architecture supports the IA\-32 instruction set and derivatives and the AMD64 instruction set\&. It consists of two machines: +architecture supports the IA\-32 instruction set and derivatives and the AMD64 instruction set. It consists of two machines: \(lqx86\(rq (for the IA\-32 and derivatives) and \(lqamd64\(rq -(for the AMD64 and derivatives)\&. The default machine for the +(for the AMD64 and derivatives). The default machine for the \(lqx86\(rq architecture is the \(lqx86\(rq -machine\&. +machine. .SS "BITS Setting" .PP -The x86 architecture BITS setting specifies to Yasm the processor mode in which the generated code is intended to execute\&. x86 processors can run in three different major execution modes: 16\-bit, 32\-bit, and on AMD64\-supporting processors, 64\-bit\&. As the x86 instruction set contains portions whose function is execution\-mode dependent (such as operand\-size and address\-size override prefixes), Yasm cannot assemble x86 instructions correctly unless it is told by the user in what processor mode the code will execute\&. +The x86 architecture BITS setting specifies to Yasm the processor mode in which the generated code is intended to execute. x86 processors can run in three different major execution modes: 16\-bit, 32\-bit, and on AMD64\-supporting processors, 64\-bit. As the x86 instruction set contains portions whose function is execution\-mode dependent (such as operand\-size and address\-size override prefixes), Yasm cannot assemble x86 instructions correctly unless it is told by the user in what processor mode the code will execute. .PP -The BITS setting can be changed in a variety of ways\&. When using the NASM\-compatible parser, the BITS setting can be changed directly via the use of the +The BITS setting can be changed in a variety of ways. When using the NASM\-compatible parser, the BITS setting can be changed directly via the use of the \fBBITS xx\fR -assembler directive\&. The default BITS setting is determined by the object format in use\&. +assembler directive. The default BITS setting is determined by the object format in use. +.\" end of SS subsection "BITS Setting" .SS "BITS 64 Extensions" .PP -The AMD64 architecture is a new 64\-bit architecture developed by AMD, based on the 32\-bit x86 architecture\&. It extends the original x86 architecture by doubling the number of general purpose and SIMD registers, extending the arithmetic operations and address space to 64 bits, as well as other features\&. +The AMD64 architecture is a new 64\-bit architecture developed by AMD, based on the 32\-bit x86 architecture. It extends the original x86 architecture by doubling the number of general purpose and SIMD registers, extending the arithmetic operations and address space to 64 bits, as well as other features. .PP -Recently, Intel has introduced an essentially identical version of AMD64 called EM64T\&. +Recently, Intel has introduced an essentially identical version of AMD64 called EM64T. .PP -When an AMD64\-supporting processor is executing in 64\-bit mode, a number of additional extensions are available, including extra general purpose registers, extra SSE2 registers, and RIP\-relative addressing\&. +When an AMD64\-supporting processor is executing in 64\-bit mode, a number of additional extensions are available, including extra general purpose registers, extra SSE2 registers, and RIP\-relative addressing. .PP -Yasm extends the base NASM syntax to support AMD64 as follows\&. To enable assembly of instructions for the 64\-bit mode of AMD64 processors, use the directive -\fBBITS 64\fR\&. As with NASM\*(Aqs BITS directive, this does not change the format of the output object file to 64 bits; it only changes the assembler mode to assume that the instructions being assembled will be run in 64\-bit mode\&. To specify an AMD64 object file, use +Yasm extends the base NASM syntax to support AMD64 as follows. To enable assembly of instructions for the 64\-bit mode of AMD64 processors, use the directive +\fBBITS 64\fR. As with NASM's BITS directive, this does not change the format of the output object file to 64 bits; it only changes the assembler mode to assume that the instructions being assembled will be run in 64\-bit mode. To specify an AMD64 object file, use \fB\-m amd64\fR on the Yasm command line, or explicitly target a 64\-bit object format such as \fB\-f win64\fR or -\fB\-f elf64\fR\&. -\fB\-f elfx32\fR -can be used to select 32\-bit ELF object format for AMD64 processors\&. +\fB\-f elf64\fR. .sp .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br -.ps +1 \fBRegister Changes\fR -.RS 4 +.RS .PP -The additional 64\-bit general purpose registers are named r8\-r15\&. There are also 8\-bit (rXb), 16\-bit (rXw), and 32\-bit (rXd) subregisters that map to the least significant 8, 16, or 32 bits of the 64\-bit register\&. The original 8 general purpose registers have also been extended to 64\-bits: eax, edx, ecx, ebx, esi, edi, esp, and ebp have new 64\-bit versions called rax, rdx, rcx, rbx, rsi, rdi, rsp, and rbp respectively\&. The old 32\-bit registers map to the least significant bits of the new 64\-bit registers\&. +The additional 64\-bit general purpose registers are named r8\-r15. There are also 8\-bit (rXb), 16\-bit (rXw), and 32\-bit (rXd) subregisters that map to the least significant 8, 16, or 32 bits of the 64\-bit register. The original 8 general purpose registers have also been extended to 64\-bits: eax, edx, ecx, ebx, esi, edi, esp, and ebp have new 64\-bit versions called rax, rdx, rcx, rbx, rsi, rdi, rsp, and rbp respectively. The old 32\-bit registers map to the least significant bits of the new 64\-bit registers. .PP -New 8\-bit registers are also available that map to the 8 least significant bits of rsi, rdi, rsp, and rbp\&. These are called sil, dil, spl, and bpl respectively\&. Unfortunately, due to the way instructions are encoded, these new 8\-bit registers are encoded the same as the old 8\-bit registers ah, dh, ch, and bh\&. The processor tells which is being used by the presence of the new REX prefix that is used to specify the other extended registers\&. This means it is illegal to mix the use of ah, dh, ch, and bh with an instruction that requires the REX prefix for other reasons\&. For instance: +New 8\-bit registers are also available that map to the 8 least significant bits of rsi, rdi, rsp, and rbp. These are called sil, dil, spl, and bpl respectively. Unfortunately, due to the way instructions are encoded, these new 8\-bit registers are encoded the same as the old 8\-bit registers ah, dh, ch, and bh. The processor tells which is being used by the presence of the new REX prefix that is used to specify the other extended registers. This means it is illegal to mix the use of ah, dh, ch, and bh with an instruction that requires the REX prefix for other reasons. For instance: .sp -.if n \{\ -.RS 4 -.\} +.RS 3n .nf add ah, [r10] .fi -.if n \{\ .RE -.\} .PP -(NASM syntax) is not a legal instruction because the use of r10 requires a REX prefix, making it impossible to use ah\&. +(NASM syntax) is not a legal instruction because the use of r10 requires a REX prefix, making it impossible to use ah. .PP -In 64\-bit mode, an additional 8 SSE2 registers are also available\&. These are named xmm8\-xmm15\&. +In 64\-bit mode, an additional 8 SSE2 registers are also available. These are named xmm8\-xmm15. .RE +.\" end of subsection "Register Changes" .sp .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br -.ps +1 \fB64 Bit Instructions\fR -.RS 4 +.RS .PP -By default, most operations in 64\-bit mode remain 32\-bit; operations that are 64\-bit usually require a REX prefix (one bit in the REX prefix determines whether an operation is 64\-bit or 32\-bit)\&. Thus, essentially all 32\-bit instructions have a 64\-bit version, and the 64\-bit versions of instructions can use extended registers +By default, most operations in 64\-bit mode remain 32\-bit; operations that are 64\-bit usually require a REX prefix (one bit in the REX prefix determines whether an operation is 64\-bit or 32\-bit). Thus, essentially all 32\-bit instructions have a 64\-bit version, and the 64\-bit versions of instructions can use extended registers \(lqfor free\(rq -(as the REX prefix is already present)\&. Examples in NASM syntax: +(as the REX prefix is already present). Examples in NASM syntax: .sp -.if n \{\ -.RS 4 -.\} +.RS 3n .nf mov eax, 1 ; 32\-bit instruction .fi -.if n \{\ .RE -.\} .sp -.if n \{\ -.RS 4 -.\} +.RS 3n .nf mov rcx, 1 ; 64\-bit instruction .fi -.if n \{\ .RE -.\} .PP -Instructions that modify the stack (push, pop, call, ret, enter, and leave) are implicitly 64\-bit\&. Their 32\-bit counterparts are not available, but their 16\-bit counterparts are\&. Examples in NASM syntax: +Instructions that modify the stack (push, pop, call, ret, enter, and leave) are implicitly 64\-bit. Their 32\-bit counterparts are not available, but their 16\-bit counterparts are. Examples in NASM syntax: .sp -.if n \{\ -.RS 4 -.\} +.RS 3n .nf push eax ; illegal instruction .fi -.if n \{\ .RE -.\} .sp -.if n \{\ -.RS 4 -.\} +.RS 3n .nf push rbx ; 1\-byte instruction .fi -.if n \{\ .RE -.\} .sp -.if n \{\ -.RS 4 -.\} +.RS 3n .nf push r11 ; 2\-byte instruction with REX prefix .fi -.if n \{\ .RE -.\} .RE +.\" end of subsection "64 Bit Instructions" .sp .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br -.ps +1 \fBImplicit Zero Extension\fR -.RS 4 +.RS .PP -Results of 32\-bit operations are implicitly zero\-extended to the upper 32 bits of the corresponding 64\-bit register\&. 16 and 8 bit operations, on the other hand, do not affect upper bits of the register (just as in 32\-bit and 16\-bit modes)\&. This can be used to generate smaller code in some instances\&. Examples in NASM syntax: +Results of 32\-bit operations are implicitly zero\-extended to the upper 32 bits of the corresponding 64\-bit register. 16 and 8 bit operations, on the other hand, do not affect upper bits of the register (just as in 32\-bit and 16\-bit modes). This can be used to generate smaller code in some instances. Examples in NASM syntax: .sp -.if n \{\ -.RS 4 -.\} +.RS 3n .nf mov ecx, 1 ; 1 byte shorter than mov rcx, 1 .fi -.if n \{\ .RE -.\} .sp -.if n \{\ -.RS 4 -.\} +.RS 3n .nf and edx, 3 ; equivalent to and rdx, 3 .fi -.if n \{\ .RE -.\} .RE +.\" end of subsection "Implicit Zero Extension" .sp .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br -.ps +1 \fBImmediates\fR -.RS 4 +.RS .PP -For most instructions in 64\-bit mode, immediate values remain 32 bits; their value is sign\-extended into the upper 32 bits of the target register prior to being used\&. The exception is the mov instruction, which can take a 64\-bit immediate when the destination is a 64\-bit register\&. Examples in NASM syntax: +For most instructions in 64\-bit mode, immediate values remain 32 bits; their value is sign\-extended into the upper 32 bits of the target register prior to being used. The exception is the mov instruction, which can take a 64\-bit immediate when the destination is a 64\-bit register. Examples in NASM syntax: .sp -.if n \{\ -.RS 4 -.\} +.RS 3n .nf add rax, 1 ; optimized down to signed 8\-bit .fi -.if n \{\ .RE -.\} .sp -.if n \{\ -.RS 4 -.\} +.RS 3n .nf add rax, dword 1 ; force size to 32\-bit .fi -.if n \{\ .RE -.\} .sp -.if n \{\ -.RS 4 -.\} +.RS 3n .nf add rax, 0xffffffff ; sign\-extended 32\-bit .fi -.if n \{\ .RE -.\} .sp -.if n \{\ -.RS 4 -.\} +.RS 3n .nf add rax, \-1 ; same as above .fi -.if n \{\ .RE -.\} .sp -.if n \{\ -.RS 4 -.\} +.RS 3n .nf add rax, 0xffffffffffffffff ; truncated to 32\-bit (warning) .fi -.if n \{\ .RE -.\} .sp -.if n \{\ -.RS 4 -.\} +.RS 3n .nf mov eax, 1 ; 5 byte .fi -.if n \{\ .RE -.\} .sp -.if n \{\ -.RS 4 -.\} +.RS 3n .nf mov rax, 1 ; 5 byte (optimized to signed 32\-bit) .fi -.if n \{\ .RE -.\} .sp -.if n \{\ -.RS 4 -.\} +.RS 3n .nf mov rax, qword 1 ; 10 byte (forced 64\-bit) .fi -.if n \{\ .RE -.\} .sp -.if n \{\ -.RS 4 -.\} +.RS 3n .nf mov rbx, 0x1234567890abcdef ; 10 byte .fi -.if n \{\ .RE -.\} .sp -.if n \{\ -.RS 4 -.\} +.RS 3n .nf mov rcx, 0xffffffff ; 10 byte (does not fit in signed 32\-bit) .fi -.if n \{\ .RE -.\} .sp -.if n \{\ -.RS 4 -.\} +.RS 3n .nf mov ecx, \-1 ; 5 byte, equivalent to above .fi -.if n \{\ .RE -.\} .sp -.if n \{\ -.RS 4 -.\} +.RS 3n .nf mov rcx, sym ; 5 byte, 32\-bit size default for symbols .fi -.if n \{\ .RE -.\} .sp -.if n \{\ -.RS 4 -.\} +.RS 3n .nf mov rcx, qword sym ; 10 byte, override default size .fi -.if n \{\ .RE -.\} -.PP -The handling of mov reg64, unsized immediate is different between YASM and NASM 2\&.x; YASM follows the above behavior, while NASM 2\&.x does the following: -.sp -.if n \{\ -.RS 4 -.\} -.nf -add rax, 0xffffffff ; sign\-extended 32\-bit immediate -.fi -.if n \{\ -.RE -.\} -.sp -.if n \{\ -.RS 4 -.\} -.nf -add rax, \-1 ; same as above -.fi -.if n \{\ -.RE -.\} -.sp -.if n \{\ -.RS 4 -.\} -.nf -add rax, 0xffffffffffffffff ; truncated 32\-bit (warning) -.fi -.if n \{\ -.RE -.\} -.sp -.if n \{\ -.RS 4 -.\} -.nf -add rax, sym ; sign\-extended 32\-bit immediate -.fi -.if n \{\ -.RE -.\} -.sp -.if n \{\ -.RS 4 -.\} -.nf -mov eax, 1 ; 5 byte (32\-bit immediate) -.fi -.if n \{\ -.RE -.\} -.sp -.if n \{\ -.RS 4 -.\} -.nf -mov rax, 1 ; 10 byte (64\-bit immediate) -.fi -.if n \{\ -.RE -.\} -.sp -.if n \{\ -.RS 4 -.\} -.nf -mov rbx, 0x1234567890abcdef ; 10 byte instruction -.fi -.if n \{\ -.RE -.\} -.sp -.if n \{\ -.RS 4 -.\} -.nf -mov rcx, 0xffffffff ; 10 byte instruction -.fi -.if n \{\ -.RE -.\} -.sp -.if n \{\ -.RS 4 -.\} -.nf -mov ecx, \-1 ; 5 byte, equivalent to above -.fi -.if n \{\ -.RE -.\} -.sp -.if n \{\ -.RS 4 -.\} -.nf -mov ecx, sym ; 5 byte (32\-bit immediate) -.fi -.if n \{\ -.RE -.\} -.sp -.if n \{\ -.RS 4 -.\} -.nf -mov rcx, sym ; 10 byte instruction -.fi -.if n \{\ -.RE -.\} -.sp -.if n \{\ -.RS 4 -.\} -.nf -mov rcx, qword sym ; 10 byte (64\-bit immediate) -.fi -.if n \{\ -.RE -.\} .RE +.\" end of subsection "Immediates" .sp .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br -.ps +1 \fBDisplacements\fR -.RS 4 +.RS .PP -Just like immediates, displacements, for the most part, remain 32 bits and are sign extended prior to use\&. Again, the exception is one restricted form of the mov instruction: between the al/ax/eax/rax register and a 64\-bit absolute address (no registers allowed in the effective address)\&. In NASM syntax, use of the 64\-bit absolute form requires -\fB[qword]\fR\&. Examples in NASM syntax: +Just like immediates, displacements, for the most part, remain 32 bits and are sign extended prior to use. Again, the exception is one restricted form of the mov instruction: between the al/ax/eax/rax register and a 64\-bit absolute address (no registers allowed in the effective address). In NASM syntax, use of the 64\-bit absolute form requires +\fB[qword]\fR. Examples in NASM syntax: .sp -.if n \{\ -.RS 4 -.\} +.RS 3n .nf mov eax, [1] ; 32 bit, with sign extension .fi -.if n \{\ .RE -.\} .sp -.if n \{\ -.RS 4 -.\} +.RS 3n .nf mov al, [rax\-1] ; 32 bit, with sign extension .fi -.if n \{\ .RE -.\} .sp -.if n \{\ -.RS 4 -.\} +.RS 3n .nf mov al, [qword 0x1122334455667788] ; 64\-bit absolute .fi -.if n \{\ .RE -.\} .sp -.if n \{\ -.RS 4 -.\} +.RS 3n .nf mov al, [0x1122334455667788] ; truncated to 32\-bit (warning) .fi -.if n \{\ .RE -.\} .RE +.\" end of subsection "Displacements" .sp .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br -.ps +1 \fBRIP Relative Addressing\fR -.RS 4 +.RS .PP -In 64\-bit mode, a new form of effective addressing is available to make it easier to write position\-independent code\&. Any memory reference may be made RIP relative (RIP is the instruction pointer register, which contains the address of the location immediately following the current instruction)\&. +In 64\-bit mode, a new form of effective addressing is available to make it easier to write position\-independent code. Any memory reference may be made RIP relative (RIP is the instruction pointer register, which contains the address of the location immediately following the current instruction). .PP In NASM syntax, there are two ways to specify RIP\-relative addressing: .sp -.if n \{\ -.RS 4 -.\} +.RS 3n .nf mov dword [rip+10], 1 .fi -.if n \{\ .RE -.\} .PP -stores the value 1 ten bytes after the end of the instruction\&. +stores the value 1 ten bytes after the end of the instruction. \fB10\fR -can also be a symbolic constant, and will be treated the same way\&. On the other hand, +can also be a symbolic constant, and will be treated the same way. On the other hand, .sp -.if n \{\ -.RS 4 -.\} +.RS 3n .nf mov dword [symb wrt rip], 1 .fi -.if n \{\ .RE -.\} .PP stores the value 1 into the address of symbol -\fBsymb\fR\&. This is distinctly different than the behavior of: +\fBsymb\fR. This is distinctly different than the behavior of: .sp -.if n \{\ -.RS 4 -.\} +.RS 3n .nf mov dword [symb+rip], 1 .fi -.if n \{\ .RE -.\} .PP which takes the address of the end of the instruction, adds the address of \fBsymb\fR -to it, then stores the value 1 there\&. If +to it, then stores the value 1 there. If \fBsymb\fR is a variable, this will \fInot\fR store the value 1 into the \fBsymb\fR variable! -.PP -Yasm also supports the following syntax for RIP\-relative addressing: -.sp -.if n \{\ -.RS 4 -.\} -.nf -mov [rel sym], rax ; RIP\-relative -.fi -.if n \{\ -.RE -.\} -.sp -.if n \{\ -.RS 4 -.\} -.nf -mov [abs sym], rax ; not RIP\-relative -.fi -.if n \{\ -.RE -.\} -.PP -The behavior of: -.sp -.if n \{\ -.RS 4 -.\} -.nf -mov [sym], rax -.fi -.if n \{\ -.RE -.\} -.PP -Depends on a mode set by the DEFAULT directive, as follows\&. The default mode is always "abs", and in "rel" mode, use of registers, an fs or gs segment override, or an explicit "abs" override will result in a non\-RIP\-relative effective address\&. -.sp -.if n \{\ -.RS 4 -.\} -.nf -default rel -.fi -.if n \{\ -.RE -.\} -.sp -.if n \{\ -.RS 4 -.\} -.nf -mov [sym], rbx ; RIP\-relative -.fi -.if n \{\ -.RE -.\} -.sp -.if n \{\ -.RS 4 -.\} -.nf -mov [abs sym], rbx ; not RIP\-relative (explicit override) -.fi -.if n \{\ -.RE -.\} -.sp -.if n \{\ -.RS 4 -.\} -.nf -mov [rbx+1], rbx ; not RIP\-relative (register use) -.fi -.if n \{\ -.RE -.\} -.sp -.if n \{\ -.RS 4 -.\} -.nf -mov [fs:sym], rbx ; not RIP\-relative (fs or gs use) -.fi -.if n \{\ -.RE -.\} -.sp -.if n \{\ -.RS 4 -.\} -.nf -mov [ds:sym], rbx ; RIP\-relative (segment, but not fs or gs) -.fi -.if n \{\ -.RE -.\} -.sp -.if n \{\ -.RS 4 -.\} -.nf -mov [rel sym], rbx ; RIP\-relative (redundant override) -.fi -.if n \{\ -.RE -.\} -.sp -.if n \{\ -.RS 4 -.\} -.nf -default abs -.fi -.if n \{\ -.RE -.\} -.sp -.if n \{\ -.RS 4 -.\} -.nf -mov [sym], rbx ; not RIP\-relative -.fi -.if n \{\ -.RE -.\} -.sp -.if n \{\ -.RS 4 -.\} -.nf -mov [abs sym], rbx ; not RIP\-relative -.fi -.if n \{\ -.RE -.\} -.sp -.if n \{\ -.RS 4 -.\} -.nf -mov [rbx+1], rbx ; not RIP\-relative -.fi -.if n \{\ -.RE -.\} -.sp -.if n \{\ -.RS 4 -.\} -.nf -mov [fs:sym], rbx ; not RIP\-relative -.fi -.if n \{\ -.RE -.\} -.sp -.if n \{\ -.RS 4 -.\} -.nf -mov [ds:sym], rbx ; not RIP\-relative -.fi -.if n \{\ -.RE -.\} -.sp -.if n \{\ -.RS 4 -.\} -.nf -mov [rel sym], rbx ; RIP\-relative (explicit override) -.fi -.if n \{\ -.RE -.\} -.RE -.sp -.it 1 an-trap -.nr an-no-space-flag 1 -.nr an-break-flag 1 -.br -.ps +1 -\fBMemory references\fR -.RS 4 -.PP -Usually the size of a memory reference can be deduced by which registers you\*(Aqre moving\-\-for example, "mov [rax],ecx" is a 32\-bit move, because ecx is 32 bits\&. YASM currently gives the non\-obvious "invalid combination of opcode and operands" error if it can\*(Aqt figure out how much memory you\*(Aqre moving\&. The fix in this case is to add a memory size specifier: qword, dword, word, or byte\&. -.PP -Here\*(Aqs a 64\-bit memory move, which sets 8 bytes starting at rax: -.sp -.if n \{\ -.RS 4 -.\} -.nf -mov qword [rax], 1 -.fi -.if n \{\ -.RE -.\} -.PP -Here\*(Aqs a 32\-bit memory move, which sets 4 bytes: -.sp -.if n \{\ -.RS 4 -.\} -.nf -mov dword [rax], 1 -.fi -.if n \{\ -.RE -.\} -.PP -Here\*(Aqs a 16\-bit memory move, which sets 2 bytes: -.sp -.if n \{\ -.RS 4 -.\} -.nf -mov word [rax], 1 -.fi -.if n \{\ -.RE -.\} -.PP -Here\*(Aqs an 8\-bit memory move, which sets 1 byte: -.sp -.if n \{\ -.RS 4 -.\} -.nf -mov byte [rax], 1 -.fi -.if n \{\ -.RE -.\} .RE +.\" end of subsection "RIP Relative Addressing" +.\" end of SS subsection "BITS 64 Extensions" .SH "LC3B ARCHITECTURE" .PP The \(lqlc3b\(rq -architecture supports the LC\-3b ISA as used in the ECE 312 (now ECE 411) course at the University of Illinois, Urbana\-Champaign, as well as other university courses\&. See -\m[blue]\fB\%http://courses.ece.uiuc.edu/ece411/\fR\m[] -for more details and example code\&. The +architecture supports the LC\-3b ISA as used in the ECE 312 (now ECE 411) course at the University of Illinois, Urbana\-Champaign, as well as other university courses. See +\fI\%http://courses.ece.uiuc.edu/ece411/\fR +for more details and example code. The \(lqlc3b\(rq architecture consists of only one machine: -\(lqlc3b\(rq\&. +\(lqlc3b\(rq. .SH "SEE ALSO" .PP \fByasm\fR(1) @@ -844,17 +358,15 @@ architecture, it is overly easy to generate AMD64 code (using the \fBBITS 64\fR directive) and generate a 32\-bit object file (by failing to specify \fB\-m amd64\fR -on the command line or selecting a 64\-bit object format)\&. Similarly, specifying +on the command line or selecting a 64\-bit object format). Similarly, specifying \fB\-m amd64\fR -does not default the BITS setting to 64\&. An easy way to avoid this is by directly specifying a 64\-bit object format such as -\fB\-f elf64\fR\&. +does not default the BITS setting to 64. An easy way to avoid this is by directly specifying a 64\-bit object format such as +\fB\-f elf64\fR. .SH "AUTHOR" .PP -\fBPeter Johnson\fR <\&peter@tortall\&.net\&> -.RS 4 +\fBPeter\fR \fBJohnson\fR +.sp -1n +.IP "" 3n Author. -.RE .SH "COPYRIGHT" -.br -Copyright \(co 2004, 2005, 2006, 2007 Peter Johnson -.br +Copyright \(co 2004, 2005, 2006 Peter Johnson diff --git a/yasm_dbgfmts.7 b/yasm_dbgfmts.7 index aed28823..2227d8cf 100644 --- a/yasm_dbgfmts.7 +++ b/yasm_dbgfmts.7 @@ -1,63 +1,53 @@ -'\" t .\" Title: yasm_dbgfmts .\" Author: Peter Johnson -.\" Generator: DocBook XSL Stylesheets v1.75.2 +.\" Generator: DocBook XSL Stylesheets v1.70.1 .\" Date: October 2006 .\" Manual: Yasm Supported Debug Formats .\" Source: Yasm -.\" Language: English .\" .TH "YASM_DBGFMTS" "7" "October 2006" "Yasm" "Yasm Supported Debug Formats" -.\" ----------------------------------------------------------------- -.\" * set default formatting -.\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l -.\" ----------------------------------------------------------------- -.\" * MAIN CONTENT STARTS HERE * -.\" ----------------------------------------------------------------- .SH "NAME" yasm_dbgfmts \- Yasm Supported Debugging Formats .SH "SYNOPSIS" -.HP \w'\fByasm\fR\ 'u -\fByasm\fR \fB\-g\ \fR\fB\fIdbgfmt\fR\fR \fB\fI\&.\&.\&.\fR\fR +.HP 5 +\fByasm\fR \fB\-g\ \fR\fB\fIdbgfmt\fR\fR \fB\fI...\fR\fR .SH "DESCRIPTION" .PP -The standard Yasm distribution includes a number of modules for different debugging formats\&. The debugging information is embedded into the object file\&. Use of a non\-\(lqnull\(rq -debug format also causes Yasm to output all symbols to the object file (including local symbols)\&. +The standard Yasm distribution includes a number of modules for different debugging formats. The debugging information is embedded into the object file. Use of a non\-\(lqnull\(rq +debug format also causes Yasm to output all symbols to the object file (including local symbols). .PP The debug format is selected on the \fByasm\fR(1) command line by use of the \fB\-g \fR\fB\fIdbgfmt\fR\fR -command line option\&. +command line option. .SH "CV8" .PP -The CV8 debug format is used by Microsoft Visual Studio 2005 (version 8\&.0) and is completely undocumented, although it bears strong similarities to earlier CodeView formats\&. Yasm\'s support for the CV8 debug format is currently limited to generating assembly\-level line number information (to allow some level of source\-level debugging)\&. The CV8 debug information is stored in the \&.debug$S and \&.debug$T sections of the Win64 object file\&. +The CV8 debug format is used by Microsoft Visual Studio 2005 (version 8.0) and is completely undocumented, although it bears strong similarities to earlier CodeView formats. Yasm's support for the CV8 debug format is currently limited to generating assembly\-level line number information (to allow some level of source\-level debugging). The CV8 debug information is stored in the .debug$S and .debug$T sections of the Win64 object file. .SH "DWARF2" .PP -The DWARF 2 debug format is a complex, well\-documented standard for debugging information\&. It was created to overcome shortcomings in STABS, allowing for much more detailed and compact descriptions of data structures, data variable movement, and complex language structures such as in C++\&. The debugging information is stored in sections (just like normal program sections) in the object file\&. Yasm supports full pass\-through of DWARF2 debugging information (e\&.g\&. from a C++ compiler), and can also generate assembly\-level line number information\&. +The DWARF 2 debug format is a complex, well\-documented standard for debugging information. It was created to overcome shortcomings in STABS, allowing for much more detailed and compact descriptions of data structures, data variable movement, and complex language structures such as in C++. The debugging information is stored in sections (just like normal program sections) in the object file. Yasm supports full pass\-through of DWARF2 debugging information (e.g. from a C++ compiler), and can also generate assembly\-level line number information. .SH "NULL" .PP The \(lqnull\(rq -debug format is a placeholder; it adds no debugging information to the output file\&. +debug format is a placeholder; it adds no debugging information to the output file. .SH "STABS" .PP -The STABS debug format is a poorly documented, semi\-standard format for debugging information in COFF and ELF object files\&. The debugging information is stored as part of the object file\'s symbol table and thus is limited in complexity and scope\&. Despite this, STABS is a common debugging format on older Unix and compatible systems, as well as DJGPP\&. +The STABS debug format is a poorly documented, semi\-standard format for debugging information in COFF and ELF object files. The debugging information is stored as part of the object file's symbol table and thus is limited in complexity and scope. Despite this, STABS is a common debugging format on older Unix and compatible systems, as well as DJGPP. .SH "SEE ALSO" .PP \fByasm\fR(1), \fByasm_objfmts\fR(7) .SH "AUTHOR" .PP -\fBPeter Johnson\fR <\&peter@tortall\&.net\&> -.RS 4 +\fBPeter\fR \fBJohnson\fR +.sp -1n +.IP "" 3n Author. -.RE .SH "COPYRIGHT" -.br Copyright \(co 2006 Peter Johnson -.br diff --git a/yasm_objfmts.7 b/yasm_objfmts.7 index bc649860..9825c0ac 100644 --- a/yasm_objfmts.7 +++ b/yasm_objfmts.7 @@ -1,102 +1,81 @@ -'\" t .\" Title: yasm_objfmts .\" Author: Peter Johnson -.\" Generator: DocBook XSL Stylesheets v1.76.1 +.\" Generator: DocBook XSL Stylesheets v1.70.1 .\" Date: February 2007 .\" Manual: Yasm Supported Object Formats .\" Source: Yasm -.\" Language: English .\" .TH "YASM_OBJFMTS" "7" "February 2007" "Yasm" "Yasm Supported Object Formats" -.\" ----------------------------------------------------------------- -.\" * Define some portability stuff -.\" ----------------------------------------------------------------- -.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -.\" http://bugs.debian.org/507673 -.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html -.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -.ie \n(.g .ds Aq \(aq -.el .ds Aq ' -.\" ----------------------------------------------------------------- -.\" * set default formatting -.\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l -.\" ----------------------------------------------------------------- -.\" * MAIN CONTENT STARTS HERE * -.\" ----------------------------------------------------------------- .SH "NAME" yasm_objfmts \- Yasm Supported Object Formats .SH "SYNOPSIS" -.HP \w'\fByasm\fR\ 'u -\fByasm\fR \fB\-f\ \fR\fB\fIobjfmt\fR\fR \fB\fI\&.\&.\&.\fR\fR +.HP 5 +\fByasm\fR \fB\-f\ \fR\fB\fIobjfmt\fR\fR \fB\fI...\fR\fR .SH "DESCRIPTION" .PP -The standard Yasm distribution includes a number of modules for different object formats (Yasm\*(Aqs primary output)\&. +The standard Yasm distribution includes a number of modules for different object formats (Yasm's primary output). .PP The object format is selected on the \fByasm\fR(1) command line by use of the \fB\-f \fR\fB\fIobjfmt\fR\fR -command line option\&. +command line option. .SH "BIN" .PP The \(lqbin\(rq -object format produces a flat\-format, non\-relocatable binary file\&. It is appropriate for producing DOS \&.COM executables or things like boot blocks\&. It supports only 3 sections and those sections are written in a predefined order to the output file\&. +object format produces a flat\-format, non\-relocatable binary file. It is appropriate for producing DOS .COM executables or things like boot blocks. It supports only 3 sections and those sections are written in a predefined order to the output file. .SH "COFF" .PP -The COFF object format is an older relocatable object format used on older Unix and compatible systems, and also (more recently) on the DJGPP development system for DOS\&. +The COFF object format is an older relocatable object format used on older Unix and compatible systems, and also (more recently) on the DJGPP development system for DOS. .SH "DBG" .PP The \(lqdbg\(rq object format is not a \(lqreal\(rq -object format; the output file it creates simply describes the sequence of calls made to it by Yasm and the final object and symbol table information in a human\-readable text format (that in a normal object format would get processed into that object format\*(Aqs particular binary representation)\&. This object format is not intended for real use, but rather for debugging Yasm\*(Aqs internals\&. +object format; the output file it creates simply describes the sequence of calls made to it by Yasm and the final object and symbol table information in a human\-readable text format (that in a normal object format would get processed into that object format's particular binary representation). This object format is not intended for real use, but rather for debugging Yasm's internals. .SH "ELF" .PP -The ELF object format really comes in three flavors: +The ELF object format really comes in two flavors: \(lqelf32\(rq -(for 32\-bit targets), +(for 32\-bit targets) and \(lqelf64\(rq -(for 64\-bit targets and -\(lqelfx32\(rq -(for x32 targets)\&. ELF is a standard object format in common use on modern Unix and compatible systems (e\&.g\&. Linux, FreeBSD)\&. ELF has complex support for relocatable and shared objects\&. +(for 64\-bit targets). ELF is a standard object format in common use on modern Unix and compatible systems (e.g. Linux, FreeBSD). ELF has complex support for relocatable and shared objects. .SH "MACHO" .PP The Mach\-O object format really comes in two flavors: \(lqmacho32\(rq (for 32\-bit targets) and \(lqmacho64\(rq -(for 64\-bit targets)\&. Mach\-O is used as the object format on MacOS X\&. As Yasm currently only supports x86 and AMD64 instruction sets, it can only generate Mach\-O objects for Intel\-based Macs\&. +(for 64\-bit targets). Mach\-O is used as the object format on MacOS X. As Yasm currently only supports x86 and AMD64 instruction sets, it can only generate Mach\-O objects for Intel\-based Macs. .SH "RDF" .PP -The RDOFF2 object format is a simple multi\-section format originally designed for NASM\&. It supports segment references but not WRT references\&. It was designed primarily for simplicity and has minimalistic headers for ease of loading and linking\&. A complete toolchain (linker, librarian, and loader) is distributed with NASM\&. +The RDOFF2 object format is a simple multi\-section format originally designed for NASM. It supports segment references but not WRT references. It was designed primarily for simplicity and has minimalistic headers for ease of loading and linking. A complete toolchain (linker, librarian, and loader) is distributed with NASM. .SH "WIN32" .PP -The Win32 object format produces object files compatible with Microsoft compilers (such as Visual C++) that target the 32\-bit x86 Windows platform\&. The object format itself is an extended version of COFF\&. +The Win32 object format produces object files compatible with Microsoft compilers (such as Visual C++) that target the 32\-bit x86 Windows platform. The object format itself is an extended version of COFF. .SH "WIN64" .PP The Win64 object format produces object files compatible with Microsoft compilers that target the 64\-bit \(lqx64\(rq -Windows platform\&. This format is very similar to the win32 object format, but produces 64\-bit objects\&. +Windows platform. This format is very similar to the win32 object format, but produces 64\-bit objects. .SH "XDF" .PP -The XDF object format is essentially a simplified version of COFF\&. It\*(Aqs a multi\-section relocatable format that supports 64\-bit physical and virtual addresses\&. +The XDF object format is essentially a simplified version of COFF. It's a multi\-section relocatable format that supports 64\-bit physical and virtual addresses. .SH "SEE ALSO" .PP \fByasm\fR(1), \fByasm_arch\fR(7) .SH "AUTHOR" .PP -\fBPeter Johnson\fR <\&peter@tortall\&.net\&> -.RS 4 +\fBPeter\fR \fBJohnson\fR +.sp -1n +.IP "" 3n Author. -.RE .SH "COPYRIGHT" -.br Copyright \(co 2006 Peter Johnson -.br diff --git a/yasm_parsers.7 b/yasm_parsers.7 index 058db4b7..a418b6f1 100644 --- a/yasm_parsers.7 +++ b/yasm_parsers.7 @@ -1,58 +1,48 @@ -'\" t .\" Title: yasm_parsers .\" Author: Peter Johnson -.\" Generator: DocBook XSL Stylesheets v1.75.2 +.\" Generator: DocBook XSL Stylesheets v1.70.1 .\" Date: October 2006 .\" Manual: Yasm Supported Parsers .\" Source: Yasm -.\" Language: English .\" .TH "YASM_PARSERS" "7" "October 2006" "Yasm" "Yasm Supported Parsers" -.\" ----------------------------------------------------------------- -.\" * set default formatting -.\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l -.\" ----------------------------------------------------------------- -.\" * MAIN CONTENT STARTS HERE * -.\" ----------------------------------------------------------------- .SH "NAME" yasm_parsers \- Yasm Supported Parsers (Assembler Syntaxes) .SH "SYNOPSIS" -.HP \w'\fByasm\fR\ 'u -\fByasm\fR \fB\-p\ \fR\fB\fIparser\fR\fR [\fB\-r\ \fR\fB\fIpreproc\fR\fR] \fB\fI\&.\&.\&.\fR\fR +.HP 5 +\fByasm\fR \fB\-p\ \fR\fB\fIparser\fR\fR [\fB\-r\ \fR\fB\fIpreproc\fR\fR] \fB\fI...\fR\fR .SH "DESCRIPTION" .PP -The standard Yasm distribution includes a number of modules for different parsers (assembler syntaxes)\&. +The standard Yasm distribution includes a number of modules for different parsers (assembler syntaxes). .PP The parser is selected on the \fByasm\fR(1) command line by use of the \fB\-p \fR\fB\fIparser\fR\fR -command line option\&. +command line option. .SH "NASM PARSER" .PP NASM syntax, selected with -\fB\-p nasm\fR, is the most full\-featured syntax supported by Yasm\&. Yasm is nearly 100% compatible with NASM for 16\-bit and 32\-bit x86 code\&. Yasm additionally supports 64\-bit AMD64 code with Yasm extensions to the NASM syntax; see +\fB\-p nasm\fR, is the most full\-featured syntax supported by Yasm. Yasm is nearly 100% compatible with NASM for 16\-bit and 32\-bit x86 code. Yasm additionally supports 64\-bit AMD64 code with Yasm extensions to the NASM syntax; see \fByasm_arch\fR(7) -for details\&. NASM syntax is the Yasm default\&. +for details. NASM syntax is the Yasm default. .SH "GAS PARSER" .PP -The GNU Assembler (GAS) is the de\-facto cross\-platform assembler for modern Unix systems, and is used as the backend for the GCC compiler\&. Yasm\'s support for GAS syntax is moderately good, although immature: not all directives are supported, and only 32\-bit x86 and AMD64 architectures are supported\&. Nearly all of the GAS preprocessor is also supported\&. Yasm\'s GAS syntax support is good enough to handle essentially all x86 and AMD64 GCC compiler output\&. The GAS parser can be selected with -\fB\-p gas\fR\&. +The GNU Assembler (GAS) is the de\-facto cross\-platform assembler for modern Unix systems, and is used as the backend for the GCC compiler. Yasm's support for GAS syntax is moderately good, although immature: not all directives are supported, and only 32\-bit x86 and AMD64 architectures are supported. There is also no support for the GAS preprocessor. Despite these limitations, Yasm's GAS syntax support is good enough to handle essentially all x86 and AMD64 GCC compiler output. The GAS parser can be selected with +\fB\-p gas\fR. .SH "SEE ALSO" .PP \fByasm\fR(1), \fByasm_arch\fR(7) .SH "AUTHOR" .PP -\fBPeter Johnson\fR <\&peter@tortall\&.net\&> -.RS 4 +\fBPeter\fR \fBJohnson\fR +.sp -1n +.IP "" 3n Author. -.RE .SH "COPYRIGHT" -.br Copyright \(co 2006 Peter Johnson -.br