function::usymname - Linux


Overview

function::usymname is a command-line tool for rewriting symbol names in a function using a given format. It allows users to transform and modify symbol names in a consistent and standardized way.

Syntax

function::usymname [options] <function> <format>

Options/Flags

  • -h, –help: Display help and usage information.
  • -q, –quiet: Suppress output except for errors.
  • -v, –verbose: Enable verbose output, showing additional information about the transformation.

Examples

Simple Symbol Transformation:

function::usymname my_function my_prefix_%s

This rewrites the symbol name my_function to my_prefix_my_function.

Complex Format Manipulation:

function::usymname my_complex_function "($0)_(%i)"

This formats the symbol name as my_complex_function_(0), my_complex_function_(1), and so on, for multiple instances of the function.

Common Issues

  • Symbol Not Found: Ensure the function name provided in <function> exists in the code.
  • Invalid Format String: The format string in <format> should follow proper C printf() syntax.

Integration

With Scripting:

#!/bin/bash

functions=$(grep -roh 'function [a-zA-Z_0-9]*\(' *.c)

for function in ${functions}; do
  stripped_function=$(echo "${function}" | sed 's/function //g' | sed 's/(//g')
  new_function_name="my_prefix_${stripped_function}"
  function::usymname "${stripped_function}" "${new_function_name}"
done

This script automates the symbol name transformation for all functions in C source files.

Related Commands

  • objdump: Display information about object files, including symbol names.
  • nm: List symbols from object files or executables.