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