Commit graph

39 commits

Author SHA1 Message Date
Anonymous Maarten
430e4f55c0
subminor of a macho buildversion is optional (#304)
This fixes a difference in behavior between yasm built by autotools and cmake (due to different compile flags)
2026-07-20 22:30:44 -07:00
Peter Johnson
41762bead1
Update Mach-O for newer macOS (#180)
- Create a dummy .llvmasm section for bitcode
- Add [buildversion] directive for setting minos and sdk versions, e.g. [buildversion minos="10.14" sdk="10.14"]. This defaults to 10.5 on x64 and 10.4 on x86.
2021-07-10 12:12:45 -07:00
Peter Johnson
00c85278d1 Warnings cleanup. 2014-08-10 11:39:20 -07:00
Nico Weber
203bc94f39 Don't use a C++ comment in a C source file. 2012-03-10 22:52:34 -08:00
Nico Weber
01ab853e68 In the Mach-O writer, only warn on ignored flags if the new flags
are different from the old flags.

Fixes http://tortall.lighthouseapp.com/projects/78676-yasm/tickets/246
2012-03-06 17:40:41 -08:00
Peter Johnson
e11ea9df14 Add missing macho32-pext test case. 2011-09-03 21:18:08 -07:00
Peter Johnson
7d58243134 macho: Support N_PEXT bit.
Can be enabled via use of "private_extern" in NASM syntax.

Patch by: Hironori Bono

[#215 state:resolved]
2011-08-27 10:01:26 -07:00
Peter Johnson
94ab1135a3 Remove $Id$ and RCSID() usage.
These are useless now that we're using git.
2011-08-19 10:43:16 -07:00
Peter Johnson
abaf3f7d49 macho32: Correctly output pc-relative non-external intersegment.
Reported by: Justin Lebar <justin.lebar@gmail.com>

svn path=/trunk/yasm/; revision=2345
2010-08-01 01:27:40 +00:00
Peter Johnson
a4024ab0ca macho: Fix relocation table file location.
svn path=/trunk/yasm/; revision=2344
2010-08-01 01:05:04 +00:00
Peter Johnson
472838271c Fix #212: Set LC_SEGMENT vmsize correctly.
svn path=/trunk/yasm/; revision=2338
2010-07-23 03:08:24 +00:00
Peter Johnson
323153d55a Instead of initializing unknown sections en-masse during objfmt_output(),
add new objfmt interface function init_new_section() to initialize as we
go.

This fixes several issues, primarily with debug formats that create sections.

Reported by: Brian Gladman

svn path=/trunk/yasm/; revision=2310
2010-03-28 19:28:54 +00:00
Peter Johnson
b7a38ed4fd Allow @ signs in identifiers in win32/win64 only.
In ELF, @ is used to indicate special relocations.

Fixes #164.

Reported by: Gregory McGarry on yasm-devel@
Testcase by: Gregory McGarry

We don't allow identifiers to start with @; doing so conflicts with use of
e.g. "@function" in some directives.  Need to look into what GAS does.

svn path=/trunk/yasm/; revision=2166
2009-01-02 08:33:21 +00:00
Peter Johnson
6eaa345a2c Fix Mach-O alignment handling by aligning start and end of every section.
Reported and patch by: David DeHaven <dave@sagetv.com>

svn path=/trunk/yasm/; revision=2161
2008-12-07 02:49:22 +00:00
Peter Johnson
53b2d01a77 Fix #132: Add --prefix and --suffix (aka --postfix) options.
These allow arbitrary prefixes and/or suffixes to be added to
externally-visible (GLOBAL, EXTERN, or COMMON) symbol names.

svn path=/trunk/yasm/; revision=2109
2008-06-08 09:06:05 +00:00
Peter Johnson
3aab66a119 Fix #141: Add macho64 PIC support.
The way PIC relocations are generated for macho64 requires a bit of a hack
to detect MOV opcodes and generate GOT_LOAD relocs.
GAS contains a similar hack.

svn path=/trunk/yasm/; revision=2108
2008-06-05 08:48:21 +00:00
Peter Johnson
b7f2fbc64f Add cmake build infrastructure.
Not default nor even distributed in the .tar.gz, the cmake build allows for
loadable yasm plugins by building libyasm as a shared library.
Example plugins are in the plugins/ directory, and may be loaded into a
cmake-built yasm using the -N command line option (non-cmake builds will
not have this option).

Tested only on Linux so far, but should be relatively painless to port to
Windows thanks to the use of cmake rather than libtool to create shared
libraries.

The only modification to the main source tree is some conditional-compiled
additions to yasm.c.

svn path=/trunk/yasm/; revision=2098
2008-05-22 09:08:03 +00:00
Peter Johnson
cbf0c7befd Split NASM preprocessor standard macro set between various modules.
Standard macro sets are looked up based on parser and preprocessor keyword
from individual modules.

The "standard" NASM parser macros now reside in the NASM parser, so when
the GAS parser is used with the NASM preprocessor, the NASM-specific macros
are no longer defined.

Object-format specific macros are now individually defined by each object
formatm module.  This allows for the object formats to be independent of the
NASM preprocessor module and yields a small optimization benefit as unused
object format macros don't need to be skipped over.

Also add GAS macro equivalents for the Win64 SEH more complex directives [1].

[1] Requested by Brian Gladman <brg@gladman.plus.com>

svn path=/trunk/yasm/; revision=2082
2008-05-09 06:46:02 +00:00
Peter Johnson
04039380d1 Enable use of sym@FOO constructs in GAS parser.
To do this, restructure how special symbols are handled between the parser
and object format.  Instead of creating special symbols with the right
names, instead have the parser call the object format to see if a match
is found into the special symbols, which are no longer stored in the
symbol table.

svn path=/trunk/yasm/; revision=2035
2008-02-09 03:35:07 +00:00
Peter Johnson
02075ed7ca Fix #123: Be explicit that errors are such by printing "error:" at beginning
of error messages.

svn path=/trunk/yasm/; revision=2019
2007-12-04 06:19:07 +00:00
Peter Johnson
52affeb01a Add NASM-compatible multi-section binary support to bin object format.
This allows for arbitrary load (LMA) and execution (VMA) addresses.

The following new section attributes are supported:
 - start (LMA start address)
 - follows (follow another section's last LMA)
 - align (LMA alignment)
 - vstart (VMA start address)
 - vfollows (follow another section's last VMA)
 - valign (VMA alignment)
In addition, sections can be designed progbits or nobits.

The following special symbols are generated for program use:
 - section.<sectname>.start (LMA start address)
 - section.<sectname>.vstart (VMA start address)
 - section.<sectname>.length (section length)

The ORG directive adjusts the file offset relative to LMA, so that if
ORG=0x100, a section with LMA=0x100 will be at file offset 0.

VMA addresses are the same as LMA addresses unless otherwise specified.

Full map file support is supported via the [MAP] directive.  The map output
filename can be set either as a parameter to the [MAP] directive or on the
command line with --mapfile=<filename>.  MAP options are BRIEF, SECTIONS,
SEGMENTS, SYMBOLS, and ALL (all of the above).  If no filename is specified
either on the command line or in the source file, the map is output to
standard output.

Full documentation will be added to the Yasm manual in the near future.

This implementation supports several configurations NASM does not, for
instance http://osdir.com/ml/lang.nasm.devel/2004-12/msg00032.html .
It is also fully 64-bit aware.

Fixes: #71, #99.

svn path=/trunk/yasm/; revision=2010
2007-11-14 08:33:32 +00:00
Peter Johnson
2bb74148c1 Merge expr-int.h into expr.h, removing YASM_EXPR_INTERNAL in the process.
svn path=/trunk/yasm/; revision=1895
2007-07-14 05:31:08 +00:00
Peter Johnson
a958ef6df8 Merge bc-int.h into bytecode.h, removing YASM_BC_INTERNAL in the process.
svn path=/trunk/yasm/; revision=1894
2007-07-14 04:34:41 +00:00
Peter Johnson
ab13bd719e Remove YASM_LIB_INTERNAL. It never really gained us that much in terms of
visibility savings, as basically everything defined it.

svn path=/trunk/yasm/; revision=1893
2007-07-14 03:11:32 +00:00
Peter Johnson
c12eca767a Fix uninitialized variable, memory leak.
svn path=/trunk/yasm/; revision=1872
2007-06-02 08:23:29 +00:00
Peter Johnson
cfbeb3bebc Fix typo in filename reference in [1853].
svn path=/trunk/yasm/; revision=1854
2007-05-31 06:16:49 +00:00
Peter Johnson
d2fe9a793c Fix #102: Permit non-standard macho section names.
Two forms are legal ({} are replaceables):
SECTION {segname} {sectname}
SECTION {sectname} segname={segname}
Also,
SECTION {sectname}
where sectname is unrecognized is also legal, defaults segname to __TEXT,
and generates a warning.

Contributed by: bird-yasm@anduin.net

svn path=/trunk/yasm/; revision=1852
2007-05-28 08:52:18 +00:00
Peter Johnson
3e5fed2ad1 Clean up directive handling. This standardizes error/warning messages and
makes value/parameters more well-defined and flexible enough to handle
string parameters.  Value/parameters would now be better called name/values,
but avoid changing the name for now.

svn path=/trunk/yasm/; revision=1851
2007-05-26 17:56:36 +00:00
Peter Johnson
4bfff483e5 Move absolute section handling into NASM parser, removing all traces of it
from libyasm core.  Now absolute sections are tracked locally to the parser
and the parser generates EQUs directly for labels in absolute sections.

Fixes #106 and #103.

svn path=/trunk/yasm/; revision=1842
2007-05-15 07:27:26 +00:00
Peter Johnson
00473ca981 Bite the bullet and convert tabs to spaces. Previously yasm's source has
been using a mix of tabs and 4 spaces to indent; this looks horrible if
tab size is ever not 8.  While I debated converting to tab-only indentation
that would have been a far higher impact to the source.

svn path=/trunk/yasm/; revision=1825
2007-04-22 03:32:46 +00:00
Peter Johnson
decb27eaa2 Massive update of directive handling, including handling of extern, global,
and common declare.  The latter no longer passes through objfmt at parse time;
instead the objfmt must handle them at output time (objfmt-specific
extensions are parsed & stored by the parser).  Directives are now handled
using a list (with function pointers) rather than a single function entry
point.

svn path=/trunk/yasm/; revision=1819
2007-03-21 04:23:59 +00:00
Peter Johnson
415eee49ea Restructure yasm_object as the central clearing house for yasm_objfmt,
yasm_dbgfmt, and yasm_arch.  This eliminates a lot of redundant keeping
track of this information in the individual object and debug formats and
also simplifies a fair amount of code.

I'm still not happy with how arch gets passed around in output code, but
there may not be much of an alternative there.

While I'm here, clean up some unused variables and functions and re-enable
the warning for unused variables in configure.ac.

svn path=/trunk/yasm/; revision=1812
2007-03-05 08:43:00 +00:00
Peter Johnson
4fb65a432b Mach-O object format: 0-fill unused portion of section and segment names
in load commands.  This caused test miscompares on other platforms and
could conceivably cause yasm to crash by reading beyond proper boundaries
(but this is unlikely).  Functionally the output is the same.

Reported by: christophe.malvasio1@aliceadsl.fr

Backport in: 1 week

svn path=/trunk/yasm/; revision=1811
2007-03-04 09:21:03 +00:00
Peter Johnson
2f2180767d Massive warnings cleanup and cleanup of size_t vs uintptr_t vs unsigned long.
svn path=/trunk/yasm/; revision=1792
2007-02-24 20:19:27 +00:00
Peter Johnson
9cf646aa2b Revamp macho object format design, fixing some bugs in the process.
No new features yet.

svn path=/trunk/yasm/; revision=1777
2007-02-19 08:21:17 +00:00
Peter Johnson
e7b1cea7ff Allow directives to have no parameters in the parser, and check for it at
a lower level.

To reduce code duplication, refactor several of the large if/else structures
into multiple functions with a lookup table.

Add support for registers to be used in directive expressions.

Allow directives to have underscores and numbers (still cannot start with
numbers).

svn path=/trunk/yasm/; revision=1757
2007-02-07 08:29:41 +00:00
Peter Johnson
96c34438da macho-objfmt.c: Fix unused variable warning.
svn path=/trunk/yasm/; revision=1756
2007-02-06 07:42:52 +00:00
Peter Johnson
b2054b00ee Unbreak distcheck (missing test shell scripts from EXTRA_DIST).
svn path=/trunk/yasm/; revision=1733
2007-01-15 17:54:46 +00:00
Peter Johnson
7f68927283 Initial commit of Mach-O object format.
Contributed by: Henryk Richter <henryk.richter@comlab.uni-rostock.de>

This adds 3 object format keywords: macho, macho32, macho64.  These work in
the same way as elf, elf32, and elf64.  The object format is still a work
in progress; amongst other things it does not yet support full cross-section
references (othersym1-othersym2), dynamic linking, or GAS input syntax.  We
will continue to improve and work on these features in the near future.

svn path=/trunk/yasm/; revision=1732
2007-01-13 19:34:04 +00:00