Exemple #1
0
void poffReplaceDebugFuncInfo(poffHandle_t handle)
{
  poffLibDebugFuncInfo_t *pDebugInfo;

  /* Discard any existing debug info in the POFF object */

  poffDiscardDebugFuncInfo(handle);

  /* Then add all of the buffered debug info into the object */

  for (pDebugInfo = g_pDebugInfoHead; pDebugInfo;
       pDebugInfo = pDebugInfo->next)
    {
      (void)poffAddDebugFuncInfo(handle, pDebugInfo);

    }
}
Exemple #2
0
void optFinalize(poffHandle_t poffHandle, poffProgHandle_t poffProgHandle)
{
  /* Build label / line number reference table */

  pass1(poffHandle, poffProgHandle);

  /* Reset for next pass */

  insn_ResetOpCodeRead(poffHandle);
  insn_ResetTmpOpCodeWrite(poffProgHandle);

  /* Now process all of the symbols */

  pass2(poffHandle, poffProgHandle);

  /* We do not use the debug function information so we do not bother
   * to fixup the label references.  Just discard this information.
   */

  poffDiscardDebugFuncInfo(poffHandle);

  /* Reset for next pass */

  insn_ResetOpCodeRead(poffHandle);

  /* Generate relocation information and replace all label references
   * in the code with actual program section data offsets.
   */

  pass3(poffHandle, poffProgHandle);

  /* Reset for next pass */

  insn_ResetOpCodeRead(poffHandle);
  insn_ResetTmpOpCodeWrite(poffProgHandle);

  /* Finally, replace file header entry point with the I-space offset */

  pass4(poffHandle);

  /* Clean up after ourselves */

  poffReleaseLabelReferences();
}
Exemple #3
0
static void pass4(poffHandle_t poffHandle)
{
    poffLibDebugFuncInfo_t *pDebugInfoHead = NULL;
    poffLibDebugFuncInfo_t *pDebugInfoTail = NULL;
    poffLibDebugFuncInfo_t *pDebugInfo;
    poffLibDebugFuncInfo_t *pNextDebugInfo;

    /* Read all function debug information into a link list */

    while ((pDebugInfo = poffGetDebugFuncInfo(poffHandle)) != NULL)
    {
        if (!pDebugInfoHead)
        {
            pDebugInfoHead = pDebugInfo;
        }
        else
        {
            pDebugInfoTail->next = pDebugInfo;
        }
        pDebugInfoTail = pDebugInfo;
    }

    /* Convert all of the label references to pcode offsets */

    for (pDebugInfo = pDebugInfoHead; pDebugInfo; pDebugInfo = pDebugInfo->next)
    {
        /* Check if this is a defined label.  This must be the case
         * because there can be no jumps into a unit file.
         */

        int32_t value = poffGetPcForDefinedLabel(pDebugInfo->value);
        if (value >= 0)
        {
            /* Yes... replace the label reference with a text section offset. */

            pDebugInfo->value = value;
        }
        else
        {
            fatal(ePOFFCONFUSION);
        }
    }

    /* Then put all of the debug info back into the POFF object */

    poffDiscardDebugFuncInfo(poffHandle);

    for (pDebugInfo = pDebugInfoHead; pDebugInfo; pDebugInfo = pDebugInfo->next)
    {
        poffAddDebugFuncInfo(poffHandle, pDebugInfo);
    }

    /* Release the bufferred debug information */

    pDebugInfo = pDebugInfoHead;
    while (pDebugInfo)
    {
        pNextDebugInfo = pDebugInfo->next;
        poffReleaseDebugFuncContainer(pDebugInfo);
        pDebugInfo = pNextDebugInfo;
    }
}