]> Cypherpunks repositories - gostls13.git/commitdiff
fix ELF bugs found by iant
authorRuss Cox <rsc@golang.org>
Fri, 26 Sep 2008 17:25:13 +0000 (10:25 -0700)
committerRuss Cox <rsc@golang.org>
Fri, 26 Sep 2008 17:25:13 +0000 (10:25 -0700)
- .text begins at INITTEXT, not 0
   and does not include HEADR
- .shstrtab, .gosymtab, .gopclntab have alignment 1
- .gosymtab, .gopclntab have type SHT_PROGBITS

R=r
DELTA=9  (0 added, 0 deleted, 9 changed)
OCL=15953
CL=15956

src/cmd/6l/asm.c

index 86832286452eabc401aa49bddc9672fe979f2778..66aecad5a98f116c98c33ccea9e955f90afa2392 100644 (file)
@@ -452,7 +452,7 @@ asmb(void)
                        INITRND);               /* alignment */
 
                linuxphdr(0x6474e551,           /* gok - type = gok */
-                       1L+2L+4L,               /* gok - flags = PF_X+PF_R */
+                       1L+2L+4L,               /* gok - flags = PF_X+PF_W+PF_R */
                        0,                      /* file offset */
                        0,                      /* vaddr */
                        0,                      /* paddr */
@@ -472,9 +472,9 @@ asmb(void)
                        0);                     /* entsize */
 
                stroffset = 1;  /* 0 means no name, so start at 1 */
-               fo = 0;
-               va = INITRND;
-               w = HEADR+textsize;
+               fo = HEADR;
+               va = (INITTEXT & ~((vlong)INITRND - 1)) + HEADR;
+               w = textsize;
 
                linuxshdr(".text",              /* name */
                        1,                      /* type */
@@ -527,7 +527,7 @@ asmb(void)
                        w,                      /* size */
                        0,                      /* link */
                        0,                      /* info */
-                       8,                      /* align */
+                       1,                      /* align */
                        0);                     /* entsize */
 
                if (debug['s'])
@@ -537,28 +537,28 @@ asmb(void)
                w = symsize;
 
                linuxshdr(".gosymtab",          /* name */
-                       7,                      /* type */
+                       1,                      /* type 1 = SHT_PROGBITS */
                        0,                      /* flags */
                        0,                      /* addr */
                        fo,                     /* off */
                        w,                      /* size */
                        0,                      /* link */
                        0,                      /* info */
-                       8,                      /* align */
+                       1,                      /* align */
                        24);                    /* entsize */
                
                fo += w;
                w = lcsize;
 
                linuxshdr(".gopclntab",         /* name */
-                       7,                      /* type */
+                       1,                      /* type 1 = SHT_PROGBITS*/
                        0,                      /* flags */
                        0,                      /* addr */
                        fo,                     /* off */
                        w,                      /* size */
                        0,                      /* link */
                        0,                      /* info */
-                       8,                      /* align */
+                       1,                      /* align */
                        24);                    /* entsize */
                break;
        }