X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?p=pintos-anon;a=blobdiff_plain;f=specs%2Fsysv-abi-update.html%2Fch4.symtab.html;fp=specs%2Fsysv-abi-update.html%2Fch4.symtab.html;h=c1031c706f6ceaf6bca7d26084a6ae6f8084cafd;hp=0000000000000000000000000000000000000000;hb=8af06d1fd50343e17229618ef4d2693193b2b3d9;hpb=d0d14ca50fbac167253e1e1d8d806bfd749a5e8a diff --git a/specs/sysv-abi-update.html/ch4.symtab.html b/specs/sysv-abi-update.html/ch4.symtab.html new file mode 100644 index 0000000..c1031c7 --- /dev/null +++ b/specs/sysv-abi-update.html/ch4.symtab.html @@ -0,0 +1,592 @@ + +
+
+An object file's symbol table holds information +needed to locate and relocate a program's symbolic +definitions and references. +A symbol table index is a subscript into this array. +Index 0 both designates the first entry in the table +and serves as the undefined symbol index. The contents of the +initial entry are specified later in this section. +
+
Name | +Value | +
---|---|
STN_UNDEF |
+0 |
+
+A symbol table entry has the following format. +
+
+
+typedef struct {
+ Elf32_Word st_name;
+ Elf32_Addr st_value;
+ Elf32_Word st_size;
+ unsigned char st_info;
+ unsigned char st_other;
+ Elf32_Half st_shndx;
+} Elf32_Sym;
+
+typedef struct {
+ Elf64_Word st_name;
+ unsigned char st_info;
+ unsigned char st_other;
+ Elf64_Half st_shndx;
+ Elf64_Addr st_value;
+ Elf64_Xword st_size;
+} Elf64_Sym;
+
+
++
st_name
+
st_value
st_size
st_info
+ #define ELF32_ST_BIND(i) ((i)>>4) + #define ELF32_ST_TYPE(i) ((i)&0xf) + #define ELF32_ST_INFO(b,t) (((b)<<4)+((t)&0xf)) + + #define ELF64_ST_BIND(i) ((i)>>4) + #define ELF64_ST_TYPE(i) ((i)&0xf) + #define ELF64_ST_INFO(b,t) (((b)<<4)+((t)&0xf)) ++
st_other
+ #define ELF32_ST_VISIBILITY(o) ((o)&0x3) + #define ELF64_ST_VISIBILITY(o) ((o)&0x3) ++
st_shndx
sh_link
and sh_info
interpretation
+table
+and the related text describe,
+some section indexes indicate special meanings.
+
+If this member contains SHN_XINDEX
,
+then the actual section header index is too large to fit in this field.
+The actual value is contained in the associated
+section of type SHT_SYMTAB_SHNDX
.
+
+A symbol's binding determines the linkage visibility +and behavior. +
+
Name | +Value | +
---|---|
STB_LOCAL |
+0 |
+
STB_GLOBAL |
+1 |
+
STB_WEAK |
+2 |
+
STB_LOOS |
+10 |
+
STB_HIOS |
+12 |
+
STB_LOPROC |
+13 |
+
STB_HIPROC |
+15 |
+
STB_LOCAL
STB_GLOBAL
STB_WEAK
STB_LOOS
through STB_HIOS
STB_LOPROC
through STB_HIPROC
+Global and weak symbols differ in two major ways. +
STB_GLOBAL
+symbols with the same name.
+On the other hand, if a defined global symbol exists,
+the appearance of a weak symbol with the same name
+will not cause an error.
+The link editor honors the global definition and ignores
+the weak ones.
+Similarly, if a common symbol exists
+(that is, a symbol whose st_shndx
+field holds SHN_COMMON
),
+the appearance of a weak symbol with the same name will
+not cause an error.
+The link editor honors the common definition and
+ignores the weak ones.
+
+In each symbol table, all symbols with STB_LOCAL
+binding precede the weak and global symbols.
+As
+``Sections'',
+above describes,
+a symbol table section's sh_info
+section header member holds the symbol table index
+for the first non-local symbol.
+
+A symbol's type provides a general classification for +the associated entity. +
+
Name | +Value | +
---|---|
STT_NOTYPE |
+0 |
+
STT_OBJECT |
+1 |
+
STT_FUNC |
+2 |
+
STT_SECTION |
+3 |
+
STT_FILE |
+4 |
+
STT_COMMON |
+5 |
+
STT_TLS |
+6 |
+
STT_LOOS |
+10 |
+
STT_HIOS |
+12 |
+
STT_LOPROC |
+13 |
+
STT_HIPROC |
+15 |
+
+
STT_NOTYPE
STT_OBJECT
STT_FUNC
STT_SECTION
STB_LOCAL
binding.
+STT_FILE
STB_LOCAL
+binding, its section index is SHN_ABS
,
+and it precedes the other STB_LOCAL
+symbols for the file, if it is present.
+STT_COMMON
STT_TLS
STT_TLS
can be referenced
+by only special thread-local storage relocations
+and thread-local storage relocations can only reference
+symbols with type STT_TLS
.
+Implementation need not support thread-local storage.
+STT_LOOS
through STT_HIOS
STT_LOPROC
through STT_HIPROC
+Function symbols (those with type
+STT_FUNC
) in shared object files have special significance.
+When another object file references a function from
+a shared object, the link editor automatically creates a procedure
+linkage table entry for the referenced symbol.
+Shared object symbols with types other than
+STT_FUNC
will not
+be referenced automatically through the procedure linkage table.
+
+
+Symbols with type STT_COMMON
label uninitialized
+common blocks. In relocatable objects, these symbols are
+not allocated and must have the special section index
+SHN_COMMON
(see below).
+In shared objects and executables these symbols must be
+allocated to some section in the defining object.
+
+In relocatable objects, symbols with type STT_COMMON
+are treated just as other symbols with index SHN_COMMON
.
+If the link-editor allocates space for the SHN_COMMON
+symbol in an output section of the object it is producing, it
+must preserve the type of the output symbol as STT_COMMON
.
+
+When the dynamic linker encounters a reference to a symbol
+that resolves to a definition of type STT_COMMON
,
+it may (but is not required to) change its symbol resolution
+rules as follows: instead of binding the reference to
+the first symbol found with the given name, the dynamic linker searches
+for the first symbol with that name with type other
+than STT_COMMON
. If no such symbol is found,
+it looks for the STT_COMMON
definition of that
+name that has the largest size.
+
+
+A symbol's visibility, although it may be specified in a relocatable +object, defines how that symbol may be accessed once it has +become part of an executable or shared object. +
+
Name | +Value | +
---|---|
STV_DEFAULT |
+0 |
+
STV_INTERNAL |
+1 |
+
STV_HIDDEN |
+2 |
+
STV_PROTECTED |
+3 |
+
+
STV_DEFAULT
STV_DEFAULT
+attribute is as specified by the symbol's binding type.
+That is, global and weak symbols are visible
+outside of their defining component
+(executable file or shared object).
+Local symbols are hidden, as described below.
+Global and weak symbols are also preemptable,
+that is, they may by preempted by definitions of the same
+name in another component.
++
STV_PROTECTED
STB_LOCAL
binding may not have
+STV_PROTECTED
visibility.
+
+If a symbol definition with STV_PROTECTED
visibility
+from a shared object is taken as resolving a reference
+from an executable or another shared object,
+the SHN_UNDEF
symbol table entry created
+has STV_DEFAULT
visibility.
+STV_PROTECTED
flag on a symbol
+in a given load module does not affect the symbol resolution
+rules for references to that symbol from outside the containing
+load module.
++
STV_HIDDEN
+A hidden symbol contained in a relocatable object must be
+either removed or converted to STB_LOCAL
binding
+by the link-editor when the relocatable object is included in an
+executable file or shared object.
+
STV_INTERNAL
+An internal symbol contained in a relocatable object must be
+either removed or converted to STB_LOCAL
binding
+by the link-editor when the relocatable object is included in an
+executable file or shared object.
+
+None of the visibility attributes affects resolution of symbols +within an executable or shared object during link-editing -- such +resolution is controlled by the binding type. Once the link-editor +has chosen its resolution, these attributes impose two requirements, +both based on the fact that references in the code being linked may +have been optimized to take advantage of the attributes. +
STB_WEAK
binding and is resolved to zero.
+STV_PROTECTED
,
+STV_HIDDEN
and STV_INTERNAL
.
+
+If a symbol's value refers to a
+specific location within a section,
+its section index member, st_shndx
,
+holds an index into the section header table.
+As the section moves during relocation, the symbol's value
+changes as well, and references to the symbol
+continue to ``point'' to the same location in the program.
+Some special section index values give other semantics.
+
SHN_ABS
SHN_COMMON
sh_addralign
member.
+The link editor will allocate the storage for the symbol
+at an address that is a multiple of
+st_value
.
+The symbol's size tells how many bytes are required.
+Symbols with section index SHN_COMMON
may
+appear only in relocatable objects.
+SHN_UNDEF
SHN_XINDEX
SHT_SYMTAB_SHNDX
section.
+The entries in that section correspond one to one
+with the entries in the symbol table.
+Only those entries in SHT_SYMTAB_SHNDX
+that correspond to symbol table entries with SHN_XINDEX
+will hold valid section header indexes;
+all other entries will have value 0
.
+
+The symbol table entry for index 0 (STN_UNDEF
)
+is reserved; it holds the following.
+
+
Name | +Value | +Note | +
---|---|---|
st_name |
+0 |
+No name | +
st_value |
+0 |
+Zero value | +
st_size |
+0 |
+No size | +
st_info |
+0 |
+No type, local binding | +
st_other |
+0 |
+Default visibility | +
st_shndx |
+SHN_UNDEF |
+No section | +
st_value
member.
+st_value
holds alignment constraints for a symbol
+whose section index is SHN_COMMON
.
+st_value
holds
+a section offset for a defined symbol.
+st_value
is an offset from the beginning of the section that
+st_shndx
identifies.
+st_value
holds a virtual address.
+To make these files' symbols more useful
+for the dynamic linker, the section offset (file interpretation)
+gives way to a virtual address (memory interpretation)
+for which the section number is irrelevant.
+