public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* RE: [PING][PATCH 2/2] Use file offset instead of virtual address for a function address
@ 2022-05-16 13:13 Balasubrmanian, Vignesh
  0 siblings, 0 replies; only message in thread
From: Balasubrmanian, Vignesh @ 2022-05-16 13:13 UTC (permalink / raw)
  To: Simon Marchi, gdb-patches; +Cc: George, Jini Susan, Kumar N, Bhuvanendra

Can anyone take this up? Simon seems busy.

thanks,
vigneshbalu.

-----Original Message-----
From: Balasubrmanian, Vignesh 
Sent: Tuesday, March 22, 2022 9:52 PM
To: Simon Marchi <simark@simark.ca>; gdb-patches@sourceware.org
Cc: George, Jini Susan <JiniSusan.George@amd.com>; Kumar N, Bhuvanendra <Bhuvanendra.KumarN@amd.com>
Subject: RE: [PATCH 2/2] Use file offset instead of virtual address for a function address

Simon,

Added the readelf output and make check command to the commit message.

For jit-elf-solib.1.so
(readelf -s):
gcc:  000000000700111a    11 FUNC    GLOBAL DEFAULT    9 jit_function_0001
clang:00000000070015d0    11 FUNC    GLOBAL DEFAULT   10 jit_function_0001

(readelf -l):
Type  Offset             VirtAddr           PhysAddr
      FileSiz            MemSiz              Flags  Align
GCC:
LOAD  0x0000000000001000 0x0000000007001000 0x0000000007001000
      0x0000000000000131 0x0000000000000131  R E    0x1000
Offset and VirtAddr are same, so 0x700111a on both file and memory are at same location

CLANG:
LOAD  0x0000000000000510 0x0000000007001510 0x0000000007001510
      0x0000000000000110 0x0000000000000110  R E    0x1000
Here 0x70015d0 in file at 0x70005d0 and in memory at 0x70015d0.

make check command:
make check RUNTESTFLAGS="--all -v -v -v GDB='${GDB_INSTALL_DIR}/bin/gdb'
CFLAGS_FOR_TARGET='-w -gdwarf-4' CXXFLAGS_FOR_TARGET='-w -gdwarf-4'
CPPFLAGS_FOR_TARGET='-w -gdwarf-4' CC_FOR_TARGET='clang'
CXX_FOR_TARGET='clang'" TESTS="gdb.base/jit-elf.exp"

Thanks,
Vigneshbalu

-----Original Message-----
From: Simon Marchi <simark@simark.ca>
Sent: Monday, March 21, 2022 7:19 PM
To: Balasubrmanian, Vignesh <Vignesh.Balasubrmanian@amd.com>; gdb-patches@sourceware.org
Cc: George, Jini Susan <JiniSusan.George@amd.com>; Kumar N, Bhuvanendra <Bhuvanendra.KumarN@amd.com>
Subject: Re: [PATCH 2/2] Use file offset instead of virtual address for a function address

[CAUTION: External Email]

On 2022-03-21 08:19, Balasubrmanian, Vignesh via Gdb-patches wrote:
>
> Follow-up patch to fix test case "jit-elf.exp" when compiled with LLD (clang).
>
> For shared libraries, the "st_value" of the symbol from symtab holds the virtual address for the symbol's definition.
> To make a call to a function using a function pointer, the address in "st_value" works as long as the library is loaded through "dlopen()".
> As we use "mmap()" to map the entire file to the specific address in the memory, we need to find the offset at which the symbol's definition is placed in the file (".so").
> So we use "st_value" and "st_shndx" to find the offset of the function from its section start and then use it to find the file offset for the function.
> With gcc, the test points are not failing because the offset at which function is placed in the mapped ".so" and virtual address at which it is supposed to be loaded are the same.
>
> Thanks,
> vigneshbalu

As with the previous patch, please mention the command line you use to reproduce this, to allow others to try to reproduce it too.

It would be useful to show the relevant differences in readelf output between the test file when linked with ld and when linked with lld.
That would help understand where the difference lies.

Simon

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-05-16 13:13 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-16 13:13 [PING][PATCH 2/2] Use file offset instead of virtual address for a function address Balasubrmanian, Vignesh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).