# This shell script emits a C file. -*- C -*-
# Copyright (C) 2010-2025 Free Software Foundation, Inc.
#
# This file is part of the GNU Binutils.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
# MA 02110-1301, USA.
#
# This file is sourced from generic.em.
fragment <<EOF
#include "libiberty.h"
#include "getopt.h"
#include "ldlex.h"
/* We have nothing to say for anything other than a final link or an excluded
section. */
if (bfd_link_relocatable (&link_info)
|| (s->flags & (SEC_EXCLUDE | SEC_LOAD)) != SEC_LOAD)
return NULL;
/* FIXME: we should place sections by VMS program section flags. */
/* Only handle data sections. */
if ((s->flags & SEC_DATA) == 0)
return NULL;
if (hold_data.os == NULL)
hold_data.os = lang_output_section_find (hold_data.name);
bed = get_elf_backend_data (link_info.output_bfd);
/* The backend must work out the sizes of all the other dynamic
sections. */
if (bed->elf_backend_late_size_sections
&& !bed->elf_backend_late_size_sections (link_info.output_bfd,
&link_info))
fatal (_("%P: failed to set dynamic section sizes: %E\n"));