The spec says (note that it calls module scope "global"):
Binding Scope 5.4 Bit(4) Requested binding or resolution-search scope of an external symbol.
B'0000'
Unspecified
B'0001'
Section scope ("local")
B'0010'
Module scope ("global")
B'0011'
Library scope.
B'0100'
Import-Export scope
All other values are reserved.
GoffSymbol::is_global() treats module scope as local:
(Note that there's a separate issue where binding_scope() is reading the wrong nibble.)
|
// If binding scope is section or module symbol is local |
|
let scope = self.behavioral_flags().binding_scope(); |
|
if is_section || is_local_name || scope == GOFF_SCOPE_SECTION || scope == GOFF_SCOPE_MODULE |
|
{ |
|
return false; |
|
} |
write_defined_symbol() uses module scope for SymbolScope::Linkage symbols:
(For ELF, SymbolScope::Linkage means it is global for static linking, but not visible for dynamic linking.)
|
// Determine binding scope based on symbol properties |
|
let scope = if symbol.is_local() { |
|
goff::GOFF_SCOPE_SECTION |
|
} else if symbol.scope == SymbolScope::Dynamic { |
|
goff::GOFF_SCOPE_IMPORT_EXPORT |
|
} else { |
|
goff::GOFF_SCOPE_MODULE |
|
}; |
LLVM reads module scope as local (does not set SF_GLOBAL):
https://github.com/llvm/llvm-project/blob/3306ae1c98d695d7d111bd8037380c7d09e818b6/llvm/lib/Object/GOFFObjectFile.cpp#L446-L458
LLVM writes library scope or import-export scope for globals, otherwise section scope (never module scope):
https://github.com/llvm/llvm-project/blob/3306ae1c98d695d7d111bd8037380c7d09e818b6/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp#L2910-L2914
@dalvescb Which ones need changing? Based on the LLVM behaviour we probably should switch write_defined_symbol() to library scope instead of module scope, but I'm a bit confused why the spec says module scope is global but LLVM treats it as local.
The spec says (note that it calls module scope "global"):
GoffSymbol::is_global()treats module scope as local:(Note that there's a separate issue where
binding_scope()is reading the wrong nibble.)object/src/read/goff/symbol.rs
Lines 285 to 290 in dce50f0
write_defined_symbol()uses module scope forSymbolScope::Linkagesymbols:(For ELF,
SymbolScope::Linkagemeans it is global for static linking, but not visible for dynamic linking.)object/src/write/goff.rs
Lines 716 to 723 in dce50f0
LLVM reads module scope as local (does not set SF_GLOBAL):
https://github.com/llvm/llvm-project/blob/3306ae1c98d695d7d111bd8037380c7d09e818b6/llvm/lib/Object/GOFFObjectFile.cpp#L446-L458
LLVM writes library scope or import-export scope for globals, otherwise section scope (never module scope):
https://github.com/llvm/llvm-project/blob/3306ae1c98d695d7d111bd8037380c7d09e818b6/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp#L2910-L2914
@dalvescb Which ones need changing? Based on the LLVM behaviour we probably should switch
write_defined_symbol()to library scope instead of module scope, but I'm a bit confused why the spec says module scope is global but LLVM treats it as local.