Skip to content

Commit

Permalink
splitSymbols: fast-path for case where there is only one symbol
Browse files Browse the repository at this point in the history
Signed-off-by: Paul Cacheux <paul.cacheux@datadoghq.com>
  • Loading branch information
paulcacheux committed Nov 7, 2023
1 parent 8625e66 commit 4acb87b
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion linker.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,24 @@ func splitSymbols(insns asm.Instructions) (map[string]asm.Instructions, error) {
return nil, errors.New("insns is empty")
}

if insns[0].Symbol() == "" {
firstSymbol := insns[0].Symbol()
if firstSymbol == "" {
return nil, errors.New("insns must start with a Symbol")
}

onlyOneSymbol := true
for _, ins := range insns[1:] {
if ins.Symbol() != "" {
onlyOneSymbol = false
break
}
}
if onlyOneSymbol {
return map[string]asm.Instructions{
firstSymbol: insns,
}, nil
}

var name string
progs := make(map[string]asm.Instructions)
for _, ins := range insns {
Expand Down

0 comments on commit 4acb87b

Please sign in to comment.