Peter Johnson [Sun, 3 Aug 2003 21:13:20 +0000 (21:13 -0000)]
Add support for the AMD64 syntax [symbol wrt rip]. This is distinct from
[rip+symbol] in that the latter adds the symbol offset to rip, whereas the
former is the same as [symbol] but uses rip-relative addressing. This is
a minor overload of the WRT operator, but reads well and shouldn't conflict
with the use of WRT against sections.
Doing this currently adds a bit of overhead to all effective addresses in
64-bit mode (a $ symbol reference). This is the cleanest approach I could
figure out; a time/space trade could be made later, such as prescanning for
RIP usage before allocating the symbol.
Michael Urman [Sun, 3 Aug 2003 01:13:14 +0000 (01:13 -0000)]
ELF objfmt size agnosticism:
* Replace ulongs secthead.size, secthead.align, reloc.addr with intnums
* Calculate relocation size with intnums
* Create macros YASM_WRITE_32I_L, YASM_WRITE_64I_L to write 32/64bit
intnums to buffer
This doesn't quite cover everything, particularly due to various calls
to yasm_intnum_get_uint for various bits of processing, but it's close!
Miscellany:
* Fix non-call to elf_reloc_delete()
* Remove unused secthead.addr, secthead_set_addr
* Create macro YASM_WRITE_64Z_L to write zero-extended 32bit value to
64bits of buffer
Michael Urman [Sat, 2 Aug 2003 21:50:42 +0000 (21:50 -0000)]
Move elf relocation valsize handling to the backend.
Add elf x86 test case to verify it works properly.
Unsure about elf x86-64 status (relocations segfault my objdump), but
it's no *worse* than last commit.
Michael Urman [Sat, 2 Aug 2003 20:32:42 +0000 (20:32 -0000)]
Continue adding AMD64 ELF support (without breaking x86!):
Move more machine-specific items to the backend (EHDR_SIZE) and make it
target machine-dependent there.
Theoretically everything except relocations may work, but since builds
of amd64 with bits=32 can segfault objdump, don't trust it.
Work to support relocations is next; perhaps then it can be tested.
Michael Urman [Sat, 2 Aug 2003 03:43:41 +0000 (03:43 -0000)]
Implement global constants in elf. Add test to ensure they work; modify
another test such that linked together they verify that
1. It links properly
2. The constant is loaded properly
3. The function is called properly
shown (probably not proved) by the program exiting with error level 0.
Peter Johnson [Fri, 1 Aug 2003 03:52:35 +0000 (03:52 -0000)]
Fix iretq, stosq, etc, which were properly setting the opersize but the REX
generation code wasn't seeing it because it wasn't looking at the modified
opersize.
Bug noticed by: Antoine Leca <antoine64leca@unknown> (x86-64 discuss ML)
Peter Johnson [Wed, 30 Jul 2003 04:36:29 +0000 (04:36 -0000)]
Add versioning to all loadable module interfaces. The version is checked by
module users to ensure the module interface they're using matches the
interface the module was compiled with. The #define YASM_module_VERSION
should be incremented on every functional change to the module interface.
Peter Johnson [Tue, 29 Jul 2003 03:19:12 +0000 (03:19 -0000)]
Add core pieces for "machine" subtype of "architecture". Needed to
differentiate e.g. AMD64 from x86. Doesn't prohibit anything in x86 yet,
but does standardize unsupported warnings across objfmts (most objfmts will
not support all machines and/or all architectures).
Peter Johnson [Sat, 26 Jul 2003 02:32:04 +0000 (02:32 -0000)]
Fixed some conversion warnings caused by intnum commit. Missed these due to
use of configure.ac's --enable-warnerror, which was set up to disable
conversion errors due to flex's warning-prone generated code. As we no
longer use flex, fix configure.ac to not disable conversion errors.
Peter Johnson [Fri, 25 Jul 2003 03:27:21 +0000 (03:27 -0000)]
Big output_expr(), intnum_tobytes(), and floatnum_tobytes() changes:
- Switch to bit-based output, including shift capability
- This means the standard intnum output functions can be used for non-byte
oriented archs like LC-3b (implemented)
- Default out of range (overflow) warnings for intnum (bugzilla bug 14)
- Change floating point overflow/underflow errors to warnings
To do (hooks but not implemented):
- Shifting floatnums into destination
- Floatnum destinations larger than floatnum value
- Big endian support for intnum and floatnum
Related simultaneous changes:
- Use bc instead of ep in objfmt output_expr() functions; while bc->line
should == (*ep)->line, in case they differ, we want to use the bc->line
so as not to confuse users.
- lc3b-mp22NC test was not properly offsetting the accessed variables, but
since the variable "sections" started at an aligned offset, the output
was actually correct. The new intnum warnings uncovered this issue, so
fix code to be correct (and not generate warnings).
Peter Johnson [Fri, 25 Jul 2003 02:17:30 +0000 (02:17 -0000)]
When changing a section start into a start-based expression, use the
expression line number instead of the start line number (which may be 0,
which isn't nearly as useful as the expression line number).
Michael Urman [Thu, 24 Jul 2003 04:38:37 +0000 (04:38 -0000)]
Replace preliminary elf header files with...
ELF objfmt implementation.
Assumed to be correct for the test cases, but only tested as far as feasible.
Currently only implements 32bit 386 little-endian, but is mostly abstracted
well enough to easily add more machines.
Peter Johnson [Sat, 19 Jul 2003 17:53:34 +0000 (17:53 -0000)]
Enhance return values for yasm_x86__expr_checkea() to fully represent the
three possible return states (okay, invalid, or indeterminate). Propagate
this return change into the yasm_x86__expr_checkea() call tree as necessary.
Peter Johnson [Sat, 19 Jul 2003 17:28:10 +0000 (17:28 -0000)]
Fix bad assumption in x86_expr_checkea_getregusage() that was causing bad code,
internal errors, and mis-optimization as seen in Bugzilla Bug 13.
Reported by: meor@softhome.net
Fix a few minor bugs (not heavily tested) due to use of opersize == 32 as a
comparison; this fails when opersize == 64 due to bits = 64, but the default
size is still 4 bytes, not 2.
There's still a couple cases here where we might end up with internal errors
due to a lack of variety in return values; I'll fix those in the next commit.
Peter Johnson [Thu, 17 Jul 2003 02:25:25 +0000 (02:25 -0000)]
yasm_intnum_is_zero(), yasm_intnum_is_pos1(): Don't need to check if bitvect,
all <32 bit positive numbers are collapsed into ul form.
yasm_intnum_is_neg1(): fix bug which would equate 0xffffffff as -1.
Peter Johnson [Wed, 16 Jul 2003 04:55:07 +0000 (04:55 -0000)]
Fix bug in edge case of expr_level_op(): single intnum in expression with
intnum folding on and leveling performed would result in terms getting copied
over due to hitting o != i case after i++ but no o++.
Peter Johnson [Tue, 15 Jul 2003 06:27:40 +0000 (06:27 -0000)]
yasm_intnum_new_int(): Don't always create -1 intnums (oops)
yasm_intnum_get_int(): Properly overflow and handle INTNUM_UL properly
Elsewhere: use wordptr instead of intptr.
yasm_intnum_check_size() is still broken, but the interface for this will be
changing soon, so fix it then.
Peter Johnson [Sat, 12 Jul 2003 19:44:30 +0000 (19:44 -0000)]
Avoid warnings in strsep due to glibc's bits/string2.h string inlining by
defining __NO_STRING_INLINES in strsep.c. Due to string.h inclusion in
util.h, extra level of indirection is needed
(NO_STRING_INLINES->__NO_STRING_INLINES).
Peter Johnson [Fri, 11 Jul 2003 04:08:52 +0000 (04:08 -0000)]
Note bitvect is actually triple-licensed under the Artistic License, GPL,
and LGPL. Bring in the text from the original distribution README.txt and
Artistic.txt, and add an GPL reference.
Peter Johnson [Fri, 11 Jul 2003 03:02:58 +0000 (03:02 -0000)]
Revamp intnum internals:
- Up internal format size to 128 bit.
- Use full internal format size for all calculations.
- Always store negative numbers using full internal size
(avoids 0xffffffff == -1?? issue)
This fixes many inconsistencies in handling of >32-bit intnums.
Peter Johnson [Tue, 8 Jul 2003 02:55:28 +0000 (02:55 -0000)]
Allow complex (expression) section starts, primarily used for implementation
of [ORG] in bin objfmt. Still need to assess impact of self-referential
(invalid) ORG, and how to detect for that condition.
Peter Johnson [Sun, 8 Jun 2003 22:58:21 +0000 (22:58 -0000)]
Display fatal errors as FATAL, and perform other error display cleanups.
Exit immediately after bad arch/objfmt/etc selections to avoid "bad option"
secondary errors.
Peter Johnson [Sun, 8 Jun 2003 21:21:22 +0000 (21:21 -0000)]
Make yasm_fatal() and implementations take a list of printf-like parameters.
Also, don't abort(), just exit()... unlike internal errors, which we want a
backtrace for, fatal errors may happen during normal operation.
Peter Johnson [Sun, 8 Jun 2003 20:17:21 +0000 (20:17 -0000)]
Simplify preloaded search case by removing any library extension in
list_modules() rather than trying to figure it out in list_module_load().
Also avoids the corner failure case when archives aren't named *.a.
Peter Johnson [Sat, 7 Jun 2003 21:56:47 +0000 (21:56 -0000)]
Change module loader interface a bit (use enum instead of string to specify
module type), and make "yasm -[adfpr] help" work dynamically by scanning
preloaded symbols and filesystem directories.
Peter Johnson [Sat, 31 May 2003 22:37:58 +0000 (22:37 -0000)]
Add an architecture to support the LC-3b ISA as used in the ECE 312 course
at the University of Illinois, Urbana-Champaign.
See http://courses.ece.uiuc.edu/ece312/ for more details.
Peter Johnson [Tue, 27 May 2003 04:13:16 +0000 (04:13 -0000)]
Add support for FAR call/jmp. Because of the jmp label, label equ seg:off
problem, adding this required adding some fields to x86_jmprel (now a
misnomer, as FAR jumps are absolute) to save the far opcode, and additional
support in libyasm's yasm_expr_* to properly handle the YASM_EXPR_SEGOFF
operator.
Peter Johnson [Mon, 26 May 2003 19:16:44 +0000 (19:16 -0000)]
Add lindex parameter to yasm_intnum_calc(), and add error messages for SEG,
WRT, and ':' (SEGOFF) usage. This change also brings the yasm_intnum_calc()
interface in line with the yasm_floatnum_calc() interface.
Note: This may not be the final place we want these error messages to reside,
but the lindex addition should remain for the sake of consistency.
Peter Johnson [Sat, 10 May 2003 20:05:39 +0000 (20:05 -0000)]
Fix crash on Linux due to double-fclose(). The NASM preprocessor was closing
the original input file, which was then closed again by the frontend. Fix
saves the original file passed in and special-checks for it before calling
fclose().
Peter Johnson [Sat, 10 May 2003 05:40:44 +0000 (05:40 -0000)]
Pre-include libyasm/coretype.h to avoid #defining functions such as
yasm__strsep() (here) before their prototypes are declared (in coretype.h).
Header protections keep coretype.h from being included again (from libyasm.h).
Peter Johnson [Mon, 5 May 2003 03:42:12 +0000 (03:42 -0000)]
Clean up and simplify libyasm.h options and symbol visibility:
- Move config.h and util.h from libyasm (and installed libyasm) to top level.
- Move yasm_* functions from util.h to coretype.h.
- Remove a number of autoconf-related YASM_*_INTERNAL options from libyasm.h.
- Rename YASM_INTERNAL to YASM_LIB_INTERNAL; it now actually means what the
comment describes: enables definitions that violate the yasm_* namespace.
While we're at it, no longer define YASM_LIB_INTERNAL from yasm frontend, so
it's closer to what a real typical libyasm-using application would look like.
Peter Johnson [Sun, 4 May 2003 22:15:09 +0000 (22:15 -0000)]
Change how bytecode and section lists are allocated. When YASM_INTERNAL is not
defined, the structures for the list heads are not defined, so the existing
yasm_bcs_initialize() and yasm_sections_initialize() were impossible to use.
Instead, rename these functions to yasm_bcs_new() and yasm_sections_new() and
make them allocate the space internally. Update yasm_bcs_delete() and
yasm_sections_delete() to free the internally-allocated space.
Peter Johnson [Sun, 4 May 2003 22:12:14 +0000 (22:12 -0000)]
dmalloc expects never to get a NULL deallocation; nasm preproc expects
nasm_free() to handle it, which it does as yasm_xfree(). But to avoid dmalloc
complaints, check for the NULL beforehand if dmalloc is in use.
Peter Johnson [Sun, 4 May 2003 20:31:57 +0000 (20:31 -0000)]
Make yasm_section_delete() static. It's unsafe to call from outside, because
the only way to allocate a section is when making it a part of a section list,
and at present, the list is singly-linked internally.
Peter Johnson [Sat, 3 May 2003 06:26:15 +0000 (06:26 -0000)]
Install modules into pkglibdir rather than libdir, and rename to type_keyword
from yasm_keyword (separating same-keyword modules of different types). Update
yasm frontend module loader to handle this.
Peter Johnson [Thu, 3 Apr 2003 06:14:29 +0000 (06:14 -0000)]
Fix crash on the valid NASM preprocessor syntax:
var: db 5
varlen equ $-var
%if varlen>100
...
%endif
by always acting like we're in preprocess-only mode and adjusting error
message appropriately.
This would be HARD to truly fix, as yasm only parses the input once.