--- gdb_src.orig/gdb/findvar.c 2012-06-05 19:20:49.000000000 +0530 +++ ./gdb_src/gdb/findvar.c 2012-08-17 16:21:54.000000000 +0530 @@ -501,6 +501,7 @@ default_read_var_value (struct symbol *v SYMBOL_OBJ_SECTION (var)); else addr = SYMBOL_VALUE_ADDRESS (var); + addr = addr + temp_fpic_addr; break; case LOC_ARG: @@ -610,6 +611,7 @@ default_read_var_value (struct symbol *v SYMBOL_OBJ_SECTION (msym)); else addr = SYMBOL_VALUE_ADDRESS (msym); + addr = addr + temp_fpic_addr; obj_section = SYMBOL_OBJ_SECTION (msym); if (obj_section --- gdb_src.orig/gdb/remote.c 2012-07-02 20:59:34.000000000 +0530 +++ ./gdb_src/gdb/remote.c 2012-09-11 14:50:08.000000000 +0530 @@ -3151,6 +3151,7 @@ get_offsets (void) else if (data && data->num_segments == 1) { segments[0] = data->segment_bases[0] + text_addr; + segments[1] = data->segment_bases[1] + data_addr; num_segments = 1; } /* There's no way to relocate by segment. */ --- gdb_src.orig/gdb/symfile.c 2012-06-27 01:44:02.000000000 +0530 +++ ./gdb_src/gdb/symfile.c 2012-08-17 16:19:09.000000000 +0530 @@ -3757,6 +3757,16 @@ symfile_map_offsets_to_segments (bfd *ab - data->segment_bases[which - 1]); } + /* Below code to handle data address in fPIC mode, offset from .text */ + temp_fpic_addr = abfd->sections->size; + if(segment_bases[1] > segment_bases[0]) + temp_fpic_addr = segment_bases[1] - (segment_bases[0] + temp_fpic_addr); + else + { + temp_fpic_addr = (segment_bases[0] + temp_fpic_addr) - segment_bases[1]; + temp_fpic_addr = 0 - temp_fpic_addr; + } + return 1; } --- gdb_src.orig/gdb/symfile.h 2012-07-20 23:29:05.000000000 +0530 +++ ./gdb_src/gdb/symfile.h 2012-08-17 16:17:56.000000000 +0530 @@ -72,6 +72,8 @@ struct psymbol_allocation_list int size; }; +CORE_ADDR temp_fpic_addr; + /* Define an array of addresses to accommodate non-contiguous dynamic loading of modules. This is for use when entering commands, so we can keep track of the section names until we read the file and can