/* Support for the generic parts of PE/PEI; the common executable parts.
Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
- 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+ 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
Written by Cygnus Solutions.
This file is part of BFD, the Binary File Descriptor library.
they will be handled somewhat correctly in the bfd code. */
if (in->n_sclass == C_SECTION)
{
+ char namebuf[SYMNMLEN + 1];
+ const char *name = NULL;
+
in->n_value = 0x0;
/* Create synthetic empty sections as needed. DJ */
{
asection *sec;
- for (sec = abfd->sections; sec; sec = sec->next)
- {
- if (strcmp (sec->name, in->n_name) == 0)
- {
- in->n_scnum = sec->target_index;
- break;
- }
- }
+ name = _bfd_coff_internal_syment_name (abfd, in, namebuf);
+ if (name == NULL)
+ /* FIXME: Return error. */
+ abort ();
+ sec = bfd_get_section_by_name (abfd, name);
+ if (sec != NULL)
+ in->n_scnum = sec->target_index;
}
if (in->n_scnum == 0)
{
int unused_section_number = 0;
asection *sec;
- char *name;
flagword flags;
for (sec = abfd->sections; sec; sec = sec->next)
if (unused_section_number <= sec->target_index)
unused_section_number = sec->target_index + 1;
- name = bfd_alloc (abfd, (bfd_size_type) strlen (in->n_name) + 10);
- if (name == NULL)
- return;
- strcpy (name, in->n_name);
+ if (name == namebuf)
+ {
+ name = bfd_alloc (abfd, strlen (namebuf) + 1);
+ if (name == NULL)
+ /* FIXME: Return error. */
+ abort ();
+ strcpy ((char *) name, namebuf);
+ }
flags = SEC_HAS_CONTENTS | SEC_ALLOC | SEC_DATA | SEC_LOAD;
sec = bfd_make_section_anyway_with_flags (abfd, name, flags);
+ if (sec == NULL)
+ /* FIXME: Return error. */
+ abort ();
sec->vma = 0;
sec->lma = 0;
bfd_vma sa, fa, ib;
IMAGE_DATA_DIRECTORY idata2, idata5, tls;
- if (pe->force_minimum_alignment)
- {
- if (!extra->FileAlignment)
- extra->FileAlignment = PE_DEF_FILE_ALIGNMENT;
- if (!extra->SectionAlignment)
- extra->SectionAlignment = PE_DEF_SECTION_ALIGNMENT;
- }
-
- if (extra->Subsystem == IMAGE_SUBSYSTEM_UNKNOWN)
- extra->Subsystem = pe->target_subsystem;
-
sa = extra->SectionAlignment;
fa = extra->FileAlignment;
ib = extra->ImageBase;
sometimes). */
if ((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0)
{
- if (bfd_pe_executable_p (abfd))
+ if (bfd_pei_p (abfd))
{
ps = scnhdr_int->s_size;
ss = 0;
}
else
{
- if (bfd_pe_executable_p (abfd))
+ if (bfd_pei_p (abfd))
ps = scnhdr_int->s_paddr;
else
ps = 0;
return TRUE;
#undef PDATA_ROW_SIZE
}
+
\f
#define IMAGE_REL_BASED_HIGHADJ 4
static const char * const tbl[] =
case IMAGE_SUBSYSTEM_WINDOWS_CE_GUI:
subsystem_name = "Wince CUI";
break;
+ // These are from UEFI Platform Initialization Specification 1.1.
case IMAGE_SUBSYSTEM_EFI_APPLICATION:
subsystem_name = "EFI application";
break;
case IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER:
subsystem_name = "EFI runtime driver";
break;
- // These are from revision 8.0 of the MS PE/COFF spec
- case IMAGE_SUBSYSTEM_EFI_ROM:
- subsystem_name = "EFI ROM";
+ case IMAGE_SUBSYSTEM_SAL_RUNTIME_DRIVER:
+ subsystem_name = "SAL runtime driver";
break;
+ // This is from revision 8.0 of the MS PE/COFF spec
case IMAGE_SUBSYSTEM_XBOX:
subsystem_name = "XBOX";
break;
ipe = pe_data (ibfd);
ope = pe_data (obfd);
- ope->pe_opthdr = ipe->pe_opthdr;
+ /* pe_opthdr is copied in copy_object. */
ope->dll = ipe->dll;
/* Don't copy input subsystem if output is different from input. */
/* PR ld/2729: We cannot rely upon all the output sections having been
created properly, so check before referencing them. Issue a warning
message for any sections tht could not be found. */
- if (h1->root.u.def.section != NULL
+ if ((h1->root.type == bfd_link_hash_defined
+ || h1->root.type == bfd_link_hash_defweak)
+ && h1->root.u.def.section != NULL
&& h1->root.u.def.section->output_section != NULL)
pe_data (abfd)->pe_opthdr.DataDirectory[PE_IMPORT_TABLE].VirtualAddress =
(h1->root.u.def.value
h1 = coff_link_hash_lookup (coff_hash_table (info),
".idata$4", FALSE, FALSE, TRUE);
if (h1 != NULL
+ && (h1->root.type == bfd_link_hash_defined
+ || h1->root.type == bfd_link_hash_defweak)
&& h1->root.u.def.section != NULL
&& h1->root.u.def.section->output_section != NULL)
pe_data (abfd)->pe_opthdr.DataDirectory[PE_IMPORT_TABLE].Size =
h1 = coff_link_hash_lookup (coff_hash_table (info),
".idata$5", FALSE, FALSE, TRUE);
if (h1 != NULL
+ && (h1->root.type == bfd_link_hash_defined
+ || h1->root.type == bfd_link_hash_defweak)
&& h1->root.u.def.section != NULL
&& h1->root.u.def.section->output_section != NULL)
pe_data (abfd)->pe_opthdr.DataDirectory[PE_IMPORT_ADDRESS_TABLE].VirtualAddress =
h1 = coff_link_hash_lookup (coff_hash_table (info),
".idata$6", FALSE, FALSE, TRUE);
if (h1 != NULL
+ && (h1->root.type == bfd_link_hash_defined
+ || h1->root.type == bfd_link_hash_defweak)
&& h1->root.u.def.section != NULL
&& h1->root.u.def.section->output_section != NULL)
pe_data (abfd)->pe_opthdr.DataDirectory[PE_IMPORT_ADDRESS_TABLE].Size =
"__tls_used", FALSE, FALSE, TRUE);
if (h1 != NULL)
{
- if (h1->root.u.def.section != NULL
+ if ((h1->root.type == bfd_link_hash_defined
+ || h1->root.type == bfd_link_hash_defweak)
+ && h1->root.u.def.section != NULL
&& h1->root.u.def.section->output_section != NULL)
pe_data (abfd)->pe_opthdr.DataDirectory[PE_TLS_TABLE].VirtualAddress =
(h1->root.u.def.value