Deleted Added
full compact
freebsd.h (33973) freebsd.h (60526)
1/* BFD back-end definitions used by all FreeBSD a.out targets.
2 Copyright (C) 1990, 1991, 1992, 1996 Free Software Foundation, Inc.
1/* BFD back-end definitions used by all FreeBSD targets.
2 Copyright (C) 1990, 1991, 1992, 1996, 2000 Free Software Foundation, Inc.
3
4This file is part of BFD, the Binary File Descriptor library.
5
6This program is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2 of the License, or
9(at your option) any later version.
10
11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with this program; if not, write to the Free Software
18Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19*/
20
3
4This file is part of BFD, the Binary File Descriptor library.
5
6This program is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2 of the License, or
9(at your option) any later version.
10
11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with this program; if not, write to the Free Software
18Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19*/
20
21/* $FreeBSD: head/contrib/binutils/bfd/freebsd.h 60526 2000-05-13 17:55:26Z obrien $ */
22
21/* FreeBSD QMAGIC files have the header in the text. */
22#define N_HEADER_IN_TEXT(x) 1
23#define MY_text_includes_header 1
24
25#define TEXT_START_ADDR (TARGET_PAGE_SIZE + 0x20)
26
27/*
28 * FreeBSD uses a weird mix of byte orderings for its a_info field.
29 * Its assembler emits NetBSD style object files, with a big-endian
30 * a_info. Its linker seems to accept either byte ordering, but
31 * emits a little-endian a_info.
32 *
33 * Here, we accept either byte ordering, but always produce
34 * little-endian.
35 *
36 * FIXME - Probably we should always produce the _native_ byte
37 * ordering. I.e., it should be in the architecture-specific
23/* FreeBSD QMAGIC files have the header in the text. */
24#define N_HEADER_IN_TEXT(x) 1
25#define MY_text_includes_header 1
26
27#define TEXT_START_ADDR (TARGET_PAGE_SIZE + 0x20)
28
29/*
30 * FreeBSD uses a weird mix of byte orderings for its a_info field.
31 * Its assembler emits NetBSD style object files, with a big-endian
32 * a_info. Its linker seems to accept either byte ordering, but
33 * emits a little-endian a_info.
34 *
35 * Here, we accept either byte ordering, but always produce
36 * little-endian.
37 *
38 * FIXME - Probably we should always produce the _native_ byte
39 * ordering. I.e., it should be in the architecture-specific
38 * file, not here. But in reality, there is almost zero chance
40 * file, not here. But in reality, there is no chance
39 * that FreeBSD will ever use a.out in a new port.
40 */
41
42#define N_MACHTYPE(exec) \
43 ((enum machine_type) \
44 ((freebsd_swap_magic(&(exec).a_info) >> 16) & 0x3ff))
45#define N_FLAGS(exec) \
46 ((enum machine_type) \

--- 12 unchanged lines hidden (view full) ---

59
60#include "bfd.h"
61#include "sysdep.h"
62#include "libbfd.h"
63#include "libaout.h"
64
65#define SWAP_MAGIC(ext) (freebsd_swap_magic(ext))
66
41 * that FreeBSD will ever use a.out in a new port.
42 */
43
44#define N_MACHTYPE(exec) \
45 ((enum machine_type) \
46 ((freebsd_swap_magic(&(exec).a_info) >> 16) & 0x3ff))
47#define N_FLAGS(exec) \
48 ((enum machine_type) \

--- 12 unchanged lines hidden (view full) ---

61
62#include "bfd.h"
63#include "sysdep.h"
64#include "libbfd.h"
65#include "libaout.h"
66
67#define SWAP_MAGIC(ext) (freebsd_swap_magic(ext))
68
67#define MY_bfd_final_link freebsd_bfd_final_link
68#define MY_write_object_contents freebsd_write_object_contents
69#define MY_bfd_final_link MY(bfd_final_link)
70#define MY_write_object_contents MY(write_object_contents)
69
71
70static boolean freebsd_bfd_final_link PARAMS ((bfd *, struct bfd_link_info *));
72static boolean MY(bfd_final_link) PARAMS ((bfd *, struct bfd_link_info *));
73static boolean MY(write_object_contents) PARAMS ((bfd *abfd));
71static long freebsd_swap_magic PARAMS ((void *ext));
74static long freebsd_swap_magic PARAMS ((void *ext));
72static boolean freebsd_write_object_contents PARAMS ((bfd *abfd));
73
74#include "aout-target.h"
75
76static boolean
75
76#include "aout-target.h"
77
78static boolean
77freebsd_bfd_final_link(abfd, info)
79MY(bfd_final_link) (abfd, info)
78 bfd *abfd;
79 struct bfd_link_info *info;
80{
81 obj_aout_subformat (abfd) = q_magic_format;
82 return NAME(aout,final_link) (abfd, info, MY_final_link_callback);
83}
84
85/* Swap a magic number. We accept either endian, whichever looks valid. */
86
87static long
80 bfd *abfd;
81 struct bfd_link_info *info;
82{
83 obj_aout_subformat (abfd) = q_magic_format;
84 return NAME(aout,final_link) (abfd, info, MY_final_link_callback);
85}
86
87/* Swap a magic number. We accept either endian, whichever looks valid. */
88
89static long
88freebsd_swap_magic(ext)
90freebsd_swap_magic (ext)
89 void *ext;
90{
91 long linfo = bfd_getl32(ext);
92 long binfo = bfd_getb32(ext);
93 int lmagic = linfo & 0xffff;
94 int bmagic = binfo & 0xffff;
95 int lmagic_ok = lmagic == OMAGIC || lmagic == NMAGIC ||
96 lmagic == ZMAGIC || lmagic == QMAGIC;
97 int bmagic_ok = bmagic == OMAGIC || bmagic == NMAGIC ||
98 bmagic == ZMAGIC || bmagic == QMAGIC;
99
100 return bmagic_ok && !lmagic_ok ? binfo : linfo;
101}
102
103/* Write an object file.
104 Section contents have already been written. We write the
105 file header, symbols, and relocation. */
106
107static boolean
91 void *ext;
92{
93 long linfo = bfd_getl32(ext);
94 long binfo = bfd_getb32(ext);
95 int lmagic = linfo & 0xffff;
96 int bmagic = binfo & 0xffff;
97 int lmagic_ok = lmagic == OMAGIC || lmagic == NMAGIC ||
98 lmagic == ZMAGIC || lmagic == QMAGIC;
99 int bmagic_ok = bmagic == OMAGIC || bmagic == NMAGIC ||
100 bmagic == ZMAGIC || bmagic == QMAGIC;
101
102 return bmagic_ok && !lmagic_ok ? binfo : linfo;
103}
104
105/* Write an object file.
106 Section contents have already been written. We write the
107 file header, symbols, and relocation. */
108
109static boolean
108freebsd_write_object_contents(abfd)
110MY(write_object_contents) (abfd)
109 bfd *abfd;
110{
111 struct external_exec exec_bytes;
112 struct internal_exec *execp = exec_hdr (abfd);
113
111 bfd *abfd;
112{
113 struct external_exec exec_bytes;
114 struct internal_exec *execp = exec_hdr (abfd);
115
114#if CHOOSE_RELOC_SIZE
115 CHOOSE_RELOC_SIZE(abfd);
116#else
117 obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
116 obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
118#endif
119
120 /* Magic number, maestro, please! */
121 switch (bfd_get_arch(abfd)) {
122 case bfd_arch_m68k:
123 if (strcmp (abfd->xvec->name, "a.out-m68k4k-netbsd") == 0)
124 N_SET_MACHTYPE(*execp, M_68K4K_NETBSD);
125 else
126 N_SET_MACHTYPE(*execp, M_68K_NETBSD);

--- 19 unchanged lines hidden ---
117
118 /* Magic number, maestro, please! */
119 switch (bfd_get_arch(abfd)) {
120 case bfd_arch_m68k:
121 if (strcmp (abfd->xvec->name, "a.out-m68k4k-netbsd") == 0)
122 N_SET_MACHTYPE(*execp, M_68K4K_NETBSD);
123 else
124 N_SET_MACHTYPE(*execp, M_68K_NETBSD);

--- 19 unchanged lines hidden ---