arXiv:2609.08563cs.SESep 2026

Manuscript Offprint

arXiv:2609.08563

PLC-Bin2Src: Retrieving Corresponding Structured Text Source Files for PLC Binaries

Ang Jia, Yaxin Duan, He Jiang, Ming Fan, Zhilei Ren, Xiaochen Li

Ang Jia, Yaxin Duan, He Jiang, Ming Fan, Zhilei Ren, and Xiaochen Li

Abstract—Software reuse allows existing components and third-party libraries to be incorporated into new applications, but binary-only components can obscure their origins and implementations. Software composition analysis seeks to identify these reused components and trace their provenance, supporting dependency inventory, vulnerability assessment, and security auditing. For PLC applications, binary2source matching provides a core link in this analysis: given an opaque PLC binary artifact, retrieve its corresponding Structured Text (ST) source file from a collected source repository. However, this task is complicated by cross-platform compilation heterogeneity, the representation gap between PLC binaries and ST source code, and the granularity mismatch between recovered binary units and ST source files. This paper presents PLC-Bin2Src, a cross-platform binary2source matching framework for retrieving corresponding ST source files for binaries produced by CODESYS, GEB, OpenPLC v2, and OpenPLC v3. Platform-aware frontends construct comparable representations, and a shared backend equally combines control-data flow graph (CDFG), function call graph (FCG), and recovered-symbol similarities to rank source candidates. We evaluate PLC-Bin2Src on PLC-BEAD. Results show that PLC-Bin2Src achieves 95.89% Recall@1, 99.66% Recall@5, and an MRR of 0.9769 across four PLC platforms.

Index Terms—PLC, Structured Text, Binary2Source Matching, Software Composition Analysis

1 INTRODUCTION

Programmable logic controllers (PLCs) are core execution components of industrial automation systems. By cyclically reading field inputs, executing control logic, and updating actuators, deployed PLC programs directly shape the behavior of physical processes [1], [2]. Software reuse allows PLC developers to incorporate existing components and third-party libraries into control applications. However, some reused libraries are delivered only in compiled form. For example, CODESYS supports compiled-library packages and recommends this form for library delivery; downstream developers can therefore integrate such packages without access to their source code or implementation details [3], [4]. Such binary-only reuse makes it difficult for downstream analysts to determine which components have been incorporated, what logic they implement, and where they originate.

Software composition analysis addresses this visibility problem by identifying reused components and linking them to known source implementations. However, existing PLC binary reverse engineering frameworks, such as ICSREF [2] and PLC-BinX [5], only focus on reconstructing executable structure and control semantics from proprietary artifacts. They do not identify which ST source file corresponds to a binary artifact. Therefore, a binary2source matching framework is needed to retrieve the corresponding source implementations, supporting dependency inventory, vulnerability assessment, provenance tracing, and security auditing [6]–[8].

Different from the conventional binaries, PLC software is commonly written in Structured Text (ST), whereas executable artifacts are generated by platform-specific toolchains.

Fig. 1 illustrates the cross-platform representation gap and the source-binary semantic gap using ACOSH.ST from PLC-BEAD [9]. Binaries generated from this ST program yield three different ARM-level views: OpenPLC v3 exposes floating-point instructions and typed runtime calls; CODESYS v3 compiles SQRT to a floating-point square-root instruction and invokes REAL32__LN indirectly; and GEB combines floating-point operations with gebx math calls and geb_hook. Thus, even with the instruction set architecture held constant, instruction context, call targets, and recovered boundaries differ across platforms and share little surface syntax with ST. In summary, binary2source matching for PLC software presents three critical challenges:

  1. Cross-platform compilation heterogeneity. PLC platforms differ in binary formats, compilation toolchains, and runtime organization, so the same ST logic can yield different function boundaries, instruction patterns, and call structures.

  2. Binary-source representation gap. Compilation lowers high-level ST syntax, typed variables, and structured control constructs into machine instructions, memory accesses, temporary values, and runtime calls.

  3. File-level granularity mismatch. The logic of one ST file may be split or reorganized across recovered functions, wrappers, and slices, leaving no one-to-one correspondence between recovered binary units and ST source files.

To address these challenges, we propose a binary2source matching framework named PLC-Bin2Src for PLC binaries. PLC-Bin2Src first uses platform-aware binary frontends and an ST-to-C source frontend to recover comparable representations across the four platforms. It then applies cross-representation normalization and constructs aligned CDFG and FCG channels for control-data relationships and call

Corresponding author: He Jiang. E-mail: jianghe@dlut.edu.cn. Ang Jia, Yaxin Duan, He Jiang, Zhilei Ren, and Xiaochen Li are with the School of Software, Dalian University of Technology, Dalian, China. Ming Fan is with the School of Cyber Science and Engineering, Xi'an Jiaotong University, Xi'an, China.

Figure

Fig. 1. Four views of ACOSH.ST: (a) ST source; (b) OpenPLC v3 ARM disassembly; (c) CODESYS v3 ARM disassembly; and (d) GEB ARM disassembly.

structures, together with a Symbols channel that aggregates lexical clues independently of graph topology. Finally, PLC-Bin2Src organizes function- and slice-level features into file-level documents and uses fixed equal-weight fusion to rank the source repository.

We evaluate PLC-Bin2Src on PLC-BEAD [9]. The results show that PLC-Bin2Src yields 95.89% Recall@1, 99.66% Recall@5, and an MRR of 0.9769 when retrieving corresponding ST source files for PLC binaries compiled on four platforms: CODESYS, GEB, OpenPLC v2, and OpenPLC v3.

The main contributions of this paper are as follows:

  • To the best of our knowledge, PLC-Bin2Src is the first binary2source matching framework for retrieving source programs for PLC binaries.
  • PLC-Bin2Src proposes a multi-channel semantic representation comprising CDFG, FCG, and recovered-symbol representations, and equally fuses their similarities to rank candidate ST files.
  • We evaluate PLC-Bin2Src on PLC-BEAD. It achieves 95.89% Recall@1, 99.66% Recall@5, and an MRR of 0.9769 across the four platforms.

References (42)