Commit graph

237 commits

Author SHA1 Message Date
Cyrill Gorcunov
6837749d85 ofmt: Introduce output format aliases
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>
2010-04-10 00:11:00 +04:00
Cyrill Gorcunov
f134cc63da Elf: Some unification snippets for 32/64 bit versions
Nothing serious, comments and style movements.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-04-10 00:10:38 +04:00
Cyrill Gorcunov
e3c4791300 Elf: Merge WRITE_STAB to outelf.h
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-04-10 00:10:20 +04:00
Cyrill Gorcunov
6620d1aa6d Elf: Drop never used SOC helper
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-04-10 00:10:07 +04:00
Cyrill Gorcunov
572dd0021c Elf: Introduce section_attrib helper
In a sake of removing code duplication.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-04-10 00:02:38 +04:00
Cyrill Gorcunov
6fe313a719 output/outbin.c: Fix misprinted alignment bound
Due to a misprint in commit
9b66d8e4c3

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-02-11 21:49:58 +03:00
Cyrill Gorcunov
3cbd9e7215 Elf: Drop useless SEG_ALIGN_1
No need for SEG_ALIGN_1 since we have switched
to ALIGN helper.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-02-11 21:28:34 +03:00
Cyrill Gorcunov
9b66d8e4c3 Use ALIGN helper
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-02-11 21:28:30 +03:00
Cyrill Gorcunov
a135658e83 ELF: Explicitly point out SYM_GLOBAL, SYM_LOCAL binding
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>
2010-01-03 15:04:46 +03:00
Cyrill Gorcunov
de623f2679 elf.h: Add ELFXX_ST_MKBIND and move ELFXX_ST_ helpers
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>
2010-01-03 15:04:41 +03:00
Cyrill Gorcunov
126faf2e3b output/outelfX.c: Use definitions from stabs.h
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>
2010-01-03 15:04:36 +03:00
Cyrill Gorcunov
d1428b23da Add common STABs definition into output/stabs.h
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-01-03 15:04:31 +03:00
Cyrill Gorcunov
c9862c009b outelfX.c: Trivial cleanup
Some tab\space convertions together with
trivial style nitfix.

No change on binary level.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-01-03 15:04:26 +03:00
Cyrill Gorcunov
3b4c769d99 Elf: Allow symbols binding to undefined section
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>
2010-01-02 23:00:43 +03:00
Cyrill Gorcunov
2ddcd03900 Elf: bind labels to text section by default
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>
2009-12-10 00:36:37 +03:00
H. Peter Anvin
3c9d7ea8a6 outrdf.c: remove obsolete file
The old RDF format has been unsupported for long time now.  Remove it
from the tree.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-11-30 13:27:49 -08:00
H. Peter Anvin
3b861a7766 outform.h: fix OF_NO_RDF2
OF_NO_RDF2 should turn off OF_RDF2, not OF_RDF

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-11-30 13:26:34 -08:00
H. Peter Anvin
b512fb56db outmacho32: replace error() -> nasm_error()
Somehow outmacho32.c escaped the global change of error variables to
hard-coded nasm_error().

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-11-30 11:27:47 -08:00
Cyrill Gorcunov
bc0113d977 outcoff: BuildExportTable -- tab/space fix
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>
2009-11-17 23:25:15 +03:00
Cyrill Gorcunov
bf8cebd813 outcoff: Do not fail on long export identifiers
If an export identifier is greater then 241 symbols
we do fail due to buffer overflow. Fix it.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2009-11-17 20:49:58 +03:00
Cyrill Gorcunov
2e7a84b829 outelf32/64 - various cleanups in a sake of unification
Make a small step forward elf32/64 unification procedure.
Mostly style fixes. Nothing serious.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2009-11-06 22:00:59 +03:00
Cyrill Gorcunov
b15ed1f836 dwarfX_output: dont check for "ln" twice
And make dwarf64 version to be more familiar to
32bit version (preparation work for merge).

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2009-11-06 22:00:54 +03:00
Cyrill Gorcunov
24f9398a6f output/outelf64.c: simplify stabs64_cleanup, dwarf64_cleanup
nasm_free is failsafe against NULL passed

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2009-11-06 22:00:49 +03:00
Cyrill Gorcunov
a50f829435 Merge elf header files
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>
2009-11-06 22:00:41 +03:00
Cyrill Gorcunov
a353955a8d output/outelf32-64: use string helpers
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2009-10-31 20:03:29 +03:00
Cyrill Gorcunov
54e94a56e2 Remove outdated comments
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>
2009-10-31 20:03:14 +03:00
Cyrill Gorcunov
917117ff69 stdscan: switch to stdscan_get/set routines
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>
2009-10-31 20:02:43 +03:00
Keith Kanios
d2a553c072 BR 2840300: fix macho symbol alignment bug 2009-10-16 21:53:59 -05:00
Cyrill Gorcunov
69c4f63c25 elf,stabs: stabs32/64_generate -- append ending token
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>
2009-09-14 22:43:30 +04:00
Cyrill Gorcunov
28032a027c output/elfcommon.h: tab/space cleanup
No change on binary level

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2009-09-06 15:25:35 +04:00
Cyrill Gorcunov
7ea1ef1c84 output/outelf32.c: code style simplification
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>
2009-09-03 20:16:28 +04:00
Cyrill Gorcunov
6ae5903676 output/outelf32.c: tab-space cleanup
Together with a small style nitpicking.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2009-09-03 20:02:33 +04:00
Cyrill Gorcunov
82a440da6d output/elf64.h: tab-space cleanup
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2009-09-03 19:10:55 +04:00
Cyrill Gorcunov
c5e7878943 output/elf32.h: tab-space cleanup
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2009-09-03 19:06:04 +04:00
Cyrill Gorcunov
2cff224e4b output/outelf.h - tab-space cleanup
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2009-09-03 19:04:23 +04:00
Victor van den Elzen
0dd450c0ef Use fputs instead of fprintf for plain strings
LLVM's Clang warns about this. outieee.c had a real problem.
2009-08-13 15:07:59 +02:00
Victor van den Elzen
15bb233036 Fix some format strings for nasm_error
Added a format attribute to nasm_error (only for GCC) and
used the resulting warnings to fix some format strings.
2009-08-11 02:43:41 +02:00
Cyrill Gorcunov
5a49e7c578 output/dwarf.h: update dwarf constants
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>
2009-08-10 16:00:43 -07:00
H. Peter Anvin
767750b666 output: change null_debug_routine to null_debug_directive
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>
2009-08-09 13:04:13 -07:00
Cyrill Gorcunov
6f742649fe output/outbin.c -- use list helpers
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2009-08-01 23:52:25 +04:00
Cyrill Gorcunov
a95a76a868 outaout.c -- use list helpers
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>
2009-07-28 23:26:12 +04:00
H. Peter Anvin
e39dc8c5b2 Merge branch 'nasm-2.07.xx' 2009-07-26 15:31:59 -07:00
H. Peter Anvin
7ad24562dc BR 2827397: fix invalid C in outcoff AddExports()
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>
2009-07-26 15:29:09 -07:00
H. Peter Anvin
605f5155ee Drop the ofmt and errfunc arguments to label definition functions
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>
2009-07-18 18:43:58 -07:00
H. Peter Anvin
9bd1506d59 Remove function pointers in output, simplify error handling
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>
2009-07-18 18:43:12 -07:00
H. Peter Anvin
159178f2aa Merge commit 'nasm-2.07rc7' into new-preproc 2009-07-17 00:55:17 -04:00
H. Peter Anvin
a5fd1ca895 outcoff: fix invalid reference to ofmt
ofmt is a static in nasm.c (why?), not a global...

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-16 22:46:34 -04:00
H. Peter Anvin
d1904c6cbb outcoff: this is COFF, not binary
Fix error message in outcoff to say COFF, not binary format...

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-16 22:44:19 -04:00
Keith Kanios
e5b9d2dac0 outform.h: update comments regarding macho32/macho64 2009-07-16 21:13:10 -05:00
H. Peter Anvin
68bec0872f outobj: don't fclose() the output
Missed fclose() in outobj when converting system to global fclose().

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-07-14 14:47:04 -04:00