Subversion Repositories Kolibri OS

Rev

Rev 5197 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5197 Rev 6324
Line 1... Line 1...
1
/* BFD back-end for Intel 386 COFF files.
1
/* BFD back-end for Intel 386 COFF files.
2
   Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-
 
3
   2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010, 2011, 2012
-
 
4
   Free Software Foundation, Inc.
2
   Copyright (C) 1990-2015 Free Software Foundation, Inc.
5
   Written by Cygnus Support.
3
   Written by Cygnus Support.
Line 6... Line 4...
6
 
4
 
Line 7... Line 5...
7
   This file is part of BFD, the Binary File Descriptor library.
5
   This file is part of BFD, the Binary File Descriptor library.
Line 340... Line 338...
340
	 0xffffffff,		/* src_mask */
338
	 0xffffffff,		/* src_mask */
341
	 0xffffffff,		/* dst_mask */
339
	 0xffffffff,		/* dst_mask */
342
	 PCRELOFFSET)		/* pcrel_offset */
340
	 PCRELOFFSET)		/* pcrel_offset */
343
};
341
};
Line -... Line 342...
-
 
342
 
-
 
343
#define NUM_HOWTOS (sizeof (howto_table) / sizeof (howto_table[0]))
344
 
344
 
Line 345... Line 345...
345
/* Turn a howto into a reloc  nunmber */
345
/* Turn a howto into a reloc  nunmber */
346
 
346
 
347
#define SELECT_RELOC(x,howto) { x.r_type = howto->type; }
347
#define SELECT_RELOC(x,howto) { x.r_type = howto->type; }
Line 348... Line 348...
348
#define BADMAG(x) I386BADMAG(x)
348
#define BADMAG(x) I386BADMAG(x)
349
#define I386 1			/* Customize coffcode.h */
349
#define I386 1			/* Customize coffcode.h */
350
 
350
 
351
#define RTYPE2HOWTO(cache_ptr, dst)					\
351
#define RTYPE2HOWTO(cache_ptr, dst)					\
352
  ((cache_ptr)->howto =							\
352
  ((cache_ptr)->howto =							\
Line 353... Line 353...
353
   ((dst)->r_type < sizeof (howto_table) / sizeof (howto_table[0])	\
353
   ((dst)->r_type < NUM_HOWTOS					\
354
    ? howto_table + (dst)->r_type					\
354
    ? howto_table + (dst)->r_type					\
Line 377... Line 377...
377
    coff_symbol_type *coffsym = (coff_symbol_type *) NULL;	\
377
    coff_symbol_type *coffsym = (coff_symbol_type *) NULL;	\
378
    if (ptr && bfd_asymbol_bfd (ptr) != abfd)			\
378
    if (ptr && bfd_asymbol_bfd (ptr) != abfd)			\
379
      coffsym = (obj_symbols (abfd)				\
379
      coffsym = (obj_symbols (abfd)				\
380
	         + (cache_ptr->sym_ptr_ptr - symbols));		\
380
	         + (cache_ptr->sym_ptr_ptr - symbols));		\
381
    else if (ptr)						\
381
    else if (ptr)						\
382
      coffsym = coff_symbol_from (abfd, ptr);			\
382
      coffsym = coff_symbol_from (ptr);				\
383
    if (coffsym != (coff_symbol_type *) NULL			\
383
    if (coffsym != (coff_symbol_type *) NULL			\
384
	&& coffsym->native->u.syment.n_scnum == 0)		\
384
	&& coffsym->native->u.syment.n_scnum == 0)		\
385
      cache_ptr->addend = - coffsym->native->u.syment.n_value;	\
385
      cache_ptr->addend = - coffsym->native->u.syment.n_value;	\
386
    else if (ptr && bfd_asymbol_bfd (ptr) == abfd		\
386
    else if (ptr && bfd_asymbol_bfd (ptr) == abfd		\
387
	     && ptr->section != (asection *) NULL)		\
387
	     && ptr->section != (asection *) NULL)		\
388
      cache_ptr->addend = - (ptr->section->vma + ptr->value);	\
388
      cache_ptr->addend = - (ptr->section->vma + ptr->value);	\
389
    else							\
389
    else							\
390
      cache_ptr->addend = 0;					\
390
      cache_ptr->addend = 0;					\
-
 
391
    if (ptr && reloc.r_type < NUM_HOWTOS			\
391
    if (ptr && howto_table[reloc.r_type].pc_relative)		\
392
	&& howto_table[reloc.r_type].pc_relative)		\
392
      cache_ptr->addend += asect->vma;				\
393
      cache_ptr->addend += asect->vma;				\
393
  }
394
  }
Line 394... Line 395...
394
 
395
 
395
/* We use the special COFF backend linker.  For normal i386 COFF, we
396
/* We use the special COFF backend linker.  For normal i386 COFF, we
Line 414... Line 415...
414
			       bfd_byte *contents,
415
			       bfd_byte *contents,
415
			       struct internal_reloc *relocs,
416
			       struct internal_reloc *relocs,
416
			       struct internal_syment *syms,
417
			       struct internal_syment *syms,
417
			       asection **sections)
418
			       asection **sections)
418
{
419
{
419
  if (info->relocatable)
420
  if (bfd_link_relocatable (info))
420
    return TRUE;
421
    return TRUE;
Line 421... Line 422...
421
 
422
 
422
  return _bfd_coff_generic_relocate_section (output_bfd, info, input_bfd,
423
  return _bfd_coff_generic_relocate_section (output_bfd, info, input_bfd,
423
					     input_section, contents,
424
					     input_section, contents,
Line 438... Line 439...
438
			  struct internal_syment *sym,
439
			  struct internal_syment *sym,
439
			  bfd_vma *addendp)
440
			  bfd_vma *addendp)
440
{
441
{
441
  reloc_howto_type *howto;
442
  reloc_howto_type *howto;
Line 442... Line 443...
442
 
443
 
443
  if (rel->r_type >= sizeof (howto_table) / sizeof (howto_table[0]))
444
  if (rel->r_type >= NUM_HOWTOS)
444
    {
445
    {
445
      bfd_set_error (bfd_error_bad_value);
446
      bfd_set_error (bfd_error_bad_value);
446
      return NULL;
447
      return NULL;
Line 506... Line 507...
506
	  == bfd_target_coff_flavour))
507
	  == bfd_target_coff_flavour))
507
    {
508
    {
508
      *addendp -= pe_data(sec->output_section->owner)->pe_opthdr.ImageBase;
509
      *addendp -= pe_data(sec->output_section->owner)->pe_opthdr.ImageBase;
509
    }
510
    }
Line -... Line 511...
-
 
511
 
-
 
512
  /* PR 17099 - Absolute R_PCRLONG relocations do not need a symbol.  */
-
 
513
  if (rel->r_type == R_PCRLONG && sym == NULL)
-
 
514
    *addendp -= rel->r_vaddr;
510
 
515
  else
-
 
516
  BFD_ASSERT (sym != NULL);
511
  BFD_ASSERT (sym != NULL);
517
 
512
  if (rel->r_type == R_SECREL32 && sym != NULL)
518
  if (rel->r_type == R_SECREL32 && sym != NULL)
513
    {
519
    {
Line 514... Line 520...
514
      bfd_vma osect_vma;
520
      bfd_vma osect_vma;
Line 574... Line 580...
574
coff_i386_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
580
coff_i386_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
575
			     const char *r_name)
581
			     const char *r_name)
576
{
582
{
577
  unsigned int i;
583
  unsigned int i;
Line 578... Line 584...
578
 
584
 
579
  for (i = 0; i < sizeof (howto_table) / sizeof (howto_table[0]); i++)
585
  for (i = 0; i < NUM_HOWTOS; i++)
580
    if (howto_table[i].name != NULL
586
    if (howto_table[i].name != NULL
581
	&& strcasecmp (howto_table[i].name, r_name) == 0)
587
	&& strcasecmp (howto_table[i].name, r_name) == 0)
Line 582... Line 588...
582
      return &howto_table[i];
588
      return &howto_table[i];
Line 605... Line 611...
605
 
611
 
Line 606... Line 612...
606
#endif /* TARGET_UNDERSCORE */
612
#endif /* TARGET_UNDERSCORE */
Line 607... Line -...
607
 
-
 
608
#include "coffcode.h"
-
 
609
 
-
 
610
#define _bfd_generic_find_nearest_line_discriminator \
613
 
611
	coff_find_nearest_line_discriminator
614
#include "coffcode.h"
612
 
615
 
613
const bfd_target
616
const bfd_target
614
#ifdef TARGET_SYM
617
#ifdef TARGET_SYM
615
  TARGET_SYM =
618
  TARGET_SYM =
616
#else
619
#else
617
  i386coff_vec =
620
  i386_coff_vec =
618
#endif
621
#endif
619
{
622
{