34 lines
1.3 KiB
Go
34 lines
1.3 KiB
Go
package obj
|
|
|
|
import "strings"
|
|
|
|
// contentHashSection returns a mnemonic for s's section.
|
|
// The goal is to prevent content-addressability from moving symbols between sections.
|
|
// contentHashSection only distinguishes between sets of sections for which this matters.
|
|
// Allowing flexibility increases the effectiveness of content-addressability.
|
|
// But in some cases, such as doing addressing based on a base symbol,
|
|
// we need to ensure that a symbol is always in a particular section.
|
|
// Some of these conditions are duplicated in cmd/link/internal/ld.(*Link).symtab.
|
|
// TODO: instead of duplicating them, have the compiler decide where symbols go.
|
|
func contentHashSection(s *LSym) byte {
|
|
name := s.Name
|
|
if s.IsPcdata() {
|
|
return 'P'
|
|
}
|
|
if strings.HasPrefix(name, "gcargs.") ||
|
|
strings.HasPrefix(name, "gclocals.") ||
|
|
strings.HasPrefix(name, "gclocals·") ||
|
|
strings.HasSuffix(name, ".opendefer") ||
|
|
strings.HasSuffix(name, ".arginfo0") ||
|
|
strings.HasSuffix(name, ".arginfo1") ||
|
|
strings.HasSuffix(name, ".argliveinfo") ||
|
|
strings.HasSuffix(name, ".wrapinfo") ||
|
|
strings.HasSuffix(name, ".args_stackmap") ||
|
|
strings.HasSuffix(name, ".stkobj") {
|
|
return 'F' // go:func.* or go:funcrel.*
|
|
}
|
|
if strings.HasPrefix(name, "type:") {
|
|
return 'T'
|
|
}
|
|
return 0
|
|
}
|