Bug 14693 - [PATCH] Allow building for Android hosts
Summary: [PATCH] Allow building for Android hosts
Status: NEW
Alias: None
Product: binutils
Classification: Unclassified
Component: binutils (show other bugs)
Version: 2.24
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-10-09 23:59 UTC by bernhard.rosenkranzer@linaro.org
Modified: 2013-11-23 12:27 UTC (History)
2 users (show)

See Also:
Host: *-linux-androideabi
Target:
Build:
Last reconfirmed:


Attachments
Patch (731 bytes, application/octet-stream)
2012-10-09 23:59 UTC, bernhard.rosenkranzer@linaro.org
Details
my patch for fix building binutils 2.33.2 on Android ARM (1.80 KB, patch)
2013-11-23 12:27 UTC, SFENCE
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description bernhard.rosenkranzer@linaro.org 2012-10-09 23:59:21 UTC
Created attachment 6676 [details]
Patch

Currently, binutils can be built for Android targets, but not for Android hosts -- it just requires 2 minor changes:
The getpagesize() implementation in libiberty has to be commented out because Bionic (Android's libc) defines getpagesize() in <unistd.h>, and a time() call in bfd/archive.c has to cast &status.st_mtime to time_t (st_mtime is, as expected, an unsigned long -- but time_t is typedef'ed to (signed) int. Probably a bug in Bionic - but casting explicitly can't hurt).

The patch is relative to hjl's 2.23.51.0.3 release, but will probably apply to 2.24.
Comment 1 Mike Frysinger 2012-10-10 00:29:27 UTC
it can hurt if sizeof(time_t) != sizeof(status.st_mtime).  in newer systems, time_t is a 64bit quantity, not 32bit (like int).
Comment 2 H.J. Lu 2012-10-10 04:54:11 UTC
(In reply to comment #0)
> Created attachment 6676 [details]
> Patch
> 
> Currently, binutils can be built for Android targets, but not for Android hosts
> -- it just requires 2 minor changes:
> The getpagesize() implementation in libiberty has to be commented out because
> Bionic (Android's libc) defines getpagesize() in <unistd.h>, and a time() call

You should update getpagesize detection instead.

> in bfd/archive.c has to cast &status.st_mtime to time_t (st_mtime is, as
> expected, an unsigned long -- but time_t is typedef'ed to (signed) int.
> Probably a bug in Bionic - but casting explicitly can't hurt).
> 

I think it is a bug in Bionic.
Comment 3 SFENCE 2013-11-23 12:27:31 UTC
Created attachment 7298 [details]
my patch for fix building binutils 2.33.2 on Android ARM

I have just compiled binutils 2.33.2 on android ARM with native gcc. Please ignore shell changes from /bin/sh to /system/bin/sh. I know, it cannot be fixed.

I have posted this in dependence of my successful compilation of GNU Debugger on Android.
Bug http://sourceware.org/bugzilla/show_bug.cgi?id=16206 from GDB.

Thanks.