This is the mail archive of the
binutils-cvs@sourceware.org
mailing list for the binutils project.
[binutils-gdb/aoliva/SFN] non-LVU: error if .[su]leb128's operand is undefined
- From: Alexandre Oliva <aoliva at sourceware dot org>
- To: bfd-cvs at sourceware dot org
- Date: 17 Mar 2017 00:08:03 -0000
- Subject: [binutils-gdb/aoliva/SFN] non-LVU: error if .[su]leb128's operand is undefined
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=f07a13fabd8899ff740c7c1fdc19cc74a46ebc38
commit f07a13fabd8899ff740c7c1fdc19cc74a46ebc38
Author: Alexandre Oliva <aoliva@redhat.com>
Date: Sat Mar 11 00:10:11 2017 -0300
non-LVU: error if .[su]leb128's operand is undefined
Diff:
---
gas/testsuite/gas/all/gas.exp | 1 +
gas/testsuite/gas/all/sleb128-9.d | 4 ++++
gas/testsuite/gas/all/sleb128-9.l | 3 +++
gas/testsuite/gas/all/sleb128-9.s | 3 +++
gas/write.c | 7 +++++++
5 files changed, 18 insertions(+)
diff --git a/gas/testsuite/gas/all/gas.exp b/gas/testsuite/gas/all/gas.exp
index 009e68c..c7a3b76 100644
--- a/gas/testsuite/gas/all/gas.exp
+++ b/gas/testsuite/gas/all/gas.exp
@@ -394,6 +394,7 @@ if { ![istarget "tic4x*-*-*"] && ![istarget "tic54x*-*-*"] } {
run_dump_test sleb128-7
run_dump_test sleb128-8
}
+run_dump_test sleb128-9
# .byte is 32 bits on tic4x, and .p2align isn't supported on tic54x
# .space is different on hppa*-hpux.
diff --git a/gas/testsuite/gas/all/sleb128-9.d b/gas/testsuite/gas/all/sleb128-9.d
new file mode 100644
index 0000000..7c88451
--- /dev/null
+++ b/gas/testsuite/gas/all/sleb128-9.d
@@ -0,0 +1,4 @@
+#name: undefined symbols un sleb128 directive
+#source: sleb128-9.s
+#error-output: sleb128-9.l
+#target: *-*-*
diff --git a/gas/testsuite/gas/all/sleb128-9.l b/gas/testsuite/gas/all/sleb128-9.l
new file mode 100644
index 0000000..19842fa
--- /dev/null
+++ b/gas/testsuite/gas/all/sleb128-9.l
@@ -0,0 +1,3 @@
+[^:]*: Assembler messages:
+[^:]*:2: Error: leb128 operand is an undefined symbol: \.Lundef
+[^:]*:3: Error: leb128 operand is an undefined symbol: undef
diff --git a/gas/testsuite/gas/all/sleb128-9.s b/gas/testsuite/gas/all/sleb128-9.s
new file mode 100644
index 0000000..87cb955
--- /dev/null
+++ b/gas/testsuite/gas/all/sleb128-9.s
@@ -0,0 +1,3 @@
+ .data
+ .sleb128 .Lundef
+ .sleb128 undef
diff --git a/gas/write.c b/gas/write.c
index 9a99a0f..24e13d6 100644
--- a/gas/write.c
+++ b/gas/write.c
@@ -2447,6 +2447,13 @@ relax_segment (struct frag *segment_frag_root, segT segment, int pass)
#endif
case rs_leb128:
+ if (pass == 0 && !S_IS_DEFINED (fragP->fr_symbol))
+ {
+ as_bad_where (fragP->fr_file, fragP->fr_line,
+ _("leb128 operand is an undefined symbol: %s"),
+ S_GET_NAME (fragP->fr_symbol));
+ }
+
/* Initial guess is always 1; doing otherwise can result in
stable solutions that are larger than the minimum. */
address += fragP->fr_offset = 1;