[PATCH] D45737: COFF: Merge .idata, .didat and .edata into .rdata by default.

Zachary Turner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 17 14:38:15 PDT 2018


zturner added inline comments.


================
Comment at: lld/test/COFF/pdb-publics-import.test:39
     .rdata debug directory data chunks
-CHECK-NEXT:   SC[.rdata]  | mod = 1, 0002:0000, size = 28, data crc = 0, reloc crc = 0
+CHECK-NEXT:   SC[???]     | mod = 1, 0002:0000, size = 28, data crc = 0, reloc crc = 0
 CHECK-NEXT:                 IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ
----------------
pcc wrote:
> pcc wrote:
> > This is the only weird thing in the test updates.
> > 
> > @zturner I'm not sure if this is a pre-existing problem with our pdb emission?
> Actually looks like it was an off-by-one error in llvm-pdbutil -- fix incoming
I don't know if this is a pre-existing problem, it may be due to the patch.  

Short version: can you run `llvm-pdbutil dump -section-headers` on the new PDB?  My guess is that you will see less than 2 sections here.  At the very least, comparing the output of the tool with this option before and after your patch should provide a clue.

Long version: The printing code here is using the section index (the `2` from `0002:0000`) as an index into a list of section names.

It generates this list of section names by looking in the "optional debug stream array" in the DBI stream of the PDB.  Essentially this is an array of stream indices, where each array index has a special hardcoded meaning.  One of these (at index `DbgHeaderType::SectionHdr`, whose value is I think 5) represents the index of a stream which contains a list of section headers.

So the printing code looks at index 5 in this array, loads the specified stream, gets the list of section header, and then reads the second one.

If there are less than 2 though, it will print `???` for the section name.

So my suspicion is that something about this patch is causing only 1 entry to be written here instead of 2.

In LLD, this is set on this line:

```
  // Add COFF section header stream.
  ExitOnErr(
      DbiBuilder.addDbgStream(pdb::DbgHeaderType::SectionHdr, SectionTable));
```

So check there and see that `SectionTable` contains the proper list of sections.


https://reviews.llvm.org/D45737





More information about the llvm-commits mailing list