]> Cypherpunks repositories - gostls13.git/commitdiff
add a .interp section and fix vaddr in INTERP prog.
authorRob Pike <r@golang.org>
Tue, 21 Jul 2009 23:31:35 +0000 (16:31 -0700)
committerRob Pike <r@golang.org>
Tue, 21 Jul 2009 23:31:35 +0000 (16:31 -0700)
R=rsc
DELTA=16  (9 added, 3 deleted, 4 changed)
OCL=31956
CL=31963

src/cmd/6l/asm.c

index 850077b80c98d05757f409efa4c44f100880dbdb..854049cce197bbd79354eeae1a8eafd8b52e6665 100644 (file)
@@ -450,12 +450,21 @@ asmb(void)
                        ph->type = PT_INTERP;
                        ph->flags = PF_R;
                        ph->off = startelf();
-                       ph->vaddr = startva;
-                       ph->paddr = startva;
+                       ph->vaddr = startva + ph->off;
+                       ph->paddr = startva + ph->off;
                        write(cout, linuxdynld, sizeof linuxdynld);
                        ph->filesz = endelf() - ph->off;
                        ph->align = 1;
 
+                       sh = newElf64SHdr(".interp");
+                       sh->type = SHT_PROGBITS;
+                       sh->flags = SHF_ALLOC;
+                       sh->addr = va;
+                       sh->off = ph->off;
+                       sh->addr = startva + sh->off;
+                       sh->size = ph->filesz;
+                       sh->addralign = 1;
+
                        /* dynamic load section */
                        ph = newElf64PHdr();
                        ph->type = PT_LOAD;
@@ -521,9 +530,6 @@ asmb(void)
                        elf64writedynent(DT_RELAENT, ELF64RELASIZE);
                        elf64writedynent(DT_STRSZ, STRTABSIZE);
                        elf64writedynent(DT_SYMENT, 0);
-                       elf64writedynent(DT_REL, startva);
-                       elf64writedynent(DT_RELSZ, 0);
-                       elf64writedynent(DT_RELENT, ELF64RELSIZE);
                        elf64writedynent(DT_NULL, 0);
                        cflush();
                        dynsh->size = seek(cout, 0, 1) - dynsh->off;
@@ -578,8 +584,8 @@ asmb(void)
                }
 
                ph = newElf64PHdr();
-               ph->type = 0x6474e551;  /* gok */
-               ph->flags = PF_X+PF_W+PF_R;
+               ph->type = 0x6474e551;  /* GNU_STACK */
+               ph->flags = PF_W+PF_R;
                ph->align = 8;
 
                fo = ELF64RESERVE;