components/gdb/patches/gdb.bfd.elf.c.patch
changeset 1511 4d3b0b480760
child 6420 65948e9e205b
equal deleted inserted replaced
1510:2a70db54adec 1511:4d3b0b480760
       
     1 --- gdb-7.6/bfd/elf.c	2013-03-08 09:13:31.000000000 -0800
       
     2 +++ gdb-7.6/bfd/elf.c	2013-10-09 17:18:34.783717730 -0700
       
     3 @@ -8088,7 +8088,10 @@
       
     4  static bfd_boolean
       
     5  elfcore_grok_prfpreg (bfd *abfd, Elf_Internal_Note *note)
       
     6  {
       
     7 +  asection *sect = bfd_get_section_by_name (abfd, ".reg2");
       
     8 +  if (sect == NULL)
       
     9    return elfcore_make_note_pseudosection (abfd, ".reg2", note);
       
    10 +  return TRUE;
       
    11  }
       
    12  
       
    13  /* Linux dumps the Intel SSE regs in a note named "LINUX" with a note
       
    14 @@ -8341,7 +8344,6 @@
       
    15  }
       
    16  #endif /* defined (HAVE_PSTATUS_T) */
       
    17  
       
    18 -#if defined (HAVE_LWPSTATUS_T)
       
    19  static bfd_boolean
       
    20  elfcore_grok_lwpstatus (bfd *abfd, Elf_Internal_Note *note)
       
    21  {
       
    22 @@ -8423,7 +8425,6 @@
       
    23  
       
    24    return elfcore_maybe_make_sect (abfd, ".reg2", sect);
       
    25  }
       
    26 -#endif /* defined (HAVE_LWPSTATUS_T) */
       
    27  
       
    28  static bfd_boolean
       
    29  elfcore_grok_win32pstatus (bfd *abfd, Elf_Internal_Note *note)
       
    30 @@ -8534,14 +8535,17 @@
       
    31        return TRUE;
       
    32  #endif
       
    33  
       
    34 -#if defined (HAVE_PSTATUS_T)
       
    35      case NT_PSTATUS:
       
    36        return elfcore_grok_pstatus (abfd, note);
       
    37 -#endif
       
    38  
       
    39 -#if defined (HAVE_LWPSTATUS_T)
       
    40      case NT_LWPSTATUS:
       
    41 +      if (bed->elf_backend_grok_lwpstatus)
       
    42 +	if ((*bed->elf_backend_grok_lwpstatus) (abfd, note))
       
    43 +	  return TRUE;
       
    44 +#if defined (HAVE_LWPSTATUS_T)
       
    45        return elfcore_grok_lwpstatus (abfd, note);
       
    46 +#else
       
    47 +      return TRUE;
       
    48  #endif
       
    49  
       
    50      case NT_FPREGSET:		/* FIXME: rename to NT_PRFPREG */
       
    51 @@ -8881,6 +8885,297 @@
       
    52    return TRUE;
       
    53  }
       
    54  
       
    55 +#include <sys/types.h>
       
    56 +#include <sys/elf.h>
       
    57 +#include <sys/procfs.h>
       
    58 +#include <sys/regset.h>
       
    59 +#include <sys/auxv.h>
       
    60 +
       
    61 +static bfd_boolean
       
    62 +elfcore_grok_solaris_note (bfd *abfd, Elf_Internal_Note *note)
       
    63 +{
       
    64 +  asection *sect;
       
    65 +  size_t gregset_size;
       
    66 +  size_t fpregset_size;
       
    67 +  size_t prgregset_size;
       
    68 +  size_t prgregset_offset;
       
    69 +  char reg2_section_name[16];
       
    70 +
       
    71 +#ifdef DEBUG
       
    72 +  static const char* note_type[] = { "NONE (0)", "NT_PRSTATUS", "NT_PRFPREG",
       
    73 +    "NT_PRPSINFO", "NT_PRXREG", "NT_PLATFORM", "NT_AUXV", "NT_GWINDOWS",
       
    74 +    "NT_ASRS", "NT_LDT", "NT_PSTATUS", "INVALID (11)", "INVALID (12)",
       
    75 +    "NT_PSINFO", "NT_PRCRED", "NT_UTSNAME", "NT_LWPSTATUS", "NT_LWPSINFO",
       
    76 +    "NT_PRPRIV", "NT_PRPRIVINFO", "NT_CONTENT", "NT_ZONENAME",
       
    77 +    "NT_PRCPUXREG", NULL };
       
    78 +#endif
       
    79 +
       
    80 +  if (note == NULL)
       
    81 +    return TRUE;
       
    82 +
       
    83 +  sect = bfd_get_section_by_name (abfd, reg2_section_name);
       
    84 +
       
    85 +  switch ((int) note->type)
       
    86 +  {
       
    87 +    case SOLARIS_NT_PRSTATUS:
       
    88 +      if (note->descsz == 508) /* sizeof(prstatus_t) SPARC 32-bit */
       
    89 +      {
       
    90 +        gregset_size = 152;
       
    91 +        fpregset_size = 144;
       
    92 +        prgregset_size = 152; /* sizeof(prgregset_t) SPARC 32-bit */
       
    93 +        prgregset_offset = 356; /* offsetof(prstatus_t, pr_reg */
       
    94 +
       
    95 +        elf_tdata (abfd)->core->signal =
       
    96 +          bfd_get_16 (abfd, note->descdata + 136);
       
    97 +        elf_tdata (abfd)->core->pid =
       
    98 +          bfd_get_32 (abfd, note->descdata + 216);
       
    99 +        elf_tdata (abfd)->core->lwpid =
       
   100 +          bfd_get_32 (abfd, note->descdata + 308);
       
   101 +        (void) snprintf (reg2_section_name, 16, "%s/%i", ".reg2",
       
   102 +            *(int*)(note->descdata + 308));
       
   103 +      }
       
   104 +      else if (note->descsz == 904) /* sizeof(prstatus_t) SPARC 64-bit */
       
   105 +      {
       
   106 +        gregset_size = 168;
       
   107 +        fpregset_size = 288;
       
   108 +        prgregset_size = 304; /* sizeof(prgregset_t) SPARC 64-bit */
       
   109 +        prgregset_offset = 600; /* offsetof(prstatus_t, pr_reg */
       
   110 +
       
   111 +        elf_tdata (abfd)->core->signal =
       
   112 +          bfd_get_16 (abfd, note->descdata + 264);
       
   113 +        elf_tdata (abfd)->core->pid =
       
   114 +          bfd_get_32 (abfd, note->descdata + 360);
       
   115 +        elf_tdata (abfd)->core->lwpid =
       
   116 +          bfd_get_32 (abfd, note->descdata + 520);
       
   117 +        (void) snprintf (reg2_section_name, 16, "%s/%i", ".reg2",
       
   118 +            *(int*)(note->descdata + 520));
       
   119 +      }
       
   120 +      else if (note->descsz == 432) /* sizeof(prstatus_t) Intel 32-bit */
       
   121 +      {
       
   122 +        gregset_size = 76;
       
   123 +        fpregset_size = 380;
       
   124 +        prgregset_size = 76;
       
   125 +        prgregset_offset = 356; /* offsetof(prstatus_t, pr_reg */
       
   126 +
       
   127 +        elf_tdata (abfd)->core->signal =
       
   128 +          bfd_get_16 (abfd, note->descdata + 136);
       
   129 +        elf_tdata (abfd)->core->pid =
       
   130 +          bfd_get_32 (abfd, note->descdata + 216);
       
   131 +        elf_tdata (abfd)->core->lwpid =
       
   132 +          bfd_get_32 (abfd, note->descdata + 308);
       
   133 +        (void) snprintf (reg2_section_name, 16, "%s/%i", ".reg2",
       
   134 +            *(int*)(note->descdata + 308));
       
   135 +      }
       
   136 +      else if (note->descsz == 824) /* sizeof(prstatus_t) Intel 64-bit */
       
   137 +      {
       
   138 +        gregset_size = 224;
       
   139 +        fpregset_size = 528;
       
   140 +        prgregset_size = 224;
       
   141 +        prgregset_offset = 600; /* offsetof(prstatus_t, pr_reg */
       
   142 +
       
   143 +        elf_tdata (abfd)->core->signal =
       
   144 +          bfd_get_16 (abfd, note->descdata + 264);
       
   145 +        elf_tdata (abfd)->core->pid =
       
   146 +          bfd_get_32 (abfd, note->descdata + 360);
       
   147 +        elf_tdata (abfd)->core->lwpid =
       
   148 +          bfd_get_32 (abfd, note->descdata + 520);
       
   149 +        (void) snprintf (reg2_section_name, 16, "%s/%i", ".reg2",
       
   150 +            *(int*)(note->descdata + 520));
       
   151 +      }
       
   152 +
       
   153 +      sect = bfd_get_section_by_name (abfd, ".reg");
       
   154 +
       
   155 +      if (sect != NULL)
       
   156 +        sect->size = prgregset_size;
       
   157 +
       
   158 +      return _bfd_elfcore_make_pseudosection (abfd, ".reg",
       
   159 +          prgregset_size, note->descpos + prgregset_offset);
       
   160 +      break;
       
   161 +    case SOLARIS_NT_PRFPREG:
       
   162 +      break;
       
   163 +    case SOLARIS_NT_PRPSINFO:
       
   164 +      if (note->descsz == 260) /* sizeof(prpsinfo_t) */
       
   165 +      {
       
   166 +        elf_tdata (abfd)->core->program
       
   167 +          = _bfd_elfcore_strndup (abfd, note->descdata + 84, 16);
       
   168 +        elf_tdata (abfd)->core->command
       
   169 +          = _bfd_elfcore_strndup (abfd, note->descdata + 100, 80);
       
   170 +      }
       
   171 +      break;
       
   172 +    case SOLARIS_NT_PRXREG:
       
   173 +    case SOLARIS_NT_PLATFORM:
       
   174 +    case SOLARIS_NT_GWINDOWS:
       
   175 +    case SOLARIS_NT_ASRS:
       
   176 +    case SOLARIS_NT_LDT:
       
   177 +    case SOLARIS_NT_PSTATUS:
       
   178 +      break;
       
   179 +    case SOLARIS_NT_PSINFO:
       
   180 +      if (note->descsz == 336) /* sizeof(psinfo_t) SPARC */
       
   181 +      {
       
   182 +        elf_tdata (abfd)->core->program
       
   183 +          = _bfd_elfcore_strndup (abfd, note->descdata + 88, 16);
       
   184 +        elf_tdata (abfd)->core->command
       
   185 +          = _bfd_elfcore_strndup (abfd, note->descdata + 104, 80);
       
   186 +      }
       
   187 +      else if (note->descsz == 360) /* sizeof(psinfo_t) Intel */
       
   188 +      {
       
   189 +        elf_tdata (abfd)->core->program
       
   190 +          = _bfd_elfcore_strndup (abfd, note->descdata + 88, 16);
       
   191 +        elf_tdata (abfd)->core->command
       
   192 +          = _bfd_elfcore_strndup (abfd, note->descdata + 104, 80);
       
   193 +      }
       
   194 +      break;
       
   195 +    case SOLARIS_NT_PRCRED:
       
   196 +    case SOLARIS_NT_UTSNAME:
       
   197 +      break;
       
   198 +    case SOLARIS_NT_LWPSTATUS:
       
   199 +        elf_tdata (abfd)->core->lwpid =
       
   200 +          bfd_get_32 (abfd, note->descdata + 4);
       
   201 +        elf_tdata (abfd)->core->signal =
       
   202 +          bfd_get_16 (abfd, note->descdata + 12);
       
   203 +        (void) snprintf (reg2_section_name, 16, "%s/%i", ".reg2",
       
   204 +            *(int*)(note->descdata + 4));
       
   205 +
       
   206 +        if (note->descsz == 896) /* sizeof(lwpstatus_t) SPARC 32-bit */
       
   207 +        {
       
   208 +          gregset_size = 152;
       
   209 +          fpregset_size = 400;
       
   210 +          prgregset_size = 152; /* sizeof(prgregset_t) SPARC 32-bit */
       
   211 +
       
   212 +          sect = bfd_get_section_by_name (abfd, ".reg");
       
   213 +          if (sect != NULL)
       
   214 +            sect->size = sizeof(prgregset_t);
       
   215 +          else
       
   216 +          {
       
   217 +            if ((_bfd_elfcore_make_pseudosection (abfd, ".reg",
       
   218 +                    prgregset_size,
       
   219 +                    note->descpos + 356)) != TRUE)
       
   220 +              return FALSE;
       
   221 +          }
       
   222 +          sect = bfd_get_section_by_name (abfd, reg2_section_name);
       
   223 +
       
   224 +          if (sect != NULL)
       
   225 +          {
       
   226 +            sect->size = fpregset_size;
       
   227 +            sect->filepos = note->descpos + 496;
       
   228 +            sect->alignment_power = 2;
       
   229 +            return TRUE;
       
   230 +          }
       
   231 +          else
       
   232 +            return _bfd_elfcore_make_pseudosection (abfd, reg2_section_name,
       
   233 +                fpregset_size, note->descpos + 496);
       
   234 +        }
       
   235 +        else if (note->descsz == 1392) /* sizeof(lwpstatus_t) SPARC 64-bit */
       
   236 +        {
       
   237 +          gregset_size = 304;
       
   238 +          fpregset_size = 544;
       
   239 +          prgregset_size = 304; /* sizeof(prgregset_t) SPARC 64-bit */
       
   240 +
       
   241 +          sect = bfd_get_section_by_name (abfd, ".reg");
       
   242 +          if (sect != NULL)
       
   243 +            sect->size = sizeof(prgregset_t);
       
   244 +          else
       
   245 +          {
       
   246 +            if ((_bfd_elfcore_make_pseudosection (abfd, ".reg",
       
   247 +                    prgregset_size,
       
   248 +                    note->descpos + 544)) != TRUE)
       
   249 +              return FALSE;
       
   250 +          }
       
   251 +          sect = bfd_get_section_by_name (abfd, reg2_section_name);
       
   252 +
       
   253 +          if (sect != NULL)
       
   254 +          {
       
   255 +            sect->size = fpregset_size;
       
   256 +            sect->filepos = note->descpos + 848;
       
   257 +            sect->alignment_power = 2;
       
   258 +            return TRUE;
       
   259 +          }
       
   260 +          else
       
   261 +            return _bfd_elfcore_make_pseudosection (abfd, reg2_section_name,
       
   262 +                fpregset_size, note->descpos + 848);
       
   263 +        }
       
   264 +        else if (note->descsz == 800) /* sizeof(lwpstatus_t) Intel 32 */
       
   265 +        {
       
   266 +          gregset_size = 76;
       
   267 +          fpregset_size = 380;
       
   268 +          prgregset_size = 76;
       
   269 +
       
   270 +          sect = bfd_get_section_by_name (abfd, ".reg");
       
   271 +          if (sect != NULL)
       
   272 +            sect->size = prgregset_size;
       
   273 +          else
       
   274 +          {
       
   275 +            if ((_bfd_elfcore_make_pseudosection (abfd, ".reg",
       
   276 +                    prgregset_size,
       
   277 +                    note->descpos + 356)) != TRUE)
       
   278 +              return FALSE;
       
   279 +          }
       
   280 +          sect = bfd_get_section_by_name (abfd, reg2_section_name);
       
   281 +
       
   282 +          if (sect != NULL)
       
   283 +          {
       
   284 +            sect->size = fpregset_size;
       
   285 +            sect->filepos = note->descpos + 420;
       
   286 +            sect->alignment_power = 2;
       
   287 +            return TRUE;
       
   288 +          }
       
   289 +          else
       
   290 +            return _bfd_elfcore_make_pseudosection (abfd, reg2_section_name,
       
   291 +                fpregset_size, note->descpos + 420);
       
   292 +        }
       
   293 +        else if (note->descsz == 1296) /* sizeof(lwpstatus_t) Intel 64 */
       
   294 +        {
       
   295 +          gregset_size = 224;
       
   296 +          fpregset_size = 528;
       
   297 +          prgregset_size = 224;
       
   298 +
       
   299 +          sect = bfd_get_section_by_name (abfd, ".reg");
       
   300 +          if (sect != NULL)
       
   301 +            sect->size = prgregset_size;
       
   302 +          else
       
   303 +          {
       
   304 +            if ((_bfd_elfcore_make_pseudosection (abfd, ".reg",
       
   305 +                    prgregset_size,
       
   306 +                    note->descpos + 544)) != TRUE)
       
   307 +              return FALSE;
       
   308 +          }
       
   309 +          sect = bfd_get_section_by_name (abfd, reg2_section_name);
       
   310 +
       
   311 +          if (sect != NULL)
       
   312 +          {
       
   313 +            sect->size = fpregset_size;
       
   314 +            sect->filepos = note->descpos + 768;
       
   315 +            sect->alignment_power = 2;
       
   316 +            return TRUE;
       
   317 +          }
       
   318 +          else
       
   319 +            return _bfd_elfcore_make_pseudosection (abfd, reg2_section_name,
       
   320 +                fpregset_size, note->descpos + 768);
       
   321 +        }
       
   322 +      break;
       
   323 +    case SOLARIS_NT_LWPSINFO:
       
   324 +        if (note->descsz == 128) /* sizeof(lwpsinfo_t) Intel and SPARC */
       
   325 +        {
       
   326 +          elf_tdata (abfd)->core->lwpid =
       
   327 +            bfd_get_32 (abfd, note->descdata + 4);
       
   328 +        }
       
   329 +        break;
       
   330 +    case SOLARIS_NT_PRPRIV:
       
   331 +    case SOLARIS_NT_PRPRIVINFO:
       
   332 +    case SOLARIS_NT_CONTENT:
       
   333 +    case SOLARIS_NT_ZONENAME:
       
   334 +    case SOLARIS_NT_PRCPUXREG:
       
   335 +    case SOLARIS_NT_AUXV:
       
   336 +      break;
       
   337 +    default:
       
   338 +      break;
       
   339 +  }
       
   340 +
       
   341 +  /* add support for .auxv sections */
       
   342 +  sect = bfd_get_section_by_name (abfd, ".auxv");
       
   343 +  return TRUE;
       
   344 +}
       
   345 +
       
   346  static bfd_boolean
       
   347  elfcore_grok_openbsd_note (bfd *abfd, Elf_Internal_Note *note)
       
   348  {
       
   349 @@ -9657,6 +9952,13 @@
       
   350  	      if (! elfcore_grok_spu_note (abfd, &in))
       
   351  		return FALSE;
       
   352  	    }
       
   353 +	  else if (CONST_STRNEQ (in.namedata, "CORE"))
       
   354 +	    {
       
   355 +	      if (! elfcore_grok_solaris_note (abfd, &in))
       
   356 +		return FALSE;
       
   357 +	      if (! elfcore_grok_note (abfd, &in))
       
   358 +		return FALSE;
       
   359 +	    }
       
   360  	  else
       
   361  	    {
       
   362  	      if (! elfcore_grok_note (abfd, &in))