return s.Value
}
-func undefsym(ctxt *Link, s *sym.Symbol) {
- var r *sym.Reloc
-
- for i := 0; i < len(s.R); i++ {
- r = &s.R[i]
- if r.Sym == nil { // happens for some external ARM relocs
- continue
- }
- // TODO(mwhudson): the test of VisibilityHidden here probably doesn't make
- // sense and should be removed when someone has thought about it properly.
- if (r.Sym.Type == sym.Sxxx || r.Sym.Type == sym.SXREF) && !r.Sym.Attr.VisibilityHidden() {
- Errorf(s, "undefined: %q", r.Sym.Name)
- }
- if !r.Sym.Attr.Reachable() && r.Type != objabi.R_WEAKADDROFF {
- Errorf(s, "relocation target %q", r.Sym.Name)
- }
- }
-}
-
-func (ctxt *Link) undef() {
- // undefsym performs checks (almost) identical to checks
- // that report undefined relocations in relocsym.
- // Both undefsym and relocsym can report same symbol as undefined,
- // which results in error message duplication (see #10978).
- //
- // The undef is run after Arch.Asmb and could detect some
- // programming errors there, but if object being linked is already
- // failed with errors, it is better to avoid duplicated errors.
- if nerrors > 0 {
- return
- }
-
- for _, s := range ctxt.Textp {
- undefsym(ctxt, s)
- }
- for _, s := range ctxt.datap {
- undefsym(ctxt, s)
- }
- if nerrors > 0 {
- errorexit()
- }
-}
-
func (ctxt *Link) callgraph() {
if !*FlagC {
return