__OUTPUT_FORMAT__ must consist of shortname of output format
or its alias, otherwise userspace ABI gets broken.
For example source code still can refer to __OUTPUT_FORMAT__=elf,
instead of __OUTPUT_FORMAT__=elf32.
BR3246990
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Instead of opencoded zero assignments better to use nasm_zalloc
and set fields which are supposed to be non-nil. This simplifies
code and makes it more readable.
Also note the field 'ifollows' renamed to 'prev' as it should
be from the very beginning in terms of lists.
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
The backport of
4db724fdd7359b63f89701102ee8e62672af7379
so coff output target to be able to handle
massive relocations.
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
In case if relocations number exceed 16bit values
we have to hande such case by a special way, as described
in COFF specification.
"IMAGE_SCN_LNK_NRELOC_OVFL indicates that the count of
relocations for the section exceeds the 16 bits that are
reserved for it in the section header. If the bit is set
and the NumberOfRelocations field in the section header
is 0xffff, the actual relocation count is stored in the
32-bit VirtualAddress field of the first relocation. It
is an error if IMAGE_SCN_LNK_NRELOC_OVFL is set and
there are fewer than 0xffff relocations in the section."
[ BR3092924 ]
Reported-by: Robert Yates
Investigated-by: nasm64developer
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Actually it's temporary action. We have to support more
relocations then that but it requires some more code rework.
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
We could have accessed malloc'ed data on external symbols
in obj and ieee output formats. Fix it by using nasm_zalloc.
Reported-by: Jiri Malak
Patch-by: Jiri Malak
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
We could have accessed malloc'ed data on external symbols
in obj and ieee output formats. Fix it by using nasm_zalloc.
Reported-by: Jiri Malak
Patch-by: Jiri Malak
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
In commit 55ae12052c we occasionally broke byte ordering. Fix it.
Note that current stable version 2.08.01 is not affected by this bug.
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Apparently some people still care about compiling native on MS-DOS,
and we don't have a significant number of files which need adjustment.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
ARRAY_SIZE is a well known name pointing out that
we're dealing with array in macro argument.
Also to be on a safe side prefix_name helper should
check the index been in bounds more precisely.
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Add OUT_REL1ADR (one-byte relative address) and support for
OUT_ADDRESs with size == 1. Add support for it in
outbin and outdbg. *It still needs to be added to other backends*,
both the OUT_REL*ADR and OUT_ADDRESS codepaths need to be handled.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
macho_sectalign was occasionally misprinted
with macho_setcalign, fix it. No change on functionality.
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
format_mode is always set to 1 so there is no need to
keep this variable. "Old chicken bit" (c) :)
Reported-by: "H. Peter Anvin" <hpa@zytor.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Section alignment is broken due to not being
direct "align -> power of two set" mapping but
rather including second addition operation.
Fix it by introducing coff_sectalign_flags helper.
This also allow us to use this helper for getting
rid of open coded computation as well.
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Put in all constants pecoff v8 states. Most probably we
will never need most of them but lets have them here for
completeness.
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
We already have "elf" and "macho" aliases for respective
32 bit output formats. Make the same for "win32" in a
sake of consistency.
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
This allow us to keep compatibility layer without
needing the separated struct ofmt for this and
elf_init_hack routine.
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Instead of implicit declaration of global symbols obtained
by STB_GLOBAL << 4, and local symbols by STB_LOCAL << 4
use ELF32_ST_MKBIND helpers.
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
The profit of ELFXX_ST_MKBIND helper is that we
will use it for SYM_GLOBAL explicitly pointing
out from where this magic 0x10 came from.
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Also made Makefile.in to handle dependency.
There are some makefiles in Mkfiles\ should
be fixed as well.
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Commit 2ddcd03900
did bind symbols (in case of omitted SECTION directive)
to .text section but break COMMON binding.
Fix it.
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
In case if SECTION directive is omitted but the real
code exist we form .text section by default and put compiled
code here. In turn labels are not handled in a same manner.
So lets bind them to text section by default as well.
[ BR: 2835192 ]
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Due to previous commit an indent by tab (occasionally) brought in.
Fix it as well. No change on binary level.
We're not that far from NASM release so it's a bit unpleasant
manner to push in such trivial change. But since it's the previous
commit dependent -- I dare to push it.
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Merge elfcommon.h, elf32.h, elf64.h into
single elf.h -- we do support both elf32
and elf64 anyway. Let put them into common
place.
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
From Frank Kotler:
| ...
| > - stdscan_bufptr = saveme; /* bugfix? fbk 8/10/00 */
| > + stdscan_set(saveme); /* bugfix? fbk 8/10/00 */
|
| While you're at it, you could remove my comment(s - it seems to have
| reproduced). It *is* a bugfix (apparently). "saveme" might have a better
| name, too...
So get rid of the comments.
Reported-by: Frank Kotler <fbkotler@zytor.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Instead of manipulating stdscan buffer pointer directly
we switch to a routine interface.
This allow us to unify stdscan access: ie caller should
"talk" to stdscan via stdscan_get/set routines.
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
This represent "end of compilation unit" token.
Since gcc does (almost) the same lets be on the
same side.
Though to be precise gcc puts offset which points
to the first byte right after the last instruction
issued but in fact string index is analyzed only
so we may safely write zero here (without relocation
as well).
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
1) nasm_free is safe against NULL passed so call
it without test
2) dwarf32_output: check for debug_immcall early
and get out of procedure if success. This allow
us to move code blocks left removing indents.
3) dwarf32_findfile and dwarf32_findsect: no need
for 'else' when 'if' target is plain return.
Move code blocks left removing indents.
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
There is a hope we'll be supporting dwarf in full form in future. So
I've encoded the standard constants (though binutils uses some
additional codes).
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
This is the null implementation of the function debug_directive. For
some reason it ended up getting mangled as "null_debug_routine".
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Note that we use list_for_each(var,var) sometime
which actually brings in at least one redundant
assignment in case of NULL being passed but save
us a few lines of code.
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
The construct:
if (i == nsects)
directive_sec =
sects[coff_make_section
(EXPORT_SECTION_NAME, EXPORT_SECTION_FLAGS)];
... where coff_make_section() can change the global variable "sects"
is undefined C, since there is no sequence point involved in the []
operator, and it is therefore fully permitted for the C compiler to
read the sects variable first. Change this construct into two
statements to enforce defined behavior; this also ends up with the
code slightly simpler.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
We never set ofmt and errfunc to anything but the global values.
Dropping them from the label definition function command line
simplifies the code.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Remove a bunch of function pointers in the output stage; they are
never changed and don't add any value. Also make "ofile" a global
variable and let the backend use it directly.
All we ever did with these variables were stashing it in locals and
using them as-is anyway for no benefit.
Also change the global error function, nasm_error() into a true
function which invokes a function pointer internally. That lets us
use direct calls to it.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Hash all directives, even the ones that are backend-specific,
and instead pass the backend an already-parsed directive number.
Furthermore, unify null functions across various backends.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
We fopen() the output file in common code but fclose() it in the
backend. This is bad for a variety of reasons:
1. it is generally an awkward interface to change ownership.
2. we should use ferror() to test for write errors, and that is
better done in common code.
3. it requires more code.
4. we still need to fclose() in common code during error handing.
Thus, move the fclose() of the output out of the backends, and add
fflush() so we can test ferror() on output.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
outdbg is actually a good starting point to make a new backend, so we
really should endeavor to make it do things "right".
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
The OUT_REL*ADR types pass a pointer which points to an int64_t
which then should be truncated down to size. This matters on
bigendian platforms.
Add OUT_REL8ADR.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
The documentation uses "Intel hex", with that capitalization (Intel
being a proper noun, hex being descriptive) so make the help message
match.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
*To the best of my knowledge*, we now have authorization from everyone
who has significantly contributed to NASM in the past. As such,
change the license to the 2-clause BSD license.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
- add assert so we don't try to write 2^64 bytes of zero
- explicitly track the Intel hex "LBA" (64K page) instead of playing
games with the last byte written. This way it is more explicit
what we're doing and why.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Using saa_fpwrite() to dump a section to a file automatically does
saa_rewind(), but if we use saa_rnbytes() to do bit by bit then we
manually need to to saa_rewind() before we start.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Add support for directly generating Intel hex or Motorola S-records.
These formats are commonly used with ROM burners.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Allow the backend to specify that an output format is either text or
binary. For future uses, define this as a flag word so we can define
other flags in the future if it would make sense.
Currently, the ieee and dbg formats are text; all the others are
binary.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
SEG <undefined> can happen, validly, for a common symbol during the
optimization passes. It better not happen during the real passes,
however!
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Received authorization from Apple to change the license of outmacho.c
to the 2-clause BSD license. Thanks!
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Add new copyright headers to the new output modules. As far as I
know, the only module which we still don't have a green light to
release under 2-BSD is outmacho.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Move the prototypes for the null debugging format to outform.h (for
the top-level structure declaration only) and outlib.h (for the
internal routines.)
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Move backend-specific code into the output/ directory, and make the
null debugging backend a separate file (it certainly isn't needed for
ndisasm...)
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Make all the null debug routines available as a library, so we can use
them whenever appropriate. We really don't need to have a bunch of
dummy functions scattered all over the code.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
We already call current_dfmt->init in the same place (at the very end
of ofmt->init) in all the backends that do it; instead call it
centrally in nasm.c after ofmt->init.
This fixes invalid ELF files with when compiling with -F dwarf, since
the dwarf initialization routine never got called.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
The global symbol offset is a loop invariant; no need to compute it
over and over. The compiler probably will not be able to do this for
us due to global variables and function calls.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Clean up the arithmetic for global symbols; in particular, make it
clear where the dependency on the debug format comes from (DWARF needs
three symbol table entries all by itself.)
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Bump GLOBAL_TEMP_BASE so far that it *cannot* conflict for ELF32
(which has 24-bit symbol table indicies) and is *unlikely* to conflict
for ELF64 (which has 32-bit symbol table indicies.)
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Eliminiate hard-coded section numbers, at least to the best of our
ability. There is still a very odd piece of computation in
elf_build_reltab() which I can't really figure out...
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
The dependency machinery relies on properly rooted includes, so give
it to them... the path syntax munging machinery in the dependency
script handles it from a Makefile syntax perspective, and then we can
hope that C compilers are smart enough to deal with forward-slash
paths even when that is not the native syntax.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Add something approaching real ELF header files.
Begin merging the common ELF code, beginning with the section name
detection.
Drop automatic generation of .comment section, and in particular the
treatment of .common as a special section (if we decide generating
.comment is still a good idea, we should just do it as a macro.)
Augment the list of known sections, and make it table-driven.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Some vendors get nervous about parameterized printf patterns;
furthermore, it's completely unnecessary in this case.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Fix the SAFESEH directive for the specific case of a symbol internal
to the program. With the optimizer enabled, it would otherwise fail
unless the symbol is external.
Fix crash caused by uninitialised memory that lead to dangling pointer
in the rbtree. This can be seen by compiling zsnes 1.50, with a file
that define many symbols, such as fxemu2c.asm.
We have a number of all-zero buffers in the code. Put a single
all-zero buffer in nasmlib.c. Additionally, add fwritezero()
which can be used to write an arbitrary number of all-zero bytes;
this prevents the situation where the all-zero buffer is simply
too small.
When a section other than .text has a start < origin, we would
segfault; fix that.
Furthermore, at bin_cleanup() we don't have usable file/line
information, so pass ERR_NOFILE to the error() function. Perhaps less
than ideal, but better than printing a null pointer.
Previously, the ELF backends silently ignored incorrect or unknown
attributes on section declarations, and therefore used default values
in cases where the user had make an error in attempting to specify
custom values.
I needed entry point support with the as86 format, and after looking through
the archives found a similar desire from someone in 2002. For some reason
such a patch never made it into the code, even though the required flag
value is present, so I offer the a patch of my own.
I compared against what is done in the .obj format and the approaches are
quite similar which I hope will aid in its acceptability. While I have
tested it extensively it does do the job asked, and I'm honestly not sure
what extensive testing of the change would look like.
Several projects have taken to using .text to store read-only data
when building on Mac OS X due to crashes in SSE code from the .rodata
section being mis-aligned. It seems there was a misunderstanding about
how ld/ld64 handles section alignment in outmacho.c so I wrote a patch
to fix it. I tested it against x264 git, modified it to use ".rodata
align=16" for the data section and use movdqa instructions (guaranteed
to crash when built with unpatched nasm) and it passed all tests in
its checkasm tool.
If you want more data I can provide, but it's late and I've had a
couple glasses of mulled wine :)
-DrD-
Linear searches are evil, so use an llrbtree to search for symbols by
offset. This doesn't change the preexisting behaviour that we only
look for global symbols.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
nasm.c should respect the default debug format of the output format,
instead of replacing it with the first format in the list.
This is cleaner and allows the list to be sorted normally.
This commit rewrites commit 116994111b which was very fragile.
Move all the version strings to a single compilation unit, ver.c; this
does not include the version macros, which are fed into macros.c.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Set default attributes for .tdata and .tbss sections
Implement new attribute 'tls' for arbitrary section names
Flag variables in sections with tls attribute with STT_TLS
Add a common file, outlib.c, for output formats. Add the function
realsize() instead of open-coded variants in almost every backend.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Set STT_TLS in symbol table for symbols declared
in thread local storage sections. Note that,
for now at least, such symbols must also be
declared as GLOBAL.
The "bin" format was misinterpreting the overloading of the "size"
argument to out(), which caused another source of 64-bit relative
offset errors.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
It is unclear if we will ever see any "naked" (absolute bytes)
OUT_REL*ADR coming from the assembler, but if we do, we should
generate them correctly.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Now when the assembler is properly generating the address that we push
down to the backend, enable requesting an exact value for these
relocations (these are pointing to a specific GOT or PLT slot; the
addend is used to adjust the computed value in the instruction, not
for offset for the symbol.)
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
The "size" argument to the OUT_REL*ADR output types is actually
intra-instruction offset, not the actual size. Thus, emit the size
properly.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Fix the arithmetic for relative GOT/PLT references.
We still can't enable exactitude, because of the assumption that
"size" is always the proper adjustment for the offset of the
displacement inside the instruction, which is wrong in the case of
displacements that are followed by an immediate. This also affects
the list file, so it really should be fixed.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
GOTOFF64 is used for local variables (as a 64-bit offset from the GOT;
only needed in the Medium PIC or Large PIC models.) It therefore
should *not* be a elf_add_gsym_reloc() invocation.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
I am having a bit of a hard time understanding the proper operation of
the "exact" flag to elf_add_gsym_reloc(). We apparently won't
generate proper GOTOFF64 relocations with this flag set; it is
possible that there are *no* proper uses of this flag. This clearly
needs to be figured out.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
GOT and PLT references need a symbol; after all, they reference a GOT
or PLT slot. Thus, they need elf_add_gsym_reloc(). Mungify the
interface so that they can communicate the need for the PC-shifted
offset into the relocation.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
When generating an address that is *not* tied to a symbol, we just
want to emit the bytes. I believe the assembler is already supposed
to do that for us, but just in case, do it right here too.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
The x86-64 ABI wants the symbol addend to reside in the addend field
of the RELA relocation, not in the code stream. Apparently it's
something one can get away with, but the linker would still botch it
for some cases. Change it so we pass the proper output and emit zero
into the code stream.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Try to make the various GOT relocations do the right thing in ELF64,
including erring out when appropriate.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Expressions like
mov r15,[rel integer wrt ..got]
lea rax,[rel integer wrt ..gotoff]
now assemble correctly.
In addition, a fix has been made to the corresponding
abs relocations.
Both of these areas still need additional testing.
Somehow the win32 and win64 aliases got listed on Mach-O, not on
COFF. This doesn't have any effect on the current code, but might in
the future. Correct.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Don't use explicit L's for things which are really size_t; not only is
it unnecessarily ugly, but it's wrong in a lot of ways. Do some other
minor stylistic cleanups.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
We would leave the output symbol type uninitialized. Explicitly
initialize it to zero (T_NULL, meaning no symbol type information),
since that's what was effectively done.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
The testcase illustrates the problem. After "nasm -f obj
alonesym.nasm"
let's look to dump:
======
PUBDEF386(91) recnum:5, offset:0000005bh, len:03f9h, chksum:bbh(bb)
Group: 0, Seg: 1
00020000h - 'sym0000' Type:0
00020004h - 'sym0001' Type:0
....
00020134h - 'sym0077' Type:0
PUBDEF(90) recnum:6, offset:00000457h, len:000ah, chksum:b6h(b6)
Group: 0, Seg: 1
00000138h - 's' Type:2
0000b600h - '' Type:0
======
The problem is while 's' offset is 20138h it is marked as type 90h not
91h. The root cause is located in obj_x():
static ObjRecord *obj_x(ObjRecord * orp, uint32_t val)
{
if (orp->type & 1)
orp->x_size = 32;
if (val > 0xFFFF)
orp = obj_force(orp, 32);
if (orp->x_size == 32)
return (obj_dword(orp, val));
orp->x_size = 16;
return (obj_word(orp, val));
}
It sets up x_size and than writes data. In the testcase data are the
offset and this offset overflows a record. In this case the record is
emitted and its x_size is cleared. Because this is last PUBDEF the new
record with only 's' symbol is emitted also but its x_size is not 32
(it's still zero) so obj_fwrite doesn't switch to 91h type.
The problem seems to be very generic and expected to be occurred on
many other record types as well.
----
And the fix is simple:
if (orp->x_size == 32)
{
ObjRecord * nxt = obj_dword(orp, val);
nxt->x_size = 32; /* x_size is cleared when a record overflows */
return nxt;
}
ctype functions take an *int*, which the user is expected to have
taken the input character from getc() and friends, or taken a
character and cast it to (unsigned char).
We don't care about EOF (-1), so use macros that cast to (unsigned
char) for us.
Move the handling of "extra" macros (i.e. output format macros) into
the macros.pl mechanism. This allows us to change the format of the
internal macro store in the future - e.g. to a single byte store
without redundant pointers.
Also, stop using indicies into a long array when there is no good
reason to not just use different arrays.
Make the WSAA macros contain their own buffer definitions. This
eliminates the need to have a separate "workbuf" declared in the
outelf backends, which isn't even used for anything else, except for a
few completely redundant strcpys.
Note: these macros probably should be replaced with actual
functions. The overhead of the function call is likely to be more
than offset by lower icache footprint.
Guess what, SEH again, but in Win64 context, which is completely
different matter from Win32. At lowest level this one boils down to
putting so called imagerel references, or in practical terms
relocations of type ADDR32NB, 0x0003, into .pdata and .xdata
segments. Two possibilities. 1. implement say 'wrt ..imagerel' or 'wrt
..imagebase'. 2. silently enforce ADDR32NB relocations in .pdata and
.xdata segments.
This is basically not a bug report, but a feature request.
It's desired to be able to link .obj modules compiled with 'nasm -f
win32' with Microsoft 'link /safeseh'. As well as to register symbols
(commonly subroutine's entry points or even external symbols) as "safe
handlers." In order to achieve this, several points are required.
First of all, object module has to have absolute symbol named @feat.00
with value of 1. This can actually be achived by adding 'absolute 1'
and '@feat.00:' to source code, but it's desirable that it's
autogenerated for win32 modules.
Handler registration is essentially symbol's *index* in current
module's symbol table in .sxdata, segment with 0x200 segment flags, an
"info" segment. It's also essential that symbol has type 0x20 (see
below). All this is depicted in following framgents of 'objdump -xD'
output:
Sections:
Idx Name Size VMA LMA File off Algn
0 .sxdata 00000004 00000000 00000000 0000003c 2**2
CONTENTS, READONLY, DEBUGGING
SYMBOL TABLE:
...
[ 5](sec -1)(fl 0x00)(ty 0)(scl 3) (nx 0) 0x00000001 @feat.00
[ 6](sec 0)(fl 0x00)(ty 20)(scl 2) (nx 0) 0x00000000 _handler
...
<.sxdata>
0: 06 00 00 00
Note [6] and (ty 20) in _handle line in SYMBOL TABLE. "06 00 00 00" in
.sxdata is little-endian 6, _handler's index. This is what makes up
"registration." It's impossible to achieve this with current nasm
facilities and it's probably appropriate to introduce a directive for
it, 'safeseh _handler' is probably most natural choice.
When using temporaries in macros, given them a unique prefix to avoid
namespace collisions when using one macro inside another.
Move the WSAA*() macros from outelf32/outelf64 to a separate header
file.
Clean up remaining build warnings. None of this should affect code
operations. The only warnings which were actually relevant might have
been the ones in ldrdf.c, but it's not clear if anyone ever uses that.
Fix one missed change from "type" to "size". May want to look through
all the other backends as well for similar issues.
This would generate the wrong section lengths, with obviously bad results.
Our size arguments are 64-bit values, but we don't need that range for
anywhere where we need a switch. OpenWatcom can't deal with them
(sigh), so cast them to (int) for now.
Address data is always int64_t even if the size itself is smaller;
this was broken on bigendian hosts (still need testing!)
Create simple "write sized object" macros.
Fix alignment handling in the Mach-O format. The patch is from the
bug report, mangled to apply to the current source base. I have no
way to test this, so I'm going to have to assume it's correct.
Don't combine type and size into a single argument; *every* backend
immediately breaks them apart, so it's really just a huge waste of
effort. Additionally, it avoids using short immediates in the
resulting code, which is a bad thing.
OpenWatcom doesn't like 64-bit switch arguments; the change to 64-bit
type arguments caused that to happen in outmacho.c. Hack around it
for now; however, realistically speaking the whole bit stealing thing
is probably a bad idea, especially since virtually all CPUs handle
short immediates better than long ones.
Proper use of bool and enum makes code easier to debug. Do more of
it. In particular, we really should stomp out any residual uses of
magic constants that aren't enums or, in some cases, even #defines.
Both C and C++ have "bool", "true" and "false" in lower case; C
requires <stdbool.h> for this, in C++ it is an inherent type built
into the compiler. Use those instead of the old macros; emulate with
a simple typedef enum if unavailable.
Concentrate compiler dependencies to compiler.h; make sure compiler.h
is included first in every .c file (since some prototypes may depend
on the presence of feature request macros.)
Actually use the conditional inclusion of various functions (totally
broken in previous releases.)
Per SF bug report 1351586:
The COFF spec suggests that the "Virtual Size" field (which
immediately follows the name field inside a section header) be set to
0 for an object file.
By contrast (as documented in comment #4 at the beginning of its
outcoff.c file) NASM sets it to a particular non-0 value.
MASM 6.15 matches NASM for both 16- and 32-bit object files,
i.e. emits non-0 values.
MASM 8 (from VS 2005 Beta) matches the COFF spec for 64-bit object
files, i.e. emits 0.
GAS matches the COFF spec for 32-bit object files (MinGW or Cygwin),
i.e. also emits 0.
Older versions of GNU ld seem to honor said "Virtual Size" field
whereas newer versions do not. As a result those older versions
generate "bloated" image files.
Since the COFF spec and the real world seem to disagree for this case,
it might make sense to add a method for selecting between the two to
NASM.
Date: 2005-11-28 15:39
Sender: nasm64developer
Logged In: YES
user_id=804543
MASM 8 (from VS 2005 Beta) also matches the COFF spec for 16- and
32-bit object files, i.e. emits 0.
That said, NASM should always emit 0 too. Therefore I am turning this
from a support request into a bug.
Minor fixes to make it possible to compile with MS Visual C++ 2005.
Unfortunately, MSVC++ is not fully C99 compliant; in particular, it
doesn't handle interspersed declarations and other code. Furthermore,
it chokes on some expressions in outelf64.c, which fortunately can be
easily substituted with simpler expressions.
Finish the perfect hash tokenizer, and actually enable it.
Move stdscan() et al to a separate file, since it's not needed in any
of the clients of nasmlib other than nasm itself.
Run make alldeps.
Move anything compiler-specific to "compiler.h".
There was an unguarded use of __attribute__(()) in outmacho.c; also
require gcc 4+ for __builtin_ctlz(). Speed up the open-coded version, too.
- Remove obsolete types like "uint32"; use "uint32_t" consistently.
- Make sure we include <inttypes.h> where needed.
- Header file guards should be FOO_H or SUBDIR_FOO_H; _FOO_H infringes
on the C implementation's namespace and should only be used when
writing libc!
- Change a few "int8_t" back to "char" where appropriate. There are
a lot more places where that should be done, though.
- Clean up the check for getuid/getgid in rdoff/rdlar.h.
Change symbols from saa to explicitly allocated.
macho_layout_symbols: new function to sort symbols and renumber.
adjust symtab output accordingly
fixup relocs after renumbering
add relocation debugging routines.
Export/import/common label size is increased from 33 to 64. Fixed the bug
that caused wrong behavior of rdfgetheaderrec() if label length was 32.
Changed error codes from numeric values to symbolic constants.
Moved some routines from rdfdump.c to rdoff.c. They will be utilized also
by rdfdisasm, which is being developed.