Deleted Added
full compact
aoutx.h (107492) aoutx.h (130561)
1/* BFD semi-generic back-end for a.out binaries.
2 Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2000,
1/* BFD semi-generic back-end for a.out binaries.
2 Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2000,
3 2001, 2002
3 2001, 2002, 2003
4 Free Software Foundation, Inc.
5 Written by Cygnus Support.
6
4 Free Software Foundation, Inc.
5 Written by Cygnus Support.
6
7This file is part of BFD, the Binary File Descriptor library.
7 This file is part of BFD, the Binary File Descriptor library.
8
8
9This program is free software; you can redistribute it and/or modify
10it under the terms of the GNU General Public License as published by
11the Free Software Foundation; either version 2 of the License, or
12(at your option) any later version.
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
13
13
14This program is distributed in the hope that it will be useful,
15but WITHOUT ANY WARRANTY; without even the implied warranty of
16MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17GNU General Public License for more details.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
18
19You should have received a copy of the GNU General Public License
20along with this program; if not, write to the Free Software
21Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
22
23/*
24SECTION
25 a.out backends
26
27DESCRIPTION
28
29 BFD supports a number of different flavours of a.out format,

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

100 to use @file{host-aout.c}, specify:
101
102| TDEFAULTS = -DDEFAULT_VECTOR=host_aout_big_vec
103| TDEPFILES= host-aout.o trad-core.o
104
105 in the @file{config/@var{XXX}.mt} file, and modify @file{configure.in}
106 to use the
107 @file{@var{XXX}.mt} file (by setting "<<bfd_target=XXX>>") when your
22
23/*
24SECTION
25 a.out backends
26
27DESCRIPTION
28
29 BFD supports a number of different flavours of a.out format,

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

100 to use @file{host-aout.c}, specify:
101
102| TDEFAULTS = -DDEFAULT_VECTOR=host_aout_big_vec
103| TDEPFILES= host-aout.o trad-core.o
104
105 in the @file{config/@var{XXX}.mt} file, and modify @file{configure.in}
106 to use the
107 @file{@var{XXX}.mt} file (by setting "<<bfd_target=XXX>>") when your
108 configuration is selected.
108 configuration is selected. */
109
109
110*/
111
112/* Some assumptions:
113 * Any BFD with D_PAGED set is ZMAGIC, and vice versa.
114 Doesn't matter what the setting of WP_TEXT is on output, but it'll
115 get set on input.
116 * Any BFD with D_PAGED clear and WP_TEXT set is NMAGIC.
117 * Any BFD with both flags clear is OMAGIC.
118 (Just want to make these explicit, so the conditions tested in this
119 file make sense if you're more familiar with a.out than with BFD.) */

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

126#include "bfdlink.h"
127
128#include "libaout.h"
129#include "libbfd.h"
130#include "aout/aout64.h"
131#include "aout/stab_gnu.h"
132#include "aout/ar.h"
133
110/* Some assumptions:
111 * Any BFD with D_PAGED set is ZMAGIC, and vice versa.
112 Doesn't matter what the setting of WP_TEXT is on output, but it'll
113 get set on input.
114 * Any BFD with D_PAGED clear and WP_TEXT set is NMAGIC.
115 * Any BFD with both flags clear is OMAGIC.
116 (Just want to make these explicit, so the conditions tested in this
117 file make sense if you're more familiar with a.out than with BFD.) */

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

124#include "bfdlink.h"
125
126#include "libaout.h"
127#include "libbfd.h"
128#include "aout/aout64.h"
129#include "aout/stab_gnu.h"
130#include "aout/ar.h"
131
134static boolean aout_get_external_symbols PARAMS ((bfd *));
135static boolean translate_from_native_sym_flags
132static bfd_boolean aout_get_external_symbols
133 PARAMS ((bfd *));
134static bfd_boolean translate_from_native_sym_flags
136 PARAMS ((bfd *, aout_symbol_type *));
135 PARAMS ((bfd *, aout_symbol_type *));
137static boolean translate_to_native_sym_flags
136static bfd_boolean translate_to_native_sym_flags
138 PARAMS ((bfd *, asymbol *, struct external_nlist *));
137 PARAMS ((bfd *, asymbol *, struct external_nlist *));
139static void adjust_o_magic PARAMS ((bfd *, struct internal_exec *));
140static void adjust_z_magic PARAMS ((bfd *, struct internal_exec *));
141static void adjust_n_magic PARAMS ((bfd *, struct internal_exec *));
138static void adjust_o_magic
139 PARAMS ((bfd *, struct internal_exec *));
140static void adjust_z_magic
141 PARAMS ((bfd *, struct internal_exec *));
142static void adjust_n_magic
143 PARAMS ((bfd *, struct internal_exec *));
142reloc_howto_type * NAME(aout,reloc_type_lookup)
143 PARAMS ((bfd *, bfd_reloc_code_real_type));
144
145/*
146SUBSECTION
147 Relocations
148
149DESCRIPTION
150 The file @file{aoutx.h} provides for both the @emph{standard}
151 and @emph{extended} forms of a.out relocation records.
152
153 The standard records contain only an
154 address, a symbol index, and a type field. The extended records
155 (used on 29ks and sparcs) also have a full integer for an
144reloc_howto_type * NAME(aout,reloc_type_lookup)
145 PARAMS ((bfd *, bfd_reloc_code_real_type));
146
147/*
148SUBSECTION
149 Relocations
150
151DESCRIPTION
152 The file @file{aoutx.h} provides for both the @emph{standard}
153 and @emph{extended} forms of a.out relocation records.
154
155 The standard records contain only an
156 address, a symbol index, and a type field. The extended records
157 (used on 29ks and sparcs) also have a full integer for an
156 addend.
158 addend. */
157
159
158*/
159#ifndef CTOR_TABLE_RELOC_HOWTO
160#define CTOR_TABLE_RELOC_IDX 2
161#define CTOR_TABLE_RELOC_HOWTO(BFD) \
162 ((obj_reloc_entry_size (BFD) == RELOC_EXT_SIZE \
163 ? howto_table_ext : howto_table_std) \
164 + CTOR_TABLE_RELOC_IDX)
165#endif
166

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

188#define MY_relocate_contents _bfd_relocate_contents
189#endif
190
191#define howto_table_ext NAME(aout,ext_howto_table)
192#define howto_table_std NAME(aout,std_howto_table)
193
194reloc_howto_type howto_table_ext[] =
195{
160#ifndef CTOR_TABLE_RELOC_HOWTO
161#define CTOR_TABLE_RELOC_IDX 2
162#define CTOR_TABLE_RELOC_HOWTO(BFD) \
163 ((obj_reloc_entry_size (BFD) == RELOC_EXT_SIZE \
164 ? howto_table_ext : howto_table_std) \
165 + CTOR_TABLE_RELOC_IDX)
166#endif
167

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

189#define MY_relocate_contents _bfd_relocate_contents
190#endif
191
192#define howto_table_ext NAME(aout,ext_howto_table)
193#define howto_table_std NAME(aout,std_howto_table)
194
195reloc_howto_type howto_table_ext[] =
196{
196 /* type rs size bsz pcrel bitpos ovrf sf name part_inpl readmask setmask pcdone */
197 HOWTO(RELOC_8, 0, 0, 8, false, 0, complain_overflow_bitfield,0,"8", false, 0,0x000000ff, false),
198 HOWTO(RELOC_16, 0, 1, 16, false, 0, complain_overflow_bitfield,0,"16", false, 0,0x0000ffff, false),
199 HOWTO(RELOC_32, 0, 2, 32, false, 0, complain_overflow_bitfield,0,"32", false, 0,0xffffffff, false),
200 HOWTO(RELOC_DISP8, 0, 0, 8, true, 0, complain_overflow_signed,0,"DISP8", false, 0,0x000000ff, false),
201 HOWTO(RELOC_DISP16, 0, 1, 16, true, 0, complain_overflow_signed,0,"DISP16", false, 0,0x0000ffff, false),
202 HOWTO(RELOC_DISP32, 0, 2, 32, true, 0, complain_overflow_signed,0,"DISP32", false, 0,0xffffffff, false),
203 HOWTO(RELOC_WDISP30,2, 2, 30, true, 0, complain_overflow_signed,0,"WDISP30", false, 0,0x3fffffff, false),
204 HOWTO(RELOC_WDISP22,2, 2, 22, true, 0, complain_overflow_signed,0,"WDISP22", false, 0,0x003fffff, false),
205 HOWTO(RELOC_HI22, 10, 2, 22, false, 0, complain_overflow_bitfield,0,"HI22", false, 0,0x003fffff, false),
206 HOWTO(RELOC_22, 0, 2, 22, false, 0, complain_overflow_bitfield,0,"22", false, 0,0x003fffff, false),
207 HOWTO(RELOC_13, 0, 2, 13, false, 0, complain_overflow_bitfield,0,"13", false, 0,0x00001fff, false),
208 HOWTO(RELOC_LO10, 0, 2, 10, false, 0, complain_overflow_dont,0,"LO10", false, 0,0x000003ff, false),
209 HOWTO(RELOC_SFA_BASE,0, 2, 32, false, 0, complain_overflow_bitfield,0,"SFA_BASE", false, 0,0xffffffff, false),
210 HOWTO(RELOC_SFA_OFF13,0,2, 32, false, 0, complain_overflow_bitfield,0,"SFA_OFF13",false, 0,0xffffffff, false),
211 HOWTO(RELOC_BASE10, 0, 2, 10, false, 0, complain_overflow_dont,0,"BASE10", false, 0,0x000003ff, false),
212 HOWTO(RELOC_BASE13, 0, 2, 13, false, 0, complain_overflow_signed,0,"BASE13", false, 0,0x00001fff, false),
213 HOWTO(RELOC_BASE22, 10, 2, 22, false, 0, complain_overflow_bitfield,0,"BASE22", false, 0,0x003fffff, false),
214 HOWTO(RELOC_PC10, 0, 2, 10, true, 0, complain_overflow_dont,0,"PC10", false, 0,0x000003ff, true),
215 HOWTO(RELOC_PC22, 10, 2, 22, true, 0, complain_overflow_signed,0,"PC22", false, 0,0x003fffff, true),
216 HOWTO(RELOC_JMP_TBL,2, 2, 30, true, 0, complain_overflow_signed,0,"JMP_TBL", false, 0,0x3fffffff, false),
217 HOWTO(RELOC_SEGOFF16,0, 2, 0, false, 0, complain_overflow_bitfield,0,"SEGOFF16", false, 0,0x00000000, false),
218 HOWTO(RELOC_GLOB_DAT,0, 2, 0, false, 0, complain_overflow_bitfield,0,"GLOB_DAT", false, 0,0x00000000, false),
219 HOWTO(RELOC_JMP_SLOT,0, 2, 0, false, 0, complain_overflow_bitfield,0,"JMP_SLOT", false, 0,0x00000000, false),
220 HOWTO(RELOC_RELATIVE,0, 2, 0, false, 0, complain_overflow_bitfield,0,"RELATIVE", false, 0,0x00000000, false),
221 HOWTO(0, 0, 0, 0, false, 0, complain_overflow_dont, 0, "R_SPARC_NONE", false,0,0x00000000,true),
222 HOWTO(0, 0, 0, 0, false, 0, complain_overflow_dont, 0, "R_SPARC_NONE", false,0,0x00000000,true),
197 /* type rs size bsz pcrel bitpos ovrf sf name part_inpl readmask setmask pcdone. */
198 HOWTO(RELOC_8, 0, 0, 8, FALSE, 0, complain_overflow_bitfield,0,"8", FALSE, 0,0x000000ff, FALSE),
199 HOWTO(RELOC_16, 0, 1, 16, FALSE, 0, complain_overflow_bitfield,0,"16", FALSE, 0,0x0000ffff, FALSE),
200 HOWTO(RELOC_32, 0, 2, 32, FALSE, 0, complain_overflow_bitfield,0,"32", FALSE, 0,0xffffffff, FALSE),
201 HOWTO(RELOC_DISP8, 0, 0, 8, TRUE, 0, complain_overflow_signed,0,"DISP8", FALSE, 0,0x000000ff, FALSE),
202 HOWTO(RELOC_DISP16, 0, 1, 16, TRUE, 0, complain_overflow_signed,0,"DISP16", FALSE, 0,0x0000ffff, FALSE),
203 HOWTO(RELOC_DISP32, 0, 2, 32, TRUE, 0, complain_overflow_signed,0,"DISP32", FALSE, 0,0xffffffff, FALSE),
204 HOWTO(RELOC_WDISP30,2, 2, 30, TRUE, 0, complain_overflow_signed,0,"WDISP30", FALSE, 0,0x3fffffff, FALSE),
205 HOWTO(RELOC_WDISP22,2, 2, 22, TRUE, 0, complain_overflow_signed,0,"WDISP22", FALSE, 0,0x003fffff, FALSE),
206 HOWTO(RELOC_HI22, 10, 2, 22, FALSE, 0, complain_overflow_bitfield,0,"HI22", FALSE, 0,0x003fffff, FALSE),
207 HOWTO(RELOC_22, 0, 2, 22, FALSE, 0, complain_overflow_bitfield,0,"22", FALSE, 0,0x003fffff, FALSE),
208 HOWTO(RELOC_13, 0, 2, 13, FALSE, 0, complain_overflow_bitfield,0,"13", FALSE, 0,0x00001fff, FALSE),
209 HOWTO(RELOC_LO10, 0, 2, 10, FALSE, 0, complain_overflow_dont,0,"LO10", FALSE, 0,0x000003ff, FALSE),
210 HOWTO(RELOC_SFA_BASE,0, 2, 32, FALSE, 0, complain_overflow_bitfield,0,"SFA_BASE", FALSE, 0,0xffffffff, FALSE),
211 HOWTO(RELOC_SFA_OFF13,0,2, 32, FALSE, 0, complain_overflow_bitfield,0,"SFA_OFF13",FALSE, 0,0xffffffff, FALSE),
212 HOWTO(RELOC_BASE10, 0, 2, 10, FALSE, 0, complain_overflow_dont,0,"BASE10", FALSE, 0,0x000003ff, FALSE),
213 HOWTO(RELOC_BASE13, 0, 2, 13, FALSE, 0, complain_overflow_signed,0,"BASE13", FALSE, 0,0x00001fff, FALSE),
214 HOWTO(RELOC_BASE22, 10, 2, 22, FALSE, 0, complain_overflow_bitfield,0,"BASE22", FALSE, 0,0x003fffff, FALSE),
215 HOWTO(RELOC_PC10, 0, 2, 10, TRUE, 0, complain_overflow_dont,0,"PC10", FALSE, 0,0x000003ff, TRUE),
216 HOWTO(RELOC_PC22, 10, 2, 22, TRUE, 0, complain_overflow_signed,0,"PC22", FALSE, 0,0x003fffff, TRUE),
217 HOWTO(RELOC_JMP_TBL,2, 2, 30, TRUE, 0, complain_overflow_signed,0,"JMP_TBL", FALSE, 0,0x3fffffff, FALSE),
218 HOWTO(RELOC_SEGOFF16,0, 2, 0, FALSE, 0, complain_overflow_bitfield,0,"SEGOFF16", FALSE, 0,0x00000000, FALSE),
219 HOWTO(RELOC_GLOB_DAT,0, 2, 0, FALSE, 0, complain_overflow_bitfield,0,"GLOB_DAT", FALSE, 0,0x00000000, FALSE),
220 HOWTO(RELOC_JMP_SLOT,0, 2, 0, FALSE, 0, complain_overflow_bitfield,0,"JMP_SLOT", FALSE, 0,0x00000000, FALSE),
221 HOWTO(RELOC_RELATIVE,0, 2, 0, FALSE, 0, complain_overflow_bitfield,0,"RELATIVE", FALSE, 0,0x00000000, FALSE),
222 HOWTO(0, 0, 0, 0, FALSE, 0, complain_overflow_dont, 0, "R_SPARC_NONE", FALSE,0,0x00000000,TRUE),
223 HOWTO(0, 0, 0, 0, FALSE, 0, complain_overflow_dont, 0, "R_SPARC_NONE", FALSE,0,0x00000000,TRUE),
223#define RELOC_SPARC_REV32 RELOC_WDISP19
224#define RELOC_SPARC_REV32 RELOC_WDISP19
224 HOWTO(RELOC_SPARC_REV32, 0, 2, 32, false, 0, complain_overflow_dont,0,"R_SPARC_REV32", false, 0,0xffffffff, false),
225 HOWTO(RELOC_SPARC_REV32, 0, 2, 32, FALSE, 0, complain_overflow_dont,0,"R_SPARC_REV32", FALSE, 0,0xffffffff, FALSE),
225};
226
227/* Convert standard reloc records to "arelent" format (incl byte swap). */
228
226};
227
228/* Convert standard reloc records to "arelent" format (incl byte swap). */
229
229reloc_howto_type howto_table_std[] = {
230 /* type rs size bsz pcrel bitpos ovrf sf name part_inpl readmask setmask pcdone */
231HOWTO ( 0, 0, 0, 8, false, 0, complain_overflow_bitfield,0,"8", true, 0x000000ff,0x000000ff, false),
232HOWTO ( 1, 0, 1, 16, false, 0, complain_overflow_bitfield,0,"16", true, 0x0000ffff,0x0000ffff, false),
233HOWTO ( 2, 0, 2, 32, false, 0, complain_overflow_bitfield,0,"32", true, 0xffffffff,0xffffffff, false),
234HOWTO ( 3, 0, 4, 64, false, 0, complain_overflow_bitfield,0,"64", true, 0xdeaddead,0xdeaddead, false),
235HOWTO ( 4, 0, 0, 8, true, 0, complain_overflow_signed, 0,"DISP8", true, 0x000000ff,0x000000ff, false),
236HOWTO ( 5, 0, 1, 16, true, 0, complain_overflow_signed, 0,"DISP16", true, 0x0000ffff,0x0000ffff, false),
237HOWTO ( 6, 0, 2, 32, true, 0, complain_overflow_signed, 0,"DISP32", true, 0xffffffff,0xffffffff, false),
238HOWTO ( 7, 0, 4, 64, true, 0, complain_overflow_signed, 0,"DISP64", true, 0xfeedface,0xfeedface, false),
239HOWTO ( 8, 0, 2, 0, false, 0, complain_overflow_bitfield,0,"GOT_REL", false, 0,0x00000000, false),
240HOWTO ( 9, 0, 1, 16, false, 0, complain_overflow_bitfield,0,"BASE16", false,0xffffffff,0xffffffff, false),
241HOWTO (10, 0, 2, 32, false, 0, complain_overflow_bitfield,0,"BASE32", false,0xffffffff,0xffffffff, false),
230reloc_howto_type howto_table_std[] =
231{
232 /* type rs size bsz pcrel bitpos ovrf sf name part_inpl readmask setmask pcdone. */
233HOWTO ( 0, 0, 0, 8, FALSE, 0, complain_overflow_bitfield,0,"8", TRUE, 0x000000ff,0x000000ff, FALSE),
234HOWTO ( 1, 0, 1, 16, FALSE, 0, complain_overflow_bitfield,0,"16", TRUE, 0x0000ffff,0x0000ffff, FALSE),
235HOWTO ( 2, 0, 2, 32, FALSE, 0, complain_overflow_bitfield,0,"32", TRUE, 0xffffffff,0xffffffff, FALSE),
236HOWTO ( 3, 0, 4, 64, FALSE, 0, complain_overflow_bitfield,0,"64", TRUE, 0xdeaddead,0xdeaddead, FALSE),
237HOWTO ( 4, 0, 0, 8, TRUE, 0, complain_overflow_signed, 0,"DISP8", TRUE, 0x000000ff,0x000000ff, FALSE),
238HOWTO ( 5, 0, 1, 16, TRUE, 0, complain_overflow_signed, 0,"DISP16", TRUE, 0x0000ffff,0x0000ffff, FALSE),
239HOWTO ( 6, 0, 2, 32, TRUE, 0, complain_overflow_signed, 0,"DISP32", TRUE, 0xffffffff,0xffffffff, FALSE),
240HOWTO ( 7, 0, 4, 64, TRUE, 0, complain_overflow_signed, 0,"DISP64", TRUE, 0xfeedface,0xfeedface, FALSE),
241HOWTO ( 8, 0, 2, 0, FALSE, 0, complain_overflow_bitfield,0,"GOT_REL", FALSE, 0,0x00000000, FALSE),
242HOWTO ( 9, 0, 1, 16, FALSE, 0, complain_overflow_bitfield,0,"BASE16", FALSE,0xffffffff,0xffffffff, FALSE),
243HOWTO (10, 0, 2, 32, FALSE, 0, complain_overflow_bitfield,0,"BASE32", FALSE,0xffffffff,0xffffffff, FALSE),
242EMPTY_HOWTO (-1),
243EMPTY_HOWTO (-1),
244EMPTY_HOWTO (-1),
245EMPTY_HOWTO (-1),
246EMPTY_HOWTO (-1),
244EMPTY_HOWTO (-1),
245EMPTY_HOWTO (-1),
246EMPTY_HOWTO (-1),
247EMPTY_HOWTO (-1),
248EMPTY_HOWTO (-1),
247 HOWTO (16, 0, 2, 0, false, 0, complain_overflow_bitfield,0,"JMP_TABLE", false, 0,0x00000000, false),
249 HOWTO (16, 0, 2, 0, FALSE, 0, complain_overflow_bitfield,0,"JMP_TABLE", FALSE, 0,0x00000000, FALSE),
248EMPTY_HOWTO (-1),
249EMPTY_HOWTO (-1),
250EMPTY_HOWTO (-1),
251EMPTY_HOWTO (-1),
252EMPTY_HOWTO (-1),
253EMPTY_HOWTO (-1),
254EMPTY_HOWTO (-1),
255EMPTY_HOWTO (-1),
256EMPTY_HOWTO (-1),
257EMPTY_HOWTO (-1),
258EMPTY_HOWTO (-1),
259EMPTY_HOWTO (-1),
260EMPTY_HOWTO (-1),
261EMPTY_HOWTO (-1),
262EMPTY_HOWTO (-1),
250EMPTY_HOWTO (-1),
251EMPTY_HOWTO (-1),
252EMPTY_HOWTO (-1),
253EMPTY_HOWTO (-1),
254EMPTY_HOWTO (-1),
255EMPTY_HOWTO (-1),
256EMPTY_HOWTO (-1),
257EMPTY_HOWTO (-1),
258EMPTY_HOWTO (-1),
259EMPTY_HOWTO (-1),
260EMPTY_HOWTO (-1),
261EMPTY_HOWTO (-1),
262EMPTY_HOWTO (-1),
263EMPTY_HOWTO (-1),
264EMPTY_HOWTO (-1),
263 HOWTO (32, 0, 2, 0, false, 0, complain_overflow_bitfield,0,"RELATIVE", false, 0,0x00000000, false),
265 HOWTO (32, 0, 2, 0, FALSE, 0, complain_overflow_bitfield,0,"RELATIVE", FALSE, 0,0x00000000, FALSE),
264EMPTY_HOWTO (-1),
265EMPTY_HOWTO (-1),
266EMPTY_HOWTO (-1),
267EMPTY_HOWTO (-1),
268EMPTY_HOWTO (-1),
269EMPTY_HOWTO (-1),
270EMPTY_HOWTO (-1),
266EMPTY_HOWTO (-1),
267EMPTY_HOWTO (-1),
268EMPTY_HOWTO (-1),
269EMPTY_HOWTO (-1),
270EMPTY_HOWTO (-1),
271EMPTY_HOWTO (-1),
272EMPTY_HOWTO (-1),
271 HOWTO (40, 0, 2, 0, false, 0, complain_overflow_bitfield,0,"BASEREL", false, 0,0x00000000, false),
273 HOWTO (40, 0, 2, 0, FALSE, 0, complain_overflow_bitfield,0,"BASEREL", FALSE, 0,0x00000000, FALSE),
272};
273
274#define TABLE_SIZE(TABLE) (sizeof (TABLE) / sizeof (TABLE[0]))
275
276reloc_howto_type *
277NAME(aout,reloc_type_lookup) (abfd,code)
278 bfd *abfd;
279 bfd_reloc_code_real_type code;
280{
281#define EXT(i, j) case i: return &howto_table_ext[j]
282#define STD(i, j) case i: return &howto_table_std[j]
283 int ext = obj_reloc_entry_size (abfd) == RELOC_EXT_SIZE;
274};
275
276#define TABLE_SIZE(TABLE) (sizeof (TABLE) / sizeof (TABLE[0]))
277
278reloc_howto_type *
279NAME(aout,reloc_type_lookup) (abfd,code)
280 bfd *abfd;
281 bfd_reloc_code_real_type code;
282{
283#define EXT(i, j) case i: return &howto_table_ext[j]
284#define STD(i, j) case i: return &howto_table_std[j]
285 int ext = obj_reloc_entry_size (abfd) == RELOC_EXT_SIZE;
286
284 if (code == BFD_RELOC_CTOR)
285 switch (bfd_get_arch_info (abfd)->bits_per_address)
286 {
287 case 32:
288 code = BFD_RELOC_32;
289 break;
290 case 64:
291 code = BFD_RELOC_64;
292 break;
293 }
287 if (code == BFD_RELOC_CTOR)
288 switch (bfd_get_arch_info (abfd)->bits_per_address)
289 {
290 case 32:
291 code = BFD_RELOC_32;
292 break;
293 case 64:
294 code = BFD_RELOC_64;
295 break;
296 }
297
294 if (ext)
295 switch (code)
296 {
297 EXT (BFD_RELOC_8, 0);
298 EXT (BFD_RELOC_16, 1);
299 EXT (BFD_RELOC_32, 2);
300 EXT (BFD_RELOC_HI22, 8);
301 EXT (BFD_RELOC_LO10, 11);

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

308 EXT (BFD_RELOC_SPARC_GOT22, 16);
309 EXT (BFD_RELOC_SPARC_PC10, 17);
310 EXT (BFD_RELOC_SPARC_PC22, 18);
311 EXT (BFD_RELOC_SPARC_WPLT30, 19);
312 EXT (BFD_RELOC_SPARC_REV32, 26);
313 default: return (reloc_howto_type *) NULL;
314 }
315 else
298 if (ext)
299 switch (code)
300 {
301 EXT (BFD_RELOC_8, 0);
302 EXT (BFD_RELOC_16, 1);
303 EXT (BFD_RELOC_32, 2);
304 EXT (BFD_RELOC_HI22, 8);
305 EXT (BFD_RELOC_LO10, 11);

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

312 EXT (BFD_RELOC_SPARC_GOT22, 16);
313 EXT (BFD_RELOC_SPARC_PC10, 17);
314 EXT (BFD_RELOC_SPARC_PC22, 18);
315 EXT (BFD_RELOC_SPARC_WPLT30, 19);
316 EXT (BFD_RELOC_SPARC_REV32, 26);
317 default: return (reloc_howto_type *) NULL;
318 }
319 else
316 /* std relocs */
320 /* std relocs. */
317 switch (code)
318 {
321 switch (code)
322 {
323 STD (BFD_RELOC_8, 0);
319 STD (BFD_RELOC_16, 1);
320 STD (BFD_RELOC_32, 2);
321 STD (BFD_RELOC_8_PCREL, 4);
322 STD (BFD_RELOC_16_PCREL, 5);
323 STD (BFD_RELOC_32_PCREL, 6);
324 STD (BFD_RELOC_16_BASEREL, 9);
325 STD (BFD_RELOC_32_BASEREL, 10);
326 default: return (reloc_howto_type *) NULL;

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

411 PUT_WORD (abfd, execp->a_syms , bytes->e_syms);
412 PUT_WORD (abfd, execp->a_entry , bytes->e_entry);
413 PUT_WORD (abfd, execp->a_trsize, bytes->e_trsize);
414 PUT_WORD (abfd, execp->a_drsize, bytes->e_drsize);
415}
416
417/* Make all the section for an a.out file. */
418
324 STD (BFD_RELOC_16, 1);
325 STD (BFD_RELOC_32, 2);
326 STD (BFD_RELOC_8_PCREL, 4);
327 STD (BFD_RELOC_16_PCREL, 5);
328 STD (BFD_RELOC_32_PCREL, 6);
329 STD (BFD_RELOC_16_BASEREL, 9);
330 STD (BFD_RELOC_32_BASEREL, 10);
331 default: return (reloc_howto_type *) NULL;

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

416 PUT_WORD (abfd, execp->a_syms , bytes->e_syms);
417 PUT_WORD (abfd, execp->a_entry , bytes->e_entry);
418 PUT_WORD (abfd, execp->a_trsize, bytes->e_trsize);
419 PUT_WORD (abfd, execp->a_drsize, bytes->e_drsize);
420}
421
422/* Make all the section for an a.out file. */
423
419boolean
424bfd_boolean
420NAME(aout,make_sections) (abfd)
421 bfd *abfd;
422{
423 if (obj_textsec (abfd) == (asection *) NULL
424 && bfd_make_section (abfd, ".text") == (asection *) NULL)
425NAME(aout,make_sections) (abfd)
426 bfd *abfd;
427{
428 if (obj_textsec (abfd) == (asection *) NULL
429 && bfd_make_section (abfd, ".text") == (asection *) NULL)
425 return false;
430 return FALSE;
426 if (obj_datasec (abfd) == (asection *) NULL
427 && bfd_make_section (abfd, ".data") == (asection *) NULL)
431 if (obj_datasec (abfd) == (asection *) NULL
432 && bfd_make_section (abfd, ".data") == (asection *) NULL)
428 return false;
433 return FALSE;
429 if (obj_bsssec (abfd) == (asection *) NULL
430 && bfd_make_section (abfd, ".bss") == (asection *) NULL)
434 if (obj_bsssec (abfd) == (asection *) NULL
435 && bfd_make_section (abfd, ".bss") == (asection *) NULL)
431 return false;
432 return true;
436 return FALSE;
437 return TRUE;
433}
434
435/*
436FUNCTION
437 aout_@var{size}_some_aout_object_p
438
439SYNOPSIS
440 const bfd_target *aout_@var{size}_some_aout_object_p

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

469 /* Copy the contents of the old tdata struct.
470 In particular, we want the subformat, since for hpux it was set in
471 hp300hpux.c:swap_exec_header_in and will be used in
472 hp300hpux.c:callback. */
473 if (oldrawptr != NULL)
474 *abfd->tdata.aout_data = *oldrawptr;
475
476 abfd->tdata.aout_data->a.hdr = &rawptr->e;
438}
439
440/*
441FUNCTION
442 aout_@var{size}_some_aout_object_p
443
444SYNOPSIS
445 const bfd_target *aout_@var{size}_some_aout_object_p

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

474 /* Copy the contents of the old tdata struct.
475 In particular, we want the subformat, since for hpux it was set in
476 hp300hpux.c:swap_exec_header_in and will be used in
477 hp300hpux.c:callback. */
478 if (oldrawptr != NULL)
479 *abfd->tdata.aout_data = *oldrawptr;
480
481 abfd->tdata.aout_data->a.hdr = &rawptr->e;
477 *(abfd->tdata.aout_data->a.hdr) = *execp; /* Copy in the internal_exec struct */
482 /* Copy in the internal_exec struct. */
483 *(abfd->tdata.aout_data->a.hdr) = *execp;
478 execp = abfd->tdata.aout_data->a.hdr;
479
484 execp = abfd->tdata.aout_data->a.hdr;
485
480 /* Set the file flags */
486 /* Set the file flags. */
481 abfd->flags = BFD_NO_FLAGS;
482 if (execp->a_drsize || execp->a_trsize)
483 abfd->flags |= HAS_RELOC;
487 abfd->flags = BFD_NO_FLAGS;
488 if (execp->a_drsize || execp->a_trsize)
489 abfd->flags |= HAS_RELOC;
484 /* Setting of EXEC_P has been deferred to the bottom of this function */
490 /* Setting of EXEC_P has been deferred to the bottom of this function. */
485 if (execp->a_syms)
486 abfd->flags |= HAS_LINENO | HAS_DEBUG | HAS_SYMS | HAS_LOCALS;
487 if (N_DYNAMIC (*execp))
488 abfd->flags |= DYNAMIC;
489
490 if (N_MAGIC (*execp) == ZMAGIC)
491 {
492 abfd->flags |= D_PAGED | WP_TEXT;

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

558 /* Call back to the format-dependent code to fill in the rest of the
559 fields and do any further cleanup. Things that should be filled
560 in by the callback: */
561
562 struct exec *execp = exec_hdr (abfd);
563
564 obj_textsec (abfd)->size = N_TXTSIZE (*execp);
565 obj_textsec (abfd)->raw_size = N_TXTSIZE (*execp);
491 if (execp->a_syms)
492 abfd->flags |= HAS_LINENO | HAS_DEBUG | HAS_SYMS | HAS_LOCALS;
493 if (N_DYNAMIC (*execp))
494 abfd->flags |= DYNAMIC;
495
496 if (N_MAGIC (*execp) == ZMAGIC)
497 {
498 abfd->flags |= D_PAGED | WP_TEXT;

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

564 /* Call back to the format-dependent code to fill in the rest of the
565 fields and do any further cleanup. Things that should be filled
566 in by the callback: */
567
568 struct exec *execp = exec_hdr (abfd);
569
570 obj_textsec (abfd)->size = N_TXTSIZE (*execp);
571 obj_textsec (abfd)->raw_size = N_TXTSIZE (*execp);
566 /* data and bss are already filled in since they're so standard */
572 /* Data and bss are already filled in since they're so standard. */
567
573
568 /* The virtual memory addresses of the sections */
574 /* The virtual memory addresses of the sections. */
569 obj_textsec (abfd)->vma = N_TXTADDR (*execp);
570 obj_datasec (abfd)->vma = N_DATADDR (*execp);
571 obj_bsssec (abfd)->vma = N_BSSADDR (*execp);
572
575 obj_textsec (abfd)->vma = N_TXTADDR (*execp);
576 obj_datasec (abfd)->vma = N_DATADDR (*execp);
577 obj_bsssec (abfd)->vma = N_BSSADDR (*execp);
578
573 /* The file offsets of the sections */
579 /* The file offsets of the sections. */
574 obj_textsec (abfd)->filepos = N_TXTOFF (*execp);
575 obj_datasec (abfd)->filepos = N_DATOFF (*execp);
576
580 obj_textsec (abfd)->filepos = N_TXTOFF (*execp);
581 obj_datasec (abfd)->filepos = N_DATOFF (*execp);
582
577 /* The file offsets of the relocation info */
583 /* The file offsets of the relocation info. */
578 obj_textsec (abfd)->rel_filepos = N_TRELOFF (*execp);
579 obj_datasec (abfd)->rel_filepos = N_DRELOFF (*execp);
580
581 /* The file offsets of the string table and symbol table. */
582 obj_str_filepos (abfd) = N_STROFF (*execp);
583 obj_sym_filepos (abfd) = N_SYMOFF (*execp);
584
585 /* Determine the architecture and machine type of the object file. */

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

664 return NULL;
665}
666
667/*
668FUNCTION
669 aout_@var{size}_mkobject
670
671SYNOPSIS
584 obj_textsec (abfd)->rel_filepos = N_TRELOFF (*execp);
585 obj_datasec (abfd)->rel_filepos = N_DRELOFF (*execp);
586
587 /* The file offsets of the string table and symbol table. */
588 obj_str_filepos (abfd) = N_STROFF (*execp);
589 obj_sym_filepos (abfd) = N_SYMOFF (*execp);
590
591 /* Determine the architecture and machine type of the object file. */

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

670 return NULL;
671}
672
673/*
674FUNCTION
675 aout_@var{size}_mkobject
676
677SYNOPSIS
672 boolean aout_@var{size}_mkobject, (bfd *abfd);
678 bfd_boolean aout_@var{size}_mkobject, (bfd *abfd);
673
674DESCRIPTION
675 Initialize BFD @var{abfd} for use with a.out files.
676*/
677
679
680DESCRIPTION
681 Initialize BFD @var{abfd} for use with a.out files.
682*/
683
678boolean
684bfd_boolean
679NAME(aout,mkobject) (abfd)
680 bfd *abfd;
681{
682 struct aout_data_struct *rawptr;
683 bfd_size_type amt = sizeof (struct aout_data_struct);
684
685 bfd_set_error (bfd_error_system_call);
686
687 rawptr = (struct aout_data_struct *) bfd_zalloc (abfd, amt);
688 if (rawptr == NULL)
685NAME(aout,mkobject) (abfd)
686 bfd *abfd;
687{
688 struct aout_data_struct *rawptr;
689 bfd_size_type amt = sizeof (struct aout_data_struct);
690
691 bfd_set_error (bfd_error_system_call);
692
693 rawptr = (struct aout_data_struct *) bfd_zalloc (abfd, amt);
694 if (rawptr == NULL)
689 return false;
695 return FALSE;
690
691 abfd->tdata.aout_data = rawptr;
692 exec_hdr (abfd) = &(rawptr->e);
693
694 obj_textsec (abfd) = (asection *) NULL;
695 obj_datasec (abfd) = (asection *) NULL;
696 obj_bsssec (abfd) = (asection *) NULL;
697
696
697 abfd->tdata.aout_data = rawptr;
698 exec_hdr (abfd) = &(rawptr->e);
699
700 obj_textsec (abfd) = (asection *) NULL;
701 obj_datasec (abfd) = (asection *) NULL;
702 obj_bsssec (abfd) = (asection *) NULL;
703
698 return true;
704 return TRUE;
699}
700
701/*
702FUNCTION
703 aout_@var{size}_machine_type
704
705SYNOPSIS
706 enum machine_type aout_@var{size}_machine_type

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

716 If the architecture is understood, machine type 0 (default)
717 is always understood.
718*/
719
720enum machine_type
721NAME(aout,machine_type) (arch, machine, unknown)
722 enum bfd_architecture arch;
723 unsigned long machine;
705}
706
707/*
708FUNCTION
709 aout_@var{size}_machine_type
710
711SYNOPSIS
712 enum machine_type aout_@var{size}_machine_type

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

722 If the architecture is understood, machine type 0 (default)
723 is always understood.
724*/
725
726enum machine_type
727NAME(aout,machine_type) (arch, machine, unknown)
728 enum bfd_architecture arch;
729 unsigned long machine;
724 boolean *unknown;
730 bfd_boolean *unknown;
725{
726 enum machine_type arch_flags;
727
728 arch_flags = M_UNKNOWN;
731{
732 enum machine_type arch_flags;
733
734 arch_flags = M_UNKNOWN;
729 *unknown = true;
735 *unknown = TRUE;
730
731 switch (arch)
732 {
733 case bfd_arch_sparc:
734 if (machine == 0
735 || machine == bfd_mach_sparc
736 || machine == bfd_mach_sparc_sparclite
737 || machine == bfd_mach_sparc_sparclite_le
738 || machine == bfd_mach_sparc_v9)
739 arch_flags = M_SPARC;
740 else if (machine == bfd_mach_sparc_sparclet)
741 arch_flags = M_SPARCLET;
742 break;
743
744 case bfd_arch_m68k:
745 switch (machine)
746 {
747 case 0: arch_flags = M_68010; break;
736
737 switch (arch)
738 {
739 case bfd_arch_sparc:
740 if (machine == 0
741 || machine == bfd_mach_sparc
742 || machine == bfd_mach_sparc_sparclite
743 || machine == bfd_mach_sparc_sparclite_le
744 || machine == bfd_mach_sparc_v9)
745 arch_flags = M_SPARC;
746 else if (machine == bfd_mach_sparc_sparclet)
747 arch_flags = M_SPARCLET;
748 break;
749
750 case bfd_arch_m68k:
751 switch (machine)
752 {
753 case 0: arch_flags = M_68010; break;
748 case bfd_mach_m68000: arch_flags = M_UNKNOWN; *unknown = false; break;
754 case bfd_mach_m68000: arch_flags = M_UNKNOWN; *unknown = FALSE; break;
749 case bfd_mach_m68010: arch_flags = M_68010; break;
750 case bfd_mach_m68020: arch_flags = M_68020; break;
751 default: arch_flags = M_UNKNOWN; break;
752 }
753 break;
754
755 case bfd_arch_i386:
755 case bfd_mach_m68010: arch_flags = M_68010; break;
756 case bfd_mach_m68020: arch_flags = M_68020; break;
757 default: arch_flags = M_UNKNOWN; break;
758 }
759 break;
760
761 case bfd_arch_i386:
756 if (machine == 0)
762 if (machine == 0
763 || machine == bfd_mach_i386_i386
764 || machine == bfd_mach_i386_i386_intel_syntax)
757 arch_flags = M_386;
758 break;
759
760 case bfd_arch_a29k:
761 if (machine == 0)
762 arch_flags = M_29K;
763 break;
764

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

785 case bfd_mach_mips4400:
786 case bfd_mach_mips4600:
787 case bfd_mach_mips4650:
788 case bfd_mach_mips8000:
789 case bfd_mach_mips10000:
790 case bfd_mach_mips12000:
791 case bfd_mach_mips16:
792 case bfd_mach_mipsisa32:
765 arch_flags = M_386;
766 break;
767
768 case bfd_arch_a29k:
769 if (machine == 0)
770 arch_flags = M_29K;
771 break;
772

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

793 case bfd_mach_mips4400:
794 case bfd_mach_mips4600:
795 case bfd_mach_mips4650:
796 case bfd_mach_mips8000:
797 case bfd_mach_mips10000:
798 case bfd_mach_mips12000:
799 case bfd_mach_mips16:
800 case bfd_mach_mipsisa32:
801 case bfd_mach_mipsisa32r2:
793 case bfd_mach_mips5:
794 case bfd_mach_mipsisa64:
802 case bfd_mach_mips5:
803 case bfd_mach_mipsisa64:
804 case bfd_mach_mipsisa64r2:
795 case bfd_mach_mips_sb1:
796 /* FIXME: These should be MIPS3, MIPS4, MIPS16, MIPS32, etc. */
797 arch_flags = M_MIPS2;
798 break;
799 default:
800 arch_flags = M_UNKNOWN;
801 break;
802 }

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

808 case 0: arch_flags = M_NS32532; break;
809 case 32032: arch_flags = M_NS32032; break;
810 case 32532: arch_flags = M_NS32532; break;
811 default: arch_flags = M_UNKNOWN; break;
812 }
813 break;
814
815 case bfd_arch_vax:
805 case bfd_mach_mips_sb1:
806 /* FIXME: These should be MIPS3, MIPS4, MIPS16, MIPS32, etc. */
807 arch_flags = M_MIPS2;
808 break;
809 default:
810 arch_flags = M_UNKNOWN;
811 break;
812 }

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

818 case 0: arch_flags = M_NS32532; break;
819 case 32032: arch_flags = M_NS32032; break;
820 case 32532: arch_flags = M_NS32532; break;
821 default: arch_flags = M_UNKNOWN; break;
822 }
823 break;
824
825 case bfd_arch_vax:
816 *unknown = false;
826 *unknown = FALSE;
817 break;
818
819 case bfd_arch_cris:
820 if (machine == 0 || machine == 255)
821 arch_flags = M_CRIS;
822 break;
823
824 default:
825 arch_flags = M_UNKNOWN;
826 }
827
828 if (arch_flags != M_UNKNOWN)
827 break;
828
829 case bfd_arch_cris:
830 if (machine == 0 || machine == 255)
831 arch_flags = M_CRIS;
832 break;
833
834 default:
835 arch_flags = M_UNKNOWN;
836 }
837
838 if (arch_flags != M_UNKNOWN)
829 *unknown = false;
839 *unknown = FALSE;
830
831 return arch_flags;
832}
833
834/*
835FUNCTION
836 aout_@var{size}_set_arch_mach
837
838SYNOPSIS
840
841 return arch_flags;
842}
843
844/*
845FUNCTION
846 aout_@var{size}_set_arch_mach
847
848SYNOPSIS
839 boolean aout_@var{size}_set_arch_mach,
849 bfd_boolean aout_@var{size}_set_arch_mach,
840 (bfd *,
841 enum bfd_architecture arch,
842 unsigned long machine));
843
844DESCRIPTION
845 Set the architecture and the machine of the BFD @var{abfd} to the
846 values @var{arch} and @var{machine}. Verify that @var{abfd}'s format
847 can support the architecture required.
848*/
849
850 (bfd *,
851 enum bfd_architecture arch,
852 unsigned long machine));
853
854DESCRIPTION
855 Set the architecture and the machine of the BFD @var{abfd} to the
856 values @var{arch} and @var{machine}. Verify that @var{abfd}'s format
857 can support the architecture required.
858*/
859
850boolean
860bfd_boolean
851NAME(aout,set_arch_mach) (abfd, arch, machine)
852 bfd *abfd;
853 enum bfd_architecture arch;
854 unsigned long machine;
855{
856 if (! bfd_default_set_arch_mach (abfd, arch, machine))
861NAME(aout,set_arch_mach) (abfd, arch, machine)
862 bfd *abfd;
863 enum bfd_architecture arch;
864 unsigned long machine;
865{
866 if (! bfd_default_set_arch_mach (abfd, arch, machine))
857 return false;
867 return FALSE;
858
859 if (arch != bfd_arch_unknown)
860 {
868
869 if (arch != bfd_arch_unknown)
870 {
861 boolean unknown;
871 bfd_boolean unknown;
862
863 NAME(aout,machine_type) (arch, machine, &unknown);
864 if (unknown)
872
873 NAME(aout,machine_type) (arch, machine, &unknown);
874 if (unknown)
865 return false;
875 return FALSE;
866 }
867
876 }
877
868 /* Determine the size of a relocation entry */
878 /* Determine the size of a relocation entry. */
869 switch (arch)
870 {
871 case bfd_arch_sparc:
872 case bfd_arch_a29k:
873 case bfd_arch_mips:
874 obj_reloc_entry_size (abfd) = RELOC_EXT_SIZE;
875 break;
876 default:

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

898 vma = obj_textsec (abfd)->vma;
899
900 pos += obj_textsec (abfd)->_raw_size;
901 vma += obj_textsec (abfd)->_raw_size;
902
903 /* Data. */
904 if (!obj_datasec (abfd)->user_set_vma)
905 {
879 switch (arch)
880 {
881 case bfd_arch_sparc:
882 case bfd_arch_a29k:
883 case bfd_arch_mips:
884 obj_reloc_entry_size (abfd) = RELOC_EXT_SIZE;
885 break;
886 default:

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

908 vma = obj_textsec (abfd)->vma;
909
910 pos += obj_textsec (abfd)->_raw_size;
911 vma += obj_textsec (abfd)->_raw_size;
912
913 /* Data. */
914 if (!obj_datasec (abfd)->user_set_vma)
915 {
906#if 0 /* ?? Does alignment in the file image really matter? */
916#if 0 /* ?? Does alignment in the file image really matter? */
907 pad = align_power (vma, obj_datasec (abfd)->alignment_power) - vma;
908#endif
909 obj_textsec (abfd)->_raw_size += pad;
910 pos += pad;
911 vma += pad;
912 obj_datasec (abfd)->vma = vma;
913 }
914 else

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

1105
1106 /* Fix up exec header. */
1107 execp->a_text = obj_textsec (abfd)->_raw_size;
1108 execp->a_data = obj_datasec (abfd)->_raw_size;
1109 execp->a_bss = obj_bsssec (abfd)->_raw_size;
1110 N_SET_MAGIC (*execp, NMAGIC);
1111}
1112
917 pad = align_power (vma, obj_datasec (abfd)->alignment_power) - vma;
918#endif
919 obj_textsec (abfd)->_raw_size += pad;
920 pos += pad;
921 vma += pad;
922 obj_datasec (abfd)->vma = vma;
923 }
924 else

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

1115
1116 /* Fix up exec header. */
1117 execp->a_text = obj_textsec (abfd)->_raw_size;
1118 execp->a_data = obj_datasec (abfd)->_raw_size;
1119 execp->a_bss = obj_bsssec (abfd)->_raw_size;
1120 N_SET_MAGIC (*execp, NMAGIC);
1121}
1122
1113boolean
1123bfd_boolean
1114NAME(aout,adjust_sizes_and_vmas) (abfd, text_size, text_end)
1115 bfd *abfd;
1116 bfd_size_type *text_size;
1117 file_ptr *text_end ATTRIBUTE_UNUSED;
1118{
1119 struct internal_exec *execp = exec_hdr (abfd);
1120
1121 if (! NAME(aout,make_sections) (abfd))
1124NAME(aout,adjust_sizes_and_vmas) (abfd, text_size, text_end)
1125 bfd *abfd;
1126 bfd_size_type *text_size;
1127 file_ptr *text_end ATTRIBUTE_UNUSED;
1128{
1129 struct internal_exec *execp = exec_hdr (abfd);
1130
1131 if (! NAME(aout,make_sections) (abfd))
1122 return false;
1132 return FALSE;
1123
1124 if (adata (abfd).magic != undecided_magic)
1133
1134 if (adata (abfd).magic != undecided_magic)
1125 return true;
1135 return TRUE;
1126
1127 obj_textsec (abfd)->_raw_size =
1128 align_power (obj_textsec (abfd)->_raw_size,
1129 obj_textsec (abfd)->alignment_power);
1130
1131 *text_size = obj_textsec (abfd)->_raw_size;
1132 /* Rule (heuristic) for when to pad to a new page. Note that there
1133 are (at least) two ways demand-paged (ZMAGIC) files have been

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

1194 fprintf (stderr, " text=<%x,%x,%x> data=<%x,%x,%x> bss=<%x,%x>\n",
1195 obj_textsec (abfd)->vma, obj_textsec (abfd)->_raw_size,
1196 obj_textsec (abfd)->filepos,
1197 obj_datasec (abfd)->vma, obj_datasec (abfd)->_raw_size,
1198 obj_datasec (abfd)->filepos,
1199 obj_bsssec (abfd)->vma, obj_bsssec (abfd)->_raw_size);
1200#endif
1201
1136
1137 obj_textsec (abfd)->_raw_size =
1138 align_power (obj_textsec (abfd)->_raw_size,
1139 obj_textsec (abfd)->alignment_power);
1140
1141 *text_size = obj_textsec (abfd)->_raw_size;
1142 /* Rule (heuristic) for when to pad to a new page. Note that there
1143 are (at least) two ways demand-paged (ZMAGIC) files have been

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

1204 fprintf (stderr, " text=<%x,%x,%x> data=<%x,%x,%x> bss=<%x,%x>\n",
1205 obj_textsec (abfd)->vma, obj_textsec (abfd)->_raw_size,
1206 obj_textsec (abfd)->filepos,
1207 obj_datasec (abfd)->vma, obj_datasec (abfd)->_raw_size,
1208 obj_datasec (abfd)->filepos,
1209 obj_bsssec (abfd)->vma, obj_bsssec (abfd)->_raw_size);
1210#endif
1211
1202 return true;
1212 return TRUE;
1203}
1204
1205/*
1206FUNCTION
1207 aout_@var{size}_new_section_hook
1208
1209SYNOPSIS
1213}
1214
1215/*
1216FUNCTION
1217 aout_@var{size}_new_section_hook
1218
1219SYNOPSIS
1210 boolean aout_@var{size}_new_section_hook,
1220 bfd_boolean aout_@var{size}_new_section_hook,
1211 (bfd *abfd,
1212 asection *newsect));
1213
1214DESCRIPTION
1215 Called by the BFD in response to a @code{bfd_make_section}
1216 request.
1217*/
1221 (bfd *abfd,
1222 asection *newsect));
1223
1224DESCRIPTION
1225 Called by the BFD in response to a @code{bfd_make_section}
1226 request.
1227*/
1218boolean
1228bfd_boolean
1219NAME(aout,new_section_hook) (abfd, newsect)
1220 bfd *abfd;
1221 asection *newsect;
1222{
1229NAME(aout,new_section_hook) (abfd, newsect)
1230 bfd *abfd;
1231 asection *newsect;
1232{
1223 /* align to double at least */
1233 /* Align to double at least. */
1224 newsect->alignment_power = bfd_get_arch_info (abfd)->section_align_power;
1225
1226 if (bfd_get_format (abfd) == bfd_object)
1234 newsect->alignment_power = bfd_get_arch_info (abfd)->section_align_power;
1235
1236 if (bfd_get_format (abfd) == bfd_object)
1227 {
1228 if (obj_textsec (abfd) == NULL && !strcmp (newsect->name, ".text"))
1229 {
1230 obj_textsec (abfd)= newsect;
1231 newsect->target_index = N_TEXT;
1232 return true;
1233 }
1237 {
1238 if (obj_textsec (abfd) == NULL && !strcmp (newsect->name, ".text"))
1239 {
1240 obj_textsec (abfd)= newsect;
1241 newsect->target_index = N_TEXT;
1242 return TRUE;
1243 }
1234
1244
1235 if (obj_datasec (abfd) == NULL && !strcmp (newsect->name, ".data"))
1236 {
1237 obj_datasec (abfd) = newsect;
1238 newsect->target_index = N_DATA;
1239 return true;
1240 }
1245 if (obj_datasec (abfd) == NULL && !strcmp (newsect->name, ".data"))
1246 {
1247 obj_datasec (abfd) = newsect;
1248 newsect->target_index = N_DATA;
1249 return TRUE;
1250 }
1241
1251
1242 if (obj_bsssec (abfd) == NULL && !strcmp (newsect->name, ".bss"))
1243 {
1244 obj_bsssec (abfd) = newsect;
1245 newsect->target_index = N_BSS;
1246 return true;
1247 }
1252 if (obj_bsssec (abfd) == NULL && !strcmp (newsect->name, ".bss"))
1253 {
1254 obj_bsssec (abfd) = newsect;
1255 newsect->target_index = N_BSS;
1256 return TRUE;
1257 }
1258 }
1248
1259
1249 }
1250
1251 /* We allow more than three sections internally */
1252 return true;
1260 /* We allow more than three sections internally. */
1261 return TRUE;
1253}
1254
1262}
1263
1255boolean
1264bfd_boolean
1256NAME(aout,set_section_contents) (abfd, section, location, offset, count)
1257 bfd *abfd;
1258 sec_ptr section;
1265NAME(aout,set_section_contents) (abfd, section, location, offset, count)
1266 bfd *abfd;
1267 sec_ptr section;
1259 PTR location;
1268 const PTR location;
1260 file_ptr offset;
1261 bfd_size_type count;
1262{
1263 file_ptr text_end;
1264 bfd_size_type text_size;
1265
1266 if (! abfd->output_has_begun)
1267 {
1268 if (! NAME(aout,adjust_sizes_and_vmas) (abfd, &text_size, &text_end))
1269 file_ptr offset;
1270 bfd_size_type count;
1271{
1272 file_ptr text_end;
1273 bfd_size_type text_size;
1274
1275 if (! abfd->output_has_begun)
1276 {
1277 if (! NAME(aout,adjust_sizes_and_vmas) (abfd, &text_size, &text_end))
1269 return false;
1278 return FALSE;
1270 }
1271
1272 if (section == obj_bsssec (abfd))
1273 {
1274 bfd_set_error (bfd_error_no_contents);
1279 }
1280
1281 if (section == obj_bsssec (abfd))
1282 {
1283 bfd_set_error (bfd_error_no_contents);
1275 return false;
1284 return FALSE;
1276 }
1277
1278 if (section != obj_textsec (abfd)
1279 && section != obj_datasec (abfd))
1280 {
1285 }
1286
1287 if (section != obj_textsec (abfd)
1288 && section != obj_datasec (abfd))
1289 {
1281 (*_bfd_error_handler)
1282 (_("%s: can not represent section `%s' in a.out object file format"),
1283 bfd_get_filename (abfd), bfd_get_section_name (abfd, section));
1284 bfd_set_error (bfd_error_nonrepresentable_section);
1285 return false;
1290 if (aout_section_merge_with_text_p (abfd, section))
1291 section->filepos = obj_textsec (abfd)->filepos +
1292 (section->vma - obj_textsec (abfd)->vma);
1293 else
1294 {
1295 (*_bfd_error_handler)
1296 (_("%s: can not represent section `%s' in a.out object file format"),
1297 bfd_get_filename (abfd), bfd_get_section_name (abfd, section));
1298 bfd_set_error (bfd_error_nonrepresentable_section);
1299 return FALSE;
1300 }
1286 }
1287
1288 if (count != 0)
1289 {
1290 if (bfd_seek (abfd, section->filepos + offset, SEEK_SET) != 0
1291 || bfd_bwrite (location, count, abfd) != count)
1301 }
1302
1303 if (count != 0)
1304 {
1305 if (bfd_seek (abfd, section->filepos + offset, SEEK_SET) != 0
1306 || bfd_bwrite (location, count, abfd) != count)
1292 return false;
1307 return FALSE;
1293 }
1294
1308 }
1309
1295 return true;
1310 return TRUE;
1296}
1297
1298/* Read the external symbols from an a.out file. */
1299
1311}
1312
1313/* Read the external symbols from an a.out file. */
1314
1300static boolean
1315static bfd_boolean
1301aout_get_external_symbols (abfd)
1302 bfd *abfd;
1303{
1304 if (obj_aout_external_syms (abfd) == (struct external_nlist *) NULL)
1305 {
1306 bfd_size_type count;
1307 struct external_nlist *syms;
1308 bfd_size_type amt;
1309
1310 count = exec_hdr (abfd)->a_syms / EXTERNAL_NLIST_SIZE;
1311
1312#ifdef USE_MMAP
1313 if (! bfd_get_file_window (abfd, obj_sym_filepos (abfd),
1314 exec_hdr (abfd)->a_syms,
1316aout_get_external_symbols (abfd)
1317 bfd *abfd;
1318{
1319 if (obj_aout_external_syms (abfd) == (struct external_nlist *) NULL)
1320 {
1321 bfd_size_type count;
1322 struct external_nlist *syms;
1323 bfd_size_type amt;
1324
1325 count = exec_hdr (abfd)->a_syms / EXTERNAL_NLIST_SIZE;
1326
1327#ifdef USE_MMAP
1328 if (! bfd_get_file_window (abfd, obj_sym_filepos (abfd),
1329 exec_hdr (abfd)->a_syms,
1315 &obj_aout_sym_window (abfd), true))
1316 return false;
1330 &obj_aout_sym_window (abfd), TRUE))
1331 return FALSE;
1317 syms = (struct external_nlist *) obj_aout_sym_window (abfd).data;
1318#else
1319 /* We allocate using malloc to make the values easy to free
1320 later on. If we put them on the objalloc it might not be
1321 possible to free them. */
1322 syms = ((struct external_nlist *)
1323 bfd_malloc (count * EXTERNAL_NLIST_SIZE));
1324 if (syms == (struct external_nlist *) NULL && count != 0)
1332 syms = (struct external_nlist *) obj_aout_sym_window (abfd).data;
1333#else
1334 /* We allocate using malloc to make the values easy to free
1335 later on. If we put them on the objalloc it might not be
1336 possible to free them. */
1337 syms = ((struct external_nlist *)
1338 bfd_malloc (count * EXTERNAL_NLIST_SIZE));
1339 if (syms == (struct external_nlist *) NULL && count != 0)
1325 return false;
1340 return FALSE;
1326
1327 amt = exec_hdr (abfd)->a_syms;
1328 if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0
1329 || bfd_bread (syms, amt, abfd) != amt)
1330 {
1331 free (syms);
1341
1342 amt = exec_hdr (abfd)->a_syms;
1343 if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0
1344 || bfd_bread (syms, amt, abfd) != amt)
1345 {
1346 free (syms);
1332 return false;
1347 return FALSE;
1333 }
1334#endif
1335
1336 obj_aout_external_syms (abfd) = syms;
1337 obj_aout_external_sym_count (abfd) = count;
1338 }
1339
1340 if (obj_aout_external_strings (abfd) == NULL
1341 && exec_hdr (abfd)->a_syms != 0)
1342 {
1343 unsigned char string_chars[BYTES_IN_WORD];
1344 bfd_size_type stringsize;
1345 char *strings;
1346 bfd_size_type amt = BYTES_IN_WORD;
1347
1348 /* Get the size of the strings. */
1349 if (bfd_seek (abfd, obj_str_filepos (abfd), SEEK_SET) != 0
1350 || bfd_bread ((PTR) string_chars, amt, abfd) != amt)
1348 }
1349#endif
1350
1351 obj_aout_external_syms (abfd) = syms;
1352 obj_aout_external_sym_count (abfd) = count;
1353 }
1354
1355 if (obj_aout_external_strings (abfd) == NULL
1356 && exec_hdr (abfd)->a_syms != 0)
1357 {
1358 unsigned char string_chars[BYTES_IN_WORD];
1359 bfd_size_type stringsize;
1360 char *strings;
1361 bfd_size_type amt = BYTES_IN_WORD;
1362
1363 /* Get the size of the strings. */
1364 if (bfd_seek (abfd, obj_str_filepos (abfd), SEEK_SET) != 0
1365 || bfd_bread ((PTR) string_chars, amt, abfd) != amt)
1351 return false;
1366 return FALSE;
1352 stringsize = GET_WORD (abfd, string_chars);
1353
1354#ifdef USE_MMAP
1355 if (! bfd_get_file_window (abfd, obj_str_filepos (abfd), stringsize,
1367 stringsize = GET_WORD (abfd, string_chars);
1368
1369#ifdef USE_MMAP
1370 if (! bfd_get_file_window (abfd, obj_str_filepos (abfd), stringsize,
1356 &obj_aout_string_window (abfd), true))
1357 return false;
1371 &obj_aout_string_window (abfd), TRUE))
1372 return FALSE;
1358 strings = (char *) obj_aout_string_window (abfd).data;
1359#else
1360 strings = (char *) bfd_malloc (stringsize + 1);
1361 if (strings == NULL)
1373 strings = (char *) obj_aout_string_window (abfd).data;
1374#else
1375 strings = (char *) bfd_malloc (stringsize + 1);
1376 if (strings == NULL)
1362 return false;
1377 return FALSE;
1363
1364 /* Skip space for the string count in the buffer for convenience
1365 when using indexes. */
1366 amt = stringsize - BYTES_IN_WORD;
1367 if (bfd_bread (strings + BYTES_IN_WORD, amt, abfd) != amt)
1368 {
1369 free (strings);
1378
1379 /* Skip space for the string count in the buffer for convenience
1380 when using indexes. */
1381 amt = stringsize - BYTES_IN_WORD;
1382 if (bfd_bread (strings + BYTES_IN_WORD, amt, abfd) != amt)
1383 {
1384 free (strings);
1370 return false;
1385 return FALSE;
1371 }
1372#endif
1373
1374 /* Ensure that a zero index yields an empty string. */
1375 strings[0] = '\0';
1376
1377 strings[stringsize - 1] = 0;
1378
1379 obj_aout_external_strings (abfd) = strings;
1380 obj_aout_external_string_size (abfd) = stringsize;
1381 }
1382
1386 }
1387#endif
1388
1389 /* Ensure that a zero index yields an empty string. */
1390 strings[0] = '\0';
1391
1392 strings[stringsize - 1] = 0;
1393
1394 obj_aout_external_strings (abfd) = strings;
1395 obj_aout_external_string_size (abfd) = stringsize;
1396 }
1397
1383 return true;
1398 return TRUE;
1384}
1385
1386/* Translate an a.out symbol into a BFD symbol. The desc, other, type
1387 and symbol->value fields of CACHE_PTR will be set from the a.out
1388 nlist structure. This function is responsible for setting
1389 symbol->flags and symbol->section, and adjusting symbol->value. */
1390
1399}
1400
1401/* Translate an a.out symbol into a BFD symbol. The desc, other, type
1402 and symbol->value fields of CACHE_PTR will be set from the a.out
1403 nlist structure. This function is responsible for setting
1404 symbol->flags and symbol->section, and adjusting symbol->value. */
1405
1391static boolean
1406static bfd_boolean
1392translate_from_native_sym_flags (abfd, cache_ptr)
1393 bfd *abfd;
1394 aout_symbol_type *cache_ptr;
1395{
1396 flagword visible;
1397
1398 if ((cache_ptr->type & N_STAB) != 0
1399 || cache_ptr->type == N_FN)
1400 {
1401 asection *sec;
1402
1403 /* This is a debugging symbol. */
1407translate_from_native_sym_flags (abfd, cache_ptr)
1408 bfd *abfd;
1409 aout_symbol_type *cache_ptr;
1410{
1411 flagword visible;
1412
1413 if ((cache_ptr->type & N_STAB) != 0
1414 || cache_ptr->type == N_FN)
1415 {
1416 asection *sec;
1417
1418 /* This is a debugging symbol. */
1404
1405 cache_ptr->symbol.flags = BSF_DEBUGGING;
1406
1407 /* Work out the symbol section. */
1408 switch (cache_ptr->type & N_TYPE)
1409 {
1410 case N_TEXT:
1411 case N_FN:
1412 sec = obj_textsec (abfd);

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

1421 case N_ABS:
1422 sec = bfd_abs_section_ptr;
1423 break;
1424 }
1425
1426 cache_ptr->symbol.section = sec;
1427 cache_ptr->symbol.value -= sec->vma;
1428
1419 cache_ptr->symbol.flags = BSF_DEBUGGING;
1420
1421 /* Work out the symbol section. */
1422 switch (cache_ptr->type & N_TYPE)
1423 {
1424 case N_TEXT:
1425 case N_FN:
1426 sec = obj_textsec (abfd);

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

1435 case N_ABS:
1436 sec = bfd_abs_section_ptr;
1437 break;
1438 }
1439
1440 cache_ptr->symbol.section = sec;
1441 cache_ptr->symbol.value -= sec->vma;
1442
1429 return true;
1443 return TRUE;
1430 }
1431
1432 /* Get the default visibility. This does not apply to all types, so
1433 we just hold it in a local variable to use if wanted. */
1434 if ((cache_ptr->type & N_EXT) == 0)
1435 visible = BSF_LOCAL;
1436 else
1437 visible = BSF_GLOBAL;

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

1510 section = bfd_get_section_by_name (abfd, cache_ptr->symbol.name);
1511 if (section == NULL)
1512 {
1513 char *copy;
1514
1515 amt = strlen (cache_ptr->symbol.name) + 1;
1516 copy = bfd_alloc (abfd, amt);
1517 if (copy == NULL)
1444 }
1445
1446 /* Get the default visibility. This does not apply to all types, so
1447 we just hold it in a local variable to use if wanted. */
1448 if ((cache_ptr->type & N_EXT) == 0)
1449 visible = BSF_LOCAL;
1450 else
1451 visible = BSF_GLOBAL;

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

1524 section = bfd_get_section_by_name (abfd, cache_ptr->symbol.name);
1525 if (section == NULL)
1526 {
1527 char *copy;
1528
1529 amt = strlen (cache_ptr->symbol.name) + 1;
1530 copy = bfd_alloc (abfd, amt);
1531 if (copy == NULL)
1518 return false;
1532 return FALSE;
1519
1520 strcpy (copy, cache_ptr->symbol.name);
1521 section = bfd_make_section (abfd, copy);
1522 if (section == NULL)
1533
1534 strcpy (copy, cache_ptr->symbol.name);
1535 section = bfd_make_section (abfd, copy);
1536 if (section == NULL)
1523 return false;
1537 return FALSE;
1524 }
1525
1526 amt = sizeof (arelent_chain);
1527 reloc = (arelent_chain *) bfd_alloc (abfd, amt);
1528 if (reloc == NULL)
1538 }
1539
1540 amt = sizeof (arelent_chain);
1541 reloc = (arelent_chain *) bfd_alloc (abfd, amt);
1542 if (reloc == NULL)
1529 return false;
1543 return FALSE;
1530
1531 /* Build a relocation entry for the constructor. */
1532 switch (cache_ptr->type & N_TYPE)
1533 {
1534 case N_SETA:
1535 into_section = bfd_abs_section_ptr;
1536 cache_ptr->type = N_ABS;
1537 break;

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

1634
1635 case N_WEAKB:
1636 cache_ptr->symbol.section = obj_bsssec (abfd);
1637 cache_ptr->symbol.value -= cache_ptr->symbol.section->vma;
1638 cache_ptr->symbol.flags = BSF_WEAK;
1639 break;
1640 }
1641
1544
1545 /* Build a relocation entry for the constructor. */
1546 switch (cache_ptr->type & N_TYPE)
1547 {
1548 case N_SETA:
1549 into_section = bfd_abs_section_ptr;
1550 cache_ptr->type = N_ABS;
1551 break;

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

1648
1649 case N_WEAKB:
1650 cache_ptr->symbol.section = obj_bsssec (abfd);
1651 cache_ptr->symbol.value -= cache_ptr->symbol.section->vma;
1652 cache_ptr->symbol.flags = BSF_WEAK;
1653 break;
1654 }
1655
1642 return true;
1656 return TRUE;
1643}
1644
1645/* Set the fields of SYM_POINTER according to CACHE_PTR. */
1646
1657}
1658
1659/* Set the fields of SYM_POINTER according to CACHE_PTR. */
1660
1647static boolean
1661static bfd_boolean
1648translate_to_native_sym_flags (abfd, cache_ptr, sym_pointer)
1649 bfd *abfd;
1650 asymbol *cache_ptr;
1651 struct external_nlist *sym_pointer;
1652{
1653 bfd_vma value = cache_ptr->value;
1654 asection *sec;
1655 bfd_vma off;

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

1665 {
1666 /* This case occurs, e.g., for the *DEBUG* section of a COFF
1667 file. */
1668 (*_bfd_error_handler)
1669 (_("%s: can not represent section for symbol `%s' in a.out object file format"),
1670 bfd_get_filename (abfd),
1671 cache_ptr->name != NULL ? cache_ptr->name : _("*unknown*"));
1672 bfd_set_error (bfd_error_nonrepresentable_section);
1662translate_to_native_sym_flags (abfd, cache_ptr, sym_pointer)
1663 bfd *abfd;
1664 asymbol *cache_ptr;
1665 struct external_nlist *sym_pointer;
1666{
1667 bfd_vma value = cache_ptr->value;
1668 asection *sec;
1669 bfd_vma off;

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

1679 {
1680 /* This case occurs, e.g., for the *DEBUG* section of a COFF
1681 file. */
1682 (*_bfd_error_handler)
1683 (_("%s: can not represent section for symbol `%s' in a.out object file format"),
1684 bfd_get_filename (abfd),
1685 cache_ptr->name != NULL ? cache_ptr->name : _("*unknown*"));
1686 bfd_set_error (bfd_error_nonrepresentable_section);
1673 return false;
1687 return FALSE;
1674 }
1675
1676 if (sec->output_section != NULL)
1677 {
1678 off = sec->output_offset;
1679 sec = sec->output_section;
1680 }
1681

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

1690 else if (bfd_is_und_section (sec))
1691 sym_pointer->e_type[0] = N_UNDF | N_EXT;
1692 else if (bfd_is_ind_section (sec))
1693 sym_pointer->e_type[0] = N_INDR;
1694 else if (bfd_is_com_section (sec))
1695 sym_pointer->e_type[0] = N_UNDF | N_EXT;
1696 else
1697 {
1688 }
1689
1690 if (sec->output_section != NULL)
1691 {
1692 off = sec->output_offset;
1693 sec = sec->output_section;
1694 }
1695

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

1704 else if (bfd_is_und_section (sec))
1705 sym_pointer->e_type[0] = N_UNDF | N_EXT;
1706 else if (bfd_is_ind_section (sec))
1707 sym_pointer->e_type[0] = N_INDR;
1708 else if (bfd_is_com_section (sec))
1709 sym_pointer->e_type[0] = N_UNDF | N_EXT;
1710 else
1711 {
1698 (*_bfd_error_handler)
1699 (_("%s: can not represent section `%s' in a.out object file format"),
1700 bfd_get_filename (abfd), bfd_get_section_name (abfd, sec));
1701 bfd_set_error (bfd_error_nonrepresentable_section);
1702 return false;
1712 if (aout_section_merge_with_text_p (abfd, sec))
1713 sym_pointer->e_type[0] |= N_TEXT;
1714 else
1715 {
1716 (*_bfd_error_handler)
1717 (_("%s: can not represent section `%s' in a.out object file format"),
1718 bfd_get_filename (abfd), bfd_get_section_name (abfd, sec));
1719 bfd_set_error (bfd_error_nonrepresentable_section);
1720 return FALSE;
1721 }
1703 }
1704
1722 }
1723
1705 /* Turn the symbol from section relative to absolute again */
1724 /* Turn the symbol from section relative to absolute again. */
1706 value += sec->vma + off;
1707
1708 if ((cache_ptr->flags & BSF_WARNING) != 0)
1709 sym_pointer->e_type[0] = N_WARNING;
1710
1711 if ((cache_ptr->flags & BSF_DEBUGGING) != 0)
1712 sym_pointer->e_type[0] = ((aout_symbol_type *) cache_ptr)->type;
1713 else if ((cache_ptr->flags & BSF_GLOBAL) != 0)
1714 sym_pointer->e_type[0] |= N_EXT;
1715 else if ((cache_ptr->flags & BSF_LOCAL) != 0)
1716 sym_pointer->e_type[0] &= ~N_EXT;
1717
1718 if ((cache_ptr->flags & BSF_CONSTRUCTOR) != 0)
1719 {
1720 int type = ((aout_symbol_type *) cache_ptr)->type;
1725 value += sec->vma + off;
1726
1727 if ((cache_ptr->flags & BSF_WARNING) != 0)
1728 sym_pointer->e_type[0] = N_WARNING;
1729
1730 if ((cache_ptr->flags & BSF_DEBUGGING) != 0)
1731 sym_pointer->e_type[0] = ((aout_symbol_type *) cache_ptr)->type;
1732 else if ((cache_ptr->flags & BSF_GLOBAL) != 0)
1733 sym_pointer->e_type[0] |= N_EXT;
1734 else if ((cache_ptr->flags & BSF_LOCAL) != 0)
1735 sym_pointer->e_type[0] &= ~N_EXT;
1736
1737 if ((cache_ptr->flags & BSF_CONSTRUCTOR) != 0)
1738 {
1739 int type = ((aout_symbol_type *) cache_ptr)->type;
1740
1721 switch (type)
1722 {
1723 case N_ABS: type = N_SETA; break;
1724 case N_TEXT: type = N_SETT; break;
1725 case N_DATA: type = N_SETD; break;
1726 case N_BSS: type = N_SETB; break;
1727 }
1728 sym_pointer->e_type[0] = type;

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

1741 case N_BSS: type = N_WEAKB; break;
1742 case N_UNDF: type = N_WEAKU; break;
1743 }
1744 sym_pointer->e_type[0] = type;
1745 }
1746
1747 PUT_WORD (abfd, value, sym_pointer->e_value);
1748
1741 switch (type)
1742 {
1743 case N_ABS: type = N_SETA; break;
1744 case N_TEXT: type = N_SETT; break;
1745 case N_DATA: type = N_SETD; break;
1746 case N_BSS: type = N_SETB; break;
1747 }
1748 sym_pointer->e_type[0] = type;

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

1761 case N_BSS: type = N_WEAKB; break;
1762 case N_UNDF: type = N_WEAKU; break;
1763 }
1764 sym_pointer->e_type[0] = type;
1765 }
1766
1767 PUT_WORD (abfd, value, sym_pointer->e_value);
1768
1749 return true;
1769 return TRUE;
1750}
1751
1752/* Native-level interface to symbols. */
1753
1754asymbol *
1755NAME(aout,make_empty_symbol) (abfd)
1756 bfd *abfd;
1757{
1758 bfd_size_type amt = sizeof (aout_symbol_type);
1759 aout_symbol_type *new = (aout_symbol_type *) bfd_zalloc (abfd, amt);
1760 if (!new)
1761 return NULL;
1762 new->symbol.the_bfd = abfd;
1763
1764 return &new->symbol;
1765}
1766
1767/* Translate a set of internal symbols into external symbols. */
1768
1770}
1771
1772/* Native-level interface to symbols. */
1773
1774asymbol *
1775NAME(aout,make_empty_symbol) (abfd)
1776 bfd *abfd;
1777{
1778 bfd_size_type amt = sizeof (aout_symbol_type);
1779 aout_symbol_type *new = (aout_symbol_type *) bfd_zalloc (abfd, amt);
1780 if (!new)
1781 return NULL;
1782 new->symbol.the_bfd = abfd;
1783
1784 return &new->symbol;
1785}
1786
1787/* Translate a set of internal symbols into external symbols. */
1788
1769boolean
1789bfd_boolean
1770NAME(aout,translate_symbol_table) (abfd, in, ext, count, str, strsize, dynamic)
1771 bfd *abfd;
1772 aout_symbol_type *in;
1773 struct external_nlist *ext;
1774 bfd_size_type count;
1775 char *str;
1776 bfd_size_type strsize;
1790NAME(aout,translate_symbol_table) (abfd, in, ext, count, str, strsize, dynamic)
1791 bfd *abfd;
1792 aout_symbol_type *in;
1793 struct external_nlist *ext;
1794 bfd_size_type count;
1795 char *str;
1796 bfd_size_type strsize;
1777 boolean dynamic;
1797 bfd_boolean dynamic;
1778{
1779 struct external_nlist *ext_end;
1780
1781 ext_end = ext + count;
1782 for (; ext < ext_end; ext++, in++)
1783 {
1784 bfd_vma x;
1785

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

1791 null string. For the dynamic symbols, the number of bytes in
1792 the string table is stored in the __DYNAMIC structure and the
1793 zero index points at an actual string. */
1794 if (x == 0 && ! dynamic)
1795 in->symbol.name = "";
1796 else if (x < strsize)
1797 in->symbol.name = str + x;
1798 else
1798{
1799 struct external_nlist *ext_end;
1800
1801 ext_end = ext + count;
1802 for (; ext < ext_end; ext++, in++)
1803 {
1804 bfd_vma x;
1805

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

1811 null string. For the dynamic symbols, the number of bytes in
1812 the string table is stored in the __DYNAMIC structure and the
1813 zero index points at an actual string. */
1814 if (x == 0 && ! dynamic)
1815 in->symbol.name = "";
1816 else if (x < strsize)
1817 in->symbol.name = str + x;
1818 else
1799 return false;
1819 return FALSE;
1800
1801 in->symbol.value = GET_SWORD (abfd, ext->e_value);
1802 in->desc = H_GET_16 (abfd, ext->e_desc);
1803 in->other = H_GET_8 (abfd, ext->e_other);
1804 in->type = H_GET_8 (abfd, ext->e_type);
1805 in->symbol.udata.p = NULL;
1806
1807 if (! translate_from_native_sym_flags (abfd, in))
1820
1821 in->symbol.value = GET_SWORD (abfd, ext->e_value);
1822 in->desc = H_GET_16 (abfd, ext->e_desc);
1823 in->other = H_GET_8 (abfd, ext->e_other);
1824 in->type = H_GET_8 (abfd, ext->e_type);
1825 in->symbol.udata.p = NULL;
1826
1827 if (! translate_from_native_sym_flags (abfd, in))
1808 return false;
1828 return FALSE;
1809
1810 if (dynamic)
1811 in->symbol.flags |= BSF_DYNAMIC;
1812 }
1813
1829
1830 if (dynamic)
1831 in->symbol.flags |= BSF_DYNAMIC;
1832 }
1833
1814 return true;
1834 return TRUE;
1815}
1816
1817/* We read the symbols into a buffer, which is discarded when this
1818 function exits. We read the strings into a buffer large enough to
1819 hold them all plus all the cached symbol entries. */
1820
1835}
1836
1837/* We read the symbols into a buffer, which is discarded when this
1838 function exits. We read the strings into a buffer large enough to
1839 hold them all plus all the cached symbol entries. */
1840
1821boolean
1841bfd_boolean
1822NAME(aout,slurp_symbol_table) (abfd)
1823 bfd *abfd;
1824{
1825 struct external_nlist *old_external_syms;
1826 aout_symbol_type *cached;
1827 bfd_size_type cached_size;
1828
1842NAME(aout,slurp_symbol_table) (abfd)
1843 bfd *abfd;
1844{
1845 struct external_nlist *old_external_syms;
1846 aout_symbol_type *cached;
1847 bfd_size_type cached_size;
1848
1829 /* If there's no work to be done, don't do any */
1849 /* If there's no work to be done, don't do any. */
1830 if (obj_aout_symbols (abfd) != (aout_symbol_type *) NULL)
1850 if (obj_aout_symbols (abfd) != (aout_symbol_type *) NULL)
1831 return true;
1851 return TRUE;
1832
1833 old_external_syms = obj_aout_external_syms (abfd);
1834
1835 if (! aout_get_external_symbols (abfd))
1852
1853 old_external_syms = obj_aout_external_syms (abfd);
1854
1855 if (! aout_get_external_symbols (abfd))
1836 return false;
1856 return FALSE;
1837
1838 cached_size = obj_aout_external_sym_count (abfd);
1839 cached_size *= sizeof (aout_symbol_type);
1840 cached = (aout_symbol_type *) bfd_zmalloc (cached_size);
1841 if (cached == NULL && cached_size != 0)
1857
1858 cached_size = obj_aout_external_sym_count (abfd);
1859 cached_size *= sizeof (aout_symbol_type);
1860 cached = (aout_symbol_type *) bfd_zmalloc (cached_size);
1861 if (cached == NULL && cached_size != 0)
1842 return false;
1862 return FALSE;
1843
1844 /* Convert from external symbol information to internal. */
1845 if (! (NAME(aout,translate_symbol_table)
1846 (abfd, cached,
1847 obj_aout_external_syms (abfd),
1848 obj_aout_external_sym_count (abfd),
1849 obj_aout_external_strings (abfd),
1850 obj_aout_external_string_size (abfd),
1863
1864 /* Convert from external symbol information to internal. */
1865 if (! (NAME(aout,translate_symbol_table)
1866 (abfd, cached,
1867 obj_aout_external_syms (abfd),
1868 obj_aout_external_sym_count (abfd),
1869 obj_aout_external_strings (abfd),
1870 obj_aout_external_string_size (abfd),
1851 false)))
1871 FALSE)))
1852 {
1853 free (cached);
1872 {
1873 free (cached);
1854 return false;
1874 return FALSE;
1855 }
1856
1857 bfd_get_symcount (abfd) = obj_aout_external_sym_count (abfd);
1858
1859 obj_aout_symbols (abfd) = cached;
1860
1861 /* It is very likely that anybody who calls this function will not
1862 want the external symbol information, so if it was allocated

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

1868#ifdef USE_MMAP
1869 bfd_free_window (&obj_aout_sym_window (abfd));
1870#else
1871 free (obj_aout_external_syms (abfd));
1872#endif
1873 obj_aout_external_syms (abfd) = NULL;
1874 }
1875
1875 }
1876
1877 bfd_get_symcount (abfd) = obj_aout_external_sym_count (abfd);
1878
1879 obj_aout_symbols (abfd) = cached;
1880
1881 /* It is very likely that anybody who calls this function will not
1882 want the external symbol information, so if it was allocated

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

1888#ifdef USE_MMAP
1889 bfd_free_window (&obj_aout_sym_window (abfd));
1890#else
1891 free (obj_aout_external_syms (abfd));
1892#endif
1893 obj_aout_external_syms (abfd) = NULL;
1894 }
1895
1876 return true;
1896 return TRUE;
1877}
1878
1879/* We use a hash table when writing out symbols so that we only write
1880 out a particular string once. This helps particularly when the
1881 linker writes out stabs debugging entries, because each different
1882 contributing object file tends to have many duplicate stabs
1883 strings.
1884
1885 This hash table code breaks dbx on SunOS 4.1.3, so we don't do it
1886 if BFD_TRADITIONAL_FORMAT is set. */
1887
1888static bfd_size_type add_to_stringtab
1897}
1898
1899/* We use a hash table when writing out symbols so that we only write
1900 out a particular string once. This helps particularly when the
1901 linker writes out stabs debugging entries, because each different
1902 contributing object file tends to have many duplicate stabs
1903 strings.
1904
1905 This hash table code breaks dbx on SunOS 4.1.3, so we don't do it
1906 if BFD_TRADITIONAL_FORMAT is set. */
1907
1908static bfd_size_type add_to_stringtab
1889 PARAMS ((bfd *, struct bfd_strtab_hash *, const char *, boolean));
1890static boolean emit_stringtab PARAMS ((bfd *, struct bfd_strtab_hash *));
1909 PARAMS ((bfd *, struct bfd_strtab_hash *, const char *, bfd_boolean));
1910static bfd_boolean emit_stringtab
1911 PARAMS ((bfd *, struct bfd_strtab_hash *));
1891
1892/* Get the index of a string in a strtab, adding it if it is not
1893 already present. */
1894
1895static INLINE bfd_size_type
1896add_to_stringtab (abfd, tab, str, copy)
1897 bfd *abfd;
1898 struct bfd_strtab_hash *tab;
1899 const char *str;
1912
1913/* Get the index of a string in a strtab, adding it if it is not
1914 already present. */
1915
1916static INLINE bfd_size_type
1917add_to_stringtab (abfd, tab, str, copy)
1918 bfd *abfd;
1919 struct bfd_strtab_hash *tab;
1920 const char *str;
1900 boolean copy;
1921 bfd_boolean copy;
1901{
1922{
1902 boolean hash;
1923 bfd_boolean hash;
1903 bfd_size_type index;
1904
1905 /* An index of 0 always means the empty string. */
1906 if (str == 0 || *str == '\0')
1907 return 0;
1908
1909 /* Don't hash if BFD_TRADITIONAL_FORMAT is set, because SunOS dbx
1910 doesn't understand a hashed string table. */
1924 bfd_size_type index;
1925
1926 /* An index of 0 always means the empty string. */
1927 if (str == 0 || *str == '\0')
1928 return 0;
1929
1930 /* Don't hash if BFD_TRADITIONAL_FORMAT is set, because SunOS dbx
1931 doesn't understand a hashed string table. */
1911 hash = true;
1932 hash = TRUE;
1912 if ((abfd->flags & BFD_TRADITIONAL_FORMAT) != 0)
1933 if ((abfd->flags & BFD_TRADITIONAL_FORMAT) != 0)
1913 hash = false;
1934 hash = FALSE;
1914
1915 index = _bfd_stringtab_add (tab, str, hash, copy);
1916
1917 if (index != (bfd_size_type) -1)
1918 {
1919 /* Add BYTES_IN_WORD to the return value to account for the
1920 space taken up by the string table size. */
1921 index += BYTES_IN_WORD;
1922 }
1923
1924 return index;
1925}
1926
1927/* Write out a strtab. ABFD is already at the right location in the
1928 file. */
1929
1935
1936 index = _bfd_stringtab_add (tab, str, hash, copy);
1937
1938 if (index != (bfd_size_type) -1)
1939 {
1940 /* Add BYTES_IN_WORD to the return value to account for the
1941 space taken up by the string table size. */
1942 index += BYTES_IN_WORD;
1943 }
1944
1945 return index;
1946}
1947
1948/* Write out a strtab. ABFD is already at the right location in the
1949 file. */
1950
1930static boolean
1951static bfd_boolean
1931emit_stringtab (abfd, tab)
1932 register bfd *abfd;
1933 struct bfd_strtab_hash *tab;
1934{
1935 bfd_byte buffer[BYTES_IN_WORD];
1936 bfd_size_type amt = BYTES_IN_WORD;
1937
1938 /* The string table starts with the size. */
1939 PUT_WORD (abfd, _bfd_stringtab_size (tab) + BYTES_IN_WORD, buffer);
1940 if (bfd_bwrite ((PTR) buffer, amt, abfd) != amt)
1952emit_stringtab (abfd, tab)
1953 register bfd *abfd;
1954 struct bfd_strtab_hash *tab;
1955{
1956 bfd_byte buffer[BYTES_IN_WORD];
1957 bfd_size_type amt = BYTES_IN_WORD;
1958
1959 /* The string table starts with the size. */
1960 PUT_WORD (abfd, _bfd_stringtab_size (tab) + BYTES_IN_WORD, buffer);
1961 if (bfd_bwrite ((PTR) buffer, amt, abfd) != amt)
1941 return false;
1962 return FALSE;
1942
1943 return _bfd_stringtab_emit (abfd, tab);
1944}
1945
1963
1964 return _bfd_stringtab_emit (abfd, tab);
1965}
1966
1946boolean
1967bfd_boolean
1947NAME(aout,write_syms) (abfd)
1948 bfd *abfd;
1949{
1950 unsigned int count ;
1951 asymbol **generic = bfd_get_outsymbols (abfd);
1952 struct bfd_strtab_hash *strtab;
1953
1954 strtab = _bfd_stringtab_init ();
1955 if (strtab == NULL)
1968NAME(aout,write_syms) (abfd)
1969 bfd *abfd;
1970{
1971 unsigned int count ;
1972 asymbol **generic = bfd_get_outsymbols (abfd);
1973 struct bfd_strtab_hash *strtab;
1974
1975 strtab = _bfd_stringtab_init ();
1976 if (strtab == NULL)
1956 return false;
1977 return FALSE;
1957
1958 for (count = 0; count < bfd_get_symcount (abfd); count++)
1959 {
1960 asymbol *g = generic[count];
1961 bfd_size_type indx;
1962 struct external_nlist nsp;
1963 bfd_size_type amt;
1964
1978
1979 for (count = 0; count < bfd_get_symcount (abfd); count++)
1980 {
1981 asymbol *g = generic[count];
1982 bfd_size_type indx;
1983 struct external_nlist nsp;
1984 bfd_size_type amt;
1985
1965 indx = add_to_stringtab (abfd, strtab, g->name, false);
1986 indx = add_to_stringtab (abfd, strtab, g->name, FALSE);
1966 if (indx == (bfd_size_type) -1)
1967 goto error_return;
1968 PUT_WORD (abfd, indx, (bfd_byte *) nsp.e_strx);
1969
1970 if (bfd_asymbol_flavour (g) == abfd->xvec->flavour)
1971 {
1972 H_PUT_16 (abfd, aout_symbol (g)->desc, nsp.e_desc);
1973 H_PUT_8 (abfd, aout_symbol (g)->other, nsp.e_other);

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

1992 g->KEEPIT = count;
1993 }
1994
1995 if (! emit_stringtab (abfd, strtab))
1996 goto error_return;
1997
1998 _bfd_stringtab_free (strtab);
1999
1987 if (indx == (bfd_size_type) -1)
1988 goto error_return;
1989 PUT_WORD (abfd, indx, (bfd_byte *) nsp.e_strx);
1990
1991 if (bfd_asymbol_flavour (g) == abfd->xvec->flavour)
1992 {
1993 H_PUT_16 (abfd, aout_symbol (g)->desc, nsp.e_desc);
1994 H_PUT_8 (abfd, aout_symbol (g)->other, nsp.e_other);

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

2013 g->KEEPIT = count;
2014 }
2015
2016 if (! emit_stringtab (abfd, strtab))
2017 goto error_return;
2018
2019 _bfd_stringtab_free (strtab);
2020
2000 return true;
2021 return TRUE;
2001
2002error_return:
2003 _bfd_stringtab_free (strtab);
2022
2023error_return:
2024 _bfd_stringtab_free (strtab);
2004 return false;
2025 return FALSE;
2005}
2006
2007long
2026}
2027
2028long
2008NAME(aout,get_symtab) (abfd, location)
2029NAME(aout,canonicalize_symtab) (abfd, location)
2009 bfd *abfd;
2010 asymbol **location;
2011{
2012 unsigned int counter = 0;
2013 aout_symbol_type *symbase;
2014
2015 if (!NAME(aout,slurp_symbol_table) (abfd))
2016 return -1;
2017
2018 for (symbase = obj_aout_symbols (abfd);
2019 counter++ < bfd_get_symcount (abfd);
2020 )
2021 *(location++) = (asymbol *) (symbase++);
2022 *location++ =0;
2023 return bfd_get_symcount (abfd);
2024}
2025
2030 bfd *abfd;
2031 asymbol **location;
2032{
2033 unsigned int counter = 0;
2034 aout_symbol_type *symbase;
2035
2036 if (!NAME(aout,slurp_symbol_table) (abfd))
2037 return -1;
2038
2039 for (symbase = obj_aout_symbols (abfd);
2040 counter++ < bfd_get_symcount (abfd);
2041 )
2042 *(location++) = (asymbol *) (symbase++);
2043 *location++ =0;
2044 return bfd_get_symcount (abfd);
2045}
2046
2026/* Standard reloc stuff */
2047/* Standard reloc stuff. */
2027/* Output standard relocation information to a file in target byte order. */
2028
2029extern void NAME(aout,swap_std_reloc_out)
2030 PARAMS ((bfd *, arelent *, struct reloc_std_external *));
2031
2032void
2033NAME(aout,swap_std_reloc_out) (abfd, g, natptr)
2034 bfd *abfd;

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

2040 int r_extern;
2041 unsigned int r_length;
2042 int r_pcrel;
2043 int r_baserel, r_jmptable, r_relative;
2044 asection *output_section = sym->section->output_section;
2045
2046 PUT_WORD (abfd, g->address, natptr->r_address);
2047
2048/* Output standard relocation information to a file in target byte order. */
2049
2050extern void NAME(aout,swap_std_reloc_out)
2051 PARAMS ((bfd *, arelent *, struct reloc_std_external *));
2052
2053void
2054NAME(aout,swap_std_reloc_out) (abfd, g, natptr)
2055 bfd *abfd;

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

2061 int r_extern;
2062 unsigned int r_length;
2063 int r_pcrel;
2064 int r_baserel, r_jmptable, r_relative;
2065 asection *output_section = sym->section->output_section;
2066
2067 PUT_WORD (abfd, g->address, natptr->r_address);
2068
2048 r_length = g->howto->size ; /* Size as a power of two */
2049 r_pcrel = (int) g->howto->pc_relative; /* Relative to PC? */
2069 r_length = g->howto->size ; /* Size as a power of two. */
2070 r_pcrel = (int) g->howto->pc_relative; /* Relative to PC? */
2050 /* XXX This relies on relocs coming from a.out files. */
2051 r_baserel = (g->howto->type & 8) != 0;
2052 r_jmptable = (g->howto->type & 16) != 0;
2053 r_relative = (g->howto->type & 32) != 0;
2054
2055#if 0
2056 /* For a standard reloc, the addend is in the object file. */
2057 r_addend = g->addend + (*(g->sym_ptr_ptr))->section->output_section->vma;
2058#endif
2059
2071 /* XXX This relies on relocs coming from a.out files. */
2072 r_baserel = (g->howto->type & 8) != 0;
2073 r_jmptable = (g->howto->type & 16) != 0;
2074 r_relative = (g->howto->type & 32) != 0;
2075
2076#if 0
2077 /* For a standard reloc, the addend is in the object file. */
2078 r_addend = g->addend + (*(g->sym_ptr_ptr))->section->output_section->vma;
2079#endif
2080
2060 /* name was clobbered by aout_write_syms to be symbol index */
2081 /* Name was clobbered by aout_write_syms to be symbol index. */
2061
2062 /* If this relocation is relative to a symbol then set the
2063 r_index to the symbols index, and the r_extern bit.
2064
2065 Absolute symbols can come in in two ways, either as an offset
2066 from the abs section, or as a symbol which has an abs value.
2082
2083 /* If this relocation is relative to a symbol then set the
2084 r_index to the symbols index, and the r_extern bit.
2085
2086 Absolute symbols can come in in two ways, either as an offset
2087 from the abs section, or as a symbol which has an abs value.
2067 check for that here
2068 */
2088 check for that here. */
2069
2070 if (bfd_is_com_section (output_section)
2071 || bfd_is_abs_section (output_section)
2072 || bfd_is_und_section (output_section))
2073 {
2074 if (bfd_abs_section_ptr->symbol == sym)
2089
2090 if (bfd_is_com_section (output_section)
2091 || bfd_is_abs_section (output_section)
2092 || bfd_is_und_section (output_section))
2093 {
2094 if (bfd_abs_section_ptr->symbol == sym)
2075 {
2076 /* Whoops, looked like an abs symbol, but is really an offset
2077 from the abs section */
2078 r_index = N_ABS;
2079 r_extern = 0;
2080 }
2095 {
2096 /* Whoops, looked like an abs symbol, but is
2097 really an offset from the abs section. */
2098 r_index = N_ABS;
2099 r_extern = 0;
2100 }
2081 else
2101 else
2082 {
2083 /* Fill in symbol */
2084 r_extern = 1;
2085 r_index = (*(g->sym_ptr_ptr))->KEEPIT;
2086
2087 }
2102 {
2103 /* Fill in symbol. */
2104 r_extern = 1;
2105 r_index = (*(g->sym_ptr_ptr))->KEEPIT;
2106 }
2088 }
2089 else
2090 {
2107 }
2108 else
2109 {
2091 /* Just an ordinary section */
2110 /* Just an ordinary section. */
2092 r_extern = 0;
2093 r_index = output_section->target_index;
2094 }
2095
2111 r_extern = 0;
2112 r_index = output_section->target_index;
2113 }
2114
2096 /* now the fun stuff */
2115 /* Now the fun stuff. */
2097 if (bfd_header_big_endian (abfd))
2098 {
2099 natptr->r_index[0] = r_index >> 16;
2100 natptr->r_index[1] = r_index >> 8;
2101 natptr->r_index[2] = r_index;
2102 natptr->r_type[0] = ((r_extern ? RELOC_STD_BITS_EXTERN_BIG : 0)
2103 | (r_pcrel ? RELOC_STD_BITS_PCREL_BIG : 0)
2104 | (r_baserel ? RELOC_STD_BITS_BASEREL_BIG : 0)

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

2115 | (r_pcrel ? RELOC_STD_BITS_PCREL_LITTLE : 0)
2116 | (r_baserel ? RELOC_STD_BITS_BASEREL_LITTLE : 0)
2117 | (r_jmptable ? RELOC_STD_BITS_JMPTABLE_LITTLE : 0)
2118 | (r_relative ? RELOC_STD_BITS_RELATIVE_LITTLE : 0)
2119 | (r_length << RELOC_STD_BITS_LENGTH_SH_LITTLE));
2120 }
2121}
2122
2116 if (bfd_header_big_endian (abfd))
2117 {
2118 natptr->r_index[0] = r_index >> 16;
2119 natptr->r_index[1] = r_index >> 8;
2120 natptr->r_index[2] = r_index;
2121 natptr->r_type[0] = ((r_extern ? RELOC_STD_BITS_EXTERN_BIG : 0)
2122 | (r_pcrel ? RELOC_STD_BITS_PCREL_BIG : 0)
2123 | (r_baserel ? RELOC_STD_BITS_BASEREL_BIG : 0)

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

2134 | (r_pcrel ? RELOC_STD_BITS_PCREL_LITTLE : 0)
2135 | (r_baserel ? RELOC_STD_BITS_BASEREL_LITTLE : 0)
2136 | (r_jmptable ? RELOC_STD_BITS_JMPTABLE_LITTLE : 0)
2137 | (r_relative ? RELOC_STD_BITS_RELATIVE_LITTLE : 0)
2138 | (r_length << RELOC_STD_BITS_LENGTH_SH_LITTLE));
2139 }
2140}
2141
2123/* Extended stuff */
2142/* Extended stuff. */
2124/* Output extended relocation information to a file in target byte order. */
2125
2126extern void NAME(aout,swap_ext_reloc_out)
2127 PARAMS ((bfd *, arelent *, struct reloc_ext_external *));
2128
2129void
2130NAME(aout,swap_ext_reloc_out) (abfd, g, natptr)
2131 bfd *abfd;

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

2148 r_addend += (*(g->sym_ptr_ptr))->section->output_section->vma;
2149
2150 /* If this relocation is relative to a symbol then set the
2151 r_index to the symbols index, and the r_extern bit.
2152
2153 Absolute symbols can come in in two ways, either as an offset
2154 from the abs section, or as a symbol which has an abs value.
2155 check for that here. */
2143/* Output extended relocation information to a file in target byte order. */
2144
2145extern void NAME(aout,swap_ext_reloc_out)
2146 PARAMS ((bfd *, arelent *, struct reloc_ext_external *));
2147
2148void
2149NAME(aout,swap_ext_reloc_out) (abfd, g, natptr)
2150 bfd *abfd;

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

2167 r_addend += (*(g->sym_ptr_ptr))->section->output_section->vma;
2168
2169 /* If this relocation is relative to a symbol then set the
2170 r_index to the symbols index, and the r_extern bit.
2171
2172 Absolute symbols can come in in two ways, either as an offset
2173 from the abs section, or as a symbol which has an abs value.
2174 check for that here. */
2156
2157 if (bfd_is_abs_section (bfd_get_section (sym)))
2158 {
2159 r_extern = 0;
2160 r_index = N_ABS;
2161 }
2162 else if ((sym->flags & BSF_SECTION_SYM) == 0)
2163 {
2164 if (bfd_is_und_section (bfd_get_section (sym))
2165 || (sym->flags & BSF_GLOBAL) != 0)
2166 r_extern = 1;
2167 else
2168 r_extern = 0;
2169 r_index = (*(g->sym_ptr_ptr))->KEEPIT;
2170 }
2171 else
2172 {
2175 if (bfd_is_abs_section (bfd_get_section (sym)))
2176 {
2177 r_extern = 0;
2178 r_index = N_ABS;
2179 }
2180 else if ((sym->flags & BSF_SECTION_SYM) == 0)
2181 {
2182 if (bfd_is_und_section (bfd_get_section (sym))
2183 || (sym->flags & BSF_GLOBAL) != 0)
2184 r_extern = 1;
2185 else
2186 r_extern = 0;
2187 r_index = (*(g->sym_ptr_ptr))->KEEPIT;
2188 }
2189 else
2190 {
2173 /* Just an ordinary section */
2191 /* Just an ordinary section. */
2174 r_extern = 0;
2175 r_index = output_section->target_index;
2176 }
2177
2192 r_extern = 0;
2193 r_index = output_section->target_index;
2194 }
2195
2178 /* now the fun stuff */
2196 /* Now the fun stuff. */
2179 if (bfd_header_big_endian (abfd))
2180 {
2181 natptr->r_index[0] = r_index >> 16;
2182 natptr->r_index[1] = r_index >> 8;
2183 natptr->r_index[2] = r_index;
2184 natptr->r_type[0] = ((r_extern ? RELOC_EXT_BITS_EXTERN_BIG : 0)
2185 | (r_type << RELOC_EXT_BITS_TYPE_SH_BIG));
2186 }

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

2251{
2252 unsigned int r_index;
2253 int r_extern;
2254 unsigned int r_type;
2255 struct aoutdata *su = &(abfd->tdata.aout_data->a);
2256
2257 cache_ptr->address = (GET_SWORD (abfd, bytes->r_address));
2258
2197 if (bfd_header_big_endian (abfd))
2198 {
2199 natptr->r_index[0] = r_index >> 16;
2200 natptr->r_index[1] = r_index >> 8;
2201 natptr->r_index[2] = r_index;
2202 natptr->r_type[0] = ((r_extern ? RELOC_EXT_BITS_EXTERN_BIG : 0)
2203 | (r_type << RELOC_EXT_BITS_TYPE_SH_BIG));
2204 }

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

2269{
2270 unsigned int r_index;
2271 int r_extern;
2272 unsigned int r_type;
2273 struct aoutdata *su = &(abfd->tdata.aout_data->a);
2274
2275 cache_ptr->address = (GET_SWORD (abfd, bytes->r_address));
2276
2259 /* now the fun stuff */
2277 /* Now the fun stuff. */
2260 if (bfd_header_big_endian (abfd))
2261 {
2262 r_index = (((unsigned int) bytes->r_index[0] << 16)
2263 | ((unsigned int) bytes->r_index[1] << 8)
2264 | bytes->r_index[2]);
2265 r_extern = (0 != (bytes->r_type[0] & RELOC_EXT_BITS_EXTERN_BIG));
2266 r_type = ((bytes->r_type[0] & RELOC_EXT_BITS_TYPE_BIG)
2267 >> RELOC_EXT_BITS_TYPE_SH_BIG);

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

2310 unsigned int r_length;
2311 int r_pcrel;
2312 int r_baserel, r_jmptable, r_relative;
2313 struct aoutdata *su = &(abfd->tdata.aout_data->a);
2314 unsigned int howto_idx;
2315
2316 cache_ptr->address = H_GET_32 (abfd, bytes->r_address);
2317
2278 if (bfd_header_big_endian (abfd))
2279 {
2280 r_index = (((unsigned int) bytes->r_index[0] << 16)
2281 | ((unsigned int) bytes->r_index[1] << 8)
2282 | bytes->r_index[2]);
2283 r_extern = (0 != (bytes->r_type[0] & RELOC_EXT_BITS_EXTERN_BIG));
2284 r_type = ((bytes->r_type[0] & RELOC_EXT_BITS_TYPE_BIG)
2285 >> RELOC_EXT_BITS_TYPE_SH_BIG);

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

2328 unsigned int r_length;
2329 int r_pcrel;
2330 int r_baserel, r_jmptable, r_relative;
2331 struct aoutdata *su = &(abfd->tdata.aout_data->a);
2332 unsigned int howto_idx;
2333
2334 cache_ptr->address = H_GET_32 (abfd, bytes->r_address);
2335
2318 /* now the fun stuff */
2336 /* Now the fun stuff. */
2319 if (bfd_header_big_endian (abfd))
2320 {
2321 r_index = (((unsigned int) bytes->r_index[0] << 16)
2322 | ((unsigned int) bytes->r_index[1] << 8)
2323 | bytes->r_index[2]);
2324 r_extern = (0 != (bytes->r_type[0] & RELOC_STD_BITS_EXTERN_BIG));
2325 r_pcrel = (0 != (bytes->r_type[0] & RELOC_STD_BITS_PCREL_BIG));
2326 r_baserel = (0 != (bytes->r_type[0] & RELOC_STD_BITS_BASEREL_BIG));

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

2363 r_index = N_ABS;
2364 }
2365
2366 MOVE_ADDRESS (0);
2367}
2368
2369/* Read and swap the relocs for a section. */
2370
2337 if (bfd_header_big_endian (abfd))
2338 {
2339 r_index = (((unsigned int) bytes->r_index[0] << 16)
2340 | ((unsigned int) bytes->r_index[1] << 8)
2341 | bytes->r_index[2]);
2342 r_extern = (0 != (bytes->r_type[0] & RELOC_STD_BITS_EXTERN_BIG));
2343 r_pcrel = (0 != (bytes->r_type[0] & RELOC_STD_BITS_PCREL_BIG));
2344 r_baserel = (0 != (bytes->r_type[0] & RELOC_STD_BITS_BASEREL_BIG));

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

2381 r_index = N_ABS;
2382 }
2383
2384 MOVE_ADDRESS (0);
2385}
2386
2387/* Read and swap the relocs for a section. */
2388
2371boolean
2389bfd_boolean
2372NAME(aout,slurp_reloc_table) (abfd, asect, symbols)
2373 bfd *abfd;
2374 sec_ptr asect;
2375 asymbol **symbols;
2376{
2377 bfd_size_type count;
2378 bfd_size_type reloc_size;
2379 PTR relocs;
2380 arelent *reloc_cache;
2381 size_t each_size;
2382 unsigned int counter = 0;
2383 arelent *cache_ptr;
2384 bfd_size_type amt;
2385
2386 if (asect->relocation)
2390NAME(aout,slurp_reloc_table) (abfd, asect, symbols)
2391 bfd *abfd;
2392 sec_ptr asect;
2393 asymbol **symbols;
2394{
2395 bfd_size_type count;
2396 bfd_size_type reloc_size;
2397 PTR relocs;
2398 arelent *reloc_cache;
2399 size_t each_size;
2400 unsigned int counter = 0;
2401 arelent *cache_ptr;
2402 bfd_size_type amt;
2403
2404 if (asect->relocation)
2387 return true;
2405 return TRUE;
2388
2389 if (asect->flags & SEC_CONSTRUCTOR)
2406
2407 if (asect->flags & SEC_CONSTRUCTOR)
2390 return true;
2408 return TRUE;
2391
2392 if (asect == obj_datasec (abfd))
2393 reloc_size = exec_hdr (abfd)->a_drsize;
2394 else if (asect == obj_textsec (abfd))
2395 reloc_size = exec_hdr (abfd)->a_trsize;
2396 else if (asect == obj_bsssec (abfd))
2397 reloc_size = 0;
2398 else
2399 {
2400 bfd_set_error (bfd_error_invalid_operation);
2409
2410 if (asect == obj_datasec (abfd))
2411 reloc_size = exec_hdr (abfd)->a_drsize;
2412 else if (asect == obj_textsec (abfd))
2413 reloc_size = exec_hdr (abfd)->a_trsize;
2414 else if (asect == obj_bsssec (abfd))
2415 reloc_size = 0;
2416 else
2417 {
2418 bfd_set_error (bfd_error_invalid_operation);
2401 return false;
2419 return FALSE;
2402 }
2403
2404 if (bfd_seek (abfd, asect->rel_filepos, SEEK_SET) != 0)
2420 }
2421
2422 if (bfd_seek (abfd, asect->rel_filepos, SEEK_SET) != 0)
2405 return false;
2423 return FALSE;
2406
2407 each_size = obj_reloc_entry_size (abfd);
2408
2409 count = reloc_size / each_size;
2410
2411 amt = count * sizeof (arelent);
2412 reloc_cache = (arelent *) bfd_zmalloc (amt);
2413 if (reloc_cache == NULL && count != 0)
2424
2425 each_size = obj_reloc_entry_size (abfd);
2426
2427 count = reloc_size / each_size;
2428
2429 amt = count * sizeof (arelent);
2430 reloc_cache = (arelent *) bfd_zmalloc (amt);
2431 if (reloc_cache == NULL && count != 0)
2414 return false;
2432 return FALSE;
2415
2416 relocs = bfd_malloc (reloc_size);
2417 if (relocs == NULL && reloc_size != 0)
2418 {
2419 free (reloc_cache);
2433
2434 relocs = bfd_malloc (reloc_size);
2435 if (relocs == NULL && reloc_size != 0)
2436 {
2437 free (reloc_cache);
2420 return false;
2438 return FALSE;
2421 }
2422
2423 if (bfd_bread (relocs, reloc_size, abfd) != reloc_size)
2424 {
2425 free (relocs);
2426 free (reloc_cache);
2439 }
2440
2441 if (bfd_bread (relocs, reloc_size, abfd) != reloc_size)
2442 {
2443 free (relocs);
2444 free (reloc_cache);
2427 return false;
2445 return FALSE;
2428 }
2429
2430 cache_ptr = reloc_cache;
2431 if (each_size == RELOC_EXT_SIZE)
2432 {
2433 struct reloc_ext_external *rptr = (struct reloc_ext_external *) relocs;
2434
2435 for (; counter < count; counter++, rptr++, cache_ptr++)

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

2445 (bfd_size_type) bfd_get_symcount (abfd));
2446 }
2447
2448 free (relocs);
2449
2450 asect->relocation = reloc_cache;
2451 asect->reloc_count = cache_ptr - reloc_cache;
2452
2446 }
2447
2448 cache_ptr = reloc_cache;
2449 if (each_size == RELOC_EXT_SIZE)
2450 {
2451 struct reloc_ext_external *rptr = (struct reloc_ext_external *) relocs;
2452
2453 for (; counter < count; counter++, rptr++, cache_ptr++)

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

2463 (bfd_size_type) bfd_get_symcount (abfd));
2464 }
2465
2466 free (relocs);
2467
2468 asect->relocation = reloc_cache;
2469 asect->reloc_count = cache_ptr - reloc_cache;
2470
2453 return true;
2471 return TRUE;
2454}
2455
2456/* Write out a relocation section into an object file. */
2457
2472}
2473
2474/* Write out a relocation section into an object file. */
2475
2458boolean
2476bfd_boolean
2459NAME(aout,squirt_out_relocs) (abfd, section)
2460 bfd *abfd;
2461 asection *section;
2462{
2463 arelent **generic;
2464 unsigned char *native, *natptr;
2465 size_t each_size;
2466
2467 unsigned int count = section->reloc_count;
2468 bfd_size_type natsize;
2469
2470 if (count == 0 || section->orelocation == NULL)
2477NAME(aout,squirt_out_relocs) (abfd, section)
2478 bfd *abfd;
2479 asection *section;
2480{
2481 arelent **generic;
2482 unsigned char *native, *natptr;
2483 size_t each_size;
2484
2485 unsigned int count = section->reloc_count;
2486 bfd_size_type natsize;
2487
2488 if (count == 0 || section->orelocation == NULL)
2471 return true;
2489 return TRUE;
2472
2473 each_size = obj_reloc_entry_size (abfd);
2474 natsize = (bfd_size_type) each_size * count;
2475 native = (unsigned char *) bfd_zalloc (abfd, natsize);
2476 if (!native)
2490
2491 each_size = obj_reloc_entry_size (abfd);
2492 natsize = (bfd_size_type) each_size * count;
2493 native = (unsigned char *) bfd_zalloc (abfd, natsize);
2494 if (!native)
2477 return false;
2495 return FALSE;
2478
2479 generic = section->orelocation;
2480
2481 if (each_size == RELOC_EXT_SIZE)
2482 {
2483 for (natptr = native;
2484 count != 0;
2485 --count, natptr += each_size, ++generic)

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

2493 --count, natptr += each_size, ++generic)
2494 MY_swap_std_reloc_out (abfd, *generic,
2495 (struct reloc_std_external *) natptr);
2496 }
2497
2498 if (bfd_bwrite ((PTR) native, natsize, abfd) != natsize)
2499 {
2500 bfd_release (abfd, native);
2496
2497 generic = section->orelocation;
2498
2499 if (each_size == RELOC_EXT_SIZE)
2500 {
2501 for (natptr = native;
2502 count != 0;
2503 --count, natptr += each_size, ++generic)

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

2511 --count, natptr += each_size, ++generic)
2512 MY_swap_std_reloc_out (abfd, *generic,
2513 (struct reloc_std_external *) natptr);
2514 }
2515
2516 if (bfd_bwrite ((PTR) native, natsize, abfd) != natsize)
2517 {
2518 bfd_release (abfd, native);
2501 return false;
2519 return FALSE;
2502 }
2503 bfd_release (abfd, native);
2504
2520 }
2521 bfd_release (abfd, native);
2522
2505 return true;
2523 return TRUE;
2506}
2507
2524}
2525
2508/* This is stupid. This function should be a boolean predicate */
2526/* This is stupid. This function should be a boolean predicate. */
2527
2509long
2510NAME(aout,canonicalize_reloc) (abfd, section, relptr, symbols)
2511 bfd *abfd;
2512 sec_ptr section;
2513 arelent **relptr;
2514 asymbol **symbols;
2515{
2516 arelent *tblptr = section->relocation;

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

2553 bfd *abfd;
2554 sec_ptr asect;
2555{
2556 if (bfd_get_format (abfd) != bfd_object)
2557 {
2558 bfd_set_error (bfd_error_invalid_operation);
2559 return -1;
2560 }
2528long
2529NAME(aout,canonicalize_reloc) (abfd, section, relptr, symbols)
2530 bfd *abfd;
2531 sec_ptr section;
2532 arelent **relptr;
2533 asymbol **symbols;
2534{
2535 arelent *tblptr = section->relocation;

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

2572 bfd *abfd;
2573 sec_ptr asect;
2574{
2575 if (bfd_get_format (abfd) != bfd_object)
2576 {
2577 bfd_set_error (bfd_error_invalid_operation);
2578 return -1;
2579 }
2580
2561 if (asect->flags & SEC_CONSTRUCTOR)
2581 if (asect->flags & SEC_CONSTRUCTOR)
2562 {
2563 return (sizeof (arelent *) * (asect->reloc_count+1));
2564 }
2582 return (sizeof (arelent *) * (asect->reloc_count+1));
2565
2566 if (asect == obj_datasec (abfd))
2567 return (sizeof (arelent *)
2568 * ((exec_hdr (abfd)->a_drsize / obj_reloc_entry_size (abfd))
2569 + 1));
2570
2571 if (asect == obj_textsec (abfd))
2572 return (sizeof (arelent *)

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

2674
2675/* Read minisymbols. For minisymbols, we use the unmodified a.out
2676 symbols. The minisymbol_to_symbol function translates these into
2677 BFD asymbol structures. */
2678
2679long
2680NAME(aout,read_minisymbols) (abfd, dynamic, minisymsp, sizep)
2681 bfd *abfd;
2583
2584 if (asect == obj_datasec (abfd))
2585 return (sizeof (arelent *)
2586 * ((exec_hdr (abfd)->a_drsize / obj_reloc_entry_size (abfd))
2587 + 1));
2588
2589 if (asect == obj_textsec (abfd))
2590 return (sizeof (arelent *)

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

2692
2693/* Read minisymbols. For minisymbols, we use the unmodified a.out
2694 symbols. The minisymbol_to_symbol function translates these into
2695 BFD asymbol structures. */
2696
2697long
2698NAME(aout,read_minisymbols) (abfd, dynamic, minisymsp, sizep)
2699 bfd *abfd;
2682 boolean dynamic;
2700 bfd_boolean dynamic;
2683 PTR *minisymsp;
2684 unsigned int *sizep;
2685{
2686 if (dynamic)
2687 {
2688 /* We could handle the dynamic symbols here as well, but it's
2689 easier to hand them off. */
2690 return _bfd_generic_read_minisymbols (abfd, dynamic, minisymsp, sizep);

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

2710
2711/* Convert a minisymbol to a BFD asymbol. A minisymbol is just an
2712 unmodified a.out symbol. The SYM argument is a structure returned
2713 by bfd_make_empty_symbol, which we fill in here. */
2714
2715asymbol *
2716NAME(aout,minisymbol_to_symbol) (abfd, dynamic, minisym, sym)
2717 bfd *abfd;
2701 PTR *minisymsp;
2702 unsigned int *sizep;
2703{
2704 if (dynamic)
2705 {
2706 /* We could handle the dynamic symbols here as well, but it's
2707 easier to hand them off. */
2708 return _bfd_generic_read_minisymbols (abfd, dynamic, minisymsp, sizep);

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

2728
2729/* Convert a minisymbol to a BFD asymbol. A minisymbol is just an
2730 unmodified a.out symbol. The SYM argument is a structure returned
2731 by bfd_make_empty_symbol, which we fill in here. */
2732
2733asymbol *
2734NAME(aout,minisymbol_to_symbol) (abfd, dynamic, minisym, sym)
2735 bfd *abfd;
2718 boolean dynamic;
2736 bfd_boolean dynamic;
2719 const PTR minisym;
2720 asymbol *sym;
2721{
2722 if (dynamic
2723 || obj_aout_external_sym_count (abfd) < MINISYM_THRESHOLD)
2724 return _bfd_generic_minisymbol_to_symbol (abfd, dynamic, minisym, sym);
2725
2726 memset (sym, 0, sizeof (aout_symbol_type));
2727
2728 /* We call translate_symbol_table to translate a single symbol. */
2729 if (! (NAME(aout,translate_symbol_table)
2730 (abfd,
2731 (aout_symbol_type *) sym,
2732 (struct external_nlist *) minisym,
2733 (bfd_size_type) 1,
2734 obj_aout_external_strings (abfd),
2735 obj_aout_external_string_size (abfd),
2737 const PTR minisym;
2738 asymbol *sym;
2739{
2740 if (dynamic
2741 || obj_aout_external_sym_count (abfd) < MINISYM_THRESHOLD)
2742 return _bfd_generic_minisymbol_to_symbol (abfd, dynamic, minisym, sym);
2743
2744 memset (sym, 0, sizeof (aout_symbol_type));
2745
2746 /* We call translate_symbol_table to translate a single symbol. */
2747 if (! (NAME(aout,translate_symbol_table)
2748 (abfd,
2749 (aout_symbol_type *) sym,
2750 (struct external_nlist *) minisym,
2751 (bfd_size_type) 1,
2752 obj_aout_external_strings (abfd),
2753 obj_aout_external_string_size (abfd),
2736 false)))
2754 FALSE)))
2737 return NULL;
2738
2739 return sym;
2740}
2741
2755 return NULL;
2756
2757 return sym;
2758}
2759
2742/*
2743 provided a BFD, a section and an offset into the section, calculate
2744 and return the name of the source file and the line nearest to the
2745 wanted location.
2746*/
2760/* Provided a BFD, a section and an offset into the section, calculate
2761 and return the name of the source file and the line nearest to the
2762 wanted location. */
2747
2763
2748boolean
2764bfd_boolean
2749NAME(aout,find_nearest_line)
2750 (abfd, section, symbols, offset, filename_ptr, functionname_ptr, line_ptr)
2751 bfd *abfd;
2752 asection *section;
2753 asymbol **symbols;
2754 bfd_vma offset;
2755 const char **filename_ptr;
2756 const char **functionname_ptr;
2757 unsigned int *line_ptr;
2758{
2765NAME(aout,find_nearest_line)
2766 (abfd, section, symbols, offset, filename_ptr, functionname_ptr, line_ptr)
2767 bfd *abfd;
2768 asection *section;
2769 asymbol **symbols;
2770 bfd_vma offset;
2771 const char **filename_ptr;
2772 const char **functionname_ptr;
2773 unsigned int *line_ptr;
2774{
2759 /* Run down the file looking for the filename, function and linenumber */
2775 /* Run down the file looking for the filename, function and linenumber. */
2760 asymbol **p;
2761 const char *directory_name = NULL;
2762 const char *main_file_name = NULL;
2763 const char *current_file_name = NULL;
2764 const char *line_file_name = NULL; /* Value of current_file_name at line number. */
2765 const char *line_directory_name = NULL; /* Value of directory_name at line number. */
2766 bfd_vma low_line_vma = 0;
2767 bfd_vma low_func_vma = 0;
2768 asymbol *func = 0;
2769 bfd_size_type filelen, funclen;
2770 char *buf;
2771
2772 *filename_ptr = abfd->filename;
2773 *functionname_ptr = 0;
2774 *line_ptr = 0;
2776 asymbol **p;
2777 const char *directory_name = NULL;
2778 const char *main_file_name = NULL;
2779 const char *current_file_name = NULL;
2780 const char *line_file_name = NULL; /* Value of current_file_name at line number. */
2781 const char *line_directory_name = NULL; /* Value of directory_name at line number. */
2782 bfd_vma low_line_vma = 0;
2783 bfd_vma low_func_vma = 0;
2784 asymbol *func = 0;
2785 bfd_size_type filelen, funclen;
2786 char *buf;
2787
2788 *filename_ptr = abfd->filename;
2789 *functionname_ptr = 0;
2790 *line_ptr = 0;
2791
2775 if (symbols != (asymbol **)NULL)
2776 {
2777 for (p = symbols; *p; p++)
2778 {
2779 aout_symbol_type *q = (aout_symbol_type *) (*p);
2780 next:
2781 switch (q->type)
2782 {

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

2854 *line_ptr = q->desc;
2855 low_line_vma = q->symbol.value;
2856 line_file_name = current_file_name;
2857 line_directory_name = directory_name;
2858 }
2859 break;
2860 case N_FUN:
2861 {
2792 if (symbols != (asymbol **)NULL)
2793 {
2794 for (p = symbols; *p; p++)
2795 {
2796 aout_symbol_type *q = (aout_symbol_type *) (*p);
2797 next:
2798 switch (q->type)
2799 {

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

2871 *line_ptr = q->desc;
2872 low_line_vma = q->symbol.value;
2873 line_file_name = current_file_name;
2874 line_directory_name = directory_name;
2875 }
2876 break;
2877 case N_FUN:
2878 {
2862 /* We'll keep this if it is nearer than the one we have already */
2879 /* We'll keep this if it is nearer than the one we have already. */
2863 if (q->symbol.value >= low_func_vma &&
2880 if (q->symbol.value >= low_func_vma &&
2864 q->symbol.value <= offset) {
2865 low_func_vma = q->symbol.value;
2866 func = (asymbol *)q;
2867 }
2881 q->symbol.value <= offset)
2882 {
2883 low_func_vma = q->symbol.value;
2884 func = (asymbol *)q;
2885 }
2868 else if (q->symbol.value > offset)
2869 goto done;
2870 }
2871 break;
2872 }
2873 }
2874 }
2875

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

2881 }
2882
2883 if (main_file_name == NULL
2884 || IS_ABSOLUTE_PATH (main_file_name)
2885 || directory_name == NULL)
2886 filelen = 0;
2887 else
2888 filelen = strlen (directory_name) + strlen (main_file_name);
2886 else if (q->symbol.value > offset)
2887 goto done;
2888 }
2889 break;
2890 }
2891 }
2892 }
2893

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

2899 }
2900
2901 if (main_file_name == NULL
2902 || IS_ABSOLUTE_PATH (main_file_name)
2903 || directory_name == NULL)
2904 filelen = 0;
2905 else
2906 filelen = strlen (directory_name) + strlen (main_file_name);
2907
2889 if (func == NULL)
2890 funclen = 0;
2891 else
2892 funclen = strlen (bfd_asymbol_name (func));
2893
2894 if (adata (abfd).line_buf != NULL)
2895 free (adata (abfd).line_buf);
2908 if (func == NULL)
2909 funclen = 0;
2910 else
2911 funclen = strlen (bfd_asymbol_name (func));
2912
2913 if (adata (abfd).line_buf != NULL)
2914 free (adata (abfd).line_buf);
2915
2896 if (filelen + funclen == 0)
2897 adata (abfd).line_buf = buf = NULL;
2898 else
2899 {
2900 buf = (char *) bfd_malloc (filelen + funclen + 3);
2901 adata (abfd).line_buf = buf;
2902 if (buf == NULL)
2916 if (filelen + funclen == 0)
2917 adata (abfd).line_buf = buf = NULL;
2918 else
2919 {
2920 buf = (char *) bfd_malloc (filelen + funclen + 3);
2921 adata (abfd).line_buf = buf;
2922 if (buf == NULL)
2903 return false;
2923 return FALSE;
2904 }
2905
2906 if (main_file_name != NULL)
2907 {
2908 if (IS_ABSOLUTE_PATH (main_file_name) || directory_name == NULL)
2909 *filename_ptr = main_file_name;
2910 else
2911 {

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

2925 underscore back in, so that the caller gets a symbol name. */
2926 if (bfd_get_symbol_leading_char (abfd) == '\0')
2927 strcpy (buf, function);
2928 else
2929 {
2930 buf[0] = bfd_get_symbol_leading_char (abfd);
2931 strcpy (buf + 1, function);
2932 }
2924 }
2925
2926 if (main_file_name != NULL)
2927 {
2928 if (IS_ABSOLUTE_PATH (main_file_name) || directory_name == NULL)
2929 *filename_ptr = main_file_name;
2930 else
2931 {

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

2945 underscore back in, so that the caller gets a symbol name. */
2946 if (bfd_get_symbol_leading_char (abfd) == '\0')
2947 strcpy (buf, function);
2948 else
2949 {
2950 buf[0] = bfd_get_symbol_leading_char (abfd);
2951 strcpy (buf + 1, function);
2952 }
2933 /* Have to remove : stuff */
2953 /* Have to remove : stuff. */
2934 colon = strchr (buf, ':');
2935 if (colon != NULL)
2936 *colon = '\0';
2937 *functionname_ptr = buf;
2938 }
2939
2954 colon = strchr (buf, ':');
2955 if (colon != NULL)
2956 *colon = '\0';
2957 *functionname_ptr = buf;
2958 }
2959
2940 return true;
2960 return TRUE;
2941}
2942
2943int
2944NAME(aout,sizeof_headers) (abfd, execable)
2945 bfd *abfd;
2961}
2962
2963int
2964NAME(aout,sizeof_headers) (abfd, execable)
2965 bfd *abfd;
2946 boolean execable ATTRIBUTE_UNUSED;
2966 bfd_boolean execable ATTRIBUTE_UNUSED;
2947{
2948 return adata (abfd).exec_bytes_size;
2949}
2950
2951/* Free all information we have cached for this BFD. We can always
2952 read it again later if we need it. */
2953
2967{
2968 return adata (abfd).exec_bytes_size;
2969}
2970
2971/* Free all information we have cached for this BFD. We can always
2972 read it again later if we need it. */
2973
2954boolean
2974bfd_boolean
2955NAME(aout,bfd_free_cached_info) (abfd)
2956 bfd *abfd;
2957{
2958 asection *o;
2959
2960 if (bfd_get_format (abfd) != bfd_object
2961 || abfd->tdata.aout_data == NULL)
2975NAME(aout,bfd_free_cached_info) (abfd)
2976 bfd *abfd;
2977{
2978 asection *o;
2979
2980 if (bfd_get_format (abfd) != bfd_object
2981 || abfd->tdata.aout_data == NULL)
2962 return true;
2982 return TRUE;
2963
2964#define BFCI_FREE(x) if (x != NULL) { free (x); x = NULL; }
2965 BFCI_FREE (obj_aout_symbols (abfd));
2966#ifdef USE_MMAP
2967 obj_aout_external_syms (abfd) = 0;
2968 bfd_free_window (&obj_aout_sym_window (abfd));
2969 bfd_free_window (&obj_aout_string_window (abfd));
2970 obj_aout_external_strings (abfd) = 0;
2971#else
2972 BFCI_FREE (obj_aout_external_syms (abfd));
2973 BFCI_FREE (obj_aout_external_strings (abfd));
2974#endif
2975 for (o = abfd->sections; o != (asection *) NULL; o = o->next)
2976 BFCI_FREE (o->relocation);
2977#undef BFCI_FREE
2978
2983
2984#define BFCI_FREE(x) if (x != NULL) { free (x); x = NULL; }
2985 BFCI_FREE (obj_aout_symbols (abfd));
2986#ifdef USE_MMAP
2987 obj_aout_external_syms (abfd) = 0;
2988 bfd_free_window (&obj_aout_sym_window (abfd));
2989 bfd_free_window (&obj_aout_string_window (abfd));
2990 obj_aout_external_strings (abfd) = 0;
2991#else
2992 BFCI_FREE (obj_aout_external_syms (abfd));
2993 BFCI_FREE (obj_aout_external_strings (abfd));
2994#endif
2995 for (o = abfd->sections; o != (asection *) NULL; o = o->next)
2996 BFCI_FREE (o->relocation);
2997#undef BFCI_FREE
2998
2979 return true;
2999 return TRUE;
2980}
2981
2982/* a.out link code. */
2983
3000}
3001
3002/* a.out link code. */
3003
2984static boolean aout_link_add_object_symbols
3004static bfd_boolean aout_link_add_object_symbols
2985 PARAMS ((bfd *, struct bfd_link_info *));
3005 PARAMS ((bfd *, struct bfd_link_info *));
2986static boolean aout_link_check_archive_element
2987 PARAMS ((bfd *, struct bfd_link_info *, boolean *));
2988static boolean aout_link_free_symbols PARAMS ((bfd *));
2989static boolean aout_link_check_ar_symbols
2990 PARAMS ((bfd *, struct bfd_link_info *, boolean *pneeded));
2991static boolean aout_link_add_symbols
3006static bfd_boolean aout_link_check_archive_element
3007 PARAMS ((bfd *, struct bfd_link_info *, bfd_boolean *));
3008static bfd_boolean aout_link_free_symbols
3009 PARAMS ((bfd *));
3010static bfd_boolean aout_link_check_ar_symbols
3011 PARAMS ((bfd *, struct bfd_link_info *, bfd_boolean *pneeded));
3012static bfd_boolean aout_link_add_symbols
2992 PARAMS ((bfd *, struct bfd_link_info *));
2993
2994/* Routine to create an entry in an a.out link hash table. */
2995
2996struct bfd_hash_entry *
2997NAME(aout,link_hash_newfunc) (entry, table, string)
2998 struct bfd_hash_entry *entry;
2999 struct bfd_hash_table *table;

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

3011
3012 /* Call the allocation method of the superclass. */
3013 ret = ((struct aout_link_hash_entry *)
3014 _bfd_link_hash_newfunc ((struct bfd_hash_entry *) ret,
3015 table, string));
3016 if (ret)
3017 {
3018 /* Set local fields. */
3013 PARAMS ((bfd *, struct bfd_link_info *));
3014
3015/* Routine to create an entry in an a.out link hash table. */
3016
3017struct bfd_hash_entry *
3018NAME(aout,link_hash_newfunc) (entry, table, string)
3019 struct bfd_hash_entry *entry;
3020 struct bfd_hash_table *table;

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

3032
3033 /* Call the allocation method of the superclass. */
3034 ret = ((struct aout_link_hash_entry *)
3035 _bfd_link_hash_newfunc ((struct bfd_hash_entry *) ret,
3036 table, string));
3037 if (ret)
3038 {
3039 /* Set local fields. */
3019 ret->written = false;
3040 ret->written = FALSE;
3020 ret->indx = -1;
3021 }
3022
3023 return (struct bfd_hash_entry *) ret;
3024}
3025
3026/* Initialize an a.out link hash table. */
3027
3041 ret->indx = -1;
3042 }
3043
3044 return (struct bfd_hash_entry *) ret;
3045}
3046
3047/* Initialize an a.out link hash table. */
3048
3028boolean
3049bfd_boolean
3029NAME(aout,link_hash_table_init) (table, abfd, newfunc)
3030 struct aout_link_hash_table *table;
3031 bfd *abfd;
3050NAME(aout,link_hash_table_init) (table, abfd, newfunc)
3051 struct aout_link_hash_table *table;
3052 bfd *abfd;
3032 struct bfd_hash_entry *(*newfunc) PARAMS ((struct bfd_hash_entry *,
3033 struct bfd_hash_table *,
3034 const char *));
3053 struct bfd_hash_entry *(*newfunc)
3054 PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *,
3055 const char *));
3035{
3036 return _bfd_link_hash_table_init (&table->root, abfd, newfunc);
3037}
3038
3039/* Create an a.out link hash table. */
3040
3041struct bfd_link_hash_table *
3042NAME(aout,link_hash_table_create) (abfd)
3043 bfd *abfd;
3044{
3045 struct aout_link_hash_table *ret;
3046 bfd_size_type amt = sizeof (struct aout_link_hash_table);
3047
3056{
3057 return _bfd_link_hash_table_init (&table->root, abfd, newfunc);
3058}
3059
3060/* Create an a.out link hash table. */
3061
3062struct bfd_link_hash_table *
3063NAME(aout,link_hash_table_create) (abfd)
3064 bfd *abfd;
3065{
3066 struct aout_link_hash_table *ret;
3067 bfd_size_type amt = sizeof (struct aout_link_hash_table);
3068
3048 ret = (struct aout_link_hash_table *) bfd_alloc (abfd, amt);
3069 ret = (struct aout_link_hash_table *) bfd_malloc (amt);
3049 if (ret == NULL)
3050 return (struct bfd_link_hash_table *) NULL;
3070 if (ret == NULL)
3071 return (struct bfd_link_hash_table *) NULL;
3072
3051 if (! NAME(aout,link_hash_table_init) (ret, abfd,
3052 NAME(aout,link_hash_newfunc)))
3053 {
3054 free (ret);
3055 return (struct bfd_link_hash_table *) NULL;
3056 }
3057 return &ret->root;
3058}
3059
3060/* Given an a.out BFD, add symbols to the global hash table as
3061 appropriate. */
3062
3073 if (! NAME(aout,link_hash_table_init) (ret, abfd,
3074 NAME(aout,link_hash_newfunc)))
3075 {
3076 free (ret);
3077 return (struct bfd_link_hash_table *) NULL;
3078 }
3079 return &ret->root;
3080}
3081
3082/* Given an a.out BFD, add symbols to the global hash table as
3083 appropriate. */
3084
3063boolean
3085bfd_boolean
3064NAME(aout,link_add_symbols) (abfd, info)
3065 bfd *abfd;
3066 struct bfd_link_info *info;
3067{
3068 switch (bfd_get_format (abfd))
3069 {
3070 case bfd_object:
3071 return aout_link_add_object_symbols (abfd, info);
3072 case bfd_archive:
3073 return _bfd_generic_link_add_archive_symbols
3074 (abfd, info, aout_link_check_archive_element);
3075 default:
3076 bfd_set_error (bfd_error_wrong_format);
3086NAME(aout,link_add_symbols) (abfd, info)
3087 bfd *abfd;
3088 struct bfd_link_info *info;
3089{
3090 switch (bfd_get_format (abfd))
3091 {
3092 case bfd_object:
3093 return aout_link_add_object_symbols (abfd, info);
3094 case bfd_archive:
3095 return _bfd_generic_link_add_archive_symbols
3096 (abfd, info, aout_link_check_archive_element);
3097 default:
3098 bfd_set_error (bfd_error_wrong_format);
3077 return false;
3099 return FALSE;
3078 }
3079}
3080
3081/* Add symbols from an a.out object file. */
3082
3100 }
3101}
3102
3103/* Add symbols from an a.out object file. */
3104
3083static boolean
3105static bfd_boolean
3084aout_link_add_object_symbols (abfd, info)
3085 bfd *abfd;
3086 struct bfd_link_info *info;
3087{
3088 if (! aout_get_external_symbols (abfd))
3106aout_link_add_object_symbols (abfd, info)
3107 bfd *abfd;
3108 struct bfd_link_info *info;
3109{
3110 if (! aout_get_external_symbols (abfd))
3089 return false;
3111 return FALSE;
3090 if (! aout_link_add_symbols (abfd, info))
3112 if (! aout_link_add_symbols (abfd, info))
3091 return false;
3113 return FALSE;
3092 if (! info->keep_memory)
3093 {
3094 if (! aout_link_free_symbols (abfd))
3114 if (! info->keep_memory)
3115 {
3116 if (! aout_link_free_symbols (abfd))
3095 return false;
3117 return FALSE;
3096 }
3118 }
3097 return true;
3119 return TRUE;
3098}
3099
3100/* Check a single archive element to see if we need to include it in
3101 the link. *PNEEDED is set according to whether this element is
3102 needed in the link or not. This is called from
3103 _bfd_generic_link_add_archive_symbols. */
3104
3120}
3121
3122/* Check a single archive element to see if we need to include it in
3123 the link. *PNEEDED is set according to whether this element is
3124 needed in the link or not. This is called from
3125 _bfd_generic_link_add_archive_symbols. */
3126
3105static boolean
3127static bfd_boolean
3106aout_link_check_archive_element (abfd, info, pneeded)
3107 bfd *abfd;
3108 struct bfd_link_info *info;
3128aout_link_check_archive_element (abfd, info, pneeded)
3129 bfd *abfd;
3130 struct bfd_link_info *info;
3109 boolean *pneeded;
3131 bfd_boolean *pneeded;
3110{
3111 if (! aout_get_external_symbols (abfd))
3132{
3133 if (! aout_get_external_symbols (abfd))
3112 return false;
3134 return FALSE;
3113
3114 if (! aout_link_check_ar_symbols (abfd, info, pneeded))
3135
3136 if (! aout_link_check_ar_symbols (abfd, info, pneeded))
3115 return false;
3137 return FALSE;
3116
3117 if (*pneeded)
3118 {
3119 if (! aout_link_add_symbols (abfd, info))
3138
3139 if (*pneeded)
3140 {
3141 if (! aout_link_add_symbols (abfd, info))
3120 return false;
3142 return FALSE;
3121 }
3122
3123 if (! info->keep_memory || ! *pneeded)
3124 {
3125 if (! aout_link_free_symbols (abfd))
3143 }
3144
3145 if (! info->keep_memory || ! *pneeded)
3146 {
3147 if (! aout_link_free_symbols (abfd))
3126 return false;
3148 return FALSE;
3127 }
3128
3149 }
3150
3129 return true;
3151 return TRUE;
3130}
3131
3132/* Free up the internal symbols read from an a.out file. */
3133
3152}
3153
3154/* Free up the internal symbols read from an a.out file. */
3155
3134static boolean
3156static bfd_boolean
3135aout_link_free_symbols (abfd)
3136 bfd *abfd;
3137{
3138 if (obj_aout_external_syms (abfd) != (struct external_nlist *) NULL)
3139 {
3140#ifdef USE_MMAP
3141 bfd_free_window (&obj_aout_sym_window (abfd));
3142#else

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

3148 {
3149#ifdef USE_MMAP
3150 bfd_free_window (&obj_aout_string_window (abfd));
3151#else
3152 free ((PTR) obj_aout_external_strings (abfd));
3153#endif
3154 obj_aout_external_strings (abfd) = (char *) NULL;
3155 }
3157aout_link_free_symbols (abfd)
3158 bfd *abfd;
3159{
3160 if (obj_aout_external_syms (abfd) != (struct external_nlist *) NULL)
3161 {
3162#ifdef USE_MMAP
3163 bfd_free_window (&obj_aout_sym_window (abfd));
3164#else

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

3170 {
3171#ifdef USE_MMAP
3172 bfd_free_window (&obj_aout_string_window (abfd));
3173#else
3174 free ((PTR) obj_aout_external_strings (abfd));
3175#endif
3176 obj_aout_external_strings (abfd) = (char *) NULL;
3177 }
3156 return true;
3178 return TRUE;
3157}
3158
3159/* Look through the internal symbols to see if this object file should
3160 be included in the link. We should include this object file if it
3161 defines any symbols which are currently undefined. If this object
3162 file defines a common symbol, then we may adjust the size of the
3163 known symbol but we do not include the object file in the link
3164 (unless there is some other reason to include it). */
3165
3179}
3180
3181/* Look through the internal symbols to see if this object file should
3182 be included in the link. We should include this object file if it
3183 defines any symbols which are currently undefined. If this object
3184 file defines a common symbol, then we may adjust the size of the
3185 known symbol but we do not include the object file in the link
3186 (unless there is some other reason to include it). */
3187
3166static boolean
3188static bfd_boolean
3167aout_link_check_ar_symbols (abfd, info, pneeded)
3168 bfd *abfd;
3169 struct bfd_link_info *info;
3189aout_link_check_ar_symbols (abfd, info, pneeded)
3190 bfd *abfd;
3191 struct bfd_link_info *info;
3170 boolean *pneeded;
3192 bfd_boolean *pneeded;
3171{
3172 register struct external_nlist *p;
3173 struct external_nlist *pend;
3174 char *strings;
3175
3193{
3194 register struct external_nlist *p;
3195 struct external_nlist *pend;
3196 char *strings;
3197
3176 *pneeded = false;
3198 *pneeded = FALSE;
3177
3178 /* Look through all the symbols. */
3179 p = obj_aout_external_syms (abfd);
3180 pend = p + obj_aout_external_sym_count (abfd);
3181 strings = obj_aout_external_strings (abfd);
3182 for (; p < pend; p++)
3183 {
3184 int type = H_GET_8 (abfd, p->e_type);

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

3198 {
3199 if (type == N_WARNING
3200 || type == N_INDR)
3201 ++p;
3202 continue;
3203 }
3204
3205 name = strings + GET_WORD (abfd, p->e_strx);
3199
3200 /* Look through all the symbols. */
3201 p = obj_aout_external_syms (abfd);
3202 pend = p + obj_aout_external_sym_count (abfd);
3203 strings = obj_aout_external_strings (abfd);
3204 for (; p < pend; p++)
3205 {
3206 int type = H_GET_8 (abfd, p->e_type);

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

3220 {
3221 if (type == N_WARNING
3222 || type == N_INDR)
3223 ++p;
3224 continue;
3225 }
3226
3227 name = strings + GET_WORD (abfd, p->e_strx);
3206 h = bfd_link_hash_lookup (info->hash, name, false, false, true);
3228 h = bfd_link_hash_lookup (info->hash, name, FALSE, FALSE, TRUE);
3207
3208 /* We are only interested in symbols that are currently
3209 undefined or common. */
3210 if (h == (struct bfd_link_hash_entry *) NULL
3211 || (h->type != bfd_link_hash_undefined
3212 && h->type != bfd_link_hash_common))
3213 {
3214 if (type == (N_INDR | N_EXT))

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

3219 if (type == (N_TEXT | N_EXT)
3220 || type == (N_DATA | N_EXT)
3221 || type == (N_BSS | N_EXT)
3222 || type == (N_ABS | N_EXT)
3223 || type == (N_INDR | N_EXT))
3224 {
3225 /* This object file defines this symbol. We must link it
3226 in. This is true regardless of whether the current
3229
3230 /* We are only interested in symbols that are currently
3231 undefined or common. */
3232 if (h == (struct bfd_link_hash_entry *) NULL
3233 || (h->type != bfd_link_hash_undefined
3234 && h->type != bfd_link_hash_common))
3235 {
3236 if (type == (N_INDR | N_EXT))

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

3241 if (type == (N_TEXT | N_EXT)
3242 || type == (N_DATA | N_EXT)
3243 || type == (N_BSS | N_EXT)
3244 || type == (N_ABS | N_EXT)
3245 || type == (N_INDR | N_EXT))
3246 {
3247 /* This object file defines this symbol. We must link it
3248 in. This is true regardless of whether the current
3227 definition of the symbol is undefined or common. If the
3228 current definition is common, we have a case in which we
3229 have already seen an object file including
3249 definition of the symbol is undefined or common.
3250
3251 If the current definition is common, we have a case in
3252 which we have already seen an object file including:
3230 int a;
3253 int a;
3231 and this object file from the archive includes
3254 and this object file from the archive includes:
3232 int a = 5;
3255 int a = 5;
3233 In such a case we must include this object file.
3256 In such a case, whether to include this object is target
3257 dependant for backward compatibility.
3234
3235 FIXME: The SunOS 4.1.3 linker will pull in the archive
3236 element if the symbol is defined in the .data section,
3237 but not if it is defined in the .text section. That
3258
3259 FIXME: The SunOS 4.1.3 linker will pull in the archive
3260 element if the symbol is defined in the .data section,
3261 but not if it is defined in the .text section. That
3238 seems a bit crazy to me, and I haven't implemented it.
3239 However, it might be correct. */
3262 seems a bit crazy to me, and it has not been implemented
3263 yet. However, it might be correct. */
3264 if (h->type == bfd_link_hash_common)
3265 {
3266 int skip = 0;
3267
3268 switch (info->common_skip_ar_aymbols)
3269 {
3270 case bfd_link_common_skip_text:
3271 skip = (type == (N_TEXT | N_EXT));
3272 break;
3273 case bfd_link_common_skip_data:
3274 skip = (type == (N_DATA | N_EXT));
3275 break;
3276 default:
3277 case bfd_link_common_skip_all:
3278 skip = 1;
3279 break;
3280 }
3281
3282 if (skip)
3283 continue;
3284 }
3285
3240 if (! (*info->callbacks->add_archive_element) (info, abfd, name))
3286 if (! (*info->callbacks->add_archive_element) (info, abfd, name))
3241 return false;
3242 *pneeded = true;
3243 return true;
3287 return FALSE;
3288 *pneeded = TRUE;
3289 return TRUE;
3244 }
3245
3246 if (type == (N_UNDF | N_EXT))
3247 {
3248 bfd_vma value;
3249
3250 value = GET_WORD (abfd, p->e_value);
3251 if (value != 0)

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

3262 {
3263 /* This symbol was created as undefined from
3264 outside BFD. We assume that we should link
3265 in the object file. This is done for the -u
3266 option in the linker. */
3267 if (! (*info->callbacks->add_archive_element) (info,
3268 abfd,
3269 name))
3290 }
3291
3292 if (type == (N_UNDF | N_EXT))
3293 {
3294 bfd_vma value;
3295
3296 value = GET_WORD (abfd, p->e_value);
3297 if (value != 0)

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

3308 {
3309 /* This symbol was created as undefined from
3310 outside BFD. We assume that we should link
3311 in the object file. This is done for the -u
3312 option in the linker. */
3313 if (! (*info->callbacks->add_archive_element) (info,
3314 abfd,
3315 name))
3270 return false;
3271 *pneeded = true;
3272 return true;
3316 return FALSE;
3317 *pneeded = TRUE;
3318 return TRUE;
3273 }
3274 /* Turn the current link symbol into a common
3275 symbol. It is already on the undefs list. */
3276 h->type = bfd_link_hash_common;
3277 h->u.c.p = ((struct bfd_link_hash_common_entry *)
3278 bfd_hash_allocate (&info->hash->table,
3279 sizeof (struct bfd_link_hash_common_entry)));
3280 if (h->u.c.p == NULL)
3319 }
3320 /* Turn the current link symbol into a common
3321 symbol. It is already on the undefs list. */
3322 h->type = bfd_link_hash_common;
3323 h->u.c.p = ((struct bfd_link_hash_common_entry *)
3324 bfd_hash_allocate (&info->hash->table,
3325 sizeof (struct bfd_link_hash_common_entry)));
3326 if (h->u.c.p == NULL)
3281 return false;
3327 return FALSE;
3282
3283 h->u.c.size = value;
3284
3285 /* FIXME: This isn't quite right. The maximum
3286 alignment of a common symbol should be set by the
3287 architecture of the output file, not of the input
3288 file. */
3289 power = bfd_log2 (value);

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

3310 || type == N_WEAKB)
3311 {
3312 /* This symbol is weak but defined. We must pull it in if
3313 the current link symbol is undefined, but we don't want
3314 it if the current link symbol is common. */
3315 if (h->type == bfd_link_hash_undefined)
3316 {
3317 if (! (*info->callbacks->add_archive_element) (info, abfd, name))
3328
3329 h->u.c.size = value;
3330
3331 /* FIXME: This isn't quite right. The maximum
3332 alignment of a common symbol should be set by the
3333 architecture of the output file, not of the input
3334 file. */
3335 power = bfd_log2 (value);

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

3356 || type == N_WEAKB)
3357 {
3358 /* This symbol is weak but defined. We must pull it in if
3359 the current link symbol is undefined, but we don't want
3360 it if the current link symbol is common. */
3361 if (h->type == bfd_link_hash_undefined)
3362 {
3363 if (! (*info->callbacks->add_archive_element) (info, abfd, name))
3318 return false;
3319 *pneeded = true;
3320 return true;
3364 return FALSE;
3365 *pneeded = TRUE;
3366 return TRUE;
3321 }
3322 }
3323 }
3324
3325 /* We do not need this object file. */
3367 }
3368 }
3369 }
3370
3371 /* We do not need this object file. */
3326 return true;
3372 return TRUE;
3327}
3328
3329/* Add all symbols from an object file to the hash table. */
3330
3373}
3374
3375/* Add all symbols from an object file to the hash table. */
3376
3331static boolean
3377static bfd_boolean
3332aout_link_add_symbols (abfd, info)
3333 bfd *abfd;
3334 struct bfd_link_info *info;
3335{
3378aout_link_add_symbols (abfd, info)
3379 bfd *abfd;
3380 struct bfd_link_info *info;
3381{
3336 boolean (*add_one_symbol) PARAMS ((struct bfd_link_info *, bfd *,
3337 const char *, flagword, asection *,
3338 bfd_vma, const char *, boolean,
3339 boolean,
3340 struct bfd_link_hash_entry **));
3382 bfd_boolean (*add_one_symbol)
3383 PARAMS ((struct bfd_link_info *, bfd *, const char *, flagword, asection *,
3384 bfd_vma, const char *, bfd_boolean, bfd_boolean,
3385 struct bfd_link_hash_entry **));
3341 struct external_nlist *syms;
3342 bfd_size_type sym_count;
3343 char *strings;
3386 struct external_nlist *syms;
3387 bfd_size_type sym_count;
3388 char *strings;
3344 boolean copy;
3389 bfd_boolean copy;
3345 struct aout_link_hash_entry **sym_hash;
3346 register struct external_nlist *p;
3347 struct external_nlist *pend;
3348 bfd_size_type amt;
3349
3350 syms = obj_aout_external_syms (abfd);
3351 sym_count = obj_aout_external_sym_count (abfd);
3352 strings = obj_aout_external_strings (abfd);
3353 if (info->keep_memory)
3390 struct aout_link_hash_entry **sym_hash;
3391 register struct external_nlist *p;
3392 struct external_nlist *pend;
3393 bfd_size_type amt;
3394
3395 syms = obj_aout_external_syms (abfd);
3396 sym_count = obj_aout_external_sym_count (abfd);
3397 strings = obj_aout_external_strings (abfd);
3398 if (info->keep_memory)
3354 copy = false;
3399 copy = FALSE;
3355 else
3400 else
3356 copy = true;
3401 copy = TRUE;
3357
3358 if (aout_backend_info (abfd)->add_dynamic_symbols != NULL)
3359 {
3360 if (! ((*aout_backend_info (abfd)->add_dynamic_symbols)
3361 (abfd, info, &syms, &sym_count, &strings)))
3402
3403 if (aout_backend_info (abfd)->add_dynamic_symbols != NULL)
3404 {
3405 if (! ((*aout_backend_info (abfd)->add_dynamic_symbols)
3406 (abfd, info, &syms, &sym_count, &strings)))
3362 return false;
3407 return FALSE;
3363 }
3364
3365 /* We keep a list of the linker hash table entries that correspond
3366 to particular symbols. We could just look them up in the hash
3367 table, but keeping the list is more efficient. Perhaps this
3368 should be conditional on info->keep_memory. */
3369 amt = sym_count * sizeof (struct aout_link_hash_entry *);
3370 sym_hash = (struct aout_link_hash_entry **) bfd_alloc (abfd, amt);
3371 if (sym_hash == NULL && sym_count != 0)
3408 }
3409
3410 /* We keep a list of the linker hash table entries that correspond
3411 to particular symbols. We could just look them up in the hash
3412 table, but keeping the list is more efficient. Perhaps this
3413 should be conditional on info->keep_memory. */
3414 amt = sym_count * sizeof (struct aout_link_hash_entry *);
3415 sym_hash = (struct aout_link_hash_entry **) bfd_alloc (abfd, amt);
3416 if (sym_hash == NULL && sym_count != 0)
3372 return false;
3417 return FALSE;
3373 obj_aout_sym_hashes (abfd) = sym_hash;
3374
3375 add_one_symbol = aout_backend_info (abfd)->add_one_symbol;
3376 if (add_one_symbol == NULL)
3377 add_one_symbol = _bfd_generic_link_add_one_symbol;
3378
3379 p = syms;
3380 pend = p + sym_count;

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

3510 case N_WEAKB:
3511 section = obj_bsssec (abfd);
3512 value -= bfd_get_section_vma (abfd, section);
3513 flags = BSF_WEAK;
3514 break;
3515 }
3516
3517 if (! ((*add_one_symbol)
3418 obj_aout_sym_hashes (abfd) = sym_hash;
3419
3420 add_one_symbol = aout_backend_info (abfd)->add_one_symbol;
3421 if (add_one_symbol == NULL)
3422 add_one_symbol = _bfd_generic_link_add_one_symbol;
3423
3424 p = syms;
3425 pend = p + sym_count;

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

3555 case N_WEAKB:
3556 section = obj_bsssec (abfd);
3557 value -= bfd_get_section_vma (abfd, section);
3558 flags = BSF_WEAK;
3559 break;
3560 }
3561
3562 if (! ((*add_one_symbol)
3518 (info, abfd, name, flags, section, value, string, copy, false,
3563 (info, abfd, name, flags, section, value, string, copy, FALSE,
3519 (struct bfd_link_hash_entry **) sym_hash)))
3564 (struct bfd_link_hash_entry **) sym_hash)))
3520 return false;
3565 return FALSE;
3521
3522 /* Restrict the maximum alignment of a common symbol based on
3523 the architecture, since a.out has no way to represent
3524 alignment requirements of a section in a .o file. FIXME:
3525 This isn't quite right: it should use the architecture of the
3526 output file, not the input files. */
3527 if ((*sym_hash)->root.type == bfd_link_hash_common
3528 && ((*sym_hash)->root.u.c.p->alignment_power >

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

3538 BFD_ASSERT ((flags & BSF_CONSTRUCTOR) != 0);
3539 *sym_hash = NULL;
3540 }
3541
3542 if (type == (N_INDR | N_EXT) || type == N_WARNING)
3543 ++sym_hash;
3544 }
3545
3566
3567 /* Restrict the maximum alignment of a common symbol based on
3568 the architecture, since a.out has no way to represent
3569 alignment requirements of a section in a .o file. FIXME:
3570 This isn't quite right: it should use the architecture of the
3571 output file, not the input files. */
3572 if ((*sym_hash)->root.type == bfd_link_hash_common
3573 && ((*sym_hash)->root.u.c.p->alignment_power >

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

3583 BFD_ASSERT ((flags & BSF_CONSTRUCTOR) != 0);
3584 *sym_hash = NULL;
3585 }
3586
3587 if (type == (N_INDR | N_EXT) || type == N_WARNING)
3588 ++sym_hash;
3589 }
3590
3546 return true;
3591 return TRUE;
3547}
3548
3549/* A hash table used for header files with N_BINCL entries. */
3550
3551struct aout_link_includes_table
3552{
3553 struct bfd_hash_table root;
3554};

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

3601 /* A buffer large enough to hold the symbol map of any input BFD. */
3602 int *symbol_map;
3603 /* A buffer large enough to hold output symbols of any input BFD. */
3604 struct external_nlist *output_syms;
3605};
3606
3607static struct bfd_hash_entry *aout_link_includes_newfunc
3608 PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
3592}
3593
3594/* A hash table used for header files with N_BINCL entries. */
3595
3596struct aout_link_includes_table
3597{
3598 struct bfd_hash_table root;
3599};

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

3646 /* A buffer large enough to hold the symbol map of any input BFD. */
3647 int *symbol_map;
3648 /* A buffer large enough to hold output symbols of any input BFD. */
3649 struct external_nlist *output_syms;
3650};
3651
3652static struct bfd_hash_entry *aout_link_includes_newfunc
3653 PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
3609static boolean aout_link_input_bfd
3654static bfd_boolean aout_link_input_bfd
3610 PARAMS ((struct aout_final_link_info *, bfd *input_bfd));
3655 PARAMS ((struct aout_final_link_info *, bfd *input_bfd));
3611static boolean aout_link_write_symbols
3656static bfd_boolean aout_link_write_symbols
3612 PARAMS ((struct aout_final_link_info *, bfd *input_bfd));
3657 PARAMS ((struct aout_final_link_info *, bfd *input_bfd));
3613static boolean aout_link_write_other_symbol
3658static bfd_boolean aout_link_write_other_symbol
3614 PARAMS ((struct aout_link_hash_entry *, PTR));
3659 PARAMS ((struct aout_link_hash_entry *, PTR));
3615static boolean aout_link_input_section
3660static bfd_boolean aout_link_input_section
3616 PARAMS ((struct aout_final_link_info *, bfd *input_bfd,
3617 asection *input_section, file_ptr *reloff_ptr,
3618 bfd_size_type rel_size));
3661 PARAMS ((struct aout_final_link_info *, bfd *input_bfd,
3662 asection *input_section, file_ptr *reloff_ptr,
3663 bfd_size_type rel_size));
3619static boolean aout_link_input_section_std
3664static bfd_boolean aout_link_input_section_std
3620 PARAMS ((struct aout_final_link_info *, bfd *input_bfd,
3621 asection *input_section, struct reloc_std_external *,
3622 bfd_size_type rel_size, bfd_byte *contents));
3665 PARAMS ((struct aout_final_link_info *, bfd *input_bfd,
3666 asection *input_section, struct reloc_std_external *,
3667 bfd_size_type rel_size, bfd_byte *contents));
3623static boolean aout_link_input_section_ext
3668static bfd_boolean aout_link_input_section_ext
3624 PARAMS ((struct aout_final_link_info *, bfd *input_bfd,
3625 asection *input_section, struct reloc_ext_external *,
3626 bfd_size_type rel_size, bfd_byte *contents));
3627static INLINE asection *aout_reloc_index_to_section
3628 PARAMS ((bfd *, int));
3669 PARAMS ((struct aout_final_link_info *, bfd *input_bfd,
3670 asection *input_section, struct reloc_ext_external *,
3671 bfd_size_type rel_size, bfd_byte *contents));
3672static INLINE asection *aout_reloc_index_to_section
3673 PARAMS ((bfd *, int));
3629static boolean aout_link_reloc_link_order
3674static bfd_boolean aout_link_reloc_link_order
3630 PARAMS ((struct aout_final_link_info *, asection *,
3631 struct bfd_link_order *));
3632
3633/* The function to create a new entry in the header file hash table. */
3634
3635static struct bfd_hash_entry *
3636aout_link_includes_newfunc (entry, table, string)
3637 struct bfd_hash_entry *entry;

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

3664
3665/* Do the final link step. This is called on the output BFD. The
3666 INFO structure should point to a list of BFDs linked through the
3667 link_next field which can be used to find each BFD which takes part
3668 in the output. Also, each section in ABFD should point to a list
3669 of bfd_link_order structures which list all the input sections for
3670 the output section. */
3671
3675 PARAMS ((struct aout_final_link_info *, asection *,
3676 struct bfd_link_order *));
3677
3678/* The function to create a new entry in the header file hash table. */
3679
3680static struct bfd_hash_entry *
3681aout_link_includes_newfunc (entry, table, string)
3682 struct bfd_hash_entry *entry;

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

3709
3710/* Do the final link step. This is called on the output BFD. The
3711 INFO structure should point to a list of BFDs linked through the
3712 link_next field which can be used to find each BFD which takes part
3713 in the output. Also, each section in ABFD should point to a list
3714 of bfd_link_order structures which list all the input sections for
3715 the output section. */
3716
3672boolean
3717bfd_boolean
3673NAME(aout,final_link) (abfd, info, callback)
3674 bfd *abfd;
3675 struct bfd_link_info *info;
3676 void (*callback) PARAMS ((bfd *, file_ptr *, file_ptr *, file_ptr *));
3677{
3678 struct aout_final_link_info aout_info;
3718NAME(aout,final_link) (abfd, info, callback)
3719 bfd *abfd;
3720 struct bfd_link_info *info;
3721 void (*callback) PARAMS ((bfd *, file_ptr *, file_ptr *, file_ptr *));
3722{
3723 struct aout_final_link_info aout_info;
3679 boolean includes_hash_initialized = false;
3724 bfd_boolean includes_hash_initialized = FALSE;
3680 register bfd *sub;
3681 bfd_size_type trsize, drsize;
3682 bfd_size_type max_contents_size;
3683 bfd_size_type max_relocs_size;
3684 bfd_size_type max_sym_count;
3685 bfd_size_type text_size;
3686 file_ptr text_end;
3687 register struct bfd_link_order *p;
3688 asection *o;
3725 register bfd *sub;
3726 bfd_size_type trsize, drsize;
3727 bfd_size_type max_contents_size;
3728 bfd_size_type max_relocs_size;
3729 bfd_size_type max_sym_count;
3730 bfd_size_type text_size;
3731 file_ptr text_end;
3732 register struct bfd_link_order *p;
3733 asection *o;
3689 boolean have_link_order_relocs;
3734 bfd_boolean have_link_order_relocs;
3690
3691 if (info->shared)
3692 abfd->flags |= DYNAMIC;
3693
3694 aout_info.info = info;
3695 aout_info.output_bfd = abfd;
3696 aout_info.contents = NULL;
3697 aout_info.relocs = NULL;
3698 aout_info.symbol_map = NULL;
3699 aout_info.output_syms = NULL;
3700
3701 if (! bfd_hash_table_init_n (&aout_info.includes.root,
3702 aout_link_includes_newfunc,
3703 251))
3704 goto error_return;
3735
3736 if (info->shared)
3737 abfd->flags |= DYNAMIC;
3738
3739 aout_info.info = info;
3740 aout_info.output_bfd = abfd;
3741 aout_info.contents = NULL;
3742 aout_info.relocs = NULL;
3743 aout_info.symbol_map = NULL;
3744 aout_info.output_syms = NULL;
3745
3746 if (! bfd_hash_table_init_n (&aout_info.includes.root,
3747 aout_link_includes_newfunc,
3748 251))
3749 goto error_return;
3705 includes_hash_initialized = true;
3750 includes_hash_initialized = TRUE;
3706
3707 /* Figure out the largest section size. Also, if generating
3751
3752 /* Figure out the largest section size. Also, if generating
3708 relocateable output, count the relocs. */
3753 relocatable output, count the relocs. */
3709 trsize = 0;
3710 drsize = 0;
3711 max_contents_size = 0;
3712 max_relocs_size = 0;
3713 max_sym_count = 0;
3714 for (sub = info->input_bfds; sub != NULL; sub = sub->link_next)
3715 {
3716 bfd_size_type sz;
3717
3754 trsize = 0;
3755 drsize = 0;
3756 max_contents_size = 0;
3757 max_relocs_size = 0;
3758 max_sym_count = 0;
3759 for (sub = info->input_bfds; sub != NULL; sub = sub->link_next)
3760 {
3761 bfd_size_type sz;
3762
3718 if (info->relocateable)
3763 if (info->relocatable)
3719 {
3720 if (bfd_get_flavour (sub) == bfd_target_aout_flavour)
3721 {
3722 trsize += exec_hdr (sub)->a_trsize;
3723 drsize += exec_hdr (sub)->a_drsize;
3724 }
3725 else
3726 {
3727 /* FIXME: We need to identify the .text and .data sections
3728 and call get_reloc_upper_bound and canonicalize_reloc to
3729 work out the number of relocs needed, and then multiply
3730 by the reloc size. */
3731 (*_bfd_error_handler)
3764 {
3765 if (bfd_get_flavour (sub) == bfd_target_aout_flavour)
3766 {
3767 trsize += exec_hdr (sub)->a_trsize;
3768 drsize += exec_hdr (sub)->a_drsize;
3769 }
3770 else
3771 {
3772 /* FIXME: We need to identify the .text and .data sections
3773 and call get_reloc_upper_bound and canonicalize_reloc to
3774 work out the number of relocs needed, and then multiply
3775 by the reloc size. */
3776 (*_bfd_error_handler)
3732 (_("%s: relocateable link from %s to %s not supported"),
3777 (_("%s: relocatable link from %s to %s not supported"),
3733 bfd_get_filename (abfd),
3734 sub->xvec->name, abfd->xvec->name);
3735 bfd_set_error (bfd_error_invalid_operation);
3736 goto error_return;
3737 }
3738 }
3739
3740 if (bfd_get_flavour (sub) == bfd_target_aout_flavour)

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

3754 max_relocs_size = sz;
3755
3756 sz = obj_aout_external_sym_count (sub);
3757 if (sz > max_sym_count)
3758 max_sym_count = sz;
3759 }
3760 }
3761
3778 bfd_get_filename (abfd),
3779 sub->xvec->name, abfd->xvec->name);
3780 bfd_set_error (bfd_error_invalid_operation);
3781 goto error_return;
3782 }
3783 }
3784
3785 if (bfd_get_flavour (sub) == bfd_target_aout_flavour)

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

3799 max_relocs_size = sz;
3800
3801 sz = obj_aout_external_sym_count (sub);
3802 if (sz > max_sym_count)
3803 max_sym_count = sz;
3804 }
3805 }
3806
3762 if (info->relocateable)
3807 if (info->relocatable)
3763 {
3764 if (obj_textsec (abfd) != (asection *) NULL)
3765 trsize += (_bfd_count_link_order_relocs (obj_textsec (abfd)
3766 ->link_order_head)
3767 * obj_reloc_entry_size (abfd));
3768 if (obj_datasec (abfd) != (asection *) NULL)
3769 drsize += (_bfd_count_link_order_relocs (obj_datasec (abfd)
3770 ->link_order_head)

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

3820 /* If we have a symbol named __DYNAMIC, force it out now. This is
3821 required by SunOS. Doing this here rather than in sunos.c is a
3822 hack, but it's easier than exporting everything which would be
3823 needed. */
3824 {
3825 struct aout_link_hash_entry *h;
3826
3827 h = aout_link_hash_lookup (aout_hash_table (info), "__DYNAMIC",
3808 {
3809 if (obj_textsec (abfd) != (asection *) NULL)
3810 trsize += (_bfd_count_link_order_relocs (obj_textsec (abfd)
3811 ->link_order_head)
3812 * obj_reloc_entry_size (abfd));
3813 if (obj_datasec (abfd) != (asection *) NULL)
3814 drsize += (_bfd_count_link_order_relocs (obj_datasec (abfd)
3815 ->link_order_head)

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

3865 /* If we have a symbol named __DYNAMIC, force it out now. This is
3866 required by SunOS. Doing this here rather than in sunos.c is a
3867 hack, but it's easier than exporting everything which would be
3868 needed. */
3869 {
3870 struct aout_link_hash_entry *h;
3871
3872 h = aout_link_hash_lookup (aout_hash_table (info), "__DYNAMIC",
3828 false, false, false);
3873 FALSE, FALSE, FALSE);
3829 if (h != NULL)
3830 aout_link_write_other_symbol (h, &aout_info);
3831 }
3832
3833 /* The most time efficient way to do the link would be to read all
3834 the input object files into memory and then sort out the
3835 information into the output file. Unfortunately, that will
3836 probably use too much memory. Another method would be to step

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

3847 out the symbols--and then we throw away the information we read
3848 from it. This approach requires a lot of lseeks of the output
3849 file, which is unfortunate but still faster than reopening a lot
3850 of files.
3851
3852 We use the output_has_begun field of the input BFDs to see
3853 whether we have already handled it. */
3854 for (sub = info->input_bfds; sub != (bfd *) NULL; sub = sub->link_next)
3874 if (h != NULL)
3875 aout_link_write_other_symbol (h, &aout_info);
3876 }
3877
3878 /* The most time efficient way to do the link would be to read all
3879 the input object files into memory and then sort out the
3880 information into the output file. Unfortunately, that will
3881 probably use too much memory. Another method would be to step

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

3892 out the symbols--and then we throw away the information we read
3893 from it. This approach requires a lot of lseeks of the output
3894 file, which is unfortunate but still faster than reopening a lot
3895 of files.
3896
3897 We use the output_has_begun field of the input BFDs to see
3898 whether we have already handled it. */
3899 for (sub = info->input_bfds; sub != (bfd *) NULL; sub = sub->link_next)
3855 sub->output_has_begun = false;
3900 sub->output_has_begun = FALSE;
3856
3857 /* Mark all sections which are to be included in the link. This
3858 will normally be every section. We need to do this so that we
3859 can identify any sections which the linker has decided to not
3860 include. */
3861 for (o = abfd->sections; o != NULL; o = o->next)
3862 {
3863 for (p = o->link_order_head; p != NULL; p = p->next)
3901
3902 /* Mark all sections which are to be included in the link. This
3903 will normally be every section. We need to do this so that we
3904 can identify any sections which the linker has decided to not
3905 include. */
3906 for (o = abfd->sections; o != NULL; o = o->next)
3907 {
3908 for (p = o->link_order_head; p != NULL; p = p->next)
3864 {
3865 if (p->type == bfd_indirect_link_order)
3866 p->u.indirect.section->linker_mark = (unsigned int) true;
3867 }
3909 if (p->type == bfd_indirect_link_order)
3910 p->u.indirect.section->linker_mark = TRUE;
3868 }
3869
3911 }
3912
3870 have_link_order_relocs = false;
3913 have_link_order_relocs = FALSE;
3871 for (o = abfd->sections; o != (asection *) NULL; o = o->next)
3872 {
3873 for (p = o->link_order_head;
3874 p != (struct bfd_link_order *) NULL;
3875 p = p->next)
3876 {
3877 if (p->type == bfd_indirect_link_order
3878 && (bfd_get_flavour (p->u.indirect.section->owner)
3879 == bfd_target_aout_flavour))
3880 {
3881 bfd *input_bfd;
3882
3883 input_bfd = p->u.indirect.section->owner;
3884 if (! input_bfd->output_has_begun)
3885 {
3886 if (! aout_link_input_bfd (&aout_info, input_bfd))
3887 goto error_return;
3914 for (o = abfd->sections; o != (asection *) NULL; o = o->next)
3915 {
3916 for (p = o->link_order_head;
3917 p != (struct bfd_link_order *) NULL;
3918 p = p->next)
3919 {
3920 if (p->type == bfd_indirect_link_order
3921 && (bfd_get_flavour (p->u.indirect.section->owner)
3922 == bfd_target_aout_flavour))
3923 {
3924 bfd *input_bfd;
3925
3926 input_bfd = p->u.indirect.section->owner;
3927 if (! input_bfd->output_has_begun)
3928 {
3929 if (! aout_link_input_bfd (&aout_info, input_bfd))
3930 goto error_return;
3888 input_bfd->output_has_begun = true;
3931 input_bfd->output_has_begun = TRUE;
3889 }
3890 }
3891 else if (p->type == bfd_section_reloc_link_order
3892 || p->type == bfd_symbol_reloc_link_order)
3893 {
3894 /* These are handled below. */
3932 }
3933 }
3934 else if (p->type == bfd_section_reloc_link_order
3935 || p->type == bfd_symbol_reloc_link_order)
3936 {
3937 /* These are handled below. */
3895 have_link_order_relocs = true;
3938 have_link_order_relocs = TRUE;
3896 }
3897 else
3898 {
3899 if (! _bfd_default_link_order (abfd, info, o, p))
3900 goto error_return;
3901 }
3902 }
3903 }

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

3947 if (aout_info.output_syms != NULL)
3948 {
3949 free (aout_info.output_syms);
3950 aout_info.output_syms = NULL;
3951 }
3952 if (includes_hash_initialized)
3953 {
3954 bfd_hash_table_free (&aout_info.includes.root);
3939 }
3940 else
3941 {
3942 if (! _bfd_default_link_order (abfd, info, o, p))
3943 goto error_return;
3944 }
3945 }
3946 }

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

3990 if (aout_info.output_syms != NULL)
3991 {
3992 free (aout_info.output_syms);
3993 aout_info.output_syms = NULL;
3994 }
3995 if (includes_hash_initialized)
3996 {
3997 bfd_hash_table_free (&aout_info.includes.root);
3955 includes_hash_initialized = false;
3998 includes_hash_initialized = FALSE;
3956 }
3957
3958 /* Finish up any dynamic linking we may be doing. */
3959 if (aout_backend_info (abfd)->finish_dynamic_link != NULL)
3960 {
3961 if (! (*aout_backend_info (abfd)->finish_dynamic_link) (abfd, info))
3962 goto error_return;
3963 }

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

3986
3987 b = 0;
3988 pos = obj_datasec (abfd)->filepos + exec_hdr (abfd)->a_data - 1;
3989 if (bfd_seek (abfd, pos, SEEK_SET) != 0
3990 || bfd_bwrite (&b, (bfd_size_type) 1, abfd) != 1)
3991 goto error_return;
3992 }
3993
3999 }
4000
4001 /* Finish up any dynamic linking we may be doing. */
4002 if (aout_backend_info (abfd)->finish_dynamic_link != NULL)
4003 {
4004 if (! (*aout_backend_info (abfd)->finish_dynamic_link) (abfd, info))
4005 goto error_return;
4006 }

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

4029
4030 b = 0;
4031 pos = obj_datasec (abfd)->filepos + exec_hdr (abfd)->a_data - 1;
4032 if (bfd_seek (abfd, pos, SEEK_SET) != 0
4033 || bfd_bwrite (&b, (bfd_size_type) 1, abfd) != 1)
4034 goto error_return;
4035 }
4036
3994 return true;
4037 return TRUE;
3995
3996 error_return:
3997 if (aout_info.contents != NULL)
3998 free (aout_info.contents);
3999 if (aout_info.relocs != NULL)
4000 free (aout_info.relocs);
4001 if (aout_info.symbol_map != NULL)
4002 free (aout_info.symbol_map);
4003 if (aout_info.output_syms != NULL)
4004 free (aout_info.output_syms);
4005 if (includes_hash_initialized)
4006 bfd_hash_table_free (&aout_info.includes.root);
4038
4039 error_return:
4040 if (aout_info.contents != NULL)
4041 free (aout_info.contents);
4042 if (aout_info.relocs != NULL)
4043 free (aout_info.relocs);
4044 if (aout_info.symbol_map != NULL)
4045 free (aout_info.symbol_map);
4046 if (aout_info.output_syms != NULL)
4047 free (aout_info.output_syms);
4048 if (includes_hash_initialized)
4049 bfd_hash_table_free (&aout_info.includes.root);
4007 return false;
4050 return FALSE;
4008}
4009
4010/* Link an a.out input BFD into the output file. */
4011
4051}
4052
4053/* Link an a.out input BFD into the output file. */
4054
4012static boolean
4055static bfd_boolean
4013aout_link_input_bfd (finfo, input_bfd)
4014 struct aout_final_link_info *finfo;
4015 bfd *input_bfd;
4016{
4017 bfd_size_type sym_count;
4018
4019 BFD_ASSERT (bfd_get_format (input_bfd) == bfd_object);
4020
4021 /* If this is a dynamic object, it may need special handling. */
4022 if ((input_bfd->flags & DYNAMIC) != 0
4023 && aout_backend_info (input_bfd)->link_dynamic_object != NULL)
4024 {
4025 return ((*aout_backend_info (input_bfd)->link_dynamic_object)
4026 (finfo->info, input_bfd));
4027 }
4028
4029 /* Get the symbols. We probably have them already, unless
4056aout_link_input_bfd (finfo, input_bfd)
4057 struct aout_final_link_info *finfo;
4058 bfd *input_bfd;
4059{
4060 bfd_size_type sym_count;
4061
4062 BFD_ASSERT (bfd_get_format (input_bfd) == bfd_object);
4063
4064 /* If this is a dynamic object, it may need special handling. */
4065 if ((input_bfd->flags & DYNAMIC) != 0
4066 && aout_backend_info (input_bfd)->link_dynamic_object != NULL)
4067 {
4068 return ((*aout_backend_info (input_bfd)->link_dynamic_object)
4069 (finfo->info, input_bfd));
4070 }
4071
4072 /* Get the symbols. We probably have them already, unless
4030 finfo->info->keep_memory is false. */
4073 finfo->info->keep_memory is FALSE. */
4031 if (! aout_get_external_symbols (input_bfd))
4074 if (! aout_get_external_symbols (input_bfd))
4032 return false;
4075 return FALSE;
4033
4034 sym_count = obj_aout_external_sym_count (input_bfd);
4035
4036 /* Write out the symbols and get a map of the new indices. The map
4037 is placed into finfo->symbol_map. */
4038 if (! aout_link_write_symbols (finfo, input_bfd))
4076
4077 sym_count = obj_aout_external_sym_count (input_bfd);
4078
4079 /* Write out the symbols and get a map of the new indices. The map
4080 is placed into finfo->symbol_map. */
4081 if (! aout_link_write_symbols (finfo, input_bfd))
4039 return false;
4082 return FALSE;
4040
4041 /* Relocate and write out the sections. These functions use the
4042 symbol map created by aout_link_write_symbols. The linker_mark
4043 field will be set if these sections are to be included in the
4044 link, which will normally be the case. */
4045 if (obj_textsec (input_bfd)->linker_mark)
4046 {
4047 if (! aout_link_input_section (finfo, input_bfd,
4048 obj_textsec (input_bfd),
4049 &finfo->treloff,
4050 exec_hdr (input_bfd)->a_trsize))
4083
4084 /* Relocate and write out the sections. These functions use the
4085 symbol map created by aout_link_write_symbols. The linker_mark
4086 field will be set if these sections are to be included in the
4087 link, which will normally be the case. */
4088 if (obj_textsec (input_bfd)->linker_mark)
4089 {
4090 if (! aout_link_input_section (finfo, input_bfd,
4091 obj_textsec (input_bfd),
4092 &finfo->treloff,
4093 exec_hdr (input_bfd)->a_trsize))
4051 return false;
4094 return FALSE;
4052 }
4053 if (obj_datasec (input_bfd)->linker_mark)
4054 {
4055 if (! aout_link_input_section (finfo, input_bfd,
4056 obj_datasec (input_bfd),
4057 &finfo->dreloff,
4058 exec_hdr (input_bfd)->a_drsize))
4095 }
4096 if (obj_datasec (input_bfd)->linker_mark)
4097 {
4098 if (! aout_link_input_section (finfo, input_bfd,
4099 obj_datasec (input_bfd),
4100 &finfo->dreloff,
4101 exec_hdr (input_bfd)->a_drsize))
4059 return false;
4102 return FALSE;
4060 }
4061
4062 /* If we are not keeping memory, we don't need the symbols any
4063 longer. We still need them if we are keeping memory, because the
4064 strings in the hash table point into them. */
4065 if (! finfo->info->keep_memory)
4066 {
4067 if (! aout_link_free_symbols (input_bfd))
4103 }
4104
4105 /* If we are not keeping memory, we don't need the symbols any
4106 longer. We still need them if we are keeping memory, because the
4107 strings in the hash table point into them. */
4108 if (! finfo->info->keep_memory)
4109 {
4110 if (! aout_link_free_symbols (input_bfd))
4068 return false;
4111 return FALSE;
4069 }
4070
4112 }
4113
4071 return true;
4114 return TRUE;
4072}
4073
4074/* Adjust and write out the symbols for an a.out file. Set the new
4075 symbol indices into a symbol_map. */
4076
4115}
4116
4117/* Adjust and write out the symbols for an a.out file. Set the new
4118 symbol indices into a symbol_map. */
4119
4077static boolean
4120static bfd_boolean
4078aout_link_write_symbols (finfo, input_bfd)
4079 struct aout_final_link_info *finfo;
4080 bfd *input_bfd;
4081{
4082 bfd *output_bfd;
4083 bfd_size_type sym_count;
4084 char *strings;
4085 enum bfd_link_strip strip;
4086 enum bfd_link_discard discard;
4087 struct external_nlist *outsym;
4088 bfd_size_type strtab_index;
4089 register struct external_nlist *sym;
4090 struct external_nlist *sym_end;
4091 struct aout_link_hash_entry **sym_hash;
4092 int *symbol_map;
4121aout_link_write_symbols (finfo, input_bfd)
4122 struct aout_final_link_info *finfo;
4123 bfd *input_bfd;
4124{
4125 bfd *output_bfd;
4126 bfd_size_type sym_count;
4127 char *strings;
4128 enum bfd_link_strip strip;
4129 enum bfd_link_discard discard;
4130 struct external_nlist *outsym;
4131 bfd_size_type strtab_index;
4132 register struct external_nlist *sym;
4133 struct external_nlist *sym_end;
4134 struct aout_link_hash_entry **sym_hash;
4135 int *symbol_map;
4093 boolean pass;
4094 boolean skip_next;
4136 bfd_boolean pass;
4137 bfd_boolean skip_next;
4095
4096 output_bfd = finfo->output_bfd;
4097 sym_count = obj_aout_external_sym_count (input_bfd);
4098 strings = obj_aout_external_strings (input_bfd);
4099 strip = finfo->info->strip;
4100 discard = finfo->info->discard;
4101 outsym = finfo->output_syms;
4102
4103 /* First write out a symbol for this object file, unless we are
4104 discarding such symbols. */
4105 if (strip != strip_all
4106 && (strip != strip_some
4107 || bfd_hash_lookup (finfo->info->keep_hash, input_bfd->filename,
4138
4139 output_bfd = finfo->output_bfd;
4140 sym_count = obj_aout_external_sym_count (input_bfd);
4141 strings = obj_aout_external_strings (input_bfd);
4142 strip = finfo->info->strip;
4143 discard = finfo->info->discard;
4144 outsym = finfo->output_syms;
4145
4146 /* First write out a symbol for this object file, unless we are
4147 discarding such symbols. */
4148 if (strip != strip_all
4149 && (strip != strip_some
4150 || bfd_hash_lookup (finfo->info->keep_hash, input_bfd->filename,
4108 false, false) != NULL)
4151 FALSE, FALSE) != NULL)
4109 && discard != discard_all)
4110 {
4111 H_PUT_8 (output_bfd, N_TEXT, outsym->e_type);
4112 H_PUT_8 (output_bfd, 0, outsym->e_other);
4113 H_PUT_16 (output_bfd, 0, outsym->e_desc);
4114 strtab_index = add_to_stringtab (output_bfd, finfo->strtab,
4152 && discard != discard_all)
4153 {
4154 H_PUT_8 (output_bfd, N_TEXT, outsym->e_type);
4155 H_PUT_8 (output_bfd, 0, outsym->e_other);
4156 H_PUT_16 (output_bfd, 0, outsym->e_desc);
4157 strtab_index = add_to_stringtab (output_bfd, finfo->strtab,
4115 input_bfd->filename, false);
4158 input_bfd->filename, FALSE);
4116 if (strtab_index == (bfd_size_type) -1)
4159 if (strtab_index == (bfd_size_type) -1)
4117 return false;
4160 return FALSE;
4118 PUT_WORD (output_bfd, strtab_index, outsym->e_strx);
4119 PUT_WORD (output_bfd,
4120 (bfd_get_section_vma (output_bfd,
4121 obj_textsec (input_bfd)->output_section)
4122 + obj_textsec (input_bfd)->output_offset),
4123 outsym->e_value);
4124 ++obj_aout_external_sym_count (output_bfd);
4125 ++outsym;
4126 }
4127
4161 PUT_WORD (output_bfd, strtab_index, outsym->e_strx);
4162 PUT_WORD (output_bfd,
4163 (bfd_get_section_vma (output_bfd,
4164 obj_textsec (input_bfd)->output_section)
4165 + obj_textsec (input_bfd)->output_offset),
4166 outsym->e_value);
4167 ++obj_aout_external_sym_count (output_bfd);
4168 ++outsym;
4169 }
4170
4128 pass = false;
4129 skip_next = false;
4171 pass = FALSE;
4172 skip_next = FALSE;
4130 sym = obj_aout_external_syms (input_bfd);
4131 sym_end = sym + sym_count;
4132 sym_hash = obj_aout_sym_hashes (input_bfd);
4133 symbol_map = finfo->symbol_map;
4134 memset (symbol_map, 0, (size_t) sym_count * sizeof *symbol_map);
4135 for (; sym < sym_end; sym++, sym_hash++, symbol_map++)
4136 {
4137 const char *name;
4138 int type;
4139 struct aout_link_hash_entry *h;
4173 sym = obj_aout_external_syms (input_bfd);
4174 sym_end = sym + sym_count;
4175 sym_hash = obj_aout_sym_hashes (input_bfd);
4176 symbol_map = finfo->symbol_map;
4177 memset (symbol_map, 0, (size_t) sym_count * sizeof *symbol_map);
4178 for (; sym < sym_end; sym++, sym_hash++, symbol_map++)
4179 {
4180 const char *name;
4181 int type;
4182 struct aout_link_hash_entry *h;
4140 boolean skip;
4183 bfd_boolean skip;
4141 asection *symsec;
4142 bfd_vma val = 0;
4184 asection *symsec;
4185 bfd_vma val = 0;
4143 boolean copy;
4186 bfd_boolean copy;
4144
4145 /* We set *symbol_map to 0 above for all symbols. If it has
4146 already been set to -1 for this symbol, it means that we are
4147 discarding it because it appears in a duplicate header file.
4148 See the N_BINCL code below. */
4149 if (*symbol_map == -1)
4150 continue;
4151

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

4159
4160 h = NULL;
4161
4162 if (pass)
4163 {
4164 /* Pass this symbol through. It is the target of an
4165 indirect or warning symbol. */
4166 val = GET_WORD (input_bfd, sym->e_value);
4187
4188 /* We set *symbol_map to 0 above for all symbols. If it has
4189 already been set to -1 for this symbol, it means that we are
4190 discarding it because it appears in a duplicate header file.
4191 See the N_BINCL code below. */
4192 if (*symbol_map == -1)
4193 continue;
4194

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

4202
4203 h = NULL;
4204
4205 if (pass)
4206 {
4207 /* Pass this symbol through. It is the target of an
4208 indirect or warning symbol. */
4209 val = GET_WORD (input_bfd, sym->e_value);
4167 pass = false;
4210 pass = FALSE;
4168 }
4169 else if (skip_next)
4170 {
4171 /* Skip this symbol, which is the target of an indirect
4172 symbol that we have changed to no longer be an indirect
4173 symbol. */
4211 }
4212 else if (skip_next)
4213 {
4214 /* Skip this symbol, which is the target of an indirect
4215 symbol that we have changed to no longer be an indirect
4216 symbol. */
4174 skip_next = false;
4217 skip_next = FALSE;
4175 continue;
4176 }
4177 else
4178 {
4179 struct aout_link_hash_entry *hresolve;
4180
4181 /* We have saved the hash table entry for this symbol, if
4182 there is one. Note that we could just look it up again

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

4208 }
4209
4210 /* If the symbol has already been written out, skip it. */
4211 if (h != (struct aout_link_hash_entry *) NULL
4212 && h->written)
4213 {
4214 if ((type & N_TYPE) == N_INDR
4215 || type == N_WARNING)
4218 continue;
4219 }
4220 else
4221 {
4222 struct aout_link_hash_entry *hresolve;
4223
4224 /* We have saved the hash table entry for this symbol, if
4225 there is one. Note that we could just look it up again

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

4251 }
4252
4253 /* If the symbol has already been written out, skip it. */
4254 if (h != (struct aout_link_hash_entry *) NULL
4255 && h->written)
4256 {
4257 if ((type & N_TYPE) == N_INDR
4258 || type == N_WARNING)
4216 skip_next = true;
4259 skip_next = TRUE;
4217 *symbol_map = h->indx;
4218 continue;
4219 }
4220
4221 /* See if we are stripping this symbol. */
4260 *symbol_map = h->indx;
4261 continue;
4262 }
4263
4264 /* See if we are stripping this symbol. */
4222 skip = false;
4265 skip = FALSE;
4223 switch (strip)
4224 {
4225 case strip_none:
4226 break;
4227 case strip_debugger:
4228 if ((type & N_STAB) != 0)
4266 switch (strip)
4267 {
4268 case strip_none:
4269 break;
4270 case strip_debugger:
4271 if ((type & N_STAB) != 0)
4229 skip = true;
4272 skip = TRUE;
4230 break;
4231 case strip_some:
4273 break;
4274 case strip_some:
4232 if (bfd_hash_lookup (finfo->info->keep_hash, name, false, false)
4275 if (bfd_hash_lookup (finfo->info->keep_hash, name, FALSE, FALSE)
4233 == NULL)
4276 == NULL)
4234 skip = true;
4277 skip = TRUE;
4235 break;
4236 case strip_all:
4278 break;
4279 case strip_all:
4237 skip = true;
4280 skip = TRUE;
4238 break;
4239 }
4240 if (skip)
4241 {
4242 if (h != (struct aout_link_hash_entry *) NULL)
4281 break;
4282 }
4283 if (skip)
4284 {
4285 if (h != (struct aout_link_hash_entry *) NULL)
4243 h->written = true;
4286 h->written = TRUE;
4244 continue;
4245 }
4246
4247 /* Get the value of the symbol. */
4248 if ((type & N_TYPE) == N_TEXT
4249 || type == N_WEAKT)
4250 symsec = obj_textsec (input_bfd);
4251 else if ((type & N_TYPE) == N_DATA

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

4264 && hresolve->root.type != bfd_link_hash_common)))
4265 || type == N_WARNING)
4266 {
4267 /* Pass the next symbol through unchanged. The
4268 condition above for indirect symbols is so that if
4269 the indirect symbol was defined, we output it with
4270 the correct definition so the debugger will
4271 understand it. */
4287 continue;
4288 }
4289
4290 /* Get the value of the symbol. */
4291 if ((type & N_TYPE) == N_TEXT
4292 || type == N_WEAKT)
4293 symsec = obj_textsec (input_bfd);
4294 else if ((type & N_TYPE) == N_DATA

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

4307 && hresolve->root.type != bfd_link_hash_common)))
4308 || type == N_WARNING)
4309 {
4310 /* Pass the next symbol through unchanged. The
4311 condition above for indirect symbols is so that if
4312 the indirect symbol was defined, we output it with
4313 the correct definition so the debugger will
4314 understand it. */
4272 pass = true;
4315 pass = TRUE;
4273 val = GET_WORD (input_bfd, sym->e_value);
4274 symsec = NULL;
4275 }
4276 else if ((type & N_STAB) != 0)
4277 {
4278 val = GET_WORD (input_bfd, sym->e_value);
4279 symsec = NULL;
4280 }
4281 else
4282 {
4283 /* If we get here with an indirect symbol, it means that
4284 we are outputting it with a real definition. In such
4285 a case we do not want to output the next symbol,
4286 which is the target of the indirection. */
4287 if ((type & N_TYPE) == N_INDR)
4316 val = GET_WORD (input_bfd, sym->e_value);
4317 symsec = NULL;
4318 }
4319 else if ((type & N_STAB) != 0)
4320 {
4321 val = GET_WORD (input_bfd, sym->e_value);
4322 symsec = NULL;
4323 }
4324 else
4325 {
4326 /* If we get here with an indirect symbol, it means that
4327 we are outputting it with a real definition. In such
4328 a case we do not want to output the next symbol,
4329 which is the target of the indirection. */
4330 if ((type & N_TYPE) == N_INDR)
4288 skip_next = true;
4331 skip_next = TRUE;
4289
4290 symsec = NULL;
4291
4292 /* We need to get the value from the hash table. We use
4293 hresolve so that if we have defined an indirect
4294 symbol we output the final definition. */
4295 if (h == (struct aout_link_hash_entry *) NULL)
4296 {

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

4372 + symsec->output_offset
4373 + (GET_WORD (input_bfd, sym->e_value)
4374 - symsec->vma));
4375
4376 /* If this is a global symbol set the written flag, and if
4377 it is a local symbol see if we should discard it. */
4378 if (h != (struct aout_link_hash_entry *) NULL)
4379 {
4332
4333 symsec = NULL;
4334
4335 /* We need to get the value from the hash table. We use
4336 hresolve so that if we have defined an indirect
4337 symbol we output the final definition. */
4338 if (h == (struct aout_link_hash_entry *) NULL)
4339 {

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

4415 + symsec->output_offset
4416 + (GET_WORD (input_bfd, sym->e_value)
4417 - symsec->vma));
4418
4419 /* If this is a global symbol set the written flag, and if
4420 it is a local symbol see if we should discard it. */
4421 if (h != (struct aout_link_hash_entry *) NULL)
4422 {
4380 h->written = true;
4423 h->written = TRUE;
4381 h->indx = obj_aout_external_sym_count (output_bfd);
4382 }
4383 else if ((type & N_TYPE) != N_SETT
4384 && (type & N_TYPE) != N_SETD
4385 && (type & N_TYPE) != N_SETB
4386 && (type & N_TYPE) != N_SETA)
4387 {
4388 switch (discard)
4389 {
4390 case discard_none:
4391 case discard_sec_merge:
4392 break;
4393 case discard_l:
4394 if ((type & N_STAB) == 0
4395 && bfd_is_local_label_name (input_bfd, name))
4424 h->indx = obj_aout_external_sym_count (output_bfd);
4425 }
4426 else if ((type & N_TYPE) != N_SETT
4427 && (type & N_TYPE) != N_SETD
4428 && (type & N_TYPE) != N_SETB
4429 && (type & N_TYPE) != N_SETA)
4430 {
4431 switch (discard)
4432 {
4433 case discard_none:
4434 case discard_sec_merge:
4435 break;
4436 case discard_l:
4437 if ((type & N_STAB) == 0
4438 && bfd_is_local_label_name (input_bfd, name))
4396 skip = true;
4439 skip = TRUE;
4397 break;
4398 case discard_all:
4440 break;
4441 case discard_all:
4399 skip = true;
4442 skip = TRUE;
4400 break;
4401 }
4402 if (skip)
4403 {
4443 break;
4444 }
4445 if (skip)
4446 {
4404 pass = false;
4447 pass = FALSE;
4405 continue;
4406 }
4407 }
4408
4409 /* An N_BINCL symbol indicates the start of the stabs
4410 entries for a header file. We need to scan ahead to the
4411 next N_EINCL symbol, ignoring nesting, adding up all the
4412 characters in the symbol names, not including the file

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

4452 }
4453 }
4454 }
4455 }
4456
4457 /* If we have already included a header file with the
4458 same value, then replace this one with an N_EXCL
4459 symbol. */
4448 continue;
4449 }
4450 }
4451
4452 /* An N_BINCL symbol indicates the start of the stabs
4453 entries for a header file. We need to scan ahead to the
4454 next N_EINCL symbol, ignoring nesting, adding up all the
4455 characters in the symbol names, not including the file

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

4495 }
4496 }
4497 }
4498 }
4499
4500 /* If we have already included a header file with the
4501 same value, then replace this one with an N_EXCL
4502 symbol. */
4460 copy = (boolean) (! finfo->info->keep_memory);
4503 copy = (bfd_boolean) (! finfo->info->keep_memory);
4461 incl_entry = aout_link_includes_lookup (&finfo->includes,
4504 incl_entry = aout_link_includes_lookup (&finfo->includes,
4462 name, true, copy);
4505 name, TRUE, copy);
4463 if (incl_entry == NULL)
4506 if (incl_entry == NULL)
4464 return false;
4507 return FALSE;
4465 for (t = incl_entry->totals; t != NULL; t = t->next)
4466 if (t->total == val)
4467 break;
4468 if (t == NULL)
4469 {
4470 /* This is the first time we have seen this header
4471 file with this set of stabs strings. */
4472 t = ((struct aout_link_includes_totals *)
4473 bfd_hash_allocate (&finfo->includes.root,
4474 sizeof *t));
4475 if (t == NULL)
4508 for (t = incl_entry->totals; t != NULL; t = t->next)
4509 if (t->total == val)
4510 break;
4511 if (t == NULL)
4512 {
4513 /* This is the first time we have seen this header
4514 file with this set of stabs strings. */
4515 t = ((struct aout_link_includes_totals *)
4516 bfd_hash_allocate (&finfo->includes.root,
4517 sizeof *t));
4518 if (t == NULL)
4476 return false;
4519 return FALSE;
4477 t->total = val;
4478 t->next = incl_entry->totals;
4479 incl_entry->totals = t;
4480 }
4481 else
4482 {
4483 int *incl_map;
4484

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

4513 }
4514 }
4515
4516 /* Copy this symbol into the list of symbols we are going to
4517 write out. */
4518 H_PUT_8 (output_bfd, type, outsym->e_type);
4519 H_PUT_8 (output_bfd, H_GET_8 (input_bfd, sym->e_other), outsym->e_other);
4520 H_PUT_16 (output_bfd, H_GET_16 (input_bfd, sym->e_desc), outsym->e_desc);
4520 t->total = val;
4521 t->next = incl_entry->totals;
4522 incl_entry->totals = t;
4523 }
4524 else
4525 {
4526 int *incl_map;
4527

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

4556 }
4557 }
4558
4559 /* Copy this symbol into the list of symbols we are going to
4560 write out. */
4561 H_PUT_8 (output_bfd, type, outsym->e_type);
4562 H_PUT_8 (output_bfd, H_GET_8 (input_bfd, sym->e_other), outsym->e_other);
4563 H_PUT_16 (output_bfd, H_GET_16 (input_bfd, sym->e_desc), outsym->e_desc);
4521 copy = false;
4564 copy = FALSE;
4522 if (! finfo->info->keep_memory)
4523 {
4524 /* name points into a string table which we are going to
4525 free. If there is a hash table entry, use that string.
4526 Otherwise, copy name into memory. */
4527 if (h != (struct aout_link_hash_entry *) NULL)
4528 name = h->root.root.string;
4529 else
4565 if (! finfo->info->keep_memory)
4566 {
4567 /* name points into a string table which we are going to
4568 free. If there is a hash table entry, use that string.
4569 Otherwise, copy name into memory. */
4570 if (h != (struct aout_link_hash_entry *) NULL)
4571 name = h->root.root.string;
4572 else
4530 copy = true;
4573 copy = TRUE;
4531 }
4532 strtab_index = add_to_stringtab (output_bfd, finfo->strtab,
4533 name, copy);
4534 if (strtab_index == (bfd_size_type) -1)
4574 }
4575 strtab_index = add_to_stringtab (output_bfd, finfo->strtab,
4576 name, copy);
4577 if (strtab_index == (bfd_size_type) -1)
4535 return false;
4578 return FALSE;
4536 PUT_WORD (output_bfd, strtab_index, outsym->e_strx);
4537 PUT_WORD (output_bfd, val, outsym->e_value);
4538 *symbol_map = obj_aout_external_sym_count (output_bfd);
4539 ++obj_aout_external_sym_count (output_bfd);
4540 ++outsym;
4541 }
4542
4543 /* Write out the output symbols we have just constructed. */
4544 if (outsym > finfo->output_syms)
4545 {
4546 bfd_size_type outsym_size;
4547
4548 if (bfd_seek (output_bfd, finfo->symoff, SEEK_SET) != 0)
4579 PUT_WORD (output_bfd, strtab_index, outsym->e_strx);
4580 PUT_WORD (output_bfd, val, outsym->e_value);
4581 *symbol_map = obj_aout_external_sym_count (output_bfd);
4582 ++obj_aout_external_sym_count (output_bfd);
4583 ++outsym;
4584 }
4585
4586 /* Write out the output symbols we have just constructed. */
4587 if (outsym > finfo->output_syms)
4588 {
4589 bfd_size_type outsym_size;
4590
4591 if (bfd_seek (output_bfd, finfo->symoff, SEEK_SET) != 0)
4549 return false;
4592 return FALSE;
4550 outsym_size = outsym - finfo->output_syms;
4551 outsym_size *= EXTERNAL_NLIST_SIZE;
4552 if (bfd_bwrite ((PTR) finfo->output_syms, outsym_size, output_bfd)
4553 != outsym_size)
4593 outsym_size = outsym - finfo->output_syms;
4594 outsym_size *= EXTERNAL_NLIST_SIZE;
4595 if (bfd_bwrite ((PTR) finfo->output_syms, outsym_size, output_bfd)
4596 != outsym_size)
4554 return false;
4597 return FALSE;
4555 finfo->symoff += outsym_size;
4556 }
4557
4598 finfo->symoff += outsym_size;
4599 }
4600
4558 return true;
4601 return TRUE;
4559}
4560
4561/* Write out a symbol that was not associated with an a.out input
4562 object. */
4563
4602}
4603
4604/* Write out a symbol that was not associated with an a.out input
4605 object. */
4606
4564static boolean
4607static bfd_boolean
4565aout_link_write_other_symbol (h, data)
4566 struct aout_link_hash_entry *h;
4567 PTR data;
4568{
4569 struct aout_final_link_info *finfo = (struct aout_final_link_info *) data;
4570 bfd *output_bfd;
4571 int type;
4572 bfd_vma val;
4573 struct external_nlist outsym;
4574 bfd_size_type indx;
4575 bfd_size_type amt;
4576
4577 if (h->root.type == bfd_link_hash_warning)
4578 {
4579 h = (struct aout_link_hash_entry *) h->root.u.i.link;
4580 if (h->root.type == bfd_link_hash_new)
4608aout_link_write_other_symbol (h, data)
4609 struct aout_link_hash_entry *h;
4610 PTR data;
4611{
4612 struct aout_final_link_info *finfo = (struct aout_final_link_info *) data;
4613 bfd *output_bfd;
4614 int type;
4615 bfd_vma val;
4616 struct external_nlist outsym;
4617 bfd_size_type indx;
4618 bfd_size_type amt;
4619
4620 if (h->root.type == bfd_link_hash_warning)
4621 {
4622 h = (struct aout_link_hash_entry *) h->root.u.i.link;
4623 if (h->root.type == bfd_link_hash_new)
4581 return true;
4624 return TRUE;
4582 }
4583
4584 output_bfd = finfo->output_bfd;
4585
4586 if (aout_backend_info (output_bfd)->write_dynamic_symbol != NULL)
4587 {
4588 if (! ((*aout_backend_info (output_bfd)->write_dynamic_symbol)
4589 (output_bfd, finfo->info, h)))
4590 {
4591 /* FIXME: No way to handle errors. */
4592 abort ();
4593 }
4594 }
4595
4596 if (h->written)
4625 }
4626
4627 output_bfd = finfo->output_bfd;
4628
4629 if (aout_backend_info (output_bfd)->write_dynamic_symbol != NULL)
4630 {
4631 if (! ((*aout_backend_info (output_bfd)->write_dynamic_symbol)
4632 (output_bfd, finfo->info, h)))
4633 {
4634 /* FIXME: No way to handle errors. */
4635 abort ();
4636 }
4637 }
4638
4639 if (h->written)
4597 return true;
4640 return TRUE;
4598
4641
4599 h->written = true;
4642 h->written = TRUE;
4600
4601 /* An indx of -2 means the symbol must be written. */
4602 if (h->indx != -2
4603 && (finfo->info->strip == strip_all
4604 || (finfo->info->strip == strip_some
4605 && bfd_hash_lookup (finfo->info->keep_hash, h->root.root.string,
4643
4644 /* An indx of -2 means the symbol must be written. */
4645 if (h->indx != -2
4646 && (finfo->info->strip == strip_all
4647 || (finfo->info->strip == strip_some
4648 && bfd_hash_lookup (finfo->info->keep_hash, h->root.root.string,
4606 false, false) == NULL)))
4607 return true;
4649 FALSE, FALSE) == NULL)))
4650 return TRUE;
4608
4609 switch (h->root.type)
4610 {
4611 default:
4612 case bfd_link_hash_warning:
4613 abort ();
4614 /* Avoid variable not initialized warnings. */
4651
4652 switch (h->root.type)
4653 {
4654 default:
4655 case bfd_link_hash_warning:
4656 abort ();
4657 /* Avoid variable not initialized warnings. */
4615 return true;
4658 return TRUE;
4616 case bfd_link_hash_new:
4617 /* This can happen for set symbols when sets are not being
4618 built. */
4659 case bfd_link_hash_new:
4660 /* This can happen for set symbols when sets are not being
4661 built. */
4619 return true;
4662 return TRUE;
4620 case bfd_link_hash_undefined:
4621 type = N_UNDF | N_EXT;
4622 val = 0;
4623 break;
4624 case bfd_link_hash_defined:
4625 case bfd_link_hash_defweak:
4626 {
4627 asection *sec;

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

4648 val = h->root.u.c.size;
4649 break;
4650 case bfd_link_hash_undefweak:
4651 type = N_WEAKU;
4652 val = 0;
4653 case bfd_link_hash_indirect:
4654 /* We ignore these symbols, since the indirected symbol is
4655 already in the hash table. */
4663 case bfd_link_hash_undefined:
4664 type = N_UNDF | N_EXT;
4665 val = 0;
4666 break;
4667 case bfd_link_hash_defined:
4668 case bfd_link_hash_defweak:
4669 {
4670 asection *sec;

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

4691 val = h->root.u.c.size;
4692 break;
4693 case bfd_link_hash_undefweak:
4694 type = N_WEAKU;
4695 val = 0;
4696 case bfd_link_hash_indirect:
4697 /* We ignore these symbols, since the indirected symbol is
4698 already in the hash table. */
4656 return true;
4699 return TRUE;
4657 }
4658
4659 H_PUT_8 (output_bfd, type, outsym.e_type);
4660 H_PUT_8 (output_bfd, 0, outsym.e_other);
4661 H_PUT_16 (output_bfd, 0, outsym.e_desc);
4662 indx = add_to_stringtab (output_bfd, finfo->strtab, h->root.root.string,
4700 }
4701
4702 H_PUT_8 (output_bfd, type, outsym.e_type);
4703 H_PUT_8 (output_bfd, 0, outsym.e_other);
4704 H_PUT_16 (output_bfd, 0, outsym.e_desc);
4705 indx = add_to_stringtab (output_bfd, finfo->strtab, h->root.root.string,
4663 false);
4706 FALSE);
4664 if (indx == - (bfd_size_type) 1)
4665 {
4666 /* FIXME: No way to handle errors. */
4667 abort ();
4668 }
4669 PUT_WORD (output_bfd, indx, outsym.e_strx);
4670 PUT_WORD (output_bfd, val, outsym.e_value);
4671

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

4676 /* FIXME: No way to handle errors. */
4677 abort ();
4678 }
4679
4680 finfo->symoff += EXTERNAL_NLIST_SIZE;
4681 h->indx = obj_aout_external_sym_count (output_bfd);
4682 ++obj_aout_external_sym_count (output_bfd);
4683
4707 if (indx == - (bfd_size_type) 1)
4708 {
4709 /* FIXME: No way to handle errors. */
4710 abort ();
4711 }
4712 PUT_WORD (output_bfd, indx, outsym.e_strx);
4713 PUT_WORD (output_bfd, val, outsym.e_value);
4714

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

4719 /* FIXME: No way to handle errors. */
4720 abort ();
4721 }
4722
4723 finfo->symoff += EXTERNAL_NLIST_SIZE;
4724 h->indx = obj_aout_external_sym_count (output_bfd);
4725 ++obj_aout_external_sym_count (output_bfd);
4726
4684 return true;
4727 return TRUE;
4685}
4686
4687/* Link an a.out section into the output file. */
4688
4728}
4729
4730/* Link an a.out section into the output file. */
4731
4689static boolean
4732static bfd_boolean
4690aout_link_input_section (finfo, input_bfd, input_section, reloff_ptr,
4691 rel_size)
4692 struct aout_final_link_info *finfo;
4693 bfd *input_bfd;
4694 asection *input_section;
4695 file_ptr *reloff_ptr;
4696 bfd_size_type rel_size;
4697{
4698 bfd_size_type input_size;
4699 PTR relocs;
4700
4701 /* Get the section contents. */
4702 input_size = bfd_section_size (input_bfd, input_section);
4703 if (! bfd_get_section_contents (input_bfd, input_section,
4704 (PTR) finfo->contents,
4705 (file_ptr) 0, input_size))
4733aout_link_input_section (finfo, input_bfd, input_section, reloff_ptr,
4734 rel_size)
4735 struct aout_final_link_info *finfo;
4736 bfd *input_bfd;
4737 asection *input_section;
4738 file_ptr *reloff_ptr;
4739 bfd_size_type rel_size;
4740{
4741 bfd_size_type input_size;
4742 PTR relocs;
4743
4744 /* Get the section contents. */
4745 input_size = bfd_section_size (input_bfd, input_section);
4746 if (! bfd_get_section_contents (input_bfd, input_section,
4747 (PTR) finfo->contents,
4748 (file_ptr) 0, input_size))
4706 return false;
4749 return FALSE;
4707
4708 /* Read in the relocs if we haven't already done it. */
4709 if (aout_section_data (input_section) != NULL
4710 && aout_section_data (input_section)->relocs != NULL)
4711 relocs = aout_section_data (input_section)->relocs;
4712 else
4713 {
4714 relocs = finfo->relocs;
4715 if (rel_size > 0)
4716 {
4717 if (bfd_seek (input_bfd, input_section->rel_filepos, SEEK_SET) != 0
4718 || bfd_bread (relocs, rel_size, input_bfd) != rel_size)
4750
4751 /* Read in the relocs if we haven't already done it. */
4752 if (aout_section_data (input_section) != NULL
4753 && aout_section_data (input_section)->relocs != NULL)
4754 relocs = aout_section_data (input_section)->relocs;
4755 else
4756 {
4757 relocs = finfo->relocs;
4758 if (rel_size > 0)
4759 {
4760 if (bfd_seek (input_bfd, input_section->rel_filepos, SEEK_SET) != 0
4761 || bfd_bread (relocs, rel_size, input_bfd) != rel_size)
4719 return false;
4762 return FALSE;
4720 }
4721 }
4722
4723 /* Relocate the section contents. */
4724 if (obj_reloc_entry_size (input_bfd) == RELOC_STD_SIZE)
4725 {
4726 if (! aout_link_input_section_std (finfo, input_bfd, input_section,
4727 (struct reloc_std_external *) relocs,
4728 rel_size, finfo->contents))
4763 }
4764 }
4765
4766 /* Relocate the section contents. */
4767 if (obj_reloc_entry_size (input_bfd) == RELOC_STD_SIZE)
4768 {
4769 if (! aout_link_input_section_std (finfo, input_bfd, input_section,
4770 (struct reloc_std_external *) relocs,
4771 rel_size, finfo->contents))
4729 return false;
4772 return FALSE;
4730 }
4731 else
4732 {
4733 if (! aout_link_input_section_ext (finfo, input_bfd, input_section,
4734 (struct reloc_ext_external *) relocs,
4735 rel_size, finfo->contents))
4773 }
4774 else
4775 {
4776 if (! aout_link_input_section_ext (finfo, input_bfd, input_section,
4777 (struct reloc_ext_external *) relocs,
4778 rel_size, finfo->contents))
4736 return false;
4779 return FALSE;
4737 }
4738
4739 /* Write out the section contents. */
4740 if (! bfd_set_section_contents (finfo->output_bfd,
4741 input_section->output_section,
4742 (PTR) finfo->contents,
4743 (file_ptr) input_section->output_offset,
4744 input_size))
4780 }
4781
4782 /* Write out the section contents. */
4783 if (! bfd_set_section_contents (finfo->output_bfd,
4784 input_section->output_section,
4785 (PTR) finfo->contents,
4786 (file_ptr) input_section->output_offset,
4787 input_size))
4745 return false;
4788 return FALSE;
4746
4789
4747 /* If we are producing relocateable output, the relocs were
4790 /* If we are producing relocatable output, the relocs were
4748 modified, and we now write them out. */
4791 modified, and we now write them out. */
4749 if (finfo->info->relocateable && rel_size > 0)
4792 if (finfo->info->relocatable && rel_size > 0)
4750 {
4751 if (bfd_seek (finfo->output_bfd, *reloff_ptr, SEEK_SET) != 0)
4793 {
4794 if (bfd_seek (finfo->output_bfd, *reloff_ptr, SEEK_SET) != 0)
4752 return false;
4795 return FALSE;
4753 if (bfd_bwrite (relocs, rel_size, finfo->output_bfd) != rel_size)
4796 if (bfd_bwrite (relocs, rel_size, finfo->output_bfd) != rel_size)
4754 return false;
4797 return FALSE;
4755 *reloff_ptr += rel_size;
4756
4757 /* Assert that the relocs have not run into the symbols, and
4758 that if these are the text relocs they have not run into the
4759 data relocs. */
4760 BFD_ASSERT (*reloff_ptr <= obj_sym_filepos (finfo->output_bfd)
4761 && (reloff_ptr != &finfo->treloff
4762 || (*reloff_ptr
4763 <= obj_datasec (finfo->output_bfd)->rel_filepos)));
4764 }
4765
4798 *reloff_ptr += rel_size;
4799
4800 /* Assert that the relocs have not run into the symbols, and
4801 that if these are the text relocs they have not run into the
4802 data relocs. */
4803 BFD_ASSERT (*reloff_ptr <= obj_sym_filepos (finfo->output_bfd)
4804 && (reloff_ptr != &finfo->treloff
4805 || (*reloff_ptr
4806 <= obj_datasec (finfo->output_bfd)->rel_filepos)));
4807 }
4808
4766 return true;
4809 return TRUE;
4767}
4768
4769/* Get the section corresponding to a reloc index. */
4770
4771static INLINE asection *
4772aout_reloc_index_to_section (abfd, indx)
4773 bfd *abfd;
4774 int indx;

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

4788 abort ();
4789 }
4790 /*NOTREACHED*/
4791 return NULL;
4792}
4793
4794/* Relocate an a.out section using standard a.out relocs. */
4795
4810}
4811
4812/* Get the section corresponding to a reloc index. */
4813
4814static INLINE asection *
4815aout_reloc_index_to_section (abfd, indx)
4816 bfd *abfd;
4817 int indx;

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

4831 abort ();
4832 }
4833 /*NOTREACHED*/
4834 return NULL;
4835}
4836
4837/* Relocate an a.out section using standard a.out relocs. */
4838
4796static boolean
4839static bfd_boolean
4797aout_link_input_section_std (finfo, input_bfd, input_section, relocs,
4798 rel_size, contents)
4799 struct aout_final_link_info *finfo;
4800 bfd *input_bfd;
4801 asection *input_section;
4802 struct reloc_std_external *relocs;
4803 bfd_size_type rel_size;
4804 bfd_byte *contents;
4805{
4840aout_link_input_section_std (finfo, input_bfd, input_section, relocs,
4841 rel_size, contents)
4842 struct aout_final_link_info *finfo;
4843 bfd *input_bfd;
4844 asection *input_section;
4845 struct reloc_std_external *relocs;
4846 bfd_size_type rel_size;
4847 bfd_byte *contents;
4848{
4806 boolean (*check_dynamic_reloc) PARAMS ((struct bfd_link_info *,
4807 bfd *, asection *,
4808 struct aout_link_hash_entry *,
4809 PTR, bfd_byte *, boolean *,
4810 bfd_vma *));
4849 bfd_boolean (*check_dynamic_reloc)
4850 PARAMS ((struct bfd_link_info *, bfd *, asection *,
4851 struct aout_link_hash_entry *, PTR, bfd_byte *, bfd_boolean *,
4852 bfd_vma *));
4811 bfd *output_bfd;
4853 bfd *output_bfd;
4812 boolean relocateable;
4854 bfd_boolean relocatable;
4813 struct external_nlist *syms;
4814 char *strings;
4815 struct aout_link_hash_entry **sym_hashes;
4816 int *symbol_map;
4817 bfd_size_type reloc_count;
4818 register struct reloc_std_external *rel;
4819 struct reloc_std_external *rel_end;
4820
4821 output_bfd = finfo->output_bfd;
4822 check_dynamic_reloc = aout_backend_info (output_bfd)->check_dynamic_reloc;
4823
4824 BFD_ASSERT (obj_reloc_entry_size (input_bfd) == RELOC_STD_SIZE);
4825 BFD_ASSERT (input_bfd->xvec->header_byteorder
4826 == output_bfd->xvec->header_byteorder);
4827
4855 struct external_nlist *syms;
4856 char *strings;
4857 struct aout_link_hash_entry **sym_hashes;
4858 int *symbol_map;
4859 bfd_size_type reloc_count;
4860 register struct reloc_std_external *rel;
4861 struct reloc_std_external *rel_end;
4862
4863 output_bfd = finfo->output_bfd;
4864 check_dynamic_reloc = aout_backend_info (output_bfd)->check_dynamic_reloc;
4865
4866 BFD_ASSERT (obj_reloc_entry_size (input_bfd) == RELOC_STD_SIZE);
4867 BFD_ASSERT (input_bfd->xvec->header_byteorder
4868 == output_bfd->xvec->header_byteorder);
4869
4828 relocateable = finfo->info->relocateable;
4870 relocatable = finfo->info->relocatable;
4829 syms = obj_aout_external_syms (input_bfd);
4830 strings = obj_aout_external_strings (input_bfd);
4831 sym_hashes = obj_aout_sym_hashes (input_bfd);
4832 symbol_map = finfo->symbol_map;
4833
4834 reloc_count = rel_size / RELOC_STD_SIZE;
4835 rel = relocs;
4836 rel_end = rel + reloc_count;

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

4889
4890 howto_idx = (r_length + 4 * r_pcrel + 8 * r_baserel
4891 + 16 * r_jmptable + 32 * r_relative);
4892 BFD_ASSERT (howto_idx < TABLE_SIZE (howto_table_std));
4893 howto = howto_table_std + howto_idx;
4894 }
4895#endif
4896
4871 syms = obj_aout_external_syms (input_bfd);
4872 strings = obj_aout_external_strings (input_bfd);
4873 sym_hashes = obj_aout_sym_hashes (input_bfd);
4874 symbol_map = finfo->symbol_map;
4875
4876 reloc_count = rel_size / RELOC_STD_SIZE;
4877 rel = relocs;
4878 rel_end = rel + reloc_count;

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

4931
4932 howto_idx = (r_length + 4 * r_pcrel + 8 * r_baserel
4933 + 16 * r_jmptable + 32 * r_relative);
4934 BFD_ASSERT (howto_idx < TABLE_SIZE (howto_table_std));
4935 howto = howto_table_std + howto_idx;
4936 }
4937#endif
4938
4897 if (relocateable)
4939 if (relocatable)
4898 {
4940 {
4899 /* We are generating a relocateable output file, and must
4941 /* We are generating a relocatable output file, and must
4900 modify the reloc accordingly. */
4901 if (r_extern)
4902 {
4903 /* If we know the symbol this relocation is against,
4904 convert it into a relocation against a section. This
4905 is what the native linker does. */
4906 h = sym_hashes[r_index];
4907 if (h != (struct aout_link_hash_entry *) NULL

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

4946 /* We decided to strip this symbol, but it
4947 turns out that we can't. Note that we
4948 lose the other and desc information here.
4949 I don't think that will ever matter for a
4950 global symbol. */
4951 if (h->indx < 0)
4952 {
4953 h->indx = -2;
4942 modify the reloc accordingly. */
4943 if (r_extern)
4944 {
4945 /* If we know the symbol this relocation is against,
4946 convert it into a relocation against a section. This
4947 is what the native linker does. */
4948 h = sym_hashes[r_index];
4949 if (h != (struct aout_link_hash_entry *) NULL

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

4988 /* We decided to strip this symbol, but it
4989 turns out that we can't. Note that we
4990 lose the other and desc information here.
4991 I don't think that will ever matter for a
4992 global symbol. */
4993 if (h->indx < 0)
4994 {
4995 h->indx = -2;
4954 h->written = false;
4996 h->written = FALSE;
4955 if (! aout_link_write_other_symbol (h,
4956 (PTR) finfo))
4997 if (! aout_link_write_other_symbol (h,
4998 (PTR) finfo))
4957 return false;
4999 return FALSE;
4958 }
4959 r_index = h->indx;
4960 }
4961 else
4962 {
4963 const char *name;
4964
4965 name = strings + GET_WORD (input_bfd,
4966 syms[r_index].e_strx);
4967 if (! ((*finfo->info->callbacks->unattached_reloc)
4968 (finfo->info, name, input_bfd, input_section,
4969 r_addr)))
5000 }
5001 r_index = h->indx;
5002 }
5003 else
5004 {
5005 const char *name;
5006
5007 name = strings + GET_WORD (input_bfd,
5008 syms[r_index].e_strx);
5009 if (! ((*finfo->info->callbacks->unattached_reloc)
5010 (finfo->info, name, input_bfd, input_section,
5011 r_addr)))
4970 return false;
5012 return FALSE;
4971 r_index = 0;
4972 }
4973 }
4974
4975 relocation = 0;
4976 }
4977
4978 /* Write out the new r_index value. */

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

5022 r = bfd_reloc_ok;
5023 else
5024 r = MY_relocate_contents (howto,
5025 input_bfd, relocation,
5026 contents + r_addr);
5027 }
5028 else
5029 {
5013 r_index = 0;
5014 }
5015 }
5016
5017 relocation = 0;
5018 }
5019
5020 /* Write out the new r_index value. */

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

5064 r = bfd_reloc_ok;
5065 else
5066 r = MY_relocate_contents (howto,
5067 input_bfd, relocation,
5068 contents + r_addr);
5069 }
5070 else
5071 {
5030 boolean hundef;
5072 bfd_boolean hundef;
5031
5032 /* We are generating an executable, and must do a full
5033 relocation. */
5073
5074 /* We are generating an executable, and must do a full
5075 relocation. */
5034 hundef = false;
5076 hundef = FALSE;
5035
5036 if (r_extern)
5037 {
5038 h = sym_hashes[r_index];
5039
5040 if (h != (struct aout_link_hash_entry *) NULL
5041 && (h->root.type == bfd_link_hash_defined
5042 || h->root.type == bfd_link_hash_defweak))
5043 {
5044 relocation = (h->root.u.def.value
5045 + h->root.u.def.section->output_section->vma
5046 + h->root.u.def.section->output_offset);
5047 }
5048 else if (h != (struct aout_link_hash_entry *) NULL
5049 && h->root.type == bfd_link_hash_undefweak)
5050 relocation = 0;
5051 else
5052 {
5077
5078 if (r_extern)
5079 {
5080 h = sym_hashes[r_index];
5081
5082 if (h != (struct aout_link_hash_entry *) NULL
5083 && (h->root.type == bfd_link_hash_defined
5084 || h->root.type == bfd_link_hash_defweak))
5085 {
5086 relocation = (h->root.u.def.value
5087 + h->root.u.def.section->output_section->vma
5088 + h->root.u.def.section->output_offset);
5089 }
5090 else if (h != (struct aout_link_hash_entry *) NULL
5091 && h->root.type == bfd_link_hash_undefweak)
5092 relocation = 0;
5093 else
5094 {
5053 hundef = true;
5095 hundef = TRUE;
5054 relocation = 0;
5055 }
5056 }
5057 else
5058 {
5059 asection *section;
5060
5061 section = aout_reloc_index_to_section (input_bfd, r_index);
5062 relocation = (section->output_section->vma
5063 + section->output_offset
5064 - section->vma);
5065 if (r_pcrel)
5066 relocation += input_section->vma;
5067 }
5068
5069 if (check_dynamic_reloc != NULL)
5070 {
5096 relocation = 0;
5097 }
5098 }
5099 else
5100 {
5101 asection *section;
5102
5103 section = aout_reloc_index_to_section (input_bfd, r_index);
5104 relocation = (section->output_section->vma
5105 + section->output_offset
5106 - section->vma);
5107 if (r_pcrel)
5108 relocation += input_section->vma;
5109 }
5110
5111 if (check_dynamic_reloc != NULL)
5112 {
5071 boolean skip;
5113 bfd_boolean skip;
5072
5073 if (! ((*check_dynamic_reloc)
5074 (finfo->info, input_bfd, input_section, h,
5075 (PTR) rel, contents, &skip, &relocation)))
5114
5115 if (! ((*check_dynamic_reloc)
5116 (finfo->info, input_bfd, input_section, h,
5117 (PTR) rel, contents, &skip, &relocation)))
5076 return false;
5118 return FALSE;
5077 if (skip)
5078 continue;
5079 }
5080
5081 /* Now warn if a global symbol is undefined. We could not
5082 do this earlier, because check_dynamic_reloc might want
5083 to skip this reloc. */
5084 if (hundef && ! finfo->info->shared && ! r_baserel)
5085 {
5086 const char *name;
5087
5088 if (h != NULL)
5089 name = h->root.root.string;
5090 else
5091 name = strings + GET_WORD (input_bfd, syms[r_index].e_strx);
5092 if (! ((*finfo->info->callbacks->undefined_symbol)
5093 (finfo->info, name, input_bfd, input_section,
5119 if (skip)
5120 continue;
5121 }
5122
5123 /* Now warn if a global symbol is undefined. We could not
5124 do this earlier, because check_dynamic_reloc might want
5125 to skip this reloc. */
5126 if (hundef && ! finfo->info->shared && ! r_baserel)
5127 {
5128 const char *name;
5129
5130 if (h != NULL)
5131 name = h->root.root.string;
5132 else
5133 name = strings + GET_WORD (input_bfd, syms[r_index].e_strx);
5134 if (! ((*finfo->info->callbacks->undefined_symbol)
5135 (finfo->info, name, input_bfd, input_section,
5094 r_addr, true)))
5095 return false;
5136 r_addr, TRUE)))
5137 return FALSE;
5096 }
5097
5098 r = MY_final_link_relocate (howto,
5099 input_bfd, input_section,
5100 contents, r_addr, relocation,
5101 (bfd_vma) 0);
5102 }
5103

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

5122 asection *s;
5123
5124 s = aout_reloc_index_to_section (input_bfd, r_index);
5125 name = bfd_section_name (input_bfd, s);
5126 }
5127 if (! ((*finfo->info->callbacks->reloc_overflow)
5128 (finfo->info, name, howto->name,
5129 (bfd_vma) 0, input_bfd, input_section, r_addr)))
5138 }
5139
5140 r = MY_final_link_relocate (howto,
5141 input_bfd, input_section,
5142 contents, r_addr, relocation,
5143 (bfd_vma) 0);
5144 }
5145

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

5164 asection *s;
5165
5166 s = aout_reloc_index_to_section (input_bfd, r_index);
5167 name = bfd_section_name (input_bfd, s);
5168 }
5169 if (! ((*finfo->info->callbacks->reloc_overflow)
5170 (finfo->info, name, howto->name,
5171 (bfd_vma) 0, input_bfd, input_section, r_addr)))
5130 return false;
5172 return FALSE;
5131 }
5132 break;
5133 }
5134 }
5135 }
5136
5173 }
5174 break;
5175 }
5176 }
5177 }
5178
5137 return true;
5179 return TRUE;
5138}
5139
5140/* Relocate an a.out section using extended a.out relocs. */
5141
5180}
5181
5182/* Relocate an a.out section using extended a.out relocs. */
5183
5142static boolean
5184static bfd_boolean
5143aout_link_input_section_ext (finfo, input_bfd, input_section, relocs,
5144 rel_size, contents)
5145 struct aout_final_link_info *finfo;
5146 bfd *input_bfd;
5147 asection *input_section;
5148 struct reloc_ext_external *relocs;
5149 bfd_size_type rel_size;
5150 bfd_byte *contents;
5151{
5185aout_link_input_section_ext (finfo, input_bfd, input_section, relocs,
5186 rel_size, contents)
5187 struct aout_final_link_info *finfo;
5188 bfd *input_bfd;
5189 asection *input_section;
5190 struct reloc_ext_external *relocs;
5191 bfd_size_type rel_size;
5192 bfd_byte *contents;
5193{
5152 boolean (*check_dynamic_reloc) PARAMS ((struct bfd_link_info *,
5153 bfd *, asection *,
5154 struct aout_link_hash_entry *,
5155 PTR, bfd_byte *, boolean *,
5156 bfd_vma *));
5194 bfd_boolean (*check_dynamic_reloc)
5195 PARAMS ((struct bfd_link_info *, bfd *, asection *,
5196 struct aout_link_hash_entry *, PTR, bfd_byte *, bfd_boolean *,
5197 bfd_vma *));
5157 bfd *output_bfd;
5198 bfd *output_bfd;
5158 boolean relocateable;
5199 bfd_boolean relocatable;
5159 struct external_nlist *syms;
5160 char *strings;
5161 struct aout_link_hash_entry **sym_hashes;
5162 int *symbol_map;
5163 bfd_size_type reloc_count;
5164 register struct reloc_ext_external *rel;
5165 struct reloc_ext_external *rel_end;
5166
5167 output_bfd = finfo->output_bfd;
5168 check_dynamic_reloc = aout_backend_info (output_bfd)->check_dynamic_reloc;
5169
5170 BFD_ASSERT (obj_reloc_entry_size (input_bfd) == RELOC_EXT_SIZE);
5171 BFD_ASSERT (input_bfd->xvec->header_byteorder
5172 == output_bfd->xvec->header_byteorder);
5173
5200 struct external_nlist *syms;
5201 char *strings;
5202 struct aout_link_hash_entry **sym_hashes;
5203 int *symbol_map;
5204 bfd_size_type reloc_count;
5205 register struct reloc_ext_external *rel;
5206 struct reloc_ext_external *rel_end;
5207
5208 output_bfd = finfo->output_bfd;
5209 check_dynamic_reloc = aout_backend_info (output_bfd)->check_dynamic_reloc;
5210
5211 BFD_ASSERT (obj_reloc_entry_size (input_bfd) == RELOC_EXT_SIZE);
5212 BFD_ASSERT (input_bfd->xvec->header_byteorder
5213 == output_bfd->xvec->header_byteorder);
5214
5174 relocateable = finfo->info->relocateable;
5215 relocatable = finfo->info->relocatable;
5175 syms = obj_aout_external_syms (input_bfd);
5176 strings = obj_aout_external_strings (input_bfd);
5177 sym_hashes = obj_aout_sym_hashes (input_bfd);
5178 symbol_map = finfo->symbol_map;
5179
5180 reloc_count = rel_size / RELOC_EXT_SIZE;
5181 rel = relocs;
5182 rel_end = rel + reloc_count;

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

5211 r_type = ((rel->r_type[0] & RELOC_EXT_BITS_TYPE_LITTLE)
5212 >> RELOC_EXT_BITS_TYPE_SH_LITTLE);
5213 }
5214
5215 r_addend = GET_SWORD (input_bfd, rel->r_addend);
5216
5217 BFD_ASSERT (r_type < TABLE_SIZE (howto_table_ext));
5218
5216 syms = obj_aout_external_syms (input_bfd);
5217 strings = obj_aout_external_strings (input_bfd);
5218 sym_hashes = obj_aout_sym_hashes (input_bfd);
5219 symbol_map = finfo->symbol_map;
5220
5221 reloc_count = rel_size / RELOC_EXT_SIZE;
5222 rel = relocs;
5223 rel_end = rel + reloc_count;

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

5252 r_type = ((rel->r_type[0] & RELOC_EXT_BITS_TYPE_LITTLE)
5253 >> RELOC_EXT_BITS_TYPE_SH_LITTLE);
5254 }
5255
5256 r_addend = GET_SWORD (input_bfd, rel->r_addend);
5257
5258 BFD_ASSERT (r_type < TABLE_SIZE (howto_table_ext));
5259
5219 if (relocateable)
5260 if (relocatable)
5220 {
5261 {
5221 /* We are generating a relocateable output file, and must
5262 /* We are generating a relocatable output file, and must
5222 modify the reloc accordingly. */
5223 if (r_extern
5224 || r_type == (unsigned int) RELOC_BASE10
5225 || r_type == (unsigned int) RELOC_BASE13
5226 || r_type == (unsigned int) RELOC_BASE22)
5227 {
5228 /* If we know the symbol this relocation is against,
5229 convert it into a relocation against a section. This

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

5284 /* We decided to strip this symbol, but it
5285 turns out that we can't. Note that we
5286 lose the other and desc information here.
5287 I don't think that will ever matter for a
5288 global symbol. */
5289 if (h->indx < 0)
5290 {
5291 h->indx = -2;
5263 modify the reloc accordingly. */
5264 if (r_extern
5265 || r_type == (unsigned int) RELOC_BASE10
5266 || r_type == (unsigned int) RELOC_BASE13
5267 || r_type == (unsigned int) RELOC_BASE22)
5268 {
5269 /* If we know the symbol this relocation is against,
5270 convert it into a relocation against a section. This

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

5325 /* We decided to strip this symbol, but it
5326 turns out that we can't. Note that we
5327 lose the other and desc information here.
5328 I don't think that will ever matter for a
5329 global symbol. */
5330 if (h->indx < 0)
5331 {
5332 h->indx = -2;
5292 h->written = false;
5333 h->written = FALSE;
5293 if (! aout_link_write_other_symbol (h,
5294 (PTR) finfo))
5334 if (! aout_link_write_other_symbol (h,
5335 (PTR) finfo))
5295 return false;
5336 return FALSE;
5296 }
5297 r_index = h->indx;
5298 }
5299 else
5300 {
5301 const char *name;
5302
5303 name = strings + GET_WORD (input_bfd,
5304 syms[r_index].e_strx);
5305 if (! ((*finfo->info->callbacks->unattached_reloc)
5306 (finfo->info, name, input_bfd, input_section,
5307 r_addr)))
5337 }
5338 r_index = h->indx;
5339 }
5340 else
5341 {
5342 const char *name;
5343
5344 name = strings + GET_WORD (input_bfd,
5345 syms[r_index].e_strx);
5346 if (! ((*finfo->info->callbacks->unattached_reloc)
5347 (finfo->info, name, input_bfd, input_section,
5348 r_addr)))
5308 return false;
5349 return FALSE;
5309 r_index = 0;
5310 }
5311 }
5312
5313 relocation = 0;
5314
5315 /* If this is a PC relative reloc, then the addend
5316 is the negative of the source VMA. We must

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

5365
5366 /* Change the address of the relocation. */
5367 PUT_WORD (output_bfd,
5368 r_addr + input_section->output_offset,
5369 rel->r_address);
5370 }
5371 else
5372 {
5350 r_index = 0;
5351 }
5352 }
5353
5354 relocation = 0;
5355
5356 /* If this is a PC relative reloc, then the addend
5357 is the negative of the source VMA. We must

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

5406
5407 /* Change the address of the relocation. */
5408 PUT_WORD (output_bfd,
5409 r_addr + input_section->output_offset,
5410 rel->r_address);
5411 }
5412 else
5413 {
5373 boolean hundef;
5414 bfd_boolean hundef;
5374 bfd_reloc_status_type r;
5375
5376 /* We are generating an executable, and must do a full
5377 relocation. */
5415 bfd_reloc_status_type r;
5416
5417 /* We are generating an executable, and must do a full
5418 relocation. */
5378 hundef = false;
5419 hundef = FALSE;
5379
5380 if (r_extern)
5381 {
5382 h = sym_hashes[r_index];
5383
5384 if (h != (struct aout_link_hash_entry *) NULL
5385 && (h->root.type == bfd_link_hash_defined
5386 || h->root.type == bfd_link_hash_defweak))
5387 {
5388 relocation = (h->root.u.def.value
5389 + h->root.u.def.section->output_section->vma
5390 + h->root.u.def.section->output_offset);
5391 }
5392 else if (h != (struct aout_link_hash_entry *) NULL
5393 && h->root.type == bfd_link_hash_undefweak)
5394 relocation = 0;
5395 else
5396 {
5420
5421 if (r_extern)
5422 {
5423 h = sym_hashes[r_index];
5424
5425 if (h != (struct aout_link_hash_entry *) NULL
5426 && (h->root.type == bfd_link_hash_defined
5427 || h->root.type == bfd_link_hash_defweak))
5428 {
5429 relocation = (h->root.u.def.value
5430 + h->root.u.def.section->output_section->vma
5431 + h->root.u.def.section->output_offset);
5432 }
5433 else if (h != (struct aout_link_hash_entry *) NULL
5434 && h->root.type == bfd_link_hash_undefweak)
5435 relocation = 0;
5436 else
5437 {
5397 hundef = true;
5438 hundef = TRUE;
5398 relocation = 0;
5399 }
5400 }
5401 else if (r_type == (unsigned int) RELOC_BASE10
5402 || r_type == (unsigned int) RELOC_BASE13
5403 || r_type == (unsigned int) RELOC_BASE22)
5404 {
5405 struct external_nlist *sym;

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

5462 + r_section->output_offset
5463 - r_section->vma);
5464 if (howto_table_ext[r_type].pc_relative)
5465 relocation += input_section->vma;
5466 }
5467
5468 if (check_dynamic_reloc != NULL)
5469 {
5439 relocation = 0;
5440 }
5441 }
5442 else if (r_type == (unsigned int) RELOC_BASE10
5443 || r_type == (unsigned int) RELOC_BASE13
5444 || r_type == (unsigned int) RELOC_BASE22)
5445 {
5446 struct external_nlist *sym;

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

5503 + r_section->output_offset
5504 - r_section->vma);
5505 if (howto_table_ext[r_type].pc_relative)
5506 relocation += input_section->vma;
5507 }
5508
5509 if (check_dynamic_reloc != NULL)
5510 {
5470 boolean skip;
5511 bfd_boolean skip;
5471
5472 if (! ((*check_dynamic_reloc)
5473 (finfo->info, input_bfd, input_section, h,
5474 (PTR) rel, contents, &skip, &relocation)))
5512
5513 if (! ((*check_dynamic_reloc)
5514 (finfo->info, input_bfd, input_section, h,
5515 (PTR) rel, contents, &skip, &relocation)))
5475 return false;
5516 return FALSE;
5476 if (skip)
5477 continue;
5478 }
5479
5480 /* Now warn if a global symbol is undefined. We could not
5481 do this earlier, because check_dynamic_reloc might want
5482 to skip this reloc. */
5483 if (hundef

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

5489 const char *name;
5490
5491 if (h != NULL)
5492 name = h->root.root.string;
5493 else
5494 name = strings + GET_WORD (input_bfd, syms[r_index].e_strx);
5495 if (! ((*finfo->info->callbacks->undefined_symbol)
5496 (finfo->info, name, input_bfd, input_section,
5517 if (skip)
5518 continue;
5519 }
5520
5521 /* Now warn if a global symbol is undefined. We could not
5522 do this earlier, because check_dynamic_reloc might want
5523 to skip this reloc. */
5524 if (hundef

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

5530 const char *name;
5531
5532 if (h != NULL)
5533 name = h->root.root.string;
5534 else
5535 name = strings + GET_WORD (input_bfd, syms[r_index].e_strx);
5536 if (! ((*finfo->info->callbacks->undefined_symbol)
5537 (finfo->info, name, input_bfd, input_section,
5497 r_addr, true)))
5498 return false;
5538 r_addr, TRUE)))
5539 return FALSE;
5499 }
5500
5501 if (r_type != (unsigned int) RELOC_SPARC_REV32)
5502 r = MY_final_link_relocate (howto_table_ext + r_type,
5503 input_bfd, input_section,
5504 contents, r_addr, relocation,
5505 r_addend);
5506 else

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

5537 asection *s;
5538
5539 s = aout_reloc_index_to_section (input_bfd, r_index);
5540 name = bfd_section_name (input_bfd, s);
5541 }
5542 if (! ((*finfo->info->callbacks->reloc_overflow)
5543 (finfo->info, name, howto_table_ext[r_type].name,
5544 r_addend, input_bfd, input_section, r_addr)))
5540 }
5541
5542 if (r_type != (unsigned int) RELOC_SPARC_REV32)
5543 r = MY_final_link_relocate (howto_table_ext + r_type,
5544 input_bfd, input_section,
5545 contents, r_addr, relocation,
5546 r_addend);
5547 else

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

5578 asection *s;
5579
5580 s = aout_reloc_index_to_section (input_bfd, r_index);
5581 name = bfd_section_name (input_bfd, s);
5582 }
5583 if (! ((*finfo->info->callbacks->reloc_overflow)
5584 (finfo->info, name, howto_table_ext[r_type].name,
5585 r_addend, input_bfd, input_section, r_addr)))
5545 return false;
5586 return FALSE;
5546 }
5547 break;
5548 }
5549 }
5550 }
5551 }
5552
5587 }
5588 break;
5589 }
5590 }
5591 }
5592 }
5593
5553 return true;
5594 return TRUE;
5554}
5555
5556/* Handle a link order which is supposed to generate a reloc. */
5557
5595}
5596
5597/* Handle a link order which is supposed to generate a reloc. */
5598
5558static boolean
5599static bfd_boolean
5559aout_link_reloc_link_order (finfo, o, p)
5560 struct aout_final_link_info *finfo;
5561 asection *o;
5562 struct bfd_link_order *p;
5563{
5564 struct bfd_link_order_reloc *pr;
5565 int r_index;
5566 int r_extern;

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

5587 else
5588 {
5589 struct aout_link_hash_entry *h;
5590
5591 BFD_ASSERT (p->type == bfd_symbol_reloc_link_order);
5592 r_extern = 1;
5593 h = ((struct aout_link_hash_entry *)
5594 bfd_wrapped_link_hash_lookup (finfo->output_bfd, finfo->info,
5600aout_link_reloc_link_order (finfo, o, p)
5601 struct aout_final_link_info *finfo;
5602 asection *o;
5603 struct bfd_link_order *p;
5604{
5605 struct bfd_link_order_reloc *pr;
5606 int r_index;
5607 int r_extern;

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

5628 else
5629 {
5630 struct aout_link_hash_entry *h;
5631
5632 BFD_ASSERT (p->type == bfd_symbol_reloc_link_order);
5633 r_extern = 1;
5634 h = ((struct aout_link_hash_entry *)
5635 bfd_wrapped_link_hash_lookup (finfo->output_bfd, finfo->info,
5595 pr->u.name, false, false, true));
5636 pr->u.name, FALSE, FALSE, TRUE));
5596 if (h != (struct aout_link_hash_entry *) NULL
5597 && h->indx >= 0)
5598 r_index = h->indx;
5599 else if (h != NULL)
5600 {
5601 /* We decided to strip this symbol, but it turns out that we
5602 can't. Note that we lose the other and desc information
5603 here. I don't think that will ever matter for a global
5604 symbol. */
5605 h->indx = -2;
5637 if (h != (struct aout_link_hash_entry *) NULL
5638 && h->indx >= 0)
5639 r_index = h->indx;
5640 else if (h != NULL)
5641 {
5642 /* We decided to strip this symbol, but it turns out that we
5643 can't. Note that we lose the other and desc information
5644 here. I don't think that will ever matter for a global
5645 symbol. */
5646 h->indx = -2;
5606 h->written = false;
5647 h->written = FALSE;
5607 if (! aout_link_write_other_symbol (h, (PTR) finfo))
5648 if (! aout_link_write_other_symbol (h, (PTR) finfo))
5608 return false;
5649 return FALSE;
5609 r_index = h->indx;
5610 }
5611 else
5612 {
5613 if (! ((*finfo->info->callbacks->unattached_reloc)
5614 (finfo->info, pr->u.name, (bfd *) NULL,
5615 (asection *) NULL, (bfd_vma) 0)))
5650 r_index = h->indx;
5651 }
5652 else
5653 {
5654 if (! ((*finfo->info->callbacks->unattached_reloc)
5655 (finfo->info, pr->u.name, (bfd *) NULL,
5656 (asection *) NULL, (bfd_vma) 0)))
5616 return false;
5657 return FALSE;
5617 r_index = 0;
5618 }
5619 }
5620
5621 howto = bfd_reloc_type_lookup (finfo->output_bfd, pr->reloc);
5622 if (howto == 0)
5623 {
5624 bfd_set_error (bfd_error_bad_value);
5658 r_index = 0;
5659 }
5660 }
5661
5662 howto = bfd_reloc_type_lookup (finfo->output_bfd, pr->reloc);
5663 if (howto == 0)
5664 {
5665 bfd_set_error (bfd_error_bad_value);
5625 return false;
5666 return FALSE;
5626 }
5627
5628 if (o == obj_textsec (finfo->output_bfd))
5629 reloff_ptr = &finfo->treloff;
5630 else if (o == obj_datasec (finfo->output_bfd))
5631 reloff_ptr = &finfo->dreloff;
5632 else
5633 abort ();

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

5687 reliable if we had the current contents of the file here,
5688 rather than assuming zeroes, but we can't read the file since
5689 it was opened using bfd_openw. */
5690 if (pr->addend != 0)
5691 {
5692 bfd_size_type size;
5693 bfd_reloc_status_type r;
5694 bfd_byte *buf;
5667 }
5668
5669 if (o == obj_textsec (finfo->output_bfd))
5670 reloff_ptr = &finfo->treloff;
5671 else if (o == obj_datasec (finfo->output_bfd))
5672 reloff_ptr = &finfo->dreloff;
5673 else
5674 abort ();

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

5728 reliable if we had the current contents of the file here,
5729 rather than assuming zeroes, but we can't read the file since
5730 it was opened using bfd_openw. */
5731 if (pr->addend != 0)
5732 {
5733 bfd_size_type size;
5734 bfd_reloc_status_type r;
5735 bfd_byte *buf;
5695 boolean ok;
5736 bfd_boolean ok;
5696
5697 size = bfd_get_reloc_size (howto);
5698 buf = (bfd_byte *) bfd_zmalloc (size);
5699 if (buf == (bfd_byte *) NULL)
5737
5738 size = bfd_get_reloc_size (howto);
5739 buf = (bfd_byte *) bfd_zmalloc (size);
5740 if (buf == (bfd_byte *) NULL)
5700 return false;
5741 return FALSE;
5701 r = MY_relocate_contents (howto, finfo->output_bfd,
5702 (bfd_vma) pr->addend, buf);
5703 switch (r)
5704 {
5705 case bfd_reloc_ok:
5706 break;
5707 default:
5708 case bfd_reloc_outofrange:

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

5713 (p->type == bfd_section_reloc_link_order
5714 ? bfd_section_name (finfo->output_bfd,
5715 pr->u.section)
5716 : pr->u.name),
5717 howto->name, pr->addend, (bfd *) NULL,
5718 (asection *) NULL, (bfd_vma) 0)))
5719 {
5720 free (buf);
5742 r = MY_relocate_contents (howto, finfo->output_bfd,
5743 (bfd_vma) pr->addend, buf);
5744 switch (r)
5745 {
5746 case bfd_reloc_ok:
5747 break;
5748 default:
5749 case bfd_reloc_outofrange:

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

5754 (p->type == bfd_section_reloc_link_order
5755 ? bfd_section_name (finfo->output_bfd,
5756 pr->u.section)
5757 : pr->u.name),
5758 howto->name, pr->addend, (bfd *) NULL,
5759 (asection *) NULL, (bfd_vma) 0)))
5760 {
5761 free (buf);
5721 return false;
5762 return FALSE;
5722 }
5723 break;
5724 }
5725 ok = bfd_set_section_contents (finfo->output_bfd, o, (PTR) buf,
5726 (file_ptr) p->offset, size);
5727 free (buf);
5728 if (! ok)
5763 }
5764 break;
5765 }
5766 ok = bfd_set_section_contents (finfo->output_bfd, o, (PTR) buf,
5767 (file_ptr) p->offset, size);
5768 free (buf);
5769 if (! ok)
5729 return false;
5770 return FALSE;
5730 }
5731 }
5732 else
5733 {
5734#ifdef MY_put_ext_reloc
5735 MY_put_ext_reloc (finfo->output_bfd, r_extern, r_index, p->offset,
5736 howto, &erel, pr->addend);
5737#else

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

5760#endif /* MY_put_ext_reloc */
5761
5762 rel_ptr = (PTR) &erel;
5763 }
5764
5765 amt = obj_reloc_entry_size (finfo->output_bfd);
5766 if (bfd_seek (finfo->output_bfd, *reloff_ptr, SEEK_SET) != 0
5767 || bfd_bwrite (rel_ptr, amt, finfo->output_bfd) != amt)
5771 }
5772 }
5773 else
5774 {
5775#ifdef MY_put_ext_reloc
5776 MY_put_ext_reloc (finfo->output_bfd, r_extern, r_index, p->offset,
5777 howto, &erel, pr->addend);
5778#else

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

5801#endif /* MY_put_ext_reloc */
5802
5803 rel_ptr = (PTR) &erel;
5804 }
5805
5806 amt = obj_reloc_entry_size (finfo->output_bfd);
5807 if (bfd_seek (finfo->output_bfd, *reloff_ptr, SEEK_SET) != 0
5808 || bfd_bwrite (rel_ptr, amt, finfo->output_bfd) != amt)
5768 return false;
5809 return FALSE;
5769
5770 *reloff_ptr += obj_reloc_entry_size (finfo->output_bfd);
5771
5772 /* Assert that the relocs have not run into the symbols, and that n
5773 the text relocs have not run into the data relocs. */
5774 BFD_ASSERT (*reloff_ptr <= obj_sym_filepos (finfo->output_bfd)
5775 && (reloff_ptr != &finfo->treloff
5776 || (*reloff_ptr
5777 <= obj_datasec (finfo->output_bfd)->rel_filepos)));
5778
5810
5811 *reloff_ptr += obj_reloc_entry_size (finfo->output_bfd);
5812
5813 /* Assert that the relocs have not run into the symbols, and that n
5814 the text relocs have not run into the data relocs. */
5815 BFD_ASSERT (*reloff_ptr <= obj_sym_filepos (finfo->output_bfd)
5816 && (reloff_ptr != &finfo->treloff
5817 || (*reloff_ptr
5818 <= obj_datasec (finfo->output_bfd)->rel_filepos)));
5819
5779 return true;
5820 return TRUE;
5780}
5821}