/* ----------------------------------------------------------------------- * * * Copyright 1996-2017 The NASM Authors - All Rights Reserved * See the file AUTHORS included with the NASM distribution for * the specific copyright holders. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following * conditions are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials provided * with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * ----------------------------------------------------------------------- */ /* * outas86.c output routines for the Netwide Assembler to produce * Linux as86 (bin86-0.3) object files */ #include "compiler.h" #include "nctype.h" #include "nasm.h" #include "nasmlib.h" #include "error.h" #include "saa.h" #include "raa.h" #include "outform.h" #include "outlib.h" #ifdef OF_AS86 struct Piece { … }; struct Symbol { … }; /* * Section IDs - used in Piece.number and Symbol.segment. */ #define SECT_TEXT … #define SECT_DATA … #define SECT_BSS … /* * Flags used in Symbol.flags. */ #define SYM_ENTRY … #define SYM_EXPORT … #define SYM_IMPORT … #define SYM_ABSOLUTE … struct Section { … }; static struct Section stext, sdata; static uint32_t bsslen; static int32_t bssindex; static struct SAA *syms; static uint32_t nsyms; static struct RAA *bsym; static struct SAA *strs; static size_t strslen; static int as86_reloc_size; static void as86_write(void); static void as86_write_section(struct Section *, int); static size_t as86_add_string(const char *name); static void as86_sect_write(struct Section *, const uint8_t *, uint32_t); static void as86_init(void) { … } static void as86_cleanup(void) { … } static int32_t as86_section_names(char *name, int *bits) { … } static size_t as86_add_string(const char *name) { … } static void as86_deflabel(char *name, int32_t segment, int64_t offset, int is_global, char *special) { … } static void as86_add_piece(struct Section *sect, int type, int32_t offset, int32_t segment, int32_t bytes, int relative) { … } static void as86_out(int32_t segto, const void *data, enum out_type type, uint64_t size, int32_t segment, int32_t wrt) { … } static void as86_write(void) { … } static void as86_set_rsize(int size) { … } static void as86_write_section(struct Section *sect, int index) { … } static void as86_sect_write(struct Section *sect, const uint8_t *data, uint32_t len) { … } extern macros_t as86_stdmac[]; const struct ofmt of_as86 = …; #endif /* OF_AS86 */