Menu

ELF hidden attribute?

dbely
2009-08-04
2013-04-20
  • dbely

    dbely - 2009-08-04

    Is it possible to achieve with jwasm the same effect as with gcc's -fvisibility=hidden option or __attribute__ ((visibility("hidden")))? I'd like to export no public symbol across .so boundary by default.

     
    • dbely

      dbely - 2009-08-04

      OK, answering to my own question: Elf32_Sym::st_other field where visibility info should reside:

      typedef struct
      {
        Elf32_Word    st_name;                /* Symbol name (string tbl index) */
        Elf32_Addr    st_value;               /* Symbol value */
        Elf32_Word    st_size;                /* Symbol size */
        unsigned char st_info;                /* Symbol type and binding */
        unsigned char st_other;               /* Symbol visibility */
        Elf32_Section st_shndx;               /* Section index */
      } Elf32_Sym;
      (...)
      /* How to extract and insert information held in the st_other field.  */

      #define ELF32_ST_VISIBILITY(o)  ((o) & 0x03)

      /* For ELF64 the definitions are the same.  */
      #define ELF64_ST_VISIBILITY(o)  ELF32_ST_VISIBILITY (o)

      /* Symbol visibility specification encoded in the st_other field.  */
      #define STV_DEFAULT     0               /* Default symbol visibility rules */
      #define STV_INTERNAL    1               /* Processor specific hidden class */
      #define STV_HIDDEN      2               /* Sym unavailable in other modules */
      #define STV_PROTECTED   3               /* Not preemptible, not exported */

      is not used by jwasm 1.95 at all; so this question becomes a feature request :) It could be easy enough to implement except the syntax which is not obvious (to me).

       

Log in to post a comment.