aboutsummaryrefslogtreecommitdiff
path: root/libminijail-private.h
diff options
context:
space:
mode:
authorWill Drewry <wad@chromium.org>2011-10-21 16:38:58 -0500
committerGerrit <chrome-bot@google.com>2011-10-27 15:30:12 -0700
commit6ac9112378c716d6c1de2952bb971728b0655616 (patch)
tree333c93a54015401667e984383bb0ae6c34b50aea /libminijail-private.h
parentbee7ba7f2cd6168f60f51dd0ce3ac8961b4cc25a (diff)
downloadminijail-6ac9112378c716d6c1de2952bb971728b0655616.tar.gz
Makefile, libminijail: Invert symbol visibility to allow sane unittesting
libminijail.c contains many helpers that are marked static. For instance, consumestr and consumebytes are both static yet eminently unittestable. The options for testing are as follows: 1. Replace "static" with a "private" or "protected" macro which we undefined during testing. 2. #include "libminijail.c" into the unittests to avoid visibility challenges. 3. Change default visibility to internal for all functions and data then invert it during unittesting. I chose #3. It also has the benefit of creating an optimally stripped binary and shared object. Using 'internal' visibility also let's the linker perform more optimizations. Feedback on this approach is very welcome. In the past, I've chosen approach #2, but that seems wrong for at least a couple of reasons. TEST=build, run readelf -s in all the output. .so should show LOCAL for all internal functions and on executables, private functions should show INTERNAL. Running strip --unneeded should remove all of the private linkage which can be checked with readelf -s again BUG=none Change-Id: Ifb1f02b4505f2f25d824c067748054520c39d3bf Reviewed-on: https://gerrit.chromium.org/gerrit/10540 Commit-Ready: Will Drewry <wad@chromium.org> Tested-by: Will Drewry <wad@chromium.org> Reviewed-by: Will Drewry <wad@chromium.org>
Diffstat (limited to 'libminijail-private.h')
-rw-r--r--libminijail-private.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/libminijail-private.h b/libminijail-private.h
index a076736..62d2625 100644
--- a/libminijail-private.h
+++ b/libminijail-private.h
@@ -10,6 +10,11 @@
#ifndef LIBMINIJAIL_PRIVATE_H
#define LIBMINIJAIL_PRIVATE_H
+/* Explicitly declare exported functions so that -fvisibility tricks
+ * can be used for testing and minimal symbol leakage occurs.
+ */
+#define API __attribute__ ((visibility("default")))
+
static const char *kFdEnvVar = "__MINIJAIL_FD";
static const char *kLdPreloadEnvVar = "LD_PRELOAD";