As non-private functions, they should come with full disambiguating
prefixes - add bfd_elf_ to both. Hence commit
2903d813fcc2 ("bfd/ELF: mark
internal LoongArch functions hidden") also wrongly added ATTRIBUTE_HIDDEN
to them.
While loongarch_get_uleb128_length() also falls in the same category,
having it live in libbfd, when outside of gas there's hardly any use to be
expected, isn't very useful. Drop the function altogether and simplify the
clearing of the ULEB128 in md_apply_fix().
For loongarch_larch_reloc_name_lookup() drop gas'es custom declaration;
the libbfd one ought to be used, for producer and consumer to "see" the
same one. Also drop ATTRIBUTE_UNUSED there, as that makes sense only for
parameters in function definitions.
{
/* Adjust the immediate based on alignment and
its position in the instruction. */
- if (!loongarch_adjust_reloc_bitsfield (input_bfd, howto, &reloc_val))
+ if (!bfd_elf_loongarch_adjust_reloc_bitsfield (input_bfd, howto, &reloc_val))
return bfd_reloc_overflow;
int bits = bfd_get_reloc_size (howto) * 8;
}
bfd_reloc_code_real_type
-loongarch_larch_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
- const char *l_r_name)
+bfd_elf_loongarch_larch_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
+ const char *l_r_name)
{
for (size_t i = 0; i < ARRAY_SIZE (loongarch_howto_table); i++)
{
}
bool
-loongarch_adjust_reloc_bitsfield (bfd *abfd, reloc_howto_type *howto,
- bfd_vma *fix_val)
+bfd_elf_loongarch_adjust_reloc_bitsfield (bfd *abfd, reloc_howto_type *howto,
+ bfd_vma *fix_val)
{
BFD_ASSERT (((loongarch_reloc_howto_type *)howto)->adjust_reloc_bits);
return ((loongarch_reloc_howto_type *)
while (len);
return p;
}
-
-int loongarch_get_uleb128_length (bfd_byte *buf)
-{
- unsigned int len = 0;
- _bfd_read_unsigned_leb128 (NULL, buf, &len);
- return len;
-}
ATTRIBUTE_HIDDEN;
extern bfd_reloc_code_real_type
-loongarch_larch_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
- const char *l_r_name) ATTRIBUTE_HIDDEN;
+bfd_elf_loongarch_larch_reloc_name_lookup (bfd *abfd, const char *l_r_name);
bool
-loongarch_adjust_reloc_bitsfield (bfd *, reloc_howto_type *, bfd_vma *)
- ATTRIBUTE_HIDDEN;
+bfd_elf_loongarch_adjust_reloc_bitsfield (bfd *, reloc_howto_type *, bfd_vma *);
void
bfd_elf32_loongarch_set_data_segment_info (struct bfd_link_info *, int *);
void
loongarch_write_unsigned_leb128 (bfd_byte *p, unsigned int len, bfd_vma value)
ATTRIBUTE_HIDDEN;
-int loongarch_get_uleb128_length (bfd_byte *buf) ATTRIBUTE_HIDDEN;
-
/* TRUE if this is a PLT reference to a local IFUNC. */
#define PLT_LOCAL_IFUNC_P(INFO, H) \
((H)->dynindx == -1 \
size_t max_reloc_num,
size_t *reloc_num,
offsetT *imm);
-bfd_reloc_code_real_type
-loongarch_larch_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
- const char *l_r_name);
#include "as.h"
#include "loongarch-lex.h"
#include "loongarch-parse.h"
+#include "bfd/elfxx-loongarch.h"
static void yyerror (const char *s ATTRIBUTE_UNUSED)
{
};
btype = BFD_RELOC_LARCH_B26;
else
{
- btype = loongarch_larch_reloc_name_lookup (NULL, op_c_str);
+ btype = bfd_elf_loongarch_larch_reloc_name_lookup (NULL, op_c_str);
if (btype == BFD_RELOC_NONE)
as_fatal (_("unsupported modifier %s"), op_c_str);
}
insn = bfd_getl32 (buf);
- if (!loongarch_adjust_reloc_bitsfield (NULL, howto, &reloc_val))
+ if (!bfd_elf_loongarch_adjust_reloc_bitsfield (NULL, howto, &reloc_val))
as_bad_where (fixP->fx_file, fixP->fx_line, "Reloc overflow");
insn = (insn & (insn_t)howto->src_mask)
case BFD_RELOC_LARCH_ADD_ULEB128: */
case BFD_RELOC_LARCH_SUB_ULEB128:
{
- unsigned int len = 0;
- len = loongarch_get_uleb128_length ((bfd_byte *)buf);
- bfd_byte *endp = (bfd_byte*) buf + len -1;
/* Clean the uleb128 value to 0. Do not reduce the length. */
- memset (buf, 0x80, len - 1);
- *endp = 0;
+ for (bfd_byte *ptr = (bfd_byte *)buf; *ptr &= 0x80; ++ptr)
+ /* Nothing. */;
break;
}