]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - bfd/coff-bfd.c
Automatic date update in version.in
[thirdparty/binutils-gdb.git] / bfd / coff-bfd.c
CommitLineData
f4943d82 1/* BFD COFF interfaces used outside of BFD.
fd67aa11 2 Copyright (C) 1990-2024 Free Software Foundation, Inc.
f4943d82
AM
3 Written by Cygnus Support.
4
5 This file is part of BFD, the Binary File Descriptor library.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
20 MA 02110-1301, USA. */
21
22#include "sysdep.h"
23#include "bfd.h"
24#include "libbfd.h"
25#include "coff/internal.h"
26#include "libcoff.h"
27
28/* Return the COFF syment for a symbol. */
29
0a1b45a2 30bool
f4943d82
AM
31bfd_coff_get_syment (bfd *abfd,
32 asymbol *symbol,
33 struct internal_syment *psyment)
34{
35 coff_symbol_type *csym;
36
37 csym = coff_symbol_from (symbol);
38 if (csym == NULL || csym->native == NULL
39 || ! csym->native->is_sym)
40 {
41 bfd_set_error (bfd_error_invalid_operation);
0a1b45a2 42 return false;
f4943d82
AM
43 }
44
45 *psyment = csym->native->u.syment;
46
47 if (csym->native->fix_value)
2043ddb2
AM
48 {
49 psyment->n_value =
50 ((psyment->n_value - (uintptr_t) obj_raw_syments (abfd))
51 / sizeof (combined_entry_type));
52 csym->native->fix_value = 0;
53 }
f4943d82
AM
54
55 /* FIXME: We should handle fix_line here. */
56
0a1b45a2 57 return true;
f4943d82
AM
58}
59
60/* Return the COFF auxent for a symbol. */
61
0a1b45a2 62bool
f4943d82
AM
63bfd_coff_get_auxent (bfd *abfd,
64 asymbol *symbol,
65 int indx,
66 union internal_auxent *pauxent)
67{
68 coff_symbol_type *csym;
69 combined_entry_type *ent;
70
71 csym = coff_symbol_from (symbol);
72
73 if (csym == NULL
74 || csym->native == NULL
75 || ! csym->native->is_sym
76 || indx >= csym->native->u.syment.n_numaux)
77 {
78 bfd_set_error (bfd_error_invalid_operation);
0a1b45a2 79 return false;
f4943d82
AM
80 }
81
82 ent = csym->native + indx + 1;
83
84 BFD_ASSERT (! ent->is_sym);
85 *pauxent = ent->u.auxent;
86
87 if (ent->fix_tag)
3bb1480e 88 {
a2c7ca15 89 pauxent->x_sym.x_tagndx.u32 =
3bb1480e
AM
90 ((combined_entry_type *) pauxent->x_sym.x_tagndx.p
91 - obj_raw_syments (abfd));
92 ent->fix_tag = 0;
93 }
f4943d82
AM
94
95 if (ent->fix_end)
3bb1480e 96 {
a2c7ca15 97 pauxent->x_sym.x_fcnary.x_fcn.x_endndx.u32 =
3bb1480e
AM
98 ((combined_entry_type *) pauxent->x_sym.x_fcnary.x_fcn.x_endndx.p
99 - obj_raw_syments (abfd));
100 ent->fix_end = 0;
101 }
f4943d82
AM
102
103 if (ent->fix_scnlen)
3bb1480e 104 {
a2c7ca15 105 pauxent->x_csect.x_scnlen.u64 =
3bb1480e
AM
106 ((combined_entry_type *) pauxent->x_csect.x_scnlen.p
107 - obj_raw_syments (abfd));
108 ent->fix_scnlen = 0;
109 }
f4943d82 110
0a1b45a2 111 return true;
f4943d82 112}