summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2016-10-24 21:42:41 -0400
committermidipix <writeonce@midipix.org>2016-11-10 23:35:53 -0500
commit251206109d1c2d9c52dc63bbce431685fbabf0a7 (patch)
tree61ce045da2207ce6cf9a7d504c499377dda78ed5
parent68f5d95a7ae35f7284769db992069eab119793ba (diff)
downloadperk-251206109d1c2d9c52dc63bbce431685fbabf0a7.tar.bz2
perk-251206109d1c2d9c52dc63bbce431685fbabf0a7.tar.xz
pe_output_import_libraries(): added error trace support.
-rw-r--r--include/perk/perk.h2
-rw-r--r--src/driver/pe_amain.c8
-rw-r--r--src/output/pe_output_import_libraries.c25
3 files changed, 22 insertions, 13 deletions
diff --git a/include/perk/perk.h b/include/perk/perk.h
index 6f0ee27..1e955b5 100644
--- a/include/perk/perk.h
+++ b/include/perk/perk.h
@@ -200,7 +200,7 @@ perk_api void pe_free_unit_ctx (struct pe_unit_ctx *);
/* utility api */
perk_api int pe_main (int, char **, char **);
perk_api int pe_output_export_symbols (const struct pe_image_meta *, const struct pe_common_ctx *, FILE *);
-perk_api int pe_output_import_libraries(const struct pe_image_meta *, const struct pe_common_ctx *, FILE *);
+perk_api int pe_output_import_libraries(const struct pe_driver_ctx *, const struct pe_image_meta *, FILE *);
perk_api int pe_output_error_record (const struct pe_driver_ctx *, const struct pe_error_info *);
perk_api int pe_output_error_vector (const struct pe_driver_ctx *);
diff --git a/src/driver/pe_amain.c b/src/driver/pe_amain.c
index caebe58..142db3b 100644
--- a/src/driver/pe_amain.c
+++ b/src/driver/pe_amain.c
@@ -59,7 +59,9 @@ static ssize_t pe_paragraph_break(struct pe_unit_ctx * uctx, int * fpara)
return 0;
}
-static void pe_perform_unit_actions(struct pe_unit_ctx * uctx)
+static void pe_perform_unit_actions(
+ const struct pe_driver_ctx * dctx,
+ struct pe_unit_ctx * uctx)
{
int fpara = 0;
uint64_t flags = uctx->cctx->fmtflags;
@@ -72,7 +74,7 @@ static void pe_perform_unit_actions(struct pe_unit_ctx * uctx)
if ((flags & PERK_OUTPUT_IMPORT_LIBS) || (flags & PERK_OUTPUT_IMPORT_SYMS)) {
pe_paragraph_break(uctx,&fpara);
- uctx->status = pe_output_import_libraries(uctx->meta,uctx->cctx,0);
+ uctx->status = pe_output_import_libraries(dctx,uctx->meta,0);
uctx->nerrors += !!uctx->status;
fpara += (uctx->meta->summary.nimplibs > 0);
}
@@ -100,7 +102,7 @@ int pe_main(int argc, char ** argv, char ** envp)
for (unit=dctx->units; *unit; unit++) {
if (!(pe_get_unit_ctx(dctx,*unit,&uctx))) {
- pe_perform_unit_actions(uctx);
+ pe_perform_unit_actions(dctx,uctx);
ret += uctx->nerrors;
pe_free_unit_ctx(uctx);
}
diff --git a/src/output/pe_output_import_libraries.c b/src/output/pe_output_import_libraries.c
index a2eb01b..95920ab 100644
--- a/src/output/pe_output_import_libraries.c
+++ b/src/output/pe_output_import_libraries.c
@@ -13,6 +13,7 @@
#include <perk/perk.h>
#include <perk/perk_output.h>
#include "perk_output_impl.h"
+#include "perk_errinfo_impl.h"
static int pretty_header(const struct pe_common_ctx * cctx, FILE * fout)
{
@@ -42,26 +43,31 @@ static int pretty_implib_item(const struct pe_common_ctx * cctx, const char * na
}
int pe_output_import_libraries(
+ const struct pe_driver_ctx * dctx,
const struct pe_image_meta * m,
- const struct pe_common_ctx * cctx,
FILE * fout)
{
- FILE * ftmp;
- int i;
- unsigned j;
+ FILE * ftmp;
+ int i;
+ unsigned j;
+ const struct pe_common_ctx * cctx = dctx->cctx;
if (!m->summary.nimplibs)
return 0;
if (!(fout = pe_output_prolog(cctx,fout,&ftmp)))
- return -1;
+ return PERK_SYSTEM_ERROR(dctx);
if ((pretty_header(cctx,fout)) < 0)
- return pe_output_epilog(-1,ftmp);
+ return pe_output_epilog(
+ PERK_FILE_ERROR(dctx),
+ ftmp);
for (i=0; i<m->summary.nimplibs; i++) {
if ((pretty_implib_header(cctx,m->idata[i].name,fout)) < 0)
- return pe_output_epilog(-1,ftmp);
+ return pe_output_epilog(
+ PERK_FILE_ERROR(dctx),
+ ftmp);
if (cctx->fmtflags & PERK_OUTPUT_IMPORT_SYMS)
for (j=0; j<m->idata[i].count; j++)
@@ -70,8 +76,9 @@ int pe_output_import_libraries(
cctx,
m->idata[i].items[j].name,
fout)) < 0)
- return pe_output_epilog(-1,ftmp);
-
+ return pe_output_epilog(
+ PERK_FILE_ERROR(dctx),
+ ftmp);
}
return pe_output_epilog(0,ftmp);