All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ken YANG <spng.yang@gmail.com>
To: SELinux List <selinux@tycho.nsa.gov>
Subject: puzzles about hidden_def and hidden_proto
Date: Wed, 26 Sep 2007 18:36:12 +0800	[thread overview]
Message-ID: <46FA361C.8080008@gmail.com> (raw)

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=GB18030, Size: 1695 bytes --]


hi all,

i have three puzzles about the macro "hidden_def"
and "hidden_proto" in "libsepol/src/dso.h".

i copy the definitions of these two macros into
a separate header file to test these two macros,
and assembly them:

$ cat hidden_def.h

int extern_i=12345;
#define hidden __attribute__ ((visibility("hidden")))
#define hidden_proto(fct) __hidden_proto (fct, fct##_internal)
#define __hidden_proto(fct, internal)   \
        extern __typeof(fct) internal;  \
        extern __typeof(fct) fct __asm (#internal) hidden;
#define hidden_def(fct) \
        asm (".globl " #fct "\n.set " #fct ", " #fct "_internal");

$ cat hidden_def.c

#include "hidden_def.h"
int main()
{
        hidden_proto(extern_i);
}

$ gcc -S hidden_def.c -o hidden_proto.s
hidden_def.c: In function ¡®main¡¯:
hidden_def.c:17: warning: asm declaration ignored due to conflict with
previous rename

as a result, there aren't #APP(#NO_APP) section in ".s" file

Questions:

(1)
i don't know why i got these assembly warning?

(2)
i find in the gas manual:

.set SYMBOL, EXPRESSION

if SYMBOL are flagged as external, it remains flagged

how can "fct" be hidden, because it has been declared as globl.

(3)
what is the difference between hidden_def and gcc hidden
visibility attribute? why libsepol use both of them?


i know these problems are not selinux-specific, but i have
googled for a long time, i don't know where i can get guides
about these kinds of problems. can anyone give me some hints?






--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

             reply	other threads:[~2007-09-26 10:40 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-26 10:36 Ken YANG [this message]
2007-09-26 14:06 ` puzzles about hidden_def and hidden_proto Stephen Smalley
  -- strict thread matches above, loose matches on Subject: below --
2007-10-05 16:06 Ken

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=46FA361C.8080008@gmail.com \
    --to=spng.yang@gmail.com \
    --cc=selinux@tycho.nsa.gov \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.