Page MenuHomePhabricator

Improve the posix core file triple detection

Authored by tberghammer on Jul 29 2017, 6:08 AM.



Posix core files sometime don't contain enough information to correctly
detect the OS. If that is the case we should use the OS from the target
instead as it will contain usable information in more cases and if the
target and the core contain different OS-es then we are already in a
pretty bad state so moving from an unknown OS to a known (but possibly
incorrect) OS will do no harm.

We already had similar code in place for MIPS. This change tries to make
it more generic by using ArchSpec::MergeFrom and extends it to all
architectures but some MIPS specific issue prevent us from getting rid
of special casing MIPS.

Event Timeline

tberghammer created this revision.Jul 29 2017, 6:08 AM
tberghammer added inline comments.Jul 29 2017, 6:10 AM

Hi Nitesh,

I tried to remove this MIPS specific code as it shouldn't be necessary if I add the above MergeFrom for all architecture but if I do it fails LinuxCore

The issue is that in that case the tripe we get from the core file is "mipsel--" ("mipsel--linux" after the merge) and the one we get from the binary is "mips64el--linux". Is it normal to have a seemingly 32bit core file with a 64bit binary on mips? If not then can I ask you to help me figure out which one is incorrect?

If it is then I don't see any better short term solution then leaving this condition here but it feels like a quite big hack what might backfire when somebody tries to use a core file with a completely incompatible binary.


nitesh.jain added inline comments.Jul 31 2017, 7:10 AM

Hi Tamas,

In MIPS , the core file doesn't contain any Architecture information . It's just specify the generic MIPS architecture. Hence we need to relied on target_arch for correct architecture informations.

TestCase.test_mips_n32 is "32 bit binary" with triple "mips64el-linux". This binary can only run on 64 bit target as compared to O32 which can run on 32/64 bit target.

Add comment about the MIPS special case.

Hi Greg, can you take a look sometime? Thanks, Tamas


Thank you for the explanation. I added a comment to the code to explain it better there.

clayborg accepted this revision.Aug 16 2017, 10:37 AM

Looks fine. Sorry for the delay.

This revision is now accepted and ready to land.Aug 16 2017, 10:37 AM
This revision was automatically updated to reflect the committed changes.