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>