need help to understand a piece of code

This is a discussion on need help to understand a piece of code within the C Programming forums, part of the General Programming Boards category; I am struck in understanding a piece of code. It is the implementation of a function called UX_location. the code ...

  1. #1
    Registered User
    Join Date
    Aug 2004
    Posts
    2

    need help to understand a piece of code

    I am struck in understanding a piece of code.
    It is the implementation of a function called UX_location.
    the code for it is

    /* Procedure: 0x000446C4 - 0x000446CF
    * Argument size: 0
    * Local size: 0
    * Save regs size: 0
    */

    UX_location()
    {

    r1 = 0x6c000;
    asm("ba,a 0x00044514");
    }



    I am giving below a part of the code that calls this function

    RUshmdetach()
    {
    /* unknown */ void Vfffffffc;



    if(*RUshmsegatt != -1) {
    if(UXsh_detach( *RUshmaddr) != -20) {
    goto L0002478c;
    }
    UX_location("/apx/ecpc21/OFC18L21.0/1apx10/rdbu/gen/omp/RUitdetach.c", 39);
    UX_elog("RUshmdetach() failure: RUshmaddr = %d, RUshmtblptr = %d", *RUshmaddr, *RUshmtblptr);
    Vfffffffc = 0;
    } else {
    L0002478c:
    *RUshmsegatt = -1;
    Vfffffffc = 1;
    }
    r24 = Vfffffffc;
    return(r3);
    }



    This is output of the REC .
    I am trying to reverse a ELF 32-bit MSB executable SPARC Version 1, dynamically linked,not stripped code.


    Any one can lead me into this?

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    I am giving below a part of the code that calls this function

    RUshmdetach()
    {
    /* unknown */ void Vfffffffc;
    I suspect you have, or this was written on, an old piece of crap compiler. Something like the one talked about here:
    C: A reference Manual, Fifth Edition
    Page 87, 4.4.1 Default Type Specifiers

    Originally, C allowed the type specifier in a variable declaration or function to
    be omitted, in which chase it defaulted to int. This is considered bad programming style in
    modern C, and in fact C99 treats it as an error. Older compilers did not implement the
    void type
    , so rationale behind omitting the type specifier on function definitions was to
    indicate to human readers that the default function did not really return a value (although the com-
    piler had to assume that it did).

    Example
    Code:
    In pre-Standard C, it was common to see function definitions like this:
    /* Sort v[0] ... vpn-1] into increasing order. */
    sort(v, n)
        int v[], n;
    {
        ...
    }
    The modern, Standard C style is to declare those functions with the void type:
    Code:
    /* Sort v[0] ... v[n-1] into increasing order. */
    void sort(int v[], int n)
    {
        ...
    }
    Example
    When using a compiler that does not implement void, it is much nicer to define void your-
    self and then use it explicitly than to omit the type specifier entirely:
    Code:
    /* Make "void" be a synonym for "int". */
    typedef int void;
    At least one compiler we know of actually reserves the identifier void, but does not imple-
    ment it. For that compiler, the preprocessor definition
    Code:
    #define void int

    is one of the few cases in which using a reserved word as a macro name is justified.
    As per the above, I suspect the code, or you, whatever, was written for a compiler which did not implement void, or, that it was implemented as illustrated above.

    Because otherwise, you cannot declare a void variable instance. In otherwords, this code isn't ANSI C. At least that's my take on it.

    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,499
    > I am trying to reverse a ELF 32-bit MSB executable SPARC Version 1
    Yeah thought as much.
    That code is so horrible it could only come from either a shrouder or a decompiler.

    > Any one can lead me into this?
    You're on your own I'm afraid.
    You need "good to excellent" skills in both C and the assembly of the target processor to have any real chance of achieving what you want.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  4. #4
    Registered User
    Join Date
    Aug 2004
    Posts
    2
    Thanks guys

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. whats wrong with this piece of code?
    By psycho88 in forum C Programming
    Replies: 3
    Last Post: 12-03-2005, 10:28 PM
  2. Updated sound engine code
    By VirtualAce in forum Game Programming
    Replies: 8
    Last Post: 11-18-2004, 11:38 AM
  3. Help with a little piece of code
    By cdonlan in forum C Programming
    Replies: 5
    Last Post: 11-15-2004, 11:38 AM
  4. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM
  5. What is your favorite piece of code?
    By Yoshi in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 01-22-2002, 06:12 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21