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 backend for Extended Tektronix Hex Format  objects.
1
/* BFD backend for Extended Tektronix Hex Format  objects.
2
   Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002,
-
 
3
   2003, 2004, 2005, 2006, 2007, 2009, 2011 Free Software Foundation, Inc.
2
   Copyright (C) 1992-2015 Free Software Foundation, Inc.
4
   Written by Steve Chamberlain of Cygnus Support .
3
   Written by Steve Chamberlain of Cygnus Support .
Line 5... Line 4...
5
 
4
 
Line 6... Line 5...
6
   This file is part of BFD, the Binary File Descriptor library.
5
   This file is part of BFD, the Binary File Descriptor library.
Line 245... Line 244...
245
 
244
 
246
};
245
};
Line 247... Line 246...
247
typedef struct tekhex_data_list_struct tekhex_data_list_type;
246
typedef struct tekhex_data_list_struct tekhex_data_list_type;
-
 
247
 
Line 248... Line 248...
248
 
248
#define CHUNK_MASK 0x1fff
249
#define CHUNK_MASK 0x1fff
249
#define CHUNK_SPAN 32
250
 
250
 
251
struct data_struct
251
struct data_struct
252
{
252
{
253
  char chunk_data[CHUNK_MASK + 1];
253
  unsigned char chunk_data[CHUNK_MASK + 1];
254
  char chunk_init[CHUNK_MASK + 1];
254
  unsigned char chunk_init[(CHUNK_MASK + 1 + CHUNK_SPAN - 1) / CHUNK_SPAN];
Line 255... Line 255...
255
  bfd_vma vma;
255
  bfd_vma vma;
Line 265... Line 265...
265
} tdata_type;
265
} tdata_type;
Line 266... Line 266...
266
 
266
 
Line 267... Line 267...
267
#define enda(x) (x->vma + x->size)
267
#define enda(x) (x->vma + x->size)
268
 
268
 
269
static bfd_boolean
269
static bfd_boolean
270
getvalue (char **srcp, bfd_vma *valuep)
270
getvalue (char **srcp, bfd_vma *valuep, char * endp)
271
{
271
{
272
  char *src = *srcp;
272
  char *src = *srcp;
Line 277... Line 277...
277
    return FALSE;
277
    return FALSE;
Line 278... Line 278...
278
 
278
 
279
  len = hex_value (*src++);
279
  len = hex_value (*src++);
280
  if (len == 0)
280
  if (len == 0)
281
    len = 16;
281
    len = 16;
282
  while (len--)
282
  while (len-- && src < endp)
283
    {
283
    {
284
      if (!ISHEX (*src))
284
      if (!ISHEX (*src))
285
	return FALSE;
285
	return FALSE;
286
      value = value << 4 | hex_value (*src++);
286
      value = value << 4 | hex_value (*src++);
Line 287... Line 287...
287
    }
287
    }
288
 
288
 
289
  *srcp = src;
289
  *srcp = src;
290
  *valuep = value;
290
  *valuep = value;
Line 291... Line 291...
291
  return TRUE;
291
  return len == -1U;
292
}
292
}
293
 
293
 
294
static bfd_boolean
294
static bfd_boolean
295
getsym (char *dstp, char **srcp, unsigned int *lenp)
295
getsym (char *dstp, char **srcp, unsigned int *lenp, char * endp)
296
{
296
{
Line 302... Line 302...
302
    return FALSE;
302
    return FALSE;
Line 303... Line 303...
303
 
303
 
304
  len = hex_value (*src++);
304
  len = hex_value (*src++);
305
  if (len == 0)
305
  if (len == 0)
306
    len = 16;
306
    len = 16;
307
  for (i = 0; i < len; i++)
307
  for (i = 0; i < len && src < endp; i++)
308
    dstp[i] = src[i];
308
    dstp[i] = src[i];
309
  dstp[i] = 0;
309
  dstp[i] = 0;
310
  *srcp = src + i;
310
  *srcp = src + i;
311
  *lenp = len;
311
  *lenp = len;
312
  return TRUE;
312
  return i == len;
Line 313... Line 313...
313
}
313
}
314
 
314
 
315
static struct data_struct *
315
static struct data_struct *
316
find_chunk (bfd *abfd, bfd_vma vma)
316
find_chunk (bfd *abfd, bfd_vma vma, bfd_boolean create)
Line 317... Line 317...
317
{
317
{
318
  struct data_struct *d = abfd->tdata.tekhex_data->data;
318
  struct data_struct *d = abfd->tdata.tekhex_data->data;
319
 
319
 
Line 320... Line 320...
320
  vma &= ~CHUNK_MASK;
320
  vma &= ~CHUNK_MASK;
321
  while (d && (d->vma) != vma)
321
  while (d && (d->vma) != vma)
322
    d = d->next;
322
    d = d->next;
323
 
323
 
324
  if (!d)
324
  if (!d && create)
Line 338... Line 338...
338
}
338
}
Line 339... Line 339...
339
 
339
 
340
static void
340
static void
341
insert_byte (bfd *abfd, int value, bfd_vma addr)
341
insert_byte (bfd *abfd, int value, bfd_vma addr)
-
 
342
{
-
 
343
  if (value != 0)
342
{
344
    {
343
  /* Find the chunk that this byte needs and put it in.  */
345
  /* Find the chunk that this byte needs and put it in.  */
Line 344... Line 346...
344
  struct data_struct *d = find_chunk (abfd, addr);
346
      struct data_struct *d = find_chunk (abfd, addr, TRUE);
345
 
347
 
-
 
348
  d->chunk_data[addr & CHUNK_MASK] = value;
346
  d->chunk_data[addr & CHUNK_MASK] = value;
349
      d->chunk_init[(addr & CHUNK_MASK) / CHUNK_SPAN] = 1;
Line 347... Line 350...
347
  d->chunk_init[addr & CHUNK_MASK] = 1;
350
    }
348
}
351
}
Line 349... Line 352...
349
 
352
 
350
/* The first pass is to find the names of all the sections, and see
353
/* The first pass is to find the names of all the sections, and see
351
  how big the data is.  */
354
  how big the data is.  */
352
 
355
 
353
static bfd_boolean
356
static bfd_boolean
354
first_phase (bfd *abfd, int type, char *src)
357
first_phase (bfd *abfd, int type, char *src, char * src_end)
355
{
358
{
Line 356... Line 359...
356
  asection *section = bfd_abs_section_ptr;
359
  asection *section, *alt_section;
Line 363... Line 366...
363
    case '6':
366
    case '6':
364
      /* Data record - read it and store it.  */
367
      /* Data record - read it and store it.  */
365
      {
368
      {
366
	bfd_vma addr;
369
	bfd_vma addr;
Line 367... Line 370...
367
 
370
 
368
	if (!getvalue (&src, &addr))
371
	if (!getvalue (&src, &addr, src_end))
Line 369... Line 372...
369
	  return FALSE;
372
	  return FALSE;
370
 
373
 
371
	while (*src)
374
	while (*src && src < src_end - 1)
372
	  {
375
	  {
373
	    insert_byte (abfd, HEX (src), addr);
376
	    insert_byte (abfd, HEX (src), addr);
374
	    src += 2;
377
	    src += 2;
-
 
378
	    addr++;
375
	    addr++;
379
	  }
Line 376... Line -...
376
	  }
-
 
377
      }
380
	return TRUE;
378
 
381
      }
379
      return TRUE;
382
 
380
    case '3':
383
    case '3':
381
      /* Symbol record, read the segment.  */
384
      /* Symbol record, read the segment.  */
382
      if (!getsym (sym, &src, &len))
385
      if (!getsym (sym, &src, &len, src_end))
383
	return FALSE;
386
	return FALSE;
384
      section = bfd_get_section_by_name (abfd, sym);
387
      section = bfd_get_section_by_name (abfd, sym);
Line 391... Line 394...
391
	  memcpy (n, sym, len + 1);
394
	  memcpy (n, sym, len + 1);
392
	  section = bfd_make_section (abfd, n);
395
	  section = bfd_make_section (abfd, n);
393
	  if (section == NULL)
396
	  if (section == NULL)
394
	    return FALSE;
397
	    return FALSE;
395
	}
398
	}
-
 
399
      alt_section = NULL;
396
      while (*src)
400
      while (src < src_end && *src)
397
	{
401
	{
398
	  switch (*src)
402
	  switch (*src)
399
	    {
403
	    {
400
	    case '1':		/* Section range.  */
404
	    case '1':		/* Section range.  */
401
	      src++;
405
	      src++;
402
	      if (!getvalue (&src, §ion->vma))
406
	      if (!getvalue (&src, §ion->vma, src_end))
403
		return FALSE;
407
		return FALSE;
404
	      if (!getvalue (&src, &val))
408
	      if (!getvalue (&src, &val, src_end))
405
		return FALSE;
409
		return FALSE;
-
 
410
	      if (val < section->vma)
-
 
411
		val = section->vma;
406
	      section->size = val - section->vma;
412
	      section->size = val - section->vma;
-
 
413
	      /* PR 17512: file: objdump-s-endless-loop.tekhex.
-
 
414
	         Check for overlarge section sizes.  */
-
 
415
	      if (section->size & 0x80000000)
-
 
416
		return FALSE;
407
	      section->flags = SEC_HAS_CONTENTS | SEC_LOAD | SEC_ALLOC;
417
	      section->flags = SEC_HAS_CONTENTS | SEC_LOAD | SEC_ALLOC;
408
	      break;
418
	      break;
409
	    case '0':
419
	    case '0':
410
	    case '2':
420
	    case '2':
411
	    case '3':
421
	    case '3':
Line 426... Line 436...
426
		src++;
436
		src++;
427
		abfd->symcount++;
437
		abfd->symcount++;
428
		abfd->flags |= HAS_SYMS;
438
		abfd->flags |= HAS_SYMS;
429
		new_symbol->prev = abfd->tdata.tekhex_data->symbols;
439
		new_symbol->prev = abfd->tdata.tekhex_data->symbols;
430
		abfd->tdata.tekhex_data->symbols = new_symbol;
440
		abfd->tdata.tekhex_data->symbols = new_symbol;
431
		if (!getsym (sym, &src, &len))
441
		if (!getsym (sym, &src, &len, src_end))
432
		  return FALSE;
442
		  return FALSE;
433
		new_symbol->symbol.name = (const char *)
443
		new_symbol->symbol.name = (const char *)
434
                    bfd_alloc (abfd, (bfd_size_type) len + 1);
444
                    bfd_alloc (abfd, (bfd_size_type) len + 1);
435
		if (!new_symbol->symbol.name)
445
		if (!new_symbol->symbol.name)
436
		  return FALSE;
446
		  return FALSE;
Line 438... Line 448...
438
		new_symbol->symbol.section = section;
448
		new_symbol->symbol.section = section;
439
		if (stype <= '4')
449
		if (stype <= '4')
440
		  new_symbol->symbol.flags = (BSF_GLOBAL | BSF_EXPORT);
450
		  new_symbol->symbol.flags = (BSF_GLOBAL | BSF_EXPORT);
441
		else
451
		else
442
		  new_symbol->symbol.flags = BSF_LOCAL;
452
		  new_symbol->symbol.flags = BSF_LOCAL;
-
 
453
		if (stype == '2' || stype == '6')
-
 
454
		  new_symbol->symbol.section = bfd_abs_section_ptr;
-
 
455
		else if (stype == '3' || stype == '7')
-
 
456
		  {
-
 
457
		    if ((section->flags & SEC_DATA) == 0)
-
 
458
		      section->flags |= SEC_CODE;
-
 
459
		    else
-
 
460
		      {
-
 
461
			if (alt_section == NULL)
-
 
462
			  alt_section
-
 
463
			    = bfd_get_next_section_by_name (NULL, section);
-
 
464
			if (alt_section == NULL)
-
 
465
			  alt_section = bfd_make_section_anyway_with_flags
-
 
466
			    (abfd, section->name,
-
 
467
			     (section->flags & ~SEC_DATA) | SEC_CODE);
-
 
468
			if (alt_section == NULL)
-
 
469
			  return FALSE;
-
 
470
			new_symbol->symbol.section = alt_section;
-
 
471
		      }
-
 
472
		  }
-
 
473
		else if (stype == '4' || stype == '8')
-
 
474
		  {
-
 
475
		    if ((section->flags & SEC_CODE) == 0)
-
 
476
		      section->flags |= SEC_DATA;
-
 
477
		    else
-
 
478
		      {
-
 
479
			if (alt_section == NULL)
-
 
480
			  alt_section
-
 
481
			    = bfd_get_next_section_by_name (NULL, section);
-
 
482
			if (alt_section == NULL)
-
 
483
			  alt_section = bfd_make_section_anyway_with_flags
-
 
484
			    (abfd, section->name,
-
 
485
			     (section->flags & ~SEC_CODE) | SEC_DATA);
-
 
486
			if (alt_section == NULL)
-
 
487
			  return FALSE;
-
 
488
			new_symbol->symbol.section = alt_section;
-
 
489
		      }
-
 
490
		  }
443
		if (!getvalue (&src, &val))
491
		if (!getvalue (&src, &val, src_end))
444
		  return FALSE;
492
		  return FALSE;
445
		new_symbol->symbol.value = val - section->vma;
493
		new_symbol->symbol.value = val - section->vma;
446
		break;
494
		break;
447
	      }
495
	      }
448
	    default:
496
	    default:
Line 456... Line 504...
456
 
504
 
457
/* Pass over a tekhex, calling one of the above functions on each
505
/* Pass over a tekhex, calling one of the above functions on each
Line 458... Line 506...
458
   record.  */
506
   record.  */
459
 
507
 
460
static bfd_boolean
508
static bfd_boolean
461
pass_over (bfd *abfd, bfd_boolean (*func) (bfd *, int, char *))
509
pass_over (bfd *abfd, bfd_boolean (*func) (bfd *, int, char *, char *))
462
{
510
{
Line 463... Line 511...
463
  unsigned int chars_on_line;
511
  unsigned int chars_on_line;
Line 497... Line 545...
497
      if (bfd_bread (src, (bfd_size_type) chars_on_line, abfd) != chars_on_line)
545
      if (bfd_bread (src, (bfd_size_type) chars_on_line, abfd) != chars_on_line)
498
	return FALSE;
546
	return FALSE;
Line 499... Line 547...
499
 
547
 
500
      /* Put a null at the end.  */
548
      /* Put a null at the end.  */
501
      src[chars_on_line] = 0;
-
 
502
 
549
      src[chars_on_line] = 0;
503
      if (!func (abfd, type, src))
550
      if (!func (abfd, type, src, src + chars_on_line))
504
	return FALSE;
551
	return FALSE;
Line 505... Line 552...
505
    }
552
    }
506
 
553
 
Line 588... Line 635...
588
  for (addr = section->vma; count != 0; count--, addr++)
635
  for (addr = section->vma; count != 0; count--, addr++)
589
    {
636
    {
590
      /* Get high bits of address.  */
637
      /* Get high bits of address.  */
591
      bfd_vma chunk_number = addr & ~(bfd_vma) CHUNK_MASK;
638
      bfd_vma chunk_number = addr & ~(bfd_vma) CHUNK_MASK;
592
      bfd_vma low_bits = addr & CHUNK_MASK;
639
      bfd_vma low_bits = addr & CHUNK_MASK;
-
 
640
      bfd_boolean must_write = !get && *location != 0;
Line 593... Line 641...
593
 
641
 
-
 
642
      if (chunk_number != prev_number || (!d && must_write))
594
      if (chunk_number != prev_number)
643
	{
595
	/* Different chunk, so move pointer. */
644
	/* Different chunk, so move pointer. */
-
 
645
	  d = find_chunk (abfd, chunk_number, must_write);
-
 
646
	  prev_number = chunk_number;
Line 596... Line 647...
596
	d = find_chunk (abfd, chunk_number);
647
	}
597
 
648
 
598
      if (get)
649
      if (get)
599
	{
650
	{
600
	  if (d->chunk_init[low_bits])
651
	  if (d)
601
	    *location = d->chunk_data[low_bits];
652
	    *location = d->chunk_data[low_bits];
602
	  else
653
	  else
603
	    *location = 0;
654
	    *location = 0;
604
	}
655
	}
605
      else
656
      else if (must_write)
606
	{
657
	{
607
	  d->chunk_data[low_bits] = *location;
658
	  d->chunk_data[low_bits] = *location;
Line 608... Line 659...
608
	  d->chunk_init[low_bits] = (*location != 0);
659
	  d->chunk_init[low_bits / CHUNK_SPAN] = 1;
609
	}
660
	}
610
 
661
 
Line 631... Line 682...
631
static bfd_boolean
682
static bfd_boolean
632
tekhex_set_arch_mach (bfd *abfd,
683
tekhex_set_arch_mach (bfd *abfd,
633
		      enum bfd_architecture arch,
684
		      enum bfd_architecture arch,
634
		      unsigned long machine)
685
		      unsigned long machine)
635
{
686
{
-
 
687
  /* Ignore errors about unknown architecture.  */
636
  return bfd_default_set_arch_mach (abfd, arch, machine);
688
  return (bfd_default_set_arch_mach (abfd, arch, machine)
-
 
689
	  || arch == bfd_arch_unknown);
637
}
690
}
Line 638... Line 691...
638
 
691
 
Line 639... Line 692...
639
/* We have to save up all the Tekhexords for a splurge before output.  */
692
/* We have to save up all the Tekhexords for a splurge before output.  */
Line 643... Line 696...
643
			     sec_ptr section,
696
			     sec_ptr section,
644
			     const void * locationp,
697
			     const void * locationp,
645
			     file_ptr offset,
698
			     file_ptr offset,
646
			     bfd_size_type bytes_to_do)
699
			     bfd_size_type bytes_to_do)
647
{
700
{
648
  if (! abfd->output_has_begun)
-
 
649
    {
-
 
650
      /* The first time around, allocate enough sections to hold all the chunks.  */
-
 
651
      asection *s = abfd->sections;
-
 
652
      bfd_vma vma;
-
 
653
 
-
 
654
      for (s = abfd->sections; s; s = s->next)
-
 
655
	{
-
 
656
	  if (s->flags & SEC_LOAD)
-
 
657
	    {
-
 
658
	      for (vma = s->vma & ~(bfd_vma) CHUNK_MASK;
-
 
659
		   vma < s->vma + s->size;
-
 
660
		   vma += CHUNK_MASK)
-
 
661
		find_chunk (abfd, vma);
-
 
662
	    }
-
 
663
	}
-
 
664
    }
-
 
665
 
-
 
666
  if (section->flags & (SEC_LOAD | SEC_ALLOC))
701
  if (section->flags & (SEC_LOAD | SEC_ALLOC))
667
    {
702
    {
668
      move_section_contents (abfd, section, locationp, offset, bytes_to_do,
703
      move_section_contents (abfd, section, locationp, offset, bytes_to_do,
669
			     FALSE);
704
			     FALSE);
670
      return TRUE;
705
      return TRUE;
Line 771... Line 806...
771
  for (d = abfd->tdata.tekhex_data->data;
806
  for (d = abfd->tdata.tekhex_data->data;
772
       d != NULL;
807
       d != NULL;
773
       d = d->next)
808
       d = d->next)
774
    {
809
    {
775
      int low;
810
      int low;
776
 
-
 
777
      const int span = 32;
-
 
778
      int addr;
811
      int addr;
Line 779... Line 812...
779
 
812
 
780
      /* Write it in blocks of 32 bytes.  */
813
      /* Write it in blocks of 32 bytes.  */
781
      for (addr = 0; addr < CHUNK_MASK + 1; addr += span)
814
      for (addr = 0; addr < CHUNK_MASK + 1; addr += CHUNK_SPAN)
782
	{
-
 
783
	  int need = 0;
-
 
784
 
-
 
785
	  /* Check to see if necessary.  */
-
 
786
	  for (low = 0; !need && low < span; low++)
815
	{
787
	    if (d->chunk_init[addr + low])
-
 
788
	      need = 1;
-
 
789
 
-
 
790
	  if (need)
816
	  if (d->chunk_init[addr / CHUNK_SPAN])
791
	    {
817
	    {
Line 792... Line 818...
792
	      char *dst = buffer;
818
	      char *dst = buffer;
793
 
819
 
794
	      writevalue (&dst, addr + d->vma);
820
	      writevalue (&dst, addr + d->vma);
795
	      for (low = 0; low < span; low++)
821
	      for (low = 0; low < CHUNK_SPAN; low++)
796
		{
822
		{
797
		  TOHEX (dst, d->chunk_data[addr + low]);
823
		  TOHEX (dst, d->chunk_data[addr + low]);
798
		  dst += 2;
824
		  dst += 2;
Line 934... Line 960...
934
#define tekhex_new_section_hook                     _bfd_generic_new_section_hook
960
#define tekhex_new_section_hook                     _bfd_generic_new_section_hook
935
#define tekhex_bfd_is_target_special_symbol ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
961
#define tekhex_bfd_is_target_special_symbol ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
936
#define tekhex_bfd_is_local_label_name               bfd_generic_is_local_label_name
962
#define tekhex_bfd_is_local_label_name               bfd_generic_is_local_label_name
937
#define tekhex_get_lineno                           _bfd_nosymbols_get_lineno
963
#define tekhex_get_lineno                           _bfd_nosymbols_get_lineno
938
#define tekhex_find_nearest_line                    _bfd_nosymbols_find_nearest_line
964
#define tekhex_find_nearest_line                    _bfd_nosymbols_find_nearest_line
-
 
965
#define tekhex_find_line                            _bfd_nosymbols_find_line
939
#define tekhex_find_inliner_info                    _bfd_nosymbols_find_inliner_info
966
#define tekhex_find_inliner_info                    _bfd_nosymbols_find_inliner_info
-
 
967
#define tekhex_get_symbol_version_string	    _bfd_nosymbols_get_symbol_version_string
940
#define tekhex_bfd_make_debug_symbol                _bfd_nosymbols_bfd_make_debug_symbol
968
#define tekhex_bfd_make_debug_symbol                _bfd_nosymbols_bfd_make_debug_symbol
941
#define tekhex_read_minisymbols                     _bfd_generic_read_minisymbols
969
#define tekhex_read_minisymbols                     _bfd_generic_read_minisymbols
942
#define tekhex_minisymbol_to_symbol                 _bfd_generic_minisymbol_to_symbol
970
#define tekhex_minisymbol_to_symbol                 _bfd_generic_minisymbol_to_symbol
943
#define tekhex_bfd_get_relocated_section_contents   bfd_generic_get_relocated_section_contents
971
#define tekhex_bfd_get_relocated_section_contents   bfd_generic_get_relocated_section_contents
944
#define tekhex_bfd_relax_section                    bfd_generic_relax_section
972
#define tekhex_bfd_relax_section                    bfd_generic_relax_section
Line 948... Line 976...
948
#define tekhex_bfd_is_group_section                 bfd_generic_is_group_section
976
#define tekhex_bfd_is_group_section                 bfd_generic_is_group_section
949
#define tekhex_bfd_discard_group                    bfd_generic_discard_group
977
#define tekhex_bfd_discard_group                    bfd_generic_discard_group
950
#define tekhex_section_already_linked               _bfd_generic_section_already_linked
978
#define tekhex_section_already_linked               _bfd_generic_section_already_linked
951
#define tekhex_bfd_define_common_symbol             bfd_generic_define_common_symbol
979
#define tekhex_bfd_define_common_symbol             bfd_generic_define_common_symbol
952
#define tekhex_bfd_link_hash_table_create           _bfd_generic_link_hash_table_create
980
#define tekhex_bfd_link_hash_table_create           _bfd_generic_link_hash_table_create
953
#define tekhex_bfd_link_hash_table_free             _bfd_generic_link_hash_table_free
-
 
954
#define tekhex_bfd_link_add_symbols                 _bfd_generic_link_add_symbols
981
#define tekhex_bfd_link_add_symbols                 _bfd_generic_link_add_symbols
955
#define tekhex_bfd_link_just_syms                   _bfd_generic_link_just_syms
982
#define tekhex_bfd_link_just_syms                   _bfd_generic_link_just_syms
956
#define tekhex_bfd_copy_link_hash_symbol_type \
983
#define tekhex_bfd_copy_link_hash_symbol_type \
957
  _bfd_generic_copy_link_hash_symbol_type
984
  _bfd_generic_copy_link_hash_symbol_type
958
#define tekhex_bfd_final_link                       _bfd_generic_final_link
985
#define tekhex_bfd_final_link                       _bfd_generic_final_link