}
}
+static inline size_t
+buffer_pos (Elf_Data *data, const unsigned char *p)
+{
+ return p - (const unsigned char *) data->d_buf;
+}
+
static void
check_attributes (Ebl *ebl, GElf_Ehdr *ehdr, GElf_Shdr *shdr, int idx)
{
return;
}
- inline size_t pos (const unsigned char *p)
- {
- return p - (const unsigned char *) data->d_buf;
- }
-
const unsigned char *p = data->d_buf;
if (*p++ != 'A')
{
if (len == 0)
ERROR (_("\
section [%2d] '%s': offset %zu: zero length field in attribute section\n"),
- idx, section_name (ebl, idx), pos (p));
+ idx, section_name (ebl, idx), buffer_pos (data, p));
if (MY_ELFDATA != ehdr->e_ident[EI_DATA])
CONVERT (len);
{
ERROR (_("\
section [%2d] '%s': offset %zu: invalid length in attribute section\n"),
- idx, section_name (ebl, idx), pos (p));
+ idx, section_name (ebl, idx), buffer_pos (data, p));
break;
}
{
ERROR (_("\
section [%2d] '%s': offset %zu: unterminated vendor name string\n"),
- idx, section_name (ebl, idx), pos (p));
+ idx, section_name (ebl, idx), buffer_pos (data, p));
break;
}
++q;
{
ERROR (_("\
section [%2d] '%s': offset %zu: endless ULEB128 in attribute subsection tag\n"),
- idx, section_name (ebl, idx), pos (chunk));
+ idx, section_name (ebl, idx), buffer_pos (data, chunk));
break;
}
{
ERROR (_("\
section [%2d] '%s': offset %zu: truncated attribute section\n"),
- idx, section_name (ebl, idx), pos (q));
+ idx, section_name (ebl, idx), buffer_pos (data, q));
break;
}
{
ERROR (_("\
section [%2d] '%s': offset %zu: zero length field in attribute subsection\n"),
- idx, section_name (ebl, idx), pos (q));
+ idx, section_name (ebl, idx), buffer_pos (data, q));
q += sizeof subsection_len;
continue;
{
ERROR (_("\
section [%2d] '%s': offset %zu: invalid length in attribute subsection\n"),
- idx, section_name (ebl, idx), pos (q));
+ idx, section_name (ebl, idx), buffer_pos (data, q));
break;
}
if (subsection_tag != 1) /* Tag_File */
ERROR (_("\
section [%2d] '%s': offset %zu: attribute subsection has unexpected tag %u\n"),
- idx, section_name (ebl, idx), pos (chunk), subsection_tag);
+ idx, section_name (ebl, idx), buffer_pos (data, chunk), subsection_tag);
else
{
chunk += sizeof subsection_len;
{
ERROR (_("\
section [%2d] '%s': offset %zu: endless ULEB128 in attribute tag\n"),
- idx, section_name (ebl, idx), pos (chunk));
+ idx, section_name (ebl, idx), buffer_pos (data, chunk));
break;
}
}
{
ERROR (_("\
section [%2d] '%s': offset %zu: unterminated string in attribute\n"),
- idx, section_name (ebl, idx), pos (chunk));
+ idx, section_name (ebl, idx), buffer_pos (data, chunk));
break;
}
++r;
&tag_name, &value_name))
ERROR (_("\
section [%2d] '%s': offset %zu: unrecognized attribute tag %u\n"),
- idx, section_name (ebl, idx), pos (chunk), tag);
+ idx, section_name (ebl, idx), buffer_pos (data, chunk), tag);
else if ((tag & 1) == 0 && value_name == NULL)
ERROR (_("\
section [%2d] '%s': offset %zu: unrecognized %s attribute value %" PRIu64 "\n"),
- idx, section_name (ebl, idx), pos (chunk),
+ idx, section_name (ebl, idx), buffer_pos (data, chunk),
tag_name, value);
chunk = r;
else
ERROR (_("\
section [%2d] '%s': offset %zu: vendor '%s' unknown\n"),
- idx, section_name (ebl, idx), pos (p), name);
+ idx, section_name (ebl, idx), buffer_pos (data, p), name);
}
if (left () != 0)
ERROR (_("\
section [%2d] '%s': offset %zu: extra bytes after last attribute section\n"),
- idx, section_name (ebl, idx), pos (p));
+ idx, section_name (ebl, idx), buffer_pos (data, p));
}
static bool has_loadable_segment;