]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/ld: make .rela and .rela.plt sections contiguous
authorAram Hăvărneanu <aram@mgk.ro>
Mon, 30 Mar 2015 13:45:33 +0000 (15:45 +0200)
committerAram Hăvărneanu <aram@mgk.ro>
Wed, 6 May 2015 11:37:13 +0000 (11:37 +0000)
ELF normally requires this and Solaris runtime loader will crash if we
don't do it.

Fixes Solaris build.

Change-Id: I0482eed890aff2d346136ae7f9caf8f094f502ed
Reviewed-on: https://go-review.googlesource.com/8216
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/cmd/internal/ld/data.go

index 4650db035832b45637caaf8269dd85e566cdc1d2..3194bd568ed3df4e0062f79b3024798b7d8464ef 100644 (file)
@@ -1267,6 +1267,27 @@ func dodata() {
 
        datap = listsort(datap, datcmp, listnextp)
 
+       if Iself {
+               // Make .rela and .rela.plt contiguous, the ELF ABI requires this
+               // and Solaris actually cares.
+               var relplt *LSym
+               for l = &datap; *l != nil; l = &(*l).Next {
+                       if (*l).Name == ".rel.plt" || (*l).Name == ".rela.plt" {
+                               relplt = (*l)
+                               *l = (*l).Next
+                               break
+                       }
+               }
+               if relplt != nil {
+                       for s = datap; s != nil; s = s.Next {
+                               if s.Name == ".rel" || s.Name == ".rela" {
+                                       relplt.Next = s.Next
+                                       s.Next = relplt
+                               }
+                       }
+               }
+       }
+
        /*
         * allocate sections.  list is sorted by type,
         * so we can just walk it for each piece we want to emit.