Deleted Added
full compact
elf32-i386.c (104840) elf32-i386.c (107497)
1/* Intel 80386/80486-specific support for 32-bit ELF
2 Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
3 Free Software Foundation, Inc.
4
5This file is part of BFD, the Binary File Descriptor library.
6
7This program is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by

--- 4 unchanged lines hidden (view full) ---

13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with this program; if not, write to the Free Software
19Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
20
1/* Intel 80386/80486-specific support for 32-bit ELF
2 Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
3 Free Software Foundation, Inc.
4
5This file is part of BFD, the Binary File Descriptor library.
6
7This program is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by

--- 4 unchanged lines hidden (view full) ---

13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with this program; if not, write to the Free Software
19Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
20
21/* $FreeBSD: head/contrib/binutils/bfd/elf32-i386.c 104840 2002-10-11 06:10:28Z obrien $ */
21/* $FreeBSD: head/contrib/binutils/bfd/elf32-i386.c 107497 2002-12-02 09:22:58Z obrien $ */
22
23#include "bfd.h"
24#include "sysdep.h"
25#include "bfdlink.h"
26#include "libbfd.h"
27#include "elf-bfd.h"
28
29static reloc_howto_type *elf_i386_reloc_type_lookup

--- 471 unchanged lines hidden (view full) ---

501 from external routines. eg. elf_i386_check_relocs is called
502 early in the link process, elf_i386_finish_dynamic_sections is
503 one of the last functions. */
504
505
506/* The name of the dynamic interpreter. This is put in the .interp
507 section. */
508
22
23#include "bfd.h"
24#include "sysdep.h"
25#include "bfdlink.h"
26#include "libbfd.h"
27#include "elf-bfd.h"
28
29static reloc_howto_type *elf_i386_reloc_type_lookup

--- 471 unchanged lines hidden (view full) ---

501 from external routines. eg. elf_i386_check_relocs is called
502 early in the link process, elf_i386_finish_dynamic_sections is
503 one of the last functions. */
504
505
506/* The name of the dynamic interpreter. This is put in the .interp
507 section. */
508
509
510#ifndef ELF_DYNAMIC_INTERPRETER
511#define ELF_DYNAMIC_INTERPRETER "/usr/lib/libc.so.1"
509#define ELF_DYNAMIC_INTERPRETER "/usr/lib/libc.so.1"
512#endif
513
510
514
515/* The size in bytes of an entry in the procedure linkage table. */
516
517#define PLT_ENTRY_SIZE 16
518
519/* The first entry in an absolute procedure linkage table looks like
520 this. See the SVR4 ABI i386 supplement to see how this works. */
521
522static const bfd_byte elf_i386_plt0_entry[PLT_ENTRY_SIZE] =

--- 2094 unchanged lines hidden (view full) ---

2617 addl foo, %reg
2618 We change it into:
2619 movl $foo, %eax
2620 movl $foo, %reg
2621 addl $foo, %reg. */
2622 BFD_ASSERT (rel->r_offset >= 1);
2623 val = bfd_get_8 (input_bfd, contents + rel->r_offset - 1);
2624 BFD_ASSERT (rel->r_offset + 4 <= input_section->_raw_size);
511/* The size in bytes of an entry in the procedure linkage table. */
512
513#define PLT_ENTRY_SIZE 16
514
515/* The first entry in an absolute procedure linkage table looks like
516 this. See the SVR4 ABI i386 supplement to see how this works. */
517
518static const bfd_byte elf_i386_plt0_entry[PLT_ENTRY_SIZE] =

--- 2094 unchanged lines hidden (view full) ---

2613 addl foo, %reg
2614 We change it into:
2615 movl $foo, %eax
2616 movl $foo, %reg
2617 addl $foo, %reg. */
2618 BFD_ASSERT (rel->r_offset >= 1);
2619 val = bfd_get_8 (input_bfd, contents + rel->r_offset - 1);
2620 BFD_ASSERT (rel->r_offset + 4 <= input_section->_raw_size);
2625 if (val != 0xa1)
2626 {
2627 BFD_ASSERT (rel->r_offset >= 2);
2628 type = bfd_get_8 (input_bfd, contents + rel->r_offset - 2);
2629 }
2630 if (val == 0xa1)
2631 {
2632 /* movl foo, %eax. */
2621 if (val == 0xa1)
2622 {
2623 /* movl foo, %eax. */
2633 bfd_put_8 (output_bfd, 0xb8, contents + rel->r_offset - 2);
2624 bfd_put_8 (output_bfd, 0xb8, contents + rel->r_offset - 1);
2634 }
2625 }
2635 else if (type == 0x8b)
2626 else
2636 {
2627 {
2637 /* movl */
2638 BFD_ASSERT ((val & 0xc7) == 0x05);
2639 bfd_put_8 (output_bfd, 0xc7,
2640 contents + rel->r_offset - 2);
2641 bfd_put_8 (output_bfd, 0xc0 | ((val >> 3) & 7),
2642 contents + rel->r_offset - 1);
2628 BFD_ASSERT (rel->r_offset >= 2);
2629 type = bfd_get_8 (input_bfd, contents + rel->r_offset - 2);
2630 switch (type)
2631 {
2632 case 0x8b:
2633 /* movl */
2634 BFD_ASSERT ((val & 0xc7) == 0x05);
2635 bfd_put_8 (output_bfd, 0xc7,
2636 contents + rel->r_offset - 2);
2637 bfd_put_8 (output_bfd,
2638 0xc0 | ((val >> 3) & 7),
2639 contents + rel->r_offset - 1);
2640 break;
2641 case 0x03:
2642 /* addl */
2643 BFD_ASSERT ((val & 0xc7) == 0x05);
2644 bfd_put_8 (output_bfd, 0x81,
2645 contents + rel->r_offset - 2);
2646 bfd_put_8 (output_bfd,
2647 0xc0 | ((val >> 3) & 7),
2648 contents + rel->r_offset - 1);
2649 break;
2650 default:
2651 BFD_FAIL ();
2652 break;
2653 }
2643 }
2654 }
2644 else if (type == 0x03)
2645 {
2646 /* addl */
2647 BFD_ASSERT ((val & 0xc7) == 0x05);
2648 bfd_put_8 (output_bfd, 0x81,
2649 contents + rel->r_offset - 2);
2650 bfd_put_8 (output_bfd, 0xc0 | ((val >> 3) & 7),
2651 contents + rel->r_offset - 1);
2652 }
2653 else
2654 BFD_FAIL ();
2655 bfd_put_32 (output_bfd, -tpoff (info, relocation),
2656 contents + rel->r_offset);
2657 continue;
2658 }
2659 else
2660 {
2661 unsigned int val, type;
2662

--- 722 unchanged lines hidden (view full) ---

3385#define elf_backend_gc_mark_hook elf_i386_gc_mark_hook
3386#define elf_backend_gc_sweep_hook elf_i386_gc_sweep_hook
3387#define elf_backend_grok_prstatus elf_i386_grok_prstatus
3388#define elf_backend_grok_psinfo elf_i386_grok_psinfo
3389#define elf_backend_reloc_type_class elf_i386_reloc_type_class
3390#define elf_backend_relocate_section elf_i386_relocate_section
3391#define elf_backend_size_dynamic_sections elf_i386_size_dynamic_sections
3392
2655 bfd_put_32 (output_bfd, -tpoff (info, relocation),
2656 contents + rel->r_offset);
2657 continue;
2658 }
2659 else
2660 {
2661 unsigned int val, type;
2662

--- 722 unchanged lines hidden (view full) ---

3385#define elf_backend_gc_mark_hook elf_i386_gc_mark_hook
3386#define elf_backend_gc_sweep_hook elf_i386_gc_sweep_hook
3387#define elf_backend_grok_prstatus elf_i386_grok_prstatus
3388#define elf_backend_grok_psinfo elf_i386_grok_psinfo
3389#define elf_backend_reloc_type_class elf_i386_reloc_type_class
3390#define elf_backend_relocate_section elf_i386_relocate_section
3391#define elf_backend_size_dynamic_sections elf_i386_size_dynamic_sections
3392
3393#ifndef ELF32_I386_C_INCLUDED
3394#include "elf32-target.h"
3393#include "elf32-target.h"
3395#endif