ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hello,
Can I use objdump to extract information from a section???
In this moment, objdump give me a lot of information of several sections of program??
Usage: objcopy [option(s)] in-file [out-file]
Copies a binary file, possibly transforming it in the process
The options are:
-I --input-target <bfdname> Assume input file is in format <bfdname>
-O --output-target <bfdname> Create an output file in format <bfdname>
-B --binary-architecture <arch> Set arch of output file, when input is binary
-F --target <bfdname> Set both input and output format to <bfdname>
--debugging Convert debugging information, if possible
-p --preserve-dates Copy modified/access timestamps to the output
-j --only-section <name> Only copy section <name> into the output
--add-gnu-debuglink=<file> Add section .gnu_debuglink linking to <file>
-R --remove-section <name> Remove section <name> from the output
-S --strip-all Remove all symbol and relocation information
-g --strip-debug Remove all debugging symbols & sections
--strip-unneeded Remove all symbols not needed by relocations
-N --strip-symbol <name> Do not copy symbol <name>
--strip-unneeded-symbol <name>
Do not copy symbol <name> unless needed by
relocations
--only-keep-debug Strip everything but the debug information
-K --keep-symbol <name> Do not strip symbol <name>
-L --localize-symbol <name> Force symbol <name> to be marked as a local
--globalize-symbol <name> Force symbol <name> to be marked as a global
-G --keep-global-symbol <name> Localize all symbols except <name>
-W --weaken-symbol <name> Force symbol <name> to be marked as a weak
--weaken Force all global symbols to be marked as weak
-w --wildcard Permit wildcard in symbol comparison
-x --discard-all Remove all non-global symbols
-X --discard-locals Remove any compiler-generated symbols
-i --interleave <number> Only copy one out of every <number> bytes
-b --byte <num> Select byte <num> in every interleaved block
--gap-fill <val> Fill gaps between sections with <val>
--pad-to <addr> Pad the last section up to address <addr>
--set-start <addr> Set the start address to <addr>
{--change-start|--adjust-start} <incr>
Add <incr> to the start address
{--change-addresses|--adjust-vma} <incr>
Add <incr> to LMA, VMA and start addresses
{--change-section-address|--adjust-section-vma} <name>{=|+|-}<val>
Change LMA and VMA of section <name> by <val>
--change-section-lma <name>{=|+|-}<val>
Change the LMA of section <name> by <val>
--change-section-vma <name>{=|+|-}<val>
Change the VMA of section <name> by <val>
{--[no-]change-warnings|--[no-]adjust-warnings}
Warn if a named section does not exist
--set-section-flags <name>=<flags>
Set section <name>'s properties to <flags>
--add-section <name>=<file> Add section <name> found in <file> to output
--rename-section <old>=<new>[,<flags>] Rename section <old> to <new>
--change-leading-char Force output format's leading character style
--remove-leading-char Remove leading character from global symbols
--redefine-sym <old>=<new> Redefine symbol name <old> to <new>
--redefine-syms <file> --redefine-sym for all symbol pairs
listed in <file>
--srec-len <number> Restrict the length of generated Srecords
--srec-forceS3 Restrict the type of generated Srecords to S3
--strip-symbols <file> -N for all symbols listed in <file>
--strip-unneeded-symbols <file>
--strip-unneeded-symbol for all symbols listed
in <file>
--keep-symbols <file> -K for all symbols listed in <file>
--localize-symbols <file> -L for all symbols listed in <file>
--globalize-symbols <file> --globalize-symbol for all in <file>
--keep-global-symbols <file> -G for all symbols listed in <file>
--weaken-symbols <file> -W for all symbols listed in <file>
--alt-machine-code <index> Use alternate machine code for output
--writable-text Mark the output text as writable
--readonly-text Make the output text write protected
--pure Mark the output file as demand paged
--impure Mark the output file as impure
--prefix-symbols <prefix> Add <prefix> to start of every symbol name
--prefix-sections <prefix> Add <prefix> to start of every section name
--prefix-alloc-sections <prefix>
Add <prefix> to start of every allocatable
section name
-v --verbose List all object files modified
-V --version Display this program's version number
-h --help Display this output
--info List object formats & architectures supported
objcopy: supported targets: pe-i386 pei-i386 elf32-i386 elf32-little elf32-big srec symbolsrec tekhex binary ihex
--------------------------------------------------
So, I can't to say you more about this command, because I use it for building binary file. But I assume that you should use it with '-I' option together.
Can you say me what do you want to do more in details? And which target are you use?
If I am sincere, I do not known what I want.
Well, I try to explain you my idea.
With GDB you can debug a program, but there is something that it is impossible to do it with GDB, make a watch of var without stop program.
I try to develop a protocol between programm and other PC with a Visual basic program.
Visual basic send to Linux commands and Linux respond. In this moment, with objdump, I have created a table with all vars of programm, and I took only vars that I want and send to Visual basic programm, name, address, length, type and value. Linux sendt all this information to Visual Basic programm, and after it I can request to Linux, for example, a value of some variable, every one second for example.
But the problem is objdump give a lot of information. I put my vars in two sections, .global_var and .local_var, and I am interesting to obtain information from theese sections.
Well, my english is not good, but I hope that you can understand the basic idea.
With GDB you can debug a program, but there is something that it is impossible to do it with GDB
AFAIK, it isn't possible in most debuggers.
Quote:
Originally Posted by webquinty
I try to develop a protocol between programm and other PC with a Visual basic program.
Visual basic send to Linux commands and Linux respond. In this moment, with objdump, I have created a table with all vars of programm, and I took only vars that I want and send to Visual basic programm, name, address, length, type and value.
If you want to watch several variables without stopping program, either print them all to the console, or create some kind of GUI window that'll display them while program is running. Printing to console is faster to implement.
If you want to watch several variables without stopping program, either print them all to the console, or create some kind of GUI window that'll display them while program is running. Printing to console is faster to implement.
Hello ErV,
Well, It is a good idea, but if the program and console is in the same PC.
But, What happen is linux program is in the computer A and debugger programm (Visual Basic) in the computer B???.
I suppose that you need serial port or socket, or other kind of communications.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.