Skip to contentSkip to conversation

reading elf section data

DISCUSSION Gery 4 participants 11 messages Nov 12, 2007 – Nov 13, 2007

lore
Share & tools
lore

Gery

author
#0 lore raw

How to read in human format data from elf section?

#1 lore raw
Quoted 1 line · Gery

How to read in human format data from elf section?

Can you be more specific? What kind of data? What format?

objdump and readelf can provide a lot of information about ELF files, but they can't decode every type of data which could conceivably be stored in an ELF file.

Signature · 1 line
Glynn Clements <[email protected]>
#2 lore raw
Quoted 6 lines · Glynn Clements
Quoted 1 line · Gery

How to read in human format data from elf section?

Can you be more specific? What kind of data? What format?

I stopped replying to messages like those from the OP. Demanding help without providing a minimum of information is just annoying, but doing so without any etiquette is simply rude.

\Steve

--

Steve Grägert
DigitalEther.de
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

author
#3 lore raw
Quoted 12 lines · Steve Graegert
Quoted 4 lines · Glynn Clements
Quoted 1 line · Gery

How to read in human format data from elf section?

Can you be more specific? What kind of data? What format?

I stopped replying to messages like those from the OP. Demanding help without providing a minimum of information is just annoying, but doing so without any etiquette is simply rude.

\Steve

Quoted 9 lines

--

Steve Grägert
DigitalEther.de
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Just for my understanding :)
What is OP?
What is it wrong w/ my etiquette?
PLease, help me to fix my mistakes.
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#4 lore raw
Quoted 23 lines · Gery
Quoted 12 lines · Steve Graegert
Quoted 4 lines · Glynn Clements
Quoted 1 line · Gery

How to read in human format data from elf section?

Can you be more specific? What kind of data? What format?

I stopped replying to messages like those from the OP. Demanding help without providing a minimum of information is just annoying, but doing so without any etiquette is simply rude.

\Steve

Quoted 9 lines

--

Steve Grägert
DigitalEther.de
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Quoted 5 lines

Just for my understanding :)
What is OP?
What is it wrong w/ my etiquette?
PLease, help me to fix my mistakes.

Hi Gery,

Let's start with a greeting, you'll be welcome and you're done with 50% of the "etiquette".
The OP stands for "original poster" and refers to the thread starter. Finally I like to conclude a post with a closing formula or just a signature including your name. That's the second part of the "etiquette".

What I mean by rude is that questions like "How to read ELF data?" motivates no one to answer as we have to ask for clarification first. If you'd have asked "How do I read custom ELF sections added by GCC using C?" everyone knows exactly what you want just by being a bit more accurate.

Regarding your original question: try readelf first. It'll probably do the trick.

\Steve

--

Steve Grägert
DigitalEther.de
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

author
#5 lore raw
Quoted 54 lines · Steve Graegert
Quoted 27 lines · Gery
Quoted 15 lines · Steve Graegert
Quoted 7 lines · Glynn Clements
Quoted 2 lines · Gery

How to read in human format data from elf section?

Can you be more specific? What kind of data? What format?

I stopped replying to messages like those from the OP. Demanding help without providing a minimum of information is just annoying, but doing so without any etiquette is simply rude.

\Steve

Quoted 10 lines

--

Steve Grägert
DigitalEther.de
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Quoted 6 lines

Just for my understanding :)
What is OP?
What is it wrong w/ my etiquette?
PLease, help me to fix my mistakes.

Hi Gery,

Let's start with a greeting, you'll be welcome and you're done with 50% of the "etiquette".
The OP stands for "original poster" and refers to the thread starter. Finally I like to conclude a post with a closing formula or just a signature including your name. That's the second part of the "etiquette".

What I mean by rude is that questions like "How to read ELF data?" motivates no one to answer as we have to ask for clarification first. If you'd have asked "How do I read custom ELF sections added by GCC using C?" everyone knows exactly what you want just by being a bit more accurate.

Regarding your original question: try readelf first. It'll probably do the trick.

Quoted 8 lines

\Steve

--

Steve Grägert
DigitalEther.de

Thank you, Steve.

I already tried readelf and even sectiondump utility from elfutils-0.130/tests/ I hope there is a solution w/o coding, but may be not :(

Gery
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

author
#6 lore raw
In reply to Glynn Clements
Quoted 13 lines · Glynn Clements
Quoted 2 lines · Gery

How to read in human format data from elf section?

Can you be more specific? What kind of data? What format?

objdump and readelf can provide a lot of information about ELF files, but they can't decode every type of data which could conceivably be stored in an ELF file.

Ok.
i put some structure with gcc attribute to special section named ".my_sec" The structure is like
struct abc {
char *a;
char *b;
};
and global variable is
struct abc klm = { "this is 1st string", "this is 2nd string" };

Which utility can show me just the data of that section?

#7 lore raw
Quoted 8 lines · Gery

i put some structure with gcc attribute to special section named ".my_sec" The structure is like
struct abc {
char *a;
char *b;
};
and global variable is
struct abc klm = { "this is 1st string", "this is 2nd string" };

Like this:

struct abc klm __attribute__ ((section (".my_sec"))) = { "this is 1st string", "this is 2nd string" };

?

Quoted 1 line

Which utility can show me just the data of that section?

	$ objdump -j .my_sec -d foo.o
	foo.o:     file format elf32-i386
	
	Disassembly of section .my_sec:
	
	00000000 <klm>:
	   0:	00 00 00 00 13 00 00 00                             ........

Bear in mind that the structure only contains the pointers, not the strings themselves. String literals used as values are stored in the .rodata section. If you want them elsewhere, you'll have to store them in named variables, e.g.:

	static char s1[] __attribute__ ((section (".my_sec"))) = "this is 1st string";
	static char s2[] __attribute__ ((section (".my_sec"))) = "this is 2nd string";
	struct abc klm __attribute__ ((section (".my_sec"))) = { s1, s2 };

	$ objdump -j .my_sec -d foo.o

	foo.o:     file format elf32-i386
	
	Disassembly of section .my_sec:
	
	00000000 <s1>:
	   0:	74 68 69 73 20 69 73 20 31 73 74 20 73 74 72 69     this is 1st stri
	  10:	6e 67 00                                            ng.
	
	00000013 <s2>:
	  13:	74 68 69 73 20 69 73 20 32 6e 64 20 73 74 72 69     this is 2nd stri
	  23:	6e 67 00 00 00                                      ng...
	
	00000028 <klm>:
	  28:	00 00 00 00 13 00 00 00                             ........
Signature · 1 line
Glynn Clements <[email protected]>
author
#8 lore raw
Quoted 49 lines · Glynn Clements
Quoted 9 lines · Gery

i put some structure with gcc attribute to special section named ".my_sec" The structure is like
struct abc {
char *a;
char *b;
};
and global variable is
struct abc klm = { "this is 1st string", "this is 2nd string" };

Like this:

struct abc klm __attribute__ ((section (".my_sec"))) = { "this is 1st string", "this is 2nd string" };

?

Quoted 2 lines

Which utility can show me just the data of that section?

	$ objdump -j .my_sec -d foo.o
	foo.o:     file format elf32-i386
	
	Disassembly of section .my_sec:
	
	00000000 <klm>:
	   0:	00 00 00 00 13 00 00 00                             ........

Bear in mind that the structure only contains the pointers, not the strings themselves. String literals used as values are stored in the .rodata section. If you want them elsewhere, you'll have to store them in named variables, e.g.:

	static char s1[] __attribute__ ((section (".my_sec"))) = "this is 1st string";
	static char s2[] __attribute__ ((section (".my_sec"))) = "this is 2nd string";
	struct abc klm __attribute__ ((section (".my_sec"))) = { s1, s2 };

	$ objdump -j .my_sec -d foo.o

	foo.o:     file format elf32-i386
	
	Disassembly of section .my_sec:
	
	00000000 <s1>:
	   0:	74 68 69 73 20 69 73 20 31 73 74 20 73 74 72 69     this is 1st stri
Quoted 10 lines
	  10:	6e 67 00                                            ng.
	
	00000013 <s2>:
	  13:	74 68 69 73 20 69 73 20 32 6e 64 20 73 74 72 69     this is 2nd stri
	  23:	6e 67 00 00 00                                      ng...
	
	00000028 <klm>:
	  28:	00 00 00 00 13 00 00 00                             ........

Thank you very much :))

author
#10 lore raw
Quoted 8 lines · Kristof Provost
Quoted 2 lines · Gery

How to read in human format data from elf section?

The readelf and objdump tools should help you.

Kristof

thank you.