kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
From: tobias@gambas-buch.de (Tobias Boege)
To: kernelnewbies@lists.kernelnewbies.org
Subject: Understanding disassembly x86 + understanding function call + parameter pass and stack frame
Date: Sun, 15 Sep 2013 20:13:43 +0200	[thread overview]
Message-ID: <20130915181343.GF5469@aurora> (raw)
In-Reply-To: <CAL+pkpd=Sa-9VLuWJUMpxa1yr=U5sfs6JCLxnSKdRoUq2ZGW5A@mail.gmail.com>

On Tue, 03 Sep 2013, nidhi mittal hada wrote:
> Hi,
> 
> while in the pursuit of learning to understand assembly ..
> This is my doubt ..Please help to understand
> 
> *I want to catch where in this disassembly call is made to get_sb function.*
> 
> Somehow in this disassembly, i m not finding, a direct *call* instruction,
> with function name, written in english.
>
> [...]
> 
> *Thats the definition of function*
> 
> vfs_kern_mount(struct file_system_type *type, int flags, const char *name,
> void *data)
> {
>         struct vfsmount *mnt;
>         char *secdata = NULL;
>         int error;
> 
>         if (!type)
>                 return ERR_PTR(-ENODEV);
> 
>         error = -ENOMEM;
> 
>     *  mnt = alloc_vfsmnt(name);*
>         if (!mnt)
>                 goto out;
> 
> *<<<<<<<<<<<<<<THIS PORTION, IS   NOT  VISIBLE  TO ME, **IN  ASSEMBLY
> >>>>>>>>>>>>>>>*
>         if (data && !(type->fs_flags & FS_BINARY_MOUNTDATA)) {
>                 secdata = alloc_secdata();
>                 if (!secdata)
>                         goto out_mnt;
> 
>                 error = security_sb_copy_data(data, secdata);
>                 if (error)
>                         goto out_free_secdata;
>         }
> 
> *   error = type->get_sb(type, flags, name, data,
> mnt);>>>>>>>>>>>>>>>>thats the line i want to catch, in assembly above.
> Where is this call  made in assembly ???*
>         if (error < 0)
>                 goto out_free_secdata;
>         BUG_ON(!mnt->mnt_sb);
>         mnt->mnt_sb->s_flags |= MS_BORN;
> 
>     *    error = security_sb_kern_mount(mnt->mnt_sb, flags, secdata);*
>         if (error)
>                 goto out_sb;
> .
> .
> .
> .
> .
> *out_sb:*
>         dput(mnt->mnt_root);
>         deactivate_locked_super(mnt->mnt_sb);
> *out_free_secdata*:
>         free_secdata(secdata);
> *out_mnt:*
>         free_vfsmnt(mnt);
> *out:*   >>>368
>         return ERR_PTR(error);
> }

You won't find a "direct *call* instruction, with function name, written in
english" because 'get_sb' is not a function[*] but a function pointer. And
moreover it is a member of a structure.

You will have to find out where a pointer to this structure is stored and
where a member relative to this structure it is referenced in a call
instruction. (Hint: It is the only function pointer inside 'type' which is
used in this function. Moreover, it is the only function pointer used in
this function at all.)

Regards,
Tobi

[*] To my shame, I have no clue about the subtleties of definitions of
    entities in the C language. Please forgive me if my words don't accord
    with these definitions.

  reply	other threads:[~2013-09-15 18:13 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CAL+pkpfXRUPUK9phHEt_auM0zCC97yzkgD0e1TRsFzSMfnrb3g@mail.gmail.com>
2013-08-06  9:06 ` Fwd: Understanding disassembly x86 + understanding function call + parameter pass and stack frame nidhi mittal hada
2013-08-06  9:43   ` Saket Sinha
2013-08-06 10:16     ` Anuz Pratap Singh Tomar
2013-08-06 10:30   ` Fwd: " Tobias Boege
2013-08-06 13:43   ` Matthias Brugger
2013-08-09 19:19     ` Tayade, Nilesh
2013-08-09 21:40       ` neha naik
2013-08-12 11:58         ` nidhi mittal hada
2013-08-12 12:51           ` Tobias Boege
2013-08-12 14:44             ` Tobias Boege
2013-08-12 15:07           ` amit mehta
2013-08-13 12:17             ` nidhi mittal hada
2013-08-13 12:32               ` amit mehta
2013-08-14 10:21                 ` nidhi mittal hada
2013-08-14 10:44                   ` nidhi mittal hada
2013-08-14 11:35                     ` Valdis.Kletnieks at vt.edu
2013-09-03  9:16                       ` nidhi mittal hada
2013-09-15 18:13                         ` Tobias Boege [this message]
2013-08-14 10:55                   ` Valdis.Kletnieks at vt.edu
2013-08-06 14:13   ` Fwd: " Andreas Platschek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130915181343.GF5469@aurora \
    --to=tobias@gambas-buch.de \
    --cc=kernelnewbies@lists.kernelnewbies.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).