Merge branch 'linus' into perf/core, to fix conflicts
[linux-2.6-microblaze.git] / tools / perf / util / annotate.c
index 0816416..da1c4c4 100644 (file)
@@ -605,9 +605,19 @@ static struct arch *arch__find(const char *name)
 int symbol__alloc_hist(struct symbol *sym)
 {
        struct annotation *notes = symbol__annotation(sym);
-       const size_t size = symbol__size(sym);
+       size_t size = symbol__size(sym);
        size_t sizeof_sym_hist;
 
+       /*
+        * Add buffer of one element for zero length symbol.
+        * When sample is taken from first instruction of
+        * zero length symbol, perf still resolves it and
+        * shows symbol name in perf report and allows to
+        * annotate it.
+        */
+       if (size == 0)
+               size = 1;
+
        /* Check for overflow when calculating sizeof_sym_hist */
        if (size > (SIZE_MAX - sizeof(struct sym_hist)) / sizeof(struct sym_hist_entry))
                return -1;