[PATCH 6/7] [gdb/testsuite] use -Ttext-segment for jit-elf tests
Simon Marchi
simark@simark.ca
Mon Mar 23 03:03:47 GMT 2020
Just some formatting nits:
> @@ -96,6 +89,15 @@ update_locations (const void *const addr, int idx)
> #define MAIN main
> #endif
>
> +/* Must be defined by .exp file when compiling to know
> + what address to map the ELF binary to. */
> +#ifndef LOAD_ADDRESS
> +#error "Must define LOAD_ADDRESS"
> +#endif
> +#ifndef LOAD_INCREMENT
> +#error "Must define LOAD_INCREMENT"
> +#endif
> +
> /* Used to spin waiting for GDB. */
> volatile int wait_for_gdb = ATTACH;
> #define WAIT_FOR_GDB while (wait_for_gdb)
> @@ -137,7 +139,8 @@ MAIN (int argc, char *argv[])
> exit (1);
> }
>
> - const void *const addr = mmap (0, st.st_size, PROT_READ|PROT_WRITE,
> + void* load_addr = (void*) (size_t) (LOAD_ADDRESS + (i-1) * LOAD_INCREMENT);
> + const void *const addr = mmap (load_addr, st.st_size, PROT_READ|PROT_WRITE,
> MAP_PRIVATE, fd, 0);
We try to use the same style in code for tests as code for GDB itself. So
void* load_addr = (void*) (size_t) (LOAD_ADDRESS + (i-1) * LOAD_INCREMENT);
should be
void *load_addr = (void *) (size_t) (LOAD_ADDRESS + (i - 1) * LOAD_INCREMENT);
I think we should be using MAP_FIXED in this mmap call, to make sure the mapping ends
up exactly at `load_addr`, and check the result to make sure it's not MAP_FAILED.
> struct jit_code_entry *const entry = calloc (1, sizeof (*entry));
>
> @@ -147,7 +150,7 @@ MAIN (int argc, char *argv[])
> exit (1);
> }
>
> - update_locations (addr, i);
> + update_name (addr, i);
>
> /* Link entry at the end of the list. */
> entry->symfile_addr = (const char *)addr;
> diff --git a/gdb/testsuite/lib/jit-elf-helpers.exp b/gdb/testsuite/lib/jit-elf-helpers.exp
> index f63694b8f5..cff47ec73c 100644
> --- a/gdb/testsuite/lib/jit-elf-helpers.exp
> +++ b/gdb/testsuite/lib/jit-elf-helpers.exp
> @@ -13,15 +13,25 @@
> # You should have received a copy of the GNU General Public License
> # along with this program. If not, see <http://www.gnu.org/licenses/>.
>
> +# Magic constants used to calculate a starting address when linking
> +# "jit" shared libraries. When loaded, will be mapped by jit-elf-main
Our standard is to use two spaces after periods in comments and other "prose".
Simon
More information about the Gdb-patches
mailing list