static member data issue in arm-eabi-ld

by simon » Fri, 16 Jan 2009 02:14:26 GMT


Sponsored Links
 i all,

i'm trying to compile simple native application under Android platform
and got problem with linker (looks like linker or linker scripts bug)

my simple program:

class C
{
static int m;

public:
static void f() { m = 0; }
};

int main(int, char**)
{
C::f();
return 0;
}

compilation commands:

arm-eabi-gcc -c -I/home/simon/workspace/mydroid/system/core/include -I/
home/simon/workspace/mydroid/hardware/libhardware/include -I/home/
simon/workspace/mydroid/hardware/ril/include -I/home/simon/workspace/
mydroid/dalvik/libnativehelper/include/nativehelper -I/home/simon/
workspace/mydroid/frameworks/base/include -I/home/simon/workspace/
mydroid/frameworks/base/libs/audioflinger -I/home/simon/workspace/
mydroid/external/skia/include -I/home/simon/workspace/mydroid/out/
target/product/generic/obj/include -I/home/simon/workspace/mydroid/
bionic/libc/arch-arm/include -I/home/simon/workspace/mydroid/bionic/
libc/include -I/home/simon/workspace/mydroid/bionic/libstdc++/include -
I/home/simon/workspace/mydroid/bionic/libc/kernel/common -I/home/simon/
workspace/mydroid/bionic/libc/kernel/arch-arm -I/home/simon/workspace/
mydroid/bionic/libm/include -I/home/simon/workspace/mydroid/bionic/
libm/include/arch/arm -I/home/simon/workspace/mydroid/bionic/
libthread_db/include -I/home/simon/workspace/mydroid/bionic/libm/arm -
I/home/simon/workspace/mydroid/bionic/libm -I/home/simon/workspace/
mydroid/out/target/product/generic/obj/SHARED_LIBRARIES/
libm_intermediates -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -
D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ -DANDROID -DSK_DEBUG -DDEBUG -
march=armv5te -mtune=xscale -msoft-float -mthumb-interwork -fno-
threadsafe-statics -fpic -fno-exceptions -ffunction-sections -funwind-
tables -fstack-protector-all -fmessage-length=0 main2.cpp

arm-eabi-gcc -o mt -I/home/simon/workspace/mydroid/system/core/include
-I/home/simon/workspace/mydroid/hardware/libhardware/include -I/home/
simon/workspace/mydroid/hardware/ril/include -I/home/simon/workspace/
mydroid/dalvik/libnativehelper/include/nativehelper -I/home/simon/
workspace/mydroid/frameworks/base/include -I/home/simon/workspace/
mydroid/frameworks/base/libs/audioflinger -I/home/simon/workspace/
mydroid/external/skia/include -I/home/simon/workspace/mydroid/out/
target/product/generic/obj/include -I/home/simon/workspace/mydroid/
bionic/libc/arch-arm/include -I/home/simon/workspace/mydroid/bionic/
libc/include -I/home/simon/workspace/mydroid/bionic/libstdc++/include -
I/home/simon/workspace/mydroid/bionic/libc/kernel/common -I/home/simon/
workspace/mydroid/bionic/libc/kernel/arch-arm -I/home/simon/workspace/
mydroid/bionic/libm/include -I/home/simon/workspace/mydroid/bionic/
libm/include/arch/arm -I/home/simon/workspace/mydroid/bionic/
libthread_db/include -I/home/simon/workspace/mydroid/bionic/libm/arm -
I/home/simon/workspace/mydroid/bionic/libm -I/home/simon/workspace/
mydroid/out/target/product/generic/obj/SHARED_LIBRARIES/
libm_intermediates -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -
D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ -DANDROID -DSK_DEBUG -DDEBUG -
march=armv5te -mtune=xscale -msoft-float -mthumb-interwork -fno-
threadsafe-statics -fpic -fno-exceptions -ffunction-sections -funwind-
tables -fstack-protector-all -fmessage-length=0 -Bdynamic -Wl,-T,/home/
simon/workspace/mydroid/build/core/armelf.x -Wl,-dynamic-linker,/
system/bin/linker -Wl,--gc-sections -Wl,-z,nocopyreloc -Wl,--no-
undefined -Wl,-rpath



static member data issue in arm-eabi-ld

by Michael MacDonald » Fri, 16 Jan 2009 03:44:15 GMT


 his is a problem with your c++ program, not with android.

m is declared but not defined.

You need to add

int c::m;

to your source file.

simon wrote:


--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


static member data issue in arm-eabi-ld

by Andrew Stadler » Fri, 16 Jan 2009 06:12:20 GMT


 orry to keep repeating this, but native development is *not*
currently supported by the SDK. This mailing list is for discussion
of application development using the SDK. You may want to try
android-platform or android-discuss.

See <http://source.android.com/discuss> for more information.

Thanks,
Andy




On Thu, Jan 15, 2009 at 8:25 AM, simon <semen.sema...@gmail.com> wrote:

--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. Unexpected extra byte occurring in binary logcat entry stream

I've been implementing a logcat reader in java which uses the binary
output of logcat (-B switch) rather than the text based formats. My
code works for many of the entries, but frequently the binary log
entries have an extra byte inserted which I can't account for, making
the payload the wrong size.

program itself and the logging apis, the binary format seems to be:

Header (20 bytes total):
[payloadlength]  2 bytes
[unused padding] 2 bytes
[PID]            4 bytes
[Thread ID]      4 bytes
[time seconds]   4 bytes
[time nanosecs]  4 bytes
[payload]        payloadlength bytes

Payload section of the header is (payloadlength bytes total):
[log priority]            1 byte
[null terminated tag]     unknown length, < payloadlength
[null terminated log msg] unknown length, < payloadlength

This file defines the struct: 
http://www.google.com/codesearch/p?hl=en#2wSbThBwwIw/include/cutils/logger.h&l=15

The extra byte I'm seeing occours after the nanosecond timestamp and
before the log priority of the payload. e.g. Here is a hex dump of one
of the log entries with the phantom byte:

The byte (in this instance) is 0x1D at offset 0x14
0000:0000 | 2E 00 0D 0A  C0 7C 00 00  00 9A 00 00  00 EC BA E5  4C
| ....|.......L
0000:0011 | EB E8 AA 1D  03 4B 65 79  67 75 61 72  64 56 69 65  77 |
..KeyguardView
0000:0022 | 4D 65 64 69  61 74 6F 72  00 68 61 6E  64 6C 65 57  61 |
Mediator.handleWa
0000:0033 | 6B 65 57 68  65 6E 52 65  61 64 79 28  32 36 29 00     |
keWhenReady(26).

The extra byte shifts the payload by 1, so the payload length becomes
incorrect. I can't see where this byte is coming from.

I also tried the LogReceiver class in ddmlib, but that also fails to
handle extra byte and produces garbage after it hits an entry with the
extra byte:
http://www.google.com/codesearch/p?hl=en#cZwlSNS7aEw/sdk/ddms/libs/ddmlib/src/com/android/ddmlib/log/LogReceiver.java&sa=N&cd=2&ct=rc

Here is a quick python script which demonstrates the problem. It reads
and prints binary log entries in the expected format. It will raise an
exception when it encounters an entry with an unexpected byte:
http://pastebin.com/nvvsBjkZ

The logcat program itself successfully reinterprets the binary format
without jumping through any hoops, so I can only guess it's some kind
of struct alignment artifact. Anyone encountered this or got any idea
why the extra byte is appearing?

-- 

2. Paging Om Ibnu Sina (ibun)

Om Ibnu,

Tolong dibales email japri saya ke punyai...@gmail.com.

Terima kasih

-- 
===============
"

3. selusin alasan beli garmin asus a10/a50

4. Koneksi 3 bermasalah?

5. Android apps crashing on different phone models

6. Monthly Calendar

7. How to Dismiss a PopupWindow when Switching Among TabActivities?