Bug 3083

Summary: qemu-arm can not execute after relocated
Product: [Yocto Project Subprojects] ADT Reporter: Yi Zhao <yi.zhao>
Component: adtAssignee: Laurentiu Palcu <laurentiu.palcu>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: Medium CC: jessica.zhang, liang.li2, poky.adt.watcher, poky.watcher, Qi.Chen, sgw
Version: 1.3   
Target Milestone: 1.3 M5   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: ---
Attachments:
Description Flags
qemu-arm-without-reloc
none
qemu-arm-with-reloc none

Description Yi Zhao 2012-09-10 10:19:42 UTC
This issue is related to bug 3009.

adt_intaller from http://downloads.yoctoproject.org/releases/yocto/milestones/yocto-1.3-beta/adt_installer-QA/

Steps:
1. download adt_installer.tar.bz2 from http://downloads.yoctoproject.org/releases/yocto/milestones/yocto-1.3-beta/adt_installer-QA/
2. Install adt_installer: $ ./adt_installer
3. source /opt/poky/1.2+snapshot/environment-setup-armv5te-poky-linux-gnueabi
4. run "qemu-arm"

Error message:
###############
$ which qemu-arm 
/opt/poky/1.2+snapshot/sysroots/x86_64-pokysdk-linux/usr/bin/qemu-arm
$ qemu-arm
bash: /opt/poky/1.2+snapshot/sysroots/x86_64-pokysdk-linux/usr/bin/qemu-arm: cannot execute binary file
################

When I comment the following line in scripts/adt_installer_internal and re-install. 
########
$SUDO scripts/relocate_sdk_tmp.py $INSTALL_FOLDER $dl_path $executable_files
########

The qemu-arm could work
###########
$ which qemu-arm
/opt/poky/1.2+snapshot/sysroots/x86_64-pokysdk-linux/usr/bin/qemu-arm
zhaoyi@zhaoyi-ubuntu:~$ sudo qemu-arm
usage: qemu-arm [options] program [arguments...]
Linux CPU emulator (compiled for arm emulation)

Options and associated environment variables:

Argument     Env-variable      Description
-h                             print this help
-g port      QEMU_GDB          wait gdb connection to 'port'
-L path      QEMU_LD_PREFIX    set the elf interpreter prefix to 'path'
-s size      QEMU_STACK_SIZE   set the stack size to 'size' bytes
-cpu model   QEMU_CPU          select CPU (-cpu ? for list)
-E var=value QEMU_SET_ENV      sets targets environment variable (see below)
-U var       QEMU_UNSET_ENV    unsets targets environment variable (see below)
-0 argv0     QEMU_ARGV0        forces target process argv[0] to be 'argv0'
-r uname     QEMU_UNAME        set qemu uname release string to 'uname'
-B address   QEMU_GUEST_BASE   set guest_base address to 'address'
-R size      QEMU_RESERVED_VA  reserve 'size' bytes for guest virtual address space
-d options   QEMU_LOG          activate log
-D logfile   QEMU_LOG_FILENAME override default logfile location
-p pagesize  QEMU_PAGESIZE     set the host page size to 'pagesize'
-singlestep  QEMU_SINGLESTEP   run in singlestep mode
-strace      QEMU_STRACE       log system calls
-version     QEMU_VERSION      display version information and exit

Defaults:
QEMU_LD_PREFIX  = /etc/qemu-binfmt/arm
QEMU_STACK_SIZE = 8388608 byte
QEMU_LOG        = /tmp/qemu.log

You can use -E and -U options or the QEMU_SET_ENV and
QEMU_UNSET_ENV environment variables to set and unset
environment variables for the target process.
It is possible to provide several variables by separating them
by commas in getsubopt(3) style. Additionally it is possible to
provide the -E and -U options multiple times.
The following lines are equivalent:
    -E var1=val2 -E var2=val2 -U LD_PRELOAD -U LD_DEBUG
    -E var1=val2,var2=val2 -U LD_PRELOAD,LD_DEBUG
    QEMU_SET_ENV=var1=val2,var2=val2 QEMU_UNSET_ENV=LD_PRELOAD,LD_DEBUG
Note that if you provide several changes to a single variable
the last change will stay in effect.
zhaoyi@zhaoyi-ubuntu:~$ 
################

The qemu-arm command is from qemu-nativesdk_0.15.1-r11_x86_64-nativesdk.ipk which download from http://adtrepo-dev.yoctoproject.org/1.2+snapshot/adt-ipk/x86_64-nativesdk/
Comment 1 Yi Zhao 2012-09-10 10:21:58 UTC
Created attachment 777 [details]
qemu-arm-without-reloc
Comment 2 Yi Zhao 2012-09-10 10:23:19 UTC
Created attachment 778 [details]
qemu-arm-with-reloc

Here is the readelf message for qemu-arm with reloc
Comment 3 Laurentiu Palcu 2012-09-11 13:41:18 UTC
Patches sent on the oe-core mailing list for review.
Comment 5 liang li 2012-09-19 03:08:11 UTC
same as bug 3009,verified on :
git info:e5c3513ca8abb21eb5e9b8c19d1b9199b14ae07c
git branch:poky/1.3_M4