Make bfd_get_8 return a bfd_vma like other bfd_get_* functions
[deliverable/binutils-gdb.git] / bfd / netbsd.h
CommitLineData
252b5132 1/* BFD back-end definitions used by all NetBSD targets.
82704155 2 Copyright (C) 1990-2019 Free Software Foundation, Inc.
252b5132 3
116c20d2 4 This file is part of BFD, the Binary File Descriptor library.
252b5132 5
116c20d2
NC
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
cd123cb7 8 the Free Software Foundation; either version 3 of the License, or
116c20d2 9 (at your option) any later version.
252b5132 10
116c20d2
NC
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
252b5132 15
116c20d2
NC
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
cd123cb7
NC
18 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
19 MA 02110-1301, USA. */
20
252b5132 21
1518639e 22/* Check for our machine type (part of magic number). */
252b5132
RH
23#ifndef MACHTYPE_OK
24#define MACHTYPE_OK(m) ((m) == DEFAULT_MID || (m) == M_UNKNOWN)
25#endif
26
1518639e 27/* This is the normal load address for executables. */
252b5132
RH
28#define TEXT_START_ADDR TARGET_PAGE_SIZE
29
30/* NetBSD ZMAGIC has its header in the text segment. */
31#define N_HEADER_IN_TEXT(x) 1
32
1518639e 33/* Determine if this is a shared library using the flags. */
07d6d2b8 34#define N_SHARED_LIB(x) (N_DYNAMIC (x))
252b5132
RH
35
36/* We have 6 bits of flags and 10 bits of machine ID. */
bbb1afc8
AM
37#define N_MACHTYPE(execp) \
38 ((enum machine_type) (((execp)->a_info >> 16) & 0x03ff))
39#define N_FLAGS(execp) \
40 (((execp)->a_info >> 26) & 0x3f)
252b5132 41
bbb1afc8
AM
42#define N_SET_INFO(execp, magic, type, flags) \
43 ((execp)->a_info = ((magic) & 0xffff) \
1518639e 44 | (((int) (type) & 0x3ff) << 16) \
252b5132 45 | (((flags) & 0x3f) << 24))
bbb1afc8
AM
46#define N_SET_MACHTYPE(execp, machtype) \
47 ((execp)->a_info = \
07d6d2b8 48 ((execp)->a_info & 0xfb00ffff) | ((((int) (machtype)) & 0x3ff) << 16))
bbb1afc8
AM
49#define N_SET_FLAGS(execp, flags) \
50 ((execp)->a_info = \
51 ((execp)->a_info & 0x03ffffff) | ((flags & 0x03f) << 26))
252b5132 52
252b5132 53#include "sysdep.h"
3db64b00 54#include "bfd.h"
252b5132
RH
55#include "libbfd.h"
56#include "libaout.h"
57
58/* On NetBSD, the magic number is always in ntohl's "network" (big-endian)
59 format. */
60#define SWAP_MAGIC(ext) bfd_getb32 (ext)
61
62/* On NetBSD, the entry point may be taken to be the start of the text
63 section. */
64#define MY_entry_is_text_address 1
65
116c20d2
NC
66#define MY_write_object_contents MY (write_object_contents)
67static bfd_boolean MY (write_object_contents) (bfd *);
68
252b5132
RH
69#define MY_text_includes_header 1
70
71#include "aout-target.h"
72
73/* Write an object file.
74 Section contents have already been written. We write the
75 file header, symbols, and relocation. */
76
b34976b6 77static bfd_boolean
116c20d2 78MY (write_object_contents) (bfd *abfd)
252b5132
RH
79{
80 struct external_exec exec_bytes;
81 struct internal_exec *execp = exec_hdr (abfd);
82
83 /* We must make certain that the magic number has been set. This
84 will normally have been done by set_section_contents, but only if
85 there actually are some section contents. */
86 if (! abfd->output_has_begun)
3a8c4a5b 87 NAME (aout, adjust_sizes_and_vmas) (abfd);
252b5132 88
252b5132 89 obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
252b5132
RH
90
91 /* Magic number, maestro, please! */
116c20d2
NC
92 switch (bfd_get_arch(abfd))
93 {
94 case DEFAULT_ARCH:
bbb1afc8 95 N_SET_MACHTYPE (execp, DEFAULT_MID);
116c20d2
NC
96 break;
97 default:
bbb1afc8 98 N_SET_MACHTYPE (execp, M_UNKNOWN);
116c20d2
NC
99 break;
100 }
252b5132 101
cc643b88 102 /* The NetBSD magic number is always big-endian. */
252b5132
RH
103#ifndef TARGET_IS_BIG_ENDIAN_P
104 /* XXX aren't there any macro to change byteorder of a word independent of
cc643b88 105 the host's or target's endiannesses? */
252b5132
RH
106 execp->a_info
107 = (execp->a_info & 0xff) << 24 | (execp->a_info & 0xff00) << 8
108 | (execp->a_info & 0xff0000) >> 8 | (execp->a_info & 0xff000000) >> 24;
109#endif
110
116c20d2 111 WRITE_HEADERS (abfd, execp);
252b5132 112
b34976b6 113 return TRUE;
252b5132 114}
This page took 1.087512 seconds and 4 git commands to generate.