diff options
author | Fangrui Song <i@maskray.me> | 2022-04-08 14:06:36 -0700 |
---|---|---|
committer | Fangrui Song <i@maskray.me> | 2022-04-08 14:06:36 -0700 |
commit | a3a7f5e1586467b137b8dcdcd2f74f5efa9f3919 (patch) | |
tree | d1191266bf9f698ae50ecdb69d3581c482a8b0aa /gas | |
parent | 9f184a64f51b00fd5c208c8528f6a553f5b27c1c (diff) | |
download | gdb-a3a7f5e1586467b137b8dcdcd2f74f5efa9f3919.zip gdb-a3a7f5e1586467b137b8dcdcd2f74f5efa9f3919.tar.gz gdb-a3a7f5e1586467b137b8dcdcd2f74f5efa9f3919.tar.bz2 |
gas: Port "copy st_size only if unset" to aarch64 and riscv
And disable the new test gas/elf/size.s for alpha which uses its own
.set, for hppa*-*-hpux* which does not allow .size before declaration.
Diffstat (limited to 'gas')
-rw-r--r-- | gas/config/tc-aarch64.c | 20 | ||||
-rw-r--r-- | gas/config/tc-riscv.c | 21 | ||||
-rw-r--r-- | gas/testsuite/gas/elf/size.d | 2 |
3 files changed, 22 insertions, 21 deletions
diff --git a/gas/config/tc-aarch64.c b/gas/config/tc-aarch64.c index cbebc6b..dee7d19 100644 --- a/gas/config/tc-aarch64.c +++ b/gas/config/tc-aarch64.c @@ -10469,17 +10469,17 @@ aarch64_elf_copy_symbol_attributes (symbolS *dest, symbolS *src) { struct elf_obj_sy *srcelf = symbol_get_obj (src); struct elf_obj_sy *destelf = symbol_get_obj (dest); - if (srcelf->size) + /* If size is unset, copy size from src. Because we don't track whether + .size has been used, we can't differentiate .size dest, 0 from the case + where dest's size is unset. */ + if (!destelf->size && S_GET_SIZE (dest) == 0) { - if (destelf->size == NULL) - destelf->size = XNEW (expressionS); - *destelf->size = *srcelf->size; - } - else - { - free (destelf->size); - destelf->size = NULL; + if (srcelf->size) + { + destelf->size = XNEW (expressionS); + *destelf->size = *srcelf->size; + } + S_SET_SIZE (dest, S_GET_SIZE (src)); } - S_SET_SIZE (dest, S_GET_SIZE (src)); } #endif diff --git a/gas/config/tc-riscv.c b/gas/config/tc-riscv.c index bb5f6e4..fb3fc64 100644 --- a/gas/config/tc-riscv.c +++ b/gas/config/tc-riscv.c @@ -4540,19 +4540,18 @@ riscv_elf_copy_symbol_attributes (symbolS *dest, symbolS *src) { struct elf_obj_sy *srcelf = symbol_get_obj (src); struct elf_obj_sy *destelf = symbol_get_obj (dest); - if (srcelf->size) + /* If size is unset, copy size from src. Because we don't track whether + .size has been used, we can't differentiate .size dest, 0 from the case + where dest's size is unset. */ + if (!destelf->size && S_GET_SIZE (dest) == 0) { - if (destelf->size == NULL) - destelf->size = XNEW (expressionS); - *destelf->size = *srcelf->size; - } - else - { - if (destelf->size != NULL) - free (destelf->size); - destelf->size = NULL; + if (srcelf->size) + { + destelf->size = XNEW (expressionS); + *destelf->size = *srcelf->size; + } + S_SET_SIZE (dest, S_GET_SIZE (src)); } - S_SET_SIZE (dest, S_GET_SIZE (src)); } /* RISC-V pseudo-ops table. */ diff --git a/gas/testsuite/gas/elf/size.d b/gas/testsuite/gas/elf/size.d index 51bf4eb..5890386 100644 --- a/gas/testsuite/gas/elf/size.d +++ b/gas/testsuite/gas/elf/size.d @@ -1,5 +1,7 @@ #readelf: -sW #name: ELF symbol size +#notarget: alpha-*-* hppa*-*-hpux* +# The Alpha target uses its own .set pseudo-insn. #... +[0-9]+: 0+ +1 +NOTYPE +LOCAL +DEFAULT +[0-9]+ +foo1 |