diff options
author | Thiemo Seufer <ths@networkno.de> | 2005-03-05 00:01:44 +0000 |
---|---|---|
committer | Thiemo Seufer <ths@networkno.de> | 2005-03-05 00:01:44 +0000 |
commit | bbe506e8ba9444fb4a00ba66762a2c498443e1b6 (patch) | |
tree | 4989bcc748cfc73d2cfb45f9321ee5247cde59ec | |
parent | 92862f42b561a218a220939cd8a1bef7c9756d06 (diff) | |
download | gdb-bbe506e8ba9444fb4a00ba66762a2c498443e1b6.zip gdb-bbe506e8ba9444fb4a00ba66762a2c498443e1b6.tar.gz gdb-bbe506e8ba9444fb4a00ba66762a2c498443e1b6.tar.bz2 |
bfd/ChangeLog
* elfxx-mips.c (mips_elf_calculate_relocation): Handle special
'__gnu_local_gp' symbol used by gas -mno-shared.
gas/ChangeLog
* config/tc-mips.c (macro_build_lui): Use '__gnu_local_gp'
instead of '_gp' for -mno-shared optimization.
(s_cpload): Ditto.
(s_abicalls): Document it in the comment.
(md_show_usage): Document the -mno-shared option.
gas/testsuite/ChangeLog
* gas/mips/elf-rel23b.d: Use '__gnu_local_gp' instead of '_gp'
for -mno-shared optimization.
* gas/mips/elf-rel25a.d: Ditto.
ld/testsuite/ChangeLog
* ld-mips-elf/multi-got-no-shared-1.s,
ld-mips-elf/multi-got-no-shared-2.s,
ld-mips-elf/multi-got-no-shared.d: New tests.
* ld-mips-elf/mips-elf.exp: Run them.
-rw-r--r-- | bfd/ChangeLog | 5 | ||||
-rw-r--r-- | bfd/elfxx-mips.c | 12 | ||||
-rw-r--r-- | gas/ChangeLog | 8 | ||||
-rw-r--r-- | gas/config/tc-mips.c | 20 | ||||
-rw-r--r-- | gas/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gas/testsuite/gas/mips/elf-rel23b.d | 4 | ||||
-rw-r--r-- | gas/testsuite/gas/mips/elf-rel25a.d | 4 | ||||
-rw-r--r-- | ld/testsuite/ChangeLog | 7 | ||||
-rw-r--r-- | ld/testsuite/ld-mips-elf/mips-elf.exp | 1 | ||||
-rw-r--r-- | ld/testsuite/ld-mips-elf/multi-got-no-shared-1.s | 29 | ||||
-rw-r--r-- | ld/testsuite/ld-mips-elf/multi-got-no-shared-2.s | 27 | ||||
-rw-r--r-- | ld/testsuite/ld-mips-elf/multi-got-no-shared.d | 18 |
12 files changed, 129 insertions, 12 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index b2d3a3f..af8d64e 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,8 @@ +2005-03-04 David Daney <ddaney@avtrex.com> + + * elfxx-mips.c (mips_elf_calculate_relocation): Handle special + '__gnu_local_gp' symbol used by gas -mno-shared. + 2005-03-03 H.J. Lu <hongjiu.lu@intel.com> * elf-bfd.h (elf_backend_data): Add "const char *" to diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c index 5c2e5b4..847e7e6 100644 --- a/bfd/elfxx-mips.c +++ b/bfd/elfxx-mips.c @@ -3646,6 +3646,9 @@ mips_elf_calculate_relocation (bfd *abfd, bfd *input_bfd, bfd_boolean local_p, was_local_p; /* TRUE if the symbol referred to by this relocation is "_gp_disp". */ bfd_boolean gp_disp_p = FALSE; + /* TRUE if the symbol referred to by this relocation is + "__gnu_local_gp". */ + bfd_boolean gnu_local_gp_p = FALSE; Elf_Internal_Shdr *symtab_hdr; size_t extsymoff; unsigned long r_symndx; @@ -3742,6 +3745,12 @@ mips_elf_calculate_relocation (bfd *abfd, bfd *input_bfd, gp_disp_p = TRUE; } + /* See if this is the special _gp symbol. Note that such a + symbol must always be a global symbol. */ + else if (strcmp (*namep, "__gnu_local_gp") == 0) + gnu_local_gp_p = TRUE; + + /* If this symbol is defined, calculate its address. Note that _gp_disp is a magic symbol, always implicitly defined by the linker, so it's inappropriate to check to see whether or not @@ -3956,6 +3965,9 @@ mips_elf_calculate_relocation (bfd *abfd, bfd *input_bfd, break; } + if (gnu_local_gp_p) + symbol = gp; + /* Figure out what kind of relocation is being performed. */ switch (r_type) { diff --git a/gas/ChangeLog b/gas/ChangeLog index efd2db9..1892de8 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,11 @@ +2005-03-04 David Daney <ddaney@avtrex.com> + + * config/tc-mips.c (macro_build_lui): Use '__gnu_local_gp' + instead of '_gp' for -mno-shared optimization. + (s_cpload): Ditto. + (s_abicalls): Document it in the comment. + (md_show_usage): Document the -mno-shared option. + 2005-03-04 Richard Sandiford <rsandifo@redhat.com> * config/tc-mips.c (mips_set_options): Add sym32 field. diff --git a/gas/config/tc-mips.c b/gas/config/tc-mips.c index a0ad808..284d09c 100644 --- a/gas/config/tc-mips.c +++ b/gas/config/tc-mips.c @@ -3393,13 +3393,14 @@ macro_build_lui (expressionS *ep, int regnum) else { assert (ep->X_op == O_symbol); - /* _gp_disp is a special case, used from s_cpload. _gp is used - if mips_no_shared. */ + /* _gp_disp is a special case, used from s_cpload. + __gnu_local_gp is used if mips_no_shared. */ assert (mips_pic == NO_PIC || (! HAVE_NEWABI && strcmp (S_GET_NAME (ep->X_add_symbol), "_gp_disp") == 0) || (! mips_in_shared - && strcmp (S_GET_NAME (ep->X_add_symbol), "_gp") == 0)); + && strcmp (S_GET_NAME (ep->X_add_symbol), + "__gnu_local_gp") == 0)); *r = BFD_RELOC_HI16_S; } @@ -11819,12 +11820,12 @@ s_abicalls (int ignore ATTRIBUTE_UNUSED) The .cpload argument is normally $25 == $t9. The -mno-shared option changes this to: - lui $gp,%hi(_gp) - addiu $gp,$gp,%lo(_gp) + lui $gp,%hi(__gnu_local_gp) + addiu $gp,$gp,%lo(__gnu_local_gp) and the argument is ignored. This saves an instruction, but the resulting code is not position independent; it uses an absolute - address for _gp. Thus code assembled with -mno-shared can go into - an ordinary executable, but not into a shared library. */ + address for __gnu_local_gp. Thus code assembled with -mno-shared + can go into an ordinary executable, but not into a shared library. */ static void s_cpload (int ignore ATTRIBUTE_UNUSED) @@ -11852,7 +11853,8 @@ s_cpload (int ignore ATTRIBUTE_UNUSED) in_shared = mips_in_shared || HAVE_64BIT_SYMBOLS; ex.X_op = O_symbol; - ex.X_add_symbol = symbol_find_or_make (in_shared ? "_gp_disp" : "_gp"); + ex.X_add_symbol = symbol_find_or_make (in_shared ? "_gp_disp" : + "__gnu_local_gp"); ex.X_op_symbol = NULL; ex.X_add_number = 0; @@ -14118,6 +14120,8 @@ MIPS options:\n\ -non_shared do not generate position independent code\n\ -xgot assume a 32 bit GOT\n\ -mpdr, -mno-pdr enable/disable creation of .pdr sections\n\ +-mshared, -mno-shared disable/enable .cpload optimization for\n\ + non-shared code\n\ -mabi=ABI create ABI conformant object file for:\n")); first = 1; diff --git a/gas/testsuite/ChangeLog b/gas/testsuite/ChangeLog index 077b7b6..21a8ff6c 100644 --- a/gas/testsuite/ChangeLog +++ b/gas/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2005-03-04 David Daney <ddaney@avtrex.com> + + * gas/mips/elf-rel23b.d: Use '__gnu_local_gp' instead of '_gp' + for -mno-shared optimization. + * gas/mips/elf-rel25a.d: Ditto. + 2005-03-04 Nick Clifton <nickc@redhat.com> * gas/arm/arm.exp: Fix test for running the "undefined" to catch diff --git a/gas/testsuite/gas/mips/elf-rel23b.d b/gas/testsuite/gas/mips/elf-rel23b.d index b144a84..7c02f15 100644 --- a/gas/testsuite/gas/mips/elf-rel23b.d +++ b/gas/testsuite/gas/mips/elf-rel23b.d @@ -10,7 +10,7 @@ Disassembly of section \.text: 0+00 <.*>: .*: 0380282d move \$5,\$28 .*: 3c1c0000 lui \$28,0x0 - .*: R_MIPS_HI16 _gp + .*: R_MIPS_HI16 __gnu_local_gp .*: 279c0000 addiu \$28,\$28,0 - .*: R_MIPS_LO16 _gp + .*: R_MIPS_LO16 __gnu_local_gp .*: 00000000 nop diff --git a/gas/testsuite/gas/mips/elf-rel25a.d b/gas/testsuite/gas/mips/elf-rel25a.d index 5c45f1e..a7d30a5 100644 --- a/gas/testsuite/gas/mips/elf-rel25a.d +++ b/gas/testsuite/gas/mips/elf-rel25a.d @@ -9,7 +9,7 @@ Disassembly of section \.text: 0+00 <.*>: .*: 3c1c0000 lui \$28,0x0 - .*: R_MIPS_HI16 _gp + .*: R_MIPS_HI16 __gnu_local_gp .*: 279c0000 addiu \$28,\$28,0 - .*: R_MIPS_LO16 _gp + .*: R_MIPS_LO16 __gnu_local_gp #pass diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog index e49ff3e..92530c8 100644 --- a/ld/testsuite/ChangeLog +++ b/ld/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2005-03-04 David Daney <ddaney@avtrex.com> + + * ld-mips-elf/multi-got-no-shared-1.s, + ld-mips-elf/multi-got-no-shared-2.s, + ld-mips-elf/multi-got-no-shared.d: New tests. + * ld-mips-elf/mips-elf.exp: Run them. + 2005-03-02 Daniel Jacobowitz <dan@codesourcery.com> * ld-mips-elf/tlsbin-o32.s, ld-mips-elf/mips-dyn.ld, diff --git a/ld/testsuite/ld-mips-elf/mips-elf.exp b/ld/testsuite/ld-mips-elf/mips-elf.exp index 6cc7d9a..5413a72 100644 --- a/ld/testsuite/ld-mips-elf/mips-elf.exp +++ b/ld/testsuite/ld-mips-elf/mips-elf.exp @@ -35,6 +35,7 @@ run_dump_test "branch-misc-1" # the "traditional" emulations. if { $linux_gnu } { run_dump_test "multi-got-1" + run_dump_test "multi-got-no-shared" } if $has_newabi { diff --git a/ld/testsuite/ld-mips-elf/multi-got-no-shared-1.s b/ld/testsuite/ld-mips-elf/multi-got-no-shared-1.s new file mode 100644 index 0000000..a2eee84 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/multi-got-no-shared-1.s @@ -0,0 +1,29 @@ + .macro one_sym count + .globl sym_1_\count +sym_1_\count: + la $2, sym_1_\count + .endm + + + .text + .globl func1 + .ent func1 +func1: + .frame $sp,0,$31 + .set noreorder + .cpload $25 + .set reorder + .cprestore 8 + .set noreorder + + .irp thou,0,1,2,3,4,5,6,7,8 + .irp hund,0,1,2,3,4,5,6,7,8,9 + .irp tens,0,1,2,3,4,5,6,7,8,9 + .irp ones,0,1,2,3,4,5,6,7,8,9 + one_sym \thou\hund\tens\ones + .endr + .endr + .endr + .endr + + .end func1 diff --git a/ld/testsuite/ld-mips-elf/multi-got-no-shared-2.s b/ld/testsuite/ld-mips-elf/multi-got-no-shared-2.s new file mode 100644 index 0000000..1de7a14 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/multi-got-no-shared-2.s @@ -0,0 +1,27 @@ + .macro one_sym count + .globl sym_2_\count +sym_2_\count: + la $2, sym_2_\count + .endm + + .text + .ent func2 +func2: + .frame $sp,0,$31 + .set noreorder + .cpload $25 + .set reorder + .cprestore 8 + .set noreorder + + .irp thou,0,1,2,3,4,5,6,7,8 + .irp hund,0,1,2,3,4,5,6,7,8,9 + .irp tens,0,1,2,3,4,5,6,7,8,9 + .irp ones,0,1,2,3,4,5,6,7,8,9 + one_sym \thou\hund\tens\ones + .endr + .endr + .endr + .endr + + .end func2 diff --git a/ld/testsuite/ld-mips-elf/multi-got-no-shared.d b/ld/testsuite/ld-mips-elf/multi-got-no-shared.d new file mode 100644 index 0000000..d072864 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/multi-got-no-shared.d @@ -0,0 +1,18 @@ +#name: MIPS multi-got-no-shared +#as: -EB -32 -KPIC -mno-shared +#source: multi-got-no-shared-1.s +#source: multi-got-no-shared-2.s +#ld: -melf32btsmip --entry func1 +#objdump: -D -j .text --prefix-addresses --show-raw-insn + +.*: +file format.* + +Disassembly of section \.text: +004000b0 <[^>]*> 3c1c1000 lui gp,0x1000 +004000b4 <[^>]*> 279c7ff0 addiu gp,gp,32752 +004000b8 <[^>]*> afbc0008 sw gp,8\(sp\) +#... +00408d60 <[^>]*> 3c1c1002 lui gp,0x1002 +00408d64 <[^>]*> 279c9960 addiu gp,gp,-26272 +00408d68 <[^>]*> afbc0008 sw gp,8\(sp\) +#pass |