diff options
author | Alan Modra <amodra@gmail.com> | 2018-01-18 22:06:40 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2018-01-18 22:25:21 +1030 |
commit | 691d2e9af211ff8dd5fa8c96cb961b73a78394d7 (patch) | |
tree | e50abd115ac31293734bb1f32b9fd2a07adcf926 /gold | |
parent | 7ab820379890dc68699ba5acf8ab4f03053fa2b0 (diff) | |
download | gdb-691d2e9af211ff8dd5fa8c96cb961b73a78394d7.zip gdb-691d2e9af211ff8dd5fa8c96cb961b73a78394d7.tar.gz gdb-691d2e9af211ff8dd5fa8c96cb961b73a78394d7.tar.bz2 |
PowerPC PLT stub alignment fixes
Asking for ppc32 plt call stubs to be aligned at 32 byte boundaries
didn't quite work. For ld.bfd they were spaced 32 bytes apart, but
only started on a 16 byte boundary. ld.gold also didn't get it right.
Finding that bug made me check over the ppc64 plt stub alignment,
where I found that negative values for alignment (meaning align to
minimize boundary crossing) were not accepted. Since no one has
complained about that, I guess I could have removed the feature from
ld.bfd documentation, but I've opted instead to correct the code.
I've also added an optional alignment paramenter for ppc32
--plt-align, for some consistency with gold and ppc64 ld.bfd.
bfd/
* elf32-ppc.c (ppc_elf_create_glink): Correct alignment of .glink.
* elf64-ppc.c (ppc64_elf_size_stubs): Handle negative plt_stub_align.
(ppc64_elf_build_stubs): Likewise.
gold/
* powerpc.cc (param_plt_align): New function supplying default
--plt-align values. Use it..
(Stub_table::plt_call_align): ..here, and..
(Output_data_glink::global_entry_align): ..here.
(Stub_table::stub_align): Correct 32-bit minimum alignment.
ld/
* emultempl/ppc32elf.em: Support optional --plt-align arg.
* emultempl/ppc64elf.em: Support negative --plt-align arg.
Diffstat (limited to 'gold')
-rw-r--r-- | gold/ChangeLog | 8 | ||||
-rw-r--r-- | gold/powerpc.cc | 19 |
2 files changed, 20 insertions, 7 deletions
diff --git a/gold/ChangeLog b/gold/ChangeLog index ec56a89..b833a7b 100644 --- a/gold/ChangeLog +++ b/gold/ChangeLog @@ -1,3 +1,11 @@ +2018-01-18 Alan Modra <amodra@gmail.com> + + * powerpc.cc (param_plt_align): New function supplying default + --plt-align values. Use it.. + (Stub_table::plt_call_align): ..here, and.. + (Output_data_glink::global_entry_align): ..here. + (Stub_table::stub_align): Correct 32-bit minimum alignment. + 2018-01-17 Alan Modra <amodra@gmail.com> * options.h (speculate_indirect_jumps): New option. diff --git a/gold/powerpc.cc b/gold/powerpc.cc index 6b65792..3c38a06 100644 --- a/gold/powerpc.cc +++ b/gold/powerpc.cc @@ -4186,6 +4186,15 @@ output_bctr(unsigned char* p) return p; } +template<int size> +static inline unsigned int +param_plt_align() +{ + if (!parameters->options().user_set_plt_align()) + return size == 64 ? 32 : 8; + return 1 << parameters->options().plt_align(); +} + // Stub_table holds information about plt and long branch stubs. // Stubs are built in an area following some input section determined // by group_sections(). This input section is converted to a relaxed @@ -4412,9 +4421,7 @@ class Stub_table : public Output_relaxed_input_section unsigned int stub_align() const { - unsigned int min_align = 4; - if (!parameters->options().user_set_plt_align()) - return size == 64 ? 32 : min_align; + unsigned int min_align = size == 64 ? 32 : 16; unsigned int user_align = 1 << parameters->options().plt_align(); return std::max(user_align, min_align); } @@ -4483,7 +4490,7 @@ class Stub_table : public Output_relaxed_input_section unsigned int plt_call_align(unsigned int bytes) const { - unsigned int align = this->stub_align(); + unsigned int align = param_plt_align<size>(); return (bytes + align - 1) & -align; } @@ -4926,9 +4933,7 @@ class Output_data_glink : public Output_section_data unsigned int global_entry_align(unsigned int off) const { - unsigned int align = 1 << parameters->options().plt_align(); - if (!parameters->options().user_set_plt_align()) - align = size == 64 ? 32 : 4; + unsigned int align = param_plt_align<size>(); return (off + align - 1) & -align; } |