Skip to content

Commit

Permalink
[gsupplicant] Hide internal symbols. JB#41874
Browse files Browse the repository at this point in the history
If nothing else, this makes the library file smaller by reducing
the size of the dynamic symbol table.
  • Loading branch information
monich committed May 13, 2020
1 parent 6673638 commit 2d6f067
Show file tree
Hide file tree
Showing 6 changed files with 135 additions and 46 deletions.
32 changes: 21 additions & 11 deletions Makefile
Expand Up @@ -3,7 +3,7 @@
.PHONY: clean all debug release pkgconfig test
.PHONY: print_debug_lib print_release_lib
.PHONY: print_debug_link print_release_link
.PHONY: print_debug_path print_release_path
.PHONY: print_debug_so print_release_so

#
# Required packages
Expand Down Expand Up @@ -39,6 +39,7 @@ LIB_SYMLINK1 = $(LIB_DEV_SYMLINK).$(VERSION_MAJOR)
LIB_SYMLINK2 = $(LIB_SYMLINK1).$(VERSION_MINOR)
LIB_SONAME = $(LIB_SYMLINK1)
LIB = $(LIB_SONAME).$(VERSION_MINOR).$(VERSION_RELEASE)
STATIC_LIB = $(LIB_NAME).a

#
# Sources
Expand Down Expand Up @@ -94,8 +95,8 @@ INCLUDES = -I$(INCLUDE_DIR) -I$(GEN_DIR)
BASE_FLAGS = -fPIC
FULL_CFLAGS = $(BASE_FLAGS) $(CFLAGS) $(DEFINES) $(WARNINGS) $(INCLUDES) \
-MMD -MP $(shell pkg-config --cflags $(PKGS))
FULL_LDFLAGS = $(BASE_FLAGS) $(LDFLAGS) -shared -Wl,-soname -Wl,$(LIB_SONAME) \
$(shell pkg-config --libs $(PKGS))
FULL_LDFLAGS = $(BASE_FLAGS) $(LDFLAGS) -shared -Wl,-soname=$(LIB_SONAME) \
-Wl,--version-script=libgsupplicant.map $(shell pkg-config --libs $(PKGS))
DEBUG_FLAGS = -g
RELEASE_FLAGS =

Expand Down Expand Up @@ -150,17 +151,19 @@ DEBUG_LIB = $(DEBUG_BUILD_DIR)/$(LIB)
RELEASE_LIB = $(RELEASE_BUILD_DIR)/$(LIB)
DEBUG_LINK = $(DEBUG_BUILD_DIR)/$(LIB_SONAME)
RELEASE_LINK = $(RELEASE_BUILD_DIR)/$(LIB_SONAME)
DEBUG_STATIC_LIB = $(DEBUG_BUILD_DIR)/$(STATIC_LIB)
RELEASE_STATIC_LIB = $(RELEASE_BUILD_DIR)/$(STATIC_LIB)

debug: $(DEBUG_LIB) $(DEBUG_LINK)
debug: $(DEBUG_STATIC_LIB) $(DEBUG_LIB) $(DEBUG_LINK)

release: $(RELEASE_LIB) $(RELEASE_LINK)
release: $(RELEASE_STATIC_LIB) $(RELEASE_LIB) $(RELEASE_LINK)

pkgconfig: $(PKGCONFIG)

print_debug_lib:
print_debug_so:
@echo $(DEBUG_LIB)

print_release_lib:
print_release_so:
@echo $(RELEASE_LIB)

print_debug_link:
Expand All @@ -169,11 +172,12 @@ print_debug_link:
print_release_link:
@echo $(RELEASE_LINK)

print_debug_path:
@echo $(DEBUG_BUILD_DIR)
print_debug_lib:
@echo $(DEBUG_STATIC_LIB)

print_release_lib:
@echo $(RELEASE_STATIC_LIB)

print_release_path:
@echo $(RELEASE_BUILD_DIR)

clean:
rm -f *~ $(SRC_DIR)/*~ $(INCLUDE_DIR)/*~ rpm/*~
Expand Down Expand Up @@ -220,6 +224,12 @@ ifeq ($(KEEP_SYMBOLS),0)
strip $@
endif

$(DEBUG_STATIC_LIB): $(DEBUG_OBJS)
$(AR) rc $@ $?

$(RELEASE_STATIC_LIB): $(RELEASE_OBJS)
$(AR) rc $@ $?

$(DEBUG_BUILD_DIR)/$(LIB_SYMLINK1): $(DEBUG_BUILD_DIR)/$(LIB_SYMLINK2)
ln -sf $(LIB_SYMLINK2) $@

Expand Down
6 changes: 6 additions & 0 deletions libgsupplicant.map
@@ -0,0 +1,6 @@
{
global:
gsupplicant_*;
local:
*;
};
49 changes: 49 additions & 0 deletions src/gsupplicant_types_p.h
@@ -0,0 +1,49 @@
/*
* Copyright (C) 2020 Jolla Ltd.
* Copyright (C) 2020 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the names of the copyright holders nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef GSUPPLICANT_TYPES_PRIVATE_H
#define GSUPPLICANT_TYPES_PRIVATE_H

#include <gsupplicant_types.h>

/* Macros */
#define GSUPPLICANT_INTERNAL G_GNUC_INTERNAL

#endif /* GSUPPLICANT_TYPES_PRIVATE_H */

/*
* Local Variables:
* mode: C
* c-basic-offset: 4
* indent-tabs-mode: nil
* End:
*/
85 changes: 55 additions & 30 deletions src/gsupplicant_util_p.h
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2015-2017 Jolla Ltd.
* Contact: Slava Monich <slava.monich@jolla.com>
* Copyright (C) 2015-2020 Jolla Ltd.
* Copyright (C) 2015-2020 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
Expand All @@ -13,9 +13,9 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Jolla Ltd nor the names of its contributors may
* be used to endorse or promote products derived from this software
* without specific prior written permission.
* 3. Neither the names of the copyright holders nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Expand All @@ -33,6 +33,7 @@
#ifndef GSUPPLICANT_UTIL_PRIVATE_H
#define GSUPPLICANT_UTIL_PRIVATE_H

#include "gsupplicant_types_p.h"
#include <gsupplicant_util.h>
#include <gio/gio.h>

Expand All @@ -54,138 +55,162 @@ gsupplicant_parse_bits_array(
const char* name,
GVariant* value,
const GSupNameIntPair* map,
gsize count);
gsize count)
GSUPPLICANT_INTERNAL;

const char*
gsupplicant_name_int_find_bit(
guint value,
guint* bit,
const GSupNameIntPair* list,
gsize count);
gsize count)
GSUPPLICANT_INTERNAL;

const char*
gsupplicant_name_int_find_int(
guint value,
const GSupNameIntPair* list,
gsize count);
gsize count)
GSUPPLICANT_INTERNAL;

guint
gsupplicant_name_int_get_int(
const char* name,
const GSupNameIntPair* list,
gsize count,
guint default_value);
guint default_value)
GSUPPLICANT_INTERNAL;

gboolean
gsupplicant_name_int_set_bits(
guint* bitmask,
const char* name,
const GSupNameIntPair* list,
gsize count);
gsize count)
GSUPPLICANT_INTERNAL;

const GSupNameIntPair*
gsupplicant_name_int_find_name(
const char* name,
const GSupNameIntPair* list,
gsize count);
gsize count)
GSUPPLICANT_INTERNAL;

const GSupNameIntPair*
gsupplicant_name_int_find_name_i(
const char* name,
const GSupNameIntPair* list,
gsize count);
gsize count)
GSUPPLICANT_INTERNAL;

char*
gsupplicant_name_int_concat(
guint value,
char separator,
const GSupNameIntPair* list,
gsize count);
gsize count)
GSUPPLICANT_INTERNAL;

const char*
gsupplicant_format_bytes(
GBytes* bytes,
gboolean append_length);
gboolean append_length)
GSUPPLICANT_INTERNAL;

guint
gsupplicant_call_later(
GDestroyNotify notify,
void* data);
void* data)
GSUPPLICANT_INTERNAL;

guint
gsupplicant_cancel_later(
GCancellable* cancel);
GCancellable* cancel)
GSUPPLICANT_INTERNAL;

const char*
gsupplicant_check_abs_path(
const char* path);
const char* path)
GSUPPLICANT_INTERNAL;

const char*
gsupplicant_check_blob_or_abs_path(
const char* path,
GHashTable* blobs);
GHashTable* blobs)
GSUPPLICANT_INTERNAL;

int
gsupplicant_dict_parse(
GVariant* dict,
GSupplicantDictStrFunc fn,
void* data);
void* data)
GSUPPLICANT_INTERNAL;

void
gsupplicant_dict_add_value(
GVariantBuilder* builder,
const char* name,
GVariant* value);
GVariant* value)
GSUPPLICANT_INTERNAL;

void
gsupplicant_dict_add_boolean(
GVariantBuilder* builder,
const char* name,
gboolean value);
gboolean value)
GSUPPLICANT_INTERNAL;

void
gsupplicant_dict_add_uint32(
GVariantBuilder* builder,
const char* name,
guint32 value);
guint32 value)
GSUPPLICANT_INTERNAL;

void
gsupplicant_dict_add_string(
GVariantBuilder* builder,
const char* name,
const char* value);
const char* value)
GSUPPLICANT_INTERNAL;

void
gsupplicant_dict_add_string0(
GVariantBuilder* builder,
const char* name,
const char* value);
const char* value)
GSUPPLICANT_INTERNAL;

void
gsupplicant_dict_add_string_ne(
GVariantBuilder* builder,
const char* name,
const char* value);
const char* value)
GSUPPLICANT_INTERNAL;

void
gsupplicant_dict_add_bytes(
GVariantBuilder* builder,
const char* name,
GBytes* value);
GBytes* value)
GSUPPLICANT_INTERNAL;

void
gsupplicant_dict_add_bytes0(
GVariantBuilder* builder,
const char* name,
GBytes* value);
GBytes* value)
GSUPPLICANT_INTERNAL;

GVariant*
gsupplicant_variant_new_ayy(
GBytes** bytes);
GBytes** bytes)
GSUPPLICANT_INTERNAL;

GBytes *
GBytes*
gsupplicant_variant_data_as_bytes(
GVariant *value);
GVariant* value)
GSUPPLICANT_INTERNAL;

#endif /* GSUPPLICANT_UTIL_PRIVATE_H */

Expand Down
5 changes: 2 additions & 3 deletions test/common/Makefile
Expand Up @@ -96,7 +96,6 @@ RELEASE_OBJS = \

DEBUG_LIB_FILE := $(shell $(QUIET_MAKE) -C $(LIB_DIR) print_debug_lib)
RELEASE_LIB_FILE := $(shell $(QUIET_MAKE) -C $(LIB_DIR) print_release_lib)
DEBUG_LIB_PATH := $(shell $(QUIET_MAKE) -C $(LIB_DIR) print_debug_path)
DEBUG_LIB := $(LIB_DIR)/$(DEBUG_LIB_FILE)
RELEASE_LIB := $(LIB_DIR)/$(RELEASE_LIB_FILE)

Expand Down Expand Up @@ -136,10 +135,10 @@ test_banner:
@echo "===========" $(EXE) "=========== "

test: test_banner debug
@LD_LIBRARY_PATH="$(LIB_DIR)/$(DEBUG_LIB_PATH)" $(DEBUG_EXE)
@$(DEBUG_EXE)

valgrind: test_banner debug
@LD_LIBRARY_PATH="$(LIB_DIR)/$(DEBUG_LIB_PATH)" G_DEBUG=gc-friendly G_SLICE=always-malloc valgrind --tool=memcheck --leak-check=full --show-possibly-lost=no $(DEBUG_EXE)
@G_DEBUG=gc-friendly G_SLICE=always-malloc valgrind --tool=memcheck --leak-check=full --show-possibly-lost=no $(DEBUG_EXE)

$(DEBUG_BUILD_DIR):
mkdir -p $@
Expand Down
4 changes: 2 additions & 2 deletions tools/wpa-tool/Makefile
Expand Up @@ -72,8 +72,8 @@ RELEASE_CFLAGS = $(CFLAGS) $(RELEASE_FLAGS) -O2

DEBUG_OBJS = $(SRC:%.c=$(DEBUG_BUILD_DIR)/%.o)
RELEASE_OBJS = $(SRC:%.c=$(RELEASE_BUILD_DIR)/%.o)
DEBUG_LIB_FILE := $(shell $(QUIET_MAKE) -C $(LIB_DIR) print_debug_lib)
RELEASE_LIB_FILE := $(shell $(QUIET_MAKE) -C $(LIB_DIR) print_release_lib)
DEBUG_LIB_FILE := $(shell $(QUIET_MAKE) -C $(LIB_DIR) print_debug_so)
RELEASE_LIB_FILE := $(shell $(QUIET_MAKE) -C $(LIB_DIR) print_release_so)
DEBUG_LINK_FILE := $(shell $(QUIET_MAKE) -C $(LIB_DIR) print_debug_link)
RELEASE_LINK_FILE := $(shell $(QUIET_MAKE) -C $(LIB_DIR) print_release_link)
DEBUG_LIB = $(LIB_DIR)/$(DEBUG_LIB_FILE)
Expand Down

0 comments on commit 2d6f067

Please sign in to comment.