Q: How to point a shared object to debug information in GDB without altering the files? I have two files - a shared object file and debug information file.
How can I tell GDB to use the debug information file for that shared object without altering the files, file names or creating links?
Is it even possible?
I just want to tell GDB about it, not to change anything.
EDIT: Here is what I am trying to do (on Ubuntu 16.04, x86_64)
I am taking the libc and libc debug information files from my system, and copy them to a new directory. Then, I preload the moved libc to a process and attach to it with GDB.
    sudo apt install libc6-dbg
    cp /usr/lib/debug/lib/x86_64-linux-gnu/libc-2.23.so debug_file
    cp /lib/x86_64-linux-gnu/libc.so.6 .
    cat << EOF > traceme.c
    #include <stdio.h>
    #include <unistd.h>
    #include <sys/types.h>
    int main(void) {
      printf("trace me:\nsudo gdb -p %d\n", getpid());
      sleep(20);
      return 0;
    }
    EOF
    gcc -o traceme traceme.c
    LD_PRELOAD=./libc.so.6 ./traceme &
    sudo gdb -p 28163

Now, my GDB sessions is this:
    (gdb) info sharedlibrary
    From                To                  Syms Read   Shared Object Library
    0x00007ff8e77c68b0  0x00007ff8e7919ac4  Yes (*)     ./libc.so.6
    0x00007ff8e7b71ac0  0x00007ff8e7b8f810  Yes         /lib64/ld-linux-x86-64.so.2
    (*): Shared library is missing debugging information.
    (gdb) add-symbol-file debug_file 0x00007ff8e77c68b0
    add symbol table from file "debug_file" at
        .text_addr = 0x7ff8e77c68b0
    (y or n) y
    Reading symbols from debug_file...done.
    (gdb) p &main_arena
    $1 = (struct malloc_state *) 0x3c4b20 <main_arena>
    (gdb) p main_arena
    Cannot access memory at address 0x3c4b20
    (gdb) info proc mappings
    process 28163
    Mapped address spaces:

              Start Addr           End Addr       Size     Offset objfile
                0x400000           0x401000     0x1000        0x0 /home/ubuntu/tmp/z/traceme
                0x600000           0x601000     0x1000        0x0 /home/ubuntu/tmp/z/traceme
                0x601000           0x602000     0x1000     0x1000 /home/ubuntu/tmp/z/traceme
                0xff8000          0x1019000    0x21000        0x0 [heap]
          0x7ff8e77a7000     0x7ff8e7967000   0x1c0000        0x0 /home/ubuntu/tmp/z/libc.so.6
          0x7ff8e7967000     0x7ff8e7b67000   0x200000   0x1c0000 /home/ubuntu/tmp/z/libc.so.6
          0x7ff8e7b67000     0x7ff8e7b6b000     0x4000   0x1c0000 /home/ubuntu/tmp/z/libc.so.6
          0x7ff8e7b6b000     0x7ff8e7b6d000     0x2000   0x1c4000 /home/ubuntu/tmp/z/libc.so.6
          0x7ff8e7b6d000     0x7ff8e7b71000     0x4000        0x0
          0x7ff8e7b71000     0x7ff8e7b97000    0x26000        0x0 /lib/x86_64-linux-gnu/ld-2.23.so
          0x7ff8e7d91000     0x7ff8e7d96000     0x5000        0x0
          0x7ff8e7d96000     0x7ff8e7d97000     0x1000    0x25000 /lib/x86_64-linux-gnu/ld-2.23.so
          0x7ff8e7d97000     0x7ff8e7d98000     0x1000    0x26000 /lib/x86_64-linux-gnu/ld-2.23.so
          0x7ff8e7d98000     0x7ff8e7d99000     0x1000        0x0
          0x7ffe53a5a000     0x7ffe53a7b000    0x21000        0x0 [stack]
          0x7ffe53b3a000     0x7ffe53b3c000     0x2000        0x0 [vvar]
          0x7ffe53b3c000     0x7ffe53b3e000     0x2000        0x0 [vdso]
      0xffffffffff600000 0xffffffffff601000     0x1000        0x0 [vsyscall]

For some reason, the main_arena symbol is not within the mapping of the libc.

A: 
How can I tell GDB to use the symbols file for that shared object without altering the files, file names or creating links? 

(gdb) info shared

Will tell you at what address your foo.so is loaded. Say it's $addr.
(gdb) add-symbol-file /path/to/foo.so.debug $addr

will tell GDB to add debug symbols for foo.so from foo.so.debug
Update:

(gdb) p main_arena
Cannot access memory at address 0x3c4b20

I am pretty sure this is a bug in GDB. You are correct: it's not relocating the .data section when it should.
Fortunately, there is a workaround:
(gdb) add-symbol-file debug_file 0x00007ff8e77c68b0 -s .data 0x7ff8e77a7000

(The first address is from info shared. The second address is from info proc map for the (first) address where libc.so.6 is loaded.)
