diff options
author | Michael Matz <matz@suse.de> | 2022-10-12 17:29:43 +0200 |
---|---|---|
committer | Michael Matz <matz@suse.de> | 2023-01-20 14:58:04 +0100 |
commit | ec15b12d0684b41f67b56623f6e9b5024bf08905 (patch) | |
tree | 1fb4110367f93c99af7e05f0bb4c1ad5f955fbb7 /ld/testsuite/ld-elf/merge4a.c | |
parent | 26ec71f5128af2da9bf859321f388f76ad04dfe0 (diff) | |
download | gdb-ec15b12d0684b41f67b56623f6e9b5024bf08905.zip gdb-ec15b12d0684b41f67b56623f6e9b5024bf08905.tar.gz gdb-ec15b12d0684b41f67b56623f6e9b5024bf08905.tar.bz2 |
Add testcase ld-elf/merge4
to check a situation that once failed with the new section merging
when it mishandled offsets pointing into alignment padding in mergable
string sections (i.e. pointing to zeros). It made bootstrap.exp fail
but that depends on many factors to actually go wrong so this is a more
explicit variant of it.
Diffstat (limited to 'ld/testsuite/ld-elf/merge4a.c')
-rw-r--r-- | ld/testsuite/ld-elf/merge4a.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/ld/testsuite/ld-elf/merge4a.c b/ld/testsuite/ld-elf/merge4a.c new file mode 100644 index 0000000..133303e --- /dev/null +++ b/ld/testsuite/ld-elf/merge4a.c @@ -0,0 +1,23 @@ +extern const char * getstr3(int); +extern int printf (const char *, ...); + +extern const char *addr_of_str; +extern const char *addr_of_str2; + +/* "foobar" needs to be a string literal, so that it's put into + a mergable string section, then merged with the "foobar" from merge4b.s + and then (when the linker is buggy) doesn't cover the additional + nul byte after "foobar" in the asm source (which addr_of_str2 is supposed + to point into. */ +const char * getstr3(int i) +{ + return i ? "blabla" : "foobar"; +} + +int main(void) +{ + printf ("1: %s\n", addr_of_str); + printf ("2: %s\n", addr_of_str2); + printf ("3: %s\n", getstr3(1)); + return 0; +} |