diff --git a/.gitattributes b/.gitattributes
index 7bd6ee155b..6a9433f00f 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -9634,6 +9634,9 @@ tests/test/cg/variants/tvarol96.pp svneol=native#text/plain
 tests/test/dumpclass.pp svneol=native#text/plain
 tests/test/dumpmethods.pp svneol=native#text/plain
 tests/test/lcpref.inc svneol=native#text/plain
+tests/test/library/tlib1a.pp svneol=native#text/plain
+tests/test/library/tlib1a2.pp svneol=native#text/plain
+tests/test/library/tlib1b.pp svneol=native#text/plain
 tests/test/opt/README.txt svneol=native#text/plain
 tests/test/opt/tarmshift.pp svneol=native#text/plain
 tests/test/opt/tcaseopt1.pp svneol=native#text/plain
diff --git a/tests/test/library/tlib1a.pp b/tests/test/library/tlib1a.pp
new file mode 100644
index 0000000000..29173b610b
--- /dev/null
+++ b/tests/test/library/tlib1a.pp
@@ -0,0 +1,14 @@
+{ %skiptarget=go32v2 }
+{ %norun }
+{$goto on}
+library tlib1a;
+
+  procedure p(var a : dword);
+    begin
+      a:=1;
+    end;
+
+  exports p;
+
+begin
+end.
diff --git a/tests/test/library/tlib1a2.pp b/tests/test/library/tlib1a2.pp
new file mode 100644
index 0000000000..58ff18471e
--- /dev/null
+++ b/tests/test/library/tlib1a2.pp
@@ -0,0 +1,14 @@
+{ %skiptarget=go32v2 }
+{ %norun }
+{$goto on}
+library tlib1a2;
+
+  procedure p(var a : dword);
+    begin
+      a:=2;
+    end;
+
+  exports p;
+
+begin
+end.
diff --git a/tests/test/library/tlib1b.pp b/tests/test/library/tlib1b.pp
new file mode 100644
index 0000000000..d0afd16b9e
--- /dev/null
+++ b/tests/test/library/tlib1b.pp
@@ -0,0 +1,31 @@
+{ %skiptarget=go32v2 }
+{ %needlibrary }
+{$goto on}
+
+
+{ Checks that the two functions with the same exported name 'p'
+  are each loaded correctly. }
+uses
+  {$ifdef unix}dl,{$endif unix}sysutils;
+
+{$ifdef darwin}
+{$linklib tlib1a}
+{$linklib tlib1a2}
+{$endif darwin}
+
+procedure p(var a : dword);external 'tlib1a' name 'p';
+procedure p2(var a : dword);external 'tlib1a2' name 'p';
+
+var
+  a : dword;
+begin
+  a:=0;
+  p(a);
+  if a <> 1 then
+    halt(1);
+  p2(a);
+  if a <> 2 then
+    halt(2);
+
+  writeln('ok');
+end.