This is an archive of the discontinued LLVM Phabricator instance.

Fixing layout of elf-core file related structures
ClosedPublic

Authored by dvlahovski on Jul 21 2016, 7:14 AM.

Details

Summary

The binary layout of prstatus and prpsinfo was wrong.
Some of the member variables where not aligned properly
and others where with a wrong type (e.g. the time related
stuff in prstatus).

I used the structs defined in bfd in binutils to see what the layout
of the elf-core format in these section is.
(https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=bfd/hosts/x86-64linux.h;h=4e420a1f2081dd3b51f5d6b7a8e4093580f5cdb5;hb=master)
Note: those structures are only for x86 64 bit elf-core files

This shouldn't have any impact on the functionality, because
lldb actually uses only a few of the member variables of those structs
and they are with a correct type and alignment.

I found this while trying to add/fix the support for
i386 core files (https://llvm.org/bugs/show_bug.cgi?id=26947)

Diff Detail

Event Timeline

dvlahovski updated this revision to Diff 64883.Jul 21 2016, 7:14 AM
dvlahovski retitled this revision from to Fixing layout of elf-core file related structures.
dvlahovski updated this object.
dvlahovski added a reviewer: labath.
dvlahovski added a subscriber: lldb-commits.
dvlahovski updated this revision to Diff 64902.Jul 21 2016, 8:37 AM

Forgot to add alignas to two members of prstatus

labath edited edge metadata.Jul 22 2016, 1:52 AM

Looks good, just please fix the small stylistic issue.

source/Plugins/Process/elf-core/ThreadElfCore.h
24

Please define a separate type for a "64-bit integer aligned to 8 bytes", so we can avoid littering the code with the alignas directives.

So, alignas doesn't work with typedef
We can use a #define but that's kind of ugly

labath accepted this revision.Jul 22 2016, 5:25 AM
labath edited edge metadata.

Ok, nevermind then. Looks good.

This revision is now accepted and ready to land.Jul 22 2016, 5:25 AM
labath closed this revision.Jul 25 2016, 9:18 AM

Submitted in r276406.