[llvm] [symbolizer] Address starting with a plus sign is valid. (PR #135857)

James Henderson via llvm-commits llvm-commits at lists.llvm.org
Tue May 27 00:49:37 PDT 2025


jh7370 wrote:

> This change does not add any new capabilities; it is purely syntactic sugar. Syntactic sugar is OK when it provides additional convenience, such as shorter commands or improved readability. Typically, there is no intention to merely expand the set of allowed constructs without clear benefits.
> 
> Addresses, by their nature, are unsigned. Using a plus sign in address specifications does not seem useful. Supporting unnecessary syntax may even introduce errors. For example, if a script invokes `llvm-symbolizer` with arguments like `$BASE+1234`, and the script doesn't define $BASE due to an error, the address would resolve to +1234. In the original implementation, this would raise an error, but with this change, it could output garbage instead.
> 
> Before adopting this patch, we need understand how this change could be useful.

@da-viper has already highlighted that GNU addr2line supports this syntax. As we broadly aim for binary tools to be compatible with GNU tools where possible, we should accept this syntax too. The usefulness is that it then allows LLVM tools to be used as drop-in replacements for GNU tools in more cases. I will start properly reviewing this in a couple of weeks, if I don't get to it sooner.

> Addresses, by their nature, are unsigned.

Aside: while I suspect this is true for all architectures LLVM supports, it's not an inherent requirement. Imagine an architecture where the address values are mapped one-to-one with physical elements in a memory array. There's nothing stopping the maker of that architecture labelling the "middle" one as value 0, therefore necessitating negative addresses.

https://github.com/llvm/llvm-project/pull/135857


More information about the llvm-commits mailing list