# HG changeset patch # User Matti Hamalainen # Date 1352631951 -7200 # Node ID c1d5cccbf5b3ad1966c51f1b04cb0609714865cc # Parent 81b92a0e754bc95ab78384bacad0ba3041ffe001 Implement output data cropping option -c, with which the memory area to be stored in output can be specified. For example -c 0x1000-0x2000. diff -r 81b92a0e754b -r c1d5cccbf5b3 objlink.c --- a/objlink.c Sun Nov 11 13:05:04 2012 +0200 +++ b/objlink.c Sun Nov 11 13:05:51 2012 +0200 @@ -130,6 +130,8 @@ Uint32 optInitValue = 0; int optInitValueType = 1; +ssize_t optCropStart, optCropEnd; +BOOL optCropOutput = FALSE; int optMemModel = 0; const DMMemModel *memModel = NULL; @@ -152,6 +154,7 @@ { 9, 'f', "format", "Format of link-file: (g)eneric, (p)lain, (d)ecimal", OPT_ARGREQ }, { 10, 'i', "initvalue", "Initialize memory with: -i :[bwd]", OPT_ARGREQ }, { 11, 'd', "describe", "Output ASCII memory map description", OPT_NONE }, + { 13, 'c', "crop", "Crop output file to: -c - or :", OPT_ARGREQ }, }; static const int optListN = sizeof(optList) / sizeof(optList[0]); @@ -437,6 +440,19 @@ } break; + case 13: + { + ssize_t cropLen; + if (!dmParseSection(optArg, &optCropStart, &optCropEnd, &cropLen)) + return FALSE; + + dmMsg(1, "Cutting output to $%.4x - $%.4x ($%x, %d bytes)\n", + optCropStart, optCropEnd, cropLen, cropLen); + + optCropOutput = TRUE; + } + break; + default: dmError("Unknown argument '%s'.\n", currArg); return FALSE; @@ -866,9 +882,19 @@ } // Show some information + if (optCropOutput) + { + startAddr = optCropStart; + endAddr = optCropEnd; + } + dataSize = endAddr - startAddr + 1; - dmMsg(1, "Total of %d/$%x bytes unused(?) areas.\n", - dataSize - totalSize, dataSize - totalSize); + + if (dataSize - totalSize > 0) + { + dmMsg(1, "Total of %d/$%x bytes unused(?) areas.\n", + dataSize - totalSize, dataSize - totalSize); + } dmMsg(1, "Writing $%.4x - $%.4x (%d/$%x bytes) ", startAddr, endAddr, dataSize, dataSize);