{"action":"opened","issue":{"url":"https://api.github.com/repos/dotnet/roslyn/issues/8095","labels_url":"https://api.github.com/repos/dotnet/roslyn/issues/8095/labels{/name}","comments_url":"https://api.github.com/repos/dotnet/roslyn/issues/8095/comments","events_url":"https://api.github.com/repos/dotnet/roslyn/issues/8095/events","html_url":"https://github.com/dotnet/roslyn/issues/8095","id":128064080,"number":8095,"title":"Incorrect section-relative address of methods emitted to native PDBs","user":{"login":"tmat","id":41759,"avatar_url":"https://avatars.githubusercontent.com/u/41759?v=3","gravatar_id":"","url":"https://api.github.com/users/tmat","html_url":"https://github.com/tmat","followers_url":"https://api.github.com/users/tmat/followers","following_url":"https://api.github.com/users/tmat/following{/other_user}","gists_url":"https://api.github.com/users/tmat/gists{/gist_id}","starred_url":"https://api.github.com/users/tmat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tmat/subscriptions","organizations_url":"https://api.github.com/users/tmat/orgs","repos_url":"https://api.github.com/users/tmat/repos","events_url":"https://api.github.com/users/tmat/events{/privacy}","received_events_url":"https://api.github.com/users/tmat/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-01-22T01:54:33Z","updated_at":"2016-01-22T01:54:33Z","closed_at":null,"body":"Currently Roslyn uses ```ISymUnmanagedWriter.OpenMethod(token)``` to emit debug information for a method definition. This API doesn't write the correct section-relative address into the PDB. \r\n\r\n ```ISymUnmanagedWriter3.OpenMethod2(token, sectionIndex, sectionRelativeAddress)``` should be used, where *sectionIndex* is the index of .text section, since we emit IL to this section. *sectionRelativeAddress* is the offset of the method from the start of the .text section (in other words the RVA of the method - the RVA of the .text section). \r\n\r\nCurrently we are emitting debug information for a method while building metadata tables. Since IL stream follows metadata stream in the .text section and we don't know upfront what the size of the metadata stream is gonna be we don't know the RVA of a method body until we build all metadata tables and heaps. So in order to calculate section relative addresses for methods we need to move PDB writing to the emit phase after the metadata tables and heaps are built, at which point we have all information necessary."}}