Skip to content

Latest commit

 

History

History
42 lines (33 loc) · 1.31 KB

README.md

File metadata and controls

42 lines (33 loc) · 1.31 KB

This is a tiny GCC plugin that takes a list of forbidden functions and emits -Wdeprecated warnings for every call to such a function. It helps enforce bans on the use of certain 'dangerous' library functions such as sprintf() or system().

Building the plugin

You need the following prerequisites:

  • GCC >= 5, with C++ support and plugin-development headers
  • Make
  • Bash (for running the unit tests)

When all dependencies are in place, type:

make

Installing the plugin

sudo make install

This will install forbidden_funcs.so into GCC's plugin directory, i.e. /usr/lib/gcc/<target>/<version>/plugin.

Using the plugin

The plugin takes a comma-separated list of symbols as a named argument called list. For example, to ban the use of sprintf() and system(), add the following flags to GCC's command line (mind the underscores and dashes):

-fplugin=forbidden_funcs -fplugin-arg-forbidden_funcs-list=sprintf,system

To include a C++ function or method, use its mangled symbol name.

Use with icecream

To make proper use of the plugin in an icecream parallel-build setup:

  • Ensure that forbidden_funcs.so and its dependencies (libgcc_s.so.1 and libstdc++.so.6) are included in the build-environment tarball.
  • Pass the plugin's absolute path as the -fplugin= argument.