Sponsored Content
Top Forums Programming Editing or Adding to ELF string tables Post 302255356 by otheus on Thursday 6th of November 2008 09:50:15 AM
Old 11-06-2008
Doing a "man elf" I see that the ELF structure is as follows:
Code:
 #define EI_NIDENT 16

           typedef struct {
                   unsigned char  e_ident[EI_NIDENT];
                   uint16_t       e_type;
                   uint16_t       e_machine;
                   uint32_t       e_version;
                   ElfN_Addr      e_entry;
                   ElfN_Off       e_phoff;
                   ElfN_Off       e_shoff;
                   uint32_t       e_flags;
                   uint16_t       e_ehsize;
                   uint16_t       e_phentsize;
                   uint16_t       e_phnum;
                   uint16_t       e_shentsize;
                   uint16_t       e_shnum;
                   uint16_t       e_shstrndx;
           } ElfN_Ehdr;

Remarks:
Quote:
e_flags - This member holds processor-specific flags associated with the file. Flag names take the form EF_'machine_flag'. Currently no flags have been defined.
So you have 32 bits to fool around with until someone else defines a flag.

Last edited by otheus; 11-06-2008 at 10:51 AM.. Reason: formatting
 

8 More Discussions You Might Find Interesting

1. Linux

editing ELF file

Hello, This is not exactly relevant to Linux kernel but I'm gonna ask any way. Is there any way I can modify a 64-bit ELF object file to make it look like 32-bit ELF object file and link it (using `ld`) with 32-bit ELF file? I tried libelf but was unsuccessful. I had this pretty link... (1 Reply)
Discussion started by: tejuwala
1 Replies

2. Shell Programming and Scripting

string editing in files

Hi all, I'm fairly new to scripting in linux and need some help. I have an file that looks something like this: ~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Some comments # Some comments # Some comments # Some comments # Some comments # Some comments abc:/path/to/somewhere:X... (3 Replies)
Discussion started by: Avatar Gixxer
3 Replies

3. Shell Programming and Scripting

SH Script help. editing string

I have a string that looks like this username|field1|field2|field3 the data has a delimiter of "|" how can i edit field1, keeping the rest of the data the same also how can i edit field2 and 3. (3 Replies)
Discussion started by: nookie
3 Replies

4. Programming

ELF-string table

hello everybody! I want to read the string table of an object file(which is in ELF format). I get the sh_name value but i cant find a way to read the value in the string table that this index represent. I program in C. thanx a lot folks! (3 Replies)
Discussion started by: nicos
3 Replies

5. UNIX for Dummies Questions & Answers

Help with editing string elements

Hi All I have a question. I would like to edit some string characters by replacing with characters of choice located in another file. For example in sample file>S5_SK1.chr01 NNNNNNNNNNNNNNNNNNNCAGCATGCAATAAGGTGACATAGATATACCCACACACCACACCCTAACACTAACCCTAATCTAACCCTGGCCAACCTGTTT... (9 Replies)
Discussion started by: pawannoel
9 Replies

6. Shell Programming and Scripting

Editing part of the string

Hi guys got a problem here hope u all can help me. I learn that sed can actually edit a string but you need to know the old attribute to change to new 1. Example: sed "s/$title:$author/$title:$Nauthor/g" "Harry Potter - The Half Blood Prince:J.K Rowling:40.30:10:50" Each delimiter : represent... (4 Replies)
Discussion started by: GQiang
4 Replies

7. Shell Programming and Scripting

Need help regarding String editing

Hi Geeks I am working on trimming the logs and extracting the XMLs from it. I am facing one problem here. My XML String is ending with ...........Request></Body></Envelope>S/R sometimes there is more then just S/R in the end. I want to delete anything comes after </Envelope>... (3 Replies)
Discussion started by: santy00110011
3 Replies

8. Shell Programming and Scripting

Editing in vi - adding words to a line

i have lines in a file similar to this: results=$(echo Total: ${res} | command | command) now I need to add text before the word "results", but i dont know how to do it. here's what i tried: %s~results=.*echo Total:.* ${7}~PROCESS \; results=.*echo Total:.* ${7}~g the problem is,... (1 Reply)
Discussion started by: SkySmart
1 Replies
elf32_getehdr(3ELF)                                            ELF Library Functions                                           elf32_getehdr(3ELF)

NAME
elf32_getehdr, elf32_newehdr, elf64_getehdr, elf64_newehdr - retrieve class-dependent object file header SYNOPSIS
cc [ flag ... ] file ... -lelf [ library ... ] #include <libelf.h> Elf32_Ehdr *elf32_getehdr(Elf *elf); Elf32_Ehdr *elf32_newehdr(Elf *elf); Elf64_Ehdr *elf64_getehdr(Elf *elf); Elf64_Ehdr *elf64_newehdr(Elf *elf); DESCRIPTION
For a 32-bit class file, elf32_getehdr() returns a pointer to an ELF header, if one is available for the ELF descriptor elf. If no header exists for the descriptor, elf32_newehdr() allocates a clean one, but it otherwise behaves the same as elf32_getehdr(). It does not allo- cate a new header if one exists already. If no header exists for elf32_getehdr(), one cannot be created for elf32_newehdr(), a system error occurs, the file is not a 32-bit class file, or elf is NULL, both functions return a null pointer. For the 64-bit class, replace 32 with 64 as appropriate. The header includes the following members: unsigned char e_ident[EI_NIDENT]; Elf32_Half e_type; Elf32_Half e_machine; Elf32_Word e_version; Elf32_Addr e_entry; Elf32_Off e_phoff; Elf32_Off e_shoff; Elf32_Word e_flags; Elf32_Half e_ehsize; Elf32_Half e_phentsize; Elf32_Half e_phnum; Elf32_Half e_shentsize; Elf32_Half e_shnum; Elf32_Half e_shstrndx; The elf32_newehdr() function automatically sets the ELF_F_DIRTY bit. See elf_flagdata(3ELF). An application can use elf_getident() to inspect the identification bytes from a file. An application can use elf_getshnum() and elf_getshstrndx() to obtain section header information. The location of this section header information differs between standard ELF files to those that require Extended Sections. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Stable | +-----------------------------+-----------------------------+ |MT-Level |MT-Safe | +-----------------------------+-----------------------------+ SEE ALSO
elf(3ELF), elf_begin(3ELF), elf_flagdata(3ELF), elf_getident(3ELF), elf_getshnum(3ELF), elf_getshstrndx(3ELF), libelf(3LIB), attributes(5) SunOS 5.10 19 Jun 2002 elf32_getehdr(3ELF)
All times are GMT -4. The time now is 08:01 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy