• Austin Clements's avatar
    cmd/compile: separate data and function LSyms · a2e79571
    Austin Clements authored
    Currently, obj.Ctxt's symbol table does not distinguish between ABI0
    and ABIInternal symbols. This is *almost* okay, since a given symbol
    name in the final object file is only going to belong to one ABI or
    the other, but it requires that the compiler mark a Sym as being a
    function symbol before it retrieves its LSym. If it retrieves the LSym
    first, that LSym will be created as ABI0, and later marking the Sym as
    a function symbol won't change the LSym's ABI.
    
    Marking a Sym as a function symbol before looking up its LSym sounds
    easy, except Syms have a dual purpose: they are used just as interned
    strings (every function, variable, parameter, etc with the same
    textual name shares a Sym), and *also* to store state for whatever
    package global has that name. As a result, it's easy to slip up and
    look up an LSym when a Sym is serving as the name of a local variable,
    and then later mark it as a function when it's serving as the global
    with the name.
    
    In general, we were careful to avoid this, but #29610 demonstrates one
    case where we messed up. Because of on-demand importing from indexed
    export data, it's possible to compile a method wrapper for a type
    imported from another package before importing an init function from
    that package. If the argument of the method is named "init", the
    "init" LSym will be created as a data symbol when compiling the
    wrapper, before it gets marked as a function symbol.
    
    To fix this, we separate obj.Ctxt's symbol tables for ABI0 and
    ABIInternal symbols. This way, the compiler will simply get a
    different LSym once the Sym takes on its package-global meaning as a
    function.
    
    This fixes the above ordering issue, and means we no longer need to go
    out of our way to create the "init" function early and mark it as a
    function symbol.
    
    Fixes #29610.
    Updates #27539.
    
    Change-Id: Id9458b40017893d46ef9e4a3f9b47fc49e1ce8df
    Reviewed-on: https://go-review.googlesource.com/c/157017
    Run-TryBot: Austin Clements <austin@google.com>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    Reviewed-by: 's avatarRobert Griesemer <gri@golang.org>
    a2e79571
Name
Last commit
Last update
..
builtin Loading commit data...
testdata Loading commit data...
alg.go Loading commit data...
align.go Loading commit data...
bexport.go Loading commit data...
bimport.go Loading commit data...
bitset.go Loading commit data...
bootstrap.go Loading commit data...
builtin.go Loading commit data...
builtin_test.go Loading commit data...
bv.go Loading commit data...
class_string.go Loading commit data...
closure.go Loading commit data...
const.go Loading commit data...
constFold_test.go Loading commit data...
dcl.go Loading commit data...
dump.go Loading commit data...
dwinl.go Loading commit data...
esc.go Loading commit data...
export.go Loading commit data...
fixedbugs_test.go Loading commit data...
float_test.go Loading commit data...
fmt.go Loading commit data...
gen.go Loading commit data...
global_test.go Loading commit data...
go.go Loading commit data...
gsubr.go Loading commit data...
iexport.go Loading commit data...
iface_test.go Loading commit data...
iimport.go Loading commit data...
init.go Loading commit data...
inl.go Loading commit data...
inl_test.go Loading commit data...
lang_test.go Loading commit data...
lex.go Loading commit data...
lex_test.go Loading commit data...
logic_test.go Loading commit data...
main.go Loading commit data...
mapfile_mmap.go Loading commit data...
mapfile_read.go Loading commit data...
mkbuiltin.go Loading commit data...
mpfloat.go Loading commit data...
mpint.go Loading commit data...
noder.go Loading commit data...
norace.go Loading commit data...
obj.go Loading commit data...
op_string.go Loading commit data...
order.go Loading commit data...
pgen.go Loading commit data...
pgen_test.go Loading commit data...
phi.go Loading commit data...
plive.go Loading commit data...
pprof.go Loading commit data...
race.go Loading commit data...
racewalk.go Loading commit data...
range.go Loading commit data...
reflect.go Loading commit data...
reproduciblebuilds_test.go Loading commit data...
scope.go Loading commit data...
scope_test.go Loading commit data...
select.go Loading commit data...
shift_test.go Loading commit data...
sinit.go Loading commit data...
sizeof_test.go Loading commit data...
ssa.go Loading commit data...
ssa_test.go Loading commit data...
subr.go Loading commit data...
swt.go Loading commit data...
swt_test.go Loading commit data...
syntax.go Loading commit data...
timings.go Loading commit data...
trace.go Loading commit data...
truncconst_test.go Loading commit data...
typecheck.go Loading commit data...
types.go Loading commit data...
types_acc.go Loading commit data...
universe.go Loading commit data...
unsafe.go Loading commit data...
util.go Loading commit data...
walk.go Loading commit data...