path: root/com32/elflink
diff options
authorMatt Fleming <matt.fleming@intel.com>2012-12-04 21:17:47 +0000
committerMatt Fleming <matt.fleming@intel.com>2012-12-05 22:41:32 +0000
commite4b3ce2dd82ce2da85c37fd3f332ec2eb802b734 (patch)
tree8b98440a37716dab0bd4de8b87a3800e5a40b07b /com32/elflink
parenta79ceb45909434d392aacbb92eb2dfa738479783 (diff)
Symbol export whitelist
Before modules were dynamically loaded the boundary between GPL and non-GPL code was implicit because of the separate link domains for each module. With dynamic modules we need an explicit whitelist of core symbols that non-GPL code can link against at runtime without needing to be re-licensed under the GPL. Mark such symbols with __export, so that it is explicitly clear which symbols in the core can be linked against by non-GPL code. Reduce the visibility of symbols in both the core and ldlinux.c32 with -fvisibility=hidden. __export changes the visibility to 'default'. Signed-off-by: Matt Fleming <matt.fleming@intel.com>
Diffstat (limited to 'com32/elflink')
9 files changed, 15 insertions, 13 deletions
diff --git a/com32/elflink/ldlinux/Makefile b/com32/elflink/ldlinux/Makefile
index b4e5cfa1..93ca127d 100644
--- a/com32/elflink/ldlinux/Makefile
+++ b/com32/elflink/ldlinux/Makefile
@@ -14,7 +14,7 @@ topdir = ../../..
MAKEDIR = $(topdir)/mk
include $(MAKEDIR)/elf.mk
-CFLAGS += -I$(topdir)/core/elflink -I$(topdir)/core/include -I$(topdir)/com32/lib
+CFLAGS += -I$(topdir)/core/elflink -I$(topdir)/core/include -I$(topdir)/com32/lib -fvisibility=hidden
LIBS = --whole-archive $(com32)/lib/libcom32min.a
all: ldlinux.c32 ldlinux_lnx.a
@@ -24,6 +24,7 @@ ldlinux.c32 : ldlinux.o cli.o readconfig.o refstr.o colors.o getadv.o \
advwrite.o setadv.o eprintf.o loadhigh.o msg.o
$(LD) $(LDFLAGS) -o $@ $^ $(LIBS)
+LNXCFLAGS += -D__export='__attribute__((visibility("default")))'
LNXLIBOBJS = get_key.lo
ldlinux_lnx.a: $(LNXLIBOBJS)
rm -f $@
diff --git a/com32/elflink/ldlinux/adv.c b/com32/elflink/ldlinux/adv.c
index b81361f2..4c3ad508 100644
--- a/com32/elflink/ldlinux/adv.c
+++ b/com32/elflink/ldlinux/adv.c
@@ -36,8 +36,8 @@
#include <inttypes.h>
#include <com32.h>
-void *__syslinux_adv_ptr;
-size_t __syslinux_adv_size;
+__export void *__syslinux_adv_ptr;
+__export size_t __syslinux_adv_size;
extern void adv_init(void);
void __constructor __syslinux_init(void)
diff --git a/com32/elflink/ldlinux/advwrite.c b/com32/elflink/ldlinux/advwrite.c
index 4152eea5..35829c1c 100644
--- a/com32/elflink/ldlinux/advwrite.c
+++ b/com32/elflink/ldlinux/advwrite.c
@@ -35,7 +35,7 @@
#include <klibc/compiler.h>
#include <com32.h>
-int syslinux_adv_write(void)
+__export int syslinux_adv_write(void)
static com32sys_t reg;
diff --git a/com32/elflink/ldlinux/execute.c b/com32/elflink/ldlinux/execute.c
index 4b4faf82..bfb26ffb 100644
--- a/com32/elflink/ldlinux/execute.c
+++ b/com32/elflink/ldlinux/execute.c
@@ -47,7 +47,7 @@ const struct image_types image_boot_types[] = {
extern int create_args_and_load(char *);
-void execute(const char *cmdline, uint32_t type)
+__export void execute(const char *cmdline, uint32_t type)
const char *kernel, *args;
const char *p;
diff --git a/com32/elflink/ldlinux/get_key.c b/com32/elflink/ldlinux/get_key.c
index 123171ae..cece0f81 100644
--- a/com32/elflink/ldlinux/get_key.c
+++ b/com32/elflink/ldlinux/get_key.c
@@ -166,7 +166,7 @@ int raw_read(int fd, void *buf, size_t count)
extern int raw_read(int fd, void *buf, size_t count);
-int get_key(FILE * f, clock_t timeout)
+__export int get_key(FILE * f, clock_t timeout)
char buffer[KEY_MAXLEN];
int nc, rv;
diff --git a/com32/elflink/ldlinux/getadv.c b/com32/elflink/ldlinux/getadv.c
index 5578313e..1c27f1b8 100644
--- a/com32/elflink/ldlinux/getadv.c
+++ b/com32/elflink/ldlinux/getadv.c
@@ -36,7 +36,7 @@
#include <klibc/compiler.h>
#include <inttypes.h>
-const void *syslinux_getadv(int tag, size_t * size)
+__export const void *syslinux_getadv(int tag, size_t * size)
const uint8_t *p;
size_t left;
diff --git a/com32/elflink/ldlinux/ldlinux.c b/com32/elflink/ldlinux/ldlinux.c
index 62db2f71..484ebe52 100644
--- a/com32/elflink/ldlinux/ldlinux.c
+++ b/com32/elflink/ldlinux/ldlinux.c
@@ -46,7 +46,7 @@ static inline const char *find_command(const char *str)
return p;
-uint32_t parse_image_type(const char *kernel)
+__export uint32_t parse_image_type(const char *kernel)
const struct file_ext *ext;
const char *p;
@@ -141,7 +141,7 @@ const char *apply_extension(const char *kernel, const char *ext)
* the the kernel. If we return the caller should call enter_cmdline()
* so that the user can help us out.
-void load_kernel(const char *command_line)
+__export void load_kernel(const char *command_line)
struct menu_entry *me;
const char *cmdline;
@@ -278,7 +278,7 @@ void ldlinux_console_init(void)
openconsole(&dev_stdcon_r, &dev_ansiserial_w);
-int main(int argc __unused, char **argv __unused)
+__export int main(int argc __unused, char **argv __unused)
const void *adv;
const char *cmdline;
diff --git a/com32/elflink/ldlinux/readconfig.c b/com32/elflink/ldlinux/readconfig.c
index 7411fcaf..6a419c6d 100644
--- a/com32/elflink/ldlinux/readconfig.c
+++ b/com32/elflink/ldlinux/readconfig.c
@@ -82,10 +82,11 @@ short vkernel = 0; //have we seen any "label" statements?
short displaycon = 1; //conio.inc
extern short NoHalt; //idle.c
-const char *default_cmd = NULL; //"default" command line
const char *onerror = NULL; //"onerror" command line
const char *ontimeout = NULL; //"ontimeout" command line
+__export const char *default_cmd = NULL; //"default" command line
/* Empty refstring */
const char *empty_string;
@@ -599,7 +600,7 @@ uint32_t parse_argb(char **p)
//static const char *append = NULL;
extern const char *append;
//static unsigned int ipappend = 0;
-unsigned int ipappend = 0;
+__export unsigned int ipappend = 0;
extern uint16_t PXERetry;
static struct labeldata ld;
diff --git a/com32/elflink/ldlinux/setadv.c b/com32/elflink/ldlinux/setadv.c
index 40f00a4e..2e386213 100644
--- a/com32/elflink/ldlinux/setadv.c
+++ b/com32/elflink/ldlinux/setadv.c
@@ -45,7 +45,7 @@
#include <errno.h>
#include <alloca.h>
-int syslinux_setadv(int tag, size_t size, const void *data)
+__export int syslinux_setadv(int tag, size_t size, const void *data)
uint8_t *p, *advtmp;
size_t rleft, left;