All of lore.kernel.org
 help / color / mirror / Atom feed
* puzzles about hidden_def and hidden_proto
@ 2007-09-26 10:36 Ken YANG
  2007-09-26 14:06 ` Stephen Smalley
  0 siblings, 1 reply; 3+ messages in thread
From: Ken YANG @ 2007-09-26 10:36 UTC (permalink / raw)
  To: SELinux List

[-- 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.

^ permalink raw reply	[flat|nested] 3+ messages in thread
* Re: puzzles about hidden_def and hidden_proto
@ 2007-10-05 16:06 Ken
  0 siblings, 0 replies; 3+ messages in thread
From: Ken @ 2007-10-05 16:06 UTC (permalink / raw)
  To: Stephen Smalley; +Cc: selinux

[-- Attachment #1: Type: text/plain, Size: 1303 bytes --]

> They came from Ulrich Drepper.
> See:
> http://people.redhat.com/drepper/dsohowto.pdf <http://people.redhat.com/drepper/dsohowto.pdf>

> They are to create and use private definitions of the symbols for calls
> to them within the shared library to avoid relocations on them, as that
> has a cost and is usually unnecessary (you typically don't need to
> permit interposition on such calls).  You declare them with
> hidden_proto() in a header file (see src/*_internal.h), include those
> headers in the .c files that use those symbols, and put a hidden_def()
> in the .c file after the definition.

hi, Stephen, thanks for your reply

sorry for reply late, i have learned ulrich's paper, and i think i
understand what hidden_* macro means, but there were still two questions,
whick i dont understand:

1
IMHO, the implementation of hidden_proto() is a kind of "symbol rename"
trick, we can continue to refer to the symbol as fct in the source, but
it will be named fct_internal in the asm.

but i don't understand who make the trick happened? GCC?

it's not a grammar of C, i wonder why:

extern __typeof(OLD) OLD asm(NEW)

can rename OLD to NEW?

2
what are the difference between this "rename" trick and gcc "alias"
attribute?

why not use "alias" in hidden_proto()


thans in advance for any hints

[-- Attachment #2: Type: text/html, Size: 1582 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-10-05 16:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-26 10:36 puzzles about hidden_def and hidden_proto Ken YANG
2007-09-26 14:06 ` Stephen Smalley
  -- strict thread matches above, loose matches on Subject: below --
2007-10-05 16:06 Ken

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.