Skip to content

GCC plugin that checks for calls to forbidden functions

License

Notifications You must be signed in to change notification settings

sicherha/forbidden_funcs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

GCC plugin that checks for calls to forbidden functions

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published