cairo: Fix building with latest libbfd

Backport changes from:
https://github.com/gentoo/gentoo/commit/66be6eece6fb20cd720d5c0490eedfc947c918bc

This fixes building cairo with latest binutils-libs.

BUG=chromium:1092479
TEST=cairo builds

Cq-Depend: chromium:2234737, chromium:2234568, chromium:2234750
Change-Id: I65478df9e7f1a5a286bb4afc326df09d115b1c31
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/overlays/portage-stable/+/2236415
Tested-by: Manoj Gupta <manojgupta@chromium.org>
Commit-Queue: Manoj Gupta <manojgupta@chromium.org>
Reviewed-by: Tiancong Wang <tcwang@google.com>
diff --git a/x11-libs/cairo/cairo-1.14.12.ebuild b/x11-libs/cairo/cairo-1.14.12-r1.ebuild
similarity index 96%
rename from x11-libs/cairo/cairo-1.14.12.ebuild
rename to x11-libs/cairo/cairo-1.14.12-r1.ebuild
index 06a10f1..be75689 100644
--- a/x11-libs/cairo/cairo-1.14.12.ebuild
+++ b/x11-libs/cairo/cairo-1.14.12-r1.ebuild
@@ -64,6 +64,9 @@
 
 src_prepare() {
 	default
+	if has_version ">=sys-libs/binutils-libs-2.34"; then
+		eapply "${FILESDIR}"/${PN}-1.16.0-binutils-2.34.patch
+	fi
 
 	# tests and perf tools require X, bug #483574
 	if ! use X; then
diff --git a/x11-libs/cairo/files/cairo-1.16.0-binutils-2.34.patch b/x11-libs/cairo/files/cairo-1.16.0-binutils-2.34.patch
new file mode 100644
index 0000000..46e20bc
--- /dev/null
+++ b/x11-libs/cairo/files/cairo-1.16.0-binutils-2.34.patch
@@ -0,0 +1,19 @@
+--- a/util/cairo-trace/lookup-symbol.c
++++ b/util/cairo-trace/lookup-symbol.c
+@@ -145,14 +145,14 @@ find_address_in_section (bfd *abfd,
+     if (symbol->found)
+ 	return;
+ 
+-    if ((bfd_get_section_flags (symtab->bfd, section) & SEC_ALLOC) == 0)
++    if ((bfd_section_flags (section) & SEC_ALLOC) == 0)
+ 	return;
+ 
+-    vma = bfd_get_section_vma (symtab->bfd, section);
++    vma = bfd_section_vma (section);
+     if (symbol->pc < vma)
+ 	return;
+ 
+-    size = bfd_section_size (symtab->bfd, section);
++    size = bfd_section_size (section);
+     if (symbol->pc >= vma + size)
+ 	return;