Coverage Report

Created: 2026-07-12 09:22

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/binutils-gdb/bfd/netbsd.h
Line
Count
Source
1
/* BFD back-end definitions used by all NetBSD targets.
2
   Copyright (C) 1990-2026 Free Software Foundation, Inc.
3
4
   This file is part of BFD, the Binary File Descriptor library.
5
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
8
   the Free Software Foundation; either version 3 of the License, or
9
   (at your option) any later version.
10
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.
15
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
18
   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
19
   MA 02110-1301, USA.  */
20
21
22
/* Check for our machine type (part of magic number).  */
23
#ifndef MACHTYPE_OK
24
9.70k
#define MACHTYPE_OK(m) ((m) == DEFAULT_MID || (m) == M_UNKNOWN)
25
#endif
26
27
/* This is the normal load address for executables.  */
28
873
#define TEXT_START_ADDR   TARGET_PAGE_SIZE
29
30
/* NetBSD ZMAGIC has its header in the text segment.  */
31
4.94k
#define N_HEADER_IN_TEXT(x) 1
32
33
/* Determine if this is a shared library using the flags.  */
34
10.3k
#define N_SHARED_LIB(x)   (N_DYNAMIC (x))
35
36
/* We have 6 bits of flags and 10 bits of machine ID.  */
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)
41
42
#define N_SET_INFO(execp, magic, type, flags) \
43
  ((execp)->a_info = ((magic) & 0xffff) \
44
   | (((int) (type) & 0x3ff) << 16) \
45
   | (((flags) & 0x3f) << 24))
46
#define N_SET_MACHTYPE(execp, machtype) \
47
154
  ((execp)->a_info = \
48
154
   ((execp)->a_info & 0xfb00ffff) | ((((int) (machtype)) & 0x3ff) << 16))
49
#define N_SET_FLAGS(execp, flags) \
50
  ((execp)->a_info = \
51
   ((execp)->a_info & 0x03ffffff) | ((flags & 0x3fu) << 26))
52
53
#include "sysdep.h"
54
#include "bfd.h"
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
488k
#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
66
#define MY_write_object_contents MY (write_object_contents)
67
static bool MY (write_object_contents) (bfd *);
68
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
77
static bool
78
MY (write_object_contents) (bfd *abfd)
79
154
{
80
154
  struct external_exec exec_bytes;
81
154
  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
154
  if (! abfd->output_has_begun)
87
114
    NAME (aout, adjust_sizes_and_vmas) (abfd);
88
89
154
  obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
90
91
  /* Magic number, maestro, please!  */
92
154
  switch (bfd_get_arch(abfd))
93
154
    {
94
154
    case DEFAULT_ARCH:
95
154
      N_SET_MACHTYPE (execp, DEFAULT_MID);
96
154
      break;
97
0
    default:
98
0
      N_SET_MACHTYPE (execp, M_UNKNOWN);
99
0
      break;
100
154
    }
101
102
  /* The NetBSD magic number is always big-endian.  */
103
154
#ifndef TARGET_IS_BIG_ENDIAN_P
104
  /* XXX aren't there any macro to change byteorder of a word independent of
105
     the host's or target's endiannesses?  */
106
154
  execp->a_info
107
154
    = (execp->a_info & 0xffu) << 24 | (execp->a_info & 0xff00) << 8
108
154
      | (execp->a_info & 0xff0000) >> 8 | (execp->a_info & 0xff000000) >> 24;
109
154
#endif
110
111
898
  WRITE_HEADERS (abfd, execp);
112
113
  return true;
114
898
}
ns32knetbsd.c:ns32k_aout_pc532nbsd_write_object_contents
Line
Count
Source
79
69
{
80
69
  struct external_exec exec_bytes;
81
69
  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
69
  if (! abfd->output_has_begun)
87
53
    NAME (aout, adjust_sizes_and_vmas) (abfd);
88
89
69
  obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
90
91
  /* Magic number, maestro, please!  */
92
69
  switch (bfd_get_arch(abfd))
93
69
    {
94
69
    case DEFAULT_ARCH:
95
69
      N_SET_MACHTYPE (execp, DEFAULT_MID);
96
69
      break;
97
0
    default:
98
0
      N_SET_MACHTYPE (execp, M_UNKNOWN);
99
0
      break;
100
69
    }
101
102
  /* The NetBSD magic number is always big-endian.  */
103
69
#ifndef TARGET_IS_BIG_ENDIAN_P
104
  /* XXX aren't there any macro to change byteorder of a word independent of
105
     the host's or target's endiannesses?  */
106
69
  execp->a_info
107
69
    = (execp->a_info & 0xffu) << 24 | (execp->a_info & 0xff00) << 8
108
69
      | (execp->a_info & 0xff0000) >> 8 | (execp->a_info & 0xff000000) >> 24;
109
69
#endif
110
111
404
  WRITE_HEADERS (abfd, execp);
112
113
  return true;
114
404
}
vax1knetbsd.c:vax_aout_1knbsd_write_object_contents
Line
Count
Source
79
30
{
80
30
  struct external_exec exec_bytes;
81
30
  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
30
  if (! abfd->output_has_begun)
87
20
    NAME (aout, adjust_sizes_and_vmas) (abfd);
88
89
30
  obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
90
91
  /* Magic number, maestro, please!  */
92
30
  switch (bfd_get_arch(abfd))
93
30
    {
94
30
    case DEFAULT_ARCH:
95
30
      N_SET_MACHTYPE (execp, DEFAULT_MID);
96
30
      break;
97
0
    default:
98
0
      N_SET_MACHTYPE (execp, M_UNKNOWN);
99
0
      break;
100
30
    }
101
102
  /* The NetBSD magic number is always big-endian.  */
103
30
#ifndef TARGET_IS_BIG_ENDIAN_P
104
  /* XXX aren't there any macro to change byteorder of a word independent of
105
     the host's or target's endiannesses?  */
106
30
  execp->a_info
107
30
    = (execp->a_info & 0xffu) << 24 | (execp->a_info & 0xff00) << 8
108
30
      | (execp->a_info & 0xff0000) >> 8 | (execp->a_info & 0xff000000) >> 24;
109
30
#endif
110
111
164
  WRITE_HEADERS (abfd, execp);
112
113
  return true;
114
164
}
vaxnetbsd.c:vax_aout_nbsd_write_object_contents
Line
Count
Source
79
55
{
80
55
  struct external_exec exec_bytes;
81
55
  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
55
  if (! abfd->output_has_begun)
87
41
    NAME (aout, adjust_sizes_and_vmas) (abfd);
88
89
55
  obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
90
91
  /* Magic number, maestro, please!  */
92
55
  switch (bfd_get_arch(abfd))
93
55
    {
94
55
    case DEFAULT_ARCH:
95
55
      N_SET_MACHTYPE (execp, DEFAULT_MID);
96
55
      break;
97
0
    default:
98
0
      N_SET_MACHTYPE (execp, M_UNKNOWN);
99
0
      break;
100
55
    }
101
102
  /* The NetBSD magic number is always big-endian.  */
103
55
#ifndef TARGET_IS_BIG_ENDIAN_P
104
  /* XXX aren't there any macro to change byteorder of a word independent of
105
     the host's or target's endiannesses?  */
106
55
  execp->a_info
107
55
    = (execp->a_info & 0xffu) << 24 | (execp->a_info & 0xff00) << 8
108
55
      | (execp->a_info & 0xff0000) >> 8 | (execp->a_info & 0xff000000) >> 24;
109
55
#endif
110
111
330
  WRITE_HEADERS (abfd, execp);
112
113
  return true;
114
330
}