aboutsummaryrefslogtreecommitdiff
path: root/bfd/elf-attrs.c
diff options
context:
space:
mode:
Diffstat (limited to 'bfd/elf-attrs.c')
-rw-r--r--bfd/elf-attrs.c94
1 files changed, 55 insertions, 39 deletions
diff --git a/bfd/elf-attrs.c b/bfd/elf-attrs.c
index e80575b..7b675ab 100644
--- a/bfd/elf-attrs.c
+++ b/bfd/elf-attrs.c
@@ -236,7 +236,7 @@ bfd_elf_set_obj_attr_contents (bfd *abfd, bfd_byte *buffer, bfd_vma size)
/* Allocate/find an object attribute. */
static obj_attribute *
-elf_new_obj_attr (bfd *abfd, int vendor, unsigned int tag)
+elf_new_obj_attr (bfd *abfd, obj_attr_vendor_t vendor, obj_attr_tag_t tag)
{
obj_attribute *attr;
obj_attribute_list *list;
@@ -276,7 +276,9 @@ elf_new_obj_attr (bfd *abfd, int vendor, unsigned int tag)
/* Return the value of an integer object attribute. */
int
-bfd_elf_get_obj_attr_int (bfd *abfd, int vendor, unsigned int tag)
+bfd_elf_get_obj_attr_int (bfd *abfd,
+ obj_attr_vendor_t vendor,
+ obj_attr_tag_t tag)
{
obj_attribute_list *p;
@@ -302,15 +304,18 @@ bfd_elf_get_obj_attr_int (bfd *abfd, int vendor, unsigned int tag)
/* Add an integer object attribute. */
obj_attribute *
-bfd_elf_add_obj_attr_int (bfd *abfd, int vendor, unsigned int tag, unsigned int i)
+bfd_elf_add_obj_attr_int (bfd *abfd,
+ obj_attr_vendor_t vendor,
+ obj_attr_tag_t tag,
+ unsigned int value)
{
obj_attribute *attr;
attr = elf_new_obj_attr (abfd, vendor, tag);
if (attr != NULL)
{
- attr->type = _bfd_elf_obj_attrs_arg_type (abfd, vendor, tag);
- attr->i = i;
+ attr->type = bfd_elf_obj_attrs_arg_type (abfd, vendor, tag);
+ attr->i = value;
}
return attr;
}
@@ -344,7 +349,7 @@ _bfd_elf_attr_strdup (bfd *abfd, const char *s)
/* Add a string object attribute. */
static obj_attribute *
-elf_add_obj_attr_string (bfd *abfd, int vendor, unsigned int tag,
+elf_add_obj_attr_string (bfd *abfd, obj_attr_vendor_t vendor, obj_attr_tag_t tag,
const char *s, const char *end)
{
obj_attribute *attr;
@@ -352,7 +357,7 @@ elf_add_obj_attr_string (bfd *abfd, int vendor, unsigned int tag,
attr = elf_new_obj_attr (abfd, vendor, tag);
if (attr != NULL)
{
- attr->type = _bfd_elf_obj_attrs_arg_type (abfd, vendor, tag);
+ attr->type = bfd_elf_obj_attrs_arg_type (abfd, vendor, tag);
attr->s = elf_attr_strdup (abfd, s, end);
if (attr->s == NULL)
return NULL;
@@ -361,7 +366,9 @@ elf_add_obj_attr_string (bfd *abfd, int vendor, unsigned int tag,
}
obj_attribute *
-bfd_elf_add_obj_attr_string (bfd *abfd, int vendor, unsigned int tag,
+bfd_elf_add_obj_attr_string (bfd *abfd,
+ obj_attr_vendor_t vendor,
+ obj_attr_tag_t tag,
const char *s)
{
return elf_add_obj_attr_string (abfd, vendor, tag, s, NULL);
@@ -369,15 +376,19 @@ bfd_elf_add_obj_attr_string (bfd *abfd, int vendor, unsigned int tag,
/* Add a int+string object attribute. */
static obj_attribute *
-elf_add_obj_attr_int_string (bfd *abfd, int vendor, unsigned int tag,
- unsigned int i, const char *s, const char *end)
+elf_add_obj_attr_int_string (bfd *abfd,
+ obj_attr_vendor_t vendor,
+ obj_attr_tag_t tag,
+ unsigned int i,
+ const char *s,
+ const char *end)
{
obj_attribute *attr;
attr = elf_new_obj_attr (abfd, vendor, tag);
if (attr != NULL)
{
- attr->type = _bfd_elf_obj_attrs_arg_type (abfd, vendor, tag);
+ attr->type = bfd_elf_obj_attrs_arg_type (abfd, vendor, tag);
attr->i = i;
attr->s = elf_attr_strdup (abfd, s, end);
if (attr->s == NULL)
@@ -387,8 +398,11 @@ elf_add_obj_attr_int_string (bfd *abfd, int vendor, unsigned int tag,
}
obj_attribute *
-bfd_elf_add_obj_attr_int_string (bfd *abfd, int vendor, unsigned int tag,
- unsigned int i, const char *s)
+bfd_elf_add_obj_attr_int_string (bfd *abfd,
+ obj_attr_vendor_t vendor,
+ obj_attr_tag_t tag,
+ unsigned int i,
+ const char *s)
{
return elf_add_obj_attr_int_string (abfd, vendor, tag, i, s, NULL);
}
@@ -401,7 +415,7 @@ _bfd_elf_copy_obj_attributes (bfd *ibfd, bfd *obfd)
obj_attribute *out_attr;
obj_attribute_list *list;
int i;
- int vendor;
+ obj_attr_vendor_t vendor;
if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour
|| bfd_get_flavour (obfd) != bfd_target_elf_flavour)
@@ -459,7 +473,7 @@ _bfd_elf_copy_obj_attributes (bfd *ibfd, bfd *obfd)
/* Determine whether a GNU object attribute tag takes an integer, a
string or both. */
static int
-gnu_obj_attrs_arg_type (unsigned int tag)
+gnu_obj_attrs_arg_type (obj_attr_tag_t tag)
{
/* Except for Tag_compatibility, for GNU attributes we follow the
same rule ARM ones > 32 follow: odd-numbered tags take strings
@@ -474,7 +488,9 @@ gnu_obj_attrs_arg_type (unsigned int tag)
/* Determine what arguments an attribute tag takes. */
int
-_bfd_elf_obj_attrs_arg_type (bfd *abfd, int vendor, unsigned int tag)
+bfd_elf_obj_attrs_arg_type (bfd *abfd,
+ obj_attr_vendor_t vendor,
+ obj_attr_tag_t tag)
{
switch (vendor)
{
@@ -510,8 +526,8 @@ bfd_elf_parse_attr_section_v1 (bfd *abfd, bfd_byte *p, bfd_byte *p_end)
if (section_len <= 4)
{
_bfd_error_handler
- (_("%pB: error: attribute section length too small: %ld"),
- abfd, (long) section_len);
+ (_("%pB: error: attribute section length too small: %ld"),
+ abfd, (long) section_len);
break;
}
section_len -= 4;
@@ -541,15 +557,15 @@ bfd_elf_parse_attr_section_v1 (bfd *abfd, bfd_byte *p, bfd_byte *p_end)
orig_p = p;
tag = _bfd_safe_read_leb128 (abfd, &p, false, p_end);
if (p_end - p >= 4)
- {
- subsection_len = bfd_get_32 (abfd, p);
- p += 4;
- }
+ {
+ subsection_len = bfd_get_32 (abfd, p);
+ p += 4;
+ }
else
- {
- p = p_end;
- break;
- }
+ {
+ p = p_end;
+ break;
+ }
if (subsection_len > section_len)
subsection_len = section_len;
section_len -= subsection_len;
@@ -565,7 +581,7 @@ bfd_elf_parse_attr_section_v1 (bfd *abfd, bfd_byte *p, bfd_byte *p_end)
bool ok = false;
tag = _bfd_safe_read_leb128 (abfd, &p, false, end);
- type = _bfd_elf_obj_attrs_arg_type (abfd, vendor, tag);
+ type = bfd_elf_obj_attrs_arg_type (abfd, vendor, tag);
switch (type & (ATTR_TYPE_FLAG_INT_VAL | ATTR_TYPE_FLAG_STR_VAL))
{
case ATTR_TYPE_FLAG_INT_VAL | ATTR_TYPE_FLAG_STR_VAL:
@@ -638,12 +654,12 @@ _bfd_elf_parse_attributes (bfd *abfd, Elf_Internal_Shdr * hdr)
/* The first character is the version of the attributes.
Currently only version 'A' is recognised here. */
if (*cursor != 'A')
- {
- _bfd_error_handler (_("%pB: error: unknown attributes version '%c'(%d) "
- "- expecting 'A'\n"), abfd, *cursor, *cursor);
- bfd_set_error (bfd_error_wrong_format);
- goto free_data;
- }
+ {
+ _bfd_error_handler (_("%pB: error: unknown attributes version '%c'(%d) "
+ "- expecting 'A'\n"), abfd, *cursor, *cursor);
+ bfd_set_error (bfd_error_wrong_format);
+ goto free_data;
+ }
++cursor;
@@ -685,9 +701,9 @@ _bfd_elf_merge_object_attributes (bfd *ibfd, struct bfd_link_info *info)
{
_bfd_error_handler
/* xgettext:c-format */
- (_("error: %pB: object has vendor-specific contents that "
- "must be processed by the '%s' toolchain"),
- ibfd, in_attr->s);
+ (_("error: %pB: object has vendor-specific contents that "
+ "must be processed by the '%s' toolchain"),
+ ibfd, in_attr->s);
return false;
}
@@ -818,10 +834,10 @@ _bfd_elf_merge_unknown_attribute_list (bfd *ibfd, bfd *obfd)
return result;
}
-bool _bfd_elf_write_section_build_attributes (bfd *abfd,
- struct bfd_link_info *info ATTRIBUTE_UNUSED)
+bool _bfd_elf_write_section_object_attributes
+ (bfd *abfd, struct bfd_link_info *info ATTRIBUTE_UNUSED)
{
- asection *sec = elf_obj_build_attributes (abfd);
+ asection *sec = elf_obj_object_attributes (abfd);
if (sec == NULL)
return true;