Commit Graph

17 Commits

Author SHA1 Message Date
H. Peter Anvin
d235408c65 preproc: standard macros now C-safe, %aliases off, fix %? recursion
Enough users expect the namespace starting with underscore to be safe
for symbols. Change our private namespace from __foo__ to
__?foo?__. Use %defalias to provide backwards compatiblity (by using
%defalias instead of %define, we handle the case properly where the
user changes the value.)

Add a preprocessor directive:

%aliases off

... to disable all smacro aliases and thereby making the namespace
clean.

Finally, fix infinite recursion when seeing %? or %?? due to
paste_tokens(). If we don't paste anything, the expansion is done.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2019-08-27 16:42:41 -07:00
H. Peter Anvin
e38654a24e BR 3392411: smartalign: make sure we always define the end symbol
We need to always define the end symbol, otherwise we might find
ourselves in a situation where the alignment code grows (common!) and
then the symbol is defined late.

Reported-by: ig <glucksmann@avast.com>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-09-27 15:29:01 -07:00
H. Peter Anvin
f29123b936 smartalign.mac: Ignore smartalign in preprocess-only mode
When running in preprocess-only mode generate the equivalent of
standard alignment using nops.  This at the very least allows some
kind of reasonable output and allows for dependency generation to
proceed; the only way to *really* address this problem is to move
alignment generation into the assembler proper; this would also allow
the align/alignb distinction to be removed and handle padding with
instructions which are more than one byte.

This should resolve bug 3392319.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2016-01-15 11:03:40 -08: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
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
H. Peter Anvin
143689d35d Add copyright headers to standard macro packages
These are all recent and written by me.  BSD license them.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-06-28 17:18:13 -07:00
H. Peter Anvin
a168ab1e01 smartalign: clean up unnecessary duplication; tweak dependencies
Remove unnecessary duplicated patterns; with indirection we can handle
lists of any length.

For 16-bit generic padding, alternate between SI and DI dependencies.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2008-10-25 17:48:33 -07:00
H. Peter Anvin
f991f5ae56 smartalign: use a "times" construct rather than %rep
Use a "times" construct rather than "%rep" for higher performance.
No need to preprocess the same line over and over for no good reason.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2008-10-19 16:45:27 -07:00
H. Peter Anvin
777cdbee01 smartalign: rewrite to use the indirect construct, %[...]
This code can be made so much smaller with clever use of the
indirection construct.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2008-10-19 16:38:28 -07:00
Victor van den Elzen
fd49408ed9 Already aligned aligns should be 0 bytes, not %1. 2008-10-01 13:21:02 +02:00
H. Peter Anvin
152656f8d3 Actually make non-power-of-2 alignments work
We can't use ($$-$) % (%1) since the wraparound will be wrong except
for powers of 2.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2008-09-25 02:31:50 -07:00
H. Peter Anvin
7f0ac96fed smartalign: use context-local label
Use a context-local label in the smart align macro.
2008-07-17 14:28:29 -07:00
H. Peter Anvin
ca66ec5eec smartalign: adjust the alignment threshold
Apparently the current recommendation is for a smaller threshold when
using the "generic"-style alignment macros (short jumps are cheaper on
newer CPUs.)

Also change the alignment threshold definition to reflect the maximum
number of padding instead of when to start using jumps.
2008-07-17 14:22:10 -07:00
H. Peter Anvin
1ac41d34ba smartalign: 16-bit generic alignment macros
Smart alignment content for 16-bit "generic" mode
2008-07-17 14:20:06 -07:00
H. Peter Anvin
47b0c2d428 smartalign: 16-bit P6 NOPs
Add 16-bit P6 NOPs
2008-07-17 14:13:53 -07:00
H. Peter Anvin
f5975eead1 smartalign.mac: smart alignments macro package
"%use smartalign" followed by an optional "alignmode" can be used to
enable smart macros.
2008-07-16 14:41:39 -07:00