mirror of
https://github.com/darlinghq/darling-gdb.git
synced 2025-02-06 17:26:11 +00:00
Fix some places where octet to byte conversions are needed.
PR 19713 * elf.c (_bfd_elf_section_offset): Ensure that the returned offset uses bytes not octets. * elflink.c (resolve_section): Likewise. Add a bfd parameter. (eval_section): Pass the input_bfd to resolve_section. (bfd_elf_perform_complex_relocation): Convert byte offset to octets before read and writing values. (elf_link_input_bfd): Add byte to octet conversions. (elf_reloc_link_order): Likewise. (elf_fixup_link_order): Likewise. (bfd_elf_final_link): Likewise. * reloc.c (_bfd_final_link_relocate): Likewise. * syms.c (_bfd_stab_section_find_nearest_line): Likewise.
This commit is contained in:
parent
aa667814c7
commit
37b01f6a13
@ -1,3 +1,20 @@
|
|||||||
|
2016-03-11 Dan Gissel <dgisselq@ieee.org>
|
||||||
|
|
||||||
|
PR 19713
|
||||||
|
* elf.c (_bfd_elf_section_offset): Ensure that the returned offset
|
||||||
|
uses bytes not octets.
|
||||||
|
* elflink.c (resolve_section): Likewise.
|
||||||
|
Add a bfd parameter.
|
||||||
|
(eval_section): Pass the input_bfd to resolve_section.
|
||||||
|
(bfd_elf_perform_complex_relocation): Convert byte offset to
|
||||||
|
octets before read and writing values.
|
||||||
|
(elf_link_input_bfd): Add byte to octet conversions.
|
||||||
|
(elf_reloc_link_order): Likewise.
|
||||||
|
(elf_fixup_link_order): Likewise.
|
||||||
|
(bfd_elf_final_link): Likewise.
|
||||||
|
* reloc.c (_bfd_final_link_relocate): Likewise.
|
||||||
|
* syms.c (_bfd_stab_section_find_nearest_line): Likewise.
|
||||||
|
|
||||||
2016-03-10 Nick Clifton <nickc@redhat.com>
|
2016-03-10 Nick Clifton <nickc@redhat.com>
|
||||||
|
|
||||||
* config.bfd: Mark the i370 target as obsolete.
|
* config.bfd: Mark the i370 target as obsolete.
|
||||||
|
13
bfd/elf.c
13
bfd/elf.c
@ -10464,6 +10464,12 @@ _bfd_elf_rel_local_sym (bfd *abfd,
|
|||||||
sym->st_value + addend);
|
sym->st_value + addend);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Adjust an address within a section. Given OFFSET within SEC, return
|
||||||
|
the new offset within the section, based upon changes made to the
|
||||||
|
section. Returns -1 if the offset is now invalid.
|
||||||
|
The offset (in abnd out) is in target sized bytes, however big a
|
||||||
|
byte may be. */
|
||||||
|
|
||||||
bfd_vma
|
bfd_vma
|
||||||
_bfd_elf_section_offset (bfd *abfd,
|
_bfd_elf_section_offset (bfd *abfd,
|
||||||
struct bfd_link_info *info,
|
struct bfd_link_info *info,
|
||||||
@ -10477,12 +10483,17 @@ _bfd_elf_section_offset (bfd *abfd,
|
|||||||
offset);
|
offset);
|
||||||
case SEC_INFO_TYPE_EH_FRAME:
|
case SEC_INFO_TYPE_EH_FRAME:
|
||||||
return _bfd_elf_eh_frame_section_offset (abfd, info, sec, offset);
|
return _bfd_elf_eh_frame_section_offset (abfd, info, sec, offset);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if ((sec->flags & SEC_ELF_REVERSE_COPY) != 0)
|
if ((sec->flags & SEC_ELF_REVERSE_COPY) != 0)
|
||||||
{
|
{
|
||||||
|
/* Reverse the offset. */
|
||||||
const struct elf_backend_data *bed = get_elf_backend_data (abfd);
|
const struct elf_backend_data *bed = get_elf_backend_data (abfd);
|
||||||
bfd_size_type address_size = bed->s->arch_size / 8;
|
bfd_size_type address_size = bed->s->arch_size / 8;
|
||||||
offset = sec->size - offset - address_size;
|
|
||||||
|
/* address_size and sec->size are in octets. Convert
|
||||||
|
to bytes before subtracting the original offset. */
|
||||||
|
offset = (sec->size - address_size) / bfd_octets_per_byte (abfd) - offset;
|
||||||
}
|
}
|
||||||
return offset;
|
return offset;
|
||||||
}
|
}
|
||||||
|
@ -7751,10 +7751,15 @@ resolve_symbol (const char *name,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Looks up NAME in SECTIONS. If found sets RESULT to NAME's address (in
|
||||||
|
bytes) and returns TRUE, otherwise returns FALSE. Accepts pseudo-section
|
||||||
|
names like "foo.end" which is the end address of section "foo". */
|
||||||
|
|
||||||
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,
|
||||||
|
bfd * abfd)
|
||||||
{
|
{
|
||||||
asection *curr;
|
asection *curr;
|
||||||
unsigned int len;
|
unsigned int len;
|
||||||
@ -7767,6 +7772,7 @@ resolve_section (const char *name,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Hmm. still haven't found it. try pseudo-section names. */
|
/* Hmm. still haven't found it. try pseudo-section names. */
|
||||||
|
/* FIXME: This could be coded more efficiently... */
|
||||||
for (curr = sections; curr; curr = curr->next)
|
for (curr = sections; curr; curr = curr->next)
|
||||||
{
|
{
|
||||||
len = strlen (curr->name);
|
len = strlen (curr->name);
|
||||||
@ -7777,7 +7783,7 @@ resolve_section (const char *name,
|
|||||||
{
|
{
|
||||||
if (strncmp (".end", name + len, 4) == 0)
|
if (strncmp (".end", name + len, 4) == 0)
|
||||||
{
|
{
|
||||||
*result = curr->vma + curr->size;
|
*result = curr->vma + curr->size / bfd_octets_per_byte (abfd);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -7859,7 +7865,7 @@ eval_symbol (bfd_vma *result,
|
|||||||
|
|
||||||
if (symbol_is_section)
|
if (symbol_is_section)
|
||||||
{
|
{
|
||||||
if (!resolve_section (symbuf, flinfo->output_bfd->sections, result)
|
if (!resolve_section (symbuf, flinfo->output_bfd->sections, result, input_bfd)
|
||||||
&& !resolve_symbol (symbuf, input_bfd, flinfo, result,
|
&& !resolve_symbol (symbuf, input_bfd, flinfo, result,
|
||||||
isymbuf, locsymcount))
|
isymbuf, locsymcount))
|
||||||
{
|
{
|
||||||
@ -7872,7 +7878,7 @@ eval_symbol (bfd_vma *result,
|
|||||||
if (!resolve_symbol (symbuf, input_bfd, flinfo, result,
|
if (!resolve_symbol (symbuf, input_bfd, flinfo, result,
|
||||||
isymbuf, locsymcount)
|
isymbuf, locsymcount)
|
||||||
&& !resolve_section (symbuf, flinfo->output_bfd->sections,
|
&& !resolve_section (symbuf, flinfo->output_bfd->sections,
|
||||||
result))
|
result, input_bfd))
|
||||||
{
|
{
|
||||||
undefined_reference ("symbol", symbuf);
|
undefined_reference ("symbol", symbuf);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -8096,8 +8102,8 @@ bfd_elf_perform_complex_relocation (bfd *input_bfd,
|
|||||||
else
|
else
|
||||||
shift = (8 * wordsz) - (start + len);
|
shift = (8 * wordsz) - (start + len);
|
||||||
|
|
||||||
/* FIXME: octets_per_byte. */
|
x = get_value (wordsz, chunksz, input_bfd,
|
||||||
x = get_value (wordsz, chunksz, input_bfd, contents + rel->r_offset);
|
contents + rel->r_offset * bfd_octets_per_byte (input_bfd));
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printf ("Doing complex reloc: "
|
printf ("Doing complex reloc: "
|
||||||
@ -8129,8 +8135,8 @@ bfd_elf_perform_complex_relocation (bfd *input_bfd,
|
|||||||
(unsigned long) relocation, (unsigned long) (mask << shift),
|
(unsigned long) relocation, (unsigned long) (mask << shift),
|
||||||
(unsigned long) ((relocation & mask) << shift), (unsigned long) x);
|
(unsigned long) ((relocation & mask) << shift), (unsigned long) x);
|
||||||
#endif
|
#endif
|
||||||
/* FIXME: octets_per_byte. */
|
put_value (wordsz, chunksz, input_bfd, x,
|
||||||
put_value (wordsz, chunksz, input_bfd, x, contents + rel->r_offset);
|
contents + rel->r_offset * bfd_octets_per_byte (input_bfd));
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -10535,11 +10541,13 @@ elf_link_input_bfd (struct elf_final_link_info *flinfo, bfd *input_bfd)
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
/* FIXME: octets_per_byte. */
|
|
||||||
if (! (o->flags & SEC_EXCLUDE))
|
if (! (o->flags & SEC_EXCLUDE))
|
||||||
{
|
{
|
||||||
file_ptr offset = (file_ptr) o->output_offset;
|
file_ptr offset = (file_ptr) o->output_offset;
|
||||||
bfd_size_type todo = o->size;
|
bfd_size_type todo = o->size;
|
||||||
|
|
||||||
|
offset *= bfd_octets_per_byte (output_bfd);
|
||||||
|
|
||||||
if ((o->flags & SEC_ELF_REVERSE_COPY))
|
if ((o->flags & SEC_ELF_REVERSE_COPY))
|
||||||
{
|
{
|
||||||
/* Reverse-copy input section to output. */
|
/* Reverse-copy input section to output. */
|
||||||
@ -10703,8 +10711,11 @@ elf_reloc_link_order (bfd *output_bfd,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
ok = bfd_set_section_contents (output_bfd, output_section, buf,
|
ok = bfd_set_section_contents (output_bfd, output_section, buf,
|
||||||
link_order->offset, size);
|
link_order->offset
|
||||||
|
* bfd_octets_per_byte (output_bfd),
|
||||||
|
size);
|
||||||
free (buf);
|
free (buf);
|
||||||
if (! ok)
|
if (! ok)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -10886,9 +10897,8 @@ elf_fixup_link_order (bfd *abfd, asection *o)
|
|||||||
{
|
{
|
||||||
s = sections[n]->u.indirect.section;
|
s = sections[n]->u.indirect.section;
|
||||||
offset &= ~(bfd_vma) 0 << s->alignment_power;
|
offset &= ~(bfd_vma) 0 << s->alignment_power;
|
||||||
s->output_offset = offset;
|
s->output_offset = offset / bfd_octets_per_byte (abfd);
|
||||||
sections[n]->offset = offset;
|
sections[n]->offset = offset;
|
||||||
/* FIXME: octets_per_byte. */
|
|
||||||
offset += sections[n]->size;
|
offset += sections[n]->size;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -11948,10 +11958,10 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info)
|
|||||||
continue;
|
continue;
|
||||||
if (strcmp (o->name, ".dynstr") != 0)
|
if (strcmp (o->name, ".dynstr") != 0)
|
||||||
{
|
{
|
||||||
/* FIXME: octets_per_byte. */
|
|
||||||
if (! bfd_set_section_contents (abfd, o->output_section,
|
if (! bfd_set_section_contents (abfd, o->output_section,
|
||||||
o->contents,
|
o->contents,
|
||||||
(file_ptr) o->output_offset,
|
(file_ptr) o->output_offset
|
||||||
|
* bfd_octets_per_byte (abfd),
|
||||||
o->size))
|
o->size))
|
||||||
goto error_return;
|
goto error_return;
|
||||||
}
|
}
|
||||||
|
@ -1375,7 +1375,8 @@ _bfd_final_link_relocate (reloc_howto_type *howto,
|
|||||||
}
|
}
|
||||||
|
|
||||||
return _bfd_relocate_contents (howto, input_bfd, relocation,
|
return _bfd_relocate_contents (howto, input_bfd, relocation,
|
||||||
contents + address);
|
contents
|
||||||
|
+ address * bfd_octets_per_byte (input_bfd));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Relocate a given location using a given value and howto. */
|
/* Relocate a given location using a given value and howto. */
|
||||||
|
@ -430,7 +430,7 @@ CODE_FRAGMENT
|
|||||||
. information. *}
|
. information. *}
|
||||||
. bfd_vma lma;
|
. bfd_vma lma;
|
||||||
.
|
.
|
||||||
. {* The size of the section in octets, as it will be output.
|
. {* The size of the section in *octets*, as it will be output.
|
||||||
. Contains a value even if the section has no contents (e.g., the
|
. Contains a value even if the section has no contents (e.g., the
|
||||||
. size of <<.bss>>). *}
|
. size of <<.bss>>). *}
|
||||||
. bfd_size_type size;
|
. bfd_size_type size;
|
||||||
|
@ -1083,11 +1083,13 @@ _bfd_stab_section_find_nearest_line (bfd *abfd,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
val = bfd_get_32 (abfd, info->stabs + r->address);
|
val = bfd_get_32 (abfd, info->stabs
|
||||||
|
+ r->address * bfd_octets_per_byte (abfd));
|
||||||
val &= r->howto->src_mask;
|
val &= r->howto->src_mask;
|
||||||
sym = *r->sym_ptr_ptr;
|
sym = *r->sym_ptr_ptr;
|
||||||
val += sym->value + sym->section->vma + r->addend;
|
val += sym->value + sym->section->vma + r->addend;
|
||||||
bfd_put_32 (abfd, (bfd_vma) val, info->stabs + r->address);
|
bfd_put_32 (abfd, (bfd_vma) val, info->stabs
|
||||||
|
+ r->address * bfd_octets_per_byte (abfd));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user