Skip to content

Commit 005d79f

Browse files
committed
PowerPC .gnu.attributes
This patch extends Tag_GNU_Power_ABI_FP to cover long double ABIs, makes the assembler warn about undefined tag values, and removes similar warnings from the linker. I think it is better to not warn in the linker about undefined tag values as future extensions to the tags then won't result in likely bogus warnings. This is consistent with the fact that an older linker won't warn on an entirely new tag. include/ * elf/ppc.h (Tag_GNU_Power_ABI_FP): Comment. bfd/ * elf-bfd.h (_bfd_elf_ppc_merge_fp_attributes): Declare. * elf32-ppc.c (_bfd_elf_ppc_merge_fp_attributes): New function. (ppc_elf_merge_obj_attributes): Use it. Don't copy first file attributes, merge them. Don't warn about undefined tag bits, or copy unknown values to output. * elf64-ppc.c (ppc64_elf_merge_private_bfd_data): Call _bfd_elf_ppc_merge_fp_attributes. binutils/ * readelf.c (display_power_gnu_attribute): Catch truncated section for all powerpc attributes. Display long double ABI. Don't capitalize words, except for names. Show known bits of tag values when some unknown bits are present. Whitespace fixes. gas/ * config/tc-ppc.c (ppc_elf_gnu_attribute): New function. (md_pseudo_table <ELF>): Handle "gnu_attribute". ld/ * testsuite/ld-powerpc/attr-gnu-4-4.s: Delete. * testsuite/ld-powerpc/attr-gnu-4-14.d: Delete. * testsuite/ld-powerpc/attr-gnu-4-24.d: Delete. * testsuite/ld-powerpc/attr-gnu-4-34.d: Delete. * testsuite/ld-powerpc/attr-gnu-4-41.d: Delete. * testsuite/ld-powerpc/attr-gnu-4-32.d: Adjust expected warning. * testsuite/ld-powerpc/attr-gnu-8-23.d: Likewise. * testsuite/ld-powerpc/attr-gnu-4-01.d: Adjust expected output. * testsuite/ld-powerpc/attr-gnu-4-02.d: Likewise. * testsuite/ld-powerpc/attr-gnu-4-03.d: Likewise. * testsuite/ld-powerpc/attr-gnu-4-10.d: Likewise. * testsuite/ld-powerpc/attr-gnu-4-11.d: Likewise. * testsuite/ld-powerpc/attr-gnu-4-20.d: Likewise. * testsuite/ld-powerpc/attr-gnu-4-22.d: Likewise. * testsuite/ld-powerpc/attr-gnu-4-33.d: Likewise. * testsuite/ld-powerpc/attr-gnu-8-11.d: Likewise. * testsuite/ld-powerpc/powerpc.exp: Don't run deleted tests.
1 parent 153679d commit 005d79f

28 files changed

Lines changed: 259 additions & 171 deletions

‎bfd/ChangeLog‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
2016-09-26 Alan Modra <amodra@gmail.com>
2+
3+
* elf-bfd.h (_bfd_elf_ppc_merge_fp_attributes): Declare.
4+
* elf32-ppc.c (_bfd_elf_ppc_merge_fp_attributes): New function.
5+
(ppc_elf_merge_obj_attributes): Use it. Don't copy first file
6+
attributes, merge them. Don't warn about undefined tag bits,
7+
or copy unknown values to output.
8+
* elf64-ppc.c (ppc64_elf_merge_private_bfd_data): Call
9+
_bfd_elf_ppc_merge_fp_attributes.
10+
111
2016-09-23 Akihiko Odaki <akihiko.odaki.4i@stu.hosei.ac.jp>
212

313
PR ld/20595

‎bfd/elf-bfd.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2393,6 +2393,8 @@ extern unsigned int _bfd_elf_ppc_at_tprel_transform
23932393
(unsigned int, unsigned int);
23942394
/* PowerPC elf_object_p tweak. */
23952395
extern bfd_boolean _bfd_elf_ppc_set_arch (bfd *);
2396+
/* PowerPC .gnu.attributes handling common to both 32-bit and 64-bit. */
2397+
extern void _bfd_elf_ppc_merge_fp_attributes (bfd *, bfd *);
23962398

23972399
/* Exported interface for writing elf corefile notes. */
23982400
extern char *elfcore_write_note

‎bfd/elf32-ppc.c‎

Lines changed: 96 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -4653,117 +4653,124 @@ ppc_elf_check_relocs (bfd *abfd,
46534653
return TRUE;
46544654
}
46554655

4656-
4657-
/* Merge object attributes from IBFD into OBFD. Raise an error if
4658-
there are conflicting attributes. */
4659-
static bfd_boolean
4660-
ppc_elf_merge_obj_attributes (bfd *ibfd, bfd *obfd)
4656+
/* Warn for conflicting Tag_GNU_Power_ABI_FP attributes between IBFD
4657+
and OBFD, and merge non-conflicting ones. */
4658+
void
4659+
_bfd_elf_ppc_merge_fp_attributes (bfd *ibfd, bfd *obfd)
46614660
{
46624661
obj_attribute *in_attr, *in_attrs;
46634662
obj_attribute *out_attr, *out_attrs;
46644663

4665-
if (!elf_known_obj_attributes_proc (obfd)[0].i)
4666-
{
4667-
/* This is the first object. Copy the attributes. */
4668-
_bfd_elf_copy_obj_attributes (ibfd, obfd);
4669-
4670-
/* Use the Tag_null value to indicate the attributes have been
4671-
initialized. */
4672-
elf_known_obj_attributes_proc (obfd)[0].i = 1;
4673-
4674-
return TRUE;
4675-
}
4676-
46774664
in_attrs = elf_known_obj_attributes (ibfd)[OBJ_ATTR_GNU];
46784665
out_attrs = elf_known_obj_attributes (obfd)[OBJ_ATTR_GNU];
46794666

4680-
/* Check for conflicting Tag_GNU_Power_ABI_FP attributes and merge
4681-
non-conflicting ones. */
46824667
in_attr = &in_attrs[Tag_GNU_Power_ABI_FP];
46834668
out_attr = &out_attrs[Tag_GNU_Power_ABI_FP];
4669+
46844670
if (in_attr->i != out_attr->i)
46854671
{
4686-
out_attr->type = 1;
4687-
if (out_attr->i == 0)
4688-
out_attr->i = in_attr->i;
4689-
else if (in_attr->i == 0)
4672+
int in_fp = in_attr->i & 3;
4673+
int out_fp = out_attr->i & 3;
4674+
4675+
if (in_fp == 0)
46904676
;
4691-
else if (out_attr->i == 1 && in_attr->i == 2)
4677+
else if (out_fp == 0)
4678+
{
4679+
out_attr->type = 1;
4680+
out_attr->i ^= in_fp;
4681+
}
4682+
else if (out_fp != 2 && in_fp == 2)
46924683
_bfd_error_handler
46934684
(_("Warning: %B uses hard float, %B uses soft float"), obfd, ibfd);
4694-
else if (out_attr->i == 1 && in_attr->i == 3)
4685+
else if (out_fp == 2 && in_fp != 2)
46954686
_bfd_error_handler
4696-
(_("Warning: %B uses double-precision hard float, %B uses single-precision hard float"),
4697-
obfd, ibfd);
4698-
else if (out_attr->i == 3 && in_attr->i == 1)
4687+
(_("Warning: %B uses hard float, %B uses soft float"), ibfd, obfd);
4688+
else if (out_fp == 1 && in_fp == 3)
46994689
_bfd_error_handler
4700-
(_("Warning: %B uses double-precision hard float, %B uses single-precision hard float"),
4701-
ibfd, obfd);
4702-
else if (out_attr->i == 3 && in_attr->i == 2)
4690+
(_("Warning: %B uses double-precision hard float, "
4691+
"%B uses single-precision hard float"), obfd, ibfd);
4692+
else if (out_fp == 3 && in_fp == 1)
47034693
_bfd_error_handler
4704-
(_("Warning: %B uses soft float, %B uses single-precision hard float"),
4705-
ibfd, obfd);
4706-
else if (out_attr->i == 2 && (in_attr->i == 1 || in_attr->i == 3))
4694+
(_("Warning: %B uses double-precision hard float, "
4695+
"%B uses single-precision hard float"), ibfd, obfd);
4696+
4697+
in_fp = in_attr->i & 0xc;
4698+
out_fp = out_attr->i & 0xc;
4699+
if (in_fp == 0)
4700+
;
4701+
else if (out_fp == 0)
4702+
{
4703+
out_attr->type = 1;
4704+
out_attr->i ^= in_fp;
4705+
}
4706+
else if (out_fp != 2 * 4 && in_fp == 2 * 4)
47074707
_bfd_error_handler
4708-
(_("Warning: %B uses hard float, %B uses soft float"), ibfd, obfd);
4709-
else if (in_attr->i > 3)
4708+
(_("Warning: %B uses 64-bit long double, "
4709+
"%B uses 128-bit long double"), ibfd, obfd);
4710+
else if (in_fp != 2 * 4 && out_fp == 2 * 4)
47104711
_bfd_error_handler
4711-
(_("Warning: %B uses unknown floating point ABI %d"), ibfd,
4712-
in_attr->i);
4713-
else
4712+
(_("Warning: %B uses 64-bit long double, "
4713+
"%B uses 128-bit long double"), obfd, ibfd);
4714+
else if (out_fp == 1 * 4 && in_fp == 3 * 4)
4715+
_bfd_error_handler
4716+
(_("Warning: %B uses IBM long double, "
4717+
"%B uses IEEE long double"), ibfd, obfd);
4718+
else if (out_fp == 3 * 4 && in_fp == 1 * 4)
47144719
_bfd_error_handler
4715-
(_("Warning: %B uses unknown floating point ABI %d"), obfd,
4716-
out_attr->i);
4720+
(_("Warning: %B uses IBM long double, "
4721+
"%B uses IEEE long double"), obfd, ibfd);
47174722
}
4723+
}
4724+
4725+
/* Merge object attributes from IBFD into OBFD. Warn if
4726+
there are conflicting attributes. */
4727+
static bfd_boolean
4728+
ppc_elf_merge_obj_attributes (bfd *ibfd, bfd *obfd)
4729+
{
4730+
obj_attribute *in_attr, *in_attrs;
4731+
obj_attribute *out_attr, *out_attrs;
4732+
4733+
_bfd_elf_ppc_merge_fp_attributes (ibfd, obfd);
4734+
4735+
in_attrs = elf_known_obj_attributes (ibfd)[OBJ_ATTR_GNU];
4736+
out_attrs = elf_known_obj_attributes (obfd)[OBJ_ATTR_GNU];
47184737

47194738
/* Check for conflicting Tag_GNU_Power_ABI_Vector attributes and
47204739
merge non-conflicting ones. */
47214740
in_attr = &in_attrs[Tag_GNU_Power_ABI_Vector];
47224741
out_attr = &out_attrs[Tag_GNU_Power_ABI_Vector];
47234742
if (in_attr->i != out_attr->i)
47244743
{
4725-
const char *in_abi = NULL, *out_abi = NULL;
4726-
4727-
switch (in_attr->i)
4728-
{
4729-
case 1: in_abi = "generic"; break;
4730-
case 2: in_abi = "AltiVec"; break;
4731-
case 3: in_abi = "SPE"; break;
4732-
}
4744+
int in_vec = in_attr->i & 3;
4745+
int out_vec = out_attr->i & 3;
47334746

4734-
switch (out_attr->i)
4747+
if (in_vec == 0)
4748+
;
4749+
else if (out_vec == 0)
47354750
{
4736-
case 1: out_abi = "generic"; break;
4737-
case 2: out_abi = "AltiVec"; break;
4738-
case 3: out_abi = "SPE"; break;
4751+
out_attr->type = 1;
4752+
out_attr->i = in_vec;
47394753
}
4740-
4741-
out_attr->type = 1;
4742-
if (out_attr->i == 0)
4743-
out_attr->i = in_attr->i;
4744-
else if (in_attr->i == 0)
4745-
;
47464754
/* For now, allow generic to transition to AltiVec or SPE
47474755
without a warning. If GCC marked files with their stack
47484756
alignment and used don't-care markings for files which are
47494757
not affected by the vector ABI, we could warn about this
47504758
case too. */
4751-
else if (out_attr->i == 1)
4752-
out_attr->i = in_attr->i;
4753-
else if (in_attr->i == 1)
4759+
else if (in_vec == 1)
47544760
;
4755-
else if (in_abi == NULL)
4756-
_bfd_error_handler
4757-
(_("Warning: %B uses unknown vector ABI %d"), ibfd,
4758-
in_attr->i);
4759-
else if (out_abi == NULL)
4761+
else if (out_vec == 1)
4762+
{
4763+
out_attr->type = 1;
4764+
out_attr->i = in_vec;
4765+
}
4766+
else if (out_vec < in_vec)
47604767
_bfd_error_handler
4761-
(_("Warning: %B uses unknown vector ABI %d"), obfd,
4762-
in_attr->i);
4763-
else
4768+
(_("Warning: %B uses AltiVec vector ABI, %B uses SPE vector ABI"),
4769+
obfd, ibfd);
4770+
else if (out_vec > in_vec)
47644771
_bfd_error_handler
4765-
(_("Warning: %B uses vector ABI \"%s\", %B uses \"%s\""),
4766-
ibfd, obfd, in_abi, out_abi);
4772+
(_("Warning: %B uses AltiVec vector ABI, %B uses SPE vector ABI"),
4773+
ibfd, obfd);
47674774
}
47684775

47694776
/* Check for conflicting Tag_GNU_Power_ABI_Struct_Return attributes
@@ -4772,25 +4779,24 @@ ppc_elf_merge_obj_attributes (bfd *ibfd, bfd *obfd)
47724779
out_attr = &out_attrs[Tag_GNU_Power_ABI_Struct_Return];
47734780
if (in_attr->i != out_attr->i)
47744781
{
4775-
out_attr->type = 1;
4776-
if (out_attr->i == 0)
4777-
out_attr->i = in_attr->i;
4778-
else if (in_attr->i == 0)
4782+
int in_struct = in_attr->i & 3;
4783+
int out_struct = out_attr->i & 3;
4784+
4785+
if (in_struct == 0 || in_struct == 3)
47794786
;
4780-
else if (out_attr->i == 1 && in_attr->i == 2)
4781-
_bfd_error_handler
4782-
(_("Warning: %B uses r3/r4 for small structure returns, %B uses memory"), obfd, ibfd);
4783-
else if (out_attr->i == 2 && in_attr->i == 1)
4784-
_bfd_error_handler
4785-
(_("Warning: %B uses r3/r4 for small structure returns, %B uses memory"), ibfd, obfd);
4786-
else if (in_attr->i > 2)
4787-
_bfd_error_handler
4788-
(_("Warning: %B uses unknown small structure return convention %d"), ibfd,
4789-
in_attr->i);
4790-
else
4791-
_bfd_error_handler
4792-
(_("Warning: %B uses unknown small structure return convention %d"), obfd,
4793-
out_attr->i);
4787+
else if (out_struct == 0)
4788+
{
4789+
out_attr->type = 1;
4790+
out_attr->i = in_struct;
4791+
}
4792+
else if (out_struct < in_struct)
4793+
_bfd_error_handler
4794+
(_("Warning: %B uses r3/r4 for small structure returns, "
4795+
"%B uses memory"), obfd, ibfd);
4796+
else if (out_struct > in_struct)
4797+
_bfd_error_handler
4798+
(_("Warning: %B uses r3/r4 for small structure returns, "
4799+
"%B uses memory"), ibfd, obfd);
47944800
}
47954801

47964802
/* Merge Tag_compatibility attributes and any common GNU ones. */

‎bfd/elf64-ppc.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6030,6 +6030,8 @@ ppc64_elf_merge_private_bfd_data (bfd *ibfd, bfd *obfd)
60306030
return FALSE;
60316031
}
60326032

6033+
_bfd_elf_ppc_merge_fp_attributes (ibfd, obfd);
6034+
60336035
/* Merge Tag_compatibility attributes and any common GNU ones. */
60346036
_bfd_elf_merge_object_attributes (ibfd, obfd);
60356037

‎binutils/ChangeLog‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
2016-09-26 Alan Modra <amodra@gmail.com>
2+
3+
* readelf.c (display_power_gnu_attribute): Catch truncated section
4+
for all powerpc attributes. Display long double ABI. Don't
5+
capitalize words, except for names. Show known bits of tag values
6+
when some unknown bits are present. Whitespace fixes.
7+
18
2016-09-26 Alan Modra <amodra@gmail.com>
29

310
* nm.c (get_elf_symbol_type): Don't use sprintf with translated

0 commit comments

Comments
 (0)