In order to support Mach-O better, add support for subsections, as
used by Mach-O "subsections_via_symbols". We also want to add
infrastructure to support this by downcalling to the backend to
indicate if a new subsection is needed.
Currently this supports a maximum of 2^14 subsections per section for
Mach-O; this can be addressed by adding a level of indirection (or
cleaning up the handling of sections so we have an actual data
structure.)
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
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>
The 2-operand form was inherently unsafe. Use the 3-operand form
instead, which guarantees that arbitrary filenames are supported.
This also means we can remove a few instances of sysopen() which was
used for exactly this reason, however, at least in theory sysopen()
isn't portable.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
The ordering of the macro sets ended up changing due to the recent
file reorganization. Instead of forcing the order again, handle
multiple macro sets (rather than just two) in a coherent manner.
macros/macros.pl could use a cleanup of duplicated code, however.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Make the source code easier to understand and keep track of by
organizing it into subdirectories depending on the function.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
There is no reason why the warning-generating ilog2 has to be only the
floor variant. However, I am pretty sure we can simply implement the
ilog2cw() as a macro only; we can always fix that if that turns out to
be incorrect.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
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>
Add general support in the function parser for "integer functions"
(actually implemented as special unary operators, then wrapped in
macros) and implement a family of integer logarithms. The only
difference is the behavior on a non-power-of-two argument:
ilog2[e] -- throw an error
ilog2w -- throw a warning
ilog2f -- round down to power of 2
ilog2c -- round up to power of 2
This is useful for back-converting from masks to bit values.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
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>
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>
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>
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.
Add a builtin equivalent to the %include directive called %use.
%use includes a standard macro file compiled into the binary; these
come from the macros/ directory in the source code.
The idea here is to be able to provide optional macro packages with
the distribution, without adding complex host filesystem dependencies.