xref: /netbsd-src/external/gpl3/binutils.old/dist/ld/ldctor.h (revision e992f068c547fd6e84b3f104dc2340adcc955732)
175fd0b74Schristos /* ldctor.h - linker constructor support
2*e992f068Schristos    Copyright (C) 1991-2022 Free Software Foundation, Inc.
375fd0b74Schristos 
475fd0b74Schristos    This file is part of the GNU Binutils.
575fd0b74Schristos 
675fd0b74Schristos    This program is free software; you can redistribute it and/or modify
775fd0b74Schristos    it under the terms of the GNU General Public License as published by
875fd0b74Schristos    the Free Software Foundation; either version 3 of the License, or
975fd0b74Schristos    (at your option) any later version.
1075fd0b74Schristos 
1175fd0b74Schristos    This program is distributed in the hope that it will be useful,
1275fd0b74Schristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
1375fd0b74Schristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1475fd0b74Schristos    GNU General Public License for more details.
1575fd0b74Schristos 
1675fd0b74Schristos    You should have received a copy of the GNU General Public License
1775fd0b74Schristos    along with this program; if not, write to the Free Software
1875fd0b74Schristos    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
1975fd0b74Schristos    MA 02110-1301, USA.  */
2075fd0b74Schristos 
2175fd0b74Schristos #ifndef LDCTOR_H
2275fd0b74Schristos #define LDCTOR_H
2375fd0b74Schristos 
2475fd0b74Schristos /* List of statements needed to handle constructors */
2575fd0b74Schristos extern lang_statement_list_type constructor_list;
2675fd0b74Schristos 
2775fd0b74Schristos /* Whether the constructors should be sorted.  Note that this is
2875fd0b74Schristos    global for the entire link; we assume that there is only a single
2975fd0b74Schristos    CONSTRUCTORS command in the linker script.  */
30*e992f068Schristos extern bool constructors_sorted;
3175fd0b74Schristos 
3275fd0b74Schristos /* We keep a list of these structures for each set we build.  */
3375fd0b74Schristos 
3475fd0b74Schristos struct set_info {
3575fd0b74Schristos   struct set_info *next;		/* Next set.  */
3675fd0b74Schristos   struct bfd_link_hash_entry *h;	/* Hash table entry.  */
3775fd0b74Schristos   bfd_reloc_code_real_type reloc;	/* Reloc to use for an entry.  */
3875fd0b74Schristos   size_t count;				/* Number of elements.  */
3975fd0b74Schristos   struct set_element *elements;		/* Elements in set.  */
4075fd0b74Schristos };
4175fd0b74Schristos 
4275fd0b74Schristos struct set_element {
43012573ebSchristos   union {
4475fd0b74Schristos     struct set_element *next;		/* Next element.  */
45012573ebSchristos     long idx;
46012573ebSchristos   } u;
4775fd0b74Schristos   const char *name;			/* Name in set (may be NULL).  */
4875fd0b74Schristos   asection *section;			/* Section of value in set.  */
4975fd0b74Schristos   bfd_vma value;			/* Value in set.  */
5075fd0b74Schristos };
5175fd0b74Schristos 
5275fd0b74Schristos /* The sets we have seen.  */
5375fd0b74Schristos 
5475fd0b74Schristos extern struct set_info *sets;
5575fd0b74Schristos 
5675fd0b74Schristos extern void ldctor_add_set_entry
5775fd0b74Schristos   (struct bfd_link_hash_entry *, bfd_reloc_code_real_type, const char *,
5875fd0b74Schristos    asection *, bfd_vma);
5975fd0b74Schristos extern void ldctor_build_sets
6075fd0b74Schristos   (void);
6175fd0b74Schristos 
6275fd0b74Schristos #endif
63