Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* CORE_ADDR representation
@ 2010-02-18  4:44 Daniel Jacobowitz
  2010-02-18  5:42 ` Stan Shebs
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Daniel Jacobowitz @ 2010-02-18  4:44 UTC (permalink / raw)
  To: gdb

This comes up again and again, and has at least three times in the
past month with Jan's PIE patches.  Is it time for us to have opaque
arithmetic on target addresses?

My latest problem:

struct section_addr_info *
build_section_addr_info_from_objfile (const struct objfile *objfile)
{
...
  CORE_ADDR mask = CORE_ADDR_MAX;

  if (addr_bit < (sizeof (CORE_ADDR) * HOST_CHAR_BIT))
    mask = ((CORE_ADDR) 1 << addr_bit) - 1;
...
      sap->other[i].addr = (bfd_get_section_vma (objfile->obfd, sec)
                            + objfile->section_offsets->offsets[i]) & mask;

This truncates the high bits.  MIPS sign-extends pointers, even
internally in CORE_ADDR, and this results in separate debug info files
for MIPS executables being relocated off to la-la land.  I had to add
this awful thing:

      if (bfd_get_sign_extend_vma (objfile->obfd)
          && addr_bit < (sizeof (CORE_ADDR) * HOST_CHAR_BIT)
          && (sap->other[i].addr & ((CORE_ADDR) 1 << (addr_bit - 1))) != 0)
        sap->other[i].addr |= ~mask;

Which I'm not really proposing for inclusion, well, unless no one has
a better idea; sepdebug.exp on mips-elf currently fails without this.

For instance, should we always internally sign-extend CORE_ADDR?
Always internally zero-extend?  Having it vary by target has been a
recurring problem.

-- 
Daniel Jacobowitz
CodeSourcery


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2010-02-19 19:27 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-18  4:44 CORE_ADDR representation Daniel Jacobowitz
2010-02-18  5:42 ` Stan Shebs
2010-02-18 14:11   ` Daniel Jacobowitz
2010-02-18 23:04     ` Tom Tromey
2010-02-18 10:18 ` Mark Kettenis
2010-02-18 13:43   ` Daniel Jacobowitz
2010-02-19 19:27     ` Tom Tromey
2010-02-18 10:34 ` Jan Kratochvil
2010-02-18 13:41   ` Daniel Jacobowitz
2010-02-18 13:53     ` Jan Kratochvil

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox