mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-24 04:00:07 +08:00
* elflink.c: Formatting.
This commit is contained in:
@ -1,3 +1,7 @@
|
|||||||
|
2007-09-30 Alan Modra <amodra@bigpond.net.au>
|
||||||
|
|
||||||
|
* elflink.c: Formatting.
|
||||||
|
|
||||||
2007-09-29 Alan Modra <amodra@bigpond.net.au>
|
2007-09-29 Alan Modra <amodra@bigpond.net.au>
|
||||||
|
|
||||||
* elflink.c (resolve_symbol): Handle symbols in SEC_MERGE
|
* elflink.c (resolve_symbol): Handle symbols in SEC_MERGE
|
||||||
|
110
bfd/elflink.c
110
bfd/elflink.c
@ -7229,8 +7229,8 @@ struct elf_outext_info
|
|||||||
<unary-operator> := as in C, plus "0-" for unambiguous negation. */
|
<unary-operator> := as in C, plus "0-" for unambiguous negation. */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
set_symbol_value (bfd * bfd_with_globals,
|
set_symbol_value (bfd *bfd_with_globals,
|
||||||
Elf_Internal_Sym * isymbuf,
|
Elf_Internal_Sym *isymbuf,
|
||||||
size_t locsymcount,
|
size_t locsymcount,
|
||||||
size_t symidx,
|
size_t symidx,
|
||||||
bfd_vma val)
|
bfd_vma val)
|
||||||
@ -7270,17 +7270,17 @@ set_symbol_value (bfd * bfd_with_globals,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static bfd_boolean
|
static bfd_boolean
|
||||||
resolve_symbol (const char * name,
|
resolve_symbol (const char *name,
|
||||||
bfd * input_bfd,
|
bfd *input_bfd,
|
||||||
struct elf_final_link_info * finfo,
|
struct elf_final_link_info *finfo,
|
||||||
bfd_vma * result,
|
bfd_vma *result,
|
||||||
Elf_Internal_Sym * isymbuf,
|
Elf_Internal_Sym *isymbuf,
|
||||||
size_t locsymcount)
|
size_t locsymcount)
|
||||||
{
|
{
|
||||||
Elf_Internal_Sym * sym;
|
Elf_Internal_Sym *sym;
|
||||||
struct bfd_link_hash_entry * global_entry;
|
struct bfd_link_hash_entry *global_entry;
|
||||||
const char * candidate = NULL;
|
const char *candidate = NULL;
|
||||||
Elf_Internal_Shdr * symtab_hdr;
|
Elf_Internal_Shdr *symtab_hdr;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
symtab_hdr = & elf_tdata (input_bfd)->symtab_hdr;
|
symtab_hdr = & elf_tdata (input_bfd)->symtab_hdr;
|
||||||
@ -7314,16 +7314,17 @@ resolve_symbol (const char * name,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Hmm, haven't found it yet. perhaps it is a global. */
|
/* Hmm, haven't found it yet. perhaps it is a global. */
|
||||||
global_entry = bfd_link_hash_lookup (finfo->info->hash, name, FALSE, FALSE, TRUE);
|
global_entry = bfd_link_hash_lookup (finfo->info->hash, name,
|
||||||
|
FALSE, FALSE, TRUE);
|
||||||
if (!global_entry)
|
if (!global_entry)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (global_entry->type == bfd_link_hash_defined
|
if (global_entry->type == bfd_link_hash_defined
|
||||||
|| global_entry->type == bfd_link_hash_defweak)
|
|| global_entry->type == bfd_link_hash_defweak)
|
||||||
{
|
{
|
||||||
* result = global_entry->u.def.value
|
*result = (global_entry->u.def.value
|
||||||
+ global_entry->u.def.section->output_section->vma
|
+ global_entry->u.def.section->output_section->vma
|
||||||
+ global_entry->u.def.section->output_offset;
|
+ global_entry->u.def.section->output_offset);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printf ("Found GLOBAL symbol '%s' with value %8.8lx\n",
|
printf ("Found GLOBAL symbol '%s' with value %8.8lx\n",
|
||||||
global_entry->root.string, (unsigned long) *result);
|
global_entry->root.string, (unsigned long) *result);
|
||||||
@ -7335,11 +7336,11 @@ resolve_symbol (const char * name,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static bfd_boolean
|
static bfd_boolean
|
||||||
resolve_section (const char * name,
|
resolve_section (const char *name,
|
||||||
asection * sections,
|
asection *sections,
|
||||||
bfd_vma * result)
|
bfd_vma *result)
|
||||||
{
|
{
|
||||||
asection * curr;
|
asection *curr;
|
||||||
unsigned int len;
|
unsigned int len;
|
||||||
|
|
||||||
for (curr = sections; curr; curr = curr->next)
|
for (curr = sections; curr; curr = curr->next)
|
||||||
@ -7372,19 +7373,19 @@ resolve_section (const char * name,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
undefined_reference (const char * reftype,
|
undefined_reference (const char *reftype, const char *name)
|
||||||
const char * name)
|
|
||||||
{
|
{
|
||||||
_bfd_error_handler (_("undefined %s reference in complex symbol: %s"), reftype, name);
|
_bfd_error_handler (_("undefined %s reference in complex symbol: %s"),
|
||||||
|
reftype, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bfd_boolean
|
static bfd_boolean
|
||||||
eval_symbol (bfd_vma * result,
|
eval_symbol (bfd_vma *result,
|
||||||
const char ** symp,
|
const char **symp,
|
||||||
bfd * input_bfd,
|
bfd *input_bfd,
|
||||||
struct elf_final_link_info * finfo,
|
struct elf_final_link_info *finfo,
|
||||||
bfd_vma dot,
|
bfd_vma dot,
|
||||||
Elf_Internal_Sym * isymbuf,
|
Elf_Internal_Sym *isymbuf,
|
||||||
size_t locsymcount,
|
size_t locsymcount,
|
||||||
int signed_p)
|
int signed_p)
|
||||||
{
|
{
|
||||||
@ -7393,9 +7394,9 @@ eval_symbol (bfd_vma * result,
|
|||||||
bfd_vma a;
|
bfd_vma a;
|
||||||
bfd_vma b;
|
bfd_vma b;
|
||||||
const int bufsz = 4096;
|
const int bufsz = 4096;
|
||||||
char symbuf [bufsz];
|
char symbuf[bufsz];
|
||||||
const char *sym = *symp;
|
const char *sym = *symp;
|
||||||
const char * symend;
|
const char *symend;
|
||||||
bfd_boolean symbol_is_section = FALSE;
|
bfd_boolean symbol_is_section = FALSE;
|
||||||
|
|
||||||
len = strlen (sym);
|
len = strlen (sym);
|
||||||
@ -7426,14 +7427,14 @@ eval_symbol (bfd_vma * result,
|
|||||||
symlen = strtol (sym, (char **) symp, 10);
|
symlen = strtol (sym, (char **) symp, 10);
|
||||||
sym = *symp + 1; /* Skip the trailing ':'. */
|
sym = *symp + 1; /* Skip the trailing ':'. */
|
||||||
|
|
||||||
if ((symend < sym) || ((symlen + 1) > bufsz))
|
if (symend < sym || symlen + 1 > bufsz)
|
||||||
{
|
{
|
||||||
bfd_set_error (bfd_error_invalid_operation);
|
bfd_set_error (bfd_error_invalid_operation);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy (symbuf, sym, symlen);
|
memcpy (symbuf, sym, symlen);
|
||||||
symbuf [symlen] = '\0';
|
symbuf[symlen] = '\0';
|
||||||
*symp = sym + symlen;
|
*symp = sym + symlen;
|
||||||
|
|
||||||
/* Is it always possible, with complex symbols, that gas "mis-guessed"
|
/* Is it always possible, with complex symbols, that gas "mis-guessed"
|
||||||
@ -7471,8 +7472,8 @@ eval_symbol (bfd_vma * result,
|
|||||||
if (strncmp (sym, #op, strlen (#op)) == 0) \
|
if (strncmp (sym, #op, strlen (#op)) == 0) \
|
||||||
{ \
|
{ \
|
||||||
sym += strlen (#op); \
|
sym += strlen (#op); \
|
||||||
if (* sym == ':') \
|
if (*sym == ':') \
|
||||||
++ sym; \
|
++sym; \
|
||||||
*symp = sym; \
|
*symp = sym; \
|
||||||
if (!eval_symbol (&a, symp, input_bfd, finfo, dot, \
|
if (!eval_symbol (&a, symp, input_bfd, finfo, dot, \
|
||||||
isymbuf, locsymcount, signed_p)) \
|
isymbuf, locsymcount, signed_p)) \
|
||||||
@ -7480,7 +7481,7 @@ eval_symbol (bfd_vma * result,
|
|||||||
if (signed_p) \
|
if (signed_p) \
|
||||||
*result = op ((bfd_signed_vma) a); \
|
*result = op ((bfd_signed_vma) a); \
|
||||||
else \
|
else \
|
||||||
* result = op a; \
|
*result = op a; \
|
||||||
return TRUE; \
|
return TRUE; \
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -7488,8 +7489,8 @@ eval_symbol (bfd_vma * result,
|
|||||||
if (strncmp (sym, #op, strlen (#op)) == 0) \
|
if (strncmp (sym, #op, strlen (#op)) == 0) \
|
||||||
{ \
|
{ \
|
||||||
sym += strlen (#op); \
|
sym += strlen (#op); \
|
||||||
if (* sym == ':') \
|
if (*sym == ':') \
|
||||||
++ sym; \
|
++sym; \
|
||||||
*symp = sym; \
|
*symp = sym; \
|
||||||
if (!eval_symbol (&a, symp, input_bfd, finfo, dot, \
|
if (!eval_symbol (&a, symp, input_bfd, finfo, dot, \
|
||||||
isymbuf, locsymcount, signed_p)) \
|
isymbuf, locsymcount, signed_p)) \
|
||||||
@ -7501,7 +7502,7 @@ eval_symbol (bfd_vma * result,
|
|||||||
if (signed_p) \
|
if (signed_p) \
|
||||||
*result = ((bfd_signed_vma) a) op ((bfd_signed_vma) b); \
|
*result = ((bfd_signed_vma) a) op ((bfd_signed_vma) b); \
|
||||||
else \
|
else \
|
||||||
* result = a op b; \
|
*result = a op b; \
|
||||||
return TRUE; \
|
return TRUE; \
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -7538,9 +7539,9 @@ eval_symbol (bfd_vma * result,
|
|||||||
static void
|
static void
|
||||||
put_value (bfd_vma size,
|
put_value (bfd_vma size,
|
||||||
unsigned long chunksz,
|
unsigned long chunksz,
|
||||||
bfd * input_bfd,
|
bfd *input_bfd,
|
||||||
bfd_vma x,
|
bfd_vma x,
|
||||||
bfd_byte * location)
|
bfd_byte *location)
|
||||||
{
|
{
|
||||||
location += (size - chunksz);
|
location += (size - chunksz);
|
||||||
|
|
||||||
@ -7574,8 +7575,8 @@ put_value (bfd_vma size,
|
|||||||
static bfd_vma
|
static bfd_vma
|
||||||
get_value (bfd_vma size,
|
get_value (bfd_vma size,
|
||||||
unsigned long chunksz,
|
unsigned long chunksz,
|
||||||
bfd * input_bfd,
|
bfd *input_bfd,
|
||||||
bfd_byte * location)
|
bfd_byte *location)
|
||||||
{
|
{
|
||||||
bfd_vma x = 0;
|
bfd_vma x = 0;
|
||||||
|
|
||||||
@ -7608,15 +7609,14 @@ get_value (bfd_vma size,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
decode_complex_addend
|
decode_complex_addend (unsigned long *start, /* in bits */
|
||||||
(unsigned long * start, /* in bits */
|
unsigned long *oplen, /* in bits */
|
||||||
unsigned long * oplen, /* in bits */
|
unsigned long *len, /* in bits */
|
||||||
unsigned long * len, /* in bits */
|
unsigned long *wordsz, /* in bytes */
|
||||||
unsigned long * wordsz, /* in bytes */
|
unsigned long *chunksz, /* in bytes */
|
||||||
unsigned long * chunksz, /* in bytes */
|
unsigned long *lsb0_p,
|
||||||
unsigned long * lsb0_p,
|
unsigned long *signed_p,
|
||||||
unsigned long * signed_p,
|
unsigned long *trunc_p,
|
||||||
unsigned long * trunc_p,
|
|
||||||
unsigned long encoded)
|
unsigned long encoded)
|
||||||
{
|
{
|
||||||
* start = encoded & 0x3F;
|
* start = encoded & 0x3F;
|
||||||
@ -7645,9 +7645,9 @@ bfd_elf_perform_complex_relocation (bfd *input_bfd,
|
|||||||
i.e. the addend has the complete reloc information (bit start, end,
|
i.e. the addend has the complete reloc information (bit start, end,
|
||||||
word size, etc) encoded within it.). */
|
word size, etc) encoded within it.). */
|
||||||
|
|
||||||
decode_complex_addend (& start, & oplen, & len, & wordsz,
|
decode_complex_addend (&start, &oplen, &len, &wordsz,
|
||||||
& chunksz, & lsb0_p, & signed_p,
|
&chunksz, &lsb0_p, &signed_p,
|
||||||
& trunc_p, rel->r_addend);
|
&trunc_p, rel->r_addend);
|
||||||
|
|
||||||
mask = (((1L << (len - 1)) - 1) << 1) | 1;
|
mask = (((1L << (len - 1)) - 1) << 1) | 1;
|
||||||
|
|
||||||
@ -7670,9 +7670,9 @@ bfd_elf_perform_complex_relocation (bfd *input_bfd,
|
|||||||
if (! trunc_p)
|
if (! trunc_p)
|
||||||
{
|
{
|
||||||
/* Now do an overflow check. */
|
/* Now do an overflow check. */
|
||||||
if (bfd_check_overflow ((signed_p ?
|
if (bfd_check_overflow ((signed_p
|
||||||
complain_overflow_signed :
|
? complain_overflow_signed
|
||||||
complain_overflow_unsigned),
|
: complain_overflow_unsigned),
|
||||||
len, 0, (8 * wordsz),
|
len, 0, (8 * wordsz),
|
||||||
relocation) == bfd_reloc_overflow)
|
relocation) == bfd_reloc_overflow)
|
||||||
(*_bfd_error_handler)
|
(*_bfd_error_handler)
|
||||||
|
Reference in New Issue
Block a user