Commit graph

2057 commits

Author SHA1 Message Date
Cyrill Gorcunov
3834305507 coff: Allow alignment greater then 64 bytes on win
On win32/64 we have no 64 bytes limit so hit it on
"coff" target only.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-04-22 19:06:03 +04:00
Cyrill Gorcunov
7c8c258cdd coff: Fix section alignment computation
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>
2010-04-22 19:05:50 +04:00
Cyrill Gorcunov
42017a6115 coff: Use predefined macros instead of numbers and style fix
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-04-22 19:03:56 +04:00
Cyrill Gorcunov
641ca7fd6a ilog2: Use ROUND helper
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-04-22 19:03:39 +04:00
Cyrill Gorcunov
c8fd6fdae4 ilog2: Get rid of tabs
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-04-22 19:02:35 +04:00
Cyrill Gorcunov
557a57bd55 pecoff.h: Complete header
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>
2010-04-22 19:02:22 +04:00
H. Peter Anvin
35c30da61b Remove open-coded ilog2() implementations
When we need integer log2, use the new library routine.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2010-04-21 16:46:57 -07:00
H. Peter Anvin
084b13227e Add generic ilog2 functions
Add ilog2_{32,64}() and alignlog2_{32,64}() ... the latter is intended
for alignment statements and return -1 for non-power-of-2 other than 0
(which returns 0).

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2010-04-21 16:43:20 -07:00
H. Peter Anvin
34543131ca Makefile: clean up the lib directory on make clean
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2010-04-21 16:41:37 -07:00
Cyrill Gorcunov
900b2229e4 standard.mac: Update section alignment on align call
Achieved via sectalign call. Note that not all output
targets (ie formats) may handle sectalign yet, most
of them just ignore this entity.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-04-21 23:52:57 +04:00
Cyrill Gorcunov
83ffe8ca24 coff: Use predefined macro in common section flags
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-04-21 22:40:11 +04:00
Cyrill Gorcunov
d0c6dbe0fe coff: Use predefined macro and eliminate open coded constants
Not all are covered but process initiated.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-04-21 22:03:33 +04:00
Cyrill Gorcunov
d71d876f46 pecoff.h: Add more constants
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-04-21 21:47:03 +04:00
Cyrill Gorcunov
4c8e74e176 make: Update pecoff.h related deps
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-04-21 18:51:14 +04:00
Cyrill Gorcunov
2ece71588c pecoff: Update machine types
Update up to pecoff v8

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-04-21 18:46:27 +04:00
Cyrill Gorcunov
8906629f4f output: Introduce pecoff.h
Better to have common constants grouped.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-04-21 18:10:04 +04:00
Cyrill Gorcunov
f8dc028c07 coff: Implement sectalign handler
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-04-21 18:10:00 +04:00
Cyrill Gorcunov
2ef5c27be7 Rename SEGALIGN to SECTALIGN
"sectalign" is preferred over "segalign"
since it operates over section attributes.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-04-21 18:09:54 +04:00
Cyrill Gorcunov
1f3db76ee9 smartalign.mac: align macro should align a segment as well
This change may have backward compatibility issue but
most probably the sane program never used sections with
base address less then instruction alignment.

Note that alignment may only increase which means if a
section is aligned on 2^5 the align 2^4 will not affect
the section.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-04-21 01:22:31 +04:00
Cyrill Gorcunov
c56a7a2c82 Elf64: Implement segalign handler
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-04-21 01:15:28 +04:00
Cyrill Gorcunov
f68feb08c2 Elf-32: Implement segalign handling
Via elf_segalign helper

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-04-21 01:09:02 +04:00
Cyrill Gorcunov
2a587ab1c9 ofmt: Implement null_segalign stubs
Set stubs for all targets

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-04-21 01:08:36 +04:00
Cyrill Gorcunov
d5f2aef30a Introduce SEGALIGN directive
No real handling yet though. Definition only.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-04-21 01:07:47 +04:00
Cyrill Gorcunov
d7a64b72a2 labels.c: lookup_label -- should return bool unconditionally
Better to not put return under condition. It was bad.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-04-21 01:07:25 +04:00
Cyrill Gorcunov
92aa187f3a smartalign: Introduce nojmp mode
This allows to force nasm to generate multibyte
NOPs without jmp injected.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-04-21 01:06:53 +04:00
Cyrill Gorcunov
d807d911fe Elf: Rename SEG_ALIGN to SEC_FILEALIGN
It's Elf specifics. To not mess with segment alignment.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-04-21 01:06:44 +04:00
Cyrill Gorcunov
8d4d060104 Add "win" alias for "win32" output format
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>
2010-04-21 01:06:36 +04:00
Cyrill Gorcunov
66206e7bd8 nasm.c: Delete redundant goto
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-04-21 01:06:27 +04:00
Cyrill Gorcunov
ba3c0513dd Elf: switch section_attrib to a new nasm_opt_val interface
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-04-11 13:12:20 +04:00
Cyrill Gorcunov
370e5a94c9 nasmlib.c: Make nasm_opt_val robust
nasm_opt_val should be able handle various text stream
passed, including tainted ones. Make it so.

Also it fixes the case when Elf section has multiple
attributes such as "progbits align=16" and friends
(introduced by commit bb0745f). The former just ignore
any other options/values except first one.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-04-11 13:00:58 +04:00
Cyrill Gorcunov
6702d93c10 nasmlib.c: Introduce nasm_get_word helper
For easier space separated words extraction
from a text stream.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-04-11 12:58:09 +04:00
Cyrill Gorcunov
c084467eba Elf: Use SHA_ANY constant instead of open coded number
SHA_ANY is not part of Elf specification but rather our own symbolic
definition for convenience.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-04-11 12:58:05 +04:00
Cyrill Gorcunov
367d59e272 expand_mmacro: Use list helpers
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-04-10 00:13:57 +04:00
Cyrill Gorcunov
f32ed14ebd detoken: Use list_for_each helpers
And a few style nits.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-04-10 00:13:53 +04:00
Cyrill Gorcunov
ed4a805b0a expand_smacro: stylish nits
- no need to split functions even if it a bit longer
  then 80 characters, it becomes hard to read it

- initialize "thead" before "tail" is more natural

- use more simple while() instead of for() with a
  long initializer

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-04-10 00:13:49 +04:00
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
376b8106d2 nasmdoc.src: Refer to ..imagebase in special symbols area
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-04-10 00:02:51 +04:00
Cyrill Gorcunov
9b60308282 nasmlib: Do not hang on if log file creation has been failed
In case if we can't open "malloc.log" for writing
we should not hang out but rather switch to stderr
and continue processing.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-04-10 00:02:46 +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
bb0745f432 nasmlib: Introduce nasm_trim_spaces and nasm_opt_val helpers
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-04-10 00:02:32 +04:00
H. Peter Anvin
28711d949a directives.pl: trivial formatting fix
Fix whitespace alignment.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2010-04-07 16:56:24 -07:00
H. Peter Anvin
a36a4f2f1d nasm.c: smarter handling of missing directives
If we get D_unknown, we definitely don't need to pass it to the
backend for analysis.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2010-04-07 16:54:56 -07:00
H. Peter Anvin
8adfa72441 directives.pl: compensate for *two* specials, not just one
We need to compensate the index for two specials, not just one.  While
we're at it, actually derive the number of specials from the list.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2010-04-07 16:53:33 -07:00
H. Peter Anvin
888964a880 Distinguish no directive present from unknown directive
Distinguish the case of no directive present (D_none) from the case of
an unknown specified directive (D_unknown).  This is reflected in
different error messages.

Furthermore, change the special case symbols to lower case in case we
ever have a directive called [none] or [unknown].

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2010-04-06 17:00:12 -07:00
Cyrill Gorcunov
cdcd1f7ac4 BR2979629: vsnprintf: Use nasm_malloc
There is no nasm_malloc_error helper anymore.
Use nasm_error instead.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-04-01 01:17:00 +04:00
Cyrill Gorcunov
5d269789a5 vsnprintf: Style nitfix
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-04-01 01:09:35 +04:00
Cyrill Gorcunov
1f6a046d85 BR2975768: Update AMD LWP instructions to match upcoming changes
The former changes have been committed to binutils.
From initial message:

|
| 2010-03-22 Quentin Neill <quentin.neill@amd.com>
|           Sebastian Pop  <sebastian.pop@amd.com>
|
|	opcodes/
|	* i386-dis.c (OP_LWP_I): Removed.
|	(reg_table): Do not use OP_LWP_I, use Iq.
|	(OP_LWPCB_E): Remove use of names16.
|	(OP_LWP_E): Same.
|	* i386-opc.tbl: Removed 16bit LWP insns.  32bit LWP insns
|	should not set the Vex.length bit.
|	* i386-tbl.h: Regenerated.
|
|	gas/
|	* testsuite/gas/i386/x86-64-lwp.s: Remove use of 16bit LWP insns.
|	* testsuite/gas/i386/lwp.s: Same.
|	* testsuite/gas/i386/x86-64-lwp.d: Updated.
|	* testsuite/gas/i386/lwp.d: Updated.
|

So there is no 16 bit instructions anymore.
Also xop.l field should be set to 0.

Based on patch from nasm64developer

Reported-by: nasm64developer
Signed-off-by: nasm64developer
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-03-25 00:37:26 +03:00