Algorithms, Theory, Spirituality, Life, Technology, Food and Workout : trying to sort these deterministically in $\Theta(1)$ time (constant time).
Sunday, December 31, 2006
[PERSONAL] Lets solve the problem.....
I guess I have become a little bit more matured now, because I have to do things more responsibly now. I have a big responsibility now, I don't worry about it but I welcome it into my life, I'am ready to solve it and all the consequences...I will never run-away from the problem. But I need to be a little bit more practical also, well for any problem now there is no way out except to solve it.
So...LETS SOLVE THE PROBLEM RATHER RUNNING AWAY FROM IT....
And when you are solving problem's you need to be very methodological...I know its all spelling mistakes my blog...I may not be a great genius but I'll try my part to solve the problem. And when I solve the problem there will be no shortcuts.
Frankly I have been not getting great results for my Dynamic Programming based Border Length Minimization Problem. What to do I don't know I cannot really fake up any results. It's bad really bad. I leave it
Today puppy came out, she has been not liking the place where she is living but she has to for sometime, she should feel free and I'am a very lucky guy interms of that. I will always care for puppy and will solve the problem and not run away from it.
Happy new year 2007.....LETS SOLVE IT....that's the quote of this year.
Take care guys and keep having fun.....mean while I will lay back and keep thinking....
Friday, December 08, 2006
[NON-TECH] Travelling to india....
I should be indeed thankful to sudha for a ride from Storrs to Stamford. When I reached Stamford it was a little difficult to find out where ravi is and finally found ravi, went to circuit city to buy some stuff, later toured manhattan,brooklyn went to a great Italian restaurant, I really liked the hot bread and that olive oil to eat the bread, I never tried any Italian food apart from the normal pizza. Its really windy today in New York with -7 Centigrade, really had a hard time pulling all my luggage into the airport.....well found a wireless connection at the food court here, IT WORKS...well I'am writing this from that connection only, I need to wait till 4:00 PM to take my flight. Its a long wait.
Good that I got some charge on my laptop so that I can do some work today, I have many things pending, mac,tim,ion and raj. I need to get all the work done in this break good if I could make a proper schedule to fix up all the things.
Lets see how things work......luv....Vamsi
Thursday, December 07, 2006
I have not started any packing
Sunday, November 26, 2006
[TECH] Algorithm to find euler circuit in a graph in O(|E|)
Important observation I found is that, if we delete a cycle (delete all the edges which form a cycle) from the graph which has a Euler circuit, the property of the graph still remains, i.e the necessary and sufficient condition for the graph to have a Euler cycle is that every vertex should have even degree. And also there has to be a cycle at every vertex.
INPUT: G =(E,V) v = veuler_cycle = NULL; while(|E| > 0){ /*Find a cycle in G, start the search at v, returns c0 around which cycle is formed*/ c0 = FIND_CYCLE(G,v); v = GET_NON_ZERO_DEGREE_VERTEX(c0); /*Above can be done in constant time, using some space while finding the cycle */ MERGE(c0,euler_cyle); /*constant time operation, put c0 after an edge e1 in euler cycle which ends at vertex 'v', we can just remember the position of v n euler_cycle every time we merge*/ }
[TECH] Building tags on the complete source code...
I see that sometimes
$ctags -R *don't work. I just typed
$ctags -R *
in my cygwin it crashed
ctags.exe.stackdum. Well now the question is how do I build the tags on the complete source recursively if
-Rdon't work, we can use the the following to build the tags
$find . -name "*.c" -exec ctags -a \{\} \; -print; sort tags > tags1; mv tags1 tags;
The -a option appends to the existing tags file build
I initially thought that ctags keeps some seek information of the file in tags file,but just was amazed its a 3 column multientry text file, the first column is the tag which you are searching, second column is the file where is tag is and the most interesting part the 3 column is the search string for vim....hmmm see every one takes advantage of the plethora of things vim can do :)
Make_bp_profile ./RNAlib/ProfileDist.c /^PUBLIC float *Make_bp_profile(int length)$/ Make_swString ./RNAlib/stringdist.c /^PUBLIC swString *Make_swString(char *string)$/
.........luv.......Vamsi
Saturday, November 25, 2006
[TECH] Never use a file stream for lookahead reading while using lex.....
Just got the parser working....I did a lot of modification to mac's code, especially the grammar rules which have the lookahead information while parsing. The code tries to read from the
yyinfile stream of lex, but that is really pathetic because lex code is now optimize and it position in the lex buffer may not correspond to the position in the filestream...well this is what is the bug in code, well it took a while to fix. But its a good one.
I added lookahead rules
(st,bt)\n[\+]{linenum++;}for lookahead extensions and comments in the spice syntax.
(st,bt)\n[\*].*${linenum++;}
Tomorrow I'll get the layout printed ,,,,,,
Apart from this folks from india called and were telling me about the issues regarding priya pickles, well I think its really a slander against Ramoji Rao, any way I support this guy...yes may be after that great 3 day party at ramoji film city makes me baised, I guess you too will be baised once you receive that wonderful hospitality at hotel sitara in ramoji film city...when our team (verification group) went out there I saw mithun chakraborthy
..........luv..........Vamsi
Thursday, November 23, 2006
[TECH] SPICE layout generator.......
I have been a bit of slackish this week, but sure I want to start running soon.
Last night I read about the BPlane (Binned Plane datastructure used in micromagic, I need to implement that in magic soon).
Tonight, I thought about backing up my CVS repository regularly into my external hardrive, so that I can keep all my projects safe.
SPICE Layout generator
My new project, which generates cell layout from by reading from the SPICE files (transistor netlist) directly. I need to rewrite some of the code for the algorithm which tries to find the EULER trace in the transistors graph (and also its p-stack dual graph). Its exiting for me start it today....I'am in love with my life for the first time.......writing code is what I loved apart from all other tensions in life I love it
Tomorrow morning I'll be running for the sale in circuit city and best buy
[TECH] SRM327
http://www.topcoder.com/stat?c=problem_statement&pm=6871&rd=10007
/* * topcoder_class1.java * * Created on November 22, 2006, 1:41 AM * * To change this template, choose Tools | Template Manager * and open the template in the editor. */ package topcoder_srm1; /** * * @author vamsi */ import java.lang.Math; public class NiceOrUgly{ private boolean checkNice(char[] s_arr,int len){ int vcount=0; int ccount=0; int i; for(i=0;iI challenged some guy in this SRM got 50 bonus points.
..........luv......vamsi
Monday, November 20, 2006
[TECH] DAG's and Dynamic Programming......
Directed Acyclic Graph (DAG), directly embeds into dynamic programming....as from Vazirani's notes, the useful property of the DAG is that its nodes can be linearized (topologically). So if we process these nodes in the topological order we have sub-problems solved and the solution can be used for the next level. In the simple example of shortest path, we need (u1,v) , (u2,v) are the edges adjacent on the node v. To solve the shortest path problem we need the shortest path to u1, u2 to get the shortest path to v. The wonderful property of the DAG's is that if we start with the topological SOURCE (may be hypothetical by adding 0 weight edges), we are sure that we solved u1,u2 before solving v (if we process the nodes in topological order)
Longest monotonic subsequence in a given sequence, suppose the given sequence is '5,2,8,6,3,6,9,7' (The longest monotonically increasing sequence) in this is 2,3,6,9.
On the first look, it appears that it doesn't have sub-optimality inside it. In the sense take a subsequence '5,2,8' the longest monotonically increasing subsequence in this is is (5,8) or (2,8) but neither (5,8) and (2,8) is not in the overall longest monotonic subsequence, so the question is how dynamic programming works here??.....well people don't talk about the sub-optimality here......but still this can be solved by dynamic programming...
Let me restate the principle of optimality here...."If a optimization problem involves of sequences of decisions d1,d2,d3,d4...dn . The principle of suboptimality states that what ever decision you make initially the rest of the decisions should still optimize whats remaining after making decision d1...i.e
Any way I wrote the following code segment , S[i] = length of the longest monotonic subseqence ending at index i, input is a array of integers A[i].
global_max_length=-INFINITY;
PATH[N];
for(i=0;i
global_max_length , returns the length of the longest monotonic increasing sequence, and also prints the sequence
Apart from this life has been very cold, man today was REALLY_ __FREEZING__ here, I have cold the damn cold, I cannot drink cool drinks, eat any cold stuff it sucks......Well , I'll be going to India soon meet swapna,chamu...just talked to chamu on the phone, hope to see her and swappy soon...............THE LIFE GOES ON ON ON...by the way the GYM is closed till 26th and its cold outside I cannot even jog its really HELL out here
With love ...............Vamsi...............Tuesday, November 14, 2006
[TECH] Channel Router for cell synthesis......
Its quite an effort to get this thing working.....started on saturday night , worked on sunday, and monday night its done
perl had lot of kookups especially my $a,$b and my ($a,$b) are not the same, I pulled it from the manual. sometimes its really hard to fix this kind of errors, thanks for that wonderful debugger 'perl -d' , its really great to work with.
But I did'nt see if perl debugger has a backtrace kind of facility? just a gdb?
Life apart for my passion of the CGEN2MAGIC project, is quite slow need to study a lot about that Border Minimization Problem, also got the home work done on parallel algorithms and network flows.
I guess I'have started loving algorithms/problem solving...its really kewl
Take care....HAPPY CHILDRENS DAY.
Saturday, November 11, 2006
[TECH] Setting up VNC on LAN
Today I got my laptop dell-inspiron-640m, I have linux desktop running fedora connected to a wireless router which my friend uses, so totally we have 3 computers connected to the wireless router. Actually we have cloned the MAC address of my desktop onto the wireless router. Now I want to use my laptop and start working with vnc on my desktop. By default the port 5901 was firewalled, I had to setup the firewall to accept the tcp:5901. After which I had the probelems with the window manager, by default kde starts the twm& . So I edited the xstartup file to get the kde.
kwin & kdesktop & kicker &
You need all the three things to get the kde desktop up and running
Well thats all the infrastructure work, now I'am back to write the CHANNEL ROUTER for CGEN which I have not worked on for the last three days, due that motif-algorithm which I have been working on, last week I also had the polynomial algorithm for FINDING OUT ALL THE CUTS in the network flow graph.
Take care guys, I also had a long chat with swapna and that was really wonderful.
Monday, November 06, 2006
[TECH]Crippled mmap
I was trying to use a anonymous memory mapping to use in the first version of the Tile database memory manager which I was writing,
mmap(void *start_address,size_t length,int prot,int flags,int fd,off_t offset)
. I had prot = MAP_ANONYMOUS , (I thought its equivalent to MAP_ANON | MAP_PRIVATE , the man page says MAP_ANON , is depreciated). Well any way I got it fixed by MAP_ANONYMOUS | MAP_PRIVATE.Last time I had problem with this syscall is when I need to mmap to actual address's , i.e the start_address argument is not NULL, once again WHEN YOU DO A MMAP FOR A STATIC ADDRESS YOU NEED TO HAVE OFFSET OF THE FILE ALIGNED TO THE PAGE BOUNDARY.
Friday, October 27, 2006
Fridays seems to coming very quickly.
Sunday, October 08, 2006
A melancholic 24th birthday....but I think I have started to think
The other day I was returning back from the bus I broke within my heart, I knew I was a little more capable of getting into a better school, all my friends I have studied are now in better schools and me at UCONN making that hasty desicion to move from UCR....
I could certainly feel that I have a really hard luck, I don't know I think I have a nac for the SELF PITY for myself...first time in my life I feel I need to compromise, really I feel very low every day dont know why. May be I'am missing people very much, more than I could ever think of...mom told me to come back to india if I dont feel good here....you know at the same time I feel that by doing that I'am running away from the problem, ok now I'am in the problem a big complex problem the only way I can overcome this just by solving it....I say to myself I'AM TRANSFORMING TO MYSELF TO ATTAIN STRENGTH AND ENERGY TO SOLVE PROBLEMS....God please give me STRENGTH to face this problem. I know that I'am not a genius to come up with some idea to create a revolution but I'am trying sincerely...I don't do things to impress any one...
I don't feel any selfish any more the other day I was thinking about the change in me, I don't know I started feeling happiness in others happiness, sometimes I just did things that people are happy, although I don't expect anything from them.....
What ever it might be its really a rocky ride ahead of me....
Sunday, September 10, 2006
[TECH] Buffer insertion and signal integrity.
Well its a well studied problem after all this should have been done, but I'am loving it application of algorithms. The basic principles I need to stick to is honesty. I want to carry on like this feel good about it every day I sleep.....Well Its becoming a habit for me.
Delay modeling is a totally different research area, but the classic paper assumes a simple Elmore delay modeling...I guess I need to design a good algorithm which strikes a right balance on delay estimation and timing minimization.
Apart from that I wanted to see how much I can think backward. I tried to recall what I have done in my last few new years.
2006--> Partied in escape pub, hyderabad [I got a wildest dancer prize :)]
2005--> Freaked out on the roads boozing, my friend veeru with me he was annoyed a little that day :(
2004--> Well I was interning at Oracle this time, drank bacardi and made a mess, I guess I was frustrated that I was not having a grilfriend :))
2003--> Well I was with my parents in railclub. 2002--> I think I did nothing, but tasted beer for the first time...
Cheers! Vamsi
Saturday, September 02, 2006
Yes I cannot cheat myself......I never had...I'am proud that I was myself
Although I couldnt blame the professor for bringing me this far I need to blame myself. I know I want to do more fundamental things rather then jumping in something which I claimed to know, I told people that I had been working in a mixed signal simulation tool development. The word DEVELOPMENT here meant a different thing, I never really wrote anything core, what I was doing was just doing all system realted work to make the tool work. Well I guess I was somewhat doing well in what ever I had done. When I got admission at UCR with this background I started feeling guilty, I want to make up for it by looking into books on how fastspice was implemented, although I had a very high level of understanding on how fastspice worked I thought I could make it and decided to come to riverside. But when I talked to the professor I felt bad that he want to make use only programming skills which I had, he never expected me to design new algorithms, create new paradigms to revolutionize the research. Just at this moment I decided to leave this place RIVERSIDE. I CANNOT JUST DO SOMETHING JUST TO BELONG TO A UC AND BELONG TO CALIFORNIA AND TELL THAT PROUDLY FOR ALL THE PEOPLE OVER THAT WORLD...........I THOUGHT I'AM CHEATING MYSELF I CANNOT TAKE IT I DECIDED TO MOVE TO UCONN.
I know Dr.Raj was a great prof but people dont want me to go there when I said I got admit in a UC, well now I really dont give a damn shit on which university I belong I want to really learn the ART OF ALGORITHM DESIGN and apply in much more elegant manner with more CS pedagogy.....I FELT IF I COULD MASTER THE ART OF SOLVING PROBLEMS WITH A COMPUTER.....IT DOESNT KEEP MYSELF JUST TO CAD I CAN APPLY MY ALGORITHM DESIGN SKILLS TO ANY PROBLEM....I'AM EXCITED TO WORK UNDER DR.RAJ....
Well this is excatly what happens in pheadrus's book.......BUT I ADMIRE MY GUTS TO NOT TO CHEAT MYSELF EVEN TILL THE LAST MINUTE....ITS NEVER TO LATE TO GET IT BACK....,,,,,,NOW I NEED TO LIE SAYING SOMETHING TO THE OLD PROF AND MAKE SURE THE BRIDGES ARE NOT BURNT......
Tuesday, June 27, 2006
Problems for which "Principle of Optimality" does not hold??
o If the aim of a descision sequence(d1,d2,d3,d4........dn) is to minimize/maximize some objective function, then for any di , 1<=i<=n , the subsequence (di,di+1,....dn) should also minimize/maximize the objective function respectively.
o One problem for which the "Principle of Optimality" is when we have a KNAPSACK problem which both negative and postive profits, we might well ask ourself if a Item has negative profit then why we select that Item? well you might have forgotten the other factor which is the size of item...
I dont know of any other problems.
Tuesday, June 20, 2006
[NON-TECH] Marriage is buying conditional LOVE its for loosers, unconditional LOVE is what winners get.
I just think its bullshit if you marry you get to loose the fire in you, I just don't beleive in SETTLING in life. I just believe that "ITS JUST A JOURNEY which goes on and on and on......." , I don't think there is a destination where you think you have reached the NIRVANA and just bullshit marry and have SEX.....
I live a life for myself, I just beleive I just want to be happy without causing others any trouble (ofcourse envy and jealous are some thing I cannot help).
Any way reiterating things my aim is just to create technology for real good, not for building research papers or making a huge sum of money. Feel technology as an art and contribute without any motive. Some time I see that people tend to use my high energy levels, thats what I tell myself "Don't take it damn seriously, when can people expolit something ? if something is in abundance (high energy here) people exploit it. If I crib about people who expolit I'll loose my abundance of energy, I want more people to exploit me so that indirectly they are helping me to create a lot of abundance of energy to create things...."
Well if I keep all things aside (all but technology), people's egoes, money, holidays etc... life just ROCKS for me I love it.
Friday, June 09, 2006
Yet another memory corruption on linuxipf, new FAT POINTERS on IA-64
Well IA-64 had been a real good thing to work with, it has a real helpful kernel maintainers especially at ia64-linux@kernel.org, Well these guys gave me a lot of insight into several things RES backing store [60000fff80000000-60000fff80004000 rw-p 0000000000000000 00:00 0] this segment maps for every process on IA64 kernel.
Well other intresting thing is about the FAT POINTERS, the IA64 ABI mandates that the call to functions should be done via FAT POINTERS. do a google search if you want more details about this....
All in all a good productive week also fixed a couple of HSIM issues..
I really love it.
Wednesday, June 07, 2006
IA64 different virual memory layout
Thursday, June 01, 2006
How SIGINFO structure makes our life easy...
Writing siginfo handlers will help you get the culprit virtual address which causes the problem. See the following handy code.
======================================= struct sigaction action; action.sa_sigaction = my_handler; action.sa_flags = SA_RESTART | SA_SIGINFO | SA_RESETHAND; if(sigaction(SIGBUS,&action,NULL)<0) { printf("Cannot register handler\n"); } HANDLER: void my_handler(int sig,siginfo_t *siginfo,void *ucontext){ if(sig == SIGBUS){ printf("SIGBUS Caught\n"); switch(siginfo->si_code){ case BUS_ADRALN: printf("SIGBUS due to address alignment at %x\n",siginfo->si_addr); break; case BUS_ADRERR: printf("SIGBUS due to BUS_ADRERR%08lx\n",siginfo->si_addr); break; case BUS_OBJERR: printf("SIGBUS due to hardware\n"); } qCheers! V.
Wednesday, May 31, 2006
Gives some solace.....
Sunday, May 28, 2006
ELF CORE file optimizations in Linux, problems with non standardization of core files.
o After my deep observation of the fact why core files have some program headers which have phdr.p_filesiz==0, found that David Miller, had added some changes to the core file which the linux kernel dumps, the optimizations are ofcourse to reduce the core file size, so I guess these guys are taking off the text part of the executable and the text part of the dyanmic shared libraries.
o My Question is WHY?? WHY?? do these people just dont try to stick to standards (if some standard dont exist they should create one, and once they enhance some stuff then update the standard rather than just flushing the changes into the code), in this opensource community this is really bad that the current standard of the core file depends on few induviduals.
I checked the PHDRS (readelf --segments) the following are the PHDRS of the core.exe
================================= Elf file type is EXEC (Executable file) Entry point 0x8048364 There are 11 program headers, starting at offset 52 Program Headers: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align NOTE 0x000194 0x00000000 0x00000000 0x00a48 0x00000 0 **LOAD 0x001000 0x08048000 0x00000000 0x00000 0x01000 R E 0x1000 LOAD 0x001000 0x08049000 0x00000000 0x01000 0x01000 RWE 0x1000 LOAD 0x002000 0xf649b000 0x00000000 0x01000 0x01000 RWE 0x1000 **LOAD 0x003000 0xf649c000 0x00000000 0x00000 0x132000 R E 0x1000 LOAD 0x003000 0xf65ce000 0x00000000 0x03000 0x03000 RWE 0x1000 LOAD 0x006000 0xf65d1000 0x00000000 0x03000 0x03000 RWE 0x1000 LOAD 0x009000 0xf65e8000 0x00000000 0x01000 0x01000 RWE 0x1000 **LOAD 0x00a000 0xf65e9000 0x00000000 0x00000 0x15000 R E 0x1000 LOAD 0x00a000 0xf65fe000 0x00000000 0x01000 0x01000 RWE 0x1000 LOAD 0x00b000 0xfeffe000 0x00000000 0x02000 0x02000 RWE 0x1000 ====================== ============= o As I said earlier I see some of the PHDRS are having FileSiz as zero, the first (1st **ed ) PHDR which is having virtual address 0x08048000 (this is obviously) the start of the text of the program, and its not having any memory in the core file. o The other PHDRS for which FileSiz is zero correspond to the dynamic shared objects (.so) text , example in the above we see (2 **ed ) PHDR with VirtAddr as 0xf649c000 , so this means the text of some shared .so has been mapped here. o I had a question about the memory mapping with permissions r--s or r--p (gconv used by glibc gets mapped like this some time) , so does the core file contains this information of the memory mappings? IMO this content is also mapped as PROGBITS I guess not sure. o Is there a way I can findout the standard which the OS follows to write the core file? No absolutely no, solaris dumps the entire core. o Rather than depending on the OS core file, hows your opinion on writing out all the mappings form /proc/ /maps as PT_LOAD into a elf formatted file of type ET_EXEC, do you think this works? rather than converting core file to exe? Should I start working to write the standard. ======================== =============================== #include #include #include #include #include #ifndef __64_BIT__ #define __32_BIT__ #endif #ifdef __32_BIT__ #define ELF_EHDR Elf32_Ehdr #else #define ELF_EHDR Elf64_Ehdr #endif ELF_EHDR place_holder; /*Chages the elf_header in the file with ptr */ int ChangeElfHeader(int CoreFd, int WriteFd, unsigned long vaddr){ unsigned long got_len=0; if((got_len = read(CoreFd,&place_holder,sizeof(ELF_EHDR))) != sizeof(ELF_EHDR)){ perror("Unable to read the ELF Header::"); exit(1); } /*Change the ET_CORE tto ET_EXEC*/ if(place_holder.e_type == ET_CORE) { place_holder.e_type = ET_EXEC; } else { fprintf(stderr,"The file is not of ELF core file"); exit(1); } /*Change the entry */ place_holder.e_entry = vaddr; /*Write back the header*/ got_len = 0; if (( got_len = write(WriteFd,&place_holder,sizeof(ELF_EHDR))) != sizeof(ELF_EHDR)) { perror("Unable to write the header::"); exit(1); } return 1; } static void finishWriting(int coreFd, int writeFd) { unsigned char write_buffer[4*1024]; int got_len = -1; while( (got_len = read(coreFd,write_buffer,4096)) != 0) { if(write(writeFd,write_buffer,got_len) != got_len ){ perror("Unable to to write the length which was read:"); exit(1); } } close(writeFd); close(coreFd); } int main(int argc,char* argv[]){ int coreFd; int writeFd; unsigned long vaddr; if( argc < 3 ) { fprintf(stderr,"Usage core2elf core.file exe.file.name"); exit(1); } if( (coreFd = open(argv[1],O_RDONLY)) < 0) { perror("Unable to open the core file:"); exit(1); } if ((writeFd = open(argv[2],O_WRONLY| O_CREAT)) < 0) { perror("Unable to open the write file::"); exit(1); } sscanf(argv[3],"%lx",&vaddr); ChangeElfHeader(coreFd,writeFd,vaddr); finishWriting(coreFd,writeFd); } ========================= ===========================
Sunday, May 07, 2006
My F1 student visa.....
Saturday, March 18, 2006
Life through ELF loaders.....
o My current problem boils down to create a executable from the running program itsself. To get this working I have been studying the kernels code in 'fs/binfmt_elf.c' especially code around 'load_elf_binary', The following are my finding might find it useful (for myself to look after some time).
-----1.)The kernels loader does not do any great , it basically gets all the metadata from the elf headers and just does the dirty work of just mapping and transferring the control. The summary of what excatly the kernel does is
a.) set the entry point from the (Elf32_Ehdr *).e_entry as the start jump to the program
b.) Load all the segments (PHDRS) the loader just deals with the program headers, it does not use any section headers. It loads all the segments with type (Elf32_Phdr *).type == PT_LOAD. If you do a 'readelf --segments a.out' you can see the segments
(gdb) shell readelf --segments a.out Elf file type is EXEC (Executable file) Entry point 0x80482a0 There are 7 program headers, starting at offset 52 Program Headers: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align PHDR 0x000034 0x08048034 0x08048034 0x000e0 0x000e0 R E 0x4 INTERP 0x000114 0x08048114 0x08048114 0x00013 0x00013 R 0x1 [Requesting program interpreter: /lib/ld-linux.so.2] LOAD 0x000000 0x08048000 0x08048000 0x004cc 0x004cc R E 0x1000 LOAD 0x0004cc 0x080494cc 0x080494cc 0x00104 0x00198 RW 0x1000 DYNAMIC 0x0004dc 0x080494dc 0x080494dc 0x000c8 0x000c8 RW 0x4 NOTE 0x000128 0x08048128 0x08048128 0x00020 0x00020 R 0x4 STACK 0x000000 0x00000000 0x00000000 0x00000 0x00000 RWE 0x4 Section to Segment mapping: Segment Sections... 00 01 .interp 02 .interp .note.ABI-tag .hash .dynsym .dynstr .gnu.version .gnu.version_r .rel.dyn .rel.plt .init .plt .text .fini .rodata .eh_frame 03 .data .dynamic .ctors .dtors .jcr .got .bss 04 .dynamic 05 .note.ABI-tag 06 (gdb)
c.) One more important thing about how excatly it sets the 'brk' base I guess to set up the 'brk' base the kernel only (also see the copy of the email posted on linux-kernel mailing list
Hello All, I have been working on an idea of creating an executable from a running process image. MOTIVATION: Process migration among the nodes in distributed computing, checkpointing process state. BASIS: The basis of my idea would be update the existing executable with extra PHDRS (Program Headers) with type PT_LOAD and each of these headers corresponding the vaddr mapping from /proc//maps. I have done some basic study of kernels loders code in 'fs/binfmt_elf.c' especially code in 'load_elf_binary' function, the following is my understanding. ----------------------------- bss=0; brk=0; foreach (phdr in elf_header){ if(phdr->type == PT_LOAD){ if( phdr->filesize <>memsize){ /* Segment with .bss, so update brk and bss*/ } else { /* Just map it*/ } } /*Update brk bss*/ } ------------------------------------ from the above the kernel is updating brk, thus creating the start of sbrk(0) only when it sees a PT_LOAD segment with filesize less than memsize. The kernel will set brk base i.e sbrk(0) to the value phdr.vaddr+phdr.memsize of the last PT_LOAD segment its mapping? so do I need to reoder my PT_LOAD segments so that the heap goes as the last PT_LOAD segment? Is there any way we can tell the elf loader to force the vaddr for sbrk(0) i.e brk base ? Let me know your suggestion on this idea? Really appreciate your valuable comments. Sincerely, Vamsi [PS: I dont know if some one has already implemented this idea??]
-----2.) Also found out that the virtual address's for the sections in the segments are the excat virtual address if they are within the range of corresponding phdr. that is I found that if .bss section has a vaddr of 0x00001000 and .data has 0x00000010 and there is a corresponding mapping (rw-p) in /proc//maps as 0x00000004-0x00010000 which includes segment to section mapping in the order '.data ...... .bss' note that .data will not start at 0x00000004 it infact still starts at 0x00000010 same with .bss. This is very logical since if the kernel's loader changes the mapping of the .data section the all the code referencing the virtual address's has to be changes. So the segments in /proc//maps file are not the segments excatly corresponding to 'readelf --segments a.out' infact they are bigger carousels with wrap around the the excat segment address's for page alignment.
More ideas next time..........
Cheers
Vamsi
Wednesday, February 08, 2006
Presumption is a Programming Perversity..... [Discovery of new GUMPTION TRAP]
I cannot imagine this presumption cost me 2 valuable weeks of time, which I wasted in meeting my bullshit girlfriend who has been bugging me all the way. Suddenly today after fight with her I went back (Filled with gumption) and got time to look at the code which I had left for 2 weeks with a presumption which I made that night when I saw that the debugger (gdb) itself crashed when I tried to something tricky on that sleepy night, I lost my gumption that night and presumed that its a very big problem, I was telling my self "Come on man there should be something really nasty in the code causing the debugger to crash............huh " this presumption made me very apprehensive to touch the code for two weeks :( , I have screwed the schedule with this just a crazy apprehension.
Rather than attacking the problem, I took a conventional root of comfort bought a TV to play on the XBOX with I bought it did'nt work researched on the voltage differences between india and U.S wasted my time and also wasted......Hey this reminds the the time when pheadrus took a break from answering the basic question of QUALITY, rather he went and married and forgot about QUALITY for sometime until he started thinking about it again and the mistake he made of the Presumption that QUALITY cannot be defined and took a comfort root of the question haunting him....later on he realized how big mistake it was left his wife and went on the journey of QUALITY again.
Yes even me also with this crazy prejudice lost my QUALITY track for a while.....But "Its never too late to get back..." (My Old Slang :)) ). Today I discovered a new "GUMPTION TRAP" ---> "PRESUMPTION and APPREHENSION" , probably we should have a course "GUMPTIONOLOGY101" in our school to know about all these traps rather than discovering them ourself. The problem was very silly when I got back into my QUALITY track its just that "I have been using old instructions and accessing/writing into a virtual address of the program in optimized mode when the instructions/code came from debug executable" (May be u should send me an email to explain the problem), but in a lucid manner its a very basic problem which I overlooked, its ok as long as I discover more gumption traps like this...........One thing is never presumption is bad and also evil....its a LOW QUALITY LIFE.
So today Its the 9th revision of the file just cvs commited and wanted to save my feeling to my harddisk before I forget about it......
Take care guys.....
Its always a journey no destination, you will get of QUALITY track when you say you have reached a destination
Reminds me of a quote from prisig "When you are filled with gumption there is no one stopping you from fixing the motorcycle"
Keep going guys make it a habit and enjoy it