]> Cypherpunks repositories - gostls13.git/commitdiff
6l, 8l: emit windows dwarf sections similar to other platforms
authorAlex Brainman <alex.brainman@gmail.com>
Fri, 13 May 2011 06:05:47 +0000 (16:05 +1000)
committerAlex Brainman <alex.brainman@gmail.com>
Fri, 13 May 2011 06:05:47 +0000 (16:05 +1000)
R=golang-dev, rsc
CC=golang-dev, vcc.163
https://golang.org/cl/4517056

src/cmd/6l/asm.c
src/cmd/8l/asm.c
src/cmd/ld/dwarf.c
src/cmd/ld/pe.c

index dda19e48d028318ce844ffbb38cecce4d82ea75b..9aeef3c4d83562c2559eb50524a607991d598870 100644 (file)
@@ -787,40 +787,50 @@ asmb(void)
                        symo = rnd(symo, PEFILEALIGN);
                        break;
                }
-               /*
-                * the symbol information is stored as
-                *      32-bit symbol table size
-                *      32-bit line number table size
-                *      symbol table
-                *      line number table
-                */
-               seek(cout, symo+8, 0);
-               if(debug['v'])
-                       Bprint(&bso, "%5.2f sp\n", cputime());
-               Bflush(&bso);
-               if(debug['v'])
-                       Bprint(&bso, "%5.2f pc\n", cputime());
-               Bflush(&bso);
-               if(!debug['s'])
-                       strnput("", INITRND-(8+symsize+lcsize)%INITRND);
-               cflush();
-               seek(cout, symo, 0);
-               lputl(symsize);
-               lputl(lcsize);
-               cflush();
-               if(HEADTYPE != Hwindows && !debug['s']) {
-                       elfsymo = symo+8+symsize+lcsize;
-                       seek(cout, elfsymo, 0);
-                       asmelfsym64();
-                       cflush();
-                       elfstro = seek(cout, 0, 1);
-                       elfsymsize = elfstro - elfsymo;
-                       ewrite(cout, elfstrdat, elfstrsize);
-
+               switch(HEADTYPE) {
+               default:
+                       if(iself) {
+                               /*
+                                * the symbol information is stored as
+                                *      32-bit symbol table size
+                                *      32-bit line number table size
+                                *      symbol table
+                                *      line number table
+                                */
+                               seek(cout, symo+8, 0);
+                               if(debug['v'])
+                                       Bprint(&bso, "%5.2f sp\n", cputime());
+                               Bflush(&bso);
+                               if(debug['v'])
+                                       Bprint(&bso, "%5.2f pc\n", cputime());
+                               Bflush(&bso);
+                               if(!debug['s'])
+                                       strnput("", INITRND-(8+symsize+lcsize)%INITRND);
+                               cflush();
+                               seek(cout, symo, 0);
+                               lputl(symsize);
+                               lputl(lcsize);
+                               cflush();
+                               elfsymo = symo+8+symsize+lcsize;
+                               seek(cout, elfsymo, 0);
+                               asmelfsym64();
+                               cflush();
+                               elfstro = seek(cout, 0, 1);
+                               elfsymsize = elfstro - elfsymo;
+                               ewrite(cout, elfstrdat, elfstrsize);
+
+                               if(debug['v'])
+                                      Bprint(&bso, "%5.2f dwarf\n", cputime());
+
+                               dwarfemitdebugsections();
+                       }
+                       break;
+               case Hwindows:
                        if(debug['v'])
                               Bprint(&bso, "%5.2f dwarf\n", cputime());
 
                        dwarfemitdebugsections();
+                       break;
                }
        }
 
index 1e973c180aabed720d0847ccc7339619fdeb3129..535d8bdd382b5467ec78bee213d2feca6421f0e4 100644 (file)
@@ -742,12 +742,29 @@ asmb(void)
                        symo = rnd(symo, INITRND);
                        break;
                case Hwindows:
-                       // TODO(brainman): not sure what symo meant to be, but it is not used for Windows PE for now anyway
                        symo = rnd(HEADR+segtext.filelen, PEFILEALIGN)+segdata.filelen;
                        symo = rnd(symo, PEFILEALIGN);
                        break;
                }
-               if(HEADTYPE == Hplan9x32) {
+               switch(HEADTYPE) {
+               default:
+                       if(iself) {
+                               if(debug['v'])
+                                      Bprint(&bso, "%5.2f elfsym\n", cputime());
+                               elfsymo = symo+8+symsize+lcsize;
+                               seek(cout, elfsymo, 0);
+                               asmelfsym32();
+                               cflush();
+                               elfstro = seek(cout, 0, 1);
+                               elfsymsize = elfstro - elfsymo;
+                               ewrite(cout, elfstrdat, elfstrsize);
+
+                               if(debug['v'])
+                                       Bprint(&bso, "%5.2f dwarf\n", cputime());
+                               dwarfemitdebugsections();
+                       }
+                       break;
+               case Hplan9x32:
                        seek(cout, symo, 0);
                        asmplan9sym();
                        cflush();
@@ -760,20 +777,13 @@ asmb(void)
                                
                                cflush();
                        }
-               } else if(iself) {
-                       if(debug['v'])
-                              Bprint(&bso, "%5.2f elfsym\n", cputime());
-                       elfsymo = symo+8+symsize+lcsize;
-                       seek(cout, elfsymo, 0);
-                       asmelfsym32();
-                       cflush();
-                       elfstro = seek(cout, 0, 1);
-                       elfsymsize = elfstro - elfsymo;
-                       ewrite(cout, elfstrdat, elfstrsize);
-
+                       break;
+               case Hwindows:
+                       seek(cout, symo, 0);
                        if(debug['v'])
                                Bprint(&bso, "%5.2f dwarf\n", cputime());
                        dwarfemitdebugsections();
+                       break;
                }
        }
        if(debug['v'])
index 98b068008b6821c98daab8deaed77fa524f2402d..ed11f5e5acf3acfafafdb3dd8069bf49ffd6d2b0 100644 (file)
@@ -2562,7 +2562,6 @@ dwarfaddmachoheaders(void)
 void
 dwarfaddpeheaders(void)
 {
-       dwarfemitdebugsections();
        newPEDWARFSection(".debug_abbrev", abbrevsize);
        newPEDWARFSection(".debug_line", linesize);
        newPEDWARFSection(".debug_frame", framesize);
index d523ca9c5ba864a6b826e1247f511d7b0676c0c5..1c0c6653832b16c6b5b1d0b45ef9989dc049349a 100644 (file)
@@ -484,13 +484,13 @@ asmbpe(void)
        d->Characteristics = IMAGE_SCN_CNT_INITIALIZED_DATA|
                IMAGE_SCN_MEM_READ|IMAGE_SCN_MEM_WRITE;
 
+       if(!debug['s'])
+               dwarfaddpeheaders();
+
        addimports(nextfileoff, d);
        
        addexports(nextfileoff);
        
-       if(!debug['s'])
-               dwarfaddpeheaders();
-
        addsymtable();
                
        fh.NumberOfSections = nsect;