PostHeaderIcon TMS320F28234: Decoding a Program When the Symbols Are Gone

An image read from a production device is a flat sequence of 16-bit words. Nothing in it says where one function ends and the next begins, which regions are code and which are tables, or what any address means. A disassembler will happily produce a listing from the first word to the last, and most of that listing will be wrong — not because the disassembler is faulty, but because it is being asked to decode data as instructions.

Decoding is the work of recovering the structure that the toolchain discarded. On this family three features of the architecture make it more systematic than it first appears.

The vector table gives you the skeleton

The interrupt vector table sits at a fixed base, and every entry is a branch. That is the single most useful fact in the image: a contiguous run of branch instructions at a known address identifies, unambiguously, every routine the firmware considers an entry point.

From those branches you get:

  • the address of each interrupt service routine;
  • the set of peripherals the firmware actually services, because the vector index identifies the source;
  • a rough partition of the image into the handlers and everything else.

Vector tables are also where sloppy builds show themselves. Two entries pointing at the same address means one handler serves two sources. An entry pointing at a single return instruction means the interrupt is enabled and unhandled — often the most informative thing in the whole image, because it says which peripheral the developer intended to use and did not finish.

Initialisation is a fixed order

Startup code on a C2000 device does the same things in roughly the same sequence: disable the watchdog, configure the PLL and clock, set up the peripheral clocks, initialise RAM, copy initialised data, then enable interrupts.

That order is a signature. A region that writes the watchdog register, then the PLL registers, then a block copy, is startup code, and its boundaries are visible because it begins with the first write to the watchdog and ends with the first interrupt enable.

Recognising startup code early pays twice: it identifies the reset entry point, which anchors the whole disassembly, and it exposes the clock configuration, which you need to interpret every timing constant in the rest of the image.

Distinguishing code from data

The hard problem is that a 16-bit word can be a legal instruction and a legal constant at the same time. Three tests reduce the ambiguity:

Test Code behaves like Data behaves like
Branch alignment Targets land on instruction boundaries No branches reference it
Return density Ends with a return, or a branch to one No returns anywhere inside
Call references Addressed by a call from elsewhere Addressed by a data read

The third test is the strongest. In a C28x image, calls and branches carry addresses. A region that is never the target of a call and never branched to is almost never code — it is a table, and its structure is usually regular, because tables are indexed.

Floating-point constants and their give-away

This family has hardware floating point, and firmware that uses it stores single-precision constants as pairs of words. Two properties make them findable:

  • A run of values in a narrow numeric range looks like a coefficient set.
  • The values are read by a multiply or an add whose operands come from consecutive addresses.

Sort the constant regions by the instruction that reads them and the algorithm’s structure emerges: filters read coefficients in order of tap index, scaling factors appear once, and lookup tables have a regular stride between entries.

This is where decoding produces engineering insight rather than a listing. A block of thirty-two coefficients read in order by a multiply-accumulate loop is a 32-tap filter, and the values say what kind of filter.

Rebuilding call structure

Once entry points and code regions are established, the call graph can be reconstructed mechanically: scan for call instructions, resolve their targets, and record the edges. The result is a graph with no names, and it is still informative.

  • A node with many callers is a utility — delay, scaling, communication.
  • A node with no callers and no vector entry is dead code, or code reached only by computed branch.
  • A strongly connected cluster is a state machine or a scheduler.
  • A node reached from a timer vector that calls three others is a control loop.

The third and fourth patterns are what a reader actually wants, and both are visible without a single symbol name.

What decoding does not give you

It does not give you names, types, or the original control structure. A switch compiled to a jump table is a jump table; recovering the case labels requires knowing what the values mean to the application.

It also does not give you the parts of the behaviour that were never in the code: trim values, calibration performed at test time, configuration loaded from an external device. Those live outside the image and have to be recovered from the device or the production process.

And it does not resolve the ambiguity completely. A region that is never called and never branched to might be a table, or might be code reached through a computed jump. In a well-built image such regions are rare; in a hand-written one they are not.

The order that works

  1. Find the vector table and extract entry points.
  2. Identify startup code and read the clock and peripheral configuration out of it.
  3. Disassemble from each entry point independently, allowing the regions to meet in the middle.
  4. Mark everything not reached as data and test it for regularity.
  5. Reconstruct calls between the decoded regions.
  6. Only then read the algorithms.

Step three is the one that saves time. Disassembling linearly from address zero forces every region to start at a boundary the image does not have. Disassembling outward from entry points produces regions that are correct where they exist, and gaps that are honestly gaps.

Related reading

FAQ

Can a disassembler recover function names? No. Names are discarded at build time. Functions can be delimited and characterised, not named.

How do I tell code from a constant table? By references. Code is called or branched to; data is read. A region with neither is data.

What does the vector table tell me that the code does not? Which interrupts are serviced, which are enabled but unhandled, and where the entry points are.

Is a floating-point constant block recognisable? Yes, by its range and by the instructions that read it in sequence. Coefficient sets have a distinctive shape.

What is unrecoverable? Names, types, comments, and anything that was configured outside the image.

Conclusion

Decoding a symbol-free image is a structural exercise: vectors give the entry points, startup gives the clock, references separate code from data, and the call graph gives the shape of the application. What emerges is not source code, but it is enough to describe what the device does and how — which is the question that actually gets asked.

Comments are closed.