Both bfd and gold accept:
foo = 1K;
bar = 1M;
zed = 1H;
And lowercase forms: k, m, h.
Patch adds support for that.
Differential D24194
[ELF] - Linkerscript: add support for suffixes in numbers. Authored by grimar on Sep 2 2016, 7:46 AM.
Details Both bfd and gold accept: And lowercase forms: k, m, h.
Diff Detail Event Timeline
Comment Actions LGTM with this change.
| |||||||||||||||
Something's not right with this function. You seems to be mixing two different concepts, base and multiplier in this function, which confused me while reading this code. You cannot use K/M suffixes for hex numbers, so hex numbers should be handled first.
The code should be something like this.
if (Tok.startswith_lower("0x")) return Tok.substr(2).getAsInteger(16, Result); if (Tok.endswith_lower("H")) return Tok.drop_back().getAsInteger(16, Result); int Suffix = 1; if (Tok.endswith_lower("K")) { Suffix = 1024; Tok = Tok.drop_back(); } else if (Tok.endswith_lower("M")) { Suffix = 1024 * 1024; Tok = Tok.drop_back(); } if (Tok.getAsInteger(10, Result)) return false; Result *= Suffix; return true;