aboutsummaryrefslogtreecommitdiffstats
path: root/com32/lib/sys/module/common.c
diff options
context:
space:
mode:
authorMatt Fleming <matt.fleming@intel.com>2012-07-12 17:39:53 +0100
committerMatt Fleming <matt.fleming@intel.com>2012-07-20 10:20:18 +0100
commit373a42433c4bea38d4d93ee749bd4d7f19bded51 (patch)
tree3a5c905b995521ce8279058f6216d7a1f157bece /com32/lib/sys/module/common.c
parentb93e6bc9bdafc9fa2dc8709dc97fa5e598c7e94d (diff)
downloadsyslinux-373a42433c4bea38d4d93ee749bd4d7f19bded51.tar.gz
syslinux-373a42433c4bea38d4d93ee749bd4d7f19bded51.tar.xz
syslinux-373a42433c4bea38d4d93ee749bd4d7f19bded51.zip
lib/sys/module: Add support for weak symbols
We need a means of allowing Syslinux derivative-specific functions to remain unresolved when there is no implementation for them. For example, unload_pxe() is referenced by common code in com32/lib, but is only implemented for PXELINUX. By marking unload_pxe() as __weak we can substitute references with the undefined_symbol() function for SYSLINUX, EXTLINUX and ISOLINUX. Provided that those references are never executed everything works fine. However, if code calls actually calls unload_pxe() from SYSLINUX, EXTLINUX or ISOLINUX an error message is displayed and execution is halted. Signed-off-by: Matt Fleming <matt.fleming@intel.com>
Diffstat (limited to 'com32/lib/sys/module/common.c')
-rw-r--r--com32/lib/sys/module/common.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/com32/lib/sys/module/common.c b/com32/lib/sys/module/common.c
index 19742e65..002b733a 100644
--- a/com32/lib/sys/module/common.c
+++ b/com32/lib/sys/module/common.c
@@ -321,7 +321,7 @@ int check_symbols(struct elf_module *module)
crt_name = module->str_table + crt_sym->st_name;
strong_count = 0;
- weak_count = 0;
+ weak_count = (ELF32_ST_BIND(crt_sym->st_info) == STB_WEAK);
for_each_module(crt_module)
{
@@ -345,6 +345,14 @@ int check_symbols(struct elf_module *module)
if (crt_sym->st_shndx == SHN_UNDEF)
{
// We have an undefined symbol
+ //
+ // We use the weak_count to differentiate
+ // between Syslinux-derivative-specific
+ // functions. For example, unload_pxe() is
+ // only provided by PXELINUX, so we mark it as
+ // __weak and replace it with a reference to
+ // undefined_symbol() on SYSLINUX, EXTLINUX,
+ // and ISOLINUX. See perform_relocations().
if (strong_count == 0 && weak_count == 0)
{
DBG_PRINT("Symbol %s is undefined\n", crt_name);