Skip to content

libselinux does not build on Blackfin #5

@tpetazzoni

Description

@tpetazzoni

The libselinux library fails to build on the Blackfin architecture, with the following error message:

mapping.lo: In function `_selinux_set_mapping':
mapping.c:(.text+0x25a): undefined reference to `_avc_reset'
callbacks.lo: In function `_default_selinux_validate':
callbacks.c:(.text+0x82): undefined reference to `_security_check_context'
callbacks.lo: In function `_default_selinux_log':
callbacks.c:(.text+0x92): undefined reference to `_is_selinux_enabled'
label_media.lo: In function `_selabel_media_init':
label_media.c:(.text+0xf2): undefined reference to `_selinux_media_context_path'
label_file.lo: In function `_init':
label_file.c:(.text+0xa24): undefined reference to `_selinux_file_context_subs_dist_path'
label_file.c:(.text+0xa38): undefined reference to `_selinux_file_context_subs_path'
label_file.c:(.text+0xa4c): undefined reference to `_selinux_file_context_path'
label.lo: In function `_selabel_lookup_common':
label.c:(.text+0x172): undefined reference to `_selinux_raw_to_trans_context'
label_db.lo: In function `_selabel_db_init':
label_db.c:(.text+0xe4): undefined reference to `_selinux_sepgsql_context_path'
sestatus.lo: In function `_selinux_status_open':
sestatus.c:(.text+0x17e): undefined reference to `_security_getenforce'
sestatus.lo: In function `_selinux_status_deny_unknown':
sestatus.c:(.text+0x214): undefined reference to `_security_deny_unknown'
label_x.lo: In function `_selabel_x_init':
label_x.c:(.text+0xee): undefined reference to `_selinux_x_context_path'
collect2: ld returned 1 exit status
Makefile:119: recipe for target 'libselinux.so.1' failed
make[2]: *** [libselinux.so.1] Error 1

This is due to the fact that Blackfin has a special handling of symbols: a symbol called foo in C is called _foo in assembly. This apparently defeats the hidden_ref and hidden_proto logic in dso.h, which doesn't have explicit support for the Blackfin architecture. I tried a bit to change the assembly code to cope with the Blackfin specificities, but didn't manage to get something working. So far, the only solution I found is to simply not use this logic to hide symbols:

diff --git a/libselinux/src/dso.h b/libselinux/src/dso.h
index 12c3d11..f21d088 100644
--- a/libselinux/src/dso.h
+++ b/libselinux/src/dso.h
@@ -1,7 +1,7 @@
 #ifndef _SELINUX_DSO_H
 #define _SELINUX_DSO_H 1

-#ifdef SHARED
+#if defined(SHARED) && !defined(__bfin__)
 # define hidden __attribute__ ((visibility ("hidden")))
 # define hidden_proto(fct) __hidden_proto (fct, fct##_internal)
 # define __hidden_proto(fct, internal) \

But a real solution would be more appropriate.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions