public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* .note.ABI-tag extension for Android
@ 2012-04-20 23:36 Thiago Jung Bauermann
  2012-05-02 15:14 ` nick clifton
  0 siblings, 1 reply; 3+ messages in thread
From: Thiago Jung Bauermann @ 2012-04-20 23:36 UTC (permalink / raw)
  To: binutils

Hello,

I'm discussing with Google engineers about adding a .note.ABI-tag to
Android binaries, and extending the note format to allow identifying an
Android application.

I'd like to ask for comments about my proposed extension before
implementing and deploying it. I'm not sure which forum would be the
right one for this topic, but the binutils mailing list seems
appropriate. And it's subscribers probably overlap a lot with what would
be the correct group anyway. :-)

My goal is to allow distinguishing between an ELF file containing a
regular GNU/Linux program and an Android program.

This is so that GDB can know when it's debugging an Android application.
A few details which are not defined by the ABI differ between the two,
like the longjump buffer format and the signal handler trampoline.

The format of the ELF note is as follows:

name size: 4
desc size: 24
type: 1
name: "GNU"
desc: as as defined by the LSB standard:

"The first 32-bit word of the desc field shall be 0 (this signifies a
Linux executable). The second, third, and fourth 32-bit words of the
desc field contain the earliest compatible kernel version. For example,
if the 3 words are 2, 2, and 5, this signifies a 2.2.5 kernel."

And extended to contain the following two words right after the kernel
version:

os_variant: 1
android_api: 15

I arbitrarily chose os_variant = 1 to mean Android.

So the idea is that if desc size is >= 20, then the fifth 32-bit word
will be examined. If it is 1, then this is an Android ELF file. The
sixth word will then tell you the API level the application expects.

What do you think?

-- 
[]'s
Thiago Jung Bauermann
Linaro Toolchain Working Group



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: .note.ABI-tag extension for Android
  2012-04-20 23:36 .note.ABI-tag extension for Android Thiago Jung Bauermann
@ 2012-05-02 15:14 ` nick clifton
  2012-06-27  5:39   ` Thiago Jung Bauermann
  0 siblings, 1 reply; 3+ messages in thread
From: nick clifton @ 2012-05-02 15:14 UTC (permalink / raw)
  To: Thiago Jung Bauermann; +Cc: binutils

Hi Thiago,

> I'm discussing with Google engineers about adding a .note.ABI-tag to
> Android binaries, and extending the note format to allow identifying an
> Android application.

Why not use the ELF header for this ?  You have the ei_osabi value in 
the e_ident field for example which is already used to encode different 
flavours of Linux.

Of course this does not provide much room to defined the Android API in 
use...

> os_variant: 1
> android_api: 15
>
> I arbitrarily chose os_variant = 1 to mean Android.
>
> So the idea is that if desc size is>= 20, then the fifth 32-bit word
> will be examined. If it is 1, then this is an Android ELF file. The
> sixth word will then tell you the API level the application expects.

Are there a large number of Android APIs ?  I am wondering if it is 
necessart to have two new 32-bit fields, or whether it would be more 
efficient to combine them into just one ?

Cheers
   Nick

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: .note.ABI-tag extension for Android
  2012-05-02 15:14 ` nick clifton
@ 2012-06-27  5:39   ` Thiago Jung Bauermann
  0 siblings, 0 replies; 3+ messages in thread
From: Thiago Jung Bauermann @ 2012-06-27  5:39 UTC (permalink / raw)
  To: nick clifton; +Cc: binutils

Hello Nick,

Sorry for the long hiatus, I spent some time studying this and also was
sidetracked for a while...

Thanks for your comments!

On Wed, 2012-05-02 at 16:10 +0100, nick clifton wrote:
> > I'm discussing with Google engineers about adding a .note.ABI-tag to
> > Android binaries, and extending the note format to allow identifying an
> > Android application.
> 
> Why not use the ELF header for this ?  You have the ei_osabi value in 
> the e_ident field for example which is already used to encode different 
> flavours of Linux.
> 
> Of course this does not provide much room to defined the Android API in 
> use...

I had this idea too, but it turns out that these fields are meant for
changes to the ELF format, so that the file can be read correctly. I
found a heated discussion about this on the binutils mailing list:

http://sourceware.org/ml/binutils/2000-11/msg00367.html

With the following very informative e-mail:

http://sourceware.org/ml/binutils/2000-11/msg00383.html

> > os_variant: 1
> > android_api: 15
> >
> > I arbitrarily chose os_variant = 1 to mean Android.
> >
> > So the idea is that if desc size is>= 20, then the fifth 32-bit word
> > will be examined. If it is 1, then this is an Android ELF file. The
> > sixth word will then tell you the API level the application expects.
> 
> Are there a large number of Android APIs ?  I am wondering if it is 
> necessart to have two new 32-bit fields, or whether it would be more 
> efficient to combine them into just one ?

That's a good point. Actually, Roland McGrath mentioned that since
the .note.ABI-tag format I want to change uses the "GNU" vendor, it is
reserved for GNU tools and I shouldn't extend it. I am now dropping that
original proposal and changing my patch to use a .note.android.ident
section containing only the API level in the desc field. Now I am indeed
using only one field.

I had also asked for comments on the lsb-discuss mailing list and got
some answers there, if you would like to follow it:

http://lists.linuxfoundation.org/pipermail/lsb-discuss/2012-April/007228.html

There was a message from Roland which wasn't linked to the original
thread by the webarchive frontend:

http://lists.linuxfoundation.org/pipermail/lsb-discuss/2012-May/007243.html

And the answer I just sent there:

http://lists.linuxfoundation.org/pipermail/lsb-discuss/2012-June/007281.html

-- 
[]'s
Thiago Jung Bauermann
IBM Linux Technology Center

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-06-27  5:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-20 23:36 .note.ABI-tag extension for Android Thiago Jung Bauermann
2012-05-02 15:14 ` nick clifton
2012-06-27  5:39   ` Thiago Jung Bauermann

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 read-only IMAP folder(s) and NNTP newsgroup(s).