Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8387809
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T18:18:57+00:00 2026-06-09T18:18:57+00:00

I’m looking for a programatic way to find the powerpc cpu type on Linux.

  • 0

I’m looking for a programatic way to find the powerpc cpu type on Linux. Performing some google searches associated an answer suggesting the mfpvr instruction I found that this is available in the ELF AUX header, and sure enough I can obtain the POWER5 string for the machine I’m running on with the following:

#include <stdio.h>
#include <elf.h>

int main( int argc, char **argv, char **envp )
{
   /* walk past all env pointers */
   while ( *envp++ != NULL )
      ;

   /* and find ELF auxiliary vectors (if this was an ELF binary) */
#if 0
   Elf32_auxv_t * auxv = (Elf32_auxv_t *) envp ;
#else
   Elf64_auxv_t * auxv = (Elf64_auxv_t *) envp ;
#endif

   char * platform = NULL ;

   for ( ; auxv->a_type != AT_NULL ; auxv++ )
   {
      if ( auxv->a_type == AT_PLATFORM )
      {
         platform = (char *)auxv->a_un.a_val ;
         break;
      }
   }

   if ( platform )
   {
      printf( "%s\n", platform ) ;
   }

   return 0 ;
}

In the shared library context where I want to use this info I have no access to envp. Is there an alternate programatic method to find the beginning of the ELF AUX header?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T18:18:59+00:00Added an answer on June 9, 2026 at 6:18 pm

    You can get if from /proc/self/auxv file

    According to man proc /proc/self/auxv is available since kernel level 2.6.0-test7.

    Another option – get some (existing) environment variable – let say HOME,
    or PATH, or whatever. Please note that you’ll get it’s ADDRESS. From here you can go back and find previous env variable, then one before it, etc. After that you can likewise skip all argv arguments. And then you get to the last AUXV entry. Some steps back – and you should be able find your AT_PLATFORM.

    EDIT: It looks like glibc now provides a programatic method to get at this info:

    glibc-headers-2.17-106: /usr/include/sys/auxv.h : getauxinfo()

    Example:

    #include <sys/auxv.h>
    #include <stdio.h>
    
    int main()
    {
       unsigned long v = getauxval( AT_PLATFORM ) ;
       printf( "%s\n", (char *)v ) ;
    
       return 0 ;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm making a simple page using Google Maps API 3. My first. One marker
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I would like to count the length of a string with PHP. The string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.