Subversion Repositories Kolibri OS

Rev

Rev 5199 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5199 Rev 6324
Line 1... Line 1...
1
/* Routines to help build PEI-format DLLs (Win32 etc)
1
/* Routines to help build PEI-format DLLs (Win32 etc)
2
   Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
-
 
3
   2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
2
   Copyright (C) 1998-2015 Free Software Foundation, Inc.
4
   Written by DJ Delorie 
3
   Written by DJ Delorie 
Line 5... Line 4...
5
 
4
 
Line 6... Line 5...
6
   This file is part of the GNU Binutils.
5
   This file is part of the GNU Binutils.
Line 234... Line 233...
234
  /* Global vars that should not be exported.  */
233
  /* Global vars that should not be exported.  */
235
  { STRING_COMMA_LEN ("impure_ptr") },
234
  { STRING_COMMA_LEN ("impure_ptr") },
236
  { STRING_COMMA_LEN ("_impure_ptr") },
235
  { STRING_COMMA_LEN ("_impure_ptr") },
237
  { STRING_COMMA_LEN ("_fmode") },
236
  { STRING_COMMA_LEN ("_fmode") },
238
  { STRING_COMMA_LEN ("environ") },
237
  { STRING_COMMA_LEN ("environ") },
-
 
238
  { STRING_COMMA_LEN ("__dso_handle") },
239
  { NULL, 0 }
239
  { NULL, 0 }
240
};
240
};
Line 241... Line 241...
241
 
241
 
242
#define PE_ARCH_i386	 1
242
#define PE_ARCH_i386	 1
Line 653... Line 653...
653
  if (!pe_def_file)
653
  if (!pe_def_file)
654
    pe_def_file = def_file_empty ();
654
    pe_def_file = def_file_empty ();
Line 655... Line 655...
655
 
655
 
656
  /* First, run around to all the objects looking for the .drectve
656
  /* First, run around to all the objects looking for the .drectve
657
     sections, and push those into the def file too.  */
657
     sections, and push those into the def file too.  */
658
  for (b = info->input_bfds; b; b = b->link_next)
658
  for (b = info->input_bfds; b; b = b->link.next)
659
    {
659
    {
660
      s = bfd_get_section_by_name (b, ".drectve");
660
      s = bfd_get_section_by_name (b, ".drectve");
661
      if (s)
661
      if (s)
662
	{
662
	{
Line 691... Line 691...
691
	}
691
	}
692
    }
692
    }
Line 693... Line 693...
693
 
693
 
694
  /* If we are building an executable and there is nothing
694
  /* If we are building an executable and there is nothing
695
     to export, we do not build an export table at all.  */
695
     to export, we do not build an export table at all.  */
696
  if (info->executable && pe_def_file->num_exports == 0
696
  if (bfd_link_executable (info) && pe_def_file->num_exports == 0
697
      && (!pe_dll_export_everything || pe_dll_exclude_all_symbols))
697
      && (!pe_dll_export_everything || pe_dll_exclude_all_symbols))
Line 698... Line 698...
698
    return;
698
    return;
699
 
699
 
700
  /* Now, maybe export everything else the default way.  */
700
  /* Now, maybe export everything else the default way.  */
701
  if ((pe_dll_export_everything || pe_def_file->num_exports == 0)
701
  if ((pe_dll_export_everything || pe_def_file->num_exports == 0)
702
      && !pe_dll_exclude_all_symbols)
702
      && !pe_dll_exclude_all_symbols)
703
    {
703
    {
704
      for (b = info->input_bfds; b; b = b->link_next)
704
      for (b = info->input_bfds; b; b = b->link.next)
705
	{
705
	{
Line 706... Line 706...
706
	  asymbol **symbols;
706
	  asymbol **symbols;
Line 1266... Line 1266...
1266
			  int (*cb) (arelent *, asection *))
1266
			  int (*cb) (arelent *, asection *))
1267
{
1267
{
1268
  bfd *b;
1268
  bfd *b;
1269
  asection *s;
1269
  asection *s;
Line 1270... Line 1270...
1270
 
1270
 
1271
  for (b = info->input_bfds; b; b = b->link_next)
1271
  for (b = info->input_bfds; b; b = b->link.next)
1272
    {
1272
    {
Line 1273... Line 1273...
1273
      asymbol **symbols;
1273
      asymbol **symbols;
1274
 
1274
 
Line 1329... Line 1329...
1329
  int bi;
1329
  int bi;
1330
  bfd *b;
1330
  bfd *b;
1331
  struct bfd_section *s;
1331
  struct bfd_section *s;
Line 1332... Line 1332...
1332
 
1332
 
1333
  total_relocs = 0;
1333
  total_relocs = 0;
1334
  for (b = info->input_bfds; b; b = b->link_next)
1334
  for (b = info->input_bfds; b; b = b->link.next)
1335
    for (s = b->sections; s; s = s->next)
1335
    for (s = b->sections; s; s = s->next)
Line 1336... Line 1336...
1336
      total_relocs += s->reloc_count;
1336
      total_relocs += s->reloc_count;
Line 1337... Line 1337...
1337
 
1337
 
1338
  reloc_data = xmalloc (total_relocs * sizeof (reloc_data_type));
1338
  reloc_data = xmalloc (total_relocs * sizeof (reloc_data_type));
1339
 
1339
 
1340
  total_relocs = 0;
1340
  total_relocs = 0;
1341
  bi = 0;
1341
  bi = 0;
1342
  for (bi = 0, b = info->input_bfds; b; bi++, b = b->link_next)
1342
  for (bi = 0, b = info->input_bfds; b; bi++, b = b->link.next)
Line 1343... Line 1343...
1343
    {
1343
    {
Line 2589... Line 2589...
2589
 
2589
 
2590
  quick_symbol (abfd, "", U ("_pei386_runtime_relocator"), "", UNDSEC,
2590
  quick_symbol (abfd, "", U ("_pei386_runtime_relocator"), "", UNDSEC,
Line 2591... Line 2591...
2591
		BSF_NO_FLAGS, 0);
2591
		BSF_NO_FLAGS, 0);
2592
 
2592
 
2593
  bfd_set_section_size (abfd, extern_rt_rel, PE_IDATA5_SIZE);
2593
  bfd_set_section_size (abfd, extern_rt_rel, PE_IDATA5_SIZE);
Line 2594... Line 2594...
2594
  extern_rt_rel_d = xmalloc (PE_IDATA5_SIZE);
2594
  extern_rt_rel_d = xcalloc (1, PE_IDATA5_SIZE);
2595
  extern_rt_rel->contents = extern_rt_rel_d;
2595
  extern_rt_rel->contents = extern_rt_rel_d;
Line 2725... Line 2725...
2725
 
2725
 
2726
  /* Work out a reasonable size of things to put onto one line.  */
2726
  /* Work out a reasonable size of things to put onto one line.  */
Line 2727... Line 2727...
2727
  ar_head = make_head (outarch);
2727
  ar_head = make_head (outarch);
2728
 
2728
 
2729
  /* Iterate the input BFDs, looking for exclude-modules-for-implib.  */
2729
  /* Iterate the input BFDs, looking for exclude-modules-for-implib.  */
2730
  for (ibfd = info->input_bfds; ibfd; ibfd = ibfd->link_next)
2730
  for (ibfd = info->input_bfds; ibfd; ibfd = ibfd->link.next)
2731
    {
2731
    {
2732
      /* Iterate the exclude list.  */
2732
      /* Iterate the exclude list.  */
2733
      struct exclude_list_struct *ex;
2733
      struct exclude_list_struct *ex;
Line 3367... Line 3367...
3367
{
3367
{
3368
  pe_dll_id_target (bfd_get_target (abfd));
3368
  pe_dll_id_target (bfd_get_target (abfd));
3369
  pe_output_file_set_long_section_names (abfd);
3369
  pe_output_file_set_long_section_names (abfd);
3370
  process_def_file_and_drectve (abfd, info);
3370
  process_def_file_and_drectve (abfd, info);
Line 3371... Line 3371...
3371
 
3371
 
3372
  if (pe_def_file->num_exports == 0 && !info->shared)
3372
  if (pe_def_file->num_exports == 0 && !bfd_link_pic (info))
Line 3373... Line 3373...
3373
    return;
3373
    return;
3374
 
3374
 
3375
  generate_edata (abfd, info);
3375
  generate_edata (abfd, info);
Line 3409... Line 3409...
3409
      lang_do_assignments (lang_final_phase_enum);
3409
      lang_do_assignments (lang_final_phase_enum);
3410
    }
3410
    }
Line 3411... Line 3411...
3411
 
3411
 
Line 3412... Line 3412...
3412
  fill_edata (abfd, info);
3412
  fill_edata (abfd, info);
3413
 
3413
 
Line 3414... Line 3414...
3414
  if (info->shared && !info->pie)
3414
  if (bfd_link_dll (info))
3415
    pe_data (abfd)->dll = 1;
3415
    pe_data (abfd)->dll = 1;
3416
 
3416