The executable program cannot run on Linux and displays line 1:syntax Error:word unexpected (expecting ").

Source: Internet
Author: User

Problem
ARM-LINUX-GCC compiled executable file clkctl, downloaded to the board, under Linux can not run:
./clkctl:line 1:syntax Error:word Unexpected (expecting ")")


"Resolution Process"
1. There are also people on the web who are experiencing this problem:
Syntax Error:word Unexpected (expecting ")")
Http://hi.baidu.com/dsfire/blog/item/5d922458886ad589800a188b.html
It is sent to the board with FTP, is not transmitted intact, so led to run a problem,
But I used the LRZ through SECURECRT to make sure the file was intact.

2. Think I burned uimage and rootfs have problems, and re-burn write again,
It's still not working.

3. Thought the compiled file has the problem, therefore changed the ARM-LINUX-UCLIBC-GCC to compile, the result also still does not have. 4.

4.
Error running two test programs on a board that has been ported to Linux
Http://linux.chinaunix.net/bbs/thread-1064286-1-1.html
Mentioned in the file view, so go to the Linux server to look at a bit, it looks as if it is OK:
File Clkctl
Clkctl:elf 32-bit LSB relocatable, ARM, version 1 (ARM), not stripped

Even use the relevant tools to view, it seems OK:
Hexdump N 1 clkctl
Hexdump:n: No such file or directory
Hexdump:1: No such file or directory
0000000 457f 464c 0101 6101 0000 0000 0000 0000
0000010 0001 0028 0001 0000 0000 0000 0000 0000
0000020 0630 0000 0000 0000 0034 0000 0000 0028
。。。

Objdump-a Clkctl

Clkctl:file format Elf32-little
Clkctl

Objdump-f Clkctl

Clkctl:file format Elf32-little
architecture:unknown!, Flags 0x00000011:
Has_reloc, has_syms
Start Address 0x00000000

Objdump-h Clkctl

Clkctl:file format Elf32-little

Sections:
IDX Name Size VMA LMA File off ALGN
0. Text 000003e8 00000000 00000000 00000034 2**2
CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE
1. Data 00000000 00000000 00000000 0000041c 2**0
CONTENTS, ALLOC, LOAD, DATA
2. BSS 00000004 00000000 00000000 0000041c 2**2
ALLOC
3. Rodata 00000190 00000000 00000000 0000041c 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
4. Comment 00000012 00000000 00000000 000005ac 2**0
CONTENTS, READONLY
5. Note. Gnu-stack 00000000 00000000 00000000 000005be 2**0
CONTENTS, READONLY
6. Arm.attributes 00000010 00000000

5. Hundreds of Google posts, did not say the specific problem,
There is only one post that seems to be talking about the idea:
After updating to AIR SDK 1.5.1 all Flex AIR apps give "ABC bytecode decoding" error
http://bugs.adobe.com/jira/browse/FBE-323

Flex_sdk_3/bin/adl_lin:1: Syntax Error:word Unexpected (expecting ")")

I ' ve seen this error before and usually their a shell execution problem, but I'm not quite sure how to fix it here. Usually it ' s

Something like the change #!/bin/sh to #!/bin/bash, but since Adl_lin was a binary file I ' m not sure what to go about fixing it.

Fyi:i ' m running Ubuntu 8.04, if that's helpful in anyway.

It's like SH's problem,
But, go to the/bin directory to see, SH seems to be no problem.
# sh--help
BusyBox v1.13.2 (2009-05-13 11:38:15 CST) multi-call binary

No help available.


There is no language ...

"Solution"
Just saw this post:
Cygwin and NMT Toolchain
http://www.networkedmediatank.com/showthread.php?tid=20303
Did not notice, later did not intend to discover, originally which explained the reason and introduced the solution ...

All software errors will eventually find their cause, and here is no exception.
The final discovery is that when I write a simple makefile, when I write a compile command, it writes:
$ (CC)-O $ (out_file)-C $ (src_file)
Instead, the-c option should be removed and compiled directly into an executable file:
$ (CC)-O $ (out_file) $ (src_file)

has been confusing the-c parameter, thinking that the following is exactly the C file ...
Now it's a mistake ...

Where the-c option of GCC means:
-C
Only activates preprocessing, compilation, and assembly, that is, he only makes the program obj file
Example usage:
Gcc-c hello.c
He will generate the. O obj file

That is, if you do not add-C, the default is to directly compile the generated executable file
Plus-C is only compiled into the target obj file, it will not continue to compile into the executable file ...

Our actual order.
Arm-linux-gcc-o clkctl-c CLOCK_CONTROL.C
This means that the CLOCK_CONTROL.C is compiled into a target file, and this output (target) file is called Clkctl
In fact, if you do not write here-o Clkctl, the general default output file name is the same as the C file name, but the suffix is. O, here is CLOCK_CONTROL.O.

Arm-linux-gcc-o Clkctl CLOCK_CONTROL.C
The CLOCK_CONTROL.C is compiled into an executable file (which is compiled into a target file and then linked to an executable file)
Where the output file name is Clkctl, if you do not add-o clkctl, then the Linux default output file name is A.out,
Easy to confuse and easy to cover, also no practical meaning, so generally add-o to the output of the executable program file name.

In addition, to say, GCC also has a parameter is uppercase C:
-C
In the preprocessing, do not delete the comment information, General and e-use, and sometimes analytical procedures, with this very convenient
Be careful not to confuse with this lowercase c ...

Appendix
GCC parameters in a detailed
Http://man.lupaworld.com/content/develop/UNIX_system_develop_gcc.htm

Summary
Other friends, in the face of this problem, I guess a lot is the same as me,
is to compile, mistakenly added to the-C option, so that the generated is not an executable file, is the target file,
So when it runs, it can't run.

Feeling a sentence, so basic knowledge of the basics are forgotten, embarrassing ah ....

PostScript

In fact, it is their own knowledge is not enough, the target file information, as an executable file information, because just went to use file to see the actual executable file information, and the previous file to view the results of the target files are not the same:

[[Email protected] clock_control]$ file CLOCK_CONTROL.O
Clock_control.o:elf 32-bit LSB relocatable, ARM, version 1 (ARM), not stripped
[[Email protected] clock_control]$ file Clkctl
Clkctl:elf 32-bit LSB executable, ARM, version 1 (ARM), dynamically linked (uses shared libs), not stripped
[Email protected] clock_control]$

If you have this knowledge before, then you can see the problem. Also, if the brain is flexible, use file to view other existing executables, and then compare with the above can be seen. Or Improper method Ah ...

Similarly, using the Readelf tool to see the specific information can also be read:

[Email protected] clock_control]$readelf-h Clkctl
ELF Header:
magic:7f 4c 46 01 01 01 61 00 00 00 00 00 00 00 00
Class:elf32
Data:2 ' s complement, little endian
Version:1 (current)
Os/abi:arm
ABI version:0
type:exec (executable file)
Machine:arm
version:0x1
Entry Point address:0x854c
Start of Program headers:52 (bytes to file)
Start of section headers:5036 (bytes to file)
FLAGS:0X2, have entry point, GNU EABI
Size of this header:52 (bytes)
Size of Program headers:32 (bytes)
Number of program Headers:6
Size of section headers:40 (bytes)
Number of section headers:31
Section header string Table index:28
[[email protected] clock_control]$ ls
Clkctl clock_control.c clock_control.h CLOCK_CONTROL.O Clock-dev.ko makefile ReadMe.txt
[Email protected] clock_control]$readelf-h CLOCK_CONTROL.O
ELF Header:
magic:7f 4c 46 01 01 01 61 00 00 00 00 00 00 00 00
Class:elf32
Data:2 ' s complement, little endian
Version:1 (current)
Os/abi:arm
ABI version:0
Type:rel (relocatable file)
Machine:arm
version:0x1
Entry Point address:0x0
Start of Program headers:0 (bytes to file)
Start of section headers:1584 (bytes to file)
flags:0x0
Size of this header:52 (bytes)
Size of Program headers:0 (bytes)
Number of program headers:0
Size of section headers:40 (bytes)
Number of section Headers:12
Section header string Table Index:9

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.