Abstract
We describe an unusual application of dataflow analysis to reverse compilation from assembler source to ANSI-C. Most real architectures support (or more usually, mandate) the use of register-based operands in computations and provide status bits which are set as an implicit side-effect of arithmetic instructions. Naïve translation of these semantics into C yields programs which are dominated by references to registers and the calculation of status results. The target processor for our reverse compiler is particularly prone to these effects since the functional units are surrounded by pipeline registers which must be loaded and unloaded around each computation, but the problem is common to all reverse compilers: how to render the computational core of a low-level algorithm in high level code that is comfortable for a human to read and which maintains the low level semantics. We apply a brute-force dataflow analysis to provide exact use-define information at all program points and then follow the use-define relationships to back-substitute expressions in an effort to remove register references. We also suppress dead status code calculations and perform limited alias analysis for some special purpose registers which can be accessed via more than one name. We show that use of these techniques can significantly reduce the degree to which the underlying architecture ‘shows through’ into the resulting C translation and that the computation times required are manageable for one-off translations.
This is a preview of subscription content, log in via an institution.
Buying options
Tax calculation will be finalised at checkout
Purchases are for personal use only
Learn about institutional subscriptionsPreview
Unable to display preview. Download preview PDF.
References
Breuer, P.T., Bowen, J.P.: Decompilation: the enumeration of types and grammars. Transactions on Programming Languages and Systems 16(5), 1613–1648 (1994)
Cifuentes, C., Gough, K.J.: Decompilation of binary programs. Software — Practice and Experience 25(7), 811–829 (1995)
Cifuentes, C.: Reverse compilation techniques. PhD thesis, Queensland University of Technology (July 1994)
Freeman, L., Cifuentes, C.: An industry perspective on decompilation. In: Proc. Internat. Conference on Software Maintenance, IEEE, Los Alamitos (1999)
Fuan, C., Zongtian, L., Li, L.: Design and implementation techniques of the 8086 C decompiling system. Mini-micro systems 14(4), 10–18 (1993)
Johnstone, A., Scott, E.: rdp – an iterator based recursive descent parser generator with tree promotion operators. SIGPLAN notices 33(9) (September 1998)
Johnstone, A., Scott, E., Womack, T.: Reverse compilation of Digital Signal Processor assembler source to ANSI-C. In: Proc. Internat. Conference on Software Maintenance, IEEE, Los Alamitos (1999)
Johnstone, A., Scott, E., Womack, T.: Reverse compilation for Digital Signal Processors: a working example. In: Proc 33. Hawaii Intnl. Conf. Sys. Sci., IEEE, Los Alamitos (2000)
Johnstone, A., Scott, E., Womack, T.: What assembly language programmers get up to: control flow challenges in reverse compilation. In: Proc. 4th Eur. Conf. Soft. Maint. & Reengineering, IEEE, Los Alamitos (2000)
Mycroft, A.: Type-based decompilation. In: Swierstra, S.D. (ed.) ESOP 1999. LNCS, vol. 1576, pp. 208–223. Springer, Heidelberg (1999)
Probst, M., Krall, A., Scholz, B.: Register liveness analysis for optimizing binary translation. In: Working Conference on Reverse Engineering, October 2002, pp. 228–235. IEEE Computer Society, Los Alamitos (2002), also at http://www.complang.tuwien.ac.at/cd/wcre02.pdf
Richardson, S.E., Ganapathi, M.: Interprocedural optimization: experimental results. Software Practice and Experience 19(2), 149–169 (1989)
Sharir, M.: Structural analysis: a new approach to flow analysis in optimising compilers. Computer Languages 5(3/4), 141–153 (1980)
Sites, R.L.: Binary translation. Digital Technical Journal 4(4), 137–152 (1992)
van den Brand, M.G.J., Heering, J., Klint, P., Olivier, P.A.: Compiling language definitions: the ASF+SDF compiler. ACM Transactions on Programming Languages and Systems 24(4), 334–368 (2002)
Ward, M.: The fermat assembler re-engineering workbench. In: International Conference on Software Maintenance, November 2001, IEEE Computer Society, Los Alamitos (2001)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2004 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Johnstone, A., Scott, E. (2004). Suppression of Redundant Operations in Reverse Compiled Code Using Global Dataflow Analysis. In: Schepers, H. (eds) Software and Compilers for Embedded Systems. SCOPES 2004. Lecture Notes in Computer Science, vol 3199. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-540-30113-4_8
Download citation
DOI: https://doi.org/10.1007/978-3-540-30113-4_8
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-23035-9
Online ISBN: 978-3-540-30113-4
eBook Packages: Springer Book Archive